/**
 * Выпадающее меню
 * @author utyf
 * 
 */
$.fn.dropDownMenu = function( options ){
   var self = $(this);
   if (self.enableDropDown){
      self  .unbind('mouseenter.dropdown')
            .unbind('mouseleave.dropdown');
   }

   self.each(function(){
       //$('#'+$(this).attr('dropdown')).addClass('dropped');
   });

   self.enableDropDown = true;
   
   self.options = {
       showFunc: function(){
           $(this).show();
       },
       hideFunc: function(){
           $(this).hide();
       }
   };

   $.extend( self.options, options );

   self.bind( 'mouseenter.dropdown', function(){
       var el = $(this);
       
       var div = $('#'+el.attr('dropdown'))
                    .css('position', 'absolute')
                    .appendTo(el);
       
       //Располагаем элемент ровно под вызывающей кнопкой
       if ( ! self.options.manual){
           var o = el.offset();
           o.top += el.height();
           div = div.css(o);
       }
       
       self.options.showFunc.call( div );
   } )
   .bind( 'mouseleave.dropdown', function(){
       self.options.hideFunc.call( $('#'+$(this).attr('dropdown')) );
   })
};

$(function(){
   $('.dropdown').dropDownMenu();
});