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