$(function(){
	$("#valid").click(function() {
		var valid_form = 0;
		
		//Verification NOM
		if($("#nom").val() == ""){
			$("#nom").addClass("nom_alert");
			$("#nom").animate({ backgroundColor: "#674490"}, 200);
			$("#valid").addClass("alert_champs");
			valid_form = 1;
		}
		else {
			$("#nom").removeClass("nom_alert");
			$("#valid").removeClass("alert_champs");
			$("#nom").animate({ backgroundColor: "#FFF"}, 200);
		}
		
		//Verification EMAIL
		if($("#email").val() == ""){
			$("#email").addClass("email_alert");
			$("#email").animate({ backgroundColor: "#674490"}, 200);
			valid_form = 1;
			$("#valid").addClass("alert_champs");
		}
		else if (!$("#email").val().match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/)) {
			$("#email").addClass("email_alert");
			$("#email").animate({ backgroundColor: "#674490"}, 200);
			valid_form = 1;
			$("#valid").addClass("alert_champs");
		} 
		else {
			$("#email").removeClass("email_alert");
			$("#valid").removeClass("alert_champs");
			$("#email").animate({ backgroundColor: "#FFF"}, 200);
		}
		
		//Verification MESSAGE
		if($("#message").val() == ""){
			$("#message").addClass("message_alert");
			$("#message").animate({ backgroundColor: "#674490"}, 200);
			valid_form = 1;
		}
		else {
			$("#message").removeClass("message_alert");
			$("#valid").removeClass("alert_champs");
			$("#message").animate({ backgroundColor: "#FFF"}, 200);
		}
		
		//Verification anti_bot
		if(!$("#anti_bot").val() == ""){
			valid_form = 1;	
		}
		
		if(valid_form != 1 ) {
			$.post("form.php", { nom: $("#nom").val(), email: $("#email").val(), web: $("#web").val(), message: $("#message").val()},
				function(data){
					$("#valid").addClass("send_ok");
					$("#nom").val("");
					$("#email").val("");
					$("#web").val("");
					$("#message").val("");
					setTimeout("send_ok()",1000);
				}
			);
		}
		return;
	});
});

function send_ok() {
	$("#valid").removeClass("send_ok");
	$("#bloc_form").slideUp("normal");
}

