
setInterval("getTime();", 1000);
var diff = new Date() - server_now;
var od, oh, om;
function getTime() {
	now = new Date ();
	var twoTimers = false;
	if (document.getElementById("d2_day")) twoTimers = true;

	//date to countdown to

	res = (later - now + diff);

	days = res / 1000 / 60 / 60 / 24;
	daysRound = Math.floor(days);
	if (daysRound < 0)
		daysRound = 0;

	hours = res / 1000 / 60 / 60 - (24 * daysRound);
	hoursRound = Math.floor(hours);
	if (hoursRound < 0)
		hoursRound = 0;

	minutes = res / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
	minutesRound = Math.floor(minutes);
	if (minutesRound < 0)
		minutesRound = 0;

	seconds = res / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
	secondsRound = Math.floor(seconds);
	if (secondsRound < 0)
		secondsRound = 0;

	if (od!=null&&od!=daysRound){
		document.getElementById("d_day").innerHTML = daysRound;
		if (twoTimers) document.getElementById("d2_day").innerHTML = daysRound;
		od=daysRound;
	}

	if (oh!=hoursRound){
		if (hoursRound < 10){
			document.getElementById("d_hour").innerHTML = '0'+hoursRound;
			if (twoTimers) document.getElementById("d2_hour").innerHTML = '0'+hoursRound;
		}else{
			document.getElementById("d_hour").innerHTML = hoursRound;
			if (twoTimers) document.getElementById("d2_hour").innerHTML = hoursRound;
		}
		oh=hoursRound;
	}

	if (om!=minutesRound){
		if (minutesRound < 10){
			document.getElementById("d_min").innerHTML = '0'+minutesRound;
			if (twoTimers) document.getElementById("d2_min").innerHTML = '0'+minutesRound;
		}else{
			document.getElementById("d_min").innerHTML = minutesRound;
			if (twoTimers) document.getElementById("d2_min").innerHTML = minutesRound;
		}
		om=minutesRound;
	}

	if (secondsRound < 10){
		document.getElementById("d_sec").innerHTML = '0'+secondsRound;
		if (twoTimers) document.getElementById("d2_sec").innerHTML = '0'+secondsRound;
	}else{
		document.getElementById("d_sec").innerHTML = secondsRound;
		if (twoTimers) document.getElementById("d2_sec").innerHTML = secondsRound;
	}
}
