var objXML;
function fncLoadXML(strURL){
	fncLoading(1);
	// native XMLHttpRequest object
	if(window.XMLHttpRequest){
		objXML = new XMLHttpRequest();
		objXML.onreadystatechange = fncProcessXML;
		objXML.open("GET",strURL,true);
		if(objXML.overrideMimeType){ objXML.overrideMimeType("text/xml"); }
		objXML.send(null);
	// IE/Windows ActiveX
	}else if(window.ActiveXObject){
		objXML = new ActiveXObject("Microsoft.XMLHTTP");
		if(objXML){
			objXML.onreadystatechange = fncProcessXML;
			objXML.open("GET",strURL,true);
			objXML.send();
		}
	}else{ alert("Your browser does not suport AJAX! Please use a newer browser!"); }
}

function fncProcessXML(){
	// readyState 4 = request complete
	if(objXML.readyState == 4){
		// status 200 = no errors found
		if(objXML.status == 200){
			// process the result
			response = objXML.responseXML.documentElement;
			//response = objXML.responseXML ? objXML.responseXML.documentElement : (new DOMParser()).parseFromString(objXML.responseText,"text/xml").documentElement;
			if(response){
				strFunction = response.getElementsByTagName("function")[0].firstChild.data;
				strResults = response.getElementsByTagName("results")[0].firstChild.data.replace(/\{\[\(/g,"<").replace(/\)\]\}/g,">");
				//strFunction = response.firstChild.xml.replace("<function>","").replace("</function>","");
				//strResults = response.lastChild.xml.replace("<results>","").replace("</results>","");
				eval(strFunction + '(strResults)');
			}else{ alert("Error: not a valid XML object"); }
		}else{ alert("Error loading data:\n" + objXML.status + ": " + objXML.statusText); }
	}
	fncLoading(0);
}

function fncLoading(numOpt){
	if(numOpt){ document.getElementById("ajax_loading").style.display="inline"; }
	else{ document.getElementById("ajax_loading").style.display="none"; }
}
