// JavaScript Document pour le contrôle des champs de la table contact
  function valider_form(theForm) 
  {  
		// recuperer pVille2
		/*cp = document.getElementById('cp').value
		if (cp)
		{
			ville2 = document.getElementById('ville2').value
			ville = document.getElementById('pVille').value
			if (ville2 && ville == "") 
			{
				document.getElementById('pVille').value = ville2;
			}
		}
		*/
		if (theForm.nom.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.nom.focus();
			return false;
		}
		if (theForm.prenom.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.prenom.focus();
			return false;
		}
		if (theForm.email.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.email.focus();
			return false;
		}
		if (!isValidMail(theForm.email.value))
		{
			alert("E-Mail invalide  !\n\nL'e-mail doit comporter au moins 6 caractères dont @ et .");
			theForm.email.focus();
			return false;
		}
		// Tel numerique
		if (theForm.telephone.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.telephone.focus();
			return false;
		}
		
		//Pays 
		if (theForm.pays.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.pays.focus();
			return false;
						}
		
		if(!isPhoneNumber(theForm.telephone.value))
		{
			alert("Format de téléphone est incorrecte!");
			theForm.telephone.focus();
			return false;
		}
	
		if (theForm.cp.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.cp.focus();
			return false;
		}
		
		if (theForm.cp.value.length >0 && theForm.cp.value.length != 5 && document.getElementById("pays").value=="FR")
		{
			alert("Le code postal doit être sur 5 chiffres !");
			theForm.cp.focus();
			return false;
		}

			// CP numerique
		if ( !isNumeric(theForm.cp.value) && document.getElementById("pays").value=="FR")
		{
			alert("Format numérique invalide !");
			theForm.cp.focus();
			return false;
		}
		// cp doit être de 5 chiffres
		//if (theForm.cp.value.length >0 && theForm.cp.value.length != 5)
//		{
//			alert("Le code postal doit être sur 5 chiffres !");
//			theForm.cp.focus();
//			return false;
//		}
		
		if (theForm.pVille.value.length == 0)
		{
			alert("Veuillez sélectionnez une ville !");
			return false;
		}
		
		if (theForm.adresse.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.adresse.focus();
			return false;
		}
		if (theForm.message.value.length == 0)
		{
			alert("Les champs marqué * sont obligatoires !");
			theForm.message.focus();
			return false;
		}
		
     
	
    return true;
  }