window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function controleInscriptionPRO()
{
	var verifLettres = /^[a-zA-Z0-9' -]*$/ ;
	var verifEmail = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/ ;
	var verifCodePost = /^[0-9]{5}$/;
	var verifNumerique = /^[0-9]{1,16}$/;
	var msgNom = document.getElementById("ErrNom");
	var msgSiret = document.getElementById("ErrSiret");
	var msgTelephone = document.getElementById("ErrTelephone");
	var msgTelecopie = document.getElementById("ErrTelecopie");
	var msgMobile= document.getElementById("ErrMobile");
	var msgCodePost = document.getElementById("ErrCodePost");
	var msgVille = document.getElementById("ErrVille");
	var msgMail = document.getElementById("ErrMail");
	var msgAdresse = document.getElementById("ErrAdresse");
	var msgMotPasse = document.getElementById("ErrMotPasse");
	var msgVerif = document.getElementById("ErrVerif");
	var msgConfirmMotPasse = document.getElementById("ErrConfirmMotPasse");
	var msgErrVerif = document.getElementById("ErrVerif");
	var OK = 1 ;
	msgNom.innerHTML="";
	msgSiret.innerHTML="";
	msgTelephone.innerHTML="";
	msgTelecopie.innerHTML="";
	msgMobile.innerHTML="";
	msgCodePost.innerHTML="";
	msgVille.innerHTML="";
	msgMail.innerHTML="";
	msgAdresse.innerHTML ="";
	msgMotPasse.innerHTML ="";
	msgVerif.innerHTML ="";
	msgConfirmMotPasse.innerHTML ="";
	msgErrVerif.innerHTML ="";
	
	if((document.forms["maForm_inscription"].form_nom.value)=="")
	{
		msgNom.innerHTML = "veuillez saisir votre nom de Soci&eacute;t&eacute;";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_inscription"].form_nom.value) == null)
		{
			msgNom.innerHTML= "nom incorrect";
			OK = 0;
		}
	}
	//SIRET*********************************************************************************
	if((document.forms["maForm_inscription"].form_siret.value)=="")
	{
		msgSiret.innerHTML = "veuillez saisir votre numéro de SIRET";
		OK = 0;
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_siret.value) == null)
		{
			msgSiret.innerHTML= "SIRET incorrect";
			OK = 0;
		}
	}
	//telephone*************************************************************************
	if((document.forms["maForm_inscription"].form_telephone.value)=="")
	{
		msgTelephone.innerHTML = "veuillez saisir votre numéro de telephone";
		OK = 0;
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_telephone.value) == null)
		{
			msgTelephone.innerHTML= "telephone incorrect";
			OK = 0;
		}
	}
//telecopie*********************************************************************************
	if((document.forms["maForm_inscription"].form_telecopie.value)=="")
	{
		
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_telecopie.value) == null)
		{
			msgTelecopie.innerHTML= "telecopie incorrect";
			OK = 0;
		}
	}
//mobile*********************************************************************************
	if((document.forms["maForm_inscription"].form_mobile.value)=="")
	{
		
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_mobile.value) == null)
		{
			msgMobile.innerHTML= "mobile incorrect";
			OK = 0;
		}
	}	
	// adresse**********************************************************************************
	if((document.forms["maForm_inscription"].form_adresse.value)=="")
	{
		msgAdresse.innerHTML = "veuillez saisir votre adresse";
		OK = 0;
	}
	// code postal*******************************************************************************
	if((document.forms["maForm_inscription"].form_postal_code.value)=="")
	{
		msgCodePost.innerHTML = "veuillez saisir un code postal";
		OK = 0;
	}
	else
	{
		if(verifCodePost.exec(document.forms["maForm_inscription"].form_postal_code.value) == null)
		{
			msgCodePost.innerHTML="code postal incorrect";
			OK = 0;
		}
	}
	// ville*********************************************************************************************
	if((document.forms["maForm_inscription"].form_ville.value)=="")
	{
		msgVille.innerHTML = "veuillez saisir une ville";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_inscription"].form_ville.value) == null)
		{
			msgVille.innerHTML="ville incorrecte";
			OK = 0;
		}
	}
	// email***********************************************************************
	if((document.forms["maForm_inscription"].form_mail.value)=="")
	{
		msgMail.innerHTML = "veuillez saisir une adresse email";
		OK = 0;
	}
	else
	{
		if(verifEmail.exec(document.forms["maForm_inscription"].form_mail.value) == null)
		{
			msgMail.innerHTML="e-mail incorrect";
			OK = 0;	
		}
	}
	// login******************************************************************************

	
	// mot de passe***********************************************************************
	if((document.forms["maForm_inscription"].form_password.value)=="")
	{
		msgMotPasse.innerHTML = "veuillez saisir un mot de passe";
		OK = 0;
	}
	else
	{
		if(document.forms["maForm_inscription"].form_password.value.length < 6)
		{
			msgMotPasse.innerHTML = "au moins 6 caractères";
			OK = 0;
		}
	}
	
