/*function de verification du contenu du caddy*/
function envoyer_la_commande()
{
	QTT_articles=window.document.qCaddy.quantite.value;
	if (QTT_articles==0)
	{
	alert("Envois impossible car votre panier ne contient aucun article!");
	}
	if (QTT_articles>0)
	{
	this.location.href="cart/index.php?nLien=0h&Evenement=facture";
	}
	
}
function inputenable(id,state) {
 var divObj = null;
  if (document.getElementById) {
  divObj = document.getElementById(id);
 } else if(document.all) {
  divObj = document.all(id);
 } else if (document.layers) {
  divObj = document.layers[id];
 }
 if(state && divObj) {
  divObj.removeAttribute("readonly");
 } else if(divObj) {
  divObj.setAttribute("readonly","readonly");
 }
}

/*function de deverrouillage de champs*/
function DeverouillePassword(formulaire)
{
 	if(formulaire.mdp1.readOnly==true)
	{
		formulaire.mdp1.readOnly=false;
		formulaire.mdp2.readOnly=false;
		formulaire.mdp1.className="lise";
		formulaire.mdp2.className="lise";
		formulaire.mdp1.type="Text";
		formulaire.mdp2.type="Text";
	}
	else
	{
	 	formulaire.mdp1.readOnly=true;
		formulaire.mdp2.readOnly=true;
		formulaire.mdp1.className="liseVerouille";
		formulaire.mdp2.className="liseVerouille";
		formulaire.mdp1.type="Password";
		formulaire.mdp2.type="Password";
	}

}
/*function de verification du contenu du caddy pour inscription*/
function verifInscription()
{
	
	QTT_articles=window.document.qCaddy.quantite.value;
	//envoyer_la_commande();
	msg="";
	
	
	if (QTT_articles==0){msg=msg+"\n- Envois impossible car votre panier ne contient aucun article!"}
	if (msg!=""){
	msg="Les entrées suivantes sont incomplètes :\n"+msg;
	alert(msg);
	this.location.href="index.php?nLien=undefined";
	//window.document.inscrit.action="index.php?nLien=undefined";
	return false;
	}
	else
	{
	//window.document.inscrit.action="index.php?nLien=0o&par=ins&gui=4";
	return true;
	}
}
function verif()
{
	//alert("hello");
	QTT_articles=window.document.qCaddy.quantite.value;
	//envoyer_la_commande();
	msg="";
	if (document.log.login.value.length<3){msg=msg+"\n- Votre identifiant";}
	//if (document.log.mdp.value.length<3){msg=msg+"\n- Votre mot de passe";}
	if (QTT_articles==0){msg=msg+"\n- Envois impossible car votre panier ne contient aucun article!"}
	if (msg!=""){
	msg="Les entrées suivantes sont incomplètes :\n"+msg;
	alert(msg); 
	return false;
	}
	else
	{
	return true;
	}
}
function etoile(Param)
{
	//alert(document.form.elements["label1"].length-1);
	if (Param=="Privée")
		{
		
			for (i=0;i<document.form.elements["label"].length;i++)
			{
				document.form.label[i].value="*";
				
			}
			for (i=0;i<=document.form.elements["label1"].length-1;i++)
			{
				document.form.label1[i].value="";
			}
		}
	else
		{
			for (i=0;i<document.form.elements["label1"].length;i++)
			{
				document.form.label1[i].value="*";
			}
			for (i=0;i<=document.form.elements["label"].length-1;i++)
			{
				document.form.label[i].value="";
			}
		}
}
function changAction(Ref,formulaire)
{
 	//alert(Ref);
 	//alert(formulaire.User.value);
 	formulaire.action=Ref;
 	formulaire.submit();
 	//window.document.form.action=test;
	//window.document.form.submit();
}	
function change(test)
{
	/*<?
	if (isset($nmb)){
	 echo("QTT_articles=".$nmb.";"); 
	}
	else
	{
	echo("QTT_articles=0;");
	} 
	?>*/
	/*QTT_articles=window.document.qCaddy.quantite.value;
	alert(QTT_articles);
	if (QTT_articles==0)
	{
	alert("Envois impossible car votre panier ne contient aucun article!");
	}
	if (QTT_articles>0)
	{*/	
		
		if (envois_verif()){
		window.document.form.action=test;
		window.document.form.submit();
		}
		//else{alert(document.form.nom.value);}
	//}
	}
