function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
	
function emailCheck (emailStr) 
{
	var myAtSymbolAt = emailStr.indexOf('@');
	var myLastDotAt = emailStr.lastIndexOf('.');
	var mySpaceAt = emailStr.indexOf(' ');
	var myLength = emailStr.length;
	
	if (myAtSymbolAt < 1 ) {
		return false;
	}
	
	
	if (myLastDotAt < myAtSymbolAt) {
		return false;
	}
	
	if (myLength - myLastDotAt <= 2) {
		return false;
	}
	
	if (mySpaceAt != -1) {
		return false;
	}
	
	return true;
}

function valid()
{
	/*
	if (trim(document.f1.nom.value)=='')
	{
		alert("Nom obligatoire");
		document.f1.nom.focus();
		return;
	}
	
	if (trim(document.f1.prenom.value)=='')
	{
		alert("Prénom obligatoire");
		document.f1.prenom.focus();
		return;
	}
	
	if (trim(document.f1.adresse.value)=='')
	{
		alert("Adresse obligatoire");
		document.f1.adresse.focus();
		return;
	}
	
	if (trim(document.f1.cpostal.value)=='')
	{
		alert("Code postal obligatoire");
		document.f1.cpostal.focus();
		return;
	}
	
	if (trim(document.f1.ville.value)=='')
	{
		alert("Ville obligatoire");
		document.f1.ville.focus();
		return;
	}
	
	if (!emailCheck(document.f1.mail.value))
	{
		alert("Adresse mail obligaire");
		document.f1.mail.focus();
		return;
	}
	*/
	var login= trim(document.f1.login.value);
	var l= login.length;
	if (l<6 || l>10)
	{
		alert("L'identifiant doit être composé de 6 à 10 caractères");
		document.f1.identifiant.focus();
		return;
	}
	
	var password= trim(document.f1.password.value);
	if (password.length<6 || password.length>10)
	{
		alert("Le mot de passe doit être composé de 6 à 10 caractères");
		document.f1.password.focus();
		return;
	}
	
	if (trim(document.f1.password2.value)!=password)
	{
		alert("Les 2 mots de passe ne correspondent pas");
		document.f1.password.focus();
		return;
	}
	
	document.f1.submit();
}
