// JavaScript Document
var r=new RegExp();
r=/^([A-Za-z0-9\.\-_]+)(@)([A-Za-z0-9\.\-]+)(\.)([a-z]{2,6})$/;

// ------------ fct pour champs vides -----------------------
function pasvide(param){
	
	var id_param=$(param).attr("id");
	
	if($(param).val() == ""){
		$("#error_"+id_param).css({display:"block"});
		total_erreurs++;
	}else{
		$("#error_"+id_param).css({display:"none"});
		if(id_param == "email"){
			if( !r.test($(param).val()) ){
				$("#error_"+id_param).css({display:"block"});
				total_erreurs++;
			}else{
				$("#error_"+id_param).css({display:"none"});
			}
		}
	}
	
	
}
$(document).ready
	(

	 	function()
		{
			$(".error").each
			(
			 function()
			 {
				 $(this).css({display:"none"})
			 }
			) 
			$(".notempty").blur
			(
			 function()
			 {
				 pasvide(this);
			 }
			 )
			$("#butvalid").click
			(
				function()
				{
					total_erreurs=0;
					$(".notempty").each
					(
			 			function()
					 	{
				 			pasvide(this);
			 			}
					 )
					if (total_erreurs ==0)
					{
						document.forms.formContact.submit();
					}
				}
			)
			
		}
	)