// confirmation mot de passe************************************************************
	if((document.forms["maForm_inscription"].form_password_confirm.value)=="")
	{
		msgConfirmMotPasse.innerHTML = "veuillez confirmer votre mot de passe";
		OK = 0;
	}
	else
	{
		if(!(document.forms["maForm_inscription"].form_password.value == document.forms["maForm_inscription"].form_password_confirm.value))
		{
			msgConfirmMotPasse.innerHTML = "erreur dans la confirmation du mot de passe";
			//document.forms["maForm_inscription"].form_password_confirm.value = "";
			OK = 0;
		}
	}
	
	//  **************************************************  image vérification  ****************
	if((document.forms["maForm_inscription"].form_verif.value)=="")
	{
		msgErrVerif.innerHTML = "veuillez saisir le code de vérification";
		OK = 0;
	}
	else
	{
		if(!(document.forms["maForm_inscription"].form_verif.value == document.forms["maForm_inscription"].form_valeur_verif.value))
		{
			msgErrVerif.innerHTML = "erreur dans  l'image  de vérification ";
			//document.forms["maForm_inscription"].form_password_confirm.value = "";
			OK = 0;
		}
	}
	
	if (OK == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}	



function controleInscriptionParticulier()
{
	var verifLettres = /^[a-zA-Z0-9' -]*$/ ;
	var verifEmail = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/ ;
	var verifCodePost = /^[0-9]{5}$/;
	var verifNumerique = /^[0-9]{1,16}$/;
	var msgPre = document.getElementById("ErrPre");
	var msgNom = document.getElementById("ErrNom");
	var msgTelephone = document.getElementById("ErrTelephone");
	var msgTelecopie = document.getElementById("ErrTelecopie");
	var msgMobile= document.getElementById("ErrMobile");
	var msgCodePost = document.getElementById("ErrCodePost");
	var msgVille = document.getElementById("ErrVille");
	var msgMail = document.getElementById("ErrMail");
	var msgAdresse = document.getElementById("ErrAdresse");
	var msgMotPasse = document.getElementById("ErrMotPasse");
	var msgVerif = document.getElementById("ErrVerif");
	var msgConfirmMotPasse = document.getElementById("ErrConfirmMotPasse");
	var msgErrVerif = document.getElementById("ErrVerif");
		
	var OK = 1 ;
	msgPre.innerHTML="";
	msgNom.innerHTML="";
	msgTelephone.innerHTML="";
	msgTelecopie.innerHTML="";
	msgMobile.innerHTML="";
	msgCodePost.innerHTML="";
	msgVille.innerHTML="";
	msgMail.innerHTML="";
	msgAdresse.innerHTML ="";
	msgMotPasse.innerHTML ="";
	msgVerif.innerHTML ="";
	msgConfirmMotPasse.innerHTML ="";
	msgErrVerif.innerHTML ="";
	
	//Prenom********************************************
	if(document.forms["maForm_inscription"].form_prenom.value == "")
	{
		msgPre.innerHTML = "veuillez saisir votre prénom";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_inscription"].form_prenom.value) == null)
		{
			msgPre.innerHTML= "prénom incorrect";
			OK = 0;
		
		}
	}
	
	//nom *********************************************************
	if((document.forms["maForm_inscription"].form_nom.value)=="")
	{
		msgNom.innerHTML = "veuillez saisir votre nom de Soci&eacute;t&eacute;";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_inscription"].form_nom.value) == null)
		{
			msgNom.innerHTML= "nom incorrect";
			OK = 0;
		}
	}
	
	//telephone*************************************************************************
	if((document.forms["maForm_inscription"].form_telephone.value)=="")
	{
		msgTelephone.innerHTML = "veuillez saisir votre numéro de telephone";
		OK = 0;
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_telephone.value) == null)
		{
			msgTelephone.innerHTML= "telephone incorrect";
			OK = 0;
		}
	}
//telecopie*********************************************************************************
	if((document.forms["maForm_inscription"].form_telecopie.value)=="")
	{
		
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_telecopie.value) == null)
		{
			msgTelecopie.innerHTML= "telecopie incorrect";
			OK = 0;
		}
	}
