var req;
var xmlh_lock	= false;		// Used to control access to XMLHTTP Request function.  
								// Set to true when a reqeust is made, then set to false when the request is done.
								// This Helps prevent double-clicking errors.  Not used in these function, but in wrappers.


function xmlh_init()
{
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(oc) {
			req = null;
		}
	}

	if(!req && typeof XMLHttpRequest != "undefined") {
		req = new XMLHttpRequest();
	}
}

function xmlh_queryGet(url, callback)
{
	xmlh_init();

	if (req != null) {
		req.open("GET", url, true);
		req.onreadystatechange = function() { 
			if (req.readyState == 4) {
				if (req.status == 200) callback(req.responseText);
				else alert("There was a problem retrieving XMLHTTP data:\nStatus:"+req.status+"\nReturn text:"+req.statusText);
			}
		};
		req.send(null);
	}
}


function xmlh_queryPost(url, posttext, callback, obj)
{
	xmlh_init();

	if (req != null) {
		req.open("POST", url, true);
		req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		req.onreadystatechange = function() { 
			if (req.readyState == 4) {
				if (req.status == 200) {
					if (typeof(obj) !== undefined) callback(req.responseText, obj);
					else callback(req.responseText);
				}
				else alert("There was a problem retrieving XMLHTTP data:\nStatus:"+req.status+"\nReturn text:"+req.statusText);
			}
		};
		req.send(posttext);
	}
}
