/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* Moteur de recherche pour la home (mener à disparaitre au profit du nouveau/ */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
function lookup_home_moteur_destination(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		// SUPPRIMER LES FICHIERS QUAND LA NOUVELLE VERSION DU SITE SERA ONLINE
		$.post("rpc_home_destination.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}
function lookup_home_moteur_itineraire(inputString2) {
	if(inputString2.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		// SUPPRIMER LES FICHIERS QUAND LA NOUVELLE VERSION DU SITE SERA ONLINE
		$.post("rpc_home_itineraire.php", {queryString2: ""+inputString2+""}, function(data) { // Do an AJAX call
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* Nouveau moteur de recherche /////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
// fonction qui clean le input du moteur (quand on change entre destination, itinéraire ect...)
function clearMoteurFooter()
{
	document.getElementById("inputStringFooter").value = "";
}

/* ////////////////////////////////////////// */
function moteurFooter(char) {
	if(document.getElementById("id_destinationFooter").checked){		
		var type = "destination";
	}else if(document.getElementById("id_itineraireFooter").checked){
		var type = "itineraire";
	}else if(document.getElementById("id_hotelFooter").checked){
		var type = "hotel";	
	}
	if(char.length == 0) {
		$('#suggestions_footerMoteur').fadeOut(); // Hide the suggestions box
	} else {
			$.post("rpc_moteurFooter.php", {postChar: ""+char+"", type: ""+type+""}, function(data) { // Do an AJAX call
			$('#suggestions_footerMoteur').fadeIn(); // Show the suggestions box
			$('#suggestions_footerMoteur').html(data); // Fill the suggestions box
		});
	}
}
function moteurOffresSpeciales(char) {
	if(char.length == 0) {
		$('#suggestions_moteurOffresSpeciales').fadeOut(); // Hide the suggestions box
	} else {
			$.post("rpc_moteurFooter.php", {postChar: ""+char+"", type: "offres"}, function(data) { // Do an AJAX call
			$('#suggestions_moteurOffresSpeciales').fadeIn(); // Show the suggestions box
			$('#suggestions_moteurOffresSpeciales').html(data); // Fill the suggestions box
		});
	}
}
function moteur_out(anId){
	node = document.getElementById(anId);
	node.style.display = "none";
	node.style.height = "0";
}
function moteur_over(anId){
	node = document.getElementById(anId);
	node.style.display = "block";
	node.style.height = "auto";
}
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////// */

/* ////////////////////////////////////////// */
function lookup_destination(inputString_liste) {
	if(inputString_liste.length == 0) {
		$('#livre_onglet').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_destination.php", {queryString_liste: ""+inputString_liste+""}, function(data) { // Do an AJAX call
			$('#fil_de_fer').fadeIn(); // Show the suggestions box
			$('#fil_de_fer').html(data); // Fill the suggestions box
		});
	}
}
function lookup_destinationNew(inputString_liste) {
	if(inputString_liste.length == 0) {
		$('#livre_onglet').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_destinationNew.php", {queryString_liste: ""+inputString_liste+""}, function(data) { // Do an AJAX call
			var tab = data.split("/?&?/");
			$('#fil_de_fer').fadeIn(); // Show the suggestions box
			$('#fil_de_fer').html(tab[0]); // Fill the suggestions box
			$('#titre').html(tab[1]); // Fill the suggestions box
			$('#contenu').html(tab[2]); // Fill the suggestions box
			$('#img_apercu').html(tab[3]); // Fill the suggestions box
			document.getElementById("lien_galerie").href = tab[4]+"&amp;iframe=true&amp;width=100%&amp;height=100%";
			document.getElementById("lien_hotels").href = tab[5];			
			$('#lien_itineraires').html(tab[6]); // Fill the suggestions box
			document.getElementById("lien_carte").href = tab[7];
			if(tab[8] == "0"){
				document.getElementById("id_affiche_carte").style.display = "none";
			}else{
				document.getElementById("id_affiche_carte").style.display = "block";
			}
		});
	}
}

function lookup_extra(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_1').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_1"}, function(data) { // Do an AJAX call
			$('#extra_chambre_1').fadeIn(); // Show the suggestions box
			$('#extra_chambre_1').html(data); // Fill the suggestions box
		});
	}
}

function lookup_extra_2(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_2').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_2"}, function(data) { // Do an AJAX call
			$('#extra_chambre_2').fadeIn(); // Show the suggestions box
			$('#extra_chambre_2').html(data); // Fill the suggestions box
		});
	}
}

function lookup_extra_3(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_3').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_3"}, function(data) { // Do an AJAX call
			$('#extra_chambre_3').fadeIn(); // Show the suggestions box
			$('#extra_chambre_3').html(data); // Fill the suggestions box
		});
	}
}

function lookup_extra_4(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_4').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_4"}, function(data) { // Do an AJAX call
			$('#extra_chambre_4').fadeIn(); // Show the suggestions box
			$('#extra_chambre_4').html(data); // Fill the suggestions box
		});
	}
}

