function oninit1(){    
  defActionOngletsFiche();
  defActionOngletsPhoto();
  defActionPromo();   
  verifOngletVideo();
  if($("div_btDispo2")) $("div_btDispo2").observe("click",scrollDispo);
  initLesAvis();
}

function scrollDispo(){
  $("div_fiche_divDispo_v3").scrollTo();
}

function verifOngletVideo(){
 if(!$("div_fiche_youtube")&&!$("div_fiche_dailymotion")) $("liOngletfiche_photo_videos").style.display="none";
 if(!$("div_fiche_VisuPlanInterieur")) $("liOngletfiche_photo_plan").style.display="none";
}

function defActionOngletsFiche(){
 $("liOngletfiche_pres").onclick=function (evt){
       $("div_fiche_presentation").style.display="block";
       $("div_fiche_confortEquipement").style.display="none";
       $("div_fiche_themes").style.display="none";
       $("div_fiche_loisirs").style.display="none";
       $("div_fiche_tarifReserver").style.display="none";
       $("div_fiche_acces_plan").style.display="none";
        
        setClassForObj($("liOngletfiche_pres"),"onglets_ficheOn");
        setClassForObj($("liOngletfiche_confort"),"onglets_fiche");
        setClassForObj($("liOngletfiche_the"),"onglets_fiche");
        setClassForObj($("liOngletfiche_loisirs"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_fiche");
        setClassForObj($("liOngletfiche_prix"),"onglets_fiche");
    }
    
   $("liOngletfiche_confort").onclick=function (evt){
       $("div_fiche_confortEquipement").style.display="block";
       $("div_fiche_presentation").style.display="none";        
       $("div_fiche_themes").style.display="none";
       $("div_fiche_loisirs").style.display="none";
       $("div_fiche_tarifReserver").style.display="none";
       $("div_fiche_acces_plan").style.display="none";
        
        setClassForObj($("liOngletfiche_confort"),"onglets_ficheOn");
        setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
        setClassForObj($("liOngletfiche_the"),"onglets_fiche");
        setClassForObj($("liOngletfiche_loisirs"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_fiche");
        setClassForObj($("liOngletfiche_prix"),"onglets_fiche");
    }
    
   $("liOngletfiche_the").onclick=function (evt){
       $("div_fiche_themes").style.display="block";
       $("div_fiche_confortEquipement").style.display="none";
       $("div_fiche_presentation").style.display="none";        
       $("div_fiche_loisirs").style.display="none";
       $("div_fiche_tarifReserver").style.display="none";
       $("div_fiche_acces_plan").style.display="none";
        
        setClassForObj($("liOngletfiche_the"),"onglets_ficheOn");
        setClassForObj($("liOngletfiche_confort"),"onglets_fiche");
        setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
        setClassForObj($("liOngletfiche_loisirs"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_fiche");
        setClassForObj($("liOngletfiche_prix"),"onglets_fiche");
    }
    
   $("liOngletfiche_loisirs").onclick=function (evt){
       $("div_fiche_loisirs").style.display="block";
       $("div_fiche_themes").style.display="none";
       $("div_fiche_confortEquipement").style.display="none";
       $("div_fiche_presentation").style.display="none";        
       $("div_fiche_tarifReserver").style.display="none";
       $("div_fiche_acces_plan").style.display="none";
       
        setClassForObj($("liOngletfiche_loisirs"),"onglets_ficheOn");
        setClassForObj($("liOngletfiche_the"),"onglets_fiche");
        setClassForObj($("liOngletfiche_confort"),"onglets_fiche");
        setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_fiche");
        setClassForObj($("liOngletfiche_prix"),"onglets_fiche");
    }
    
   $("liOngletfiche_acces").onclick=function (evt){
       $("div_fiche_tarifReserver").style.display="none";
       $("div_fiche_loisirs").style.display="none";
       $("div_fiche_themes").style.display="none";
       $("div_fiche_confortEquipement").style.display="none";
       $("div_fiche_presentation").style.display="none";        
       $("div_fiche_acces_plan").style.display="block";
        
        setClassForObj($("liOngletfiche_prix"),"onglets_fiche");
        setClassForObj($("liOngletfiche_loisirs"),"onglets_fiche");
        setClassForObj($("liOngletfiche_the"),"onglets_fiche");
        setClassForObj($("liOngletfiche_confort"),"onglets_fiche");
        setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_ficheOn");  
        loadItineraire();   
        if (map){
             setDirections("Paris", $("toAddress").value, "fr_FR");
        }
    }

   $("liOngletfiche_prix").onclick=function (evt){
       $("div_fiche_tarifReserver").style.display="block";
       $("div_fiche_loisirs").style.display="none";
       $("div_fiche_themes").style.display="none";
       $("div_fiche_confortEquipement").style.display="none";
       $("div_fiche_presentation").style.display="none";        
       $("div_fiche_acces_plan").style.display="none";
        
        setClassForObj($("liOngletfiche_prix"),"onglets_ficheOnVert");
        setClassForObj($("liOngletfiche_loisirs"),"onglets_fiche");
        setClassForObj($("liOngletfiche_the"),"onglets_fiche");
        setClassForObj($("liOngletfiche_confort"),"onglets_fiche");
        setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
        setClassForObj($("liOngletfiche_acces"),"onglets_fiche");        
    }
}

function defActionOngletsPhoto(){
 $("liOngletfiche_photo_photos").onclick=function (evt){
       if($("div_fiche_visuPhoto")) $("div_fiche_visuPhoto").style.display="block";
       if($("div_fiche_VisuPlanInterieur")) $("div_fiche_VisuPlanInterieur").style.display="none";
       if($("div_fiche_videos")) $("div_fiche_videos").style.display="none";      
        
        setClassForObj($("liOngletfiche_photo_photos"),"onglets_fiche_photoOn");
        setClassForObj($("liOngletfiche_photo_plan"),"onglets_fiche_photo");  
        setClassForObj($("liOngletfiche_photo_videos"),"onglets_fiche_photo"); 
    }
   if($("div_fiche_VisuPlanInterieur")){
      $("liOngletfiche_photo_plan").onclick=function (evt){
         if($("div_fiche_visuPhoto")) $("div_fiche_visuPhoto").style.display="none";
         if($("div_fiche_VisuPlanInterieur")) $("div_fiche_VisuPlanInterieur").style.display="block";
         if($("div_fiche_videos")) $("div_fiche_videos").style.display="none";      
          
          setClassForObj($("liOngletfiche_photo_photos"),"onglets_fiche_photo");
          setClassForObj($("liOngletfiche_photo_plan"),"onglets_fiche_photoOn");
          setClassForObj($("liOngletfiche_photo_videos"),"onglets_fiche_photo");   
      }
    }
    if($("div_fiche_youtube")||$("div_fiche_dailymotion")){
     $("liOngletfiche_photo_videos").onclick=function (evt){
         if($("div_fiche_visuPhoto")) $("div_fiche_visuPhoto").style.display="none";
         if($("div_fiche_VisuPlanInterieur")) $("div_fiche_VisuPlanInterieur").style.display="none";
         if($("div_fiche_videos")) $("div_fiche_videos").style.display="block";      
          
          setClassForObj($("liOngletfiche_photo_photos"),"onglets_fiche_photo");
          setClassForObj($("liOngletfiche_photo_plan"),"onglets_fiche_photo"); 
          setClassForObj($("liOngletfiche_photo_videos"),"onglets_fiche_photoOn");  
      }
    }
}

function defActionPromo(){
  var tabObjLibPromo=document.getElementsByClassName("titre_promo");
  
  for (var i=0;i<tabObjLibPromo.length;i++){
    var objCurr=tabObjLibPromo[i];
    
    objCurr.onclick=function (evt){      
      var frere=this.nextSibling;
      if (frere.style.display=="block"){
        frere.style.display="none";
      }
      else{
        frere.style.display="block";
      }
      var frere2=frere.nextSibling;
      if (frere2.style.display=="block"){
        frere2.style.display="none";
      }
      else{
        frere2.style.display="block";
      }
    }
  
  }
}



/************** **************/
var map;
var gdir;
 function loadItineraire() {
     if (GBrowserIsCompatible()) {      
         map = new GMap2($("div_map_directions"));
         gdir = new GDirections(map,$("div_fiche_directions"));
         GEvent.addListener(gdir, "error", handleErrors);
         setDirections("Paris", $("toAddress").value, "fr_FR");
     }
}
    
function setDirections(fromAddress, toAddress, locale) {
    gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": locale,"preserveViewport":false });
    map.setZoom(9);
    map.checkResize();
}

function handleErrors(){
    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS ||  gdir.getStatus().code == G_GEO_BAD_REQUEST)$("div_fiche_directions").update("Aucune correspondance g&eacute;ographique trouv&eacute;e");
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)$("div_fiche_directions").update("Serveur de g&eacute;olocalisation non disponible");
	     else $("div_fiche_directions").update("Une erreur est survenue");
}

function initLesAvis(){
    if($("div_avisVinivi")){
      $("li_btVinivi").style.display="inline";
      $("div_fiche_avis").style.display="block";
      $("bt_vinivi").onclick = function(evt){
        if($("div_avisTrip")) $("div_avisTrip").style.display="none";
        if($("div_avisVinivi")) $("div_avisVinivi").style.display="block";
      };
    }
    if($("div_avisTrip")){ 
      $("li_btTrip").style.display="inline";
      $("div_fiche_avis").style.display="block";
      $("bt_trip").onclick = function(evt){
        if($("div_avisVinivi")) $("div_avisVinivi").style.display="none";
        if($("div_avisTrip")) $("div_avisTrip").style.display="block";        
      };
      if(!$("div_avisVinivi")) $("div_avisTrip").style.display="block";
    }
}
