/*
	Support for the center DIV help ajax display system
*/
function getRequestor() {

	if (typeof XMLHttpRequest == "undefined") {
		try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
		catch (e) {}
		try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
		catch (e) {}
		try { return new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (e) {}
	} else {
		return new XMLHttpRequest();
	}
}

var helpRequest;
function requestHelp(topic) {

	var divObj = document.getElementById('helpDiv');
	divObj.style.display = "block";
	divObj.innerHTML = "<img src=\"/static/html/images/loading.gif\"> Requesting help.<p><a onclick=\"closeHelp();\"><strong>[ Close ]</strong></a>";
	divObj.style.marginLeft = "-" + parseInt(divObj.offsetWidth / 2) + "px";
	divObj.style.marginTop = "-" + parseInt(divObj.offsetHeight / 2) + "px";

	var url = "/helpAsync?topic="+topic;
	helpRequest = getRequestor();//new XMLHttpRequest();
	helpRequest.open("GET", url, true);
	helpRequest.onreadystatechange = receiveHelp;
	helpRequest.send(null);
}
function receiveHelp() {
	if (helpRequest.readyState == 4) {
		if (helpRequest.status == 200) {

			// update the HTML DOM based on whether or not message is valid
			var message = helpRequest.responseXML.getElementsByTagName("message")[0];

			var divObj = document.getElementById('helpDiv');
			divObj = document.getElementById('helpDiv');
			divObj.innerHTML = message.childNodes[0].nodeValue;
			divObj.style.marginLeft = "-" + parseInt(divObj.offsetWidth / 2) + "px";
			divObj.style.marginTop = "-" + parseInt(divObj.offsetHeight / 2) + "px";
		}
	}
}
function closeHelp() {
	divObj = document.getElementById('helpDiv');
	divObj.style.display = "none";
}

