// AJAX.JS
// 02/02/2007 15:30:46
//-----------------------


/**
* Permet d'envoyer des données en POST en utilisant les XmlHttpRequest
*/
function sendData(data, page, returnFunction, doAfter, params){
	
	var _this = this;
	this.scope = window; 
	if(returnFunction=="" || returnFunction==undefined) this.returnFunction = null;
	else  this.returnFunction = returnFunction;
	
	if(doAfter=="" || doAfter==undefined) this.doAfter = null;
	else this.doAfter = doAfter;

	if(document.all){
		//Internet Explorer
		this.XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	}else{
		//Mozilla
		this.XhrObj = new XMLHttpRequest();
	}

	//Ouverture du fichier en methode POST
	this.XhrObj.open("POST", page);
	this.XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	this.XhrObj.send(data);
	

	//Ok pour la page cible
	this.XhrObj.onreadystatechange = function(){
		if (_this.XhrObj.readyState == 4 && _this.XhrObj.status == 200){
			if(_this.returnFunction != null) _this.returnFunction.apply(_this.scope, [_this.XhrObj.responseText]);
			if(_this.doAfter != null) _this.doAfter.apply(_this.scope, [params]);
		}
	}

}


