$(document).ready(function(){
	$('#ebegindate, #eenddate, #date_arrivee, #date_depart').datepicker({
			numberOfMonths: 2,
			dateFormat: 'dd-mm-yy',
			dayNamesMin: ['Di','Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
			minDate: 0,
			monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
			firstDay: 1
	});
	
	
	$('.ss-menu').hide();
	
	$('#menu .ss-menu-link').hover(
		function(){
			$('.ss-menu', this).stop(true, true).slideDown(100);
			$(this).css({background:"url(../images/btn_menu.png) repeat-x","border-top-left-radius":"3px", "border-top-right-radius":"3px"});
			$('a', this).css({"color": "#666","text-shadow":"0 1px #FFF", });		
			},
		function(){
			$('.ss-menu', this).stop(true, true).slideUp(100);
			/*$(this).css({background:"url(../images/btn_menu.png) repeat-x 0px 0px", "border-bottom":"1px solid #000"});*/
			$(this).css({background:"none","border-top-left-radius":"none", "border-top-right-radius":"none"});
			$('a', this).css({"color": "#FFF","text-shadow":"none", });
			}
	);
	
	$('.bx_form_left').focusin(function(){
		$(this).css({'border-top':'1px solid #00c3d5', 'border-bottom':'1px solid #00c3d5', 'border-right':'1px solid #00c3d5', color:'#00c3d5'});
		var lol = $(this).parent();
		lol.children('img').stop().animate({'margin-top':'-34px'},500);
	});	
	
	$('.bx_form_left').focusout(function(){
		$(this).css({'border-top':'1px solid #000', 'border-bottom':'1px solid #000', 'border-right':'1px solid #000', color:'#666'});
		$('img').stop().animate({'margin-top':'0px'},500);
	});
	
	
	
	$('.message').focusin(function(){
		$(this).css({'border-top':'1px solid #00c3d5', 'border-bottom':'1px solid #00c3d5', 'border-right':'1px solid #00c3d5', color:'#00c3d5'});
		var lol2 = $(this).parent();
		lol2.children('img').stop().animate({'margin-top':'-73px'},400);
	});	
	
	$('.message').focusout(function(){
		$(this).css({'border-top':'1px solid #000', 'border-bottom':'1px solid #000', 'border-right':'1px solid #000', color:'#666'});
		$('img').stop().animate({'margin-top':'0px'},400);
	});
	
	$('#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/traitement_contact.php',
				data:'nom='+nom+'&prenom='+prenom+'&email='+email+'&tel='+tel+'&message='+message+'&captcha='+captcha,
				async:false
				
				}).responseText;
				$('#nom').val('Nom');
				$('#prenom').val('Prénom');
				$('#email').val('Email');
				$('#tel').val('Téléphone');
				$('#message').val('Message');
				$('#icaptcha').val('');
				$('#reponse_text').html(reponse);
				return false;
			});
			
	$('#formulaire_seminaire').submit(function (){
		
		
		
		var nom_seminaire = $('#nom_seminaire').val();
		var type_manifestation = $('#type_manifestation').val();
		var nb_participants = $('#nb_participants').val();
		var nb_chambres = $('#nb_chambres').val();
		var date_arrivee = $('#date_arrivee').val();
		var date_depart = $('#date_depart').val();
		var dates_flexibles = $('#infos3 input').val();
		var prestations = $('#prestations').val();
		var audiovisuel = $('#audiovisuel').val();
		var nb_salles = $('#nb_salles').val();
		var titre = $('#titre').val();
		var societe = $('#societe').val();
		var nom = $('#nom').val();
		var prenom = $('#prenom').val();
		var adresse = $('#adresse').val();
		var ville = $('#ville').val();
		var telephone = $('#telephone').val();
		var courriel = $('#courriel').val();
		var captcha = $('#icaptcha2').val();
		
		var reponse = $.ajax({
				type:'POST',
				url:'inc/traitement_seminaire.php',
				data:'nom_seminaire='+nom_seminaire+'&type_manifestation='+type_manifestation+'&nb_participants='+nb_participants+'&nb_chambres='+nb_chambres+'&date_arrivee='+date_arrivee+'&date_depart='+date_depart+'&dates_flexibles='+dates_flexibles+'&prestations='+prestations+'&audiovisuel='+audiovisuel+'&nb_salles='+nb_salles+'&titre='+titre+'&societe='+societe+'&nom='+nom+'&prenom='+prenom+'&adresse='+adresse+'&ville='+ville+'&telephone='+telephone+'&courriel='+courriel+'&captcha='+captcha,
				async:false
				
				}).responseText;
				/*var nom_seminaire = $('#nom_seminaire').val('Evènement / Groupe...');
				var nb_participants = $('#nb_participants').val('Nombre de participants');
				var nb_chambres = $('#nb_chambres').val('Nombre de chambres');
				var date_arrivee = $('#date_arrivee').val('Date d arrivée');
				var date_depart = $('#date_depart').val('Date de départ');
				var nb_salles = $('#nb_salles').val('Nombre de salles nécessaires');
				var titre = $('#titre').val('Titre');
				var societe = $('#societe').val('Société');
				var nom = $('#nom').val('Nom');
				var prenom = $('#prenom').val('Prénom');
				var adresse = $('#adresse').val('Adresse');
				var ville = $('#ville').val('Ville');
				var telephone = $('#telephone').val('Téléphone');
				var courriel = $('#courriel').val('Courriel');*/
				var captcha = $('#icaptcha2').val('');
				$('#reponse_text2').html(reponse);
				return false;
			});
	
	$(window).load(function() {
	mCustomScrollbars();
	});
	
	function mCustomScrollbars(){
	/* 
	malihu custom scrollbar function parameters: 
	1) scroll type (values: "vertical" or "horizontal")
	2) scroll easing amount (0 for no easing) 
	3) scroll easing type 
	4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
	5) scrollbar height/width adjustment (values: "auto" or "fixed")
	6) mouse-wheel support (values: "yes" or "no")
	7) scrolling via buttons support (values: "yes" or "no")
	8) buttons scrolling speed (values: 1-20, 1 being the slowest)
	*/
	$("#presentation2").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10); 
}

/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

/* function to load new content dynamically */
function LoadNewContent(id,file){
	$("#"+id+" .customScrollBox .content").load(file,function(){
		mCustomScrollbars();
	});
}

	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();	
	});


});
