<!--
//---------------------------------------------------------------------||
// FUNCTION:    isEmail					                               ||
// PARAMETERS:  email			--> email à vérifier			       ||
// RETURNS:     emailValidity	--> bit de retour (true/false)		   ||
// PURPOSE:     Vérifie email (a@aa.aa) (true si ok, false sinon)	   ||
// MORE:		email de la forme (A@aa.aa) refusé ! (A résoudre)	   ||
//---------------------------------------------------------------------||
function isEmail(email)
{
	//------ définition de l'expression régulière d'un email      
    var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/ ;
    
    //------ retourne true or false
    return (reg.exec(email)!= null)
}

//----------------------------------------------------------||
// FUNCTION:    isEmail2									||
// PARAMETERS:  str	--> email à vérifier					||
// RETURNS:     --> bit de retour (true/false)				||
// PURPOSE:     Vérifie email  (true si ok, false sinon)	||
// MORE:		BEST OF SCRIPT								||
//----------------------------------------------------------||
function isEmail2(str) 
{
	// are regular expressions supported?
	var supported = 0;
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  
	if ((!r1.test(str) && r2.test(str))) return true ;
	return false;	
}

//--------------------------------------------------------------------||
// FUNCTION:    Trim					                              ||
// PARAMETERS:  str			--> string							      ||
// RETURNS:     strFormated	--> string sans espacement				  ||
// PURPOSE:     Supprime les espaces dans une chaine				  ||
//--------------------------------------------------------------------||
function Trim(string)
{
	//------ récupération de la chaine
	var str = String(string);

    //------ suppression des espaces en début de chaine
    while (str.substring(0,1) == ' ')
        str = str.substring(1, str.length);

    //------ suppression des espaces en fin de chaine
    while (str.substring(str.length-1, str.length) == ' ')
        str = str.substring(0, str.length-1);
	
	//------ retour de la chaine formatée
	return str ;
}


//----------------------------------------------------------||
// FUNCTION:    decodeUrl				                    ||
// PARAMETERS:  string	--> string							||
// RETURNS:     str		--> string sans espacement			||
// PURPOSE:     Decode 1 chaine pour etre affichée			||
//----------------------------------------------------------||
function decodeUrl(string)
{
	//------ récupération de la chaine
	var str = String(string);
	
    var test = -1 ;
	
	do
	{
		test	= str.indexOf("@") ;
		str		= str.replace("@", "'") ;	
	}
	while (test != -1) ;	
	
	do
	{
		test	= str.indexOf("*") ;
		str		= str.replace("*", " ") ;
	}
	while (test != -1) ;
	
	return str ;
}


//------------------------------------------------------------------||
// FUNCTION:    encodeUrl				                            ||
// PARAMETERS:  string	--> string									||
// RETURNS:     str		--> string sans espacement					||
// PURPOSE:     Code la chaine pour qu'elle puisse etre ds un url	||
//------------------------------------------------------------------||
function encodeUrl(string)
{
	//------ récupération de la chaine
	var str = String(string);
	//------ appel de Trim
	str = Trim(str) ;
	
    var test = -1 ;
	//------ boucle pour virer les "'"
	do
	{
		test	= str.indexOf("'") ;
		str		= str.replace("'", "@") ;	
	}
	while (test != -1) ;	
	//------ boucle pour virer les " "
	do
	{
		test	= str.indexOf(" ") ;
		str		= str.replace(" ", "*") ;
	}
	while (test != -1) ;
	
	return str ;
}
//-->
