function createXMLHttpRequest() {

	var XHR = null,
	browserUtente = navigator.userAgent.toUpperCase();

	if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object") {
		XHR = new XMLHttpRequest();
	} else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
		if(browserUtente.indexOf("MSIE 5") < 0) {
			XHR = new ActiveXObject("Msxml2.XMLHTTP");
		} else {
			XHR = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return XHR;
}

function ajax(method) {
	this.method = method;
	
	this.requestPage = function(page, param){
	    var http = createXMLHttpRequest();
	    document.ajaxObj = this;
	    
	    if(!http) {
	        alert("AJAX Error");
	        return false;
	    } else {
	        http.onreadystatechange = function() {
	            if(http.readyState === 4) {
	              if(http.status == 200) {
	                document.ajaxObj.ok_response(http.responseText);
	              } else {
	                document.ajaxObj.err_response(http.status);
	              }
	            }
	        }
	        http.open(this.method, page);
	        if(this.method == 'POST') {
	        	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	        }
	        http.setRequestHeader("connection", "close");
	        http.send(param);
	    }
	}
}