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 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_info_web ,os)
 {
	 //alert(os);
  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_info_web	= xmldoc.getElementsByTagName("id_produit_info_web")[0].childNodes[0].nodeValue;
			var id_taille			= xmldoc.getElementsByTagName("id_taille")[0].childNodes[0].nodeValue;
			var os					= xmldoc.getElementsByTagName("os")[0].childNodes[0].nodeValue;
			if (os > 0)
			{
			var prix_normal 		= xmldoc.getElementsByTagName("prix_normal")[0].childNodes[0].nodeValue;
			var prix_promo 			= xmldoc.getElementsByTagName("prix_promo")[0].childNodes[0].nodeValue;
			}
			if (os > 0)
			{
			prix_normal = prix_normal.replace(",",".");
			prix_promo = prix_promo.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('choix_taille_couleur');
			var div_choix_taille_couleur = "";
			div_choix_taille_couleur = div_choix_taille_couleur + '<span id="selection_couleur">';
			
			
			if (os > 0)
			{
				if (prix_normal > prix_promo && prix_promo != 0) {
					document.getElementById("prix_normal").innerHTML = parseFloat(prix_normal).toFixed(2) + " &euro;";
					document.getElementById("prix_promo").innerHTML = parseFloat(prix_promo).toFixed(2) + " &euro;";	
					document.getElementById("prix_normal").style.display = '';
				}
				else {
					if (prix_promo == 0) {
						document.getElementById("prix_promo").innerHTML = "N.C";	
					}
					else {
						document.getElementById("prix_promo").innerHTML = parseFloat(prix_promo).toFixed(2) + " &euro;";
						document.getElementById("prix_normal").style.display = 'none';
					}
				}
				
				if (document.getElementById("valeur_prix_promo")) {
					document.getElementById("valeur_prix_promo").value = prix_promo;
				}
			}
			if (compteur == 1) 
			{
				var couleur				= xmldoc.getElementsByTagName("couleur")[0].childNodes[0].nodeValue;
				var id_couleur 			= xmldoc.getElementsByTagName("id_couleur")[0].childNodes[0].nodeValue;
				
			
				
				div_choix_taille_couleur  = div_choix_taille_couleur + '<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_info_web,id_taille, id_couleur , os);
				photos_couleur(id_produit_info_web,id_couleur);
				
			}
			else if (compteur > 1)
			{
				
				var valeur_select = '<select name="choix_couleur" size="1" id="choix_couleur" onchange="$(\'img.select_photo_f\').css(\'border\',\'none\'); $(\'#principale_\'+this.value).css(\'border\',\'1px solid black\');document.getElementById(\'bouton_panier\').style.display=\'none\' ;taille_dispo('+id_produit_info_web+',this.value,'+os+');photos_couleur('+id_produit_info_web+',this.value);couleurs_dispo('+id_produit_info_web+','+os+');" style="height:19px; width:250px;">';
				var photo_couleur = "" ;
				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_info_web,id_taille, id_couleur);
					}
					
					
					if (couleur_actuelle == id_couleur) 
					{
						valeur_select = valeur_select + '<option value="' + id_couleur + '" selected="selected">' + couleur + '</option>';
						verif_dispo(id_produit_info_web,id_taille, id_couleur);
					}
					else 
					{
						valeur_select = valeur_select + '<option value="' + id_couleur + '">' + couleur + '</option>';
					}
					
						
				}
				//fin boucle for
			  	valeur_select = valeur_select + '</select>';
				div_choix_taille_couleur = div_choix_taille_couleur + valeur_select;
				div_choix_taille_couleur = div_choix_taille_couleur + '</span>'
				
				//div_choix_taille_couleur = div_choix_taille_couleur + '</td></tr><tr><td colspan="2" align="center">';
				
				//node1.innerHTML = photo_couleur;
				//alert(node1.innerHTML );
				document.getElementById('bouton_panier').style.display = '';
			}
			// fin else if
			else 
			{
				div_choix_taille_couleur =div_choix_taille_couleur + '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';
			}
			document.getElementById('couleur_dispo_picto').innerHTML = div_choix_taille_couleur;
			div_choix_taille_couleur = "" ;
			//alert('fin couleurs dispo');
			//div_choix_taille_couleur = div_choix_taille_couleur + "</span></div></div>";
			div_choix_taille_couleur = div_choix_taille_couleur + "<input type='hidden' value='"+id_couleur+"' id='id_couleur_apport'/>";
			div_choix_taille_couleur = div_choix_taille_couleur +"<div  id='photo_couleur' style='text-align:center;'>";
			var var_img;
			var_img="";
			for(i=0;i<compteur;i++){
				var_img = var_img +"<span style='text-align:center;'>";
				var couleur_photo 			= xmldoc.getElementsByTagName("couleur_photo")[i].childNodes[0].nodeValue;
				var photo				= xmldoc.getElementsByTagName("photo")[i].childNodes[0].nodeValue;
                 if(couleur_actuelle == couleur_photo)
				 { 
				 	var_img = var_img +'<img id="principale_'+couleur_photo+'" class="select_photo_f" style="cursor:pointer; border:1px solid #000;" src="images/photos/'+photo+'" width="50" onclick="$(\'img.select_photo_f\').css(\'border\',\'none\');$(this).css(\'border\',\'1px solid black\');document.getElementById(\'choix_couleur\').value='+couleur_photo+';document.getElementById(\'bouton_panier\').style.display=\'none\';couleurs_dispo('+id_produit_info_web+','+os+');photos_couleur('+id_produit_info_web+',this.value); verif_dispo('+id_produit_info_web+','+id_taille+', '+couleur_photo+');taille_dispo('+id_produit_info_web+',this.value,'+os+');" /></span>';
				}	
				else
				{
					
						var_img = var_img +'<img id="principale_'+couleur_photo+'" class="select_photo_f" style="cursor:pointer;" src="images/photos/'+photo+'" width="50" onclick="$(\'img.select_photo_f\').css(\'border\',\'none\');$(this).css(\'border\',\'1px solid black\');document.getElementById(\'choix_couleur\').value='+couleur_photo+';document.getElementById(\'bouton_panier\').style.display=\'none\';couleurs_dispo('+id_produit_info_web+','+os+');photos_couleur('+id_produit_info_web+',this.value); verif_dispo('+id_produit_info_web+','+id_taille+', '+couleur_photo+');taille_dispo('+id_produit_info_web+',this.value,'+os+');" /></span>';
					
					
					
				}	 
			}
			div_choix_taille_couleur = div_choix_taille_couleur + var_img;
			document.getElementById('td_photo_couleur').innerHTML = div_choix_taille_couleur;
			//node.innerHTML = div_choix_taille_couleur;
		}
		
		else 
		{
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
	
   }
 
  var id_taille = document.getElementById('choix_taille').value;
  
  
  if (document.getElementById('id_vente_flash')) {
	  var id_vente_flash = document.getElementById('id_vente_flash').value;
  }
  else {
	  var id_vente_flash = 0  ;
  }

 // alert("id_taille=" + id_taille + "&id_produit_info_web=" + id_produit_info_web + "&id_vente_flash=" + id_vente_flash + "&os=" + os);

  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_info_web=" + id_produit_info_web + "&id_vente_flash=" + id_vente_flash+ "&os=" + os);
 }
 
 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_info_web, 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;
			//alert('disponible :' + disponible);
			var dispo_fr 	= xmldoc.getElementsByTagName("dispo_fr")[0].childNodes[0].nodeValue;
			//alert('dispo_fr :' + dispo_fr);
			var dispo_gb 	= xmldoc.getElementsByTagName("dispo_gb")[0].childNodes[0].nodeValue;
			//alert('disponible :' + disponible);
			var picto_fr 	= xmldoc.getElementsByTagName("picto_fr")[0].childNodes[0].nodeValue;
			//alert('picto_fr :' + picto_fr);
			var picto_gb 	= xmldoc.getElementsByTagName("picto_gb")[0].childNodes[0].nodeValue;
			//alert('disponible :' + disponible);
			var info_sup_fr = xmldoc.getElementsByTagName("info_sup_fr")[0].childNodes[0].nodeValue;
			//alert('info_sup_fr :' + info_sup_fr);
			var info_sup_gb = xmldoc.getElementsByTagName("info_sup_gb")[0].childNodes[0].nodeValue;
			//alert('disponible :' + disponible);
			var id_lang 	= xmldoc.getElementsByTagName("id_lang")[0].childNodes[0].nodeValue;
			//alert('disponible :' + disponible);
			var couleur 	= xmldoc.getElementsByTagName("texte_couleur")[0].childNodes[0].nodeValue;
			//alert('couleur :' + couleur);
			var prix_promo 	= xmldoc.getElementsByTagName("prix_promo")[0].childNodes[0].nodeValue;
			var prix_normal	= xmldoc.getElementsByTagName("prix_normal")[0].childNodes[0].nodeValue;
			//alert('prix_promo :' + prix_promo);
			var taille_new 	= xmldoc.getElementsByTagName("taille_new")[0].childNodes[0].nodeValue;
			
			var id_couleur_ancien 	= xmldoc.getElementsByTagName("id_couleur_ancien")[0].childNodes[0].nodeValue;
			var id_couleur_news 	= xmldoc.getElementsByTagName("id_couleur_news")[0].childNodes[0].nodeValue;
			
			if (taille_new!=id_taille)
			{
				id_taille=taille_new;
				//alert (id_taille);
			}
			
			if (id_couleur_ancien!=id_couleur_news && id_couleur_news!=' ')
			{
				if(document.getElementById("choix_couleur").nodeName=="INPUT")
				{
					document.getElementById("choix_couleur").value=id_couleur_news;
					id_couleur=id_couleur_news;
					
					if(document.getElementById("choix_taille").nodeName=="SELECT")
					{
						var onchange="";
						for(i=0;i<document.getElementById("choix_taille").attributes.length;i++)
						{
							if(document.getElementById("choix_taille").attributes[i].nodeName.toLowerCase() =="onchange")
							{
								onchange=document.getElementById("choix_taille").attributes[i].value;
								break;
							}
						}
						
						onchange=onchange.replace(id_couleur_ancien,id_couleur_news);
						
						if(document.all)
							document.getElementById("td_taille").innerHTML=document.getElementById("td_taille").innerHTML.replace(","+id_couleur_ancien+")",","+id_couleur_news+")");			
						else
							document.getElementById("choix_taille").attributes[i].value=onchange;
						
						//alert("voici le onchange : \n"+onchange);
					}
				}
			}
			
			
				prix_promo = prix_promo.replace(",",".");
				prix_normal = prix_normal.replace(",",".");
			
	  		node = document.getElementById('bouton_panier');	
			
					
				/*if (document.getElementById("prix_promo").innerHTML!=parseFloat(prix_promo).toFixed(2) + "&euro;")
				{*/
					document.getElementById("prix_promo").innerHTML=(parseFloat(prix_promo).toFixed(2)).toString().replace(".",",") + "&euro;";
					document.getElementById("prix_normal").innerHTML=(parseFloat(prix_normal).toFixed(2)).toString().replace(".",",") + "&euro;";
					//alert('prix_normal :' + document.getElementById("prix_normal").innerHTML.replace(".",","));
					//alert('prix_n :' + parseFloat(prix_promo).toFixed(2) + "€");
					document.getElementById("prix_ht").innerHTML=(parseFloat(prix_promo / 1.196,2).toFixed(2)).toString().replace(".",",") + "&euro; HT"
					if (document.getElementById("prix_normal").innerHTML==(parseFloat(prix_promo).toFixed(2)).toString().replace(".",",") + "€" || document.getElementById("prix_normal").innerHTML=="")
					{
						document.getElementById("prix_normal").style.display='none';
						if(document.getElementById("pourcentage")!=null)
							document.getElementById("pourcentage").style.display='none';
					}
					else
					{
						document.getElementById("prix_normal").style.display='';
						if(document.getElementById("pourcentage")!=null)
						{
							document.getElementById("pourcentage").innerHTML = "soit -"+Math.round((1-(parseFloat(prix_promo)/parseFloat(document.getElementById("prix_normal").innerHTML.replace("€",""))))*100)+"%"; 
							document.getElementById("pourcentage").style.display='';
						}
					}
					if(!document.getElementById('id_vente_flash'))
					{
						if (document.getElementById("en_promo").value=="1"  &&  prix_normal > prix_promo  )
						{
							document.getElementById("prix_normal").style.display='';
							document.getElementById("pourcentage").style.display='';
						}
						else
						{
							document.getElementById("prix_normal").style.display='none';
							document.getElementById("pourcentage").style.display='none';
						}
					}
				//}
				if (document.getElementById("recup"))
				{
					document.getElementById("choix_taille").value = id_taille;
					document.getElementById("prix_unitaire").value = prix_promo;
					document.getElementById("montant_total").value = prix_promo;
				}
				else
				{
					 if (document.getElementById('id_vente_flash')) {
								  var idvente_flash = document.getElementById('id_vente_flash').value;
							  }
							  else {
								  var idvente_flash = 0  ;
							  }
					document.getElementById("bouton_panier").href='ajout_panier.asp?id_produit_info_web='+id_produit_info_web+'&os=0&id_vente_flash='+idvente_flash+'&id_couleur='+id_couleur+'&id_taille='+id_taille;
				}
			
				



			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;">Momentan&eacute;ment indisponible</span>';	
					//document.getElementById('text_dispo').innerHTML = '<span class="en_stock"  style="color:#FF0000;">' + dispo_fr + '</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>';		
				}
				
					if (document.getElementById("promo_produit").value != -1 )
						document.getElementById('dispo_produit').style.display = '';
					else
						document.getElementById('dispo_produit').style.display = 'none';
				document.getElementById('taille_alerte').value = document.getElementById('choix_taille').value;
				document.getElementById('couleur_alerte').value = document.getElementById('choix_couleur').value;
				//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;
				}
				document.getElementById('taille_alerte').value = document.getElementById('choix_taille').value;
				document.getElementById('couleur_alerte').value = document.getElementById('choix_couleur').value;
				document.getElementById('dispo_produit').style.display = 'none';
				//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>';
				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('text_dispo').innerHTML = '<span class="en_stock" style="color:' + couleur + ';">' + dispo_fr + '</span>';
					document.getElementById('text_dispo').innerHTML = '<span class="en_stock">' + 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 ) {
	  if (document.getElementById('choix_taille')) {
	  	var id_taille = document.getElementById('choix_taille').value;
	  }
	  else {
		var id_taille = 0;  
	  }
   }
   if( id_couleur == 0)
   {
	   if (document.getElementById('choix_couleur')) {
	  	var id_couleur = document.getElementById('choix_couleur').value;
	  }
	  else {
		var id_couleur = 0;
	  }
   }
    
  if (document.getElementById('id_vente_flash')) {
	  var id_vente_flash = document.getElementById('id_vente_flash').value;
  }
  else {
	  var id_vente_flash = 0  ;
  }

   //alert("id_taille=" + id_taille + "&id_produit_info_web=" + id_produit_info_web + "&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');
	 // alert("id_taille=" + id_taille + "&id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur);
	  xhr.send("id_taille=" + id_taille + "&id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur+ "&id_vente_flash=" + id_vente_flash);
  }
 }
 
 
 //************************************************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 )
{
  var selecteur_vignette="";
  var pourcentage = 0;
  var prix_promo = 0 ;
  getXhr()
  xhr.onreadystatechange = function()
  	{
		if(xhr.readyState == 4 && xhr.status == 200) {
			var xmldoc 					= xhr.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 pourcent				= xmldoc.getElementsByTagName("pourcent")[0].childNodes[0].nodeValue;
			var somme_manquante			= xmldoc.getElementsByTagName("somme_manquante")[0].childNodes[0].nodeValue;
			var prix_tot 				= xmldoc.getElementsByTagName("prix_tot")[0].childNodes[0].nodeValue;
			var id_langue 				= xmldoc.getElementsByTagName("id_langue")[0].childNodes[0].nodeValue;
			somme_manquante = parseFloat(somme_manquante).toFixed(2);
			somme_manquante = somme_manquante.replace(',','.');
			//alert(prix_total);
			//alert(montant_port_total);
			
			// modification by youssef 19/12/2011 : modification de TVA , Montant HT , frais de livraison , ... 
			if (somme_manquante <= 50 )
			{
				document.getElementById('bloc_liv').style.display = '';
				document.getElementById('span_somme_manquante').innerHTML = somme_manquante.replace('.',',');
				if (montant_port_total == 0 )
				{
					
					document.getElementById('bloc_liv0').style.display = '';
						
				}
			}
			else
			{
				document.getElementById('bloc_liv').style.display = 'none';	
				
			}
			if (montant_port_total == 0 )
				{
					
					document.getElementById('bloc_liv0').style.display = '';
						
				}
			else
			{
					document.getElementById('bloc_liv0').style.display = 'none';
			}
			
			document.getElementById('montant_port_total').innerHTML = montant_port_total.replace('.',',') + ' €' 
			document.getElementById('prix_port_total').value = montant_port_total.replace('.',',')
			//+ '<input type="hidden" name="prix_port_total" id="prix_port_total" value='+ montant_port_total.replace('.',',') +" />";
			//document.getElementById('span_somme_manquante').innerHTML = montant_port_total.replace('.',',') + ' €';
			
			//document.getElementById('montant_port_total').innerHTML = montant_port_total.replace('.',',') + ' €' + '<input type="hidden" name="prix_port_total" id="prix_port_total" value='+ montant_port_total.replace('.',',') +" />";
			
//alert(prix_tot);
			addition = parseFloat(prix_tot / 1.196).toFixed(2);
			//alert(addition);
			addition = addition.replace('.',',');
			document.getElementById('prix_total_ht').innerHTML = '<span id="montant_ht">'+ addition + ' €' + '</span>'+'<input type="hidden" name="prix_ht" id="prix_ht" value="'+addition+'" />';
			
			addition = addition.replace(',','.');
			var tva = parseFloat(prix_tot - addition).toFixed(2);
			tva = tva.replace('.',',');
			//alert(tva);
			document.getElementById('td_montant_tva').innerHTML = ' <span id="montant_tva">'+ tva + ' €' + '</span>'+'<input type="hidden" name="prix_tva" id="prix_tva" value="'+tva+'" />';
			//montant_port_total.replace('.',',') + ' €' + '<input type="hidden" name="prix_port_total" id="prix_port_total" value='+ montant_port_total.replace('.',',') +" />";(prix_total + prix_port_total)/1.196)
			
			
var offre_trouve = false;			
			// cas produit 1
			var id_produit_info_web1 = xmldoc.getElementsByTagName("id_produit_info_web_1")[0].childNodes[0].nodeValue;
			//alert(id_produit_info_web1);
			
			if ( id_produit_info_web1 != -1)
			{
			var nom_produit1		= xmldoc.getElementsByTagName("nom_produit_1")[0].childNodes[0].nodeValue;
			var prix_normal1		= xmldoc.getElementsByTagName("prix_normal_1")[0].childNodes[0].nodeValue;
			var prix_promo1	   		= xmldoc.getElementsByTagName("prix_promo_1")[0].childNodes[0].nodeValue;
			var photo1				= xmldoc.getElementsByTagName("photo_1")[0].childNodes[0].nodeValue;
			var promo1				= xmldoc.getElementsByTagName("promo_1")[0].childNodes[0].nodeValue;
			var nom_marque1			= xmldoc.getElementsByTagName("nom_marque_1")[0].childNodes[0].nodeValue;
			var id_produit1			= xmldoc.getElementsByTagName("id_produit_1")[0].childNodes[0].nodeValue;
			var nouveau1			= xmldoc.getElementsByTagName("nouveau_1")[0].childNodes[0].nodeValue;
			var id_couleur1			= xmldoc.getElementsByTagName("id_couleur_1")[0].childNodes[0].nodeValue;
			var exclu1				= xmldoc.getElementsByTagName("exclu_1")[0].childNodes[0].nodeValue;
			var solde1				= xmldoc.getElementsByTagName("solde_1")[0].childNodes[0].nodeValue;
			var infos_taille1		= xmldoc.getElementsByTagName("infos_taille_1")[0].childNodes[0].nodeValue;
			var sous_famille_1		= xmldoc.getElementsByTagName("sous_famille_1")[0].childNodes[0].nodeValue;
			offre_trouve = true;	
			}
//			
//			// cas produit 2
			var id_produit_info_web2= xmldoc.getElementsByTagName("id_produit_info_web_2")[0].childNodes[0].nodeValue;

			if ( id_produit_info_web2 != -1 )
			{
			var nom_produit2		= xmldoc.getElementsByTagName("nom_produit_2")[0].childNodes[0].nodeValue;
			var prix_normal2		= xmldoc.getElementsByTagName("prix_normal_2")[0].childNodes[0].nodeValue;
			var prix_promo2			= xmldoc.getElementsByTagName("prix_promo_2")[0].childNodes[0].nodeValue;
			var photo2				= xmldoc.getElementsByTagName("photo_2")[0].childNodes[0].nodeValue;
			var promo2				= xmldoc.getElementsByTagName("promo_2")[0].childNodes[0].nodeValue;
			var nom_marque2			= xmldoc.getElementsByTagName("nom_marque_2")[0].childNodes[0].nodeValue;
			var id_produit2			= xmldoc.getElementsByTagName("id_produit_2")[0].childNodes[0].nodeValue;
			var nouveau2			= xmldoc.getElementsByTagName("nouveau_2")[0].childNodes[0].nodeValue;
			var id_couleur2			= xmldoc.getElementsByTagName("id_couleur_2")[0].childNodes[0].nodeValue;
			var exclu2				= xmldoc.getElementsByTagName("exclu_2")[0].childNodes[0].nodeValue;
			var solde2				= xmldoc.getElementsByTagName("solde_2")[0].childNodes[0].nodeValue;
			var infos_taille2		= xmldoc.getElementsByTagName("infos_taille_2")[0].childNodes[0].nodeValue;
			var sous_famille_2		= xmldoc.getElementsByTagName("sous_famille_2")[0].childNodes[0].nodeValue;
			offre_trouve = true;	
			}
//			
//			// cas produit 3
			var id_produit_info_web3= xmldoc.getElementsByTagName("id_produit_info_web_3")[0].childNodes[0].nodeValue;
			if ( id_produit_info_web3 != -1 )
			{
			var nom_produit3		= xmldoc.getElementsByTagName("nom_produit_3")[0].childNodes[0].nodeValue;
			var prix_normal3		= xmldoc.getElementsByTagName("prix_normal_3")[0].childNodes[0].nodeValue;
			var prix_promo3			= xmldoc.getElementsByTagName("prix_promo_3")[0].childNodes[0].nodeValue;
			var photo3				= xmldoc.getElementsByTagName("photo_3")[0].childNodes[0].nodeValue;
			var promo3				= xmldoc.getElementsByTagName("promo_3")[0].childNodes[0].nodeValue;
			var nom_marque3			= xmldoc.getElementsByTagName("nom_marque_3")[0].childNodes[0].nodeValue;
			var id_produit3			= xmldoc.getElementsByTagName("id_produit_3")[0].childNodes[0].nodeValue;
			var nouveau3			= xmldoc.getElementsByTagName("nouveau_3")[0].childNodes[0].nodeValue;
			var id_couleur3			= xmldoc.getElementsByTagName("id_couleur_3")[0].childNodes[0].nodeValue;
			var exclu3				= xmldoc.getElementsByTagName("exclu_3")[0].childNodes[0].nodeValue;
			var solde3				= xmldoc.getElementsByTagName("solde_3")[0].childNodes[0].nodeValue;
			var infos_taille3		= xmldoc.getElementsByTagName("infos_taille_3")[0].childNodes[0].nodeValue;
			var sous_famille_3		= xmldoc.getElementsByTagName("sous_famille_3")[0].childNodes[0].nodeValue;
			offre_trouve = true;
			}
//			
//			// cas produit 4
			var id_produit_info_web4= xmldoc.getElementsByTagName("id_produit_info_web_4")[0].childNodes[0].nodeValue;
			if ( id_produit_info_web4 != -1 )
			{
			var nom_produit4		= xmldoc.getElementsByTagName("nom_produit_4")[0].childNodes[0].nodeValue;
			var prix_normal4		= xmldoc.getElementsByTagName("prix_normal_4")[0].childNodes[0].nodeValue;
			var prix_promo4			= xmldoc.getElementsByTagName("prix_promo_4")[0].childNodes[0].nodeValue;
			var photo4				= xmldoc.getElementsByTagName("photo_4")[0].childNodes[0].nodeValue;
			var promo4				= xmldoc.getElementsByTagName("promo_4")[0].childNodes[0].nodeValue;
			var nom_marque4			= xmldoc.getElementsByTagName("nom_marque_4")[0].childNodes[0].nodeValue;
			var id_produit4			= xmldoc.getElementsByTagName("id_produit_4")[0].childNodes[0].nodeValue;
			var nouveau4			= xmldoc.getElementsByTagName("nouveau_4")[0].childNodes[0].nodeValue;
			var id_couleur4			= xmldoc.getElementsByTagName("id_couleur_4")[0].childNodes[0].nodeValue;
			var exclu4				= xmldoc.getElementsByTagName("exclu_4")[0].childNodes[0].nodeValue;
			var solde4				= xmldoc.getElementsByTagName("solde_4")[0].childNodes[0].nodeValue;
			var infos_taille4		= xmldoc.getElementsByTagName("infos_taille_4")[0].childNodes[0].nodeValue;
			var sous_famille_4		= xmldoc.getElementsByTagName("sous_famille_4")[0].childNodes[0].nodeValue;
			offre_trouve = true;	
			}
		
if (offre_trouve == true)
{
	if(id_langue == 0 ) 
	{
	document.getElementById('offre_speciale').innerHTML = " <a href='#' style='white-space:nowrap'>Offre speciales</a>";
	}
	else
	{
		document.getElementById('offre_speciale').innerHTML = "<a href='#' style='white-space:nowrap'>Special offer</a>";
	}
}
else
	document.getElementById("texte_offre").style.display="none";
			
//produit1
if ( xmldoc.getElementsByTagName("id_produit_info_web_1")[0].childNodes[0].nodeValue != -1 )
{
pourcentage =  -pourcent;
prix_normal1 = prix_promo1.replace(',','.');
//alert(prix_normal4);
prix_promo  = parseFloat((prix_normal1 * (100 + pourcentage) / 100)).toFixed(2);
prix_promo = prix_promo.replace('.',',');


selecteur_vignette =  selecteur_vignette + '<div class="vignette" style="margin-left:2px; margin-right:2px;cursor:pointer;" onclick="location.href =\'fiche.asp?id_produit_info_web='+id_produit_info_web1+'&amp;id_couleur='+id_couleur1+'&os=1\';" ><div class="pourcentage">'+pourcentage+'%</div>';
selecteur_vignette =  selecteur_vignette +'<div class="solde">';

if (id_langue == 0)
{
	if (exclu1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu.png' alt='exclu'/>";
	}
	if (solde1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde.png' alt='solde'/>";
	}
	if (nouveau1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau.png' alt='nouveau'/>";
	}
	if (exclu1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
else
{
	if (exclu1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu_gb.png' alt='exclu'/>";
	}
	if (solde1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde_gb.png' alt='solde'/>";
	}
	if (nouveau1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau_gb.png' alt='nouveau'/>";
	}
	if (exclu1 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}

}
selecteur_vignette =  selecteur_vignette +"</div>";
selecteur_vignette =  selecteur_vignette +"<a href='fiche.asp?id_produit_info_web="+id_produit_info_web1+"&id_couleur="+id_couleur1+"&os=1'>";
if (photo1 != '' )
{
selecteur_vignette =  selecteur_vignette +"<img src='images/photos/"+photo1+"' width='160' height='160' /></a>";
}
else
{
selecteur_vignette =  selecteur_vignette + "<img src='images/photos/pas_photo.jpg' width='160' height='160' alt='picto vignette'/>";	
}
selecteur_vignette =  selecteur_vignette +"<h3>"+nom_marque1+"</h3><h4>"+nom_produit1+"</h4><br /><span class='prix_barre'>"+prix_normal1+"&euro;</span><span class='prix'>"+prix_promo+"&euro;</span></div>";
}

pourcentage = '' ;
prix_promo = '' ;
//produit2
if ( xmldoc.getElementsByTagName("id_produit_info_web_2")[0].childNodes[0].nodeValue != -1 )
{
	

pourcentage =  -pourcent;
prix_normal2 = prix_promo2.replace(',','.');
//alert(prix_normal4);
prix_promo  = parseFloat((prix_promo2 * (100 + pourcentage) / 100)).toFixed(2);
prix_promo = prix_promo.replace('.',',');



selecteur_vignette =  selecteur_vignette + '<div class="vignette" style="margin-left:2px; margin-right:2px;cursor:pointer;" onclick="location.href =\'fiche.asp?id_produit_info_web='+id_produit_info_web2+'&amp;id_couleur='+id_couleur2+'&os=1\';" ><div class="pourcentage">'+pourcentage+'%</div>';
selecteur_vignette =  selecteur_vignette +'<div class="solde">';

if (id_langue == 0)
{
	if (exclu2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu.png' alt='exclu'/>";
	}
	if (solde2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde.png' alt='solde'/>";
	}
	if (nouveau2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau.png' alt='nouveau'/>";
	}
	if (exclu2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
else
{
	if (exclu2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu_gb.png' alt='exclu'/>";
	}
	if (solde2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde_gb.png' alt='solde'/>";
	}
	if (nouveau2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau_gb.png' alt='nouveau'/>";
	}
	if (exclu2 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
selecteur_vignette =  selecteur_vignette +"</div>";
selecteur_vignette =  selecteur_vignette +"<a href='fiche.asp?id_produit_info_web="+id_produit_info_web2+"&id_couleur="+id_couleur2+"&os=1'>";
if (photo2 != '' )
{
selecteur_vignette =  selecteur_vignette +"<img src='images/photos/"+photo2+"' width='160' height='160' /></a>";
}
else
{
selecteur_vignette =  selecteur_vignette + "<img src='images/photos/pas_photo.jpg' width='160' height='160' alt='picto vignette'/>";	
}
selecteur_vignette =  selecteur_vignette +"<h3>"+nom_marque2+"</h3><h4>"+nom_produit2+"</h4><br /><span class='prix_barre'>"+prix_normal2+"&euro;</span><span class='prix'>"+prix_promo+"&euro;</span></div>";
}

//produit3
pourcentage = ''
prix_promo = ''
if ( xmldoc.getElementsByTagName("id_produit_info_web_3")[0].childNodes[0].nodeValue != -1 )
{
pourcentage =  -pourcent;
prix_normal3 = prix_promo3.replace(',','.');
//alert(prix_normal4);
prix_promo  = parseFloat((prix_normal3 * (100 + pourcentage) / 100)).toFixed(2);
prix_promo = prix_promo.replace('.',',');



selecteur_vignette =  selecteur_vignette + '<div class="vignette" style="margin-left:2px; margin-right:2px;cursor:pointer;" onclick="location.href =\'fiche.asp?id_produit_info_web='+id_produit_info_web3+'&amp;id_couleur='+id_couleur3+'&os=1\';" ><div class="pourcentage">'+pourcentage+'%</div>';
selecteur_vignette =  selecteur_vignette +'<div class="solde">';

if (id_langue == 0)
{
	if (exclu3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu.png' alt='exclu'/>";
	}
	if (solde3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde.png' alt='solde'/>";
	}
	if (nouveau3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau.png' alt='nouveau'/>";
	}
	if (exclu3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
else
{
	if (exclu3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu_gb.png' alt='exclu'/>";
	}
	if (solde3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde_gb.png' alt='solde'/>";
	}
	if (nouveau3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau_gb.png' alt='nouveau'/>";
	}
	if (exclu3 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
selecteur_vignette =  selecteur_vignette +"</div>";
selecteur_vignette =  selecteur_vignette +"<a href='fiche.asp?id_produit_info_web="+id_produit_info_web3+"&id_couleur="+id_couleur3+"&os=1'>";
if (photo3 != '' )
{
selecteur_vignette =  selecteur_vignette +"<img src='images/photos/"+photo3+"' width='160' height='160' /></a>";
}
else
{
selecteur_vignette =  selecteur_vignette + "<img src='images/photos/pas_photo.jpg' width='160' height='160' alt='picto vignette'/>";	
}
selecteur_vignette =  selecteur_vignette +"<h3>"+nom_marque3+"</h3><h4>"+nom_produit3+"</h4><br /><span class='prix_barre'>"+prix_normal3+"&euro;</span><span class='prix'>"+prix_promo+"&euro;</span></div>";
}

pourcentage = '' ;
prix_promo = '' ;
//produit4

if ( xmldoc.getElementsByTagName("id_produit_info_web_4")[0].childNodes[0].nodeValue != -1 )
{
pourcentage =  -pourcent;
prix_normal4 = prix_promo4.replace(',','.');
//alert(prix_normal4);
prix_promo  = parseFloat((prix_normal4 * (100 + pourcentage) / 100)).toFixed(2);
prix_promo = prix_promo.replace('.',',');

selecteur_vignette =  selecteur_vignette + '<div class="vignette" style="margin-left:2px; margin-right:2px;cursor:pointer;" onclick="location.href =\'fiche.asp?id_produit_info_web='+id_produit_info_web4+'&amp;id_couleur='+id_couleur4+'&os=1\';" ><div class="pourcentage">'+pourcentage+'%</div>';
selecteur_vignette =  selecteur_vignette +'<div class="solde">';

if (id_langue == 0)
{

	if (exclu4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu.png' alt='exclu'/>";
	}
	if (solde4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde.png' alt='solde'/>";
	}
	if (nouveau4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau.png' alt='nouveau'/>";
	}
	if (exclu4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}
}
else
{
	if (exclu4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/exclu_gb.png' alt='exclu'/>";
	}
	if (solde4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/solde_gb.png' alt='solde'/>";
	}
	if (nouveau4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/nouveau_gb.png' alt='nouveau'/>";
	}
	if (exclu4 == -1 )
	{
	selecteur_vignette =  selecteur_vignette +"<img src='images/disponibilite/promo.png' alt='promo'/>";
	}

}
selecteur_vignette =  selecteur_vignette +"</div>";
selecteur_vignette =  selecteur_vignette +"<a href='fiche.asp?id_produit_info_web="+id_produit_info_web4+"&id_couleur="+id_couleur4+"&os=1'>";
if (photo4 != '' )
{
selecteur_vignette =  selecteur_vignette +"<img src='images/photos/"+photo4+"' width='160' height='160' /></a>";
}
else
{
selecteur_vignette =  selecteur_vignette + "<img src='images/photos/pas_photo.jpg' width='160' height='160' alt='picto vignette'/>";	
}
selecteur_vignette =  selecteur_vignette +"<h3>"+nom_marque4+"</h3><h4>"+nom_produit4+"</h4><br /><span class='prix_barre'>"+prix_normal4+"&euro;</span><span class='prix'>"+prix_promo+"&euro;</span></div>";
}

selecteur_vignette =  selecteur_vignette + "<div class='clr'></div>";
			//alert('montant_port_total : ' + montant_port_total);
			//alert('prix_total : ' + prix_total);
			document.getElementById('bloc_vignette').innerHTML=selecteur_vignette;
			//document.getElementById('bloc_vignette1').innerHTML=selecteur_vignette;
			
			document.getElementById('montant_total').innerHTML = (parseFloat(prix_total)+parseFloat(montant_port_total)).toFixed(2) + ' &euro;';
			document.getElementById('prix_total').value = parseFloat(prix_total).toFixed(2);
		}
	}
   
  var prix_total = document.getElementById('prix_total').value;
  
 // alert("id_commande_ligne=" + id_commande_ligne + "&qte=" + qte + "&prix_net=" + prix_net + "&prix_total=" + prix_total);
   
  xhr.open("POST",'javascript/modif_commande_ligne.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
 //alert("id_commande_ligne=" + id_commande_ligne + "&qte=" + qte + "&prix_net=" + prix_net + "&prix_total=" + prix_total);
  xhr.send("id_commande_ligne=" + id_commande_ligne + "&qte=" + qte + "&prix_net=" + prix_net + "&prix_total=" + prix_total);
}

 //******************************* calcul des frais de livraison 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;
			var paye_tva 				= xmldoc.getElementsByTagName("paye_tva")[0].childNodes[0].nodeValue;
			var livraison_magasin		= xmldoc.getElementsByTagName("livraison_magasin")[0].childNodes[0].nodeValue;
			
			prix_port_total = prix_port_total.replace(",",".");
			montant_total_commande = montant_total_commande.replace(",",".");
			
			if (document.getElementById('panier3')) {
				if (paye_tva == 0)
					document.getElementById('montant_total').innerHTML = parseFloat(montant_total_commande/1.196).toFixed(2) + " &euro; HT.";
				else
					document.getElementById('montant_total').innerHTML = parseFloat(montant_total_commande).toFixed(2) + " &euro; TTC.";
			}
			else {
				document.getElementById('montant_total').innerHTML = parseFloat(montant_total_commande).toFixed(2) + " &euro; TTC.";
			}

			//alert('prix_port_total : ' + prix_port_total);
			//alert('montant_total : ' + montant_total_commande);
			
			if (document.getElementById('panier3')) {
				if (paye_tva == 0)
					document.getElementById('prix_port_total').innerHTML = parseFloat(prix_port_total/1.196).toFixed(2) + " &euro;";
				else
					document.getElementById('prix_port_total').innerHTML = parseFloat(prix_port_total).toFixed(2) + " &euro;";
			}
			else {
				document.getElementById('prix_port_total').innerHTML = parseFloat(prix_port_total).toFixed(2) + " &euro;";
			}
			
			
			
			if (document.getElementById('montant_tva')) {
				if (paye_tva == 0 && livraison_magasin == 0)
					document.getElementById('montant_tva').innerHTML = parseFloat(0).toFixed(2) + " &euro;";	
				else
					document.getElementById('montant_tva').innerHTML = parseFloat(montant_total_commande - montant_total_commande/1.196).toFixed(2) + " &euro;";
			}
			
			if (livraison_magasin == 0) {
				if (document.getElementById('montant_du')) {
					document.getElementById('montant_du').style.display = '';
				}	
				if (document.getElementById('montant_total_du')) {
					document.getElementById('montant_total_du').innerHTML = parseFloat(montant_total_commande/1.196).toFixed(2) + " &euro;";	
				}
			}
			else {
				if (document.getElementById('montant_du')) {
					document.getElementById('montant_du').style.display = 'none';
				}	
			}
			
			//alert('fin calcul frais port');
			
			//alert('fin calcul frais port');
		}
		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
	   }
	   else {
		   var livraison_magasin = 0
	   }
   }
   else {
	  var livraison_magasin = 0   
   }
   
   type_livraison = 1
   if (document.getElementById('livraison_express')) {
		if (document.getElementById('livraison_express').checked) {
		   type_livraison = 2;
	   }
   }
   if (document.getElementById('livraison_magasin')) {
		if (document.getElementById('livraison_magasin').checked) {
		   type_livraison = 3;
	   }
   }
//  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 + "&livraison_magasin=" + livraison_magasin + "&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("man_nom_facturation").value = nom_facturation;
				document.getElementById("prenom_facturation").value = prenom_facturation;
				document.getElementById("man_tel_facturation").value = tel_facturation;
				document.getElementById("email_facturation").value = email_facturation;
				document.getElementById("adresse_facturation").value = adresse_facturation;
				document.getElementById("cp_facturation").value = cp_facturation;
				document.getElementById("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("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_facturation').value = id_pays_facturation;
				}
				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 livraison 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 = 'moncompte_commandes.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);
  }
}

//************************************** 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);
  }
}


//************************************** 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_info_web,id_couleur)
{
	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;
				
				if (nom_photo != '' && i == 0) {
					document.getElementById("grande_photo").src = "images/photos/" + nom_photo;
					document.getElementById("lien_grande_photo").href = "images/photos/gd_" + nom_photo;
				}
				
				if (nom_photo != "" && nom_photo != "0") {
					liste_photo = liste_photo + '<img id="mini_photo_' + i + '" alt="" onmouseover="document.getElementById(\'grande_photo\').src=\'images/photos/' + nom_photo + '\'; document.getElementById(\'lien_grande_photo\').href=\'images/photos/gd_' + nom_photo + '\'; MagicZoomPlus.refresh(\'lien_grande_photo\');" src="images/photos/' + nom_photo_pt + '" width="106" height="106" style="margin-right:4px;"  />';	
					document.getElementById('lien_grande_photo').href = "images/photos/gd_" + nom_photo;
				}
			}
			document.getElementById('mini_photos').innerHTML = liste_photo;	
			
			if (compteur_photo == 0) {
				document.getElementById("grande_photo").src="images/pas_photo.jpg";		
				document.getElementById("grande_photo").style.width = '375px;'
				document.getElementById("grande_photo").style.height = '375px;'
			}
			
			 $('#mini_photo_0').trigger('mouseover');
			
			//alert("fin photos couleurs");
		}
		else {
			//alert("xhr2.readyState : " + xhr2.readyState + " xhr2.status : " + xhr2.status);
		}
   	}
	
	//alert("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur);
	
	xhr2.open("POST",'javascript/photos_couleur.asp',true)
	xhr2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr2.send("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur);
}

 //******************************* ajout d'un produit a la selection********************
function add_comparateur(id_produit_info_web, id_couleur, id_vente_flash){
	getXhr()
  	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			var xmldoc 				= xhr.responseXML.documentElement;
			var id_produit_info_web	= xmldoc.getElementsByTagName("id_produit_info_web")[0].childNodes[0].nodeValue;
			var nom_fr				= xmldoc.getElementsByTagName("nom_fr")[0].childNodes[0].nodeValue;
			var ajout				= xmldoc.getElementsByTagName("ajout")[0].childNodes[0].nodeValue;
			
			if (document.getElementById('nb_select').value == 0 && ajout == 1)	
				document.getElementById('produits_comparateur').innerHTML = '';
	
			if (ajout == 1) {
				document.getElementById("nb_select").value = parseInt(document.getElementById("nb_select").value) + 1;

				var div = document.createElement('div');
				div.className = 'bloc_produit_comparer';
				div.id = 'div_produit_'+id_produit_info_web;
				document.getElementById('produits_comparateur').appendChild(div);
				
				var span = document.createElement('span');
				span.className = 'produit_comparer';
				span.innerHTML = nom_fr;
				div.appendChild(span);
				
				var img = document.createElement('img');
				img.className = 'supprimer_prd';
				img.src = 'images/bouton/supprime_prd.png';
				img.vAlign = 'absmiddle';
				img.onmouseover = function() {this.src="images/bouton/supprime_prd_survol.png";};
				img.onmouseout = function() {this.src="images/bouton/supprime_prd.png";};
				img.onclick = function(){del_comparateur(id_produit_info_web,'div_produit_'+id_produit_info_web,0);};
				div.appendChild(img);
				
				var div2 = document.createElement('div');
				div2.className = 'clr';
				document.getElementById('produits_comparateur').appendChild(div2);
				
				document.getElementById("vider_comparateur").style.display = '';
			}
			
			document.getElementById('nb_produit_compare').innerHTML = document.getElementById('nb_select').value;
			$("#chargement_comparateur").css("display","none");
			$(".check_comparateur").css("display","");
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}    

  	}

	$("#chargement_comparateur").css("display","");
	$(".check_comparateur").css("display","none");
    
	xhr.open("POST",'javascript/add_comparateur.asp',true)
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	//alert("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur+ "&id_vente_flash=" + id_vente_flash);
	xhr.send("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur+ "&id_vente_flash=" + id_vente_flash);
}


 //******************************* suppression d'un logement de la selection ********************
function del_comparateur(id_produit_info_web, div_id, tout){
	getXhr()
  	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200) {
			var xmldoc 	= xhr.responseXML.documentElement;
			var tout	= xmldoc.getElementsByTagName("tout")[0].childNodes[0].nodeValue;
			var id_lang	= xmldoc.getElementsByTagName("id_lang")[0].childNodes[0].nodeValue;
			
			if (tout == 1) {
				document.getElementById("nb_select").value = 0;
				document.getElementById('nb_produit_compare').innerHTML = '0';
			}
			else {
				document.getElementById("nb_select").value = parseInt(document.getElementById("nb_select").value) - 1;
				document.getElementById('nb_produit_compare').innerHTML = document.getElementById('nb_select').value;	
			}
			
			if (document.getElementById("nb_select").value == 0) {
				if(id_lang==0){
					document.getElementById('produits_comparateur').innerHTML = "Vous n\'avez aucun produit \à comparer.";	
				}
				else
				{document.getElementById('produits_comparateur').innerHTML = "You have no products to compare.";	}
				document.getElementById("vider_comparateur").style.display = 'none';
			}
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}    
	}
	
	
	if (document.getElementById(div_id))
		document.getElementById(div_id).parentNode.removeChild(document.getElementById(div_id));
	
	if (tout == 1) 
		$(".check_comparateur").removeAttr("checked");

	xhr.open("POST",'javascript/del_comparateur.asp',true)
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id_produit_info_web=" + id_produit_info_web + "&tout=" + tout);
}
function couleur_taille_picto(id_produit_info_web ,id_couleur , os )
 {
  var selecteur_taille="";
  getXhr();
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
		 	var xmldoc 				= xhr.responseXML.documentElement;
			var id_produit_info_web	= xmldoc.getElementsByTagName("id_produit_info_web")[0].childNodes[0].nodeValue;
			var taille_top			= xmldoc.getElementsByTagName("taille_top")[0].childNodes[0].nodeValue;
			var nb_taille 			= xmldoc.getElementsByTagName("nb_taille").length;	
			var os					= xmldoc.getElementsByTagName("os")[0].childNodes[0].nodeValue;
			selecteur_taille = selecteur_taille + "<select style='width:100%;' name='choix_taille' id='choix_taille' onchange='document.getElementById('bouton_panier').style.display='none';couleurs_dispo(<%=id_produit_info_web%>,<%=os%>);'>"
			for(i=0;i<nb_taille-1;i++)
			{
				
			
			var id_taille			= xmldoc.getElementsByTagName("id_taille")[i].childNodes[0].nodeValue;
			var taille				= xmldoc.getElementsByTagName("taille")[i].childNodes[0].nodeValue;
			//alert(id_taille);
			//alert(taille);
			//
			if(id_taille == taille_top )
			{
selecteur_taille=selecteur_taille+"<option value='"+id_taille+"' selected='selected'>"+taille+"</option>";
			}
			else
			{
				selecteur_taille=selecteur_taille+"<option value='"+id_taille+"' >"+taille+"</option>";
					
			}
			}
			selecteur_taille = selecteur_taille +"</select>";
			selecteur_taille = selecteur_taille + '<input type="hidden" value="'+taille+'" name="nom_taille" id="nom_taille" />';
			document.getElementById('td_taille').innerHTML=selecteur_taille;
			couleurs_dispo(id_produit_info_web,os);
			
			
		}
   }

  xhr.open("POST",'javascript/couleur_taille_picto.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  //alert("id_couleur=" + id_couleur + "&id_produit_info_web=" + id_produit_info_web + "&id_photo=" + id_photo + "&os=" + os);
  xhr.send("id_couleur=" + id_couleur + "&id_produit_info_web=" + id_produit_info_web + "&os=" + os);
 }

