// 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("Fields with an * are mandatory");
			theForm.nom.focus();
			return false;
		}
		if (theForm.prenom.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.prenom.focus();
			return false;
		}
		if (theForm.email.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.email.focus();
			return false;
		}
		if (!isValidMail(theForm.email.value))
		{
			alert("Invalid email");
			theForm.email.focus();
			return false;
		}
		// Tel numerique
		if (theForm.telephone.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.telephone.focus();
			return false;
		}
		
		if(!isPhoneNumber(theForm.telephone.value))
		{
			alert("Invalid phone number");
			theForm.telephone.focus();
			return false;
		}
		
		if (theForm.adresse.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.adresse.focus();
			return false;
		}
		
		if (theForm.cp.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.cp.focus();
			return false;
		}
		
		if (theForm.ville.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.ville.focus();
			return false;
		}		
		
		if (theForm.message.value.length == 0)
		{
			alert("Fields with an * are mandatory");
			theForm.message.focus();
			return false;
		}
	
    return true;
  }