
function a1_calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (a1_LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function a1_CountBack(secs) {
  if (secs < 0) {
    document.getElementById("a1_cntdwn").innerHTML = FinishMessage;
    return;
  }

DisplayStr = a1_DisplayFormatDays.replace(/%%D%%/g, a1_calcage(secs,86400,100000));
document.getElementById("a1_d1").innerHTML = DisplayStr;
document.getElementById("a1_d2").innerHTML = "D ";

DisplayStr = a1_DisplayFormatHours.replace(/%%H%%/g, a1_calcage(secs,3600,24));
document.getElementById("a1_h1").innerHTML = DisplayStr;
document.getElementById("a1_h2").innerHTML = "H ";

DisplayStr = a1_DisplayFormatMinutes.replace(/%%M%%/g, a1_calcage(secs,60,60));
document.getElementById("a1_m1").innerHTML = DisplayStr;
document.getElementById("a1_m2").innerHTML = "M ";

DisplayStr = a1_DisplayFormatSeconds.replace(/%%S%%/g, a1_calcage(secs,1,60));
document.getElementById("a1_s1").innerHTML = DisplayStr;
document.getElementById("a1_s2").innerHTML = "S";

  if (a1_CountActive)
    setTimeout("a1_CountBack(" + (secs+a1_CountStepper) + ")", a1_SetTimeOutPeriod);
}

function a1_putspan(backcolor, forecolor) {
 document.write("<span id='a1_d1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic;height: 20px'></span>");
 document.write("<span id='a1_d2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal; '></span>");
 document.write("<span id='a1_h1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='a1_h2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'></span>");
 document.write("<span id='a1_m1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='a1_m2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'></span>");
 document.write("<span id='a1_s1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='a1_s2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'> </span>");
}



if (typeof(a1_BackColor)=="undefined")
  a1_BackColor = "white";
if (typeof(a1_ForeColor)=="undefined")
  a1_ForeColor= "black";
if (typeof(a1_TargetDate)=="undefined")
  a1_TargetDate = "12/31/2009 5:00 AM";
if (typeof(a1_DisplayFormat)=="undefined")
  a1_DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(a1_CountActive)=="undefined")
  a1_CountActive = true;
if (typeof(a1_FinishMessage)=="undefined")
  a1_FinishMessage = "";
if (typeof(a1_CountStepper)!="number")
  a1_CountStepper = -1;
if (typeof(a1_LeadingZero)=="undefined")
  a1_LeadingZero = true;
if (typeof(a1_DisplayFormatDays)=="undefined")
  a1_DisplayFormatDays = "%%D%%";
if (typeof(a1_DisplayFormatHours)=="undefined")
  a1_DisplayFormatHours = "%%H%%";
if (typeof(a1_DisplayFormatMinutes)=="undefined")
  a1_DisplayFormatMinutes = "%%M%%";
if (typeof(a1_DisplayFormatSeconds)=="undefined")
  a1_DisplayFormatSeconds = "%%S%%";






a1_CountStepper = Math.ceil(a1_CountStepper);
if (a1_CountStepper == 0)
  a1_CountActive = false;
var a1_SetTimeOutPeriod = (Math.abs(a1_CountStepper)-1)*1000 + 990;
a1_putspan(a1_BackColor, a1_ForeColor);
var dthen = new Date(a1_TargetDate);
var dnow = new Date();
if(a1_CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
a1_CountBack(gsecs);
