

 	function afficheDiv(param1, param2)
	{
	document.getElementById(param1).style['display'] = 'block';
	document.getElementById(param2).style['display'] = 'none';
	}

	
	function fermerPopup()
	{
	document.getElementById('popupDhtml').style['display'] = 'none';
	}
	
		function fermerPopup2()
	{
	document.getElementById('popupDhtml2').style['display'] = 'none';
	}
	
	function ajaxVille()
{
initAjaxInstitut();
  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_ajaxVille(xhr); };

    xhr.open("GET", chemin+"/php/ajaxVille.php?id="+document.getElementById('combo0').value, true);
    xhr.send(null);



}
	
function initAjaxInstitut(){
	 var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_ajaxInstitut(xhr); };

    xhr.open("GET", chemin+"/php/initAjaxInstitut.php", true);
    xhr.send(null);
}

	
function alert_ajaxVille(xhr)
{
	
    if (xhr.readyState==4) 
    {
document.getElementById('combo1').innerHTML = xhr.responseText;

	}
}	

	
			function ajaxInstitut()
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_ajaxInstitut(xhr); };

    xhr.open("GET", chemin+"/php/ajaxInstitut.php?id="+document.getElementById('contenucombo1').value, true);
    xhr.send(null);



}
	
	
	
function alert_ajaxInstitut(xhr)
{
	
    if (xhr.readyState==4) 
    {
	
document.getElementById('combo2').innerHTML = xhr.responseText;

	}
}	


			function saveInstitut()
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_saveInstitut(xhr); };

	//alert (document.getElementById('combo3').value+"&commande"+document.getElementById('commande').value);
    xhr.open("GET", chemin+"/php/saveInstitut.php?id="+document.getElementById('combo3').value+"&commande="+document.getElementById('commande').value, true);
    xhr.send(null);



}
	

	
function alert_saveInstitut(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById('institut').innerHTML = xhr.responseText;

	}
}


	
		function saveCheque()
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_saveCheque(xhr); };


    xhr.open("GET", chemin+"/php/saveCheque.php?id="+document.getElementById('combo8').value, true);
    xhr.send(null);



}
	
	
	
function alert_saveCheque(xhr)
{
	
    if (xhr.readyState==4) 
    {

etape ('paiement');

	}
}	
	

		function detail(produit,table)
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_popupDetail(xhr); };
	if(table){
		var supTable = "&table="+table;
	}else{
		var supTable = "";
	}

    xhr.open("GET", chemin+"/php/detail.php?id="+produit+""+supTable, true);
    xhr.send(null);





}
	
	
	
function alert_popupDetail(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("popupDhtmlContennu").innerHTML = xhr.responseText;


document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';

	}
}
	
	

	
	function popupLireAvis(produit, soin)
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_popupLireAvis(xhr); };


    xhr.open("GET", chemin+"/php/lireAvis.php?produit="+produit+"&soin="+soin+"&langue="+id_langue, true);
    xhr.send(null);






}
	
	
	
function alert_popupLireAvis(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("popupDhtmlContennu").innerHTML = xhr.responseText;


document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';

	}
}	
	
	
	
	function popupTemoignage(produit, soin)
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_popupTemoignage(xhr); };


    xhr.open("GET", chemin+"/php/form.php?produit="+produit+"&soin="+soin+"&langue="+id_langue, true);
    xhr.send(null);






}
	
	
	
function alert_popupTemoignage(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("popupDhtmlContennu").innerHTML = xhr.responseText;


document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';

	}
}	
	
	
	
	
	
	

	
	
		function popupChoix()
{


  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_popupChoix(xhr); };


    xhr.open("GET", chemin+"/php/choix.php", true);
    xhr.send(null);




}
	
