function oninit(){
  setActionSurOngletPermanent();
  if($("calendrierMoteurAffine_gite")) setCalendrierGeneral("gites85","1","","G","calendrierMoteurAffine_gite",clicCalendJsAffine,"inpt_dateDeb_affine","","","lst_nbj_affine","1","");
  if($("div_ongletsDecouvrir")) defBtOngletdecouvrir();
  setScrollHorizontalOnDiv('div_menu_themes_defil','ul_menu_themes',{nextButton:"sp_btSuivThemes",prevButton:"sp_btPrecThemes"});
  if($("div_reperePageBlocs")) defActionOngletTypeFaq();
}

function defActionOngletTypeFaq(){
  $$(".a_ongletPorteurOff").each(function(obj){
    obj.onclick=function(){if(obj.next("div").style.display=="none") obj.next("div").style.display="block";
      else obj.next("div").style.display="none";
      if(obj.hasClassName("a_ongletPorteurOn")) obj.removeClassName("a_ongletPorteurOn"); 
      else obj.addClassName("a_ongletPorteurOn");
      }
    }
  );
}

function simuleClicSuivant(){
  if(nbClick<=7){
    $("sp_btSuivThemes").onclick();
    nbClick++;
    js_log(nbClick);
  }
  else{
    $("ul_menu_themes").style.left="0";
    nbClick=0;
  }
}

function fqQuandFiniMoteur(){
  if($("calendrierMoteur_gite")) setCalendrierGeneral("gites85","1","","G","calendrierMoteur_gite",clicCalendJsGite,"inpt_dateDeb_gite","","","lst_nbj_gite","1","");
  setActionSurOngletTypes();
  $("bt_lanceNum_gite").onclick = function(evt){lanceRechercheNum("inpt_num_gite");};
  $("bt_lanceNum_chambre").onclick = function(evt){lanceRechercheNum("inpt_num_chambre");};
  $("bt_lanceNum_gegs").onclick = function(evt){lanceRechercheNum("inpt_num_gegs");};
  $("bt_lanceNum_camping").onclick = function(evt){lanceRechercheNum("inpt_num_camping");};
  $("bt_lanceNum_enfant").onclick = function(evt){lanceRechercheNum("inpt_num_enfant");};
  $("inpt_num_chambre").onkeypress = function(evt){enterNumero(evt,"inpt_num_chambre");};
  $("inpt_num_gegs").onkeypress = function(evt){enterNumero(evt,"inpt_num_gegs");};  
  $("inpt_num_camping").onkeypress = function(evt){enterNumero(evt,"inpt_num_camping");};  
  $("inpt_num_enfant").onkeypress = function(evt){enterNumero(evt,"inpt_num_enfant");};
  $("inpt_num_gite").onkeypress = function(evt){enterNumero(evt,"inpt_num_gite");};  
  initCouleurBandeau();
  $$(".lstSecteur").each(function(obj){if(obj.getAttribute("selected")=="selected"){$("lst_secteurGite").value=obj.getAttribute("valeur");$("sp_libSecteurGite").innerHTML=obj.innerHTML;}});
  $$(".lstRegion").each(function(obj){obj.observe("click",function(evt){$("lst_secteurGite").name="REGION";})});
  $$(".lstInfotour").each(function(obj){obj.observe("click",function(evt){$("lst_secteurGite").name="INFOTOUR";})});
  
  $$(".lstSecteur").each(function(obj){if(obj.getAttribute("selected")=="selected"){$("lst_secteurChambre").value=obj.getAttribute("valeur");$("sp_libSecteurChambre").innerHTML=obj.innerHTML;}});
  $$(".lstRegion").each(function(obj){obj.observe("click",function(evt){$("lst_secteurChambre").name="REGION";})});
  $$(".lstInfotour").each(function(obj){obj.observe("click",function(evt){$("lst_secteurChambre").name="INFOTOUR";})});
  
  $$(".lstSecteur").each(function(obj){obj.observe("click",function(evt){definitionSecteurTouristique(obj);})});
  $$(".bt_affinage").each(function(obj){obj.observe("click",function(evt){
    $$(".div_contentCriteresCommuns").each(function(obj2){
      obj2.style.display="block";              
    });  
  })});
}

