/*LIEN DANS LA PAGE CONTACTS_TEMOIGN.HTML : <script language="JavaScript" src="../Javascript/VeriFormTemoign.js"></script>*/

//FONCTION SPECIALE DE VERIFICATION DE L'EMAIL
function ValideEmail(theForm)
{

var mail=false;
var a=theForm.T_interloc_mail.value ;

		//Ouverture d'une boucle for à 1 qui permettra de tester du premier jusqu'au dernier caractère de l'adresse e-mail entrée.
		for (var j=1 ; j<(a.length) ; j++) 
		{
			
			//Recherche du @
			if (a.charAt(j)=='@') 
			{							
				
				//Recherche de 4 caractères minimum après le @
				if (j<(a.length-4))
				{
				
					//Seconde boucle pour vérifier s'il y a un point au moins deux lettres avant la fin
					for (var k=j ; k<(a.length-2) ; k++) 
					{
						if (a.charAt(k)=='.')	
						{
							mail = true;
						}									
					}
				}			
			}
		}
return mail;
}

// FONCTION DE VERIFICATION DES CHAMPS OBLIGATOIRES
function VeriFormTemoign(theForm)
{
	 
	//Nom de l'interlocuteur
	if ( theForm.T_interloc_nom.value == "" ) { alert ( "Nom de l'interlocuteur obligatoire." ); theForm.T_interloc_nom.focus (); return ( false ); }	 

	//Ville
	if ( theForm.T_struct_adress.value == "" ) { alert ( "Ville obligatoire." ); theForm.T_struct_adress.focus (); return ( false ); }
	 
	//Département
	if ( theForm.T_struct_dept.value == "" ) { alert ( "Numéro du département obligatoire." ); theForm.T_struct_dept.focus (); return ( false ); }
 	
	//Email
	if ( theForm.T_interloc_mail.value == "" || !ValideEmail(theForm)) { alert ( "Adresse mail vide ou non valide.\nVeuillez vérifier ce champ." ); theForm.T_interloc_mail.focus (); return ( false ); }	 
}


