// ajax.js V4 (OO, POST, variable hookback)
// écrit par Bernhard Rieder

function AjaxRequest(url,params,fonction_sortie,supplement) {

	this.url = encodeURI(url);
	this.params = encodeURI(params);
	this.fonction_sortie = fonction_sortie;
	this.supplement = supplement;
	
	var ajaxRequest = this;
	
	if (window.XMLHttpRequest) {

		this.req = new XMLHttpRequest();
		
		this.req.onreadystatechange = function () { ajaxRequest.processReqChange(); }

		this.req.open("POST", this.url, true);
		this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		this.req.send(this.params);
		
	} else if (window.ActiveXObject) {
		
		this.req = new ActiveXObject("Microsoft.XMLHTTP");

		if (this.req) {
			this.req.onreadystatechange = this.req.onreadystatechange = function () { ajaxRequest.processReqChange(); }
			this.req.open("POST", this.url, true);
			this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			this.req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
			this.req.send(this.params);
		}
	} else {

		alert("Votre navigateur ne connait pas l'objet XMLHttpRequest.");
	}
}

AjaxRequest.prototype.processReqChange = function() {

	if (this.req.readyState == 4) {
		if (this.req.status == 200) {
			eval(this.fonction_sortie+"(this.req.responseXML.documentElement,this.supplement)");
		} else {
			alert("Il y avait un probleme avec le XML: " + this.req.statusText);
		}
	}
}



