(function($){var html;function propPx(el,opts,what){return Math.round((!opts.padding&&-parseFloat(el.css('padding'+what)||0))+(!opts.border&&-parseFloat(el.css('border'+what+'Width')||0))+(opts.margin&&parseFloat(el.css('margin'+what)||0)))}function constrainPx(el,opts,what){return document.documentElement['client'+what]-el['outer'+what]()-(what=='Height'?propPx(el,opts,'Top')+propPx(el,opts,'Bottom'):propPx(el,opts,'Left')+propPx(el,opts,'Right'))}$.fn.scrollIntoView=function(opts,easing,fn){html=html||($('body')[0].scrollHeight>=$('html')[0].scrollHeight?$('body')[0]:$('html')[0]);if(typeof opts!='object')opts={duration:opts,easing:easing,complete:fn};opts=$.extend({},$.fn.scrollIntoView.defaults,$.metadata&&this.metadata()['scrollIntoView'],opts);if(opts.complete){var complete=opts.complete,self=this[0];opts.complete=function(){complete.apply(self,arguments)}}if(opts.margin)opts.border=true;if(opts.border)opts.padding=true;var offset=this.offset();offset.top-=propPx(this,opts,'Top');offset.left-=propPx(this,opts,'Left');var h=Math.max(0,constrainPx(this,opts,'Height')),w=Math.max(0,constrainPx(this,opts,'Width'));$(html).animate({scrollTop:Math.min(offset.top,Math.max(html.scrollTop,offset.top-h)),scrollLeft:Math.min(offset.left,Math.max(html.scrollLeft,offset.left-w))},opts);return this};$.fn.scrollIntoView.defaults={padding:true,border:true,margin:false}})(jQuery);
