(function($){jQuery.fn.intoViewport=function(options){options=$.extend({duration:200,easing:"swing"},options||{});return this.each(function(){function scrTo(dest){$("html,body").stop().animate({scrollTop:dest},options);}var scr=$(document).scrollTop()||$(window).scrollTop(),wheight=$(window).height(),top=$(this).offset().top,eheight=$(this).outerHeight();if(scr>top){scrTo(top - 9);}else if(scr!=top&&top+eheight>scr+wheight){scrTo(top+Math.min(eheight-wheight + 10,0));}});};})(jQuery);
