/**
* Fonctions liées au XMLHTTPRequest...
**/

function HttpReq(url, data, method, fctAsynch, isXML) {
	if(! data || data == "") data = null;
	if(! method || method.toUpperCase() != "GET") method = "POST";
	else if(data!=null) {
		url=url+"?"+data;
		data=null;
	}

	var xhr_object = null;
	if(window.XMLHttpRequest) // Firefox >= 1.0
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer >= 5.5
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("<MSX>Votre navigateur ne supporte pas les objets XMLHTTPRequest...</MSX>");
		return "";
	}
	//	xhr_object.setRequestHeader("charset","iso-8859-1");

	xhr_object.open(method, url, ((typeof fctAsynch)=="function"));

	if((typeof fctAsynch)=="function") {
		//Si c'est une fonction, on est en mode asynchrone --> on déclare la fonction suivante...
		xhr_object.onreadystatechange = function() {
			fctAsynch(xhr_object);
		}
	}

	if(method=="POST") xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send(data);

	if(!((typeof fctAsynch)=="function")) {
		if(xhr_object.readyState == 4) { //Sans mode asynchrone, on récupère la réponse quand on a tout recu (readyState=4)
			if(isXML) return xhr_object.responseXML;
			else return xhr_object.responseText;
		} else {
			alert("<MSX>Attention ! Un problème a eu lieu lors de la requête XMLHTTPRequest...</MSX>");
			return "";
		}
	} else {
		return "";
	}
}

