
function zeroPad(num,count){
	var numZeropad = num + '';
	while(numZeropad.length < count) {
		numZeropad = "0" + numZeropad;
	}
	return numZeropad;
}
 
function countdown_clock(year, month, day, hour, minute, format)
{
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth();
 
         
         //Computes the time difference between the client computer and the server.
         Server_Date = (new Date(12, 2, 6,
                                 05, 31, 24)).getTime();
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
 
         countdown(year, month, day, hour, minute, (Todays_Date - Server_Date), format);
}
 
function countdown(year, month, day, hour, minute, time_difference, format)
{
         Today = new Date();
         Todays_Year = Today.getFullYear() - 2000;
         Todays_Month = Today.getMonth();
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();
         Time_Left = Math.round((Target_Date - Todays_Date + time_difference) / 1000);
 
		 
         if(Time_Left < 0)
		 {
								
            Time_Left = 0;
            document.getElementById('countdown').innerHTML = 's&aring; sender vi den allerede imorgen!';
			document.getElementById('countdown_line1').innerHTML = 'Bestil varen nu';
			document.getElementById('countdown_line2').innerHTML = '';
	     }
		 else
		 {
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = zeroPad(Math.floor(Time_Left / (60 * 60)),1);
                    Time_Left %= (60 * 60);
                    minutes = zeroPad(Math.floor(Time_Left / 60),1);
                    Time_Left %= 60;
                    seconds = zeroPad(Time_Left,1);
                    document.getElementById('countdown').innerHTML = hours + ' time(r) ';
                    document.getElementById('countdown').innerHTML += minutes + ' min ';
                    document.getElementById('countdown').innerHTML += seconds + ' sek';
 
					document.getElementById('countdown_line1').innerHTML = 'Bestil varen inden: ';
					document.getElementById('countdown_line2').innerHTML = 's&aring; sender vi den allerede idag!';
 
         			setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + time_difference + ', ' + format + ');', 1000);
		 }
}countdown_clock(12, 2, 6, 16, 00, 1)
