var xhr = null;
var xhr2 = null;

function getXhr()
{
  if(window.XMLHttpRequest)
   {
    xhr = new XMLHttpRequest();
   }
  else if(window.ActiveXOject)
   {
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch(e)
     {
      try
       {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
       }
      catch(el)
       {
        xhr = null;
       }
     }
   }
  else
   {
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest\nVeuillez le mettre à jour");
   }
   return xhr;
}

function getXhr3()
{
  if(window.XMLHttpRequest)
   {
    xhr3 = new XMLHttpRequest();
   }
  else if(window.ActiveXOject)
   {
    try
     {
      xhr3 = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch(e)
     {
      try
       {
        xhr3 = new ActiveXObject("Microsoft.XMLHTTP");
       }
      catch(el)
       {
        xhr3 = null;
       }
     }
   }
  else
   {
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest\nVeuillez le mettre à jour");
   }
   return xhr3;
}

function getXhr2()
{
  if(window.XMLHttpRequest)
   {
    xhr2 = new XMLHttpRequest();
   }
  else if(window.ActiveXOject)
   {
    try
     {
      xhr2 = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch(e)
     {
      try
       {
        xhr2 = new ActiveXObject("Microsoft.XMLHTTP");
       }
      catch(el)
       {
        xhr2 = null;
       }
     }
   }
  else
   {
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest\nVeuillez le mettre à jour");
   }
   return xhr2;
}


//***********************************************Fonction pour connaitres les couleurs d'une taille********************************
function couleurs_dispo(id_produit,width,height,width_mini,height_mini,id_rayon)
 {
  xhr=getXhr();
  xhr.onreadystatechange = function()
   { 
		if(xhr.readyState == 4 && xhr.status == 200)
		{	
		 	
			var xmldoc 		= xhr.responseXML.documentElement;
	  		var compteur 	= xmldoc.getElementsByTagName("id_couleur").length;
			var prix_normal = xmldoc.getElementsByTagName("prix_normal")[0].childNodes[0].nodeValue;
			var prix_promo 	= xmldoc.getElementsByTagName("prix_promo")[0].childNodes[0].nodeValue;
			var pourcentage = xmldoc.getElementsByTagName("pourcentage")[0].childNodes[0].nodeValue;
			var id_produit	= xmldoc.getElementsByTagName("id_produit")[0].childNodes[0].nodeValue;
			var id_taille	= xmldoc.getElementsByTagName("id_taille")[0].childNodes[0].nodeValue;
			var promo		= xmldoc.getElementsByTagName("promo")[0].childNodes[0].nodeValue;
			var solde		= xmldoc.getElementsByTagName("solde")[0].childNodes[0].nodeValue;
			prix_normal = prix_normal.replace(",",".");
			prix_promo = prix_promo.replace(",",".");
			pourcentage = pourcentage.replace(",",".");
			
			if (document.getElementById("choix_couleur").value != 0 && document.getElementById("choix_couleur").value != '') {
				var couleur_actuelle = document.getElementById("choix_couleur").value;
			}
			else {
				var couleur_actuelle = 0
			}
			
			node=document.getElementById('selection_couleur');
			node.innerHTML="";
			if (prix_normal > prix_promo && prix_promo != 0) {
				//modifier par abir le 06/09/2011
					document.getElementById("prix_promo").innerHTML = parseFloat(prix_promo).toFixed(2) +" &euro;" ;
					/*document.getElementById("block_pourcentage").style.display='block';
					document.getElementById("pourcentage").innerHTML = Math.round(parseFloat(pourcentage))+ "%" ;*/
					if ((promo == -1) || (solde == -1))
						document.getElementById("prix_barre").innerHTML = parseFloat(prix_normal).toFixed(2) +" &euro;";
					
					document.getElementById("prix_unitaire").value = parseFloat(prix_promo).toFixed(2) ;
					document.getElementById("montant_total").value = parseFloat(prix_promo).toFixed(2) ;
					document.getElementById("quantite").value=1 ;
				
			}
			else {
				if (prix_promo == 0) {
					document.getElementById("prix_promo").innerHTML = "N.C";
					document.getElementById("prix_unitaire").value = "N.C";
					document.getElementById("montant_total").value = "N.C";
					/*document.getElementById("block_pourcentage").style.display='none'*/;
					document.getElementById("quantite").value=1 ;
				}
				else {
					
						document.getElementById("prix_promo").innerHTML = parseFloat(prix_promo).toFixed(2) +" &euro;";
						document.getElementById("prix_unitaire").value = parseFloat(prix_promo).toFixed(2) ;
						document.getElementById("montant_total").value = parseFloat(prix_promo).toFixed(2) ;
						/*document.getElementById("block_pourcentage").style.display='none';*/
						document.getElementById("quantite").value=1 ;
					
				}
			}

			if (compteur == 1) {
				var couleur = xmldoc.getElementsByTagName("couleur")[0].childNodes[0].nodeValue;
				var id_couleur = xmldoc.getElementsByTagName("id_couleur")[0].childNodes[0].nodeValue;
				node.innerHTML = '<span style=" font-size:11px;">' + couleur + '</span><input type="hidden" value="'+id_couleur+'" name="choix_couleur" id="choix_couleur" /><input type="hidden" value="'+couleur+'" name="nom_couleur" id="nom_couleur" />';
				if (couleur != 'Non dispo') {
					document.getElementById('bouton_panier').style.display = 'none';	
				}
				else {
					document.getElementById('bouton_panier').style.display = '';
				}
				verif_dispo(id_produit,id_taille, id_couleur);
				photos_couleur(id_produit,id_couleur,width,height,width_mini,height_mini);
			}
			else if (compteur > 1) {
				var valeur_select = '<span style="float:left;"><select name="choix_couleur" style="width:90px; margin-left:6px;"  size="1" id="choix_couleur" onchange="document.getElementById(\'bouton_panier\').style.display=\'none\';verif_dispo('+id_produit+',0,0);couleurs_dispo('+id_produit+',' + width +','+height+','+width_mini+','+height_mini+','+id_rayon+');photos_couleur('+id_produit+',this.value,'+ width +','+height+','+width_mini+','+height_mini+');">';
				for(i=0;i<compteur;i++) {
					var id_couleur = xmldoc.getElementsByTagName("id_couleur")[i].childNodes[0].nodeValue;
					var couleur = xmldoc.getElementsByTagName("couleur")[i].childNodes[0].nodeValue;
					if (i == 0 && couleur_actuelle != id_couleur) {
						verif_dispo(id_produit,id_taille, id_couleur);
						photos_couleur(id_produit,id_couleur,width,height,width_mini,height_mini);
					}
					if (couleur_actuelle == id_couleur) {
						valeur_select = valeur_select + '<option value="' + id_couleur + '" selected="selected">' + couleur + '</option>';
						verif_dispo(id_produit,id_taille, id_couleur);
						photos_couleur(id_produit,id_couleur,width,height,width_mini,height_mini);
					}
					else {
						valeur_select = valeur_select + '<option value="' + id_couleur + '">' + couleur + '</option>';
					}
				}	  
			  	valeur_select = valeur_select + '</select></span>';
				node.innerHTML = valeur_select;
				document.getElementById('bouton_panier').style.display = '';
			}
			else {
				node.innerHTML = 'Couleur non disponible.<td align="left"><input type="hidden" value="0" name="choix_couleur" id="choix_couleur" /><input type="hidden" value="Couleur non disponible" name="nom_couleur" id="nom_couleur" />';
				document.getElementById('bouton_panier').style.display = 'none';
			}
			//alert('fin couleurs dispo');
			if (id_rayon!=331714 && id_rayon!=331720)
				affiche_taille(id_taille,id_produit,id_rayon);
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
		
   }

  var id_taille = document.getElementById('choix_taille').value;
  var id_couleur = document.getElementById('choix_couleur').value;

  if (document.getElementById('id_vente_flash')) {
	  var id_vente_flash = document.getElementById('id_vente_flash').value;
  }
  else {
	  var id_vente_flash = 0  ;
  }

  

  xhr.open("POST",'javascript/taille_couleur_prix.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_vente_flash=" + id_vente_flash + "&width=" + width + "&height=" + height+ "&id_couleur=" + id_couleur);
 }
 
 function couleurs_dispo_package(id_produit, id_pack, rang)
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
	  		var compteur 	= xmldoc.getElementsByTagName("id_couleur").length;
			var id_produit	= xmldoc.getElementsByTagName("id_produit")[0].childNodes[0].nodeValue;
			var id_taille	= xmldoc.getElementsByTagName("id_taille")[0].childNodes[0].nodeValue;
			var id_pack		= xmldoc.getElementsByTagName("id_pack")[0].childNodes[0].nodeValue;

			if (rang != 999) {
				node=document.getElementById('selection_couleur_'+rang);	
			}
			else {
	  			node=document.getElementById('selection_couleur');
			}
			node.innerHTML="";
			
			if (compteur == 1) {
				var couleur = xmldoc.getElementsByTagName("couleur")[0].childNodes[0].nodeValue;
				var id_couleur = xmldoc.getElementsByTagName("id_couleur")[0].childNodes[0].nodeValue;
				if (rang != 999) {
					node.innerHTML = 'Couleur unique : <strong>' + couleur + '</strong><input type="hidden" value="'+id_couleur+'" name="choix_couleur_'+rang+'" id="choix_couleur_' + rang + '" /><input type="hidden" value="'+couleur+'" name="nom_couleur" id="nom_couleur" />';
				}
				else {
					node.innerHTML = 'Couleur unique :</td><td align="left"> <strong>' + couleur + '</strong><input type="hidden" value="'+id_couleur+'" name="choix_couleur" id="choix_couleur" /><input type="hidden" value="'+couleur+'" name="nom_couleur" id="nom_couleur" />';
				}
				verif_dispo_package(id_produit,id_taille, id_couleur, rang, id_pack);
			}
			else if (compteur > 1) {
				if (rang != 999) {
					var valeur_select = 'Couleur(s) : <select name="choix_couleur_'+rang+'" size="1" id="choix_couleur_'+rang+'" onchange="verif_dispo_package('+id_produit+',0,0,'+rang+','+id_pack+')">';	
				}
				else {
					var valeur_select = 'Choix de la couleur :</td><td align="left"><select name="choix_couleur" size="1" id="choix_couleur" onchange="verif_dispo_package('+id_produit+',0,0,'+rang+','+id_pack+')">';	
				}
				
				for(i=0;i<compteur;i++) {
					var id_couleur = xmldoc.getElementsByTagName("id_couleur")[i].childNodes[0].nodeValue;
					var couleur = xmldoc.getElementsByTagName("couleur")[i].childNodes[0].nodeValue;
					if (i == 0) {
						verif_dispo_package(id_produit,id_taille, id_couleur, rang, id_pack);
					}
					valeur_select = valeur_select + '<option value="' + id_couleur + '">' + couleur + '</option>';
				}	  
			  	valeur_select = valeur_select + '</select>';
				node.innerHTML = valeur_select;
			}
			else {
				if (rang != 999) {
					node.innerHTML = '<table><tr><td align="right" valign="top" width="115">Unicolore.<td align="left"><input type="hidden" value="0" name="choix_couleur_'+rang+'" id="choix_couleur_'+rang+'" /><input type="hidden" value="Unicolore" name="nom_couleur_'+rang+'" id="nom_couleur_'+rang+'" /></td></tr></table>';	
				}
				else {
					node.innerHTML = '<table><tr><td align="right" valign="top" width="115">Unicolore.<td align="left"><input type="hidden" value="0" name="choix_couleur" id="choix_couleur" /><input type="hidden" value="Couleur non disponible" name="nom_couleur" id="nom_couleur" /></td></tr></table>';
				}
			}
			//alert('fin couleurs_dispo_package');
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }

  if (rang != 999) {
	 var id_taille = document.getElementById('choix_taille_'+rang).value; 
  }
  else {
	 var id_taille = document.getElementById('choix_taille').value;  
  }
  
  //alert("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_pack=" + id_pack);
  
  xhr.open("POST",'javascript/taille_couleur_prix.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_pack=" + id_pack);
 }
 
 //************************************************verification des disponibilités pour une taille et une couleur donnée**************************
 
 function verif_dispo(id_produit, id_taille, id_couleur)
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var disponible 	= xmldoc.getElementsByTagName("disponible")[0].childNodes[0].nodeValue;
			var dispo_fr 	= xmldoc.getElementsByTagName("dispo_fr")[0].childNodes[0].nodeValue;
			var dispo_gb 	= xmldoc.getElementsByTagName("dispo_gb")[0].childNodes[0].nodeValue;
			var picto_fr 	= xmldoc.getElementsByTagName("picto_fr")[0].childNodes[0].nodeValue;
			var picto_gb 	= xmldoc.getElementsByTagName("picto_gb")[0].childNodes[0].nodeValue;
			var info_sup_fr = xmldoc.getElementsByTagName("info_sup_fr")[0].childNodes[0].nodeValue;
			var info_sup_gb = xmldoc.getElementsByTagName("info_sup_gb")[0].childNodes[0].nodeValue;
			var id_lang 	= xmldoc.getElementsByTagName("id_lang")[0].childNodes[0].nodeValue;
			var couleur 	= xmldoc.getElementsByTagName("texte_couleur")[0].childNodes[0].nodeValue;
			
	  		node			=	document.getElementById('bouton_panier');	

			if (disponible == 0) {
				node.style.display = 'none';
				//if (id_lang == 0) {
//					//document.getElementById('img_dispo').src = "images_site/quantite/reapro.gif";
//
//					document.getElementById('text_dispo').innerHTML = '<span class="en_stock"  style="color:#FF0000";>Indisponible</span>';	
//				}
//				else {
//					//document.getElementById('img_dispo').src = "images_site/quantite/reapro_gb.gif";
//					document.getElementById('text_dispo').innerHTML = '<span class="en_stock"  style="color:#FF0000";>This produit is unavailable for now.</span>';		
//				}
				//document.getElementById('dispo_produit').style.display = '';
				//document.getElementById('taille_alerte').value = document.getElementById('choix_taille').value;
				//document.getElementById('couleur_alerte').value = document.getElementById('choix_couleur').value;
			}
			else {
				node.style.display = '';
				if (picto_fr != '0') {
					//document.getElementById('img_dispo').src = "images/picto_dispo/" + picto_fr;
				}

				//pour le javascript qui montre le texte au passage de la souris
				//var valeur_inner = '<span class="en_stock" style="color:' + couleur + ';"  onmouseover="montre(\'' + info_sup_fr + '\');" onmouseout="cache();">' + dispo_fr + '</span>';
				//document.getElementById('info_dispo').title = info_sup_fr;
				var valeur_inner = '<span class="en_stock" style="color:' + couleur + ';">' + dispo_fr + '</span>';
				
				//if (document.getElementById('text_dispo').innerHTML != valeur_inner) {
					//pour le javascript qui montre le texte au passage de la souris
					//document.getElementById('text_dispo').innerHTML = '<span class="en_stock" style="color:' + couleur + ';"  onmouseover="montre(\'' + info_sup_fr + '\');" onmouseout="cache();">' + dispo_fr + '</span>';
					//document.getElementById('info_dispo').title = info_sup_fr;
					//document.getElementById('text_dispo').innerHTML = '<span class="en_stock" style="color:' + couleur + ';">' + dispo_fr + '</span>';
				//}
				//document.getElementById('dispo_produit').style.display = 'none';
			}
			//alert('fin verif_dispo');
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }

   if (id_taille == 0 && id_couleur == 0) {
	  if (document.getElementById('choix_taille')) {
	  	var id_taille = document.getElementById('choix_taille').value;
	  }
	  else {
		var id_taille = 0;  
	  }
	  
	   if (document.getElementById('choix_couleur')) {
	  	var id_couleur = document.getElementById('choix_couleur').value;
	  }
	  else {
		var id_couleur = 0;
	  }
   }
   
   //alert("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur);
	
  if (id_taille != 0) {
	  xhr.open("POST",'javascript/dispo_taille_couleur.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  xhr.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur);
  }
 }
 
 //************************************************verification des disponibilités pour une taille et une couleur donnée pour les packages **************************
 function verif_dispo_package(id_produit, id_taille, id_couleur, rang, id_pack)
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var rang 		= xmldoc.getElementsByTagName("rang")[0].childNodes[0].nodeValue;
			var disponible 	= xmldoc.getElementsByTagName("disponible")[0].childNodes[0].nodeValue;
			var dispo_fr 	= xmldoc.getElementsByTagName("dispo_fr")[0].childNodes[0].nodeValue;
			var dispo_gb 	= xmldoc.getElementsByTagName("dispo_gb")[0].childNodes[0].nodeValue;
			var picto_fr 	= xmldoc.getElementsByTagName("picto_fr")[0].childNodes[0].nodeValue;
			var picto_gb 	= xmldoc.getElementsByTagName("picto_gb")[0].childNodes[0].nodeValue;
			var info_sup_fr = xmldoc.getElementsByTagName("info_sup_fr")[0].childNodes[0].nodeValue;
			var info_sup_gb = xmldoc.getElementsByTagName("info_sup_gb")[0].childNodes[0].nodeValue;
			var couleur 	= xmldoc.getElementsByTagName("texte_couleur")[0].childNodes[0].nodeValue;

			if (disponible == 0) {
				if (rang != 999) {
					//document.getElementById('img_dispo_'+rang).src = "images/picto_dispo/indisponible.png";
					//document.getElementById('text_dispo_'+rang).innerHTML = 'Produit non disponible';
				}
				else {
					//document.getElementById('img_dispo_'+rang).src = "images/picto_dispo/indisponible.png";
					//document.getElementById('text_dispo_'+rang).innerHTML = 'Produit non disponible';
				}
			}
			else {
				if (picto_fr != '0') {
					if (rang != 999) {
						//document.getElementById('img_dispo_'+rang).src = "images/picto_dispo/" + picto_fr;
					}
					else {
						//document.getElementById('img_dispo').src = "images/picto_dispo/" + picto_fr;
					}
				}
				
				if (rang != 999) {
					//document.getElementById('text_dispo_'+rang).innerHTML = info_sup_fr;
				}
				else {
					//document.getElementById('text_dispo').innerHTML = info_sup_fr;
				}
			}
			//alert('fin verif_dispo_package');
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }

   if (id_taille == 0 && id_couleur == 0) {
	  if (rang != 999) {
		var id_taille = document.getElementById('choix_taille_'+rang).value;
	    var id_couleur = document.getElementById('choix_couleur_'+rang).value;  
	  }
	  else {
		var id_taille = document.getElementById('choix_taille').value;
	    var id_couleur = document.getElementById('choix_couleur').value;  
   	  }
	  
   }
   
  //alert("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur + "&rang=" + rang + "&id_pack=" + id_pack);
  
  xhr.open("POST",'javascript/dispo_taille_couleur.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur + "&rang=" + rang + "&id_pack=" + id_pack);
 }
 
 
 //*********** modification de la base lors de modification dans le panier des quantités et produits voulus*******
function modif_commande_ligne(id_commande_ligne, qte, prix_net)
{
  getXhr2()
  xhr2.onreadystatechange = function()
  	{
		if(xhr2.readyState == 4 && xhr2.status == 200) {
			var xmldoc 				= xhr2.responseXML.documentElement;
			var montant_port_total	= xmldoc.getElementsByTagName("montant_port_total")[0].childNodes[0].nodeValue;	
			var prix_total			= xmldoc.getElementsByTagName("prix_total")[0].childNodes[0].nodeValue;	
			var montant_remise		= xmldoc.getElementsByTagName("montant_remise")[0].childNodes[0].nodeValue;
			var quantite_totale		= xmldoc.getElementsByTagName("quantite")[0].childNodes[0].nodeValue;
			var montant_total		= xmldoc.getElementsByTagName("montant_total")[0].childNodes[0].nodeValue;
			var redirection			= xmldoc.getElementsByTagName("redirection")[0].childNodes[0].nodeValue;
			var redirection_code_promo= xmldoc.getElementsByTagName("redirection_code_promo")[0].childNodes[0].nodeValue;
			
			prix_total 				= prix_total.replace(",",".");
			montant_port_total 		= montant_port_total.replace(",",".");
			montant_remise 			= montant_remise.replace(",",".");
			montant_total 			= montant_total.replace(",",".");
			if (redirection==1)
				{
					location.href = "default.asp";
				}
			else
			{
				document.getElementById('montant_frais_port').innerHTML = 	parseFloat(montant_port_total).toFixed(2) + ' &euro;';
				document.getElementById('montant_total').innerHTML = parseFloat(montant_total).toFixed(2);
				document.getElementById('prix_total').innerHTML = parseFloat(prix_total).toFixed(2);
				document.getElementById('montant_remise').innerHTML = parseFloat(montant_remise).toFixed(2);
				//pour les variables du header
				document.getElementById('total').innerHTML = (parseFloat(montant_total)).toFixed(2);
				document.getElementById('qte').innerHTML=  quantite_totale;
			}
			if (redirection_code_promo==1)
				{
					location.href = "commande.asp";
				}
		}
	}
  var prix_total = document.getElementById('prix_total_ligne').value;   
  xhr2.open("POST",'javascript/modif_commande_ligne.asp',true)
  xhr2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr2.send("id_commande_ligne=" + id_commande_ligne + "&qte=" + qte + "&prix_net=" + prix_net + "&prix_total=" + prix_total );
}


 //******************************* calcul des frais de port après le choix du pays de livraison dans l'étape deux du paiement ********************
function calcul_frais_port(id_pays_livraison)
  {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		  	= xhr.responseXML.documentElement;
			var prix_port_total = xmldoc.getElementsByTagName("prix_port_total")[0].childNodes[0].nodeValue;
			var montant_total_commande = xmldoc.getElementsByTagName("montant_total_commande")[0].childNodes[0].nodeValue;
			
			prix_port_total = prix_port_total.replace(",",".");
			montant_total_commande = montant_total_commande.replace(",",".");

			//alert('prix_port_total : ' + prix_port_total);
			//alert('montant_total : ' + montant_total_commande);
			
			document.getElementById('montant_frais_port').innerHTML = parseFloat(prix_port_total).toFixed(2) + "&euro;";
			document.getElementById('prix_port_total').innerHTML = parseFloat(prix_port_total).toFixed(2) ;
			document.getElementById('montant_total').innerHTML = parseFloat(montant_total_commande).toFixed(2);
			document.getElementById('nom_pays').innerHTML = "(" + document.getElementById('choix_pays_livraison').options[document.getElementById('choix_pays_livraison').selectedIndex].text + ")";
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }
   
   if (id_pays_livraison != 0) {
	  var id_pays = id_pays_livraison  
   }
   else{
	  var id_pays = document.getElementById('choix_pays_livraison').value;
   }
   
//   if (document.getElementById('livraison_magasin')) {
//	   if (document.getElementById('livraison_magasin').checked) {
//		   var livraison_magasin = 1
//		   document.getElementById('choix_pays_livraison').value = 708562;
//		   var id_pays = 708562;
//	   }
//	   else {
//		   var livraison_magasin = 0
//	   }
//   }
//   else {
//	  var livraison_magasin = 0   
//   }
//   
//   if (document.getElementById('livraison_normale').checked) 
   		type_livraison = 1
//   else
//   		type_livraison = 2
   
  //alert("id_pays=" + id_pays + "&livraison_magasin=" + livraison_magasin + "&type_livraison=" + type_livraison)
  
  if (document.getElementById('frais_port_offert').value > 1) {
	  xhr.open("POST",'javascript/calcul_frais_port.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  xhr.send("id_pays=" + id_pays + "&type_livraison=" + type_livraison);
  }
}

 
//************************************** verification du login / pass lors de la validation d'une commande***************************************** 
function verif_login()
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var client_existe = xmldoc.getElementsByTagName("client_existe")[0].childNodes[0].nodeValue;
			if (client_existe == 1) {
				var nom_facturation = xmldoc.getElementsByTagName("nom_facturation")[0].childNodes[0].nodeValue;
				var prenom_facturation = xmldoc.getElementsByTagName("prenom_facturation")[0].childNodes[0].nodeValue;
				var tel_facturation = xmldoc.getElementsByTagName("tel_facturation")[0].childNodes[0].nodeValue;
				var email_facturation = xmldoc.getElementsByTagName("email_facturation")[0].childNodes[0].nodeValue;
				var adresse_facturation = xmldoc.getElementsByTagName("adresse_facturation")[0].childNodes[0].nodeValue;
				var cp_facturation = xmldoc.getElementsByTagName("cp_facturation")[0].childNodes[0].nodeValue;
				var ville_facturation = xmldoc.getElementsByTagName("ville_facturation")[0].childNodes[0].nodeValue;
				var pays_facturation = xmldoc.getElementsByTagName("pays_facturation")[0].childNodes[0].nodeValue;
				var id_pays_facturation = xmldoc.getElementsByTagName("id_pays_facturation")[0].childNodes[0].nodeValue;
				var nom_livraison = xmldoc.getElementsByTagName("nom_livraison")[0].childNodes[0].nodeValue;
				var prenom_livraison = xmldoc.getElementsByTagName("prenom_livraison")[0].childNodes[0].nodeValue;
				var tel_livraison = xmldoc.getElementsByTagName("tel_livraison")[0].childNodes[0].nodeValue;
				var email_livraison = xmldoc.getElementsByTagName("email_livraison")[0].childNodes[0].nodeValue;
				var adresse_livraison = xmldoc.getElementsByTagName("adresse_livraison")[0].childNodes[0].nodeValue;
				var cp_livraison = xmldoc.getElementsByTagName("cp_livraison")[0].childNodes[0].nodeValue;
				var ville_livraison = xmldoc.getElementsByTagName("ville_livraison")[0].childNodes[0].nodeValue;
				var pays_livraison = xmldoc.getElementsByTagName("pays_livraison")[0].childNodes[0].nodeValue;
				var id_pays_livraison = xmldoc.getElementsByTagName("id_pays_livraison")[0].childNodes[0].nodeValue;
				var password = xmldoc.getElementsByTagName("pass")[0].childNodes[0].nodeValue;
				var societe = xmldoc.getElementsByTagName("societe")[0].childNodes[0].nodeValue;
				var fax = xmldoc.getElementsByTagName("fax")[0].childNodes[0].nodeValue;
				var num_siret = xmldoc.getElementsByTagName("num_siret")[0].childNodes[0].nodeValue;
				var num_tva = xmldoc.getElementsByTagName("num_tva")[0].childNodes[0].nodeValue;
				var frais_port_offert = xmldoc.getElementsByTagName("frais_port_offert")[0].childNodes[0].nodeValue;
				if (frais_port_offert != 0) {
					var montant_total = xmldoc.getElementsByTagName("montant_total")[0].childNodes[0].nodeValue;
				}
				document.getElementById('objet1').style.display='none';
				
				if ( prenom_facturation == '-' ||  prenom_facturation == '')
					infos_client = nom_facturation ;
				else
					infos_client = nom_facturation + " " + prenom_facturation ;
				document.getElementById("connect").innerHTML = "<span style=' color:#FFF; font-weight:bold; font-style:italic; padding-right:5px;'>" + infos_client + " </span> <a href='mon_compte_coordonnee.asp'> <img title='Voir mon compte' alt='Voir mon compte' src='images/boutons/voir_mon_compte.png' width='130' height='13' border='0' /></a> <a href='default.asp?action=deconnexion'> <img title='se deconnecter' alt='se deconnecter' src='images/boutons/se_deconnecter.png' width='130' height='13' border='0' /></a>";
       
				document.getElementById("man_nom_facturation").value = nom_facturation;
				document.getElementById("prenom_facturation").value = prenom_facturation;
				document.getElementById("tel_facturation").value = tel_facturation;
				document.getElementById("email_facturation").value = email_facturation;
				document.getElementById("man_adresse_facturation").value = adresse_facturation;
				document.getElementById("man_cp_facturation").value = cp_facturation;
				document.getElementById("man_ville_facturation").value = ville_facturation;
				document.getElementById("man_nom_livraison").value = nom_livraison;
				document.getElementById("prenom_livraison").value = prenom_livraison;
				document.getElementById("tel_livraison").value = tel_livraison;
				document.getElementById("email_livraison").value = email_livraison;
				document.getElementById("man_adresse_livraison").value = adresse_livraison;
				document.getElementById("man_cp_livraison").value = cp_livraison;
				document.getElementById("man_ville_livraison").value = ville_livraison;
				document.getElementById("man_password").value = password;
				document.getElementById("man_confirm_password").value = password;
				//document.getElementById("confirm_email_facturation").value = email_facturation;
				//document.getElementById("nom_societe").value = societe;
				//document.getElementById("num_fax").value = fax;
				//document.getElementById("num_siret").value = num_siret;
				//document.getElementById("num_tva").value = num_tva;
				
				if (document.getElementById('livraison_magasin')) {
					document.getElementById('livraison_magasin').checked = false;
				}

				if (( num_tva != '' || societe != '') && (num_tva != '-' || societe != '-')) {
					document.getElementById('type_client_societe').checked = true;
					document.getElementById('type_client_particulier').checked = false;
					show_hide_societe(1);
				}

				if (id_pays_facturation != 0) {
					document.getElementById('choix_pays').value = id_pays_facturation;
					if (id_pays_facturation != 101451)
					{
						document.getElementById('paiement_par_cheque').style.display = 'none';
						document.getElementById('text_cheque').style.display = 'none';
						document.getElementById('paiement_cb').checked = true;
					}
					else 
						{
							document.getElementById('paiement_par_cheque').style.display = '';
							document.getElementById('text_cheque').style.display = '';
						}
				}
				if (id_pays_livraison != 0) {
					document.getElementById('choix_pays_livraison').value = id_pays_livraison;
					if (frais_port_offert == 0) {
						calcul_frais_port(id_pays_livraison);
					}
				}
				
				//alert('frais_port_offert : ' + frais_port_offert);
				//alert('montant_total : ' + montant_total);
				
				if (frais_port_offert != 0 && montant_total != 0) {
					document.getElementById('prix_port_total').innerHTML = '0&euro;';
					document.getElementById('valeur_total').value = montant_total;
					document.getElementById('montant_total').innerHTML = montant_total + '&euro;';
					document.getElementById('frais_port_offert').value = 1;
					alert('Vous faites parti des 100 premiers inscrit \à notre newsletter, les frais de port vous sont offerts.');
				}
			}
			else {
				alert("L\'email ou le mot de passe que vous avez rentr\é n\'est pas correct.")
			}
			//document.getElementById('chargement').style.display='none';
			
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }
   
  var login = document.getElementById('login').value;
  var pass = document.getElementById('pass').value;

  if (login.replace(/^\s+/g,'').replace(/\s+$/g,'') == '' || pass.replace(/^\s+/g,'').replace(/\s+$/g,'') == '') {
  	  alert('Le login et le mot de passe ne peuvent pas \être vide.');
	  //document.getElementById('chargement').style.display='none';  
  }
  else {
	  xhr.open("POST",'javascript/login_pass.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  xhr.send("login=" + login + "&pass=" + pass);
  }
}
 
 
 
 //************************************** verification du login / pass lors de l'acces a la partie client***************************************** 
 function verif_client()
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var client_existe = xmldoc.getElementsByTagName("client_existe")[0].childNodes[0].nodeValue;
			if (client_existe == 1) {
				location.href = 'mon_compte_coordonnee.asp';
			}
			else {
				alert("L\'email ou le mot de passe que vous avez rentr\é n\'est pas correct.")
			}
			//document.getElementById('chargement').style.display='none';
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }
   
  var login = document.getElementById('login').value;
  var pass = document.getElementById('pass').value;
  if (pass == '') {
	   alert('Le mot de passe ne peut pas \être vide');
	   //document.getElementById('chargement').style.display='none';
  }
  else {
	  xhr.open("POST",'javascript/login_pass.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  //alert( "login=" + login + "&pass=" + pass );
	  xhr.send("login=" + login + "&pass=" + pass );
  }
}

