/*
Default Setup:

<script language="JavaScript">
TargetDate1 = "01/01/2050 12:00:00 AM";
BackgroundColor1 = "#FFFFFF";
TextColor1 = "#F60400";
CounterGo1 = true;
CounterStep1 = -1;
LeadZero1 = true;
DisplayFormat1 = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
EndMessage1 = "It is finally here!";
</script>
<script language="JavaScript" src="http://www.mattrauch.com/scripts/countdown1.js"></script>
*/





function calctime1(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadZero1 && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountDown1(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn1").innerHTML = EndMessage1;
    return;
  }
  DisplayStr1 = DisplayFormat1.replace(/%%D%%/g, calctime1(secs,86400,100000));
  DisplayStr1 = DisplayStr1.replace(/%%H%%/g, calctime1(secs,3600,24));
  DisplayStr1 = DisplayStr1.replace(/%%M%%/g, calctime1(secs,60,60));
  DisplayStr1 = DisplayStr1.replace(/%%S%%/g, calctime1(secs,1,60));

  document.getElementById("cntdwn1").innerHTML = DisplayStr1;
  if (CounterGo1)
    setTimeout("CountDown1(" + (secs+CounterStep1) + ")", SetTimeOutPeriod1);
}

function putspan1(BackgroundColor1, textColor1) {
 document.write("<span id='cntdwn1' style='background-color:" + BackgroundColor1 + 
                "; color:" + TextColor1 + "'></span>");
}

if (typeof(BackgroundColor1)=="undefined")
  BackgroundColor1 = "#FFFFFF";
if (typeof(TextColor1)=="undefined")
  TextColor1= "#F60400";
if (typeof(TargetDate1)=="undefined")
  TargetDate1 = "01/01/2050 12:00:00 AM";
if (typeof(DisplayFormat1)=="undefined")
  DisplayFormat1 = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CounterGo1)=="undefined")
  CounterGo1 = true;
if (typeof(EndMessage1)=="undefined")
  EndMessage1 = "";
if (typeof(CounterStep1)!="number")
  CounterStep1 = -1;
if (typeof(LeadZero1)=="undefined")
  LeadZero1 = true;

CounterStep1 = Math.ceil(CounterStep1);
if (CounterStep1 == 0)
  CounterGo1 = false;
var SetTimeOutPeriod1 = (Math.abs(CounterStep1)-1)*1000 + 990;
putspan1(BackgroundColor1, TextColor1);
var dthen1 = new Date(TargetDate1);
var dnow1 = new Date();
if(CounterStep1>0)
  ddiff = new Date(dnow1-dthen1);
else
  ddiff = new Date(dthen1-dnow1);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountDown1(gsecs);
