function testAdrMail(adrMail) {
// d�claration et initialisation des variables
adrMailLength=adrMail.length; // longueur de la cha�ne adrMail
caractOk="_.-0123456789abcdefghijklmnopqrstuvwxyz"; // carat�res corect d'une adresse mail
var posArrobas=adrMail.indexOf('@',1); // position du premier Arrobas
var posPoint=adrMail.lastIndexOf('.',adrMailLength); // position du dernier point
var posCaractFaux=adrMail.indexOf('..',posArrobas+1); // position d'un caract�re faux ('..' ou ' ')
var caract=0; // caract�re extrait de la cha�ne adrMail (utilis�e par les boucles while)
var caractFaux=adrMail.charAt(0)+adrMail.charAt(posArrobas-1)+adrMail.charAt(posArrobas+1)+adrMail.charAt(posPoint-1);
var posCaract=0; // position du caract�re � extraire de la cha�ne adrMail (utilis�e par les boucles while)
var posCaractOk=0; // position du caract�re extrait de la cha�ne adrMail (utilis�e par les boucles while)
var posCaractNon=-1;
var retour=false; // l'adresse e-mail est consid�r�e comme fausse au d�but
// d�but du teste
// s'il n'existe pas de caract�re '..' alors on teste s'il existe un espace dans la cha�ne adrMail
if (posCaractFaux!=-1 || adrMail.indexOf(' ',0)!=-1 || adrMail.indexOf('--',0)!=-1 || adrMail.indexOf('__',0)!=-1) {
posCaractFaux=0;
}
// Teste les points ou - ou _ au d�but de l'adrMail, autour de l'arrobas et autour du dernier point
for (posCaract;posCaract<4;posCaract++) {
caract=caractFaux.charAt(posCaract);
posCaractNon=caractOk.lastIndexOf(caract,2);
if (posCaractNon!=-1) {
posCaractFaux=0;
break;
}
}
// si l'adresse mail contient au moins 1 caract�re et qu'elle comporte un arrobas
// et qu'elle comporte un point et que l'arrobas est avant le dernier point
// et qu'elle ne contient pas de '..' ou d'espace et que apr�s le dernier point il y est 2,3 ou 4 caract�res
// et qu'il n'y est pas de point autour de l'arrobas et que l'adresse ne commence pas par un point
// Alors
if (adrMailLength>0 && posArrobas!=-1 && posPoint!=-1 && posArrobas<posPoint && posCaractFaux==-1 && adrMailLength-posPoint-1>=2 && adrMailLength-posPoint-1<=4) {
// extraction d'un caract�re et teste s'il existe dans la cha�ne "_.-0123456789abcdefghijklmnopqrstuvwxyz"
// S'il n'existe pas alors posCaract=-1 donc au prochain 'tour' on passe aux autres boucles (qui ne s'effecturont pas)
// Si il existe on continue la boucle jusqu'au caract�re avant l'arrobas et on passe � la boucle while suivante
adrMail=adrMail.toLowerCase();
posCaract=0;
while (posCaract<posArrobas && posCaractOk!=-1) {
caract=adrMail.charAt(posCaract);
posCaractOk=caractOk.indexOf(caract,0);
posCaract++;
}
posCaract++; // on passe l'arrobas
// sur le m�me principe qu'au dessus mais pour la partie entre l'arrobas et le dernier point
// le test ce fait sur les caract�res ".-0123456789abcdefghijklmnopqrstuvwxyz"
// caractOk.indexOf(caract,1) on ne teste plus l'underscore
while (posCaract<posPoint && posCaractOk!=-1) {
caract=adrMail.charAt(posCaract);
posCaractOk=caractOk.indexOf(caract,1);
posCaract++;
}
posCaract++; // on passe le point
// sur le m�me principe qu'au dessus mais pour la partie entre le dernier point et la fin
// le test ce fait sur les caract�res "abcdefghijklmnopqrstuvwxyz"
// caractOk.indexOf(caract,13) on ne teste plus que des lettres
while (posCaract<adrMailLength && posCaractOk!=-1) {
caract=adrMail.charAt(posCaract);
posCaractOk=caractOk.indexOf(caract,13);
posCaract++;
} // fin de la boucle while
// durant le parcour de l'adresse mail si n'y avait pas de caract�re interdit
// posCaractOk a changer plusieurs fois de valeur mais na jamais eu la valeur -1
// donc l'adresse est bonne
if (posCaractOk!=-1) {
retour=true;
}
}
return retour; // renvoi le r�sultat (true ou false)
} // fin de la fonction


var Url = {

// public method for url encoding
encode : function (string) {
return escape(this._utf8_encode(string));
},

// public method for url decoding
decode : function (string) {
return this._utf8_decode(unescape(string));
},

// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";

for (var n = 0; n < string.length; n++) {

var c = string.charCodeAt(n);

if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}

}

return utftext;
},

// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;

while ( i < utftext.length ) {

c = utftext.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}

}