$(document).ready(function() {
		$('#coin-slider').coinslider();
		
		$('#datepicker').datepicker({
			dateFormat: 'yy-mm-dd', ///////// FORMAT DE DATE PERSONNALISÉ
			numberOfMonths: 2,
			inline: true,
			minDate: -0, 
			maxDate: "+1Y +10D"
		});

		$('#formulaire').hide();
		$('#close_resa').hide();
		$('#liste_langues').hide();
		
		
		
		var widthResa = $('#reservation').height()/2 - 10;
		$('#reservation').css({top:widthResa});
		
		
		$("li.popo").hover(function() { //Hover over event on list item
		$(this).css({background:'url(images/fond_menu_h_hover_li.png) repeat-x'});
		 //Add background color and image on hovered list item
		
		$(this).find("span").slideDown(function(){
			//var widthSub = $(this).width()/2;
			//var widthLi = $(this).find("span").width()/2;
			//var lol = widthSub - widthLi;
			//$(this).css({marginLeft:-lol+'px'});
			}); //Show the subnav
	} , function() { //on hover out...
		$(this).css({ 'background' : 'none'}); //Ditch the background
		$(this).find("span").hide(); //Hide the subnav
	});
	
	$('#reserver_btn').click(function(){
		$('#reserver_btn').slideUp().hide('slow');
		$('#reserver_btn').hide();
		$('#formulaire').slideDown();
		$('#close_resa').show();		
		});
		
	$('#close_resa').click(function(){
		$('#formulaire').hide();
		$('#reserver_btn').show();	
		$('#close_resa').hide();	
		});
		
	// Choose Language
	$('#choose_langues').click(function(){
		$('#liste_langues').slideToggle('fast');	
	});	
	
	// Switch presentation
	
	$('#description_content').hide();
	
	$('#description').click( function() {
		$('#actualites_content').hide();
		$('#description_content').show('fast');
	});
	$('#actualites').click( function() {
		$('#description_content').hide();
		$('#actualites_content').show('fast');
	});
	
	
	
	$('#footer_false').hide();
	
	$('#contact').click(function() {
		$('#footer_false').slideDown(200);
	});
	
	$('#close_contact').click(function() {
		$('#footer_false').slideUp(200);
	});
	
	$('#open_presentation').hide();
	
	/*$('#close_presentation').click(function() {									
		$('#switch_menu').fadeOut(500);
		$('#presentation').fadeOut(500);
		$('#close_presentation').fadeOut(500);
		$('#open_presentation').fadeIn(500);
	});
	
	$('#open_presentation').click(function() {									
		$('#switch_menu').fadeIn(500);
		$('#presentation').fadeIn(500);
		$('#close_presentation').fadeIn(500);
		$('#open_presentation').fadeOut(500);
	});*/
	
	$('#close_presentation').click(function() {									
		$('#switch_menu').hide(100);
		$('#presentation').fadeOut(500);
		$('#close_presentation').fadeOut(500);
		$('#open_presentation').fadeIn(500);
	});
	
	$('#open_presentation').click(function() {									
		$('#switch_menu').fadeIn(500);
		$('#presentation').fadeIn(500);
		$('#close_presentation').fadeIn(500);
		$('#open_presentation').fadeOut(500);
	});
	
	
	$('#actualites').click(function() {									
		$('#actualites').addClass("active");
		$('#description').removeClass("active");
	});
	
	$('#description').click(function() {									
		$('#description').addClass("active");
		$('#actualites').removeClass("active");
	});
	
	
	$('#menu').lavaLamp({
	fx: 'easeInExpo',
	speed: 150
});
	
	$('#cache').hide();
	
	$('#langues_show_btn').toggle(function(){
		$('#langues_show').animate({top:'219px'});
		$('#choose_langues').animate({top:'0'});
		$('#lol').rotate(180);
		$('#cache').fadeIn();
		},function(){
		$('#langues_show').animate({top:'0'});
		$('#choose_langues').animate({top:'-219px'})
		$('#lol').rotate(0);
		$('#cache').hide();
		}
		);
		
		$('#formulaire_contact').submit(function (){
			var nom = $('#nom').val();
			var prenom = $('#prenom').val();
			var email = $('#email').val();
			var tel = $('#tel').val();
			var message = $('#message').val();
			var captcha = $('#icaptcha').val();
			var reponse = $.ajax({
				type:'POST',
				url:'inc/contact.php',
				data:'nom='+nom+'&prenom='+prenom+'&email='+email+'&tel='+tel+'&message='+message+'&captcha='+captcha,
				async:false
				/*success: function (){
					alert('yahoooooo');		
				}*/
				
				}).responseText;
				$('#nom').val('');
				$('#prenom').val('');
				$('#email').val('');
				$('#tel').val('');
				$('#message').val('');
				$('#icaptcha').val('');
				$('#reponse_text').html(reponse);
				return false;
			});
		
		$('#lightbox').hide();
		
		
		$('#btn_lightbox, #close_frame').click(function(){
			$('#lightbox').fadeIn(200);
			});
			
			$('#lightbox').click(function(){
			$('#lightbox').fadeOut(200);
			});
		
		function getCookie(sName) {
		var oRegex = new RegExp("(?:; )?" + sName + "=([^;]*);?");
 
		if (oRegex.test(document.cookie)) {
				return decodeURIComponent(RegExp["$1"]);
		} else {
				return null;
		}
	}

	function setCookie(sName, sValue) {
		var today = new Date(), expires = new Date();
		expires.setTime(today.getTime() + (4*60*1000));
		document.cookie = sName + "=" + encodeURIComponent(sValue) + ";expires=" + expires.toGMTString();
	}
	
	
	if(!getCookie('promo')) {
		$('#masque_promo').show();
		setCookie('promo', 'vu');
	}
	else {
		$('#masque_promo').hide();
	}
		
	$('#go_site, #close_promo').click(function(){
		$('#masque_promo').fadeOut();	
	});
		
});
