//FORMULAIRE IDENTIFICATION CLIENT
function VerifFormPasswordClient()
   {
   if ( (Login()) && (Password())  )
       {
       	return true;
       	}
       	else
      return false;
   }
function Login()
   {
   var str = document.client.identifiant.value;
   //alert(str);
   if ((str == "" || str == " "))
      {
      alert("\nIndiquez votre login.")
      document.client.identifiant.focus();
      return false;
      }
   return true;
   }
function Password()
   {
   var str = document.client.password.value;
   if ((str == "" || str == " "))
      {
      alert("\nIndiquez votre mot de passe.")
      document.client.password.focus();
      return false;
      }
   return true;
   }
//FORMULAIRE IDENTIFICATION CLIENT
function VerifFormPasswordClient2()
   {
   if ( (Login2()) && (Password2())  )
       {
       	return true;
       	}
       	else
      return false;
   }
function Login2()
   {
   var str = document.client2.identifiant2.value;
   //alert(str);
   if ((str == "" || str == " "))
      {
      alert("\nIndiquez votre Email.")
      document.client2.identifiant2.focus();
      return false;
      }
   return true;
   }
function Password2()
   {
   var str = document.client2.password2.value;
   if ((str == "" || str == " "))
      {
      alert("\nIndiquez votre mot de passe.")
      document.client2.password2.focus();
      return false;
      }
   return true;
   }

var ff = null ;
//****POPUP AVEC FOCUS****//
function ouvrirfenetre(lien){
	ff = window.open (lien,"fiche", "width=620, height=500, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, left=0, top=65");
	ff.focus();
}
function onferme(){
	window.close();
	ff = null;
}
//script vignette images
function afficheMaxi(chemin){
	foto1= new Image();
  	foto1.src=(chemin);
	html = '<HTML><HEAD><TITLE>Image</TITLE></HEAD><link href=/css/styles.css rel=stylesheet type=text/css><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><DIV ID=PopupHead><IMG SRC=/LIBRARY/LOGO2.GIF></DIV><CENTER><A HREF="#" ONCLICK="javascript:window.close();" TITLE="CLIQUER POUR FERMER">Fermer</A><BR><IMG SRC="'+chemin+'" BORDER=0 NAME=zoom onLoad="window.resizeTo(document.zoom.width+120,document.zoom.height+150)"></CENTER></BODY></HTML>';
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,status=1');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
	}

//****FOCUS CHAMP TEXTE EMAIL ****//
function FocusText(email)
{
if (email.value == email.defaultValue)
{
email.value = '';
}
}
function BlurText(email)
{
if (email.value == '')
{
email.value = email.defaultValue;
}
}

//Affiche page depuis menu deroulant
function ChangeUrlAdr(formulaire)
	{
	(formulaire.SelectAdresseLiv.selectedIndex ==1)
		{
		location.href = formulaire.SelectAdresseLiv.options[formulaire.SelectAdresseLiv.selectedIndex].value;
		}
	}
//****FORMULAIRE CLIENT****//
	//***MEME COORDONNEES LIVRAISON***//
function idem()
	{
//	document.formClient.LivCivilite.value=document.formClient.FacCivilite.value;
	document.formClient.LivNom.value=document.formClient.nom.value;
//	document.formClient.LivPrenom.value=document.formClient.FacPrenom.value;
	document.formClient.LivAdr.value=document.formClient.adresse.value;
	document.formClient.LivSuiteAdr.value=document.formClient.adresse2.value;
	document.formClient.LivCp.value=document.formClient.cp.value;
	document.formClient.LivVille.value=document.formClient.ville.value;
	document.formClient.LivPays.value=document.formClient.pays.value;
	document.formClient.LivTel.value=document.formClient.tel.value;
	document.formClient.LivFax.value=document.formClient.fax.value;	
	document.formClient.LivPortable.value=document.formClient.portable.value;	
	document.formClient.LivEmail.value=document.formClient.email.value;
	document.formClient.LivInterloc.value=document.formClient.societe.value;
}



   //FORMULAIRE PARRAINAGE
   function EmailFilleulValide()
   {
   if (document.formParrainage.emailFilleul.value == "") 
      {
      alert("\nVeuillez indiquer une adresse E-mail valide. Celle-ci vous servira à votre filleul pour recevoir son mail d'inscription.")
      document.formParrainage.emailFilleul.focus();
      return false; 
      }
   if (document.formParrainage.emailFilleul.value.indexOf ('@',0) == -1 || 
       document.formParrainage.emailFilleul.value.indexOf ('.',0) == -1)
      {
      alert("\nVeuillez indiquer une adresse E-mail valide. Celle-ci vous servira à votre filleul pour recevoir son mail d'inscription.")
      document.formParrainage.emailFilleul.focus();
      return false;
      }
   else
      {
      return true;
      }
   } 
