 
//- Count Down Clock Java Script© - Time to Christmas®
//- Copyright (c) The WWWeb Factory © 1998 - 2006

var dateEOT = new Date("December 25, 2006 00:00:00");
var dateDLS = new Date("October 31, 2006 00:00:00");
var DT_msPerDay, DT_msPerHour, DT_msPerMinute;
var DT_msPerSecond, DT_TimerOn, DT_TimerId;
var dateNow=new Date();
var daylight=0;
var timeDiff = 0;
var dd=0;
var hh=0;
var mm=0;
var ss=0;
var On=true;
var DT_msPerDay=24*60*60*1000;
var DT_msPerHour=60*60*1000;
var DT_msPerMinute=60*1000;
var DT_msPerSecond=1000;
var timerID=true;

//- Count Down Clock Java Script© - Time to Christmas®
//- Copyright (c) The WWWeb Factory © 1998 - 2006

var ddLast="123"
var hhLast="45"
var mmLast="67"
var ssLast="89"

var currentCount=0;

function DT_showCount(timeDiff) {

    dd=Math.floor(timeDiff/DT_msPerDay);
    timeDiff=timeDiff-dd*DT_msPerDay;
    hh=Math.floor(timeDiff/DT_msPerHour);
    timeDiff=timeDiff-hh*DT_msPerHour;
    mm=Math.floor(timeDiff/DT_msPerMinute);
    timeDiff=timeDiff-mm*DT_msPerMinute;
    ss=Math.floor(timeDiff/DT_msPerSecond);

    dd=(dd>=100?dd:"0"+dd);
    dd=(dd>=10?dd:"0"+dd);
    hh=(hh>=10?hh:"0"+hh);
    mm=(mm>=10?mm:"0"+mm);
    ss=(ss>=10?ss:"0"+ss);

    if (dd != ddLast) { dateToImg("day", dd); }
    if (hh != hhLast) { dateToImg("hour", hh); }
    if (mm != mmLast) { dateToImg("minute", mm); }
    if (ss != ssLast) { dateToImg("second", ss); }

    ddLast = dd;
    hhLast = hh;
    mmLast = mm;
    ssLast = ss;

}

function dateToImg (inWords, inCode) {
  var x = inCode.toString();
  var y = inWords.toString();
  for (var i = 0; i < x.length; i++) {
    var n = x.substring (i, i+1);  
    eval ('document.' + y + (i+1) + '.src = "/clock/clock-' + n + '.gif"');
  }
  
}

function DT_startTimer() {
  dateNow=new Date();
  if (dateNow.getTime() < dateDLS.getTime()) { 
    daylight = 3600000;
  } else { 
    daylight = 0;
  }
  timeDiff = dateEOT.getTime()- dateNow.getTime() - daylight;
  DT_showCount(timeDiff);
  currentCount = currentCount + 1;
  if (currentCount<60) {
    timerID = setTimeout("DT_startTimer()",1000);
  } else {
    clearTimeout(DT_startTimer);
  }
  clearTimeout(loopTime);
}


function runTime () {
  timerID = setTimeout("DT_startTimer()",3000);
}

//- Count Down Clock Java Script© - Time to Christmas®
//- Copyright (c) The WWWeb Factory © 1998 - 2006

