/*
 * jQuery One Page Nav Plugin
 * http://github.com/davist11/jQuery-One-Page-Nav
 *
 * Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://jquery.org/license
 *
 * @version 0.3
 */
(function(e){e.fn.onePageNav=function(k){var g=e.extend({},e.fn.onePageNav.defaults,k),c={};c.sections={};c.bindNav=function(a,d,b,f,l){var h=a.parent(),i=a.attr("href"),j=e(document);if(!h.hasClass(b)){c.adjustNav(d,h,b);j.unbind(".onePageNav");e.scrollTo(i,l,{offset:0,onAfter:function(){if(f)window.location.hash=i;j.bind("scroll.onePageNav",function(){c.scrollChange(d,b)})}})}};c.adjustNav=function(a,d,b){a.find("."+b).removeClass(b);d.addClass(b)};c.getPositions=function(a){a.find("a").each(function(){var d=
e(this).attr("href"),b=e(d).offset();b=b.top;c.sections[d.substr(1)]=Math.round(b)})};c.getSection=function(a){var d="",b=Math.round(e(window).height()/2);for(var f in c.sections)if(c.sections[f]-b<a)d=f;return d};c.scrollChange=function(a,d){c.getPositions(a);var b=e(window).scrollTop();b=c.getSection(b);b!==""&&c.adjustNav(a,a.find("a[href=#"+b+"]").parent(),d)};c.init=function(a,d){a.find("a").bind("click",function(b){c.bindNav(e(this),a,d.currentClass,d.changeHash,d.scrollSpeed);b.preventDefault()});
c.getPositions(a);e(document).bind("scroll.onePageNav",function(){c.scrollChange(a,d.currentClass)})};return this.each(function(){var a=e(this),d=e.meta?e.extend({},g,a.data()):g;c.init(a,d)})};e.fn.onePageNav.defaults={currentClass:"current",changeHash:false,scrollSpeed:750}})(jQuery);
