function maj(id)
	{
		truc = $("li[id="+id+"]").text();
		$("input[name='heure']").val(truc);
		$("#time").hide();
	}
$(function() {

	function nationalDays(date) {
		for (i = 0; i < natDays.length; i++) {
		  if (date.getMonth() == natDays[i][0] - 1
			  && date.getDate() == natDays[i][1]) {
			return [false, natDays[i][2] + '_day'];
		  }
		}
	  return [true, ''];
	}
	
	$(".datepicker").datepicker({ 
		beforeShowDay: nationalDays, minDate: 1, 
		maxDate: '+1Y',
		dateFormat: 'dd/mm/yy'
	});
	
	$(".datepicker").change( function()
	{	
		var date = $(this).val();

		jQuery.post("http://www.le28thiers.fr/reservation/horaire.php", { horraire : date } , function success(data)
		{				
			$("#time").html(data);	
			$("#time").show();		
		});	
		
	
	});

	
	$('.time').click(function () 
	{
	if($(".datepicker").val()!=''){
        
   
		        var date = $(".datepicker").val();
       
			    jQuery.post("http://www.le28thiers.fr/reservation/horaire.php", { horraire : date } , function success(data)
                {                
                    $("#time").html(data);    
                    $("#time").show();    
                 
                });    
    }
    else{
        alert("Veuillez selectionner le jour avant de préciser l'heure");
    }
		
	});
	
	$('.time').keypress(function ()
	{	

		return false;
	});
	
	$('.datepicker').keypress(function ()
	{	
		return false;
	});
	
	$("body").click(function ()
	{
		$("#time").hide();
	});
	
	
   

    
    
	$("#reservation").validate(
        {
             errorLabelContainer: "#messageBoxError",
             wrapper: "div"
        }
    ); 
	$(".ajout").validate(); 
	
});