//VERIFICATION DE TOUS LES CHAMPS DU FORMULAIRE DES FILLEULS A PARRAINER
function EmailFilleulPlusValide()
   {
   if ( (EmailFilleulValide1()) && (EmailFilleulValide2()) )
       {
       	return true;
       	}
      	else
      return false;
   } 
function EmailFilleulValide1()
   {
   if (document.formParrainage2.emailFilleul1.value == "") 
      {
      return true; 
      }
   if (document.formParrainage2.emailFilleul1.value.indexOf ('@',0) == -1 || 
       document.formParrainage2.emailFilleul1.value.indexOf ('.',0) == -1)
      {
      alert("\nVeuillez indiquer une adresse E-mail valide. Celle-ci vous servira à votre filleul 1 pour recevoir son mail d'inscription.")
      document.formParrainage2.emailFilleul1.focus();
      return false;
      }
   }    
function EmailFilleulValide2()
   {
   if (document.formParrainage2.emailFilleul2.value != "") 
      {
      return false; 
      }
   if (document.formParrainage2.emailFilleul2.value.indexOf ('@',0) == -1 || 
       document.formParrainage2.emailFilleul2.value.indexOf ('.',0) == -1)
      {
      alert("\nVeuillez indiquer une adresse E-mail valide. Celle-ci vous servira à votre filleul 2 pour recevoir son mail d'inscription.")
      document.formParrainage2.emailFilleul2.focus();
      return false;
      }
   } 



//***	FORMULAIRE CONTACT***
function ValidFormContact(form) {
	if ( (nom(form)) && (email(form)) && (message(form)) ) {
		return true;
	} else
	return false;
}
//****	FORMULAIRE CLIENT*****
function submitForm(form) {
	if ( (nom(form)) && adresse(form) && cp(form) && (ville(form)) && (tel(form)) && (email(form)) ) {
       	return true;
    }else
      return false;
}


//****	FORMULAIRE INSCRIPTION*****
function ValidInscription(form) {
	if ( (nom(form)) && adresse(form) && cp(form) && (ville(form)) && (tel(form)) && (email(form)) && (login(form)) && (password(form)) && (password_confirm(form)) ) {
       	return true;
    }else
      return false;
}

//***	FORMULAIRE MOT DE PASSE PERDU***//
function ValidFormPasswordPerdu(form) {
	if ( (login1(form)) && (nom(form)) && (email(form)) ) {
       	return true;
	}else
      return false;
}

//***	FORMULAIRE TELECHARGEMENT CATALOGUE PAPIER
function verif_form_catalogue(form) {
	if ( (nom(form)) && (adresse(form)) && (cp(form)) && (ville(form)) && (email(form)) && (captcha(form)) ) {
		return true;
	}else
		return false;
	}



