
var sPath = "../Images/"
var aNum = new Array()
aNum[0] = new Image(16,21); aNum[0].src = sPath + "0.gif"
aNum[1] = new Image(16,21); aNum[1].src = sPath + "1.gif"
aNum[2] = new Image(16,21); aNum[2].src = sPath + "2.gif"
aNum[3] = new Image(16,21); aNum[3].src = sPath + "3.gif"
aNum[4] = new Image(16,21); aNum[4].src = sPath + "4.gif"
aNum[5] = new Image(16,21); aNum[5].src = sPath + "5.gif"
aNum[6] = new Image(16,21); aNum[6].src = sPath + "6.gif"
aNum[7] = new Image(16,21); aNum[7].src = sPath + "7.gif"
aNum[8] = new Image(16,21); aNum[8].src = sPath + "8.gif"
aNum[9] = new Image(16,21); aNum[9].src = sPath + "9.gif"

function startTimer() {
	setInterval("updateClock()", 100)
}

function updateClock() {
// set today's date and the target date to which we are counting down
// to set targetDate properly, the format is (year, month, day, hh, mm)
// for the month parameter, Jan = 00, Feb = 01, Mar = 02, ... Dec = 11.
	var today = new Date();
	var targetDate = new Date(2010, 09, 23, 14, 00);

// only perform the countdown functions if we have not yet reached the target date
	if (today.getTime() < targetDate.getTime()) {

// get the offset in hours between GMT and today's time and GMT and the target time.
// use the offset to determeine if our date range spans the changeover from Standard Time to Daylight Time or vice versa.
// include the Standard/Daylight difference in milliseconds in the calculated difference between today and the target date.
		var todayTimeZoneOffset = ( today.getTimezoneOffset() / 60 ) ;
		var targetDateTimeZoneOffset = ( targetDate.getTimezoneOffset() / 60 ) ;
		var standardDaylightOffset = ( todayTimeZoneOffset - targetDateTimeZoneOffset ) * 3600000 ;

// nDifference holds the difference between the current date and the target date in milliseconds with an offset for Standard/Daylight time
		var nDifference = ( targetDate.getTime() - today.getTime() ) + standardDaylightOffset ;

// get the difference in days and display the appropriate numbers on the clock
		var nDays = Math.floor(nDifference / (1000 * 60 * 60 * 24));
		if (nDays >= 100) {
			var sDays = nDays.toString()
			var sDays1 = sDays.charAt(0)
			document.Days1.src = aNum[parseInt(sDays1)].src
			var sDays2 = sDays.charAt(1)
			document.Days2.src = aNum[parseInt(sDays2)].src
			var sDays3 = sDays.charAt(2)
			document.Days3.src = aNum[parseInt(sDays3)].src
		} else if (nDays >= 10) {
			document.Days1.src = aNum[0].src
			var sDays = nDays.toString()
			var sDays2 = sDays.charAt(0)
			document.Days2.src = aNum[parseInt(sDays2)].src
			var sDays3 = sDays.charAt(1)
			document.Days3.src = aNum[parseInt(sDays3)].src
		} else {
			document.Days1.src = aNum[0].src
			document.Days2.src = aNum[0].src
			document.Days3.src = aNum[nDays].src
		}

// get the difference in hours and display the appropriate numbers on the clock
		var nHours = Math.floor(nDifference / (1000 * 60 * 60)) - (nDays * 24);
		if (nHours >= 10) {
			var sHours = nHours.toString()
			var sHours1 = sHours.charAt(0)
			document.Hours1.src = aNum[parseInt(sHours1)].src
			var sHours2 = sHours.charAt(1)
			document.Hours2.src = aNum[parseInt(sHours2)].src
		} else {
			document.Hours1.src = aNum[0].src
			document.Hours2.src = aNum[nHours].src
		}

// get the difference in minutes and display the appropriate numbers on the clock
		var nMinutes = Math.floor(nDifference / (1000 * 60)) - (nDays * 60 * 24) - (nHours * 60);
		if (nMinutes >= 10) {
			var sMinutes = nMinutes.toString()
			var sMinutes1 = sMinutes.charAt(0)
			document.Minutes1.src = aNum[parseInt(sMinutes1)].src
			var sMinutes2 = sMinutes.charAt(1)
			document.Minutes2.src = aNum[parseInt(sMinutes2)].src
		} else {
			document.Minutes1.src = aNum[0].src
			document.Minutes2.src = aNum[nMinutes].src
		}

// get the difference in seconds and display the appropriate numbers on the clock
		var nSeconds = Math.floor(nDifference / 1000) - (nDays * 60 * 60 * 24) - (nHours * 60 * 60) - (nMinutes * 60);
		if (nSeconds >= 10) {
			var sSeconds = nSeconds.toString()
			var sSeconds1 = sSeconds.charAt(0)
			document.Seconds1.src = aNum[parseInt(sSeconds1)].src
			var sSeconds2 = sSeconds.charAt(1)
			document.Seconds2.src = aNum[parseInt(sSeconds2)].src
		} else {
			document.Seconds1.src = aNum[0].src
			document.Seconds2.src = aNum[nSeconds].src
		}

// get the difference in tenths of seconds and display the appropriate numbers on the clock
		var nTenthSeconds = Math.floor(nDifference / 100) - (nDays * 10 * 60 * 60 * 24) - (nHours * 10 * 60 * 60) - (nMinutes * 10 * 60) - (nSeconds * 10);
		var sTenthSeconds = nTenthSeconds.toString()
		var sTenthSeconds = sTenthSeconds.charAt(0)
		document.TenthSeconds.src = aNum[parseInt(sTenthSeconds)].src
	} else {
		document.Days1.src = aNum[0].src
		document.Days2.src = aNum[0].src
		document.Days3.src = aNum[0].src
		document.Hours1.src = aNum[0].src
		document.Hours2.src = aNum[0].src
		document.Minutes1.src = aNum[0].src
		document.Minutes2.src = aNum[0].src
		document.Seconds1.src = aNum[0].src
		document.Seconds2.src = aNum[0].src
		document.TenthSeconds.src = aNum[0].src
	}
}
