// JavaScript Document
// Initialisation pour la banniere avec fondu et la pub
function init_ban(){
	// Désactivé pendant l'habillage cdm
	RunSlideShow("header","blendimage","./images/en_fond1.jpg;./images/en_fond2.jpg",5);
}

// Mise en place du timer pour le changement de fond de la bannière
// Ancienne fonction !
function timer() {
	change_fond(1);
	setTimeout("timer()",10000);
};

// Initialisation pour la lightBox
function init_lightbox(){
	window.addEvent('domready', function(){
    new SexyLightBox({find:'sexylightbox'});
  	});
}

// Initialisation pour l'effet sur le panneau "plus de tarif"
function init_tarif(){
	window.addEvent('domready', function() {
	var el = $('tarif');
	
	$('tarif').addEvent('click', el.fade.bind(el, [0]));
	
	$('tweenOpacity').addEvent('click', function(e) {
		e.stop();
		el.fade(1);
	});
	});
	
	// masque le panneau "plus de tarif" lors du chargement de la page
	$('tarif').fade('hide');
}


// Calendrier pour moteur de recherche sejour et circuit
var CL = new GnooCalendar("CL", 0, 1 );
// Calendrier pour moteur de recherche rapide menu gauche
var CL2 = new GnooCalendar("CL2", 0 ,1);

// initialisation des calendriers
function init()
{
	if (typeof(document.forms["recherche"]) != "undefined"){
		CL.init("calend", document.forms["recherche"].elements["date"]);
		CL.setTitle("Calendrier");
	}
	
	if (typeof(document.forms["form1"]) != "undefined"){
		CL2.init("calend2",document.forms["form1"].elements["date"]);
		CL2.setTitle("Calendrier");
	}
}


// Fonction pour ajuster la hauteur de la partie centrale
// avec les 2 parties gauche et droite
function HeightAjust(){

	// test si la hauteur de la partie centrale est plus petite que celle du menu gauche
	if (getHauteur('centre') <= getHauteur('menu_g_centre')){
		// si oui on allonge la partie centrale
		document.getElementById("centre").style.height = getHauteur('menu_gauche')-10+"px";
	}
	else{
		// si elle est plus grande alors on allonge le menu gauche et droit
		document.getElementById("menu_g_centre").style.height = getHauteur('centre')-10+"px";
		document.getElementById("menu_d_centre").style.height = getHauteur('centre')+"px";
	}
}

// Fonction d'ouverture d'un pop up pour les 
// conditions tarifaires d'un circuit
function open_popup(page){
	 window.open(page,"","menubar=no, status=no, scrollbars=yes, width=650");
}

function change_fond(i) {
	var chemin="url(images/en_fond"+i+".jpg) no-repeat top right";
	//alert(chemin);
	document.getElementById("entete").style.background=chemin;
	document.getElementById("entete").style.margin=0;
	document.getElementById("entete").style.padding=0;
	//document.getElementById("entete").style.width=955;
	//document.getElementById("entete").style.height=132;
	//background : url(images/en_fond1.jpg) no-repeat top right;
		//document.getElementById("entete").style.backgroundPosition="top right";
		i++;
		if(i!=3)
			{
				
				setTimeout("change_fond("+i+")",5000);
			}
		
	};
function recharge_mere_popup(nom,id,element)
	{
		alert("titititi");
		var o=new Option(nom,id);
		alert(o);
		window.opener.document.forms["form_hotel"].elements[element].options[window.opener.document.forms["form_hotel"].elements[element].options.length]=o;
		//window.opener.document.forms["form_hotel"].elements["pays"].value=choix;
	}
function recharge_lstpara(titre,id,texte)
	{
		alert("titititi");
		var o=new Option(nom,id);
		alert(o);
		window.opener.document.forms["form_hotel"].elements[element].options[window.opener.document.forms["form_hotel"].elements[element].options.length]=o;
		//window.opener.document.forms["form_hotel"].elements["pays"].value=choix;
	}
	
function OuvrirPopup(page,nom,option) {
  window.open(page,nom,option);
}

