var mon_ajax;
function cree_ajax()
{
	if (window.XMLHttpRequest)//  Objet de la fenêtre courant
		ajax = new XMLHttpRequest();     //  Firefox, Safari, ...
	else if (window.ActiveXObject)//  Version Active
		ajax = new ActiveXObject("Microsoft.XMLHTTP");// Internet Explorer 
	else
		ajax='';
	return ajax;
}
function ajax_get(param)
{
	return requete_ajax(param,'GET');
}
function ajax_post(param)
{
	return requete_ajax(param,'POST');
}
function requete_ajax(param,method)
{
	if(param)
		param=make_string(param);
	if(mon_ajax)
	{
		if(method == "GET")		
		{
			/*mon_ajax.abort();*/
			mon_ajax.open("GET","new_ajax.php?"+param, false);//ajax synchrone 
			mon_ajax.send(null);
		}
		else if(method == "POST")
		{
			mon_ajax.open("POST", "new_ajax.php", false);//ajax synchrone 
			mon_ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			mon_ajax.send(param);
		}
		else
			alert("Methode '"+method+"' inconnue !");
		
		return traite_retour_ajax(mon_ajax.responseText);
	}
}
function traite_retour_ajax(reponse)
{
	if(reponse.indexOf('error</b>')>0)
	{
		alert(reponse);
		return false;
	}
	if(reponse.indexOf('<finduhtml>')>0)
	{
		var mon_html=reponse.substr(0,reponse.indexOf('<finduhtml>'));
		reponse=reponse.substr(reponse.indexOf('<finduhtml>')+11,reponse.length);
		retour_ajax=eval('('+reponse+')');
		retour_ajax.retour.html=mon_html;
	}
	else
		retour_ajax=eval('('+reponse+')');
	if(retour_ajax.retour.header)
	{
		document.location.href=retour_ajax.retour.header;
	}
	else if(retour_ajax.retour.erreur_php)
	{
		alert(retour_ajax.retour.erreur_php);
		document.getElementById('debug').innerHTML=retour_ajax.retour.erreur_php;
	}
	else
	{
		if(retour_ajax.retour.debug_php)
			alert(retour_ajax.retour.debug_php);
		if(typeof(retour_ajax.retour.alert_js)!='undefined')
		{
			retour_ajax.retour.alert_js=js_replace(retour_ajax.retour.alert_js,'##ENTREE##','\n');
			alert(retour_ajax.retour.alert_js);
		}
		for(var cle in retour_ajax.retour)
		{
			//alert(retour_ajax.retour[cle]+" CLE :: "+cle);
			//retour_ajax.retour[cle]=js_replace(retour_ajax.retour[cle],'##ENTREE##','\n');
			if(cle.substr(0,4)=='var_')
			{
				eval(cle.substr(4,cle.length)+"=retour_ajax.retour[cle];");
			}
		}
	}
	
	return retour_ajax;
}
