function prendiElementoDaId(id_elemento) {
	var elemento;
	if(document.getElementById){
		elemento = document.getElementById(id_elemento);
	}else{
		elemento = document.all[id_elemento];
	}
		return elemento;
};

function assegnaXMLHttpRequest() {
	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;
} 

var paramGlobal = {valore:null};

function contentLoad(pagina,param,dest,attesa){
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("GET", pagina+"?"+param, true);
		paramGlobal.valore = param
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.send(param);
		ajax.onreadystatechange = function() {
			if(ajax.readyState === 4) {
				if(ajax.status == 200){
					result = ajax.responseText;
					prendiElementoDaId(dest).innerHTML = result;
					if(attesa != null){
						prendiElementoDaId(attesa).display = "none"
					}
				}else{
					alert("Operazione fallita, errore numero " + ajax.status);
				}
			}else{
				if(attesa != null){
					prendiElementoDaId(attesa).display = "inline"
				}
			}
		} 
	}
}