function lookup_extra_5(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_5').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_5"}, function(data) { // Do an AJAX call
			$('#extra_chambre_5').fadeIn(); // Show the suggestions box
			$('#extra_chambre_5').html(data); // Fill the suggestions box
		});
	}
}

function lookup_extra_6(inputString) {
	if(inputString.length == 0) {
		$('#extra_chambre_6').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_resa_ch_extra.php", {queryString: ""+inputString+"_6"}, function(data) { // Do an AJAX call
			$('#extra_chambre_6').fadeIn(); // Show the suggestions box
			$('#extra_chambre_6').html(data); // Fill the suggestions box
		});
	}
}

function lookup_total_personnes_placees(inputString) {
		//alert(inputString);
	$.post("rpc_total_personnes_placees.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
		$('#extra_chambre_6').fadeIn(); // Show the suggestions box
		$('#extra_chambre_6').html(data); // Fill the suggestions box
	});
}
function lookup_efface_personnes_placees(inputString) {
		//alert(inputString);
	$.post("rpc_efface_personnes_placees.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
		$('#extra_chambre_6').fadeIn(); // Show the suggestions box
		$('#extra_chambre_6').html(data); // Fill the suggestions box
	});
}

function lookup_efface_extra(inputString) {
		//alert(inputString);
	$.post("rpc_efface_extra.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
		$('#extra_chambre_6').fadeIn(); // Show the suggestions box
		$('#extra_chambre_6').html(data); // Fill the suggestions box
	});
}

function show_valide_etape2(inputString) {
	var myArray = inputString.split('_'); 
	if(((myArray[1]-myArray[0])/86400) > myArray[2] && myArray[2]!="" && myArray[2]!="0"){
		jConfirm("Pour cette période votre durée du séjour ne peut pas dépasser "+myArray[2]+" jours !");
	}
	else{
		document.getElementById('bt_valider_etape2').style.display = "block";
	}
}

function add_extra_bed_a(inputString) {
		//alert(inputString);
	$.post("rpc_ajout_extra.php", {queryString: "a_"+inputString+""}, function(data) { // Do an AJAX call
		$('#chambre_'+inputString+'_extra_a').fadeIn(); // Show the suggestions box
		$('#chambre_'+inputString+'_extra_a').html(data); // Fill the suggestions box
	});
}
function add_extra_bed_e(inputString) {
		//alert(inputString);
	$.post("rpc_ajout_extra.php", {queryString: "e_"+inputString+""}, function(data) { // Do an AJAX call
		$('#chambre_'+inputString+'_extra_e').fadeIn(); // Show the suggestions box
		$('#chambre_'+inputString+'_extra_e').html(data); // Fill the suggestions box
	});
}
function suppr_extra_bed_a(inputString) {
		//alert(inputString);
	$.post("rpc_suppr_extra.php", {queryString: "a_"+inputString+""}, function(data) { // Do an AJAX call
		$('#chambre_'+inputString+'_extra_a').fadeIn(); // Show the suggestions box
		$('#chambre_'+inputString+'_extra_a').html(data); // Fill the suggestions box
	});
}
function suppr_extra_bed_e(inputString) {
		//alert(inputString);
	$.post("rpc_suppr_extra.php", {queryString: "e_"+inputString+""}, function(data) { // Do an AJAX call
		$('#chambre_'+inputString+'_extra_e').fadeIn(); // Show the suggestions box
		$('#chambre_'+inputString+'_extra_e').html(data); // Fill the suggestions box
	});
}
function lookup_max_capacite(inputString) {
	$.post("rpc_capacite_max.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call

	});
}

function lookup_resultContenuAjax_flash(inputString) {
	$.post("rpc_resultContenuAjax_flash.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
		$('#resultContenuAjax_flash').fadeIn(); // Show the suggestions box
		$('#resultContenuAjax_flash').html(data); // Fill the suggestions box
	});
}

function lookup_resultContenuAjax_flash(inputString) {
	if(inputString != "0_destination"){
		$.post("rpc_resultContenuAjax_flash.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#resultContenuAjax_flash').fadeIn(); // Show the suggestions box
			$('#resultContenuAjax_flash').html(data); // Fill the suggestions box
		});
	}
}

