jQuery(function( $ ){
	var next = 2;
	var prev = 0;
	if( location.hash ){
		next = parseInt(location.hash.slice(1))+1;
		prev = parseInt(location.hash.slice(1))-1;
	}
	
	//hoogte van de div aanpassen om een scrollbalk over het hele venster te krijgen!
	$('#content').css({height:$(window).height()});
	//$('#headerholder').css({width:$(window).width()-20});
	//$('#headerholder').css({'border': '1px solid #ccc'});
	
	$.localScroll.defaults.axis = 'y';
	
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#content', 
		queue:true,
		duration:0
	});
	
	$.localScroll({
		target: '#content', 
		queue:true,
		duration:1000,
		hash:true,
		easing:'easeInOutQuint',
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			next = (parseInt(anchor.id)+1);
			prev = (parseInt(anchor.id)-1);
			//alert(anchor.id + "\n next:" + next + "\n prev:" + prev);
			// The 'this' contains the scrolled element (#content)
		}
	});
	
	
	$(document).keyup(function(e)
	{
		switch(e.which)
		{
			// links
			case 37:
				if(prev>0) {
					$.localScroll.arrowscroll({target: '#content', queue:true, duration:0},"/#"+prev);
					prev--;
					next--;
				}
			break;	
			// omhoog
			case 38:	
				if(prev>0) {
					$.localScroll.arrowscroll({target: '#content', queue:true, duration:0},"/#"+prev);
					prev--;
					next--;
				}
			break;
			// rechts
			case 39:	
				$.localScroll.arrowscroll({target: '#content', queue:true, duration:0},"/#"+next);
				next++;
				prev++;
			break;
			// beneden
			case 40:
				$.localScroll.arrowscroll({target: '#content', queue:true, duration:0},"/#"+next);
				next++;
				prev++;
			break;
		}
		
	});
	
});
