
/////////////////////////// Standard Ajax Object ////////////////////////////////////
//Gets the browser-specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest(); //Not IE
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP"); //IE
		} else {
			//Display your error message here. 
			//and inform the user they might want to upgrade
			//their browser.
			alert("Error: Your browser doesn't support the XmlHttpRequest object.\nYou should upgrade to Firefox.");
		}
}
///////////////////////////////////////////////////////////////////////////////

var ajaxReq = getXmlHttpRequestObject();
var AjaxObj;
var AjaxResponse;

function AjaxGet (page, outputid, fn, processAsObj)
{
	//alert("fn1: " + fn);
	
	if (ajaxReq.readyState == 4 || ajaxReq.readyState == 0) {
		ajaxReq.open("GET", page, true);
		ajaxReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');		
		ajaxReq.onreadystatechange = function () {
			if (ajaxReq.readyState == 4)
			{
				
				var splitter = "@@@@@@@@@@";
				var r = ajaxReq.responseText + "" + splitter;
				r = r.substring(0, r.indexOf(splitter));
				
				AjaxResponse = r; 
				if (document.getElementById(outputid)) document.getElementById(outputid).innerHTML = r;
				
				//This can cause mysterious errors so now will only run when setting the processAsObj to TRUE
				if (processAsObj) AjaxObj = eval("(" + r + ")");
						
				if (fn) eval(fn);
			}
		}
		ajaxReq.send(null);
	}

}

