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