function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   // a rajouter si on veut supprimer des espaces intérieurs à la chaine
   //var obj = /  /g;  
   //while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}

function CheckForm () {

        //Initialise variables
        var errorMsg = "";
        var errorMsgLong = "";

        
	if (document.identification.login.value =="")
	{
		errorMsg +="\n- Votre email\t:  Renseigner une adresse\t";
		}
		
		
	if (document.identification.login.value !="")
	{
	testm = false ;
	var string1=document.identification.login.value;
	string1 = trim(string1);
	
	for (var j=1 ; j<(string1.length) ; j++) {
			if (string1.charAt(j)=='@') { 
				if (j<(string1.length-4)){ 
					for (var k=j ; k<(string1.length-2) ; k++) { 
				if (string1.charAt(k)=='.') testm = true; 
			} 
			} 
			} 
			} 
	
	
 	 if ((string1.indexOf("@")==-1) || (string1.length < 8) || (string1.indexOf(".")==-1) || (string1.indexOf(" ")  != -1) || (string1.indexOf("www")  != -1) || (string1.indexOf("http")  != -1) || (testm==false))
  	{
  	     
	errorMsg +="\n\- Votre email\t:  Entrer une adresse email valide\t";
	document.identification.login.focus();
		
		}
		}
        //1er password
        if (document.identification.password.value.length <= 5){
                errorMsg += "\n\- Mot de passe \t:  6 caractères minimum\t";
        }

      

  	    //souci
        if ((errorMsg != "")){
                msg = "__________________________________\n\n";
                msg += "Merci de corriger les erreurs ci-dessous\net de soumettre à nouveau le formulaire.\n";
                msg += "__________________________________\n\n";
                
                errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
                return false;
        }

      return true;
}