function enterNumero(event,inpt){
  if(!event) var event = window.event;
  if(event && event.keyCode==13) lanceRechercheNum(inpt);
}

function lanceRechercheNum(inpt){
  document.location.href = "/liste?CRITINIT=O&LNO="+$(inpt).value;
}

function initCouleurBandeau(){
  if($("inpt_typeAffinage")){
    switch($("inpt_typeAffinage").value){
      case "H":
        $$(".div_moteur_type_content").each(function(obj){if(obj.hasClassName("div_moteur_type_content_on")) obj.removeClassName("div_moteur_type_content_on");});
        $("div_moteur_type_chambre").addClassName("div_moteur_type_content_on");
        break;
      case "T":
        $$(".div_moteur_type_content").each(function(obj){if(obj.hasClassName("div_moteur_type_content_on")) obj.removeClassName("div_moteur_type_content_on");});
        $("div_moteur_type_gegs").addClassName("div_moteur_type_content_on");
        break;
      case "E":
        $$(".div_moteur_type_content").each(function(obj){if(obj.hasClassName("div_moteur_type_content_on")) obj.removeClassName("div_moteur_type_content_on");});
        $("div_moteur_type_enfant").addClassName("div_moteur_type_content_on");
        break;
      case "C":
        $$(".div_moteur_type_content").each(function(obj){if(obj.hasClassName("div_moteur_type_content_on")) obj.removeClassName("div_moteur_type_content_on");});
        $("div_moteur_type_camping").addClassName("div_moteur_type_content_on");
        break;
      default:
        $$(".div_moteur_type_content").each(function(obj){if(obj.hasClassName("div_moteur_type_content_on")) obj.removeClassName("div_moteur_type_content_on");});
        $("div_moteur_type_gite").addClassName("div_moteur_type_content_on");
        break;
    }
  }
}

function foncQdFiniThemes(){
  setCalendrierGeneral("gites85","1","","G","calendrierMoteur_theme",clicCalendJsChambre,"inpt_dateDeb_theme","","","lst_nbj_theme","1","");
  $("a_lanceRecherche_theme").onclick = function(evt){lanceRechercheThemes("frm_moteur_theme")};
}

function clicCalendJsGite(evt,jour,mois,annee,etat){
  $("inpt_dateDeb_gite").value=jour+mois+annee;
  afficheEffaceCalendJs("calendrierMoteur_gite");
  $("lst_budget_gite").disabled=false;
}
function clicCalendJsChambre(evt,jour,mois,annee,etat){
  $("inpt_dateDeb_chambre").value=jour+mois+annee;
  afficheEffaceCalendJs("calendrierMoteur_chambre");
}
function clicCalendJsAffine(evt,jour,mois,annee,etat){
  $("inpt_dateDeb_affine").value=jour+mois+annee;
  afficheEffaceCalendJs("calendrierMoteurAffine");
  setListByForm($('frm_moteur_affinage'));
}

function afficheEffaceCalendJs(nomDiv){
  if($(nomDiv).showing==true){
    Effect.BlindUp(nomDiv);       
    $(nomDiv).showing=false;
  }
  else{
    Effect.BlindDown(nomDiv);       
    $(nomDiv).showing=true;
  }
}


