/**
 * Retourne l'objet XmlHTTPRequest
 */
function getHTTPObject() {
	if(typeof(XMLHttpRequest)!='undefined')
		return new XMLHttpRequest();

	var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
	for(i=0;i<axO.length;i++)
		try{
			return new ActiveXObject(axO[i]);
		}catch(e){}
	return null;
}

/**
 * Envoi de donn�e en ligne via la technologie AJAX
 *
 * @param method - la methode d'envoi des donn�es
 *					GET ou POST
 * @param url - l'url vers lequelle envoyer les donn�es
 * @param data - les donn�es � envoyer en AJAX
 */
function sendData(method, url, data) {
	var xmlhttp = getHTTPObject();

	if (!xmlhttp) {
	    return false;
	}
	
	if(method == "GET") {
		if(data == 'null') {
			xmlhttp.open("GET", url, true); //ouverture asynchrone
		} else {
			xmlhttp.open("GET", url+"?"+data, true);
		}
		xmlhttp.send(null);
	} else if(method == "POST") {
		xmlhttp.open("POST", url, true); //ouverture asynchrone
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(data);
	}
	return xmlhttp;
}

function post(url, data, response) {
	var xmlhttp;
	var data;
	
	if (xmlhttp = sendData("POST", url, data)) {
		/* on definit ce qui doit se passer quand la page repondra */
		xmlhttp.onreadystatechange=function() {

			if (xmlhttp.readyState == 4) { /* 4 : etat "complete" */ 
				if (xmlhttp.status == 200)  {/* 200 : code HTTP pour OK */
					response(xmlhttp);
				}
			}
		}
	}
}