function VerifEmailPass(Form)
{
 	
 	var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
 	var flagEmail=0;
 	var flagPassword=0;
 	var msg="";
	if ((Form.email1.value=="") || (Form.email2.value==""))
	{
	 	
	 	//msg=msg+"\n- La saisie de votre e-mail est obligatoire.\n- Il deviendra votre identifiant.";
		flagEmail=1;
	}
	if (!(reg_mail.exec(Form.email1.value)!=null))
	{
	 	
		//msg=msg+"\n- L'adresse email n'est pas valide";
		flagEmail=1;
	}
	if (!(reg_mail.exec(Form.email2.value)!=null))
	{
	 	
		//msg=msg+"\n- La confirmation d'email n'est pas valide";
		flagEmail=1;
	}
	if (Form.email1.value!=Form.email2.value)
	{
	 	
		//msg=msg+"\n- Veuillez saisir deux fois le même e-mail";
		flagEmail=2;
	}
	if ((Form.mdp1.value=="") || (Form.mdp2.value==""))
	{
		//msg=msg+"\n- La saisie de votre mot de passe est obligatoire.\n- il doit être confirmer.";
		flagPassword=1;
	}
	if (Form.mdp1.value.length<4)
	{
	 	//msg=msg+"\n- Le mot de passe ne respecte pas la longueur minimal";
	 	//msg=msg+"\n- La confirmation du mot de passe ne correspond pas au mot de passe choisi";
		flagPassword=1;
	}
	if (Form.mdp1.value!=Form.mdp2.value)
	{
		//msg=msg+"\n- Veuillez saisir deux fois le même mot de passe";
		flagPassword=2;
	}
	if (flagEmail==0 && flagPassword==0)
	{
		Form.action="index.php?nLien=0m&M=2&par=ins&gui=2";
		return true;
	}
	else
	{
	 	
	 	if (flagEmail==1)
		{
			msg=msg+"\n- L'adresse e-mail n'est pas valide";
		}
		else if (flagEmail==2)
		{
			msg=msg+"\n- les 2 adresses e-mail ne sont pas identiques";
		}
		if (flagPassword==1)
		{
			msg=msg+"\n- Le mot de passe doit comprendre au minimum 4 caractères";
		}
		else if (flagPassword==2)
		{
			msg=msg+"\n- les 2 mots de passe ne sont pas identiques";
		}
	 	alert(msg);
		return false;
	}
}
//backup VerifEmailPass
function VerifEmailPassBack(Form)
{
 	var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
 	var flag=0;
 	var msg="";
	if ((Form.email1.value=="") || (Form.email2.value==""))
	{
	 	msg=msg+"\n- La saisie de votre e-mail est obligatoire.\n- Il deviendra votre identifiant.";
		flag=1;
	}
	if (!(reg_mail.exec(Form.email1.value)!=null))
	{
		msg=msg+"\n- L'adresse e-mail n'est pas valide";
	}
	if (!(reg_mail.exec(Form.email2.value)!=null))
	{
		msg=msg+"\n- La confirmation d'e-mail n'est pas valide";
	}
	if (Form.email1.value!=Form.email2.value)
	{
		msg=msg+"\n- Veuillez saisir deux fois le même e-mail";
	}
	if ((Form.mdp1.value=="") || (Form.mdp2.value==""))
	{
		msg=msg+"\n- La saisie de votre mot de passe est obligatoire.\n- il doit être confirmer.";
	}
	if (Form.mdp1.value!=Form.mdp2.value)
	{
		msg=msg+"\n- Veuillez saisir deux fois le même mot de passe";
	}
	if (Form.mdp1.value.length<4)
	{
	 	msg=msg+"\n- Le mot de passe ne respecte pas la longueur minimal";
	 	//msg=msg+"\n- La confirmation du mot de passe ne correspond pas au mot de passe choisi";
	}
	
	if (msg=="")
	{
		Form.action="index.php?nLien=0m&M=2&par=ins&gui=2";
		return true;
	}
	else
	{
	 	alert(msg);
		return false;
	}
}
//Fonction de vérification de saisie d'email au bon format
function verif_mail(email)
{
 	if (email!='')
	{
		var reg_mail = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
		if (!(reg_mail.exec(email)!=null))
		{
			alert("L'adresse email n'est pas valide !");
			return(false);
		}
		else
		{
		 return(true);
		}
	}
	else
	{	
	 	alert("veuillez saisir une adresse e-mail valide");
		return(false);
	}
}
function verif_cp(cp)
    {
		//var reg_cp =  /^[0-9]{5}$/
		var reg_cp = /^([0-9]{4}|[0-9]{5})$/;
		//code postal francais ^(0[1-9]|[1-9][0-9])[0-9]{3}$
		// code postal belge ^(F-[0-9]{4,5}|B-[0-9]{4})$
		if (!(reg_cp.exec(cp)!=null))
		  {	
			//alert("Le code postal saisie n'est pas au format valide !");
			return(false);
		  }
  	  return(true);
	}	