function affOngletMoteur_type(){
  if(!$("div_ongletsMoteurPermanent").hasClassName("ongletsMoteurTypeOn")){
    setClassForObj($("div_ongletsMoteurPermanent"),"ongletsMoteurTypeOn");  
    $$(".div_moteurPermanent_content").each(function(obj){if(obj.hasClassName("div_moteurPermanent_contentOn")) obj.removeClassName("div_moteurPermanent_contentOn");});
    $("div_moteur_type_type").addClassName("div_moteurPermanent_contentOn");
    if($("div_form_gite")) $("div_form_gite").style.display="block";
  }
}
function affOngletMoteur_carte(){
  if(!$("div_ongletsMoteurPermanent").hasClassName("ongletsMoteurCarteOn")){
    setClassForObj($("div_ongletsMoteurPermanent"),"ongletsMoteurCarteOn");  
    $$(".div_moteurPermanent_content").each(function(obj){if(obj.hasClassName("div_moteurPermanent_contentOn")) obj.removeClassName("div_moteurPermanent_contentOn");});
    $("div_moteur_type_carte").addClassName("div_moteurPermanent_contentOn");
  }
}
function affOngletMoteur_themes(){
//  if(!$("div_ongletsMoteurPermanent").hasClassName("ongletsMoteurThemesOn")){
    setClassForObj($("div_ongletsMoteurPermanent"),"ongletsMoteurThemesOn");  
    $$(".div_moteurPermanent_content").each(function(obj){if(obj.hasClassName("div_moteurPermanent_contentOn")) obj.removeClassName("div_moteurPermanent_contentOn");});
    $("div_moteur_type_themes").addClassName("div_moteurPermanent_contentOn");
    $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
    if($("div_form_theme")) $("div_form_theme").style.display = "block";
  //}
}

function affOngletMoteur_accessibilite(){
  if(!$("div_ongletsMoteurPermanent").hasClassName("ongletsMoteurAccessibleOn")){
    setClassForObj($("div_ongletsMoteurPermanent"),"ongletsMoteurAccessibleOn");  
    $$(".div_moteurPermanent_content").each(function(obj){if(obj.hasClassName("div_moteurPermanent_contentOn")) obj.removeClassName("div_moteurPermanent_contentOn");});
    $("div_moteur_type_accessibilite").addClassName("div_moteurPermanent_contentOn");
  }
}
function setActionSurOngletPermanent(){
   $("a_onglet_type").onclick=function(evt){affOngletMoteur_type();};
   $("a_onglet_carto").onclick=function(evt){affOngletMoteur_carte();};
   $("a_onglet_themes").onclick=function(evt){affOngletMoteur_themes();};
   //$("a_onglet_accesible").onclick=function (evt){affOngletMoteur_accessibilite();}
}