function alert_popupChoix(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("popupDhtmlContennu").innerHTML = xhr.responseText;


document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';

	}
}	
	
	
	
	
	
	
	
	
		function insertAvis(produit, soin)
{


  var xhr3=null;
    
    if (window.XMLHttpRequest) { 
        xhr3 = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
    xhr3 = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr3.onreadystatechange = function() { alert_insertAvis(xhr3); };


    xhr3.open("POST", chemin+"/php/form.php?produit="+produit+"&soin="+soin+"&langue="+id_langue, true);
 

  

	donnees = "";
	donnees += "&nomAvis="+ document.getElementById('nomAvis').value;
	donnees += "&textAvis="+ document.getElementById('textAvis').value;;
	donnees += "&mailAvis="+ document.getElementById('mailAvis').value;;

		
	
	xhr3.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr3.send(donnees);



}
		
		 function alert_insertAvis(xhr3)
 	{
	    if (xhr3.readyState==4) 
    {

	document.getElementById("popupDhtmlContennu").innerHTML= text22;
	setTimeout("fermerPopup()",1600);

	}
	}	
	
	
	
	
	
	function mousseOverPict(test, cible, lien)
{
for (var i =0 ; i<document.getElementById('lien').getElementsByTagName("a").length; i++)
{
document.getElementById('lien').getElementsByTagName("a")[i].style['fontWeight'] = 'normal';
}
cible.style['fontWeight'] = 'bold';

document.getElementById('pict').innerHTML="<a href='"+lien+"' ><img border='0' src='"+chemin+"/files/miniature/"+test+"'/></a>"; 


}
	
	
	
	
	
	 function shareLink()
 {
      try
   {
  document.getElementById('shareLink').click();
   }catch(e)
   {
    var evt = document.createEvent("MouseEvents"); 
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);  
    var cb = document.getElementById('shareLink'); 
    cb.dispatchEvent(evt);  
   }
 }
	
	
	
	

		
	
	
	
		function monCompte(etape)
{



  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_monCompte(xhr); };


    xhr.open("GET", chemin+"/php/"+etape+".php", true);
    xhr.send(null);

function alert_monCompte(xhr)
{
	
    if (xhr.readyState==4) 
    {
		
	document.getElementById("container").innerHTML = xhr.responseText;
	
	}
}

}
	
	
	function etapePaiementDistributeur(valeur){
	var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() {afficheFiltreDistributeur(xhr); };
	
	
    xhr.open("POST", chemin+"/php/loadFiltreDistributeur.php", true);
  
	donnees = "";
	donnees += "&id="+document.getElementById('departement').value;


	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
    xhr.send(donnees);
	
	}
	function afficheFiltreDistributeur(xhr){
		 if (xhr.readyState==4) {
		document.getElementById("conteneurDistributeur").innerHTML = xhr.responseText;
		}
	}
	
	function majDistributeurPres(){
		var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() {afficheResultatMajDistributeur(xhr); };
	
	
    xhr.open("POST", chemin+"/php/majDistributeurPres.php", true);
  
	donnees = "";
	donnees += "&id="+document.getElementById('distributeur').value;


	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
    xhr.send(donnees);	
	}
	function afficheResultatMajDistributeur(xhr){
		if (xhr.readyState==4) {
		
		}
	}
	
	function etape(etape)
{



  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_etape(xhr,etape); };


    xhr.open("GET", chemin+"/php/"+etape+".php", true);
    xhr.send(null);

function alert_etape(xhr,etape)
{
	
    if (xhr.readyState==4) 
    {
		
	document.getElementById("container").innerHTML = xhr.responseText;
	if(etape == "adresses"){
	loadAdresseFacturation();
	}
	}
}

}
	
	
	
function test ()
{



	if(document.body.clientHeight < document.body.offsetHeight)
	{
	document.getElementById('test').style['height'] = document.body.offsetHeight+'px';
	}
	else
	{
	document.getElementById('test').style['height'] = document.body.clientHeight+'px';
	}
	
	document.getElementById('test').style['display'] = "block";

}



function etapeSuivante(template)
{

}

function maskPub()
{

document.getElementById('pub').style['display'] = 'none';	
}







function moins(argu)
{
	if(eval (document.getElementById("text"+argu+"").value)>0)
	{
	document.getElementById("text"+argu+"").value= eval (document.getElementById("text"+argu+"").value) -1;
	}
}

function plus(argu)
{
	if(eval (document.getElementById("text"+argu+"").value)<10)
	{
	document.getElementById("text"+argu+"").value= eval (document.getElementById("text"+argu+"").value) +1;
	}
}

