$(document).ready(function(){
  $("ul.menu li")
  .prepend("&nbsp;")
  .hover(function(){$(this).addClass("attivo");}, function(){$(this).removeClass("attivo");})
  .children("a")
  .each(function(){
    $(this.parentNode).data("href", $(this).attr("href")).css("cursor", "pointer").click(function(){ location.href=$(this).data("href"); });
    $(this).replaceWith($(this).html());
  })
  .end()
  .filter("li:has(ul)")
  .hover(function(){ var ul=$(this).children("ul").get(0); var l=$(ul).data("livello"); 
      $("ul.menu ul:visible").not(ul).each(function(){ if ($(this).data("livello")==l) { $(this).hide(); } }); $(ul).data("chiudi", false).show(); }, 
    function(){ var o=$(this).children("ul").data("chiudi", true).get(0); setTimeout(function(){ if ($.data(o, "chiudi")) $(o).hide(); }, 1000); })
  .children("ul").css("cursor", "default").data("chiudi", true).click(function(){return false;}).each(function(){
    $(this).data("livello", $(this).parents("li").length);
    if ($(this).parents("ul:first").hasClass("orizzontale")) { $(this).before("<span><img src='http://www.gsfraveggio.it/grafica/freccia.gif' alt='' border=0></span>"); }
    else { $(this).before("<span><img src='http://www.gsfraveggio.it/grafica/frecciadx.gif' alt='' border=0></span>"); }
  });
});

