var CountStepper = -1;
var CountActive = true;
function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
// if (s.length < 2)
// s = "0" + s;
return s;
}
function CountBack(secs) {
if (secs < 0) {
if (DisplayLink) {
document.getElementById("cntdwn").innerHTML = "" + FinishURL + "";
} else {
window.location.href=FinishURL;
};
return;
}
if (calcage(secs,86400,100000)>0) {
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000) + ' Days');
} else {
DisplayStr = DisplayFormat.replace(/%%D%%/g, '');
};
if (calcage(secs,3600,24)>0) {
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24) + ' Hours');
} else {
DisplayStr = DisplayStr.replace(/%%H%%/g, '');
};
if (calcage(secs,60,60)>0) {
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60) + ' Minutes');
} else {
DisplayStr = DisplayStr.replace(/%%M%%/g, '');
};
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60) + ' Seconds');
if (CountActive) {
document.getElementById("cntdwn").innerHTML = DisplayStr;
setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}
}
function putspan() {
document.write("");
}
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishURL)=="undefined")
FinishURL = "http://www.google.com";
if (typeof(CountStepper)!="number")
CountStepper = -1;
CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan();
var dthen = new Date(TargetDate);
var dnow = new Date();
if (GMTtimeZONE) {
var ms = dnow.getTime() + dnow.getTimezoneOffset() * 60000 + TimezoneOffset * 3600000;
var dnow = new Date(ms);
};
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);