function checkWholeForm(theForm) {
    var why = "";
    why += checkEmail(theForm.adresseemail.value);
	why += isEmpty_message(theForm.message.value);
	why += isEmpty_objet(theForm.sujet.value);
    if (why != "") {
       //alert(why);
	   document.getElementById('Controller').innerHTML ='<div style=" background-color:#ff9999; color:#ff0000; padding:3px;">'+(why)+'</div>';
	   errorMsg();
	   window.setTimeout(ceud,3000);
	   return false;
    }
document.form_contact.submit();
//$('form_contact').request();
document.getElementById('Controller').innerHTML ='Envoi en cours... ';
errorMsg();
return true;
}

function stopSend(){ 
	document.getElementById('Controller').innerHTML ='<span style="background-color:#FFFF00; color:#000;">Mail envoy&eacute;.</span>';
	errorMsg();
	window.setTimeout(ceud,3000);
}

function ceud(){
	errorMsg();
	//document.getElementById('Controller').innerHTML ='';
}

function errorMsg(){
Effect.toggle('Controller','appear'); return false;
}




function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "Vous n\'avez pas entrer d\'adresse mail.\n";
	}
	
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
		   error = "Veuillez entrer une adresse mail valide.\n";
		}
		else {
	//test email for illegal characters
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) {
			  error = "L\'adresse email contient des caract&egrave;res ill&eacute;gaux.\n";
		   }
		}
	return error;    
	}


function checkUsername (strng) {
	var error = "";
	if (strng == "") {
	   error = "Vous n'avez pas renseigner votre nom.\n";
	}
	
	
		var illegalChars = /\W/; // allow letters, numbers, and underscores
		if ((strng.length < 4) || (strng.length > 20)) {
		   error = "Votre nom est trop court ou trop long..\n";
		}
		else if (illegalChars.test(strng)) {
		error = "Votre nom contient des caract&egrave;res ill&eacute;gaux.\n";
		} 
	return error;
	}     
	
	
// non-empty textbox

function isEmpty_objet(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "<br>Veuillez remplir l'objet du mail.\n"
	  }
	return error;	  
	}


function isEmpty_message(strng) {
	var error = "";
	  if (strng.length == 0) {
		 error = "<br>Veuillez remplir le message du mail.\n"
	  }
	return error;	  
	}
