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