var xmlHttps = new Array();

function ajaxUpdate(str,updateURLp,updateObjectIDp) {
	//Calls an AJAX update
	// str - string that you want to pass, labelled as "q"
	// updateURLp - the URL that will be called
	// updateObjectIDp - the ID of the HTML object that will receive the AJAX info
	//GetXmlHttpObject.prototype.updateObjectID = updateObjectIDp;

	//Creates a unique ID XMLHTTP object for each object,
	//but allows older versions of the request object to be overwritten in each HTML object
	if(xmlHttps[updateObjectIDp]) {
		xmlHttps[updateObjectIDp].close;
	}
	xmlHttps[updateObjectIDp] = GetXmlHttpObject();

	//var xmlHttp = xmlHttps[updateObjectIDp];
	
	if(typeof loadingText != 'undefined')
		document.getElementById(updateObjectIDp).innerHTML = loadingText+document.getElementById(updateObjectIDp).innerHTML;//"Loading...";
	if (xmlHttps[updateObjectIDp]==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=updateURLp;
	if(url.indexOf("?")==-1)
		url = url+"?";
	url=url+"&q="+str;
	url=url+"&sid="+Math.random();
	xmlHttps[updateObjectIDp].open("GET",url,true);
	xmlHttps[updateObjectIDp].onreadystatechange=stateChanged;
	xmlHttps[updateObjectIDp].send("");
	
	function stateChanged() { 
		if (xmlHttps[updateObjectIDp].readyState==4) { 
			var updObj = document.getElementById(updateObjectIDp);
			if(updObj) {
				updObj.innerHTML=xmlHttps[updateObjectIDp].responseText;
				//Eval any scripts within the returned values
				var scripts = updObj.getElementsByTagName('script');
				for (var i=0;i<scripts.length;i++) {
					eval(scripts[i].innerHTML);
				}
			} else
				1;//alert("Obj Name:'"+updateObjectIDp+"' not found");
			xmlHttps[updateObjectIDp].close;
		}
	}
} 


function GetXmlHttpObject() {
	var xmlHttp=null;
	try { 
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
	// Internet Explorer
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.6.0"); } 
		catch (e) { }
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.3.0"); } 
		catch (e) { }
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch (e) { }
		try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } 
		catch (e) { }
	}
	return xmlHttp;
}