// JavaScript Document
var i=0;
/* Menu "accueil", etc */
function survol_nav(i) {
	$('#menu'+i+' a').css('border-left-color','#d3d3d3');
	$('#menu'+(i-1)+' a').css('border-right-color','#ebebeb');
	$('#menu'+i).addClass('roll');
	$('.expand').removeClass('open');
	$('#expand'+i).addClass('open');
	$('.charte1 #content_forms .form1 #country').css('visibility','hidden');
	$('.charte1 #content_forms .form1 #region').css('visibility','hidden');
	$('.charte1 #content_forms .form1 #location').css('visibility','hidden');
	$('.charte1 #content_forms .form1 #prop').css('visibility','hidden')
}

function survol_nav2(i) {
	$('#menu'+i+' a').css('border-left-color','#ebebeb');
	$('#menu'+(i-1)+' a').css('border-color','#d3d3d3');
	$('#menu'+i).removeClass('roll');
	$('.expand').removeClass('open');
	$('.charte1 #content_forms .form1 #country').css('visibility','visible');
	$('.charte1 #content_forms .form1 #region').css('visibility','visible');
	$('.charte1 #content_forms .form1 #location').css('visibility','visible');
	$('.charte1 #content_forms .form1 #prop').css('visibility','visible')
}

/* ? */
function affiche_content(i) {
	$('.onglet a').removeClass('actif');
	$('#onglet'+i+' a').addClass('actif');
	$('.content_onglet').addClass('close');
	$('#content_onglet'+i).removeClass('close');
}

/* Pour afficher les "onglets" du tout premier menu du haut */
function ouvert1() {
		$("#autres_langues").toggleClass("open");
 }; 
function ouvert2() {
		$("#plan_site").toggleClass("open");
		$("#footer #fl").toggleClass("fl_open");

 };
function ouvert3(type) {
	if(type==1)
	{
		$("#pop_news").addClass("open");
		$("#menu2_3 #fl2").addClass("fl_open");
	}else{
		$("#pop_news").removeClass("open");
		$("#menu2_3 #fl2").removeClass("fl_open");
	}
};
function ouvert4(type) {
	if(type==1)
	{
		$("#autres_langues").addClass("open");
		$("#fl4").addClass("fl_open");
	}else{
		$("#autres_langues").removeClass("open");
		$("#fl4").removeClass("fl_open");
	}
 };
function ouvert5(type) {
	if(type==1)
	{
		$("#pop_account").addClass("open");
		$("#menu2_1 #fl1").addClass("fl_open");
	}else{
		$("#pop_account").removeClass("open");
		$("#menu2_1 #fl1").removeClass("fl_open");
	}
};
function ouvert6(type) {
	if(type==1)
	{
		$("#pop_follow").addClass("open");
		$("#menu2_4 #fl3").addClass("fl_open");
	}else{
		$("#pop_follow").removeClass("open");
		$("#menu2_4 #fl3").removeClass("fl_open");
	}
};
/* Fin premier menu */
 
function AccessverifDispo()
{
	if($('#verif_dispo').attr('checked') == false)
	{
		$('#voile').css('display','block');
		$('#date_mois').attr('disabled','disabled');
		$('#date_jour').attr('disabled','disabled');
		$('#date_annee').attr('disabled','disabled');
		$('#numberOfNights').attr('disabled','disabled');
		$('#numberOfRooms').attr('disabled','disabled');
		$('#adults').attr('disabled','disabled');
	}
	else
	{
		$('#voile').css('display','none');
		$('#date_mois').removeAttr('disabled');
		$('#date_jour').removeAttr('disabled');
		$('#date_annee').removeAttr('disabled');
		$('#numberOfNights').removeAttr('disabled');
		$('#numberOfRooms').removeAttr('disabled');
		$('#adults').removeAttr('disabled');
	}
}