function verifLogin()
{


    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_verifLogin(xhr); };
	

    xhr.open("GET", chemin+"/php/verifLogin.php", true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(null);


}


function alert_verifLogin(xhr)
{


    if (xhr.readyState==4) 
    {



		if (xhr.responseText == 1)
		{

		etape("adresses");
		
		}
		
		else
		{
		etape("identification");
		
		
		}
	


	}
}






function inscriptionNewsletter()
{


    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_inscriptionNewsletter(xhr); };
	

    xhr.open("GET", chemin+"/php/inscriptionNewsletter.php?login="+document.getElementById('loginInput2').value, true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(null);


}


function alert_inscriptionNewsletter(xhr)
{

    if (xhr.readyState==4) 
    {

		document.getElementById("perdu").innerHTML =trad171;
	}
}






function pass()
{


    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_pass(xhr); };
	

    xhr.open("GET", chemin+"/php/pass.php?login="+document.getElementById('loginInput2').value, true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(null);


}


function alert_pass(xhr)
{


    if (xhr.readyState==4) 
    {



		if (xhr.responseText == 1)
		{

		
		document.getElementById("perdu").innerHTML =trad134;
		 setTimeout("etape('identification')",3000);
		
		
		}
		
		else
		{

		document.getElementById("perdu").innerHTML = trad135;
		 setTimeout("etape('perdu')",3000);
		
		}
	


	}
}



function loginAjax2()
{

if (document.getElementById('loginInput2').value != "" && document.getElementById('passInput2').value != "" )
{
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_loginAjax2(xhr); };
	
	
    xhr.open("POST", chemin+"/php/loginAjax.php", true);


	donnees = "";
	donnees += "&login="+ document.getElementById('loginInput2').value;
	donnees += "&pass="+ document.getElementById('passInput2').value;;

		
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(donnees);


}
}


function alert_loginAjax2(xhr)
{
	
    if (xhr.readyState==4) 
    {


		if (xhr.responseText == 1)
		{

		etape('adresses');
		
		}
		
		else
		{
		document.getElementById("messageAlert").innerHTML = trad137;

		
		}
	


	}
}




function logout()
{


    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_logout(xhr); };
	
	
    xhr.open("GET", chemin+"/php/logout.php", true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
    xhr.send(null);


}


function alert_logout(xhr)
{
	
    if (xhr.readyState==4) 
    {


	location.reload() ;
		

	}
}





function loginAjax()
{

if (document.getElementById('loginInput').value != "" && document.getElementById('passInput').value != "" )
{
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_loginAjax(xhr); };
	
	
    xhr.open("POST", chemin+"/php/loginAjax.php", true);
  

	donnees = "";
	donnees += "&login="+ document.getElementById('loginInput').value;
	donnees += "&pass="+ document.getElementById('passInput').value;

		
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(donnees);


}
}


function alert_loginAjax(xhr)
{
	
    if (xhr.readyState==4) 
    {

	if (xhr.responseText == 1)
		{

		document.location.href = chemin+"/"+alias_langues+"/moncompte/";
		
		}
		
		else
		{
		document.getElementById("messageAlert2").innerHTML = trad137;
		
		
		}
	

		


	}
}






function loginAjax3()
{

if (document.getElementById('loginInput3').value != "" && document.getElementById('passInput3').value != "" )
{
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_loginAjax3(xhr); };
	

    xhr.open("POST", chemin+"/php/loginAjax.php", true);
  

	donnees = "";
	donnees += "&login="+ document.getElementById('loginInput3').value;
	donnees += "&pass="+ document.getElementById('passInput3').value;

		
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(donnees);


}
}


function alert_loginAjax3(xhr)
{
	
    if (xhr.readyState==4) 
    {

	if (xhr.responseText == 1)
		{

	location.reload() ;
		
		}
		
		else
		{
		
		document.getElementById("messageAlert4").innerHTML = trad137;
		
		
		}
	

		


	}
}





