function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		//Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function getClock() {
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url = "../shared/clock.process.php";
	url = url + "?sid=" + Math.random();
	xmlHttp.onreadystatechange = function() { stateChangedClock(xmlHttp) ;};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function stateChangedClock(xmlHttp) { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("hmt").innerHTML = "<p>HMT: " + xmlHttp.responseText + "</p>";
	}
}


function UpdateClock() {
	currentTime = document.getElementById("hmt").innerHTML;
	seconds = currentTime.substring(14, 16) - 0;
	if (seconds == 59) {
		StartClock();
	} else {
		newSeconds = seconds + 1
		if (newSeconds < 10) {
			newSeconds = "0" + newSeconds;
		}
		newTime = currentTime.substring(3, 14) + newSeconds;
		document.getElementById("hmt").innerHTML = "<p>" + newTime + "</p>";
		
		setTimeout("UpdateClock()", 1000);
	}
}

function StartClock() {
	document.getElementById("hmt").innerHTML = "<p>HMT: </p>";
	getClock();
	clockID = setTimeout("UpdateClock()", 1000);
}
	
function KillClock() {
	clearTimeout(clockID);
}
