function WriteMoteur() {
    document.write('<iframe style="position:absolute; z-index:20;" id="moteur" scrolling="no" src="/include/MoteurHP.aspx?moteur=ski" width="555px" height="250px" frameborder="0"></iframe>');
}
/* fonction parametre URL */

function findUrl(txt)
{
  var url=window.location.href;
  var urlSplit=url.split(/[?&]/);
  for (var i=1; i<urlSplit.length; i++) 
   if (urlSplit[i].indexOf(txt + "=") > -1 )
   {
    var aParam = urlSplit[i].split("=");
    return aParam[1];
   }
  return "";
 }
// Parametre pour le hearde dynamique
function findUrlIframe(txt)
{
    if ( window.parent.location.href ) {
      var url=window.parent.location.href;
      var urlSplit=url.split(/[?&]/);
      for (var i=1; i<urlSplit.length; i++) 
       if (urlSplit[i].indexOf(txt + "=") > -1 )
       {
        var aParam = urlSplit[i].split("=");
        return aParam[1];
       }
      return "";
      }
 }
 /* fonction parametre URL POUR UN IFRAME*/
function menuH(){
			switch(note){
			case '1' :document.getElementById('menu1').className="menu-selection1";break;
			case '2' :document.getElementById('menu2').className="menu-selection";break;
			case '3' :document.getElementById('menu3').className="menu-selection";break;
			case '4' :document.getElementById('menu4').className="menu-selection";break;
			case '5' :document.getElementById('menu5').className="menu-selection";break;
			case '6' :document.getElementById('menu6').className="menu-selection";break;
			case '7' :document.getElementById('menu7').className="menu-selection";break;
			default :document.getElementById('menu1').className="menu-selection1";}
}

// function evoie email
function bodyOnLoad()
{
IsEmailOk('Votre inscription a bien %E9t%E9 prise en compte.', 'Une erreur est survenue, veuillez r%E9essayer ult%E9rieurement.');
}

//function pour les onglets page produit
function changeCouleurInit(ta,tp,tb,tc)
{
document.getElementById(ta).className=tp;
document.getElementById(tb).className=tc;
}
//foncion pour le changement d'images du menu de la page produit
function changeCouleur(ta,to,tb,tc,tu,tp,te,ti,tz,tr)
{
document.getElementById(ta).className=tp;
document.getElementById(to).className=te;
document.getElementById(tb).className=ti;
document.getElementById(tc).className=tz;
document.getElementById(tu).className=tr;
}
function changeCouleur2(ta,to,tb,tc,tu,tp,te,ti,tz,tr)
{
document.getElementById(ta).className=tp;
document.getElementById(to).className=te;
document.getElementById(tb).className=ti;
document.getElementById(tc).className=tz;
document.getElementById(tu).className=tr;
}
// fonction pour le changement de titre, passe de FORMULE a OPTION et affiche ou cache l'onglet Cure

//fonction page derniere minute pour afficher ou cacher une div ID
function display(divcache, divaffiche)
{
	document.getElementById(divcache).style.display="none";
	document.getElementById(divaffiche).style.display="block";
}
//function pour les onglets de la page dm j-14
function changeColor()
{
	document.getElementById("j-7").innerHTML="<img src='/images/derniere-minute/j-7.jpg' onmouseout='this.src=\"/images/derniere-minute/j-7.jpg\"' onmouseover='this.src=\"/images/derniere-minute/j-7_hover.jpg\"'/>";
	document.getElementById("j-14").innerHTML="<img src='/images/derniere-minute/j-14_hover.jpg'/>";
}
//function pour les onglets de la page dm j-7
function changeColor2()
{
	document.getElementById("j-7").innerHTML="<img src='/images/derniere-minute/j-7_hover.jpg'/>";
	document.getElementById("j-14").innerHTML="<img src='/images/derniere-minute/j-14.jpg' onmouseout='this.src=\"/images/derniere-minute/j-14.jpg\"' onmouseover='this.src=\"/images/derniere-minute/j-14_hover.jpg\"'/>";
}
//fonction page OP pour afficher ou cacher une div ID
function display1(divcache1,divcache2, divaffiche)
{
	document.getElementById(divcache1).style.display="none";
	document.getElementById(divcache2).style.display="none";
	document.getElementById(divaffiche).style.display="block";
	
}


// FONCTION POUR LE DIAPORAMA DEROULANT DE LA PAGE PRODUIT RESIDENCE

