(function($){  
  $.fn.hoverDelay = function(hoverInFunction, hoverOutFunction, options) {  
 
    var defaults = {
      inDelay: 800,
      outDelay: 1000
    };
    var options = $.extend(defaults, options);
  
    return this.each(function() {  
      var openTimer;
      var closeTimer;
      var state = false;
  
      $(this).hover(function() {
        clearTimeout(closeTimer);
        closeTimer = null;

        if (openTimer) {
          clearTimeout(openTimer);
          openTimer = null;
        }
        openTimer = setTimeout(function() {
          if (!state) {
            hoverInFunction();
            state = true;
          }
        },
        options.inDelay);
      }, function() {
        clearTimeout(openTimer);
        openTimer = null;

        if (closeTimer) {
          clearTimeout(closeTimer);
          closeTimer = null;
        }
        closeTimer = setTimeout(function() {
          if (state) {
            hoverOutFunction();
            state = false;
          }
        },
        options.outDelay);
      });
    });  
 };  
})(jQuery); 

