function Countdown(TargetElement, TargetDate, ServerDate, CustomHeading)
{
	this.TargetElement = TargetElement;
	this.CountActive = true;
	this.DisplayFormat = (CustomHeading ? CustomHeading : "Offer ends:")+ " %%D%%d %%H%%h %%M%%m %%S%%s";
	this.FinishMessage = "";
	this.SetTimeOutPeriod = 1000;
	this.dthen = new Date(TargetDate);
	
	this.calcage = function calcage(secs, num1, num2)
	{
	  s = ((Math.floor(secs/num1))%num2).toString();
	  if (s.length < 2)
	    s = "0" + s;
	  return s;
	}
	
	this.CountBack = function CountBack(secs) 
	{
	  if (secs < 0) 
	  {
	    //document.getElementById(this.TargetElement).innerHTML = this.FinishMessage;
	    top.location.reload();
	    return;
	  }
	  var daysleft = this.calcage(secs,86400,100000);
	  if(daysleft)
	  	DisplayStr = this.DisplayFormat.replace(/%%D%%/g, daysleft);
	  else
	  	DisplayStr = this.DisplayFormat.replace(/%%D%%d.?/g, "");
	  DisplayStr = DisplayStr.replace(/%%H%%/g, this.calcage(secs,3600,24));
	  DisplayStr = DisplayStr.replace(/%%M%%/g, this.calcage(secs,60,60));
	  DisplayStr = DisplayStr.replace(/%%S%%/g, this.calcage(secs,1,60));
	  	
	  document.getElementById(TargetElement).innerHTML = DisplayStr;
      setTimeout("c.CountBack(" + (secs-1) + ")", 1000);
	}
	var dnow = new Date();
	if(ServerDate)
		dnow = new Date(ServerDate);
	ddiff = new Date(this.dthen-dnow);
	gsecs = Math.floor(ddiff.valueOf()/1000);
	
	if(gsecs)
		this.CountBack(gsecs);
}