// Retourne la hauteur en pixel de l'element id_name
function getHauteur(id_name){
	var divHeight;
	var obj = document.getElementById(id_name);
	
	if(obj.offsetHeight)          {divHeight=obj.offsetHeight;}
	else if(obj.style.pixelHeight){divHeight=obj.style.pixelHeight;}
	return divHeight;
}
//fonction lié à la reservation 
//actualise le tableau des chambre
function actualise_select(balise_recup,balise_mod,numero_chambre){
	var id_objet=document.getElementById(balise_recup).options[document.getElementById(balise_recup).selectedIndex].value;
	if(id_objet!="---")
		{
		//fonction ajax qui passe a la page l'identifiant et le type de photo (hotel, chambre,...)
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "maj_tableau_resa.php?idobjet="+id_objet+"&numero_chambre="+numero_chambre, true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
				//alert(xhr_object.responseText);
				document.getElementById(balise_mod).innerHTML = "";
				document.getElementById(balise_mod).innerHTML = xhr_object.responseText;
			}
		}

		xhr_object.send(null); 
	}
	else
	{
	alert("Veuilez faire un choix");
	}
}
//actualise l'affcihage des enfants
function affcihage_enfant(balise_recup,numero_chambre){
	var type=document.getElementById(balise_recup).options[document.getElementById(balise_recup).selectedIndex].value;
	//alert(document.getElementById("nb_adulte"+numero_chambre).options[document.getElementById("nb_adulte"+numero_chambre).selectedIndex].value);
	switch(type)
		{
			case '0':document.getElementById("partage"+numero_chambre).style.display="none"; document.getElementById("separe"+numero_chambre).style.display="none"; break;
			case '1':
					if(document.getElementById("nb_adulte"+numero_chambre).options[document.getElementById("nb_adulte"+numero_chambre).selectedIndex].value==2 || document.getElementById("nb_adulte"+numero_chambre).options[document.getElementById("nb_adulte"+numero_chambre).selectedIndex].value==1)
						{
							document.getElementById("partage"+numero_chambre).style.display=""; 
							document.getElementById("separe"+numero_chambre).style.display="none";
						}
					else
						{
							alert("Il faut 1 ou 2 adultes pour pouvoir utiliser cette option.");
							document.getElementById(balise_recup).selectedIndex=0;
							document.getElementById("partage"+numero_chambre).style.display="none"; 
							document.getElementById("separe"+numero_chambre).style.display="none";
						} 
					break;
			case '2':
					if(document.getElementById("nb_adulte"+numero_chambre).options[document.getElementById("nb_adulte"+numero_chambre).selectedIndex].value==0)
						{
							
							document.getElementById("partage"+numero_chambre).style.display="none";
							
							document.getElementById("separe"+numero_chambre).style.display="";
						}
					else
						{
							alert("Le nombre d'adulte doit etre à 0 pour cette option.");
							document.getElementById(balise_recup).selectedIndex=0;
							document.getElementById("partage"+numero_chambre).style.display="none"; 
							document.getElementById("separe"+numero_chambre).style.display="none";
						}
					 break;
		}
	
}
//actualise le nombre d'adulte en prenant compte des enfant
function affichage_adulte(balise_recup,numero_chambre){
	document.getElementById("enfant"+numero_chambre).selectedIndex=0;
	document.getElementById("partage"+numero_chambre).style.display="none"; 
	document.getElementById("separe"+numero_chambre).style.display="none";
	
}
//ajout d'une chambre
function ajout_ligne_chambre(nb_chambre_actu){
	//test si la dernier chambre est renseigner avant d'en ajouter une nouvelle
	if((document.getElementById("nb_adulte"+nb_chambre_actu)!=null && document.getElementById("nb_adulte"+nb_chambre_actu).selectedIndex==0 && document.getElementById("enfant"+nb_chambre_actu).value==2) || (document.getElementById("nb_adulte"+nb_chambre_actu)!=null && document.getElementById("nb_adulte"+nb_chambre_actu).selectedIndex>0 && document.getElementById("enfant"+nb_chambre_actu).value<2) || (document.getElementById("nb_unite"+nb_chambre_actu)!=null && document.getElementById("nb_unite"+nb_chambre_actu).value>=1)){
	var nouveau_numero=nb_chambre_actu+1;
		//fonction ajax qui passe a la page l'identifiant et le type de photo (hotel, chambre,...)
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "maj_tableau_resa.php?idobjet=0&ajout="+nouveau_numero, true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
				//alert(xhr_object.responseText);
				document.getElementById("chmb"+nouveau_numero).innerHTML = "";
				document.getElementById("chmb"+nouveau_numero).innerHTML = xhr_object.responseText;
				document.getElementById("chmb"+nouveau_numero).style.display=""; 
				var bouton_ajout="";
				var bouton_sup="";
				if(nouveau_numero<5)
					{
						bouton_ajout = '<input name="ajout_chambre" type="button" id="ajout_chambre" value="" onClick="ajout_ligne_chambre('+nouveau_numero+');">';
					}
				else
					{
						bouton_ajout ="";
					}
				if(nouveau_numero>1)
					{
						bouton_sup = '<input name="sup_chambre" type="button" id="sup_chambre" value="" onClick="sup_chambre_ligne_chambre('+nouveau_numero+');">';
					}
				else
					{
						bouton_sup ="";
					}
				document.getElementById("bouton_chbre").innerHTML = bouton_ajout+bouton_sup;
			}
		}

		xhr_object.send(null); 
	}
	else
		{
			alert("Vous devez renseigner la chambre avant de pouvoir en rajouter une nouvelle.");
		}
	
}
function sup_chambre_ligne_chambre(nb_chambre_actu){
	nouveau_numero=nb_chambre_actu-1;
	document.getElementById("chmb"+nb_chambre_actu).innerHTML = "";
	document.getElementById("chmb"+nb_chambre_actu).style.display="none";
	var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "sup_ligne_tableau.php", true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
	var bouton_ajout="";
				var bouton_sup="";
				if(nouveau_numero<5)
					{
						bouton_ajout = '<input name="ajout_chambre" type="button" id="ajout_chambre" value="" onClick="ajout_ligne_chambre('+(nouveau_numero)+');">';
					}
				else
					{
						bouton_ajout ="";
					}
				if(nouveau_numero>1)
					{
						bouton_sup = '<input name="sup_chambre" type="button" id="sup_chambre" value="" onClick="sup_chambre_ligne_chambre('+(nb_chambre_actu-1)+');">';
					}
				else
					{
						bouton_sup ="";
					}
				document.getElementById("bouton_chbre").innerHTML = bouton_ajout+bouton_sup;
				}}
				xhr_object.send(null); 
}
function crea_tableau(nnbr_option,nselect_index,nvaleur_first_option,nvaleur_last_option) {
    this.nbr_option = nnbr_option;
    this.select_index = nselect_index;
    this.valeur_first_option = nvaleur_first_option;
	this.valeur_last_option = nvaleur_last_option;
  }
