function countdown_clock(target)
{
	html_code = '<div id="countdown"></div>';
	document.write(html_code);
	countdown(target);
}

function countdown(target)
{
	today = new Date();
	nowutc = Math.round(today.getTime()/1000);
	
	/* today2 = new Date("September 8, 2009 15:00:00"); // or yy,mm,dd,hh,mm,ss (no quotes)
	nowutc2 = Math.round(today2.getTime()/1000);
	alert(nowutc2); //to convert date to miliseconds */
	
	Time_Left = target - nowutc;                 

	if(Time_Left < 0)
    	Time_Left = 0;

	//More datailed.
	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;
	
	/* ret = days + ':' 
	ret += (minutes > 9)?hours + ':' : hours + ':0';
	ret += (seconds > 9)?minutes + ':' : minutes + ':0';
	ret += seconds;
	
	ret = (days > 0)?days + ':' : '';
	ret += (hours > 0)?(minutes > 9)?hours + ':' : hours + ':0' : '';
	ret += (minutes > 0)?(seconds > 9)?minutes + ':' : minutes + ':0' : '';
	ret += seconds; */
	
	ret = days + ':' + ((hours>9)?hours:('0'+hours)) + ':' + ((minutes>9)?minutes:('0'+minutes)) + ':' + ((seconds>9)?seconds:('0'+seconds)) ;
	
	document.getElementById('countdown').innerHTML = ret;
			
	//Recursive call, keeps the clock ticking every second.
	setTimeout("countdown(" + target + ")", 1000);
	//dd:hh:mm:ss -> d:h:0m:0s
}

