// This following statement must be left intact.
// Copyright (c) Michael Bloch and Taming The Beast.  
// Countdown timer script v1.2 April 20 2009
// Taming the Beast.net - http://www.tamingthebeast.net
// Free Web Marketing and Ecommerce articles and tools
// By using this code you agree to indemnify Taming the Beast
// from from any liability that might arise from its use. 
// The preceding statement be left intact. 


var present;   
var future;    
var tseconds;  
var seconds;   
var minutes;
var hours;
var days;
var milliseconds;

ID=setTimeout("countdown();",500);

function countdown() 
{
present = new Date();
present = present.getTime() + (60000) + (12 * 60 * 60 * 1000);
future = new Date("December 1, 2010 08:00:00");

tseconds = (future - present);

if(tseconds > 0)
{
	days = tseconds /1000/24/60/60;
	days = Math.floor(days);
	tseconds = tseconds - (days * 24 * 60 * 60 * 1000);
	
	hours = tseconds /1000/60/60;
	hours = Math.floor(hours);
	tseconds = tseconds - (hours * 60 * 60 * 1000);
	
	minutes = tseconds /1000/60;
	minutes = Math.floor(minutes);
	tseconds = tseconds - (minutes * 60 * 1000);
	
	seconds = tseconds/1000;
	seconds = Math.floor(seconds);
	tseconds = tseconds - (seconds  * 1000);
	
	milliseconds = tseconds;
	milliseconds = Math.floor(milliseconds);
	
	document.getElementById('days').innerHTML = padNums(days, 2);
	document.getElementById('hours').innerHTML = padNums(hours, 2);
	document.getElementById('minutes').innerHTML = padNums(minutes, 2);
	document.getElementById('seconds').innerHTML = padNums(seconds, 2);
	document.getElementById('milliseconds').innerHTML = padNums(milliseconds, 3);
} else {
	document.getElementById('time_box').style.backgroundImage = document.getElementById('timerEnd').value;
	document.getElementById('days').innerHTML = '';
	document.getElementById('hours').innerHTML = '';
	document.getElementById('minutes').innerHTML = '';
	document.getElementById('seconds').innerHTML = '';
	document.getElementById('milliseconds').innerHTML = '';
}

ID=setTimeout("countdown();",73);
}

function padNums(number, places)
{
	var strNum = number.toString();

	if(isNaN(number) || isNaN(places))
		alert('PadNums needs two numbers. Number='+number+' Places='+places);
	else if(places > 1 && (strNum.length < places))
	{
		padding = places - strNum.length;
		for(var i = 1; i <= padding; i++)
			strNum = "0"+strNum;
	}
	return strNum;	
}
