var eda = Date.parse("2010/07/27 10:00");
var msg = "IT'S OUT, GO AND PLAY THE GAME!";
function fd(data) {
	var ms = data % 1000;
	var sec = parseInt(data/1000 % 60);
	var min = parseInt(data/60000 % 60);
	var hour = parseInt(data/3600000);
	if (ms < 100) ms = "0" + ms;
	if (ms < 10) ms = "0" + ms;
	if (sec < 10) sec = "0" + sec;
	if (min < 10) min = "0" + min;
	if (hour < 10) hour = "0" + hour;
	return hour + ":" + min + ":" + sec + ":" + ms;
}
function sync2() {
	var xmlHttp = null;
	try {
		// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
		xmlHttp = new XMLHttpRequest();
	} catch(e) {
		try {
		// MS Internet Explorer (ab v6)
			xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
			try {
				// MS Internet Explorer (ab v5)
				xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				xmlHttp  = null;
			}
		}
	}
	if (xmlHttp) {
		xmlHttp.open('GET', 'time.php', false); // synchronous request	
/*		xmlHttp.onreadystatechange = function () {
			if (xmlHttp.readyState == 4) {
				var now = xmlHttp.responseText + "000";
				var off = new Date(eda-now).getTime();
				return Number(off);
			}
		}; */
		xmlHttp.send(null);
		var now = xmlHttp.responseText;;
		var off = new Date(eda-now).getTime();
		return Number(off);
	}
}

function sync() {
		var now = new Date().getTime();
		var off = new Date(eda-now).getTime();
		return off;
}

var counter = sync();
function cdown() {
	if (counter <= 0) {
		document.getElementById('counttxt').style.fontSize = "40px";
		document.getElementById('counttxt').innerHTML = msg;
	} else {
		document.getElementById('counttxt').innerHTML = fd(sync());
/*		document.getElementById('counttxt').innerHTML = fd(counter);
		if (counter % 60000 < 17) {
			var lastcounter = counter;
			counter = sync2();
			var off = counter - lastcounter;
			document.getElementById('comment').innerHTML += off + "<br />";
		}
		counter -= 17;
*/		setTimeout('cdown()', 17);
	}
}

