/*
Default Setup:

<script language="JavaScript">
TargetDate = "01/01/2050 12:00:00 AM";
BackgroundColor = "#FFFFFF";
TextColor = "#F60400";
CounterGo = true;
CounterStep = -1;
LeadZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
EndMessage = "It is finally here!";
</script>
<script language="JavaScript" src="http://www.mattrauch.com/scripts/countdown0.js"></script>
*/

function calctime0(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadZero0 && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountDown0(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn0").innerHTML = EndMessage0;
    return;
  }
  DisplayStr0 = DisplayFormat0.replace(/%%D%%/g, calctime0(secs,86400,100000));
  DisplayStr0 = DisplayStr0.replace(/%%H%%/g, calctime0(secs,3600,24));
  DisplayStr0 = DisplayStr0.replace(/%%M%%/g, calctime0(secs,60,60));
  DisplayStr0 = DisplayStr0.replace(/%%S%%/g, calctime0(secs,1,60));

  document.getElementById("cntdwn0").innerHTML = DisplayStr0;
  if (CounterGo0)
    setTimeout("CountDown0(" + (secs+CounterStep0) + ")", SetTimeOutPeriod0);
}

function putspan0(BackgroundColor0, textColor0) {
 document.write("<span id='cntdwn0' style='background-color:" + BackgroundColor0 + 
                "; color:" + TextColor0 + "'></span>");
}

if (typeof(BackgroundColor0)=="undefined")
  BackgroundColor0 = "#FFFFFF";
if (typeof(TextColor0)=="undefined")
  TextColor0= "#F60400";
if (typeof(TargetDate0)=="undefined")
  TargetDate0 = "01/01/2050 4:59:59 PM";
if (typeof(DisplayFormat0)=="undefined")
  DisplayFormat0 = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CounterGo0)=="undefined")
  CounterGo0 = true;
if (typeof(EndMessage0)=="undefined")
  EndMessage0 = "";
if (typeof(CounterStep0)!="number")
  CounterStep0 = -1;
if (typeof(LeadZero0)=="undefined")
  LeadZero0 = true;

CounterStep0 = Math.ceil(CounterStep0);
if (CounterStep0 == 0)
  CounterGo0 = false;
var SetTimeOutPeriod0 = (Math.abs(CounterStep0)-1)*1000 + 990;
putspan0(BackgroundColor0, TextColor0);
var dthen0 = new Date(TargetDate0);
var dnow0 = new Date();
if(CounterStep0>0)
  ddiff = new Date(dnow0-dthen0);
else
  ddiff = new Date(dthen0-dnow0);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountDown0(gsecs);
