// JavaScript Document


$(document).ready(function() {
		
		$('#Nivoslider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:45,
		animSpeed:500,
		pauseTime:5000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false //Force manual transitions
	});
	
	var dates = $( "#datedarrivee, #datededepart" ).datepicker({
	  minDate: 0,
	  numberOfMonths: 2,
	  onSelect: function( selectedDate ) {
		  var option = this.id == "datedarrivee" ? "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 );
	  }
	});

	$(".availpro").submit(function() {
		datedarrivee = $("#datedarrivee").datepicker( "getDate" );
		datededepart = $("#datededepart").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;
	});
	
	$('.selecter').mobilyselect({
		collection: 'hotel',
		animation: 'fade',
		duration: 300,
		listClass: 'selecterContent',
		btnsClass: 'selecterBtns',
		btnActiveClass: 'active',
		elements: 'li',
		onChange: function(){},
		onComplete: function(){}
	});
	
	$('.ajax').live('click', function(){
		$(".ajax-loading").stop(true, true).fadeIn();
		$('ul[rel=MenuChambres]').removeClass().addClass($(this).attr('class'));
		$.get($(this).attr('rel'),{},function(data){
			$('.contenuChambres').empty().append(data);
			$(".ajax-loading").stop(true, true).fadeOut();
		});
		return false;
	});

	function formatTitle1(title, currentArray, currentIndex, currentOpts) {
		return'<div class="boxfancyconteneur"><table width="100%"><tr><td valign="middle" align="right" style="padding:0 0 0 100px;"><p>'+title+'</p></td></tr></table></div>';
	}
	
	$("a[rel=chambres]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#A2988A'
	}); 
	$("a[rel=chambre_triple]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#A2988A'
	});
	$("a[rel=chambre_quadruple]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#A2988A'
	});
	$("a[rel=fancyplan]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#A2988A'
	});
	$("a[rel=googlemaps]").fancybox({
		'titleFormat'		: formatTitle1,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#A2988A',
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});


});
