// JavaScript Document
if ( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/Windows Phone/i))|| (navigator.userAgent.match(/blackberry/i))) { 
		if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "http://m.hotelpontaven.com/fr/"; 
	}
function showmenuhaut(id){
	if(!$("#Idulmenu").hasClass(id)){
		$("#"+id+"haut").stop(true,true);
		$("#"+id+"haut").animate( { color:"#BB7400" }, 200);
	}
}

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

$(document).ready(function() {
		
	$("#"+$("#Idulmenu").attr("class")).addClass("current");					   
						   
	$(function() {
		if($("#Idulmenu").attr("title")=="Hotel"){
		nbitem=0;
		}else if($("#Idulmenu").attr("title")=="Chambres"){
			nbitem=1;
		}else if($("#Idulmenu").attr("title")=="Petit-dejeuner"){
			nbitem=2;
		}else if($("#Idulmenu").attr("title")=="Services"){
			nbitem=3;
		}else if($("#Idulmenu").attr("title")=="Tarifs"){
			nbitem=4;	
		}else if($("#Idulmenu").attr("title")=="Contact-et-acces"){
			nbitem=5;
		}else if($("#Idulmenu").attr("title")=="Galerie-photos"){
			nbitem=6;
		}else if($("#Idulmenu").attr("title")=="Livre-dor"){
			nbitem=7;
		}else{
			nbitem=7;
		}   
		$("#Idulmenu").lavaLamp({
			fx: "easeOutBack",
			speed: 800,
			startItem: nbitem
		});
	});
	
	$('#Nivoslider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:45,
		animSpeed:1000,
		pauseTime:3500,
		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
	});
	
	
$('.selecter').mobilyselect({
		collection: 'hotel',
		animation: 'fade',
		duration: 300,
		listClass: 'selecterContent',
		btnsClass: 'selecterBtns',
		btnActiveClass: 'active',
		elements: 'li',
		onChange: function(){},
		onComplete: function(){}
	});
	
var dates = $( "#datedarrivee, #datededepart" ).datepicker({
			minDate: 0,
			numberOfMonths: 1,
			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;
	});
	
		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=DiapoHotel]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263'
	});
	$("a[rel=DiapoChambres]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263'
	});
	$("a[rel=DiapoServices]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263'
	});
	$("a[rel=diapo_chambres]").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titleFormat'		: formatTitle1,
		'titlePosition' 	: 'over',
		'titleShow'			: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263'
	});
	$("a[rel=googlemaps]").fancybox({
		'titleFormat'		: formatTitle1,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
});