function verif_enfant(numero_chambre,indice_tranche,indice_select){
	//determine si on travaille avec les chambre partage ou separer
	//alert("enfant"+numero_chambre+" ="+document.getElementById("enfant"+numero_chambre).selectedIndex);
	if(document.getElementById("enfant"+numero_chambre).value==1)
		{
			//cas de la chambre partager
			//var tableau_select=new Array();
			var tableau_tranche=new Array(5);
			//recuperation de chaque contenu de chaque select dans un tableau
			//alert("taille du div partage"+numero_chambre+"  "+document.getElementById("partage"+numero_chambre).childNodes.length);
			var nb_tranche=Math.round((document.getElementById("partage"+numero_chambre).childNodes.length-1)/3);
			//alert(document.getElementById("partage"+numero_chambre).childNodes[1]);
			//affiche les valeur de chaque tranche
			var numero_tranche=0;
			var tranche="";
			var selected=0;
			for(i=1;i<document.getElementById("partage"+numero_chambre).childNodes.length-1;i=i+3)
				{
					
					//recherche le nombre d'option ainsi que la valeur de la premeire option de chaque select
					var nb_option=Math.round((document.getElementById("partage"+numero_chambre).childNodes[i].childNodes.length-1)/2);
					var valeur_first_option=document.getElementById("partage"+numero_chambre).childNodes[i].childNodes[1].value;
					
					tableau_tranche[numero_tranche]= new crea_tableau(nb_option,document.getElementById("partage"+numero_chambre).childNodes[i].selectedIndex,valeur_first_option,nb_option-1);
					if((document.getElementById("partage"+numero_chambre).childNodes[i].name!="tranche"+indice_tranche+"_p"+indice_select) && (document.getElementById("partage"+numero_chambre).childNodes[i].selectedIndex!=0))
						{
							//un des select n'est pas à 0
							selected=1;
						}
						numero_tranche++;
				}
				
				
				//teste si un des select est different de 0
				if(selected==0)
					{
						//pas de selectionj dans d'autres select
						//verifie si c le max
						if(document.getElementById("tranche"+indice_tranche+"_p"+indice_select).selectedIndex==tableau_tranche[indice_select].valeur_last_option)
							{
								//valeur max
								//alert("valeur max selectionner");
								for(a=0;a<nb_tranche;a++)
									{
										if(a!=indice_select)
											{
											document.getElementById("tranche"+indice_tranche+"_p"+a).disabled =true;
											}
									}
							}
						else
							{
							if(document.getElementById("tranche"+indice_tranche+"_p"+indice_select).selectedIndex==tableau_tranche[indice_select].valeur_last_option)
								{
									//valeur max
									//alert("valeur min selectionner");
									for(a=0;a<nb_tranche;a++)
										{
											if(a!=indice_select)
												{
												document.getElementById("tranche"+indice_tranche+"_p"+a).disabled =false;
												}
										}
								}
							else
								{
									//alert("valeur du milieu selectionner");
									for(a=0;a<nb_tranche;a++)
										{
											if(a!=indice_select)
												{
													if(document.getElementById("tranche"+indice_tranche+"_p"+indice_select).selectedIndex<tableau_tranche[a].valeur_last_option)
														{
															document.getElementById("tranche"+indice_tranche+"_p"+a).disabled =false;
														}
													else
														{
															document.getElementById("tranche"+indice_tranche+"_p"+a).disabled =true;
														}
												
												}
										}
								}
							}
					}
				else
					{
						//cas s'il y a une tranche déja selectionner
						
						var valeur_max_possible=10;
						var nb_deja_selectionner=0;
						for(index=0;index<nb_tranche;index++)
							{
								if( tableau_tranche[index].select_index!=0)
									{
										if(tableau_tranche[index].valeur_last_option<valeur_max_possible)
											{
											valeur_max_possible=tableau_tranche[index].valeur_last_option;
											}
										if(indice_select!=index)
											{
												nb_deja_selectionner+=tableau_tranche[index].select_index;
											}
									}
									
							}
						if(document.getElementById("tranche"+indice_tranche+"_p"+indice_select).selectedIndex>(valeur_max_possible-nb_deja_selectionner))
							{
								alert("vous ne pouvez pas choisir cette valeur car vous depasser la capaciter possible de la chambre.");
								document.getElementById("tranche"+indice_tranche+"_p"+indice_select).selectedIndex=0;
							}

						else
							{
								//c ok on touche a rien
							}
						
					}
		}
	else
		{
			//cas de la chambre separer
			//cas de la chambre partager
			//var tableau_select=new Array();
			var tableau_tranche=new Array(5);
			//recuperation de chaque contenu de chaque select dans un tableau
			var nb_tranche=Math.round((document.getElementById("partage"+numero_chambre).childNodes.length-1)/3);
			//affiche les valeur de chaque tranche
			//alert(nb_tranche);
			var numero_tranche=0;
			var tranche="";
			var selected=0;
			for(i=1;i<document.getElementById("separe"+numero_chambre).childNodes.length-1;i=i+3)
				{
					
					//recherche le nombre d'option ainsi que la valeur de la premeire option de chaque select
					var nb_option=Math.round((document.getElementById("separe"+numero_chambre).childNodes[i].childNodes.length-1)/2);
					var valeur_first_option=document.getElementById("separe"+numero_chambre).childNodes[i].childNodes[1].value;
					//tableau_tranche[numero_tranche]=nb_option;
					//tableau_tranche[numero_tranche,1]=document.getElementById("partage"+numero_chambre).childNodes[i].selectedIndex;
					//tableau_tranche[numero_tranche,2]=valeur_first_option;
					//tableau_tranche[numero_tranche,3]=nb_option-1;
					
					tableau_tranche[numero_tranche]= new crea_tableau(nb_option,document.getElementById("separe"+numero_chambre).childNodes[i].selectedIndex,valeur_first_option,nb_option-1);
					
					//alert(numero_tranche+" last option "+tableau_tranche[numero_tranche].valeur_last_option);
					if((document.getElementById("separe"+numero_chambre).childNodes[i].name!="tranche"+indice_tranche+"_s"+indice_select) && (document.getElementById("separe"+numero_chambre).childNodes[i].selectedIndex!=0))
						{
							//un des select n'est pas à 0
							selected=1;
						}
						numero_tranche++;
					
					
					//alert(tableau_tranche[numero_tranche].join());
				}
				//alert(tableau_tranche.join());
				//alert(tableau_tranche.join());
				
				//teste si un des select est different de 0
				if(selected==0)
					{
						//pas de selectionj dans d'autres select
						//verifie si c le max
						if(document.getElementById("tranche"+indice_tranche+"_s"+indice_select).selectedIndex==tableau_tranche[indice_select].valeur_last_option)
							{
								//valeur max
								//alert("valeur max selectionner");
								for(a=0;a<nb_tranche;a++)
									{
										if(a!=indice_select)
											{
											document.getElementById("tranche"+indice_tranche+"_s"+a).disabled =true;
											}
									}
							}
						else
							{
							if(document.getElementById("tranche"+indice_tranche+"_s"+indice_select).selectedIndex==tableau_tranche[indice_select].valeur_last_option)
								{
									//valeur max
								//	alert("valeur min selectionner");
									for(a=0;a<nb_tranche;a++)
										{
											if(a!=indice_select)
												{
												document.getElementById("tranche"+indice_tranche+"_s"+a).disabled =false;
												}
										}
								}
							else
								{
									//alert("valeur du milieu selectionner");
									for(a=0;a<nb_tranche;a++)
										{
											if(a!=indice_select)
												{
													if(document.getElementById("tranche"+indice_tranche+"_s"+indice_select).selectedIndex<tableau_tranche[a].valeur_last_option)
														{
															document.getElementById("tranche"+indice_tranche+"_s"+a).disabled =false;
														}
													else
														{
															document.getElementById("tranche"+indice_tranche+"_s"+a).disabled =true;
														}
												
												}
										}
								}
							}
					}
				else
					{
						//cas s'il y a une tranche déja selectionner
						
						var valeur_max_possible=10;
						var nb_deja_selectionner=0;
						//alert("nb tranche"+nb_tranche);
						for(index=0;index<nb_tranche;index++)
							{
								if( tableau_tranche[index].select_index!=0)
									{
										if(tableau_tranche[index].valeur_last_option<valeur_max_possible)
											{
											valeur_max_possible=tableau_tranche[index].valeur_last_option;
											}
										if(indice_select!=index)
											{
												nb_deja_selectionner+=tableau_tranche[index].select_index;
											}
									}
									
							}
							//alert("valeur max possible"+valeur_max_possible+" nb deja selectionner"+nb_deja_selectionner)
						if(document.getElementById("tranche"+indice_tranche+"_s"+indice_select).selectedIndex>(valeur_max_possible-nb_deja_selectionner))
							{
								alert("vous ne pouvez pas choisir cette valeur car vous depasser la capaciter possible de la chambre.");
								document.getElementById("tranche"+indice_tranche+"_s"+indice_select).selectedIndex=0;
							}
						else
							{
								//c ok on touche a rien
							}
						
					}
		}
	
}
//page rchsej actualisation du select hotel selon pay
function actualise_hotel(){
	var id_objet=document.getElementById("pays").options[document.getElementById("pays").selectedIndex].value;
	//alert(id_objet);
		//fonction ajax qui passe a la page l'identifiant et le type de photo (hotel, chambre,...)
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "maj_select_hotel.php?pays="+id_objet, true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
				//alert(xhr_object.responseText);
				document.getElementById("select_hotel").innerHTML = "";
				document.getElementById("select_hotel").innerHTML = xhr_object.responseText;
			}
		}

		xhr_object.send(null); 
	
	
}
//page rchsej actualisation du select pays selon select sejour/pays sur menu recherche rapide
function actualise_select_pays(){
	var id_objet=document.getElementById("type").options[document.getElementById("type").selectedIndex].value;
	//alert(id_objet);
		//fonction ajax qui passe a la page l'identifiant et le type de photo (hotel, chambre,...)
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "maj_select_pays.php?type="+id_objet, true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
				//alert(xhr_object.responseText);
				document.getElementById("select_pays").innerHTML = "";
				document.getElementById("select_pays").innerHTML = xhr_object.responseText;
				if(id_objet==1)
					{
						document.getElementById("date_rr").style.display="";
					}
				else
					{
						document.getElementById("date_rr").style.display="none";
					}
			}
		}

		xhr_object.send(null); 
	
	
}
function fiche_pays(){
	
		//fonction ajax qui passe a la page l'identifiant et le type de photo (hotel, chambre,...)
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
 
		xhr_object.open("GET", "fiche_pays.php", true); 
 
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4) {
				//alert(xhr_object.responseText);
				document.getElementById("fiche_pays").innerHTML = "";
				document.getElementById("fiche_pays").innerHTML = xhr_object.responseText;
				document.getElementById("fiche_pays").style.display="";
			}
		}

		xhr_object.send(null); 
	
}
function showCountryCard(id)
{
	if (id != null && id.length != 0)
	{
		var floater = window.open('http://www.memopage.com/voyages/affilie/selectour/popme.php?pdf=' + id,'CountryCard','toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=550,height=600,left=50,top=50,resizable=yes');
		if (window.focus)
			floater.focus();
	}
}


