(function(f){var e=f.scrollTo=function(a,b,c){f(window).scrollTo(a,b,c)};e.defaults={axis:"y",duration:1};e.window=function(a){return f(window).scrollable()};f.fn.scrollable=function(){return this.map(function(){var a=this.parentWindow||this.defaultView,c=this.nodeName=="#document"?a.frameElement||a:this,b=c.contentDocument||(c.contentWindow||c).document,h=c.setInterval;return c.nodeName=="IFRAME"||h&&f.browser.safari?b.body:h?b.documentElement:this})};f.fn.scrollTo=function(a,b,c){if(typeof b=="object"){c=b;b=0}if(typeof c=="function"){c={onAfter:c}}c=f.extend({},e.defaults,c);b=b||c.speed||c.duration;c.queue=c.queue&&c.axis.length>1;if(c.queue){b/=2}c.offset=d(c.offset);c.over=d(c.over);return this.scrollable().each(function(){var o=this,q=f(o),p=a,r,t={},v=q.is("html,body");switch(typeof p){case"number":case"string":if(/^([+-]=)?\d+(px)?$/.test(p)){p=d(p);break}p=f(p,this);case"object":if(p.is||p.style){r=(p=f(p)).offset()}}f.each(c.axis.split(""),function(k,j){var i=j=="x"?"Left":"Top",g=i.toLowerCase(),l="scroll"+i,n=o[l],m=j=="x"?"Width":"Height",h=m.toLowerCase();if(r){t[l]=r[g]+(v?0:n-q.offset()[g]);if(c.margin){t[l]-=parseInt(p.css("margin"+i))||0;t[l]-=parseInt(p.css("border"+i+"Width"))||0}t[l]+=c.offset[g]||0;if(c.over[g]){t[l]+=p[h]()*c.over[g]}}else{t[l]=p[g]}if(/^\d+$/.test(t[l])){t[l]=t[l]<=0?0:Math.min(t[l],u(m))}if(!k&&c.queue){if(n!=t[l]){s(c.onAfterFirst)}delete t[l]}});s(c.onAfter);function s(g){q.animate(t,b,c.easing,g&&function(){g.call(this,a,c)})}function u(h){var i="scroll"+h,g=o.ownerDocument;return v?Math.max(g.documentElement[i],g.body[i]):o[i]}}).end()};function d(a){return typeof a=="object"?a:{top:a,left:a}}})(jQuery);