$(function(){
	if($('.clock')[0]){ countdown(1331344800); }
});

$(window).load(function(){
	
});

function countdown(Target_Date){
	var Todays_Date = Math.round(new Date().getTime() / 1000);
	Todays_Date++;
	Time_Left = Math.round((Target_Date - Todays_Date));
	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;
	
	if(days<10) days = '0' + days;
	if(days==0) days = '00';
	if(hours<10) hours = '0' + hours;
	if(hours==0) hours = '00';
	if(minutes<10) minutes = '0' + minutes;
	if(minutes==0) minutes = '00';
	if(seconds<10) seconds = '0' + seconds;
	if(seconds==0) seconds = '00';

	$('#dys').html(days);
	$('#hrs').html(hours);
	$('#min').html(minutes);
	$('#sec').html(seconds);
	   
	 //Recursive call, keeps the clock ticking.
 	setTimeout('countdown(' + Target_Date + ');', 1000);
}
