/*************************************************************/
/* Suppression des caractères blancs avant et après          */
/*************************************************************/

function trim (motsel) 
{ 
	if (!motsel || motsel.length==0) 
		return "" 
	for (var i=0; i<motsel.length; i++)
	{
		if (motsel.charAt(i) != " ") 
		{
			motsel = motsel.substr(i); 
			break
		}
	} 

	for (var j=motsel.length-1; j>0; j--) 
	{
		if (motsel.charAt(j) != " ")
		{
			motsel = motsel.substring(0,j+1);
			break
		}
	} 
	return motsel.charAt(0)==" "?"":motsel 
} 

function verifie_chaine(chaine,del_espaces)
{
	//test si on doit supprimer les espaces sur le champ
	if (del_espaces)
		chaine.value = trim(chaine.value); 
	
	if (chaine.value.length > 0)
		return true;		
	else
		return false;
}

/*************************************************************/
/* Validation du champ email 			             */
/*************************************************************/
function verifie_email(monmail)
{
	monmail.value = trim(monmail.value);
	var mail = String(monmail.value);
	var emailDomain = /^[\w_\-\.]+@[\w_\-\.]+\.[a-zA-Z]{2,3}$/
	var emailIP = /^[\w_\-\.]+@\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/

	if ((emailDomain.test(mail)) || (emailIP.test(mail)))
	{
		return true;
	}
	else
	{
		window.alert("Adresse email incorrecte !");
		monmail.focus();
		return false;
	}
}