function afficheOngletRestaurant()
{
	$('#typ2 a').addClass('actif');
	$('#typ1 a').removeClass('actif');
	$('#form_restau').css('display','block');
	$('#form_hotel').css('display','none')
}

 function verifChamps(type, lang, version, nomdefaut)
 {
	var testOK=1;

	if(type=='hotel' && $('#country').attr('value') == 0 && $('#region').attr('value') == 0 && $('#location').attr('value') == 0 && ($('#prop').attr('value') == nomdefaut) )
	{
		testOK=0;
	}

	if(type=='restau' && $('#country2').attr('value') == 0 && $('#region2').attr('value') == 0 && $('#location2').attr('value') == 0 && ($('#property').attr('value') == nomdefaut) && $('#type_gourmand').attr('checked')==false  && $('#amenities_sommelier').attr('checked')==false )
	{
		testOK=0;
	}

	if(testOK==0)
	{
			Shadowbox.open({
				content:    $('#hp_erreur_recherche').html(),
				player:     "html",
				height:     218,
				width:      366
			});				
		return false;
	}
	else
	{
		if (($('#property').attr('value') == nomdefaut))
	{
	$('#property').attr('value', '');
	}
	if (($('#prop').attr('value') == nomdefaut))
	{
	$('#prop').attr('value', '');
	}
		if(type=='hotel')
		{
			if($('#propRClist').attr('value')!='')
			{
				$('#prop').attr('value', '');
			}
			
			renvoi = "Recherche_hotel_general_ok";
			if($('#verif_dispo').attr('checked') == true) renvoi = "Recherche_hotel_dispo_ok";	
			
			_gaq.push(['_setCustomVar',4,'clic',''+renvoi,1]);
			_gaq.push(['_setCustomVar',5,'varComplete', version+'_marche-'+lang+'_Recherche_transfo_'+renvoi,1]);
			_gaq.push(['_trackEvent', version, 'Recherche_transfo', ''+renvoi]);
		}
		if(type=='restau')
		{
			if($('#propertyRClist').attr('value')!='')
			{
				$('#property').attr('value', '');
			}
			_gaq.push(['_setCustomVar',4,'clic','Recherche_resto_ok',1]);
			_gaq.push(['_setCustomVar',5,'varComplete', version+'_marche-'+lang+'_Recherche_transfo_Recherche_resto_ok',1]);
			_gaq.push(['_trackEvent', version, 'Recherche_transfo', 'Recherche_resto_ok']);
		}
	return true;
	}
 }
 
function check_email(email)
{
  var verif =/^([a-zA-Z0-9]+(([\.\-\_]?[a-zA-Z0-9]+)+)?)\@(([a-zA-Z0-9]+[\.\-\_])+[a-zA-Z]{2,4})$/;
 if (verif.exec(email) == null)
 {
 
 return(false);
 
 }
 else
 {
 return(true);
 } 
} 
 
 function DropErreurRecherche(txt){
	if($('#searchfield').val()==txt || $('#searchfield').val()==''){
		Shadowbox.open({
			content:    $('#hp_erreur_rechercher').html(),
			player:     "html",
			height:     268,
			width:      366
		});	
	}else{
		$('#recherche').submit();
	}
 }

 function DropErreurEmailCompte(trad_compte){
 	//if(!check_email($('#login').val())){
 	if($('#login').val()=="" || $('#login').val()==trad_compte){
		Shadowbox.open({
			content:    $('#hp_erreur_login').html(),
			player:     "html",
			height:     268,
			width:      366
		});	
	}else{
		$('#myrc3').submit();
	}
 
 } 
 function DropErreurEmailNewsletter(){
 	if(!check_email($('#newsemail').val())){
		Shadowbox.open({
			content:    $('#hp_erreur_mail').html(),
			player:     "html",
			height:     268,
			width:      366
		});	
	}else{
		$('#news').submit();
	}
 
 }
 
 // monkey survey
var sens_toggle_feedback=0;
$(document).ready(function() {		
	$( "#see" ).click(function() {
		
		if(sens_toggle_feedback==0){
			$( "#content_iframe" ).animate({left: '+=500px'}, 1000);
			sens_toggle_feedback=1;
		}else{
			$( "#content_iframe" ).animate({left: '-=500px'}, 1000);
			sens_toggle_feedback=0;				
		}
	});
});
