// JavaScript Document
unique = 0;
function valider(theForm)
{
	if (unique==1)
	{
		// double click
		return (false);
	}
	
	// pseudo
	if (theForm.pseudo.value.length < 4)
	{
		alert("Champ utilisateur 4 caractères min.");
		theForm.pseudo.select();
		theForm.pseudo.focus();
		return (false);
	}
	
	// email
	var lemail = theForm.email.value;
	var regexp  = /^[A-Za-z0-9_-]+([\.][A-Za-z0-9_-]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/;
	flag = regexp.test(lemail);
	if (!flag) 
	{
		alert("Adresse mail erronée\nCorriger SVP.");
		theForm.email.select();
		theForm.email.focus();
		return (false);
	}
	
	// pwd
	if (theForm.pwd.value.length < 6)
	{
		alert("Champ mot de passe 6 caractères min.");
		theForm.pwd.select();
		theForm.pwd.focus();
		return (false);
	}
	
	// confirmation pwd
	if (theForm.confirmation_mot_de_passe.value.length < 6)
	{
		alert("Champ confirmation mot de passe 6 caractères min.");
		theForm.confirmation_mot_de_passe.select();
		theForm.confirmation_mot_de_passe.focus();
		return (false);
	}
	
	if (theForm.pseudo.value == theForm.pwd.value)
	{
		alert("La valeur \"Utilisateur\" doit être différente de \"Mot de passe\".");
		theForm.pseudo.select();
		theForm.pseudo.focus();
		return (false);
	}
	
	
	// prenom
	if (theForm.prenom.value.length < 2)
	{
		alert("Champ Prénom obligatoire.");
		theForm.prenom.select();
		theForm.prenom.focus();
		return (false);
	}
	
	
	// nom
	if (theForm.nom.value.length < 2)
	{
		alert("Champ Nom obligatoire.");
		theForm.nom.select();
		theForm.nom.focus();
		return (false);
	}
	
	// CP
	if (theForm.code_postal.value.length < 2)
	{
		alert("Champ Code Postal obligatoire.");
		theForm.code_postal.select();
		theForm.code_postal.focus();
		return (false);
	}
	
	
	// ville
	if (theForm.ville.value.length < 2)
	{
		alert("Champ Ville obligatoire.");
		theForm.ville.select();
		theForm.ville.focus();
		return (false);
	}
		
	unique = 1; 
	return (true);
}
