(function(a){function c(a){return typeof a=="object"?a:{top:a,left:a}}var b=a.scrollTo=function(b,c,d){a(window).scrollTo(b,c,d)};b.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)<1.3?1:0},b.window=function(b){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!c)return b;var d=(b.contentWindow||b).document||b.ownerDocument||b;return a.browser.safari||d.compatMode=="BackCompat"?d.body:d.documentElement})},a.fn.scrollTo=function(d,e,f){return typeof e=="object"&&(f=e,e=0),typeof f=="function"&&(f={onAfter:f}),d=="max"&&(d=9e9),f=a.extend({},b.defaults,f),e=e||f.speed||f.duration,f.queue=f.queue&&f.axis.length>1,f.queue&&(e/=2),f.offset=c(f.offset),f.over=c(f.over),this._scrollable().each(function(){function m(a){h.animate(k,e,f.easing,a&&function(){a.call(this,d,f)})}var g=this,h=a(g),i=d,j,k={},l=h.is("html,body");switch(typeof i){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(i)){i=c(i);break}i=a(i,this);case"object":if(i.is||i.style)j=(i=a(i)).offset()}a.each(f.axis.split(""),function(a,c){var d=c=="x"?"Left":"Top",e=d.toLowerCase(),n="scroll"+d,o=g[n],p=b.max(g,c);if(j)k[n]=j[e]+(l?0:o-h.offset()[e]),f.margin&&(k[n]-=parseInt(i.css("margin"+d))||0,k[n]-=parseInt(i.css("border"+d+"Width"))||0),k[n]+=f.offset[e]||0,f.over[e]&&(k[n]+=i[c=="x"?"width":"height"]()*f.over[e]);else{var q=i[e];k[n]=q.slice&&q.slice(-1)=="%"?parseFloat(q)/100*p:q}/^\d+$/.test(k[n])&&(k[n]=k[n]>0?Math.min(k[n],p):0),!a&&f.queue&&(o!=k[n]&&m(f.onAfterFirst),delete k[n])}),m(f.onAfter)}).end()},b.max=function(b,c){var d=c=="x"?"Width":"Height",e="scroll"+d;if(!a(b).is("html,body"))return b[e]-a(b)[d.toLowerCase()]();var f="client"+d,g=b.ownerDocument.documentElement,h=b.ownerDocument.body;return Math.max(g[e],h[e])-Math.min(g[f],h[f])}})(jQuery)