var scrollTimer_1;
var scrollTimer2_1;
var scrollPas_1 = 10;
var scrollNB_1;

function stopScroll_1() 
{
	if(scrollTimer_1)clearTimeout(scrollTimer_1);
}
// stop scrolling autiomatique
function stopScroll2_1() 
{
	if(scrollTimer2_1)clearTimeout(scrollTimer2_1);
}
// go scrolling fleche
function scrollUp_1(px) 
{
	var div = document.getElementById("diapoScroll");
	div.scrollLeft = div.scrollLeft+px;
	scrollTimer_1 = setTimeout("scrollUp_1("+px+")", 30);
}
 
// go scrolling fleche
function scrollLeft_1(px) 
{
	var div = document.getElementById("diapoScroll");
	div.scrollUp = div.scrollUp+px;
	scrollTimer_1 = setTimeout("scrollLeft_1("+px+")", 30);
}

// go scrolling forward automatique
function scrollF_1() 
{
	if(scrollNB_1 <= 0)
		stopScroll2_1();
	else
	{
		var div = document.getElementById("diapoScroll");
		div.scrollLeft = div.scrollLeft+scrollPas_1;
		scrollNB_1--;
		scrollTimer2_1 = setTimeout("scrollF_1()", 30);
	}
}
// go scrolling backward automatique
function scrollB_1() 
{
	if(scrollNB_1 <= 0)
		stopScroll2_1();
	else
	{	
		var div = document.getElementById("diapoScroll");
		div.scrollLeft = div.scrollLeft-scrollPas_1;
		scrollNB_1--;
		scrollTimer2_1 = setTimeout("scrollB_1()", 30);
	}
}
// FONCTION POUR LE DIAPORAMA DEROULANT DE LA PAGE PRODUIT STATION

var scrollTimer_2;
var scrollTimer2_2;
var scrollPas_2 = 10;
var scrollNB_2;

function stopScroll_2() 
{
	if(scrollTimer_2)clearTimeout(scrollTimer_2);
}
// stop scrolling autiomatique
function stopScroll2_2() 
{
	if(scrollTimer2_2)clearTimeout(scrollTimer2_2);
}
// go scrolling fleche
function scrollUp_2(px) 
{
	var div = document.getElementById("diapoScroll_st");
	div.scrollLeft = div.scrollLeft+px;
	scrollTimer_2 = setTimeout("scrollUp_2("+px+")", 30);
}
// go scrolling forward automatique
function scrollF_2() 
{
	if(scrollNB_2 <= 0)
		stopScroll2_2();
	else
	{
		var div = document.getElementById("diapoScroll_st");
		div.scrollLeft = div.scrollLeft+scrollPas_2;
		scrollNB_2--;
		scrollTimer2_2 = setTimeout("scrollF_2()", 30);
	}
}
// go scrolling backward automatique
function scrollB_2() 
{
	if(scrollNB_2 <= 0)
		stopScroll2_2();
	else
	{	
		var div = document.getElementById("diapoScroll_st");
		div.scrollLeft = div.scrollLeft-scrollPas_2;
		scrollNB_2--;
		scrollTimer2_2 = setTimeout("scrollB_2()", 30);
	}
}
function changeOnglet(a,b,c,d,e,f,g,h){
		document.getElementById(a).className=b;
		document.getElementById(c).className=d;
		document.getElementById(e).className=f;
		document.getElementById(g).className=h;
}

