function oninit(){ 
    setScrollHorizontalOnDiv('div_visuActuBandeau','ul_actusBandeau',{nextButton:"bt_suivActuBandeau",prevButton:"bt_precActuBandeau"});     
    setScrollHorizontalOnLstGenerePage("div_uneDefilContent","ul_uneDefil",{idDivPastePage:"div_uneDefil",position:"top"});
    setScrollHorizontalOnLstGenerePage("div_promoDefilContent","ul_promoDefil",{idDivPastePage:"div_promoDefil",position:"top"});
    setActionSurOngletMoteur(); 
    setActionSurMenuHaut();
}

function favoris() {
  if ( navigator.appName != 'Microsoft Internet Explorer' )
  { window.sidebar.addPanel(document.title,"http://www.gites-de-france-cantal.com/",""); }
  else { window.external.AddFavorite("http://www.gites-de-france-cantal.com/",document.title); } 
}

function recupNbp(nbp,nbpMin,nbpMax){
  if(($(nbpMin).value=="")&&($(nbpMax).value!="")){
    $(nbp).value="<="+$(nbpMax).value;
  }
  else if(($(nbpMin).value!="")&&($(nbpMax).value=="")){
    $(nbp).value=">="+$(nbpMin).value;
  }
  else if(($(nbpMin).value!="")&&($(nbpMax).value!="")){
    $(nbp).value=$(nbpMin).value+"-"+$(nbpMax).value;
  }
  else{
    $(nbp).value="";
  }
}

function setCGIForLstCommuneG(li){
    if ( navigator.appName == 'Microsoft Internet Explorer' ){
      var infos=li.innerText.split(" (");
    }
    else{
      var infos=li.textContent.split(" (");
    }
    document.getElementById("inpt_communeGite").value=infos[0];
    document.getElementById("inpt_communeGite").onfocus=function (evt){this.value='';document.getElementById("inpt_ville_libcommuneGite").value='';}
    document.getElementById("inpt_communeGite").onblur=function (evt){document.getElementById("inpt_ville_libcommuneGite").value=this.value;}
    
    document.getElementById("inpt_ville_libcommuneGite").value=new String(infos[0]).replace(new RegExp(" ","g"),'_');
}
function setCGIForLstCommuneChalet(li){
    if ( navigator.appName == 'Microsoft Internet Explorer' ){
      var infos=li.innerText.split(" (");
    }
    else{
      var infos=li.textContent.split(" (");
    }
    document.getElementById("inpt_communeChalet").value=infos[0];
    document.getElementById("inpt_communeChalet").onfocus=function (evt){this.value='';document.getElementById("inpt_ville_libcommuneChalet").value='';}
    document.getElementById("inpt_communeChalet").onblur=function (evt){document.getElementById("inpt_ville_libcommuneChalet").value=this.value;}
    
    document.getElementById("inpt_ville_libcommuneChalet").value=new String(infos[0]).replace(new RegExp(" ","g"),'_');
}
function setCGIForLstCommuneH(li){
    if ( navigator.appName == 'Microsoft Internet Explorer' ){
      var infos=li.innerText.split(" (");
    }
    else{
      var infos=li.textContent.split(" (");
    }
    document.getElementById("inpt_communeChambre").value=infos[0];
    document.getElementById("inpt_communeChambre").onfocus=function (evt){this.value='';document.getElementById("inpt_ville_libcommuneChambre").value='';}
    document.getElementById("inpt_communeChambre").onblur=function (evt){document.getElementById("inpt_ville_libcommuneChambre").value=this.value;}
    
    document.getElementById("inpt_ville_libcommuneChambre").value=new String(infos[0]).replace(new RegExp(" ","g"),'_');
}
function setCGIForLstCommuneGEGS(li){
    if ( navigator.appName == 'Microsoft Internet Explorer' ){
      var infos=li.innerText.split(" (");
    }
    else{
      var infos=li.textContent.split(" (");
    }
    document.getElementById("inpt_communeGEGS").value=infos[0];
    document.getElementById("inpt_communeGEGS").onfocus=function (evt){this.value='';document.getElementById("inpt_ville_libcommuneGEGS").value='';}
    document.getElementById("inpt_communeGEGS").onblur=function (evt){document.getElementById("inpt_ville_libcommuneGEGS").value=this.value;}
    
    document.getElementById("inpt_ville_libcommuneGEGS").value=new String(infos[0]).replace(new RegExp(" ","g"),'_');
}