//mobile*********************************************************************************
	if((document.forms["maForm_inscription"].form_mobile.value)=="")
	{
		
	}
	else
	{
		if(verifNumerique(document.forms["maForm_inscription"].form_mobile.value) == null)
		{
			msgMobile.innerHTML= "mobile incorrect";
			OK = 0;
		}
	}	
	// adresse**********************************************************************************
	if((document.forms["maForm_inscription"].form_adresse.value)=="")
	{
		msgAdresse.innerHTML = "veuillez saisir votre adresse";
		OK = 0;
	}
	// code postal*******************************************************************************
	if((document.forms["maForm_inscription"].form_postal_code.value)=="")
	{
		msgCodePost.innerHTML = "veuillez saisir un code postal";
		OK = 0;
	}
	else
	{
		if(verifCodePost.exec(document.forms["maForm_inscription"].form_postal_code.value) == null)
		{
			msgCodePost.innerHTML="code postal incorrect";
			OK = 0;
		}
	}
	// ville*********************************************************************************************
	if((document.forms["maForm_inscription"].form_ville.value)=="")
	{
		msgVille.innerHTML = "veuillez saisir une ville";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_inscription"].form_ville.value) == null)
		{
			msgVille.innerHTML="ville incorrecte";
			OK = 0;
		}
	}
	// email***********************************************************************
	if((document.forms["maForm_inscription"].form_mail.value)=="")
	{
		msgMail.innerHTML = "veuillez saisir une adresse email";
		OK = 0;
	}
	else
	{
		if(verifEmail.exec(document.forms["maForm_inscription"].form_mail.value) == null)
		{
			msgMail.innerHTML="e-mail incorrect";
			OK = 0;	
		}
	}
	// login******************************************************************************

	
	// mot de passe***********************************************************************
	if((document.forms["maForm_inscription"].form_password.value)=="")
	{
		msgMotPasse.innerHTML = "veuillez saisir un mot de passe";
		OK = 0;
	}
	else
	{
		if(document.forms["maForm_inscription"].form_password.value.length < 6)
		{
			msgMotPasse.innerHTML = "au moins 6 caractères";
			OK = 0;
		}
	}
	
// confirmation mot de passe************************************************************
	if((document.forms["maForm_inscription"].form_password_confirm.value)=="")
	{
		msgConfirmMotPasse.innerHTML = "veuillez confirmer votre mot de passe";
		OK = 0;
	}
	else
	{
		if(!(document.forms["maForm_inscription"].form_password.value == document.forms["maForm_inscription"].form_password_confirm.value))
		{
			msgConfirmMotPasse.innerHTML = "erreur dans la confirmation du mot de passe";
			//document.forms["maForm_inscription"].form_password_confirm.value = "";
			OK = 0;
		}
	}
	//  **************************************************  image vérification  ****************
	if((document.forms["maForm_inscription"].form_verif.value)=="")
	{
		msgErrVerif.innerHTML = "veuillez saisir le code de vérification";
		OK = 0;
	}
	else
	{
		if(!(document.forms["maForm_inscription"].form_verif.value == document.forms["maForm_inscription"].form_valeur_verif.value))
		{
			msgErrVerif.innerHTML = "erreur dans  l'image  de vérification ";
			//document.forms["maForm_inscription"].form_password_confirm.value = "";
			OK = 0;
		}
	}
	
	if (OK == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}

	//***************************************************fab