function pub(nom_cookie){

	$("calque_pub").fade("hide");
	/*if((GetCookie(nom_cookie) == null) )
	{*/
		
		setTimeout(' show_pub();   ',3000);
		setTimeout('$("calque_pub").fade("1");   ',3500);
		//alert(nom_cookie);
		//var date_exp = new Date();
		//date_exp.setTime(date_exp.getTime()+(7*24*3600*1000));

		//SetCookie (nom_cookie, true,date_exp);
		setTimeout('hide_pub();',15000);
	//}
}

function show_pub(){
	$("calque_pub").morph("#calque_pub2");
	$("pubmaurice").morph("#pubmaurice2");
	$("closepub").morph("#closepub2");
	$("calque_pub").fade("0.5");
}

function hide_pub(){
	$("calque_pub").fade("out");
	$("calque_pub").morph("#calque_pub");
	$("pubmaurice").morph("#pubmaurice");
	$("closepub").morph("#closepub");
}

function show_aide(){
	document.getElementById("aide").style.visibility = 'visible'
	document.getElementById("f_ama").style.visibility = 'hidden';
	document.getElementById("aide").innerHTML =  '<div id="close_aide"><img src="images/closelabel2.gif" onClick="hide_aide();" alt="Fermer" /></div><div style="background:url(images/aide_load2.gif) no-repeat center"><OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="600" HEIGHT="495" CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"><PARAM NAME=movie VALUE="aide_vol/aide_vol.swf"><PARAM NAME=play VALUE=true><PARAM NAME=loop VALUE=false><PARAM NAME=quality VALUE=low><param name="wmode" value="transparent"></param><EMBED SRC="aide_vol/aide_vol.swf" WIDTH=600 HEIGHT=495 quality=low loop=false TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent"></EMBED></OBJECT></div>';
}

function hide_aide(){
	document.getElementById("aide").style.visibility = 'hidden';
	document.getElementById("f_ama").style.visibility = 'visible';
	document.getElementById("aide").innerHTML = '';
}


function SetCookie (name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}
function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
      		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
                        return getCookieVal (j);
                i=document.cookie.indexOf(" ",i)+1;
                        if (i==0) break;}
	return null;
}

// génère les stats de clic sur le lien passé en paramètre
function stats_clic(lien){
	var xhr_object = null;
	if(window.XMLHttpRequest) { // Firefox 
		xhr_object = new XMLHttpRequest();
	}
	else if(window.ActiveXObject) { // Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	}

	xhr_object.open("GET", "stats.php?lien="+lien, true); 

	xhr_object.onreadystatechange = function() { 
		if(xhr_object.readyState == 4) {
			//alert(xhr_object.responseText);
		}
	}
	xhr_object.send(null); 
}