function setChmpCommuneAutoCompleterG(reponse){
    var suffixe;
    var jsonarray=eval(reponse);
    var infos=[];
    for (var i=0;i<jsonarray.length;i++){
        (jsonarray[i].nb>1)?suffixe="s":suffixe="";
        infos.push(jsonarray[i].commune+" ("+Math.round(jsonarray[i].nb)+" r&eacute;ponse"+suffixe+")");
    }
    
    /**** champ commune ****/
    if ($("divLstCommunes_inpt_villeGite") && $("inpt_communeGite")){
        var typeahead = new Autocompleter.Local('inpt_communeGite', 'divLstCommunes_inpt_villeGite', infos, {
            frequency: 0.5,
            updateElement: setCGIForLstCommuneG
        });
    }
}
function setChmpCommuneAutoCompleterChalet(reponse){
    var suffixe;
    var jsonarray=eval(reponse);
    var infos=[];
    for (var i=0;i<jsonarray.length;i++){
        (jsonarray[i].nb>1)?suffixe="s":suffixe="";
        infos.push(jsonarray[i].commune+" ("+Math.round(jsonarray[i].nb)+" r&eacute;ponse"+suffixe+")");
    }
    
    /**** champ commune ****/
    if ($("divLstCommunes_inpt_villeChalet") && $("inpt_communeChalet")){
        var typeahead = new Autocompleter.Local('inpt_communeChalet', 'divLstCommunes_inpt_villeChalet', infos, {
            frequency: 0.5,
            updateElement: setCGIForLstCommuneChalet
        });
    }
}
function setChmpCommuneAutoCompleterH(reponse){
    var suffixe;
    var jsonarray=eval(reponse);
    var infos=[];
    for (var i=0;i<jsonarray.length;i++){
        (jsonarray[i].nb>1)?suffixe="s":suffixe="";
        infos.push(jsonarray[i].commune+" ("+Math.round(jsonarray[i].nb)+" r&eacute;ponse"+suffixe+")");
    }
    
    /**** champ commune ****/
    if ($("divLstCommunes_inpt_villeChambre") && $("inpt_communeChambre")){
        var typeahead = new Autocompleter.Local('inpt_communeChambre', 'divLstCommunes_inpt_villeChambre', infos, {
            frequency: 0.5,
            updateElement: setCGIForLstCommuneH
        });
    }
}
function setChmpCommuneAutoCompleterGEGS(reponse){
    var suffixe;
    var jsonarray=eval(reponse);
    var infos=[];
    for (var i=0;i<jsonarray.length;i++){
        (jsonarray[i].nb>1)?suffixe="s":suffixe="";
        infos.push(jsonarray[i].commune+" ("+Math.round(jsonarray[i].nb)+" r&eacute;ponse"+suffixe+")");
    }
    
    /**** champ commune ****/
    if ($("divLstCommunes_inpt_villeGEGS") && $("inpt_communeGEGS")){
        var typeahead = new Autocompleter.Local('inpt_communeGEGS', 'divLstCommunes_inpt_villeGEGS', infos, {
            frequency: 0.5,
            updateElement: setCGIForLstCommuneGEGS
        });
    }
}

function afficheMoteurGite(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="block";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="none";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="none";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="none";
        
    setClassForObj($("li_gite"),"li_ongletMoteurGiteOn");
    setClassForObj($("li_chambre"),"li_ongletMoteur");
    setClassForObj($("li_gegs"),"li_ongletMoteur");
    setClassForObj($("li_camping"),"li_ongletMoteur");
    setClassForObj($("li_chalet"),"li_ongletMoteur");
    setClassForObj($("li_thema"),"li_ongletMoteur");
}

function afficheMoteurChalet(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="none";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="none";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="none";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="block";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="none";
        
    setClassForObj($("li_gite"),"li_ongletMoteur");
    setClassForObj($("li_chambre"),"li_ongletMoteur");
    setClassForObj($("li_gegs"),"li_ongletMoteur");
    setClassForObj($("li_camping"),"li_ongletMoteur");
    setClassForObj($("li_chalet"),"li_ongletMoteurChaletOn");
    setClassForObj($("li_thema"),"li_ongletMoteur");
}

function afficheMoteurChambre(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="none";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="block";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="none";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="none";
        
    setClassForObj($("li_gite"),"li_ongletMoteur");
    setClassForObj($("li_chambre"),"li_ongletMoteurChambreOn");
    setClassForObj($("li_gegs"),"li_ongletMoteur");
    setClassForObj($("li_camping"),"li_ongletMoteur");
    setClassForObj($("li_chalet"),"li_ongletMoteur");
    setClassForObj($("li_thema"),"li_ongletMoteur");
}

