jQuery(function($){
	
	$.fn.reverse = function(){
		return this.pushStack(this.get().reverse(), arguments);
	};
		
	h2count = $('#content h2').length;
	
	$('.nav-next')
		//.prependTo("body")
		.click(function(){
			$('#nav-prev').fadeIn();
			scrollTop = $(window).scrollTop();
			$('#content h2').each(function(i, h2){
				h2top = $(h2).offset().top;
				if (scrollTop < h2top) {
					$.scrollTo(h2, 300);
					return false;
				}
			});
		});
	
	$('.nav-prev')
		//.prependTo("body")
		.click(function(){
			scrollTop = $(window).scrollTop();
			$('#content h2').reverse().each(function(i, h2){ // loop through article headings
                h2top = $(h2).offset().top; // get article heading top
                if (scrollTop > h2top) { // compare if document is above heading
                    $.scrollTo(h2, 300); // scroll to in .8 of a second
                    return false; // exit function
                }
			});
		});
		
	// Stop the click return on the links, for SCROLLER class	
	$('.scrollnav links').click(function(e){
		e.preventDefault();
		var link = e.target;
		link.blur();
	});
	// Scroll window, for SCROLLER class
	$('.scrollnav a').click(function(){
		$.scrollTo(this.hash,800);
		return false;
	});

});