// fonction pour le menu sur la HP
function slide(a,b,c,d){
	document.getElementById(a).style.display="block";
	document.getElementById(b).style.display="none";
	document.getElementById(c).style.display="none";
	document.getElementById(d).style.display="none";
}
function slide2(a,b,c){
	document.getElementById(a).style.display="block";
	document.getElementById(b).style.display="none";
	document.getElementById(c).style.display="none";
}
//function pour afficher le lire la suite dans la page produit
function opendiv(id,id2){
	if (document.getElementById(id).style.height != ""){
		document.getElementById(id).style.height="";
		document.getElementById(id2).innerHTML="Masquer la suite";
	}
	else
	{
		document.getElementById(id).style.height="153px";
		document.getElementById(id2).innerHTML="Lire la suite";	
	}
	
}
function cacheshow(div){
	if (document.getElementById(div).style.display=='none')
		{
		document.getElementById(div).style.display='block';	
		}
	else
		{
		document.getElementById(div).style.display='none';	
		}
}
function cacheshowImg(div,divimg,srchover,src){
	if (document.getElementById(div).style.display=='none')
		{
		document.getElementById(div).style.display='block';	
		document.getElementById(divimg).src =srchover;
		}
	else
		{
			document.getElementById(div).style.display='none';	
		document.getElementById(divimg).src =src;
		}
}
function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre)
{
window.open (nom_de_la_page, nom_interne_de_la_fenetre, config='top=400, left=400, height=450, width=600, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}
//fonction pour remplacer des parametre dans un chaine
function str_replace(cherche,remplace,chaine)
{   
  		while(chaine.indexOf(cherche)>-1)	
		{   
			chaine = chaine.replace(cherche,remplace);   
		}   
  		return chaine;   
}
function withaccent(chaineAcc) {
  chaineAcc = str_replace("%20"," ", chaineAcc);
  chaineAcc = str_replace("%c3%a9", "&eacute;", chaineAcc);
  chaineAcc = str_replace("%c3%b4", "&ocirc;", chaineAcc);
  chaineAcc = str_replace("%c3%a8", "&egrave;", chaineAcc);
  chaineAcc = str_replace("%c3%a2", "&acirc;", chaineAcc);
  chaineAcc = str_replace("%c3%a0", "&agrave;", chaineAcc);
  chaineAcc = str_replace("%c3%aE", "&icirc;", chaineAcc);
  chaineAcc = str_replace("%c3%a7", "&ccedil;", chaineAcc);
  
  return chaineAcc;
}
//fonction dans les list_heb pour afficher les distances  pour le moteurv3
var lihe_id = findUrl('lihe_id');
var lieu_id = findUrl('lieu_id');
var prest_id = findUrl('prest_id');
var pack_id = findUrl('pack_id');
var distance = findUrl('distance');
var nomDistance = "nomDistance_"+lihe_id+"_"+prest_id+"_"+pack_id;
var distNom = "distNom_"+lihe_id+"_"+prest_id+"_"+pack_id;

var lieunomUrl = findUrl('lieu_nom').toUpperCase();//la variable "lieu_nom" dans l'url et en majuscule
lieunomUrl = str_replace("%20"," ",lieunomUrl);// remplace la variable "lieu_nom" en enelevant les %20 (les espaces)

var lieunom = findUrlIframe('lieunom'); //la variable "lieunom" dans l'url parent de l'iframe
	lieunom = withaccent(lieunom);
var lieunomMaj = lieunom.toUpperCase();//change la variable "lieunom" en majuscule

function affiProxi(nomDistance,distNom,distance,lieunomUrl)
{
	//si la distance vaut 0,00 on cache tout 
	if(distance == "0,00"){
		if(window.parent.$(nomDistance))
		{
				window.parent.$(nomDistance).style.display="none";
		}
		}
	//si distance vaut rien alors on cache tout
	if (distance != "")
	{
		if(window.parent.$(nomDistance))
		{
		window.parent.$(nomDistance).style.visibility="visible";
		window.parent.$(distNom).innerHTML=lieunom;
		}
	}
	//si la varibale "lieu_nom" dans l'url et egal a la variable "lieunom" dans l'url PARENT alors on cache toute la div
	if (lieunomUrl == lieunomMaj)
	{
		if(window.parent.$(nomDistance))
		{
	window.parent.$(nomDistance).style.visibility="hidden";
		}
	}
}
//fonction reziseMe pour la page List_Heb  pour resizer l'iframe de la page results + javascript en innerHTML
var idprixMin = "prixmin_"+lihe_id+"_"+prest_id+"_"+pack_id;
var idmoyenne = "moyenne_"+lihe_id+"_"+prest_id+"_"+pack_id; 
var divavis= "avis_results_"+lihe_id+"_"+prest_id+"_"+pack_id;
var idnbenote = "nbenote_"+lihe_id+"_"+prest_id+"_"+pack_id;
var idtauxpromo = "tauxpromo_"+lihe_id+"_"+prest_id+"_"+pack_id;
var idPrixMinBarre = "PrixMinBarre_"+lihe_id+"_"+prest_id+"_"+pack_id;
var apartir = "idapartir_"+lihe_id+"_"+prest_id+"_"+pack_id;
var offre_heb = "offre_resultat_"+prest_id+"_"+lihe_id;
function reziseMe(id,idprixMin,idmoyenne,divavis,idnbenote,idtauxpromo,idPrixMinBarre)
{
		height = $('ListeHebergement').getHeight();
			if(window.parent.resizeIframe)
			{
            	window.parent.resizeIframe(id, height);
			}
			// prix min barre
            if (window.parent.$(idPrixMinBarre)) window.parent.$(idPrixMinBarre).innerHTML = prixMinBarre;
            // taux
            if (window.parent.$(idtauxpromo)) window.parent.$(idtauxpromo).innerHTML = tauxpromo;
            // prix min
            if (window.parent.$(idprixMin)) window.parent.$(idprixMin).innerHTML = prixMin;
			// moyenne avis
            if (window.parent.$(idmoyenne)) window.parent.$(idmoyenne).innerHTML = moyenne;
			// nbe de note avis
            if (window.parent.$(idnbenote)) window.parent.$(idnbenote).innerHTML = nbenote;
			
			if (nbenote=="0"){
				if (window.parent.$(divavis))
				{
						window.parent.$(divavis).style.display="none";
				}
			}		
                                             
            if(window.parent.$(idtauxpromo))
			{  
				if(tauxpromo==100){
					window.parent.$(idtauxpromo).style.display = 'none';
				}
				if ((prixMin==prixMinBarre || tauxpromo<=0) && window.parent.$(idtauxpromo).up()) {
				 // on masque le span promo
				 window.parent.$(idtauxpromo).up().style.display = 'none';
				 window.parent.$(idPrixMinBarre).style.display = 'none';
				} 
			}
				

} 

//fonction pour l'inscription a la newsletter avec ouverture dans une lytebox
function openDL(){
var trez = document.forms["Form1"].elements["email"].value;
//myLytebox.start("<a /newsletter/inscription-newsletter.html?mail="+trez, false, true);
document.getElementById('okA').href="/newsletter/inscription.html?mail="+trez;
}
//function pour faire disparaitre les imput (pour la lytebox sur ie6)
function disableInput()
{
	if(document.all)
	{
		var selectDis = document.getElementsByTagName("select");
		for (i = 0; i < selectDis.length; i++)
		{
			selectDis[i].style.visibility = "hidden";
		}
	}
}
//function pour faire afficher les imput (pour la lytebox sur ie6)
function showInput(){
	if(document.all){
	var selectDis = document.getElementsByTagName("select");
for (i = 0; i < selectDis.length; i++) {
selectDis[i].style.visibility = "visible";}}
}

//-----------*--------- TAG Horizon media --------------------------------
sas_tmstp=Math.round(Math.random()*10000000000);sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
 	if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};
 		document.write('<scr'+'ipt src="http://ads.horyzon-media.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/' + sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></scr'+'ipt>');
}
sas_pageid='15515/126558';	// Page : Travelfactory.Declicfrance.fr/hp
sas_formatid=6325;		// Format : MegaBanniere 728x90
sas_target='';			// Targeting
//SmartAdServer(sas_pageid,sas_formatid,sas_target);
//-----------*---------

function Popup(href,titre) {
	   window.open(href,titre,'toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=620, height=500');
}
//-----------*--------- POP UP PRIX GARANTIS --------------------------------
function PopupPG() {
	   window.open('/popupprixgarantis.aspx','prix_garantis','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=620, height=500');
}
		

/* remplace les accents */
   function noaccent(chaineAcc) {
      chaineAcc = chaineAcc.replace(/[aâä]/g,"a")
      chaineAcc = chaineAcc.replace(/[éeeë]/g,"e")
      chaineAcc = chaineAcc.replace(/[îi]/g,"i")
      chaineAcc = chaineAcc.replace(/[ôö]/g,"o")
      chaineAcc = chaineAcc.replace(/[uuü]/g,"u")
	  
	  return chaineAcc;
   }
   function nochiffre(chaineAcc) {
	   if ( chaineAcc.match(/[0123456789]/g,"") )
	   	return true;
		else return false;
   }
   function nolettre(chaineAcc) {
	   if ( chaineAcc.match(/[A-Za-z]/g,"") )
	   	return true;
		else return false;
   }
		
/* fonction liens js DF Mag */
function navTo (target) {

	var getTarget = target.replace(/[éeeë]/g,"e");
	var getPage = getTarget;

window.open(getPage, '_self');
}
function readMore (article) {
window.open('/mag/articles/'+article+'.html', '_self');	
}

/* Utiliser pour simuler un lien dynamique */ 
function Vide() { }

/* Filtre recherche ville */
function CheckVille() {
	var lieu = document.getElementById("MT3_MT3Lieu").value;
	document.getElementById("MT3_MT3Lieu").value = noaccent(document.getElementById("MT3_MT3Lieu").value);
	if ( nochiffre(lieu) && nolettre(lieu) == false ) {
		alert("Veuillez saisir le lieu de vos vacances en toutes lettres. Les chiffres ne sont pas autorisés.");
	}
}
/* fonction pour remplir la date dans le moteur_v3  */
function dateAll(){
	if(document.getElementById("MT3_MT3Date_dateInput_text")){
		if(document.getElementById("MT3_MT3Date_dateInput_text").value=="") {
			document.getElementById("MT3_MT3Date_dateInput_text").value="Date de Depart";
		}
	}
	if(document.getElementById("MT32_MT3Date_dateInput_text")){
		if(document.getElementById("MT32_MT3Date_dateInput_text").value=="") {
			document.getElementById("MT32_MT3Date_dateInput_text").value="Date de Depart";
		}
	}
}
function PopupFlash(lien) {
	window.open(lien,"cgv","menubar=no, status=no, scrollbars=yes, menubar=no, width=640, height=400");
}

/* Gestion du moteur perso Declic */
// Fonction trim bien utile
var regExpBeginning = /^\s+/;
var regExpEnd = /\s+$/; 
function trim(aString) {

    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

// Permet de faire un trie numérique
function sortfunction(a, b){
	return (a - b);
}

function SwitchSelect(id,div,stance) {
    // On choisit la bonne valeur et on réaffiche le select
	if ( stance == 1 ) {
	
		for ( var i = 0; i < eval("document.form1."+id+".options.length"); i++ ) {
		    if ( eval("document.form1."+id+".options["+i+"].value") == $(id).getValue() ) {
		    
		        eval("document.form1."+id+".options["+i+"].selected = true");
		        eval("document.form1."+id+".style.display = 'inline'");
				document.getElementById(div).innerHTML = "";
				
		    }
		}
    } else if ( stance == 3 ) { // On reset le select
        for ( var i = 0; i < eval("document.form1."+id+".options.length"); i++ ) {
		    if ( eval("document.form1."+id+".options["+i+"].value") == 0 ) {
		    
		        eval("document.form1."+id+".options["+i+"].selected = true");
		        eval("document.form1."+id+".style.display = 'inline'");
				document.getElementById(div).innerHTML = "";
				
		    }
		}
    } else { // On écrit la sélection en dur (sans select)
		// On check si la selection est correct
		if ( eval("document.form1."+id+".options[document.form1."+id+".selectedIndex].value") != 0 ) {
			var selection = eval("document.form1."+id+".options[document.form1."+id+".selectedIndex].text.trim()")
		    var appel = 'SwitchSelect(\''+id+'\', \''+div+'\', 1)';
		    var reset = 'SwitchSelect(\''+id+'\', \''+div+'\', 3)';
		    var modifier = '<a href="javascript:Vide()" onclick="'+appel+'">modifier</a><a class="reset" href="javascript:void(0);" onclick="'+reset+'">X</a>';
			
			eval("document.form1."+id+".style.display = 'none'");
			
			//if ( eval("document.form1."+id+".options.length") > 2 ) // Si le champ à plusieurs choix on affiche le lien "modifier"
			    document.getElementById(div).innerHTML = selection+modifier;
			//else
			//    document.getElementById(div).innerHTML = selection;
        }
    }
}
/* ============================ */
function ScanCookie(variable)
{
	cook = document.cookie;
	variable += "=";
	place = cook.indexOf(variable,0);
	if (place <= -1)
		return("0");
	else {
		end = cook.indexOf(";",place)
		if (end <= -1)
			return(unescape(cook.substring(place+variable.length,cook.length)));
		else
		return(unescape(cook.substring(place+variable.length,end)));
	}
}

function CreationCookie(nom,valeur)
{

	dateExp = new Date();
	dateExp.setHours(dateExp.getHours() + 24);
	dateExp = dateExp.toGMTString();
	ifpermanent = '; expires=' + dateExp + ';';

	document.cookie = nom + '=' + escape(valeur) + ifpermanent;
}

function drawFinAttente()
{
	$("prehome").hide();
}

function drawAttente()
{
	if (ScanCookie("declic_prehome") == 0)
	{
		CreationCookie("declic_prehome", "oui");
		$("prehome").show();	
	}
} 

function prodLink (prest_id, date_debut, duree) {
window.open('/produit.aspx?prest_id='+prest_id+'&date='+date_debut+'&duree='+duree, '_self');	
}