//************************************** verification du login / pass lors de l'acces a la partie client par parrainage***************************************** 
 function verif_client2()
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var client_existe = xmldoc.getElementsByTagName("client_existe")[0].childNodes[0].nodeValue;
			if (client_existe == 1) {
				location.href = 'parrainage.asp';
			}
			else {
				alert("L\'email ou le mot de passe que vous avez rentr\é n\'est pas correct.")
			}
			document.getElementById('chargement').style.display='none';
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }
   
  var login = document.getElementById('login').value;
  var pass = document.getElementById('pass').value;
  
  if (pass == '') {
	   alert('Le mot de passe ne peut pas \être vide');
	   document.getElementById('chargement').style.display='none';
  }
  else {
	  xhr.open("POST",'javascript/login_pass.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  xhr.send("login=" + login + "&pass=" + pass);
  }
}

//******Ajouté par bochra******
function new_inscription()
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 		= xhr.responseXML.documentElement;
			var message = xmldoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;
			var trouve = xmldoc.getElementsByTagName("trouve")[0].childNodes[0].nodeValue;
			var lien_page = xmldoc.getElementsByTagName("lien_page")[0].childNodes[0].nodeValue;
			if (trouve == 0) {
				alert(message);
				location.href = lien_page ;
			}
			else {
				alert(message);
			}
		}
   }
   
  var nom 		= document.getElementById('man_nom').value;
  var prenom 	= document.getElementById('man_prenom').value;
  var email	 	= document.getElementById('email_compte').value;
  var pass 		= document.getElementById('man_password_header').value;

	  xhr.open("POST",'javascript/inscription.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	  xhr.send("nom=" + nom + "&prenom=" + prenom + "&email=" + email + "&pass=" + pass);

}




