<!--
$(document).ready( function () {

  function resetPanel(panel) {
    panel.find(".category").each( function(){
      $(this).removeClass("pointing");
    });
    panel.find(".category-panel").each( function(){
      $(this).hide();
    });
  }
   
  $("#menu_block").removeClass("no-js");

  $(".main-level").hover(
    function () {
      $(this).next("div.sub-level").fadeIn("slow") ;
      var defaultPanel = $(this).next(".sub-level").find(".category.first");
      defaultPanel.find(".category-panel.first").load($(this).find("a").attr("rel"));
      defaultPanel.find(".category-panel.first").fadeIn();
      defaultPanel.find("a.category-name").removeClass("fetched");
    },
    function () {
      resetPanel($(this).next(".sub-level"));
      $(this).find("a").removeClass("pointing");
      $(this).next("div.sub-level").hide() ;
    }
  );

  $(".sub-level").hover(
    function () {
      $(this).show() ;
      $(this).prev(".main-level").find("a").addClass("pointing");
    },
    function () {
      var defaultPanel = $(this).find(".category.first");
      resetPanel($(this));
      $(this).hide() ;
      $(this).prev(".main-level").find("a").removeClass("pointing");
    }
  );

  $(".category-name").hoverIntent(
    function() {
      var catBloc = $(this).parent(".category");
      var catPane = $(this).next(".category-panel");
      if( ! $(this).hasClass("fetched") ) {
        catPane.load($(this).attr("rel"));
        $(this).addClass("fetched");
      }

      if( ! catBloc.is("pointing") ) {
        var prev = $(this).parent().siblings(".pointing");
        prev.removeClass("pointing");
        prev.find(".category-panel").fadeOut();

        catBloc.addClass("pointing");
        catPane.fadeIn();
      }
    },
    function () {
    }
  );

}); 
// -->