function envois_verif()
{
	msg="";
	if ((document.form.sexe[0].checked!=true)&&(document.form.adrsfacturation[1].checked!=true)&&(document.form.sexe[2].checked!=true))
	{
	 	document.form.sexe[0].checked=true;
	}
	if (document.form.nom.value.length<3){msg=msg+"\n- Votre nom";}
	if (document.form.prenom.value.length<3){msg=msg+"\n- Votre prénom";}
	if ((document.form.adrsfacturation[0].checked!=true)&&(document.form.adrsfacturation[1].checked!=true))
	{
		document.form.adrsfacturation[0].checked=true;
	}
	if (document.form.adrsfacturation[0].checked==true){
	if (document.form.rue1.value.length<3){msg=msg+"\n- Le nom de la rue";}
	//if (!verif_cp(document.form.npa.value)){msg=msg+"\n- Le numéro postal";}
	if (document.form.npa.value.length<4){msg=msg+"\n- Le numéro postal";}
	if (document.form.ville.value.length<3){msg=msg+"\n- Le nom de la ville";}
	if (document.form.tel.value.length<3){msg=msg+"\n- Votre numéro de téléphone";}
	if (document.form.email.value.length<3){msg=msg+"\n- Votre adresse e-mail";}
	}
	// -------------------------------------------- SI L'OPTION ADRESSE DE FACTURATION PROF. EST COCHEE
	if (document.form.adrsfacturation[1].checked==true){
	if (document.form.societe.value.length<3){msg=msg+"\n- Le nom de la société";}
	if (document.form.fonction.value.length<3){msg=msg+"\n- Votre fonction";}
	if (document.form.rue1p.value.length<3){msg=msg+"\n- Nom de la rue de la société";}
	if (document.form.npap.value.length<3){msg=msg+"\n- Numéro postal de la société";}
	if (document.form.villep.value.length<3){msg=msg+"\n- Ville où se trouve la société";}
	}
	// --------------------------------------------
	if (document.form.mdp1.value.length<4){msg=msg+"\n- Le mot de passe choisi";}
	if (document.form.mdp2.value.length<4){msg=msg+"\n- La confirmation de votre mot de passe";}
	if ((document.form.mdp1.value.length>3)&&(document.form.mdp2.value.length>3)&&(document.form.mdp1.value!=document.form.mdp2.value)){msg=msg+"\n- La confirmation du mot de passe ne correspond pas au mot de passe choisi";}
	if (msg!="")
	{
	 	msg="Le formulaire n'a pas été envoyé car il contient des éléments incomplets :\n"+msg;
		alert(msg);
		return(false);
	}
	else{
		return(true);
	}
	// ---------------------------------------------------------------------------------
}
	
function up()
{
	var maxChar = 256;
	var msg  = document.forms.log.txt_remarques;
	var left = document.forms.log.charNumberLeftOutput;
	var RemLenLeft = maxChar  - msg.value.length;
	if (RemLenLeft >= 0) 
	{ 
		left.value = RemLenLeft;
	} 
	else
	{ 
		var msgMaxLen = maxChar; 
	 	left.value = 0;
		msg.value = msg.value.substring(0, msgMaxLen);
	}
}

