// Generates and updates a countdown timer

// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com

// Created by DendE PhisH

function getTime(digitSetName, targetDateTime) {
c1 = new Image(); c1.src = "http://www.brisbears.org.au/images/digits/1" + digitSetName + ".GIF";
c2 = new Image(); c2.src = "http://www.brisbears.org.au/images/digits/2" + digitSetName + ".GIF";
c3 = new Image(); c3.src = "http://www.brisbears.org.au/images/digits/3" + digitSetName + ".GIF";
c4 = new Image(); c4.src = "http://www.brisbears.org.au/images/digits/4" + digitSetName + ".GIF";
c5 = new Image(); c5.src = "http://www.brisbears.org.au/images/digits/5" + digitSetName + ".GIF";
c6 = new Image(); c6.src = "http://www.brisbears.org.au/images/digits/6" + digitSetName + ".GIF";
c7 = new Image(); c7.src = "http://www.brisbears.org.au/images/digits/7" + digitSetName + ".GIF";
c8 = new Image(); c8.src = "http://www.brisbears.org.au/images/digits/8" + digitSetName + ".GIF";
c9 = new Image(); c9.src = "http://www.brisbears.org.au/images/digits/9" + digitSetName + ".GIF";
c0 = new Image(); c0.src = "http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF";
now = new Date();

//ENTER BELOW THE DATE YOU WISH TO COUNTDOWN TO
//later = new Date("Oct 18 2007 19:00:00");
later = new Date(targetDateTime);

if (later < now)
{
	later = now
}

days = (later - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (later - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (later - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (later - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);

if (secondsRound <= 9) {
document.images.g.src = c0.src;
document.images.h.src = eval("c"+secondsRound+".src");
}
else {
document.images.g.src = eval("c"+Math.floor(secondsRound/10)+".src");
document.images.h.src = eval("c"+(secondsRound%10)+".src");
}
if (minutesRound <= 9) {
document.images.d.src = c0.src;
document.images.e.src = eval("c"+minutesRound+".src");
}
else {
document.images.d.src = eval("c"+Math.floor(minutesRound/10)+".src");
document.images.e.src = eval("c"+(minutesRound%10)+".src");
}
if (hoursRound <= 9) {
document.images.y.src = c0.src;
document.images.z.src = eval("c"+hoursRound+".src");
}
else {
document.images.y.src = eval("c"+Math.floor(hoursRound/10)+".src");
document.images.z.src = eval("c"+(hoursRound%10)+".src");
}
if (daysRound <= 9) {
document.images.a.src = c0.src;
document.images.b.src = eval("c"+daysRound+".src");
}
if (daysRound <= 99) {
document.images.a.src = eval("c"+Math.floor((daysRound/10)%10)+".src");
document.images.b.src = eval("c"+Math.floor(daysRound%10)+".src");
}
if (daysRound <= 999){
document.images.a.src = eval("c"+Math.floor((daysRound/10)%10)+".src");
document.images.b.src = eval("c"+Math.floor(daysRound%10)+".src");
}
newtime = window.setTimeout("getTime('" + digitSetName + "', '" + targetDateTime + "');", 1000);

}


function insertCountdown(digitSetName)
{
	//document.write('<table border="0"><tr><td bgcolor="black" valign="bottom">');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=a align="top">');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=b align="top">');
	//document.write('<img src="http://www.brisbears.org.au/images/digits/COLON_COMPUTE.GIF" name=sep1>');
	document.write('&nbsp;Days&nbsp;');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + "E.GIF" name=y align="top">');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=z align="top">');
	document.write('&nbsp;Hours&nbsp;');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=d align="top">');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=e align="top">');
	document.write('&nbsp;Minutes&nbsp;');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=g align="top">');
	document.write('<img src="http://www.brisbears.org.au/images/digits/0" + digitSetName + ".GIF" name=h align="top">');
	document.write('&nbsp;Seconds&nbsp;');
	//document.write('</td></tr></table>');
}