// JavaScript Document

jQuery(document).ready(function($){
  // set up a handler for the docksleep event...
  var onDockSleep = function(){ //scope (this) is the #menu element
        var dock = $('.jqDock', this); //this is the actual dock
        //slide the dock off the top of the window, fading out as it goes...
        dock.animate({top:-1*(dock.height()),opacity:0},600);
        //Note : the original menu element (#menu) and the dock wrapper
        //(div.jqDockWrap) are still in place.
        //bind a one-off mousemove event to the original menu element...
        $(this).one('mousemove', function(){
            //slide the dock back into the window, fading it back in at the same time...
            dock.stop().animate({opacity:1,top:0},600);
            //nudge the dock to reset the idle timer without waiting for animation to finish...
            $(this).trigger('docknudge');
            return false;
          });
        //don't let the dock go to sleep...
        return false;
      }
    // set up the options to be used for jqDock...
    , dockOptions =
      { align: 'top' // horizontal menu, with expansion DOWN from a fixed TOP edge
      , labels: true  // add labels (defaults to 'bc')
      , idle : 6000000 // set idle timeout to 6 seconds
      , onSleep: onDockSleep // handler declared above
      };
  // ...and apply...
  $('#menu').jqDock(dockOptions);
});
