function oninit1(){    
  defActionOngletsFiche();
  if($("div_fiche_album")) $("div_legendeAlb").style.display="block";
  loadItineraire();  
}


function afficheOngletPresentation(){
    if ($("div_presentation"))$("div_presentation").style.display="block";     
    if ($("div_localisation"))$("div_localisation").style.display="none";
    if ($("div_fiche_rubriques"))$("div_fiche_rubriques").style.display="none";
    
    setClassForObj($("liOngletfiche_pres"),"onglets_ficheOn");
    setClassForObj($("liOngletfiche_locate"),"onglets_fiche");
    setClassForObj($("liOngletfiche_theme"),"onglets_fiche");
}

function afficheOngletLocalisation(){
    if ($("div_presentation"))$("div_presentation").style.display="none";     
    if ($("div_localisation"))$("div_localisation").style.display="block";
    if ($("div_fiche_rubriques"))$("div_fiche_rubriques").style.display="none";   
    iteaGMAP_initForFiche();
    setDirections("Paris", $("toAddress").value, "fr_FR");
        
    setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
    setClassForObj($("liOngletfiche_locate"),"onglets_ficheOn");
    setClassForObj($("liOngletfiche_theme"),"onglets_fiche");
}

function afficheOngletThemes(){
    if ($("div_presentation"))$("div_presentation").style.display="none";     
    if ($("div_localisation"))$("div_localisation").style.display="none";
    if ($("div_fiche_rubriques"))$("div_fiche_rubriques").style.display="block";
    
    setClassForObj($("liOngletfiche_pres"),"onglets_fiche");
    setClassForObj($("liOngletfiche_locate"),"onglets_fiche");
    setClassForObj($("liOngletfiche_theme"),"onglets_ficheOn");
}

function defActionOngletsFiche(){
    $("liOngletfiche_pres").onclick=function (evt){afficheOngletPresentation();}
    $("liOngletfiche_locate").onclick=function (evt){afficheOngletLocalisation();}
    $("liOngletfiche_theme").onclick=function (evt){afficheOngletThemes();}
    
    if (!$("div_fiche_rubriques"))$("liOngletfiche_theme").style.display="none";
    afficheOngletPresentation()
}


/************** **************/
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");
}

