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