1 (function($,sr){
  2  
  3   // debouncing function from John Hann
  4   // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
  5   var debounce = function (func, threshold, execAsap) {
  6       var timeout;
  7  
  8       return function debounced () {
  9           var obj = this, args = arguments;
 10           function delayed () {
 11               if (!execAsap)
 12                   func.apply(obj, args);
 13               timeout = null; 
 14           };
 15  
 16           if (timeout)
 17               clearTimeout(timeout);
 18           else if (execAsap)
 19               func.apply(obj, args);
 20  
 21           timeout = setTimeout(delayed, threshold || 100); 
 22       };
 23   }
 24 	// smartresize 
 25 	jQuery.fn[sr] = function(fn){  return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
 26  
 27 })(jQuery,'smartresize');