	function file(fichier,d,chargement)
	{
	    var data=null;
	    var xhr_object=null;
	    if(window.XMLHttpRequest) xhr_object=new XMLHttpRequest();
	    else if(window.ActiveXObject) xhr_object=new ActiveXObject("Microsoft.XMLHTTP");
	    else return(false);
	    xhr_object.open("POST",fichier,true);
	    xhr_object.onreadystatechange = function()
	    {
		    if(xhr_object.readyState==4)
		    {
			    if(xhr_object.status==200)
			    {
				    if(d!="") writediv(xhr_object.responseText,d);

				   // if(document.getElementById("chargement")) writediv("","chargement");
			    }
		    }
		    else
		    {
			    if(d!="" && d.search("suivi_")==-1 && d.search("commu")==-1 && d.search("invit")==-1 && d.search("wait_header")==-1 && document.getElementById(chargement))
			    writediv('<div class="loading" style="text-align:center;"><img src="design/images/loader.gif" alt="loading" /><br />Recherche en cours...</div>',chargement);
		    }
	    }
	    xhr_object.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	    xhr_object.send(data);
	}

	function file_old(fichier) {
	var data=null;
	var xhr_object=null;
	if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else return(false);
	xhr_object.open("GET",fichier,false);
	xhr_object.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr_object.send(data);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
	}

	function writediv(texte,div)
	{
		if (document.getElementById(div)) {
			document.getElementById(div).innerHTML = texte;
		}
	}

	function ajax(methode,param2)
	{
		if (methode=="change_etat_relance") {
			var note = encodeURIComponent(document.getElementById('etat_relance_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}

		if (methode=="change_etat_alerte") {
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","chargement");
		}

		else if (methode=="maj_note_interne")
		{
			var note = encodeURIComponent(document.getElementById('note_interne_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="maj_note_agence")
		{
			var note = encodeURIComponent(document.getElementById('note_agence_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="maj_note_annul")
		{
			var note = encodeURIComponent(document.getElementById('note_annul_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="change_annule")
		{
			var note = encodeURIComponent(document.getElementById('annule_info_'+param2).value);
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2)+'&param2='+note,"","chargement");
		}
		else if (methode=="get_anchor")
		{
			//reponse=file('/js.php?method='+methode+'&param='+document.location.hash,"liste_location","chargement");
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(document.location.hash),"","chargement");
		}
		else if (methode=="liste_client")
		{
			taille = document.info_client.partie_client.value.length;
			param1 = document.info_client.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1,"liste_client","chargement");
			}
		}
		else if (methode=="liste_location")
		{
			taille = document.info.partie.value.length;
			param1 = document.info.partie.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1,"liste_location","chargement");
			}
		}
		else if (methode=="liste_gest_client")
		{
			taille = document.form_gest_resa.partie_client.value.length;
			param1 = document.form_gest_resa.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="liste_gest_client_propo")
		{
			taille = document.fait_propo.nom_cl.value.length;
			param1 = document.fait_propo.nom_cl.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="frm_selection")
		{
			taille = document.frm_selection.partie_client.value.length;
			param1 = document.frm_selection.partie_client.value;
			if (taille>2)
			{
				reponse = file('/js.php?method='+methode+'&param='+param1+'&param2='+param2,"liste_client","chargement");
			}
		}
		else if (methode=="ajout_animal")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoanimal_'+param2,"chargement");
			}
		}
		else if (methode=="contrat_recu")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'inforesa_'+param2,"chargement");
			}
		}
		else if (methode=="bon_recu")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infobon_'+param2,"chargement");
			}
		}
		else if (methode=="contrat_online")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'',"chargement");
			}
		}
		else if (methode=="priorite")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoloc_'+param2,"chargement");
			}
		}
		else if (methode=="fiche_ok")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoloc_'+param2,"chargement");
			}
		}
		else if (methode=="fiche_ok_agence")
		{
			if (param2!="")
			{
				reponse = file('/js.php?method='+methode+'&param2='+param2,'infoagence_'+param2,"chargement");
			}
		}
		else if (methode=="panier")
		{
			reponse = file('/js.php?method='+methode+'&param2='+param2,'infopanier_'+param2,"chargement");

		}
		else if (methode.search("change_")>-1 && methode!="change_page" && methode!="change_ordre" && methode!="change_dep_detail" && methode!="change_duree_detail")
		{
		    reponse = file('/js.php?method='+methode+'&param='+param2,"","");
		    //mettre a jour bouton recherche
		    //document.location.href=''+reponse+'';
		}
		else if (methode=="dm_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="dm_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="us_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="us_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="al_add")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="al_suppr")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"domaines","domaines");
		}
		else if (methode=="planning_0")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),param2,"");
		}
		else if (methode=="planning_1")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),param2,"");
		}
		else if (methode=="invisible")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","");
		}
		else if (methode=="verifie_achat")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"","");
		}
		else if (methode=="selection_side")
		{
			reponse = file('/js.php?method='+methode+'&param='+encodeURIComponent(param2),"selection_side","selection_side");
		}
		else if (methode=="resultats2")
		{
			reponse = file_old('/js.php?method='+methode+'&param='+encodeURIComponent(param2));
			//alert(reponse);
			document.location.href=reponse;
		}
		else
		{
		    reponse = file('/js.php?method='+methode+'&param='+param2,"contenu","resultats_recherche");
		}
	}

function save_langue(clef,langue)
{
    var trad = encodeURIComponent(document.getElementById('trad_'+langue+'_'+clef).value);
    reponse = file('/js.php?method=langue&clef='+clef+'&langue='+langue+'&trad='+trad);
    //if(reponse!='') alert(clef+' ok');
}

var numb = '0123456789IB-';
function isValid(parm,val) {
if (parm == "") return true;
for (i=0; i<parm.length; i++) {
if (val.indexOf(parm.charAt(i),0) == -1) return false;
}
return true;
}

function isNumber(parm) {return isValid(parm,numb);}

function valide_search_code_log()
{
	if(document.getElementById('recherche_rapide').value!='IB-' && document.getElementById('recherche_rapide').value!='IB-xxxx' && isNumber(document.getElementById('recherche_rapide').value) )
	{
		document.location='/?l=2010-7-3-7-'+document.getElementById('recherche_rapide').value.replace(/IB-/g,'');
		reponse = file('/js.php?method=clean_selection',"","");
	}
	else alert('Code invalide');
}

function cal_aff_semaine(classname,style)
{
	var lis=document.getElementsByTagName('li');
	for(var i=0; i<lis.length; i++)
	{
		if(lis[i].className==classname) lis[i].style.background=style;
	}
}