function lookup_aventure(inputString_liste) {
	if(inputString_liste.length == 0) {
		$('#livre_onglet').fadeOut(); // Hide the suggestions box
	} else {
		$.post("rpc_aventure.php", {queryString_liste: ""+inputString_liste+""}, function(data) { // Do an AJAX call
				
			var tab = data.split("/?&?/");							
			var id_aventures = tab[0];
			var id_destination = tab[1];
			var titre_aventure = tab[2];
			var chapo_aventure = tab[3];
			var description_aventure = tab[4]; 
			var video_aventures = tab[5]; 
			var tab_img = tab[6];
			var url_rewrite_iti = tab[7]; 
			var iti = tab[8];
			var hotel_id_tab = tab[9];
			var hotel_titre_tab = tab[10];
			var hotel_titre = tab[11];
			var carte = tab[12];
			var carte_url = tab[13];
				   
			document.getElementById("encart_news_itineraire").style.display = "none";
			document.getElementById("hotel_flash").style.display = "block";
			document.getElementById("hotel_menu_droite").style.display = "block";
			document.getElementById("encart_photo").style.display = "block";
			document.getElementById("fond_parcours2").style.backgroundImage = 'url("imgv2/fonds/fond_parcours3.jpg")';
					
			document.getElementById("titre_aventure").innerHTML = titre_aventure;			
			document.getElementById("chapo_aventure").innerHTML = chapo_aventure;			
			document.getElementById("description_aventure").innerHTML = description_aventure;
			
			fleXenv.fleXcrollMain("aventures_scroll");
						
			if(carte == "1"){
				//document.getElementById("li_id_carte").style.display = "block";
				document.getElementById("id_carte").href = carte_url;
			}else{
				document.getElementById("li_id_carte").style.display = "none";
			}
			
			if(video_aventures != "none"){
				document.getElementById("id_videos").href = 'parcours_video.php?id_aventures='+id_aventures+'&iframe=true&width=1000&height=610';
			}else{
				document.getElementById("li_id_videos").style.display = "none";
			}
						
			document.getElementById("id_suggestions").href = 'parcours_suggestions.php?id_aventures='+id_aventures+'&iframe=true&width=1000&height=610';
			document.getElementById("id_photos").href = 'parcours_galerie.php?id_aventures='+id_aventures+'&iframe=true&width=100%&height=100%';
			document.getElementById("demande_devis").href = 'obtenir_devis_'+id_aventures+'.html';
				
			if(iti == ""){
				document.getElementById("conteneur_iti").style.display = "none";	
				document.getElementById("span_iti").style.display = "none";	
			}else{
				document.getElementById("id_itineraire_lie").innerHTML = '<a href="itineraire_luxe_'+id_aventures+'_'+url_rewrite_iti+'.html">'+iti+'</a>';
			}
								
			var hotel_id_tab = hotel_id_tab.split("_");
			var hotel_titre_tab = hotel_titre_tab.split("_-_");	
			var hotel_titre = hotel_titre.split("_-_");	
				
						
			if((hotel_titre.length - 1) <= 0){
				document.getElementById("conteneur_hotels").style.display = "none";		
				document.getElementById("span_hotels").style.display = "none";		
			}else{
				for(i = 0; i < hotel_titre.length - 1 ; i++){
					document.getElementById("id_hotels_lie").innerHTML += '<li><a href ="hotel-luxe_'+id_aventures+'_'+id_destination+'_'+hotel_id_tab[i]+'_'+hotel_titre_tab[i]+'.html">'+hotel_titre[i]+'</a></li>';
				}
			}
			if((hotel_titre.length - 1) <= 0 && iti == ""){
				document.getElementById("proximite").style.display = "none";			
			}
						
			var tab_img = tab_img.split("_");
			
			if(tab_img[0] == ""){		
				document.getElementById("div_img_1").innerHTML = "";	
				document.getElementById("div_img_2").innerHTML = "";
				document.getElementById("div_img_3").innerHTML = "";
				document.getElementById("div_img_4").innerHTML = "";	
				document.getElementById("li_id_photos").style.display = "none";				
			}else{
				document.getElementById("img_1").src = 'medias/aventures/light/'+tab_img[0]+'.jpg';
				document.getElementById("galerie_img_1").href = 'parcours_galerie.php?id_aventures='+id_aventures+'&iframe=true&width=100%&height=100%';
			}
			if(tab_img[1] == ""){	
				document.getElementById("div_img_2").innerHTML = "";
				document.getElementById("div_img_3").innerHTML = "";
				document.getElementById("div_img_4").innerHTML = "";					
			}else{	
				document.getElementById("img_2").src = 'medias/aventures/light/'+tab_img[1]+'.jpg';
				document.getElementById("galerie_img_2").href = 'parcours_galerie.php?id_aventures='+id_aventures+'&iframe=true&width=100%&height=100%';
			}
			if(tab_img[2] == ""){		
				document.getElementById("div_img_3").innerHTML = "";
				document.getElementById("div_img_4").innerHTML = "";					
			}else{
				document.getElementById("img_3").src = 'medias/aventures/light/'+tab_img[2]+'.jpg';
				document.getElementById("galerie_img_3").href = 'parcours_galerie.php?id_aventures='+id_aventures+'&iframe=true&width=100%&height=100%';
			}
			if(tab_img[3] == ""){		
				document.getElementById("div_img_4").innerHTML = "";				
			}else{
				document.getElementById("img_4").src = 'medias/aventures/light/'+tab_img[3]+'.jpg';
				document.getElementById("galerie_img_4").href = 'parcours_galerie.php?id_aventures='+id_aventures+'&iframe=true&width=100%&height=100%';
			}		
		});
	}
}
