var		xmlReq = null;
var		XML_RESPONSE_TEXT = '';
var		XML_CB = null;
var		XML_REQUEST_JS = true;

function getRequestObj()
{
	var obj = null;

	// try MS ActiveX method
	try {
		obj = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			obj = null;
		}
	}
	
	// try Mozilla/Safari native method
	if (!obj && typeof XMLHttpRequest != "undefined") {
		obj = new XMLHttpRequest();
	}

	return obj;
}

function evalXmlReq() 
{
	if (xmlReq && xmlReq.readyState == 4) {
		if (xmlReq.status == 200) {
			// request ok - eval the output in javascript
			eval(xmlReq.responseText);
		} else {
			// alert('the XML request failed:\n' + xmlReq.statusText);
		}
	}
}

function cbXmlReq()
{
	if (xmlReq.readyState == 4) {
		if (xmlReq.status == 200) {
			// request ok - return the output and execute callback
			XML_RESPONSE_TEXT = xmlReq.responseText;
			if (XML_CB) XML_CB();
		} else {
			alert('the XML request failed:\n' + xmlReq.statusText);
		}
	}
}


function getXml(url, cbFunc)
{
	if (xmlReq && xmlReq.readyState != 0) {
		xmlReq.abort()
	}
	
	if (cbFunc)
		XML_CB = cbFunc;
	
	xmlReq = getRequestObj();
	if (xmlReq) {
		xmlReq.open("GET", url, true);
		xmlReq.onreadystatechange = (cbFunc) ? cbXmlReq : evalXmlReq;
		xmlReq.send(null)
	}
}


