function validateEmail(addr,man,db) {
if (addr == '' && man) {
//   if (db) alert('Adresse e-mail obligatoire');
	document.getElementById('errorEmail').style.visibility="visible";
   	document.getElementById('errorEmail').style.display="inline";
   	document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.padding="3px";
	document.getElementById('errorEmail').style.color="#ffffff";
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('Adresse e-mail contient des caracteres invalides');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("Adresse e-mail contient des caracteres invalides");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }
   //alert('Adresse e-mail doit avoir un @');
   return false;
}
if (atPos == 0) {
//   if (db) alert('Adresse e-mail ne doit pas commencer par @');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
//   if (db) alert('Adresse e-mail doit avoir un seul @');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
if (addr.indexOf('.', atPos) == -1) {
//   if (db) alert('Adresse e-mail manquant un . pour le nom du domaine');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
if (addr.indexOf('@.',0) != -1) {
//   if (db) alert('Un . ne doit pas être à côté du @');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
if (addr.indexOf('.@',0) != -1){
//   if (db) alert('Un . ne doit pas être à côté du @');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
if (addr.indexOf('..',0) != -1) {
//   if (db) alert('Deux . ne doit pas être à côté du @');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
document.getElementById('inEmail').style.padding="3px";
//document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
//   if (db) alert('Nom de domaine invalide');
   if (db) 
   {
   document.getElementById('errorEmail').style.visibility="visible";
   document.getElementById('errorEmail').style.display="inline";
//   document.getElementById('inEmail').style.background="#9d0f0f";
	document.getElementById('inEmail').style.padding="3px";
//	document.getElementById('inEmail').style.color="#ffffff";
document.getElementById('errorEmail').style.background="#9d0f0f";
	document.getElementById('errorEmail').style.color="#ffffff";
	document.getElementById('errorEmail').style.padding="3px";
   }

   return false;
}
document.getElementById('errorEmail').style.visibility="hidden";
   document.getElementById('inEmail').style.background="#FFFFFF";
return true;
}

function isNumeric(str,id) {

	if (isNaN(str/1) || str.length==0 || str==null )
	{
		document.getElementById(id).style.visibility="visible";
	    document.getElementById(id).style.display="inline";
   		document.getElementById(id).style.background="#9d0f0f";
		document.getElementById(id).style.padding="3px";
		document.getElementById(id).style.color="#ffffff";
		return false;
	}
	else if (str/1 < 0){//test sur les negatifs
		document.getElementById(id).style.visibility="visible";
	    document.getElementById(id).style.display="inline";
   		document.getElementById(id).style.background="#9d0f0f";
		document.getElementById(id).style.padding="3px";
		document.getElementById(id).style.color="#ffffff";
		return false;
	}
	{
	   	document.getElementById(id).style.visibility="hidden";
	    document.getElementById(id).style.display="none";
   		document.getElementById(id).style.background="#9d0f0f";
		document.getElementById(id).style.padding="3px";
		document.getElementById(id).style.color="#ffffff";
		return true;		
	}
//return str.length ? !isNaN(str/1) : true //--- or false
}

function isEmpty(str,id)
{
	if ((str.length==0) || (str==null))
	{
		  document.getElementById(id).style.visibility="visible";
	    document.getElementById(id).style.display="inline";
   		document.getElementById(id).style.background="#9d0f0f";
    	document.getElementById(id).style.padding="3px";
    	document.getElementById(id).style.color="#ffffff";
		  return true;
	}
	else 
	{   
    document.getElementById(id).style.visibility="hidden";
    document.getElementById(id).style.display="none";
    document.getElementById(id).style.background="#9d0f0f";
    document.getElementById(id).style.padding="3px";
    document.getElementById(id).style.color="#ffffff";
		return false;
	}
}