function afficheMoteurGEGS(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="none";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="none";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="block";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="none";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="none";
        
    setClassForObj($("li_gite"),"li_ongletMoteur");
    setClassForObj($("li_chambre"),"li_ongletMoteur");
    setClassForObj($("li_gegs"),"li_ongletMoteurGegsOn");
    setClassForObj($("li_camping"),"li_ongletMoteur");
    setClassForObj($("li_chalet"),"li_ongletMoteur");
    setClassForObj($("li_thema"),"li_ongletMoteur");
}

function afficheMoteurCamping(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="none";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="none";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="block";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="none";
        
    setClassForObj($("li_gite"),"li_ongletMoteur");
    setClassForObj($("li_chambre"),"li_ongletMoteur");
    setClassForObj($("li_gegs"),"li_ongletMoteur");
    setClassForObj($("li_camping"),"li_ongletMoteurCampingOn");
    setClassForObj($("li_thema"),"li_ongletMoteur");
    setClassForObj($("li_chalet"),"li_ongletMoteur");
}


function afficheMoteurThemes(){
    if ($("div_moteur_gite"))$("div_moteur_gite").style.display="none";
    if ($("div_moteur_chambre"))$("div_moteur_chambre").style.display="none";
    if ($("div_moteur_GEGS"))$("div_moteur_GEGS").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_camping").style.display="none";
    if ($("div_moteur_chalet"))$("div_moteur_chalet").style.display="none";
    if ($("div_moteur_camping"))$("div_moteur_themes").style.display="block";
        
    setClassForObj($("li_gite"),"li_ongletMoteur");
    setClassForObj($("li_chambre"),"li_ongletMoteur");
    setClassForObj($("li_gegs"),"li_ongletMoteur");
    setClassForObj($("li_camping"),"li_ongletMoteur");
    setClassForObj($("li_thema"),"li_ongletMoteurThemesOn");
    setClassForObj($("li_chalet"),"li_ongletMoteur");
    
}

function setActionSurOngletMoteur(){
  if($("li_gite"))$("li_gite").onclick=function (evt){afficheMoteurGite();}
  if($("li_chalet"))$("li_chalet").onclick=function (evt){afficheMoteurChalet();}
  if($("li_chambre"))$("li_chambre").onclick=function (evt){afficheMoteurChambre();}
  if($("li_gegs"))$("li_gegs").onclick=function (evt){afficheMoteurGEGS();}
  if($("li_camping"))$("li_camping").onclick=function (evt){afficheMoteurCamping();}
  if($("li_thema"))$("li_thema").onclick=function (evt){afficheMoteurThemes();}
}

function setActionSurMenuHaut(){
  for(var i=1;i<=6;i++){
    var objOnglet=$("elem_lst_lien_bouton_4_"+i);
    var objDiv=$("elem_lst_lien_bouton_5_"+(i-1));
    objOnglet.objDiv=objDiv;
    
    objOnglet.onmouseover = function (evt){
      this.objDiv.style.visibility="visible";
    }
    objOnglet.onmouseout = function (evt){
      this.objDiv.style.visibility="hidden";
    }
    objDiv.onmouseover = function (evt){
      this.style.visibility="visible";
    }
    objDiv.onmouseout = function (evt){
      this.style.visibility="hidden";
    }
  }
}

function traiteEpi(suffixe){
  var inptsChecked=new Array();
  $$("input.inpt_epi"+suffixe).each(function(inpt){
    if (inpt.checked)inptsChecked.push(inpt.value);
  });

  if (inptsChecked.length==1){$("inpt_epiHidden"+suffixe).value="="+inptsChecked[0];}
  else{
    $("inpt_epiHidden"+suffixe).value=inptsChecked.join(",");
  }
}

function traiteChambre(suffixe){
  var inptsChecked=new Array();
  $$("input.inpt_chb"+suffixe).each(function(inpt){
    if (inpt.checked)inptsChecked.push(inpt.value);
  });

  if (inptsChecked.length==1){$("inpt_chbHidden"+suffixe).value="="+inptsChecked[0];}
  else{
    $("inpt_chbHidden"+suffixe).value=inptsChecked.join(",");
  }
  
  if($("inpt_chb4G").checked){
    $("inpt_chbHidden"+suffixe).value="4"
  }
}