(function( $ ){

  var methods = {
    init : function( options ) {
      var settings = {
        bottom:       '.bottom',
        text:         '.text',
        timeout:      300
      }
      if ( options ) { 
        $.extend( settings, options );
      }

      return this.each(function(){
        var $this = $(this);
        $this.bind('slide.ttSlideUp', methods.slide);

        $this.find(settings.bottom).hover(
          function() {
            $(this).trigger('slide.ttSlideUp', ['down', settings])
          },

          function() {
            $(this).trigger('slide.ttSlideUp', ['up', settings])
          }
          );
      });
    },

    slide: function(e, sliding, settings) {
      var $this = $(e.target);
      var timer = $this.data('timer.ttSlideUp')
      clearTimeout(timer)
        if (sliding == 'down') {
            $this.find(settings.text).slideDown();
        }
        else if (sliding == 'up') {
          timer = setTimeout(function() {
            $this.find(settings.text).slideUp();
          }, settings.timeout);
        }
      $this.data('timer', timer)
    }
  };

  $.fn.akSlideUp = function( method ) {

    // Method calling logic
    if ( methods[method] ) {
      return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'object' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
    }    

  };

})( jQuery );