function affOngletMoteur_gite(){
  if(!$("div_moteur_type_gite").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gite").addClassName("div_moteur_type_content_on");
  if($("div_moteur_type_chambre").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_chambre").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_gegs").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gegs").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_enfant").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_enfant").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_camping").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_camping").removeClassName("div_moteur_type_content_on");
  $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
}
function affOngletMoteur_chambre(){
  if($("div_moteur_type_gite").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gite").removeClassName("div_moteur_type_content_on");
  if(!$("div_moteur_type_chambre").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_chambre").addClassName("div_moteur_type_content_on");
  if($("div_moteur_type_gegs").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gegs").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_enfant").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_enfant").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_camping").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_camping").removeClassName("div_moteur_type_content_on");
  $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
}
function affOngletMoteur_gegs(){
  if($("div_moteur_type_gite").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gite").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_chambre").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_chambre").removeClassName("div_moteur_type_content_on");
  if(!$("div_moteur_type_gegs").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gegs").addClassName("div_moteur_type_content_on");
  if($("div_moteur_type_enfant").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_enfant").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_camping").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_camping").removeClassName("div_moteur_type_content_on");
  $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
}
function affOngletMoteur_enfant(){
  if($("div_moteur_type_gite").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gite").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_chambre").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_chambre").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_gegs").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gegs").removeClassName("div_moteur_type_content_on");
  if(!$("div_moteur_type_enfant").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_enfant").addClassName("div_moteur_type_content_on");
  if($("div_moteur_type_camping").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_camping").removeClassName("div_moteur_type_content_on");
  $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
}
function affOngletMoteur_camping(){
  if($("div_moteur_type_gite").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gite").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_chambre").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_chambre").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_gegs").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_gegs").removeClassName("div_moteur_type_content_on");
  if($("div_moteur_type_enfant").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_enfant").removeClassName("div_moteur_type_content_on");
  if(!$("div_moteur_type_camping").hasClassName("div_moteur_type_content_on")) $("div_moteur_type_camping").addClassName("div_moteur_type_content_on");
  $$(".div_form_moteur").each(function(obj){obj.style.display="block";});
}
function setActionSurOngletTypes(){
   $("a_type_onglet_gite").onclick=function (evt){affOngletMoteur_gite();};
   $("a_type_onglet_chambre").onclick=function (evt){affOngletMoteur_chambre();};
   /*$("a_type_onglet_gegs").onclick=function (evt){affOngletMoteur_gegs();}
   $("a_type_onglet_enfant").onclick=function (evt){affOngletMoteur_enfant();}
   $("a_type_onglet_camping").onclick=function (evt){affOngletMoteur_camping();}*/
}

function lanceRecherche(form){
  document.location.href='/liste?'+getQueryStringByForm($(form));
}
function lanceRechercheThemes(form){
  document.location.href='/listeheb?'+getQueryStringByForm($(form))+'#js:affListeRubriques()';
}


function definitionBudget(select,type){
  $("pmin"+type).value=select.options[select.selectedIndex].getAttribute("prixMini");
  $("pmax"+type).value=select.options[select.selectedIndex].getAttribute("prixMaxi");
  
}

// PAGES DECOUVRIR LA VENDEE //
function affOngletDecouvrir(bt,div){
  $$(".div_contentOnglet").each(function(obj){obj.style.display="none"});
  $(div).style.display="block";
  $$(".li_ongletDecouvrir").each(function(obj){if(obj.hasClassName("li_ongletDecouvrirOn")) obj.removeClassName("li_ongletDecouvrirOn")});
  $(bt).addClassName("li_ongletDecouvrirOn");
}
function defBtOngletdecouvrir(){
  $("li_ongletDecouvrirAVoir").onclick=function(){affOngletDecouvrir("li_ongletDecouvrirAVoir","div_ongletAVoir")};
  $("li_ongletDecouvrirAFaire").onclick=function(){affOngletDecouvrir("li_ongletDecouvrirAFaire","div_ongletAFaire")};
  $("li_ongletDecouvrirAGouter").onclick=function(){affOngletDecouvrir("li_ongletDecouvrirAGouter","div_ongletAGouter")};
  $("li_ongletDecouvrirSejourner").onclick=function(){affOngletDecouvrir("li_ongletDecouvrirSejourner","div_ongletSejourner")};
}

// FORMULAIRE //
function envoiForm(){
  checkForm($("frm_contactVendee"),envoiMailForm);
}
function envoiMailForm(){
  envoiMailByAjaxByForm('frm_contactVendee','div_formMessageValide',true);
}

/*--------------définition du secteur touristique------------------------*/
function definitionSecteurTouristique(obj){ 
  $$(".lstRegion").each(function(obj){obj.observe("click",function(evt){$("lst_secteur").name="REGION";})});
  $$(".lstInfotour").each(function(obj){obj.observe("click",function(evt){$("lst_secteur").name="INFOTOUR";})});
  $("lst_secteurGite").value=obj.getAttribute("valeur");
  $("sp_libSecteurGite").innerHTML=obj.innerHTML;   
  afficheEffaceCalendJs("ul_secteurGite");
  $("lst_secteurChambre").value=obj.getAttribute("valeur");
  $("sp_libSecteurChambre").innerHTML=obj.innerHTML;   
  afficheEffaceCalendJs("ul_secteurChambre");
}






