(function(n){function i(t,i,r){var e=i.hash.slice(1),u=document.getElementById(e)||document.getElementsByName(e)[0],f,o,s;if(!u)return;t&&t.preventDefault(),f=n(r.target);if(r.lock&&f.is(":animated")||r.onBefore&&r.onBefore.call(r,t,u,f)===!1)return;r.stop&&f.stop(!0),r.hash&&(o=u.id==e?"id":"name",s=n("<a> </a>").attr(o,e).css({position:"absolute",top:n(window).scrollTop(),left:n(window).scrollLeft()}),u[o]="",n("body").prepend(s),location=i.hash,s.remove(),u[o]=e),f.scrollTo(u,r).trigger("notify.serialScroll",[u])}var r=location.href.replace(/#.*/,""),t=n.localScroll=function(t){n("body").localScroll(t)};t.defaults={duration:1e3,axis:"y",event:"click",stop:!0,target:window,reset:!0},t.hash=function(r){if(location.hash){r=n.extend({},t.defaults,r),r.hash=!1;if(r.reset){var u=r.duration;delete r.duration,n(r.target).scrollTo(0,r),r.duration=u}i(0,location,r)}},n.fn.localScroll=function(u){function f(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,"")==r&&(!u.filter||n(this).is(u.filter))}return u=n.extend({},t.defaults,u),u.lazy?this.bind(u.event,function(t){var r=n([t.target,t.target.parentNode]).filter(f)[0];r&&i(t,r,u)}):this.find("a,area").filter(f).bind(u.event,function(n){i(n,this,u)}).end().end()}})(jQuery);
