
var xhr = null; 
function getXhr()
{
     if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
else if(window.ActiveXObject)
  { 
  try{
     xhr = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) 
     {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
  }
else 
  {
  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
  xhr = false; 
  } 
}

/* ***************************************************************************************** */
/* 				Fonction pour CHANGER LE TYPE DE LIVRAISON dans la COMMANDE					 */
/* ***************************************************************************************** */

function updateLivr(type)
{
	
getXhr()
xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('cmd').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?livraison=' + type + '&rand=' + rand;
 
	xhr.open("GET","php/commande.php"+pars,true);
	xhr.send(null);
}



/* ***************************************************************************************** */
/* 				Fonction pour CHANGER LA DESTINATION (+degroupage) dans la COMMANDE			 */
/* ***************************************************************************************** */

function updateDest(dest)
{
getXhr()
xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('cmd').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?dest=' + dest + '&rand=' + rand;
 
	xhr.open("GET","php/commande.php"+pars,true);
	xhr.send(null);
}




/* ***************************************************************************************** */
/*					 Fonction pour CHANGER LA QUANTITE  dans la COMMANDE					 */
/* ***************************************************************************************** */

function updateCmd(id, sens)
{
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('cmd').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?id_panier=' + id +'&sens=' + sens + '&rand=' + rand;
	
	xhr.open("GET","php/change_qte_cmd.php"+pars,true);
	xhr.send(null);
}		



/* ***************************************************************************************** */
/* 					Fonction pour SUPPRIMER UN PRODUIT dans la COMMANDE 					 */
/* ***************************************************************************************** */

function supprCmd (id) {
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('cmd').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?id_panier=' + id + '&rand=' + rand;
	
	xhr.open("GET","php/suppr_cmd.php"+pars,true);
	xhr.send(null);
	
}		



/* ***************************************************************************************** */
/*					 Fonction pour CHANGER LA QUANTITE  dans le PANIER						 */
/* ***************************************************************************************** */

function updatePanier(id, sens)
{
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('panier').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?id_panier=' + id +'&sens=' + sens + '&rand=' + rand;
	
	xhr.open("GET","php/change_qte_panier.php"+pars,true);
	xhr.send(null);
}		

/* ***************************************************************************************** */
/* 					Fonction pour SUPPRIMER UN PRODUIT dans le PANIER 						 */
/* ***************************************************************************************** */

function supprPanier (id) {
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('panier').innerHTML=xhr.responseText;}
   	}

	var rand   = Math.random(9999);
	var pars   = '?id_panier=' + id + '&rand=' + rand;
	
	xhr.open("GET","php/suppr_panier.php"+pars,true);
	xhr.send(null);
	/* maj_votre_panier();*/
}		

/* ***************************************************************************************** */
/* 					Fonction pour AJOUTER un PRODUIT dans le PANIER 						 */
/* ***************************************************************************************** */
function insertPanier (id) {
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('panier').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?id_produit=' + id + '&rand=' + rand;
	
	xhr.open("GET","php/insert_panier.php"+pars,true);
	xhr.send(null);
	/*majVotrePanier();*/
}		



/* ***************************************************************************************** */
/* 					Fonction pour METTRE A JOUR VOTRE PANIER						 */
/* ***************************************************************************************** */
function majVotrePanier() {
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('votrepanier').innerHTML=xhr.responseText; }
	 
   	}

	var rand   = Math.random(9999);
	var pars   = '?rand=' + rand;
	
	xhr.open("GET","php/votre_panier.php"+pars,true);
	xhr.send(null);

	
	
}

/* ***************************************************************************************** */
/* 					Fonction pour GESTION CODE AFFILIATION						 */
/* ***************************************************************************************** */
function updatePromo(affiliation) {
	
	
	getXhr()
	xhr.onreadystatechange = function()
	{
   	 if(xhr.readyState == 4 && xhr.status == 200){ document.getElementById('cmd').innerHTML=xhr.responseText; }
   	}

	var rand   = Math.random(9999);
	var pars   = '?affiliation=' + affiliation + '&rand=' + rand;
	
	xhr.open("GET","php/commande.php"+pars,true);
	xhr.send(null);
	/*majVotrePanier();*/

	
	
}