//************************************** developpement du menu *******************************************************************
function deroule_menu(id_rayon, id_famille)
 {
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 						= xhr.responseXML.documentElement;
	  		var nb_famille 					= xmldoc.getElementsByTagName("id_famille").length;
			var nb_sous_famille 			= xmldoc.getElementsByTagName("id_sous_famille").length;
			var id_rayon 					= xmldoc.getElementsByTagName("id_rayon")[0].childNodes[0].nodeValue;
			var id_famille_principale 		= xmldoc.getElementsByTagName("id_famille_principale")[0].childNodes[0].nodeValue;
			//var id_sous_famille_principale 	= xmldoc.getElementsByTagName("id_sous_famille_principale")[0].childNodes[0].nodeValue;
			var rayon_fr				 	= xmldoc.getElementsByTagName("rayon_fr")[0].childNodes[0].nodeValue;
			
	  		node=document.getElementById("sous_menu_" + id_rayon);
			
			if (node.type == 'hidden') {
				node.value = 0;
			}
			else {
				node.innerHTML="";
			}
			
			node.innerHTML="";
			
			for(i=0;i<nb_famille;i++)
			{
				var id_famille = xmldoc.getElementsByTagName("id_famille")[i].childNodes[0].nodeValue;
				var nom_famille = xmldoc.getElementsByTagName("nom_famille")[i].childNodes[0].nodeValue;
				if (id_famille_principale == id_famille){
					node.innerHTML = node.innerHTML + '<p style="padding-top:8px; text-decoration:none;"><a href="Liste-' + rayon_fr + '-' + nom_famille + ',' + id_rayon + ',' + id_famille + ',l.html" id="famille_' + id_famille + ' " style="color:#99CC00; font-weight:bold; text-decoration:none;">&middot; ' + nom_famille + '</a></p>'
				}
				else {
					node.innerHTML = node.innerHTML + '<p style="padding-top:8px; text-decoration:none;"><a href="Liste-' + rayon_fr + '-' + nom_famille + ',' + id_rayon + ',' + id_famille + ',l.html" id="famille_' + id_famille + ' " style="text-decoration:none;">&middot; ' +  nom_famille + '</a></p>'
				}
				node.innerHTML = node.innerHTML + '<div class="soussousmenu" style="display:none; text-decoration:none;" id="sous_sous_menu_' + id_famille + '">'
			}
			
			if (id_famille_principale > 0) {
				node2=document.getElementById("sous_sous_menu_" + id_famille_principale);
				node2.innerHTML="";
			}
			
			if (node.style.display == 'none') {
				node.style.display = '';
			}
			else {
				if (id_famille_principale == 0) {
					node.style.display = 'none';
				}
			}
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }
   
  xhr.open("POST",'javascript/deroule_menu.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_rayon=" + id_rayon + "&id_famille=" + id_famille);
 }
 
 
 //************************************** on cherche les photos qui correspondent a la couleur choisie ***************************************** 