function taille_dispo(id_produit_info_web,id_couleur,os)
 {
	
  getXhr()
  xhr.onreadystatechange = function()
   {
		if(xhr.readyState == 4 && xhr.status == 200)
		{	
				var xmldoc 		    = xhr.responseXML.documentElement;
	  			var compteur 	  	= xmldoc.getElementsByTagName("id_taille").length;
				var id_taille_choisi= xmldoc.getElementsByTagName("id_taille_choisi")[0].childNodes[0].nodeValue;
				var id_produit_info_web = xmldoc.getElementsByTagName("id_produit_info_web")[0].childNodes[0].nodeValue;
				var id_couleur		= xmldoc.getElementsByTagName("id_couleur")[0].childNodes[0].nodeValue;
				var os				= xmldoc.getElementsByTagName("os")[0].childNodes[0].nodeValue;
				
			
				if (compteur>1)
				{
					//var valeur_select   = '<select name="choix_taille" size="1" id="choix_taille" onchange="document.getElementById(\'bouton_panier\').style.display=\'none\';couleurs_dispo1('+id_produit_info_web+','+os+');" style="width:250px; height:19px;">';
				   var valeur_select   = '<select name="choix_taille" id="choix_taille" style="width:250px; height:19px; " onchange="document.getElementById(\'bouton_panier\').style.display=\'none\';verif_dispo('+id_produit_info_web+',this.value,'+id_couleur+'); ">';
					
					var trouv=0;
					for(i=0;i<compteur;i++)
					{
						var id_taille 		= xmldoc.getElementsByTagName("id_taille")[i].childNodes[0].nodeValue;
						var taille 			= xmldoc.getElementsByTagName("taille")[i].childNodes[0].nodeValue;
						var epuise 			= xmldoc.getElementsByTagName("epuise")[i].childNodes[0].nodeValue;
						var selected 		= '';
						
						if (epuise == "0")
							epuise = ' ';
						
						if (id_taille_choisi == id_taille /*&& epuise == ' '*/) {
							selected = 'selected = "selected"';
							trouv=1;
							
							if (epuise != ' ') {
								verif_dispo(id_produit_info_web, id_taille_choisi, id_couleur);
							}
						}
						
						valeur_select = valeur_select + '<option ' + epuise + ' ' + selected + ' value="' + id_taille + '">' + taille + '</option>';
						
					}//fin boucle for
					
					
					valeur_select = valeur_select + '</select>';
					valeur_select = valeur_select + '<input type="hidden" value="'+taille+'" name="nom_taille" id="nom_taille" />';
					document.getElementById("td_taille").innerHTML = valeur_select;
					
				}
					else
				{
					var taille 			= xmldoc.getElementsByTagName("taille")[0].childNodes[0].nodeValue;
					
					var valeur_select ='<strong>'+ taille +'</strong>'
					var ct = document.getElementById("choix_taille").value;
					var nt = document.getElementById("nom_taille").value;
					var valeur_select = valeur_select  +'<input type="hidden" value="'+ct+'" name="choix_taille" id="choix_taille" />'
					var valeur_select = valeur_select  +'<input type="hidden" value="'+nt+'" name="nom_taille" id="nom_taille" />'
					document.getElementById("td_taille").innerHTML = valeur_select;
				}
				
				//alert(compteur);
				//alert(valeur_select);
				 if (document.getElementById('id_vente_flash')) {
							  var id_vente_flash = document.getElementById('id_vente_flash').value;
						  }
						  else {
							  var id_vente_flash = 0  ;
						  }
					if (trouv==0 && id_vente_flash>0)
					{
						var id_taille 		= xmldoc.getElementsByTagName("id_taille")[0].childNodes[0].nodeValue;
						//alert (id_taille);
						verif_dispo(id_produit_info_web, id_taille, id_couleur);
					}
					else
					{
						verif_dispo(id_produit_info_web,id_taille_choisi,id_couleur);
					}
				
				 
		}
		
   }
   if (document.getElementById('id_vente_flash')) {
	  var id_vente_flash = document.getElementById('id_vente_flash').value;
  }
  else {
	  var id_vente_flash = 0  ;
  }
   //verif_dispo(id_produit_info_web,id_taille_choisi, id_couleur );
   	  var id_taille_choisi = document.getElementById("choix_taille").value;
	  //
	  xhr.open("POST",'javascript/taille_dispo.asp',true)
	  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	 //alert("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur + "&id_taille_choisi=" + id_taille_choisi);
	  xhr.send("id_produit_info_web=" + id_produit_info_web + "&id_couleur=" + id_couleur + "&id_taille_choisi=" + id_taille_choisi + "&id_vente_flash=" + id_vente_flash);
 }
 
		
