/**********************************************/
/* ajax functions to do the work for updating */
/**********************************************/
var xmlHttp

/* helper function to get HttpObjects */
function GetXmlHttpObject() { 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

/* callback function to reload the page after the server responds */
function reload() { 
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { 
		// alert(xmlHttp.responseText);
		// dont use reload, because it will try to re-submit form data
		window.location = window.location;
	} 
} 

function ajax_query(url, callback) {
	ajax_query(url, callback, null);
}
function ajax_query(url, callback, args) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	} 
	if (callback == true) {
		xmlHttp.onreadystatechange = reload;
	} else if (callback) {
		// custom function 
		xmlHttp.onreadystatechange = function() {
			callback(args);
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
