$(document).ready(function() {

  var MenuManager = new function() {
    var hovered = null;   
    return {
      init: function() {
        $('#nav > li').hover(function() {
          $('ul:first', this).css('left', $(this).position().left);
          $('ul:first', this).css('top', $(this).position().top + 27);
          $('ul:first', this).show();
          hovered = this;
        },
        function() {                    
          var target = this;
          hovered = null;
          setTimeout(function() {
          	if (hovered != target) {
            	 $('ul:first', target).fadeOut();
          	}
          }, 100);    
        });
                           
      }
    }
  }  
  MenuManager.init();
});