function rechercher(xhr)
{

document.location.href= chemin+"/"+alias_langues+"/search/"+document.getElementById('rechercheInput').value;
}

function contact() {
location.href="mailto:contact@ellabache.com";
}




/*
function favoris()
{
	if ( navigator.appName != "Microsoft Internet Explorer" )
	{
	window.sidebar.addPanel("Ella Baché","http://www.ellabache.com","");
	}
	
	
	else
	{
	window.external.AddFavorite("http://www.ellabache.com","Ella Baché");
	}
}
*/













function insertionCommande(typePaiement)
{



  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_insertionCommande(xhr); };


    xhr.open("GET", chemin+"/php/insertionCommande.php?typePaiement="+typePaiement, true);
	
	
	if (document.getElementById('checkboxCGV').checked == true)
	{
    xhr.send(null);
	}
	else
	{
	document.getElementById('cgv').style['color'] = "#ff0000" ;
	}

function alert_insertionCommande(xhr)
{
	
    if (xhr.readyState==4) 
    {
		if (typePaiement == "cb")
		{

		
		var chaine = xhr.responseText;
		var tableau = chaine.split('|');

		ref = tableau[0];
		total_ttc =	tableau[1];
		email =	tableau[2];
		crypt = tableau[3];
		
		document.form.PBX_CMD.value = ref;
		document.form.PBX_PORTEUR.value = email;
		document.form.PBX_TOTAL.value = total_ttc;
		
		
		document.form.PBX_EFFECTUE.value = chemin+"/"+alias_langues+"/confirmation/effectue/"+ref+"/";
		document.form.PBX_REFUSE.value = chemin+"/"+alias_langues+"/confirmation/refuse/"+ref+"/";
		document.form.PBX_ANNULE.value = chemin+"/"+alias_langues+"/confirmation/annule/"+ref+"/";
		
		
		
		
		document.form.submit();
		}
		
		else if (typePaiement == "ch")
		{
		document.getElementById("container").innerHTML = xhr.responseText;
		}
	
	}
}

}






function ajouterAjax2()
{
  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_ajouterAjax2(xhr); };
	
	
    xhr.open("POST", chemin+"/php/ajouterAjax.php", true);
  

	donnees = "";
	z=0;
	for ( var f=0; f < document.getElementById('blocs3').getElementsByTagName('select').length; f++ )
				
	{


	
		if (document.getElementsByTagName('select')[f].value > 0 )
		{
	
		donnees += "&table"+z+"=produit";
		donnees += "&id"+z+"="+document.getElementById('blocs3').getElementsByTagName('input')[f].value;
		donnees += "&nb"+z+"="+document.getElementById('blocs3').getElementsByTagName('select')[f].value;
		z++;
		}
	
	
	}
	
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

	if (z>0)
	{
    xhr.send(donnees);
	}



}



function alert_ajouterAjax2(xhr)
{
	
    if (xhr.readyState==4) 
    {
	ajax();


	}
}










function recupSoinSelect(table){
	
		if(document.getElementById('check0').checked == true){
			var id = document.getElementById('check0').value;
		}else if(document.getElementById('check1').checked == true){
			var id = document.getElementById('check1').value;
		}
	
	ajouterAjaxSimple(id,table);
}



function ajouterAjaxSimple(id,table)
{
	
  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_ajouterAjaxSimple(xhr); };
	
	
    xhr.open("POST", chemin+"/php/ajouterAjax.php", true);
  

	donnees = "";
	donnees += "&id0="+id;
	if(table){

	donnees += "&table0=bon"+'';
	}else{
	donnees += "&table0=produit"+'';
	}
	donnees += "&nb0=1";

	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(donnees);
}

