$(document).ready(function(){
	var startTimer = false;
	var timeTimer = 2500;
	var interval;
	function timeOutInfoBox(){ 
		startTimer = true;  
	    interval = setInterval(hideInfoBox, timeTimer);  
	} 
	
	function hideInfoBox(){
		$("div#infoBoxMail").animate({"top":100}, "600");
		$(this).fadeOut('800');
		startTimer = false;
	}
	
	$("form#mailForm").submit(function() {    s = $(this).serialize(); 
       	$("<div id='infoBoxMail'></div>").appendTo("body");
       	$("div#infoBoxMail").hide();
	    $.ajax({ 
	        type: "POST", 
	        data: s, 
	        url: $(this).attr("action"), 
	       	success: function(retour){ 
	        	$("div#infoBoxMail").append("<p>Votre message à bien été envoyé</p>"); 
   	        	$("div#infoBoxMail").fadeIn('200');
   	        	$("div#infoBoxMail").animate({"top":50}, "200");
   	        	$("form input[type=text], form textarea").attr({ 
          			value: ""
	 			});
   	        	if(startTimer == false){
   	        		timeOutInfoBox(); 
   	        	}
   	        	$("div#infoBoxMail").bind('click', function(){
        			$("div#infoBoxMail").animate({"top":100}, "600");
        			$(this).fadeOut('800');
        		});
	       	} 
	    }); 
	    return false; 
	});
});
