(function(B){var A=B.scrollTo=function(D,F,E){B(window).scrollTo(D,F,E);};A.defaults={axis:"y",duration:1};A.window=function(D){return B(window).scrollable();};B.fn.scrollable=function(){return this.map(function(){var D=this.parentWindow||this.defaultView,G=this.nodeName=="#document"?D.frameElement||D:this,F=G.contentDocument||(G.contentWindow||G).document,E=G.setInterval;return G.nodeName=="IFRAME"||E&&B.browser.safari?F.body:E?F.documentElement:this;});};B.fn.scrollTo=function(F,E,D){if(typeof E=="object"){D=E;E=0;}if(typeof D=="function"){D={onAfter:D};}D=B.extend({},A.defaults,D);E=E||D.speed||D.duration;D.queue=D.queue&&D.axis.length>1;if(D.queue){E/=2;}D.offset=C(D.offset);D.over=C(D.over);return this.scrollable().each(function(){var H=this,N=B(H),M=F,G,L={},K=N.is("html,body");switch(typeof M){case"number":case"string":if(/^([+-]=)?\d+(px)?$/.test(M)){M=C(M);break;}M=B(M,this);case"object":if(M.is||M.style){G=(M=B(M)).offset();}}B.each(D.axis.split(""),function(O,V){var T=V=="x"?"Left":"Top",R=T.toLowerCase(),U="scroll"+T,S=H[U],Q=V=="x"?"Width":"Height",P=Q.toLowerCase();if(G){L[U]=G[R]+(K?0:S-N.offset()[R]);if(D.margin){L[U]-=parseInt(M.css("margin"+T))||0;L[U]-=parseInt(M.css("border"+T+"Width"))||0;}L[U]+=D.offset[R]||0;if(D.over[R]){L[U]+=M[P]()*D.over[R];}}else{L[U]=M[R];}if(/^\d+$/.test(L[U])){L[U]=L[U]<=0?0:Math.min(L[U],I(Q));}if(!O&&D.queue){if(S!=L[U]){J(D.onAfterFirst);}delete L[U];}});J(D.onAfter);function J(O){N.animate(L,E,D.easing,O&&function(){O.call(this,F,D);});}function I(O){var Q="scroll"+O,P=H.ownerDocument;return K?Math.max(P.documentElement[Q],P.body[Q]):H[Q];}}).end();};function C(D){return typeof D=="object"?D:{top:D,left:D};}})(jQuery);