function validate() {
	var why = "";
	why += checkName (document.forms['MoL'].name.value, "nom");
	why += checkEmail(document.forms['MoL'].email.value);
	 if (why != "") {
       alert(why);
       return false;
    }
	return true;
}
	
function checkEmail (strng) {
	var error="";
    var emailFilter=/^.+@.+\..{2,4}$/;
	  var illegalChars= /[\(\)\<\>\,\'\;\:\\\"\[\]]/;
	  
	if (strng.length == 0) {
		error = "Vous avez oublié d'écrire le courriel !\n";
	}
	else if (!(emailFilter.test(strng))) { 
       error = "Votre courriel n'est pas valide !\n";
    }
    else  if (strng.match(illegalChars))      
	{
		error = "Votre courriel contient des caractères illégaux !\n";
	}
   	return error;    
}

function checkName (strng, field) {
	var error = "";
	var illegalChars = /([^a-zA-ZéàÉ'-])\B/; 
	if (strng.length == 0) {
		error = "SVP tapez votre " + field + " !\n";
	}
	else if ((strng.length < 3) || (strng.length > 50)) {
		error = "Votre " + field + " trop court ou trop long !\n";
	}
    else if (illegalChars.test(strng)) {
    	error ="Votre " + field + " contient des caractères illégaux !\n";
    } 
	return error;
}       

var time = 5000;
var numofitems = 3;

function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;  
  this.numberofmenuitems = allitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}

function ehandler(event,theobj){
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "menuitem"+i+".thediv");
    shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
}
				
function closesubnav(event){
  if ((event.clientY <48)||(event.clientY > 107)){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
      shutdiv.style.visibility='hidden';
    }
  }
}
