// FICHIER DE VERIFICATION
var mail=1;
function checkContact(theId){
	if(theId=="contact1"){
		document.getElementById("contact1").checked=true;
		document.getElementById("contact2").checked=false;
		document.getElementById("contact3").checked=false;
		document.getElementById("contact4").checked=true;
		document.getElementById('horaire').disabled=true;
		mail=1;
	}
	if(theId=="contact2"){
		document.getElementById("contact1").checked=false;
		document.getElementById("contact2").checked=true;
		document.getElementById("contact3").checked=true;
		document.getElementById("contact4").checked=false;
		document.getElementById('horaire').disabled=false;
		mail=0;
	}
	if(theId=="contact3"){
		document.getElementById("contact1").checked=false;
		document.getElementById("contact2").checked=true;
		document.getElementById("contact3").checked=true;
		document.getElementById("contact4").checked=false;
		document.getElementById('horaire').disabled=false;
		mail=0;
	}
	if(theId=="contact4"){
		document.getElementById("contact1").checked=true;
		document.getElementById("contact2").checked=false;
		document.getElementById("contact3").checked=false;
		document.getElementById("contact4").checked=true;
		document.getElementById('horaire').disabled=true;
		mail=1;
	}
}
function verifMail(){
	
	longueur = document.theContact.Mail.value.length;
	position = document.theContact.Mail.value.indexOf("@");
	left_str = document.theContact.Mail.value.substring(0,position);
	right_str = document.theContact.Mail.value.substring(position+1,longueur);
	left_len = left_str.length;
	right_len = right_str.length;
	
	right_longueur = right_str.length;
	right_position = right_str.lastIndexOf(".");
	l_right_str = right_str.substring(0,right_position);
	r_right_str = right_str.substring(right_position+1,right_longueur);
	l_right_len = l_right_str.length;
	r_right_len = r_right_str.length;	
	
	if (document.theContact.nom.value=="")
	{
		alert("Votre nom n\'est pas renseigné\n");
		document.theContact.nom.focus();
		return false;
		
	}	
	
	if (document.theContact.Mail.value.indexOf("@")==-1)
	{
		alert("Votre adresse Mail est incorrecte\n");
		document.theContact.Mail.focus();
		return false;
		
	}
	<!--- si la valeur gauche ou droite du @ est vide --->
	if ((left_len==0) || (right_len==0))
	{
		alert("Votre adresse Mail est incorrecte\n");
		document.theContact.Mail.focus();
		return false;
	}
	<!--- s'il n'y a pas de point --->
	if (right_str.indexOf(".")==-1)
	{
		alert("Votre adresse Mail est incorrecte\n");
		document.theContact.Mail.focus();
		return false;
	}
	<!--- s'il y a au moins 2 lettres après le point --->
	if ((r_right_len < 2)||(r_right_len > 4))
	{
		alert("Votre adresse Mail est incorrecte\n");
		document.theContact.Mail.focus();
		return false;
	}
	<!--- s'il y a au moins 1 lettre après le point --->
	if (l_right_len==0)
	{
		alert("Votre adresse Mail est incorrecte\n");
		document.theContact.Mail.focus();
		return false;
	}
	return true;
}
function verifWeb(){
		
	if (document.formWeb.nom.value=="")
	{
		alert("Votre nom n\'est pas renseigné\n");
		document.formWeb.nom.focus();
		return false;
		
	}	
	if(mail == 1){
		longueur = document.formWeb.Mail.value.length;
		position = document.formWeb.Mail.value.indexOf("@");
		left_str = document.formWeb.Mail.value.substring(0,position);
		right_str = document.formWeb.Mail.value.substring(position+1,longueur);
		left_len = left_str.length;
		right_len = right_str.length;
		
		right_longueur = right_str.length;
		right_position = right_str.lastIndexOf(".");
		l_right_str = right_str.substring(0,right_position);
		r_right_str = right_str.substring(right_position+1,right_longueur);
		l_right_len = l_right_str.length;
		r_right_len = r_right_str.length;	
		
		if (document.formWeb.Mail.value.indexOf("@")==-1)
		{
			alert("Votre adresse Mail est incorrecte\n");
			document.formWeb.Mail.focus();
			return false;
			
		}
		<!--- si la valeur gauche ou droite du @ est vide --->
		if ((left_len==0) || (right_len==0))
		{
			alert("Votre adresse Mail est incorrecte\n");
			document.formWeb.Mail.focus();
			return false;
		}
		<!--- s'il n'y a pas de point --->
		if (right_str.indexOf(".")==-1)
		{
			alert("Votre adresse Mail est incorrecte\n");
			document.formWeb.Mail.focus();
			return false;
		}
		<!--- s'il y a au moins 2 lettres après le point --->
		if ((r_right_len < 2)||(r_right_len > 4))
		{
			alert("Votre adresse Mail est incorrecte\n");
			document.formWeb.Mail.focus();
			return false;
		}
		<!--- s'il y a au moins 1 lettre après le point --->
		if (l_right_len==0)
		{
			alert("Votre adresse Mail est incorrecte\n");
			document.formWeb.Mail.focus();
			return false;
		}
		return true;
	}else{
//VERIF DES CHAMPS PORTABLE ET TELEPHONE
		if ((document.formWeb.telephone.value=="")&&(document.formWeb.portable.value==""))
		{
			alert("Votre numéro de téléphone ou de\n portable doit être renseigné !");
			document.formWeb.telephone.focus();
			return false;
		}
/////////////////////////////////////////

//VERIF DES VALEUR DE TELEPHONE
		if (document.formWeb.telephone.value!="")
		{
			if(isNaN(document.formWeb.telephone.value) == true){
				alert("Votre téléphone doit être\n un nombre à 10 chiffres");
				document.formWeb.telephone.focus();
				return false;
			}
			if(document.formWeb.telephone.value.length < 10){
				alert("Votre téléphone doit être\n un nombre à 10 chiffres");
				document.formWeb.telephone.focus();
				return false;
			}				
		}
////////////////////////////////


//VERIF DES VALEUR DE PORTABLE
		if (document.formWeb.portable.value!="")
		{
			if(isNaN(document.formWeb.portable.value) == true){
				alert("Votre portable doit être\n un nombre à 10 chiffres");
				document.formWeb.portable.focus();
				return false;
			}
			if(document.formWeb.portable.value.length < 10){
				alert("Votre portable doit être\n un nombre à 10 chiffres");
				document.formWeb.portable.focus();
				return false;
			}				
		}
////////////////////////////////

		return true;		
	}
}