function code(form){
   if (document[form].code.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre code client.";
		document[form].code.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}
function login1(form){
   if (document[form].login.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre identifiant (login).";
		document[form].login.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}
function nom(form){
   if (document[form].nom.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre nom.";
		document[form].nom.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}
function societe(form){
   if (document[form].societe.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre soci&eacute;t&eacute;.";
		document[form].societe.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}

function adresse(form){
   if (document[form].adresse.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre adresse.";
		document[form].adresse.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}
function cp(form) {
	var pay = document[form].pays.value;
	if (pay.toUpperCase() == "FRANCE") {
		var str = document[form].cp.value;
		if (str < "00001" || str.length != 5) {
			document.getElementById("alert").style.display="block";
			document.getElementById("alert").innerHTML="Le code postal est incorrect.";
			document[form].cp.select();	  
			document[form].cp.focus();
			return false;
		}   	
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring(i, i + 1);
			if ((ch < "0" || "9" < ch)) {
				document.getElementById("alert").style.display="block";
				document.getElementById("alert").innerHTML="Le code postal est incorrect.";
				document[form].cp.select();	  
				document[form].cp.focus();
				return false;
			}
		}
		return true;
	}else{
		return true;
	}
} 
function ville(form){
   if (document[form].ville.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre ville.";
		document[form].ville.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}
function email(form) {
	if (document[form].email.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre adresse E-mail.";
		document[form].email.focus();
		return false; 
	}
	if (document[form].email.value.indexOf ('@',0) == -1  || document[form].email.value.indexOf ('.',0) == -1) {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez une adresse E-mail valide.";
		document[form].email.focus();
		return false;
	} else {
		return true;
	}
} 
function tel(form) {
	var str = document[form].tel.value;
	var str2 = document[form].portable.value;
	if (str == "" && str2 == "" ) {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre num&eacute;ro de t&eacute;l&eacute;phone ou de portable.";
//		document[form].tel.focus();
		return false;
	}   
	if (str.length>0) {
		for (var i = 0; i < str.length; i++) {
			var ch = str.substring(i, i + 1);
			if ((ch < "0" || "9" < ch) && (ch != '.') && (ch != '/') && (ch != ' ') && (ch != '-')) {
				document.getElementById("alert").style.display="block";
				document.getElementById("alert").innerHTML="Le num&eacute;ro de t&eacute;l&eacute;phone n'est pas valide.";
				document[form].tel.select();
				document[form].tel.focus();
				return false;
			}
		}
	}
	if (str2.length>0) {
		for (var j = 0; j < str2.length; j++) {
			var ch2 = str2.substring(j, j + 1);
			if ((ch2 < "0" || "9" < ch2) && (ch2 != '.') && (ch2 != '/') && (ch2 != ' ') && (ch2 != '-')) {
				document.getElementById("alert").style.display="block";
				document.getElementById("alert").innerHTML="Le num&eacute;ro de t&eacute;l&eacute;phone2 n'est pas valide.";
				document[form].portable.select();
				document[form].portable.focus();
				return false;
			}
		}
	}
	return true;	  
}
function login(form){
   if (document[form].login.value == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez un identifiant.";
		document[form].login.focus();
		return false;
	}else{
		document.getElementById("alert").style.display="none";
      	return true; 
   }
}

function password(form) {
	var str = document[form].password.value;
	if (str == "" || str.length <6) {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Indiquez votre mot de passe de 6 caract&egrave;res minimum.";
		document[form].password.focus();
		return false;
	}
	else{
		return true; 
	}
}
function password_confirm(form) {
	var str = document[form].password2.value;
	if ((str == "" || str == " ")) {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Confirmez votre nouveau mot de passe.";
		document[form].password2.focus();
	return false;
	} else if (document[form].password.value != document[form].password2.value) {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Le mot de passe de confirmation n'est pas identique, veuillez le ressaisir.";
		document[form].password2.focus();
		return false;
	}
	return true;
}
function captcha(form){
	var str = document[form].captchacode.value;
	if (str == "") {
		document.getElementById("alert").style.display="block";
		document.getElementById("alert").innerHTML="Veuillez indiquer le code de contr&ocirc;le."	
		document[form].captchacode.focus();
		return false;
	}else{
		return true; 
	} 
} 
function message(form)
   {
   var str = document[form].message.value;
   if ((str == "" || str == " "))
      {
	  document.getElementById("alert").style.display="block";
	  document.getElementById("alert").innerHTML="Veuillez saisir votre message.";	
      document[form].message.focus();
      return false;
      }
   return true;
   }




function condition(formInscription)
 {
   if (document.formInscription.conditions.checked == false)
      {
      alert("\nVous devez accepter les conditions générales.")
      //document.formInscription.conditions.focus();
      return false;
      }
   else
      return true   
   }
   
function ValidCommande(form){
	if ( civ1(form) && nom1(form) && prenom1(form) && adresse1(form) && cp1(form) && ville1(form) && tel1(form) && email1(form) & condiition1(form) ){
       	return true;
       	}else{
      return false;
   }
}
function civ1(form){
	var str = form.FacCivilite.value;
	if (str == ""){
	  alert("\nVeuillez indiquer votre civilité.")
	  form.FacCivilite.focus();
	  return false;
	  }
	else{
	  return true;   
	}
}
function nom1(form){
	var str = form.FacNom.value;
	if (str == ""){
	  alert("\nVeuillez indiquer votre nom.")
	  form.FacNom.focus();
	  return false;
	  }
	else{
	  return true;   
	}
}
function prenom1(form){
	var str = form.FacPrenom.value;
	if (str == ""){
	  alert("\nVeuillez indiquer votre prénom.")
	  form.FacPrenom.focus();
	  return false;
	  }
	else{
	  return true;   
	}
}
function adresse1(form){
	var str = form.FacAdr.value;
	if (str == ""){
	  alert("\nVeuillez indiquer votre adresse.")
	  form.FacAdr.focus();
	  return false;
	  }
	else{
	  return true;   
	}
}
function cp1(form)
   {
   var str = form.FacCp.value;
    if (str.length != 5)
      {
      alert("\nIndiquez votre code postal.");
      form.FacCp.select();
      form.FacCp.focus();
      return false;
      }
   if (str < "00001")
      {
      alert("\nLe Code Postal est incorrect.");
      form.FacCp.select();	  
      form.FacCp.focus();
      return false;
      }   
   for (var i = 0; i < str.length; i++) 
      {
      var ch = str.substring(i, i + 1);
      if ((ch < "0" || "9" < ch)) 
         {
         alert("\nLe Code Postal est incorrect.");
         form.FacCp.select();
         form.FacCp.focus();
         return false;
         }
      }
   return true;
   }
function ville1(form){
	var str = form.FacVille.value;
	if (str == ""){
	  alert("\nVeuillez indiquer votre ville.")
	  form.FacVille.focus();
	  return false;
	  }
	else{
	  return true;   
	}
}
function tel1(form)
   {
   var str = form.FacTel.value;
   if (str == "")
      {
      alert("\nVeuillez compléter le Téléphone.")
      form.FacTel.focus();
      return false;
      }
	if (str < "00000000000001")
      {
      alert("\nLe numéro de téléphone n'est pas valide.");
      form.FacTel.select();
      form.FacTel.focus();
      return false;
      }   
   
   return true;
   }   
function email1(form)
   {
   if (form.FacEmail.value == "") 
      {
      alert("\nVeuillez compléter l'adresse E-mail. Celle-ci vous servira pour recevoir la confirmation de commande.")
      form.FacEmail.focus();
      return false; 
      }
   if (form.FacEmail.value.indexOf ('@',0) == -1 || 
       form.FacEmail.value.indexOf ('.',0) == -1)
      {
      alert("\nL'adresse E-mail n'est pas valide")
      form.FacEmail.focus();
      return false;
      }
   else
      {
      return true;
      }
   }
function condiition1(form)
 {
   if (form.conditions.checked == false)
      {
      alert("\nVous devez accepter les conditions générales.")
      return false;
      }
   else
      return true   
   }







// MODIFIER QUANTITE
function qm(form,cel,val,max,min) {
	nb = document[form][cel].value;
	nb = parseInt(nb) + parseInt(val);
	if (nb <min) {nb = min}
	document[form][cel].value = nb;	
	if (nb > max) {
	document[form][cel].value = max;
	}
}
// REDIRECTION RECHERCHE PAR FORMULAIRE
function ChangeUrl(formulaire)
	{
	(recherche.formFamille.selectedIndex ==1)
		{
		location.href = recherche.formFamille.options[recherche.formFamille.selectedIndex].value;
		}
		}
function ChangeUrl2(formulaire)
	{
	(recherche.formSfamille.selectedIndex ==1)
		{
		location.href = recherche.formSfamille.options[recherche.formSfamille.selectedIndex].value;
		}
		}
//AFFICHAGE ONGLET
function TabClick( nTab ){ 
    Col = document.getElementsByName("Content"); 
    for (i = 0; i < document.getElementsByName("Content").length; i++) 
        { 
        document.getElementsByName("tabs")[i].className = "Tab"+[i]+" TabOff"+[i]; 
        document.getElementsByName("Content")[i].style.display = "none"; 
        } 
    document.getElementsByName("Content")[nTab].style.display = "block";     
    document.getElementsByName("tabs")[nTab].className = "Tab"+[nTab]+" TabOn"+[nTab]; 
}


//AFFICHAGE OPTION PANIER
function afficheCarte(){
	if (document.panierOption.emballage.checked){
		document.panierOption.emballagecarte.disabled=false;	
		}else{
		document.panierOption.emballagecarte.disabled=true;		
		document.panierOption.emballagecarte.checked=false;		
		document.panierOption.carteTxt.value="";		
		document.getElementById("carte").style.display="none";
	}
}
function CarteTxt() {
	if (document.panierOption.emballagecarte.checked){
		document.getElementById("carte").style.display="block";
	}else{
		document.getElementById("carte").style.display="none";
	}
}
function verifTxt(){
	if (document.panierOption.emballagecarte.checked){
		if (document.panierOption.carteTxt.value!=""){
			return true;
		}else{
			alert("Veuillez indiquer le texte qui sera imprimé sur la carte.");
			return false;
			document.panierOption.carteTxt.select();
			document.panierOption.carteTxt.focus();
  		}
	}
}

//FONCTION POUR LIMITER LE NOMBRE DE CARACTERES DU CHAMP COMMENTAIRE
function Compter(Target, max, nomchamp)
{
StrLen = Target.value.length
if (StrLen > max )
{
Target.value = Target.value.substring(0,max);
CharsLeft = max;								
}
else
{
CharsLeft = StrLen;
}	
nomchamp.value = CharsLeft;
}

//****************************
//** FONCTION POUR CAPTCHA	**
//****************************
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

