var http = null; 
var isWorking = false; 
var NomElem;

if (window.XMLHttpRequest) // Firefox et autres
	http = new XMLHttpRequest(); 
else if (window.ActiveXObject) { // Internet Explorer 
	try {
		http = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	}
} else { // XMLHttpRequest non supporté par le navigateur 
	//alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	http = false; 
}

function treatquery(UrlEdi,Nom){
	if (!isWorking && http) {
	    NomElem=Nom;
		document.getElementById(NomElem).innerHTML = '...'; 
  		document.getElementById(NomElem).style.visibility = 'visible';
  		document.body.style.cursor = 'wait';
		http.open("GET", UrlEdi+"&ElemParent="+NomElem, true);
		//alert(UrlEdi+"&ElemParent="+NomElem);
		http.onreadystatechange = reponseHtml;
		isWorking = true;
		http.send(null);
	}
}

function reponseHtml() {
	if (http.readyState == 4) {
		if (http.responseText.indexOf('invalid') == -1) { 
		document.getElementById(NomElem).innerHTML = http.responseText;
		var allscript = document.getElementById(NomElem).getElementsByTagName('script');
		for(var i=0;i<allscript.length;i++){
      		window.eval(allscript[i].text);
	    };
		document.body.style.cursor = 'default';
    	document.getElementById(NomElem).style.visibility = 'visible';
		}
		isWorking = false;
	}
}
