// JavaScript Document

function showmenuhaut(id){
	if(!$("#Idulmenu").hasClass(id)){
		$("#"+id+"haut").stop(true,true);
		$("#"+id+"haut").animate( { color:"#483D37" }, 200);
	}
}

function hidemenuhaut(id){
	if(!$("#Idulmenu").hasClass(id)){
		$("#"+id+"haut").stop(true,true);	
		$("#"+id+"haut").animate({ color:"#9B8579" }, 200);
	}
}

$(function(){
	
	$('a.ajax').live('click', function(){
		$(".ajax-loading").stop(true, true).fadeIn();
		$('ul[rel=ul-ajax]').removeClass().addClass($(this).attr('class'));
		$('#Sp_img_menuAjax').removeClass().addClass($(this).attr('key'));
		$.get($(this).attr('rel'),{},function(data){
			$('.AjaxConteneur').empty().append(data);
			$(".ajax-loading").stop(true, true).fadeOut();
		});
		return false;
	})
	
	var dates = $( "#c_arrivaldate, #c_departuredate" ).datepicker({
		minDate: 0,
		numberOfMonths: 2,
		onSelect: function( selectedDate ) {
			var option = this.id == "c_arrivaldate" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" ),
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});
	
	$(".formminibooking").submit(function() {
		datedarrivee = $("#c_arrivaldate").datepicker( "getDate" );
		datededepart = $("#c_departuredate").datepicker( "getDate" );
		datedifference = datededepart - datedarrivee;
		if(datedarrivee.getMonth()+1<10){
			moisaafficher = "0"+(datedarrivee.getMonth()+1);	
		}else{
			moisaafficher = (datedarrivee.getMonth()+1);
		}
		dateavailpro = datedarrivee.getFullYear()+"-"+moisaafficher+"-"+datedarrivee.getDate();
		$('#AVP_arrivalDate').val(dateavailpro);
		if((datedifference/86400000)<1){
			$('#AVP_nights').val(1);
		}else{
			$('#AVP_nights').val(datedifference/86400000);
		}
		return true;
	});

	$("a[rel=GoogleMaps]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleShow'			: false,
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
		'type'				: 'iframe',
		'overlayColor'		: '#DFD4C6',
		'overlayOpacity'	: 0.9	
	});

});	
