var ajax = new Object();
//Function to create an XMLHttpRequest.
ajax.getxmlhttp = function (){
	var oXmlHttp = null;
	//If, the activexobject is available, we must be using IE.
	if (window.ActiveXObject){
		oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		//Else, we can use the native Javascript handler.
		oXmlHttp = new XMLHttpRequest();
	}
	return oXmlHttp;
}
//Function to process an XMLHttpRequest.
ajax.process = function (sServerPage, sGetOrPost, sParameter, pfHandleFunc){
	//Get an XMLHttpRequest object for use.
	var oXmlHttp = this.getxmlhttp();
	if (sGetOrPost == "get"){
		oXmlHttp.open("GET", sServerPage);
		oXmlHttp.onreadystatechange = function() {
			if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200) {
				//Handle the response with the function passed
				pfHandleFunc(oXmlHttp.responseText);
			}
		}
		oXmlHttp.send(null);
	} else {
		oXmlHttp.open("POST", sServerPage, true);
		oXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		oXmlHttp.onreadystatechange = function() {
			if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200) {
				//Handle the response with the function passed
				pfHandleFunc(oXmlHttp.responseText);
			}
		}
		oXmlHttp.send(sParameter);
	}
}
ajax.parseresponse = function(sText){
	return parseInt(sText.substring(sText.indexOf("<risposta>") + 10, sText.indexOf("</risposta>")));
}