function photos_couleur(id_produit,id_couleur,width,height,width_mini,height_mini)
{
	getXhr2()
	xhr2.onreadystatechange = function()
   	{
		if(xhr2.readyState == 4 && xhr2.status == 200)
		{
			var xmldoc 		= xhr2.responseXML.documentElement;
			var compteur_photo 	= xmldoc.getElementsByTagName("nom_photo").length;
			
			
			var liste_photo = "";
			
			for(i=0;i<compteur_photo;i++) {
				var nom_photo = xmldoc.getElementsByTagName("nom_photo")[i].childNodes[0].nodeValue;										
				var nom_photo_pt = xmldoc.getElementsByTagName("nom_photo_pt")[i].childNodes[0].nodeValue;
				var id_photo = xmldoc.getElementsByTagName("id_photo")[0].childNodes[0].nodeValue;
				if (nom_photo != '' && i == 0) {
					//document.getElementById("grande_photo").src="images/photos/" + nom_photo;
					charge_image('grande_photo','images/photos/' + nom_photo,width,height)
					//document.getElementById('photo').value = id_photo;
					
				}
				
				if (nom_photo != "" && nom_photo != "0") {
					//liste_photo = liste_photo + '<img alt="" onmouseover="document.getElementById(\'grande_photo\').src=\'images/photos/' + nom_photo + '\';" src="images/photos/' + nom_photo_pt + '" width="50" height="50" />';	
					liste_photo = liste_photo + '<img alt="" style="cursor:pointer;" onmouseover="charge_image(\'grande_photo\',\'images/photos/' + nom_photo + '\','+ width +','+ height +')" src="images/photos/' + nom_photo_pt + '" width="' + width_mini+ '" height="' +height_mini + '" class="miniature_image" />';
				}
			}
			document.getElementById('mini_photos').innerHTML = liste_photo;	
			$(".miniature_image").charge_image({maxWidth: width_mini, maxHeight: height_mini});
			
			if (compteur_photo == 0) {
				document.getElementById("grande_photo").height=height;
				document.getElementById("grande_photo").style.backgroundColor="";
				document.getElementById("grande_photo").style.padding="0px";
				document.getElementById("grande_photo").src="images/pas_photo.jpg";	
				charge_image('grande_photo','images/pas_photo.jpg',width,height)
			}
			
			//alert("fin photos couleurs");
		}
		else {
			//alert("xhr2.readyState : " + xhr2.readyState + " xhr2.status : " + xhr2.status);
		}
   	}
	
	
	xhr2.open("POST",'javascript/photos_couleur.asp',true)
	xhr2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr2.send("id_produit=" + id_produit + "&id_couleur=" + id_couleur + "&width=" + width + "&height=" + height);
}

 function affiche_taille(id_taille, id_produit, id_rayon)
 {
	 
  getXhr3()
  xhr3.onreadystatechange = function()
   {
		if(xhr3.readyState == 4 && xhr3.status == 200)
		{
		 	var xmldoc 	= xhr3.responseXML.documentElement;
			if (id_rayon== 331683 || id_rayon==331690 ) 
			{
			document.getElementById("hauteur_nose").innerHTML = xmldoc.getElementsByTagName("hauteur_nose")[0].childNodes[0].nodeValue;
			document.getElementById("hauteur_tail").innerHTML = xmldoc.getElementsByTagName("hauteur_tail")[0].childNodes[0].nodeValue;
			document.getElementById("entre_axe").innerHTML = xmldoc.getElementsByTagName("entre_axe")[0].childNodes[0].nodeValue;
			document.getElementById("nose").innerHTML = xmldoc.getElementsByTagName("nose")[0].childNodes[0].nodeValue;
			document.getElementById("tail").innerHTML = xmldoc.getElementsByTagName("tail")[0].childNodes[0].nodeValue;
			document.getElementById("largeur_board").innerHTML = xmldoc.getElementsByTagName("largeur_board")[0].childNodes[0].nodeValue;
			}
			if (id_rayon== 331708 || id_rayon==331690 ) 
			{
			document.getElementById("diametre").innerHTML = xmldoc.getElementsByTagName("diametre")[0].childNodes[0].nodeValue;
			document.getElementById("epaisseur_ext").innerHTML = xmldoc.getElementsByTagName("epaisseur_ext")[0].childNodes[0].nodeValue;
			document.getElementById("epaisseur_int").innerHTML = xmldoc.getElementsByTagName("epaisseur_int")[0].childNodes[0].nodeValue;
			}
			if (id_rayon== 331696 || id_rayon==331690 ) 
			{
				
			document.getElementById("largeur").innerHTML = xmldoc.getElementsByTagName("largeur")[0].childNodes[0].nodeValue;
			document.getElementById("hauteur").innerHTML = xmldoc.getElementsByTagName("hauteur")[0].childNodes[0].nodeValue;
			document.getElementById("largeur_totale").innerHTML = xmldoc.getElementsByTagName("largeur_totale")[0].childNodes[0].nodeValue;
			}
		}
   }
 	 if (document.getElementById("choix_couleur").value != 0 && document.getElementById("choix_couleur").value != '')
			var couleur_actuelle = document.getElementById("choix_couleur").value;
	else 
			var couleur_actuelle = 0;
		
  xhr3.open("POST",'javascript/taille.asp',true)
  xhr3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr3.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_rayon=" + id_rayon + "&id_couleur=" + couleur_actuelle);

 }
 
 function calcul_qte(id_produit,id_couleur,id_taille,rang,qte_seuil,id_commande_ligne,prix_promo)
 {
  getXhr3()
  xhr3.onreadystatechange = function()
   {
		if(xhr3.readyState == 4 && xhr3.status == 200)
		{
		 	var xmldoc 	 = xhr3.responseXML.documentElement;
			var compteur = xmldoc.getElementsByTagName("compteur")[0].childNodes[0].nodeValue;
			for (i=0 ;i<compteur;i++)
			{
				var x = xmldoc.getElementsByTagName("id_produit")[i].childNodes[0].nodeValue;
				var qte_deja= xmldoc.getElementsByTagName("qte_deja_prise")[0].childNodes[0].nodeValue;	
				
				document.getElementById("qte_deja_"+x).value = xmldoc.getElementsByTagName("qte_deja_prise")[0].childNodes[0].nodeValue;	
			}
				var nb_ligne = document.getElementById('nb_ligne').value;
				var montant_total = 0;
				var prix_port_total = 0;
				var prix_port1_ancien = 0;
				var prix_port2_ancien = 0;
				if ((parseInt(document.getElementById('nb_produit_'+rang).value) + parseInt(qte_deja) < qte_seuil) || (parseInt(qte_deja)< qte_seuil))
				{
					document.getElementById('nb_produit_'+rang).value = parseInt(document.getElementById('nb_produit_'+rang).value) + 1;
					document.getElementById('montant_ligne_'+rang).value = parseFloat(prix_promo * document.getElementById('nb_produit_'+rang).value);
					document.getElementById('qte_produit_'+rang).innerHTML = parseInt(document.getElementById('nb_produit_'+rang).value);
					document.getElementById('quantite_'+rang).value = parseInt(document.getElementById('nb_produit_'+rang).value);
					document.getElementById('prix_ligne_'+rang).innerHTML = parseFloat((prix_promo * document.getElementById('nb_produit_'+rang).value)).toFixed(2) + ' &euro;';
					document.getElementById('prix_promo_'+rang).value=prix_promo;
					if (nb_ligne > 0) {
					for(j=0;j<nb_ligne;j++){
					montant_total = montant_total + (document.getElementById('prix_promo_'+j).value * document.getElementById('nb_produit_'+j).value);
					montant_total = Math.round(montant_total*100) / 100
					}	
						document.getElementById('prix_totale').value = montant_total;
						document.getElementById('prix_total').InnerHTML = montant_total;
					}
					modif_commande_ligne(id_commande_ligne,document.getElementById('nb_produit_'+rang).value,document.getElementById('montant_ligne_'+rang).value,id_produit,1,0);		
					}
					else {
							alert('Vous ne pouvez pas commander plus de ce produit.');	
						}
			}
   }

  xhr3.open("POST",'javascript/quantite.asp',true)
  xhr3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr3.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur + "&rang=" +rang);

 }

 function calcul_qte_moins(id_produit,id_couleur,id_taille,rang,qte_seuil,id_commande_ligne,prix_promo)
 {
  getXhr3()
  xhr3.onreadystatechange = function()
   {
		if(xhr3.readyState == 4 && xhr3.status == 200)
		{
		 	var xmldoc 	 = xhr3.responseXML.documentElement;
			var compteur = xmldoc.getElementsByTagName("compteur")[0].childNodes[0].nodeValue;
			for (i=0 ;i<compteur;i++)
			{
				var x = xmldoc.getElementsByTagName("id_produit")[i].childNodes[0].nodeValue;
				var qte_deja= xmldoc.getElementsByTagName("qte_deja_prise")[0].childNodes[0].nodeValue;	
				
				document.getElementById("qte_deja_"+x).value = xmldoc.getElementsByTagName("qte_deja_prise")[0].childNodes[0].nodeValue;	
			}
				
			var nb_ligne = document.getElementById('nb_ligne').value;
			var montant_total = 0;
			var prix_port_total = 0;
			var prix_port1_ancien = 0;
			var prix_port2_ancien = 0;
			if (document.getElementById('nb_produit_'+rang).value > 1) {
			document.getElementById('nb_produit_'+rang).value = parseInt(document.getElementById('nb_produit_'+rang).value) - 1;
			document.getElementById('montant_ligne_'+rang).value = parseFloat(prix_promo * document.getElementById('nb_produit_'+rang).value);
			//alert(document.getElementById('montant_ligne_'+rang).value);
			document.getElementById('qte_produit_'+rang).innerHTML = parseInt(document.getElementById('nb_produit_'+rang).value);
			//document.getElementById('qte_deja_'+rang).value = parseInt(document.getElementById('nb_produit_'+rang).value);
			document.getElementById('prix_ligne_'+rang).innerHTML = parseFloat((prix_promo * document.getElementById('nb_produit_'+rang).value)).toFixed(2) + ' &euro;';
			document.getElementById('quantite_'+rang).value = parseInt(document.getElementById('nb_produit_'+rang).value);
			if (nb_ligne > 0) {
				for(i=0;i<nb_ligne;i++){
					montant_total = montant_total + (document.getElementById('prix_promo_'+i).value * document.getElementById('nb_produit_'+i).value);
					montant_total = Math.round(montant_total*100) / 100
				}
				document.getElementById('prix_totale').value = montant_total;
				document.getElementById('prix_total').InnerHTML = montant_total;
			}
			modif_commande_ligne(id_commande_ligne,document.getElementById('nb_produit_'+rang).value,document.getElementById('montant_ligne_'+rang).value,id_produit,1,0);
		}
			}
   }

  xhr3.open("POST",'javascript/quantite.asp',true)
  xhr3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr3.send("id_taille=" + id_taille + "&id_produit=" + id_produit + "&id_couleur=" + id_couleur + "&rang=" +rang);

 }