function controleModifInscription()
{
	var verifLettres = /^[a-zA-Z0-9' -]*$/ ;
	var verifEmail = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$/ ;
	var verifCodePost = /^[0-9]{5}$/;
	var msgPre = document.getElementById("ErrPre");
	var msgNom = document.getElementById("ErrNom");
	var msgCodePost = document.getElementById("ErrCodePost");
	var msgVille = document.getElementById("ErrVille");
	var msgMail = document.getElementById("ErrMail");
	var msgAdresse = document.getElementById("ErrAdresse");
	//var msgMotPasse = document.getElementById("ErrMotPasse");
	//var msgConfirmMotPasse = document.getElementById("ErrConfirmMotPasse");
	var OK = 1 ;
	msgPre.innerHTML="";
	msgNom.innerHTML="";
	msgCodePost.innerHTML="";
	msgVille.innerHTML="";
	msgMail.innerHTML="";
	msgAdresse.innerHTML ="";

	//nom*********************************************************************************
	if((document.forms["maForm_modification"].form_nom.value)=="")
	{
		msgNom.innerHTML = "veuillez saisir votre nom";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_modification"].form_nom.value) == null)
		{
			msgNom.innerHTML= "nom incorrect";
			OK = 0;
		}
	}
	// date de naissance **************************************************************************
	
	// adresse**********************************************************************************
	if((document.forms["maForm_modification"].form_adresse.value)=="")
	{
		msgAdresse.innerHTML = "veuillez saisir votre adresse";
		OK = 0;
	}
	// code postal*******************************************************************************
	if((document.forms["maForm_modification"].form_postal_code.value)=="")
	{
		msgCodePost.innerHTML = "veuillez saisir un code postal";
		OK = 0;
	}
	else
	{
		if(verifCodePost.exec(document.forms["maForm_modification"].form_postal_code.value) == null)
		{
			msgCodePost.innerHTML="code postal incorrect";
			OK = 0;
		}
	}
	// ville*********************************************************************************************
	if((document.forms["maForm_modification"].form_ville.value)=="")
	{
		msgVille.innerHTML = "veuillez saisir une ville";
		OK = 0;
	}
	else
	{
		if(verifLettres.exec(document.forms["maForm_modification"].form_ville.value) == null)
		{
			msgVille.innerHTML="ville incorrecte";
			OK = 0;
		}
	}
	// email***********************************************************************
	if((document.forms["maForm_modification"].form_mail.value)=="")
	{
		msgMail.innerHTML = "veuillez saisir une adresse email";
		OK = 0;
	}
	else
	{
		if(verifEmail.exec(document.forms["maForm_modification"].form_mail.value) == null)
		{
			msgMail.innerHTML="e-mail incorrect";
			OK = 0;	
		}
	}
	// login******************************************************************************

	
	// mot de passe***********************************************************************
	//if((document.forms["maForm_modification"].form_password.value)=="")
//	{
//		msgMotPasse.innerHTML = "ancien mot de passe conservé";
//		//OK = 0;
//	}
//	else
//	{
//		if(document.forms["maForm_modification"].form_password.value.length < 6)
//		{
//			msgMotPasse.innerHTML = "au moins 6 caractères";
//			OK = 0;
//		}
//	}
//	if(!(document.forms["maForm_inscription"].form_password.value == document.forms["maForm_inscription"].form_password_confirm.value))
//	// confirmation mot de passe************************************************************
//	if((!(document.forms["maForm_modification"].form_password.value=="")&&(document.forms["maForm_modification"].form_password_confirm.value)==""))
//	{
//		msgConfirmMotPasse.innerHTML = "veuillez confirmer votre nouveau mot de passe";
//		OK = 0;
//	}
//	else
//	{
//		if(document.forms["maForm_modification"].form_password.value != document.forms["maForm_modification"].form_password_confirm.value)
//		{
//			msgConfirmMotPasse.innerHTML = "erreur dans la confirmation du nouveau mot de passe";
//			//document.forms["maForm_inscription"].form_password_confirm.value = "";
//			OK = 0;
//		}
//	}
	//var errNumCompte = document.getElementById("errNumCompte");
//	errNumCompte.innerHTML="";
//
//	if(document.forms["maForm_modification"].numCompte.value == "")
//	{
//		errNumCompte.innerHTML = "veuillez saisir votre numero de compte";
//		OK = 0;
//	}
	
	if (OK == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}	
function normalizePrix(prix)
{
	prix = prix + "";
	var posPoint = prix.indexOf(".");
	if (posPoint == -1)
	{
		prix += ".00&nbsp;"
		return prix;
	}
	var strFrancs = prix.substring(0, posPoint);
	var strCentime = prix.substring(posPoint + 1);
	while (strCentime.length < 2) strCentime += "0";
	strCentime = strCentime.substring(0, 2);
	return strFrancs + "." + strCentime + "&nbsp;";
}

function changeArticle()
{
	var tabComd = document.getElementById("tabComd");
	var total = 0.0;
	for (var iRow = 1; iRow < tabComd.rows.length - 1; iRow++)
	{
		var row = tabComd.rows[iRow];
		var elQuantite = row.cells[1].firstChild;
		var elPrixU = row.cells[2].firstChild;
		var elPrixT = row.cells[3].firstChild;
		total += elPrixU.value * elQuantite.value;
		elPrixT.innerHTML = normalizePrix(elPrixU.value * elQuantite.value);
	}
	var elTotal = document.getElementById("total");
	elTotal.innerHTML = normalizePrix(total);
}

function newArticle(art)
{
	var tabComd = document.getElementById("tabComd");
	var nRows = tabComd.rows.length - 1;
	var newRow = tabComd.insertRow(nRows);
	newRow.insertCell(0);
	newRow.insertCell(1);
	newRow.insertCell(2);
	newRow.insertCell(3);
	newRow.cells[0].innerHTML=art;
	newRow.cells[1].innerHTML="<input name='quantite' style='width:100%' onChange='changeArticle()'>";
	newRow.cells[2].innerHTML="<input name='prixu' style='width:100%' onChange='changeArticle()'>";
	newRow.cells[3].innerHTML="<span name='prixt'>0.00&nbsp;</span>";
	newRow.cells[3].style.textAlign="right";
}

function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}