
function f1_calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (f1_LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function f1_CountBack(secs) {
  if (secs < 0) {
    document.getElementById("f1_cntdwn").innerHTML = FinishMessage;
    return;
  }

DisplayStr = f1_DisplayFormatDays.replace(/%%f1_D%%/g, f1_calcage(secs,86400,100000));
document.getElementById("f1_d1").innerHTML = DisplayStr;
document.getElementById("f1_d2").innerHTML = "D ";

DisplayStr = f1_DisplayFormatHours.replace(/%%f1_H%%/g, f1_calcage(secs,3600,24));
document.getElementById("f1_h1").innerHTML = DisplayStr;
document.getElementById("f1_h2").innerHTML = "H ";

DisplayStr = f1_DisplayFormatMinutes.replace(/%%f1_M%%/g, f1_calcage(secs,60,60));
document.getElementById("f1_m1").innerHTML = DisplayStr;
document.getElementById("f1_m2").innerHTML = "M ";

DisplayStr = f1_DisplayFormatSeconds.replace(/%%f1_S%%/g, f1_calcage(secs,1,60));
document.getElementById("f1_s1").innerHTML = DisplayStr;
document.getElementById("f1_s2").innerHTML = "S";

  if (f1_CountActive)
    setTimeout("f1_CountBack(" + (secs+f1_CountStepper) + ")", f1_SetTimeOutPeriod);
}

function f1_putspan(backcolor, forecolor) {
 document.write("<span id='f1_d1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='f1_d2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal; '></span>");
 document.write("<span id='f1_h1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='f1_h2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'></span>");
 document.write("<span id='f1_m1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='f1_m2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'></span>");
 document.write("<span id='f1_s1' style='font-family: HelviticaBlack-T&M; font-size: 18px;  font-weight: bold;  font-style: italic; height: 20px'></span>");
 document.write("<span id='f1_s2' style='font-family: HelviticaBlack-T&M; font-size: 8px;  font-weight: regular;  font-style: normal;'> </span>");
}

if (typeof(f1_BackColor)=="undefined")
  f1_BackColor = "white";
if (typeof(f1_ForeColor)=="undefined")
  f1_ForeColor= "black";
if (typeof(f1_TargetDate)=="undefined") 
  f1_TargetDate = "12/31/2009 5:00 AM";


if (typeof(f1_DisplayFormat)=="undefined")
  f1_DisplayFormat = "%%f1_D%% f1_Days, %%f1_H%% f1_Hours, %%f1_M%% f1_Minutes, %%f1_S%% f1_Seconds.";
if (typeof(f1_CountActive)=="undefined")
  f1_CountActive = true;
if (typeof(f1_FinishMessage)=="undefined")
  f1_FinishMessage = "";
if (typeof(f1_CountStepper)!="number")
  f1_CountStepper = -1;
if (typeof(f1_LeadingZero)=="undefined")
  f1_LeadingZero = true;
if (typeof(f1_DisplayFormatDays)=="undefined")
  f1_DisplayFormatDays = "%%f1_D%%";
if (typeof(f1_DisplayFormatHours)=="undefined")
  f1_DisplayFormatHours = "%%f1_H%%";
if (typeof(f1_DisplayFormatMinutes)=="undefined")
  f1_DisplayFormatMinutes = "%%f1_M%%";
if (typeof(f1_DisplayFormatSeconds)=="undefined")
  f1_DisplayFormatSeconds = "%%f1_S%%";


f1_CountStepper = Math.ceil(f1_CountStepper);
if (f1_CountStepper == 0)
  f1_CountActive = false;
var f1_SetTimeOutPeriod = (Math.abs(f1_CountStepper)-1)*1000 + 990;
f1_putspan(f1_BackColor, f1_ForeColor);
var f1_dthen = new Date(f1_TargetDate);
var f1_dnow = new Date();
if(f1_CountStepper>0)
  ddiff = new Date(f1_dnow-f1_dthen);
else
  ddiff = new Date(f1_dthen-f1_dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
f1_CountBack(gsecs);