function envoie(val)
{
 	
 	if (window.document.log.login.value=="")
	{
		val=val+"&gui=0";
	}
	else
	{
		val=val+"&gui=1";
	}
 	window.document.forms["log"].action=val;
	window.document.forms["log"].submit();
}
function annuleCommande()
{
	if (confirm("Voulez-vous vraiment annuler la commande ?")) 
	   { 
           go_lien("../index.php","undefined&vDes=delall");
       }
}
function fnOuvrirDetails(vDtlsCours)
{
	//alert(vDtlsCours);
							 //window.open("0_sys/index.php?vNumCours="+vDtlsCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes");
window.open("index.php?vNumCours="+vDtlsCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes");
	//window.open("cours/details/index.php?vNumCours="+vDtlsCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes");
}
function fnImprimerCours(vImprCours,vImprCat)
{//imprimer.php
	//window.open("0_sys/print.php?vCoursNoImprimer="+vImprCours+"&vCatNoImprimer="+vImprCat,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
//window.open("0_sys/index.php?vCoursNoImprimer="+vImprCours+"&vCatNoImprimer="+vImprCat,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
window.open("index.php?vCoursNoImprimer="+vImprCours+"&vCatNoImprimer="+vImprCat,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600");
}

function fnImprimerDates(vImprCours)
{
	//window.open("0_sys/index.php?vCoursNoImprimer="+vImprCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
window.open("index.php?vCoursNoImprimer="+vImprCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600");
//window.open("0_sys/imprimerdates.php?vCoursNoImprimer="+vImprCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
}
function openRequestedPopup(adresse)
{
	//window.open("0_sys/index.php?vCoursNoImprimer="+vImprCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
window.open(adresse,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600,height=400");
//window.open("0_sys/imprimerdates.php?vCoursNoImprimer="+vImprCours,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
}
function fnEnvoyerCours(vEnvCoursLienA,vEnvCoursLienB)
{
	window.open("0_sys/envoyer_amis.php?vLienA="+vEnvCoursLienA+"&vLienB="+vEnvCoursLienB,"","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes");
}
function go_lien(vURL,vPrm)
{
	window.document.form_opn_lien.url_page.value=vURL;
	window.document.form_opn_lien.param.value=vPrm;
	window.document.form_opn_lien.submit();
}
function fnQuittance(formu)
{
 	hwin=window.open("../0_sys/ticket.php","hwin","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600");
 	window.document.log.action="../0_sys/ticket.php";
 	window.document.log.target="hwin";
 	window.document.log.submit();
 	window.document.log.target="_self";
 	window.document.log.action="index.php?nLien=0q&par=au&gui=3";
 	window.document.log.submit();
 }
function fnQuittancePrint(formu)
{
 	hwin=window.open("../0_sys/ticket.php","hwin","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
 	window.document.log.action="../0_sys/ticket.php";
 	window.document.log.target="hwin";
 	window.document.log.submit();
 	//alert(window.document.log.action);
    //window.open("../0_sys/ticket.php","","scrollbars=yes,menubar=no,location=no,directories=no,toolbar=no,status=yes,resizable=yes,width=600,outerwidth=600")
	//go_lien("../index.php","0h&vDes=delall");
}
function rech_verif()
{
if (document.form.mot.value.length<3){alert("Veuillez entrer une requête/un cours à rechercher (3 car. au minimum)");return false}
}


function checkFields() {
missinginfo = "";
if ((document.userData.email.value == "") || 
  (document.userData.email.value.indexOf('@') == -1) || 
  (document.userData.email.value.indexOf('.') == -1)) {
  missinginfo += "\n     -  Adresse e-mail incorrecte ou erronée";
}
em = document.userData.email.value; 
if (em.length < 7) {
  missinginfo += "\n     -  veuilliez verifier la longueur";
}
if (em.lastIndexOf('@') > em.lastIndexOf('.')) {
  missinginfo += "\n     -  Adresse e-mail incorrecte ou erronée";
}
if ((document.userData.Nom.value =="")){
     missinginfo += "\n     -  Nom obligatoire";
}
if ((document.userData.Prenom.value =="")){
     missinginfo += "\n     -  Prénom obligatoire";
}
if (missinginfo != "") {
  missinginfo ="_____________________________________\n" +
  "Veuillez corriger:\n" + missinginfo;
  alert(missinginfo);
  return false;
}
else return true;
}



function checkFields1() {
missinginfo = "";
if ((document.userData.email.value == "") || 
  (document.userData.email.value.indexOf('@') == -1) || 
  (document.userData.email.value.indexOf('.') == -1)) {
  missinginfo += "\n     -  falsche oder fehlerhafte E-Mail Adresse";
}
em = document.userData.email.value; 
if (em.length < 7) {
  missinginfo += "\n     -  fehlerhafte E-Mail Adresse";
}
if (em.lastIndexOf('@') > em.lastIndexOf('.')) {
  missinginfo += "\n     -  fehlerhafte E-Mail Adresse";
}
if (document.userData.pwd.value == "") {
  missinginfo += "\n     -  falsches Passwort";
}
if (missinginfo != "") {
  missinginfo ="_____________________________________\n" +
  "Bitte korrigieren Sie folgende fehlerhaften Angaben:\n" + missinginfo;
  alert(missinginfo);
  return false;
}
else return true;
}
		