
var lastcnt;

http = getHTTPObject();

function getHTTPObject ()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

function doMath ()
{
	var id = document.getElementById('counterdiv');
	lastcnt = id.innerHTML;
	id.innerHTML = 'Loading';
	var url = "/counter.php?__nocounterupdate=1&__jscript=1";

	http.open("GET", url, true);
	http.onreadystatechange = handleHttpResponse;

	http.send(null);
}

function handleHttpResponse ()
{
	if (http.readyState == 4)
	{
		var id = document.getElementById('counterdiv');
		
		if (http.status == 200)
			id.innerHTML = "<h2>Sleeping dolts: " + http.responseText + "</h2>";
		else
			id.innerHTML = lastcnt;
		setTimeout ("doMath()", 60000);
	}
}

doMath();
