// 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.operacadet.com/fr/"; 
	}
function showmenuhaut(id){
	if(!$("#Idulmenu").hasClass(id)){
		$("#"+id+"haut").stop(true,true);
		$("#"+id+"haut").animate( { color:"#FABC3A" }, 200);
	}
}

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

$(document).ready(function() {
	
	$(function (){
		setInterval(function(){
		//Horloge a l'heure de Paris
		var dd;
		var Maintenant = new Date();
		var fuseau = Maintenant.getTimezoneOffset();
		var heures = Maintenant.getHours();
		var minutes = Maintenant.getMinutes();
		var secondes = Maintenant.getSeconds();
		//Décalage par rapport à Greenwich (GMT) - +1 pour Paris
		heures = heures + (fuseau/60)+1;
		//heure été
		var annee = Maintenant.getFullYear();
		for (i=31; i >24; i--) {
		dimanche = new Date(annee, 2, i);
		if (dimanche.getDay()==0) break;
		}
		for (i=31; i >24; i--) {
		dimanche2 = new Date(annee, 9, i);
		if (dimanche2.getDay()==0) break;
		}
		if (Maintenant >= dimanche && Maintenant < dimanche2) heures = heures + 1;
		//heure été
		// quelques corrections pour retablir des heures inferieures a 0H et superieures a 23H
		if ( heures < 0 ) {
		heures = 24 + heures;
		}
		if (heures > 23) {
		heures = heures - 24;
		}
		heures = ((heures < 10) ? " 0" : " ") + heures;
		minutes = ((minutes < 10) ? ":0" : ":") + minutes;
		secondes = ((secondes < 10) ? ":0" : ":") + secondes;
		// formhorloge_Paris: nom du formulaire pour l'horloge a l'heure de Paris
		// horloge: nom de l'input, où sera affiché l'horloge
		$("#heures").text(heures+minutes+secondes);
		},1000);
	});
	
	$('.ajax').live('click', function(){
		$(".ajax-loading").stop(true, true).fadeIn();
		$('ul[rel=ulchambre]').removeClass().addClass($(this).attr('class'));
		$.get($(this).attr('rel'),{},function(data){
			$('.contenuchambres').empty().append(data);
			$(".ajax-loading").stop(true, true).fadeOut();
		});
		return false;
	});
	
	$('#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
	});
	
	$('#Nivoslider2').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
	});
	
	$("#"+$("#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")=="Services"){
			nbitem=2;
		}else if($("#Idulmenu").attr("title")=="Tarifs"){
			nbitem=3;
		}else if($("#Idulmenu").attr("title")=="Seminaires"){
			nbitem=4;
		}else if($("#Idulmenu").attr("title")=="Environs"){
			nbitem=5;	
		}else if($("#Idulmenu").attr("title")=="Contact-et-acces"){
			nbitem=6;	
		}else if($("#Idulmenu").attr("title")=="Actualites"){
			nbitem=7;
		}else if($("#Idulmenu").attr("title")=="Galerie-photos"){
			nbitem=8;		
		}else{
			nbitem=0;
		}   
		$("#Idulmenu").lavaLamp({
			fx: "easeOutBack",
			speed: 800,
			startItem: nbitem
		});
	});
	
	$("a[rel=languages]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=CodeGDS]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=chambres]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=chambres2]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=all]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
        'autoScale'     	: true,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$("a[rel=googlemaps]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
		'width'				: '75%',
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$("a[rel=carte]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#646263',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
	
	$('.textehotel').click(function() {
		$('.hidden').stop(true,true);
		$('.hidden').slideToggle('slow');
		return false;
	});
	
	$("a[rel=fancyhotel]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#e7e6e2',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=fancychambres]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#e7e6e2',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=fancyrestaurant]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#e7e6e2',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
	});
	
	$("a[rel=fancyseminaires]").fancybox({
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#e7e6e2',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over'
	});
	
	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;
	});

	$('.selecter').mobilyselect({
		collection: 'chambres',
		animation: 'fade',
		duration: 300,
		listClass: 'selecterContent',
		btnsClass: 'selecterBtns',
		btnActiveClass: 'active',
		elements: 'li',
		onChange: function(){},
		onComplete: function(){}
	});

});	
