var xhr = 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;
}


//***********************************************Fonction pour connaitres les couleurs d'une taille********************************
function couleurs_dispo(id_produit)
 {
  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 id_produit	= xmldoc.getElementsByTagName("id_produit")[0].childNodes[0].nodeValue;
			var id_taille	= xmldoc.getElementsByTagName("id_taille")[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
			}
			
			node=document.getElementById('selection_couleur');
			node.innerHTML="";
			
			if (prix_normal > prix_promo && prix_promo != 0) {
				document.getElementById("prix_normal").innerHTML = prix_normal + " &euro;";
				document.getElementById("prix_promo").innerHTML = prix_promo + " &euro;";	
			}
			else {
				document.getElementById("prix_promo").innerHTML = prix_promo + " &euro;";
			}
			
			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;
				node.innerHTML = '<table><tr><td align="right" valign="top" width="115">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" /></td></tr></table>';
				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);
			}
			else if (compteur > 1) {
				var valeur_select = '<table><tr><td align="right" valign="top" width="115">Choix de la couleur :</td><td align="left"><select name="choix_couleur" size="1" id="choix_couleur" onchange="verif_dispo('+id_produit+',0,0)">';
				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(id_produit,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,id_taille, id_couleur);
					}
					else {
						valeur_select = valeur_select + '<option value="' + id_couleur + '">' + couleur + '</option>';
					}
				}	  
			  	valeur_select = valeur_select + '</select></td></tr></table>';
				node.innerHTML = valeur_select;
				document.getElementById('bouton_panier').style.display = '';
			}
			else {
				node.innerHTML = '<table><tr><td align="right" valign="top" width="115">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" /></td></tr></table>';
				document.getElementById('bouton_panier').style.display = 'none';
			}
			//alert('fin couleurs_dispo');
		}
		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  ;
  }
  
  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);
 }
 
 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;

			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 = '<table><tr><td align="right" valign="top" width="115">Couleur unique :</td><td align="left"> <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" /></td></tr></table>';
				}
				else {
					node.innerHTML = '<table><tr><td align="right" valign="top" width="115">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" /></td></tr></table>';
				}
				verif_dispo_package(id_produit,id_taille, id_couleur, rang);
			}
			else if (compteur > 1) {
				if (rang != 999) {
					var valeur_select = '<table><tr><td align="right" valign="top" width="115">Choix de la couleur :</td><td align="left"><select name="choix_couleur_'+rang+'" size="1" id="choix_couleur_'+rang+'" onchange="verif_dispo_package('+id_produit+',0,0,'+rang+')">';	
				}
				else {
					var valeur_select = '<table><tr><td align="right" valign="top" width="115">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+')">';	
				}
				
				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);
					}
					valeur_select = valeur_select + '<option value="' + id_couleur + '">' + couleur + '</option>';
				}	  
			  	valeur_select = valeur_select + '</select></td></tr></table>';
				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;  
  }
 
  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;
			
	  		node			=	document.getElementById('bouton_panier');

			if (disponible == 0) {
				node.style.display = 'none';
				document.getElementById('img_dispo').src = "images/picto_dispo/indisponible.png";
				document.getElementById('text_dispo').innerHTML = 'Produit non disponible';
			}
			else {
				node.style.display = '';
				if (picto_fr != '0') {
					document.getElementById('img_dispo').src = "images/picto_dispo/" + picto_fr;
				}
				document.getElementById('text_dispo').innerHTML = info_sup_fr;
			}
			//alert('fin verif_dispo');
		}
		else {
			//alert("xhr.readyState : " + xhr.readyState + " xhr.status : " + xhr.status);
		}
   }

   if (id_taille == 0 && id_couleur == 0) {
	  var id_taille = document.getElementById('choix_taille').value;
	  var id_couleur = document.getElementById('choix_couleur').value;
   }

  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);
 }
 
 function verif_dispo_package(id_produit, id_taille, id_couleur, rang)
 {
  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;

			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);
  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);
 }
 
 
 //******************************* 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){
  getXhr()
  xhr.onreadystatechange = function(){}
   
  var prix_total = document.getElementById('prix_total').value;
  var montant_port_total = document.getElementById('prix_port_total').value;
   
  xhr.open("POST",'javascript/modif_commande_ligne.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_commande_ligne=" + id_commande_ligne + "&qte=" + qte + "&prix_net=" + prix_net + "&prix_total=" + prix_total + "&montant_port_total=" + montant_port_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;
			
			document.getElementById('prix_port_total').innerHTML = prix_port_total + "&euro;";
			document.getElementById('montant_total').innerHTML = montant_total_commande + "&euro;";
		}
		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;
   }
  //alert('id_pays : ' + id_pays);
  
  xhr.open("POST",'javascript/calcul_frais_port.asp',true)
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("id_pays=" + id_pays);
}

 
//************************************** 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;
				
				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 (( 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;
					calcul_frais_port(id_pays_livraison);
				}
			}
			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;
  
  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 = 'client_commande.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="VTT-Liste-' + rayon_fr + '-' + nom_famille + ',' + id_rayon + ',' + id_famille + ',lv.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="VTT-Liste-' + rayon_fr + '-' + nom_famille + ',' + id_rayon + ',' + id_famille + ',lv.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);
 }