function ajouterAjax(bloc,panier)
{
  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { 
	if(xhr.readyState==4){	
	if(panier){
	goPanier();
}else{
	alert_ajouterAjax(xhr);
}
	}
	};
	

    xhr.open("POST", chemin+"/php/ajouterAjax.php", true);
  

	donnees = "";
	z=0;


	for ( var f=0; f < document.getElementById('blocs'+bloc).getElementsByTagName('input').length/3; f++ )
				
	{


		d= 3*f;
		
		
	
		if ( document.getElementById('blocs'+bloc).getElementsByTagName('input')[d].value > 0 )
		{
		

		donnees += "&nb"+z+"="+document.getElementById('blocs'+bloc).getElementsByTagName('input')[d].value;
		
		d++;
	
		donnees += "&id"+z+"="+document.getElementById('blocs'+bloc).getElementsByTagName('input')[d].value;
		
		d++;
		
		donnees += "&table"+z+"="+document.getElementById('blocs'+bloc).getElementsByTagName('input')[d].value;
		
		z++;
		}

	
	
	}
	
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

	if (z>0)
	{
	
    xhr.send(donnees);
	}



}




function goPanier()
{

document.location.href = chemin+"/"+alias_langues+"/panier/";
}
function alert_ajouterAjax(xhr)
{
	
    if (xhr.readyState==4) 
    {

	popupChoix();

	}
}

function alert_ajouterAjaxSimple(xhr)
{
	
    if (xhr.readyState==4) 
    {
	
	popupChoix();
	

	}
}




function countPanier()
{
  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_countPanier(xhr); };


    xhr.open("GET", chemin+"/php/countPanier.php", true);
    xhr.send(null);

}


function alert_countPanier(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("countPanier").innerHTML = xhr.responseText;



	}
}



function ajax(id, action)
{



  var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() {
	alert_ajax(xhr);
	
	};
	
	

    xhr.open("GET", chemin+"/php/modifierPanier.php?id="+id+"&action="+action, true);
    xhr.send(null);



}

function testCodePromo(first){
	
	var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { 
	if(first){
		reloadPanierPourPromo(xhr);
	}else{
	afficheResultatCode(xhr); 
	}
	
	};
	
	
	id = document.getElementById("code").value;
	

    xhr.open("GET", chemin+"/php/testCode.php?code="+id, true);
	if(id != ''){
    xhr.send(null);
	}
	
}
function reloadPanierPourPromo(xhr){
	 if (xhr.readyState==4){ 
	location.reload() ;
	 }
}

function afficheResultatCode(xhr){
	 if (xhr.readyState==4){ 
	
	document.getElementById("codePromo").innerHTML = xhr.responseText;
	//document.location.href = chemin+"/"+alias_langues+"/panier/";
}
	
}

function alert_ajax(xhr)
{
	
    if (xhr.readyState==4) 
    {

document.getElementById("panier").innerHTML = xhr.responseText;


countPanier();
testCodePromo();
	}
}

function inscriptionContact()
{
	
	if(document.getElementById('nom').value != "" && document.getElementById('prenom').value != "" && document.getElementById('mail').value != ""){

    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.onreadystatechange = function() { alert_inscriptionContact(xhr); };
	

    xhr.open("POST", chemin+"/php/inscriptionContact.php?nom="+document.getElementById('nom').value+"&prenom="+document.getElementById('prenom').value+"&adresse="+document.getElementById('adresse').value+"&mail="+document.getElementById('mail').value+"&telfixe="+document.getElementById('telfixe').value+"&telport="+document.getElementById('telport').value+"&cp="+document.getElementById('cp').value+"&ville="+document.getElementById('ville').value+"&pays="+document.getElementById('pays').value+"&message="+document.getElementById('message').value+"&langue="+document.getElementById('langue').value+"&adresse2="+document.getElementById('adresse2').value+"&societe="+document.getElementById('societe').value, true);

	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 

    xhr.send(null);
}else{
		document.getElementById("popupDhtmlContennu").innerHTML = trad147;
		document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';
setTimeout("fermerPopupDoublon()",2000);
}
}
function alert_inscriptionContact(xhr)
{
	
    if (xhr.readyState==4) 
    {
		
				document.getElementById("popupDhtmlContennu").innerHTML = trad228;
		document.getElementById('popupDhtml').style['height'] = document.getElementById('main').offsetHeight+100+'px';
document.getElementById('popupDhtmlFond').style['height'] = document.getElementById('main').offsetHeight+'px';

document.getElementById('popupDhtml').style['display'] = 'block';
setTimeout("location.reload()",2000);
	}

}
