var TARGET_YEAR = 2008;
var TARGET_MONTH = 8;
var TARGET_DAY = 6;
var TARGET_HOUR = 13;
var TARGET_MIN = 5;
var TARGET_SEC = 0;

var TARGET_DATE = (new Date(TARGET_YEAR, TARGET_MONTH - 1, TARGET_DAY, TARGET_HOUR, TARGET_MIN, TARGET_SEC)).getTime();

var countdownInterval;

function startCountdown() {
	countdown();
	countdownInterval = setInterval(countdown,1000);
}

function countdown() {
		 var complete = false;
         Today = new Date();
         Todays_Year = Today.getFullYear();
         Todays_Month = Today.getMonth();                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = TARGET_DATE;
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0) {
			 Time_Left = 0;
			 complete = true;
		 }
         
		days = Math.floor(Time_Left / (60 * 60 * 24));
		Time_Left %= (60 * 60 * 24);
		hours = Math.floor(Time_Left / (60 * 60));
		Time_Left %= (60 * 60);
		minutes = Math.floor(Time_Left / 60);
		Time_Left %= 60;
		seconds = Time_Left;
		
		dps = 's'; hps = 's'; mps = 's'; sps = 's';
		//ps is short for plural suffix.
		if(days == 1) dps ='';
		if(hours == 1) hps ='';
		if(minutes == 1) mps ='';
		if(seconds == 1) sps ='';
		
		var displayHtml = "";
		displayHtml += '<span class=\'countdownnumber\'>' + days + '</span> day' + dps + ' ';
		displayHtml += '<span class=\'countdownnumber\'>' + hours + '</span> hour' + hps + ' ';
		displayHtml += '<span class=\'countdownnumber\'>' + minutes + '</span> minute' + mps + ' and ';
		displayHtml += '<span class=\'countdownnumber\'>' + seconds + '</span> second' + sps;


		document.all.countdown.innerHTML = displayHtml;


         if(complete) {
			 clearInterval(countdownInterval);
			 return;
		 }
}
