function xToGo (Seconds, returnDivider, returnBase) { //--- Converts the number of seconds to the number of X return ((Math.floor (Seconds / returnDivider)) % returnBase); } function zeros (Value, NumZeros) { //--- Adds zeros to the beginning of the string if (Value.length < NumZeros) { tLength = Value.length; for (i = tLength; i < NumZeros; i++) { Value = '0' + Value; } } return Value; } function GetCountDown () { //--- Returns the countdown element as an array var TargetTime = new Date (TargetDate); var TodaysDate = new Date (); var Difference = new Date (TargetTime - TodaysDate); var SecsNum = Math.floor (Difference.valueOf () / 1000); var DaysNum = xToGo (SecsNum, 86400, 100000); SecsNum -= (DaysNum * 86400); var HourNum = xToGo (SecsNum, 3600, 24); SecsNum -= (HourNum * 3600); var MinsNum = xToGo (SecsNum, 60, 60); SecsNum -= (MinsNum * 60); var DaysStr = zeros (DaysNum.toString (), 3); var HourStr = zeros (HourNum.toString (), 2); var MinsStr = zeros (MinsNum.toString (), 2); var SecsStr = zeros (SecsNum.toString (), 2); return [DaysStr, HourStr, MinsStr, SecsStr]; } function updateClock () { //--- Updates the clock every second var XCountDown = GetCountDown (); document.getElementById ('DaysStr1').src = 'images/countdown_' + XCountDown[0].substr (0, 1) + '.gif'; document.getElementById ('DaysStr2').src = 'images/countdown_' + XCountDown[0].substr (1, 1) + '.gif'; document.getElementById ('DaysStr3').src = 'images/countdown_' + XCountDown[0].substr (2, 1) + '.gif'; document.getElementById ('HourStr1').src = 'images/countdown_' + XCountDown[1].substr (0, 1) + '.gif'; document.getElementById ('HourStr2').src = 'images/countdown_' + XCountDown[1].substr (1, 1) + '.gif'; document.getElementById ('MinsStr1').src = 'images/countdown_' + XCountDown[2].substr (0, 1) + '.gif'; document.getElementById ('MinsStr2').src = 'images/countdown_' + XCountDown[2].substr (1, 1) + '.gif'; document.getElementById ('SecsStr1').src = 'images/countdown_' + XCountDown[3].substr (0, 1) + '.gif'; document.getElementById ('SecsStr2').src = 'images/countdown_' + XCountDown[3].substr (1, 1) + '.gif'; setTimeout ("updateClock ()", 990); } var TargetDate = "06/11/2010 00:00"; var XCountDown = GetCountDown (); //--- Preload clock images cImgs = new Array (); cImgs[0] = new Image (); cImgs[0].src = 'images/countdown_0.gif'; cImgs[1] = new Image (); cImgs[1].src = 'images/countdown_1.gif'; cImgs[2] = new Image (); cImgs[2].src = 'images/countdown_2.gif'; cImgs[3] = new Image (); cImgs[3].src = 'images/countdown_3.gif'; cImgs[4] = new Image (); cImgs[4].src = 'images/countdown_4.gif'; cImgs[5] = new Image (); cImgs[5].src = 'images/countdown_5.gif'; cImgs[6] = new Image (); cImgs[6].src = 'images/countdown_6.gif'; cImgs[7] = new Image (); cImgs[7].src = 'images/countdown_7.gif'; cImgs[8] = new Image (); cImgs[8].src = 'images/countdown_8.gif'; cImgs[9] = new Image (); cImgs[9].src = 'images/countdown_9.gif';