//Gets the browser specific XmlHttpRequest Object
function getXHRObject() {
	if (window.XMLHttpRequest) {
		xhrObject = new XMLHttpRequest();
	} else {
		try {
			xhrObject = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			try {
				xhrObject = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (E) {
				alert ("Please update your browser to use certain features of this site.");
				return;
			}
		}
	}
	return xhrObject;
}

//xml http variable
xhr = getXHRObject();

function split_args(arg) {
	arg_arr = arg.split(',');
	args = "";
	for (var i=0; i<arg_arr.length; i++) {
		if (i>0) args += ",";
		args += "\'"+arg_arr[i]+"\'";
	}
	
	return args;
}
function xhr_helper (func, arg) {
	args = split_args(arg);
	var page = eval(func + "_qry("+ args + ")");
	var cache = parseInt(Math.random()*99999999);
	if(page.indexOf("?")>0) page += "&";
	else page += "?";
	page += "rand="+cache
	xhr.open("GET", page, true);
	xhr.onreadystatechange = function () {
		if (xhr.readyState == 4 && xhr.status == 200) {
			eval(func+"_suc"+"(\'"+xhr.responseText+"\')");
		} else {
			eval(func+"_loading"+"()");
			if (xhr.status == 404) {
				eval(func+"_404"+"()");
			}
		}
		
	}
	xhr.send();
}
