$(function(){
	
	$(".hidden").each(function(index) {
		$(this).height($(this).height());
		$(this).hide();
	 });
	
	$(".menu a").mouseenter(function() {
		if(!$(this).hasClass('current')){
			$(this).stop(true,true);
			$(this).animate({color:"#FFFFFF",paddingLeft:"20px"}, 200);	
		}
	});
	
	$(".menu a").mouseleave(function() {
		if(!$(this).hasClass('current')){
			$(this).stop(true,true);
			$(this).animate({color:"#C6C7C8", paddingLeft:"5px"}, 200);	
		}
	});
	
	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;
	});
	
	$('.switchlanguage').click(function() {
		$('.alllanguages').stop(true,true);
		$('.alllanguages').slideToggle('slow');
		return false;
	});
	
	$('.slider').nivoSlider({effect:'fade',pauseTime:4000});
	
	$('.details').click(function() {
		$('.boxes').stop(true,true);
		$('.boxes').slideToggle('slow');
		return false;
	});
	
	$('.fermer').click(function() {
		$('.boxes').stop(true,true);
		$('.boxes').slideToggle('slow');
		return false;
	});
	
	$('.details-2').click(function() {
		$(this).toggleClass('open');
		if($(this).children().text()=="+"){
			$(this).children().html("-");
		}else{
			$(this).children().html("+");
		}
		$("div[ref="+$(this).attr("key")+"]").toggleClass('purple');
		$("div[key="+$(this).attr("key")+"]").toggleClass('purple');
		$("div[key="+$(this).attr("key")+"]").stop(true,true);
		$("div[key="+$(this).attr("key")+"]").slideToggle('slow');
		return false;
	});
	
	$('.details-3').click(function() {
		$(this).toggleClass('open');
		if($(this).children().text()=="+"){
			$(this).children().html("-");
		}else{
			$(this).children().html("+");
		}
		$("div[ref="+$(this).attr("key")+"]").toggleClass('purple');
		$("div[key="+$(this).attr("key")+"]").toggleClass('purple');
		$("div[key="+$(this).attr("key")+"]").stop(true,true);
		$("div[key="+$(this).attr("key")+"]").slideToggle('slow');
		return false;
	});
	
	$('.paris-details').click(function() {
		$("div[ref="+$(this).attr("key")+"]").stop(true,true);
		$("div[ref="+$(this).attr("key")+"]").slideToggle('slow');
		return false;
	});
	
	$('.ratecode').click(function() {
		$('.rateinput').show();
		$(this).hide();
		return false;
	});
	
	$('.page-photos').mobilyselect({
		collection: '4e29744f-fba8-4d16-b662-11f8c0a8010e', // shows specified collection on startup
		animation: 'absolute', // type of animation, available options: plain, fade, absolute
		duration: 500, // duration of animation
		listClass: 'selecterContent', // main container
		btnsClass: 'selecterBtns',
		btnActiveClass: 'current', // add class name to the button
		elements: 'li',
		animation: 'fade',
		onChange: function(){}, // call the function when collection changes
		onComplete: function(){} // call the function when animation is completed
	});
	
	$("a[rel=diaporama]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=diaporama-roomsid]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=diaporama-4e3beab6-54d4-4b63-ad43-52aab2216711]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=diaporama-4e29744f-fba8-4d16-b662-11f8c0a8010e]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=video]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
        'autoScale'     	: false,
		'width'     		: 853,
		'height'     		: 510,
		'titlePosition' 	: 'over',
		'titleShow'			: false, 
		'type'				: 'iframe'
	});
	
	$("a[rel=googlemaps]").fancybox({
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#323132',
        'autoScale'     	: false,
		'width'     		: 853,
		'height'     		: 510,
		'titlePosition' 	: 'over',
		'titleShow'			: false, 
		'type'				: 'iframe'
	});

	
});

