function validateFormOnSubmit(theForm) {
var reason = "";

  reason += validateEmail(theForm.EMAIL);
  reason += validatePassword(theForm.PASSWORD);
      
  if (reason != "") {
    alert("Plusieurs champs ont besoin d'etre corrige :\n" + reason);
    return false;
  }

  return true;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var EMAILFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = '#0099cc';
        error = "Vous n'avez pas rempli votre adresse email.\n";
    } else if (!EMAILFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#0099cc';
        error = "Merci de rentrer un email valide.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#0099cc';
        error = "Cet email contient des caractères non valides.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#0099cc';
        error = "Vous n'avez pas rempli votre mot de passe.\n";
	} else if ((fld.value.length < 1) || (fld.value.length > 15)) {
        error = "Votre mot de passe doit contenir entre 1 et 15 caractères. \n";
		 fld.style.background = '#0099cc';
    } else if (illegalChars.test(fld.value)) {
        error = "Votre mot de passe ne doit être composé que de chiffres et de lettres.\n";
        fld.style.background = '#0099cc';
    } else {
        fld.style.background = 'White';
    }
   return error;
	}
function validateFormOnSubmit2(theForm) {
var reason = "";

  reason += validateEmail(theForm.EMAIL);
  reason += validatePasswordCompte(theForm.PASSWORD);
      
  if (reason != "") {
    alert("Plusieurs champs ont besoin d'etre corrige :\n" + reason);
    return false;
  }

  return true;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validatePasswordCompte(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = '#0099cc';
        error = "Vous n'avez pas rempli votre mot de passe.\n";
	} else if ((fld.value.length < 1) || (fld.value.length > 100)) {
        error = "Votre mot de passe doit contenir entre 1 et 100 caractères. \n";
		 fld.style.background = '#0099cc';
    } else if (illegalChars.test(fld.value)) {
        error = "Votre mot de passe ne doit être composé que de chiffres et de lettres.\n";
        fld.style.background = '#0099cc';
    } else {
        fld.style.background = 'White';
    }
   return error;
	}

function validate()
	{	
		if(document.contact.LASTNAME.value == "")
		{
			alert("Veuillez mentionner votre Nom.");
			document.contact.LASTNAME.focus();
			document.contact.LASTNAME.style.backgroundColor='#0099cc';
			return false;
		}
		
		if(validateNom(document.contact.LASTNAME)==false)
		{
			document.contact.LASTNAME.focus();
			document.contact.LASTNAME.style.backgroundColor='#0099cc';
			return false;
		}
		
		if(document.contact.EMAIL.value == "")
		{
			alert("Veuillez indiquer votre adresse email.");
			document.contact.EMAIL.focus();
			document.contact.EMAIL.style.backgroundColor='#0099cc';
			return false;
		}
		
		if (document.contact.EMAIL.value.match(/^([\w\-]+\.?)+\@([\w\-]+\.{1})+(com|net|org|edu|int|mil|gov|biz|info|aero|museum|name|coop|\w{2})$/) == null) 
		{
			alert("Veuillez vérifier votre adresse email.");
			document.contact.EMAIL.focus(); 
			return false; 
		}	
		if(document.contact.OBJET.value == "")
		{
			alert("Veuillez mentionner l'objet de votre message.");
			document.contact.OBJET.focus();
			document.contact.OBJET.style.backgroundColor='#0099cc';
			return false;
		}
		
		if(validateNom(document.contact.OBJET)==false)
		{
			document.contact.OBJET.focus();
			document.contact.OBJET.style.backgroundColor='#0099cc';
			return false;
		}
		if(document.contact.MESSAGE.value == "")
		{
			alert("Veuillez mentionner votre Message, Questions, D&eacute;sinscription...");
			document.contact.MESSAGE.focus();
			document.contact.MESSAGE.style.backgroundColor='#0099cc';
			return false;
		}
	
		    
		    return true;

			
}
	



function validateNom(entry)
	{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?0123456789";
	for (var i = 0; i < entry.value.length; i++)
	{
		if (iChars.indexOf(entry.value.charAt(i)) != -1)
		{
			alert("Veuillez v&eacute;rifier les caract&egrave;res");
			entry.value="";
			return false;
		}
	}
	}


function openWin(URL, nomWin) {
		window.open(URL, nomWin,"directories=no, location=no, menubar=no, resizable=yes,scrollbars=yes, status=yes, toolbar=no, width=800, height=545");
	}

