function loadHorNav() {
	var scrollStep = 500;
	var barWidth = 980;
	var totalWidth = getTotalWidth();
	var minScrollPos = -(totalWidth - barWidth);
	
	if ($('#horNavWrapper ul a.active').length) {
		var activeElementWidth = $('#horNavWrapper ul a.active').outerWidth();
		var activeElementPosition = $('#horNavWrapper ul a.active').position().left + activeElementWidth;
	}
	
	debugThis('reset');
	debugThis('Init[ totalWidth: '+totalWidth+', minScrollPos: '+minScrollPos+', scrollStep: '+scrollStep+', activeElementPosition: '+ activeElementPosition +', activeElementWidth: '+ activeElementWidth +' ]');
	
	$('.nextNavButton a').bind("click", function(e){
		var curPos = getCurrentPosition();
		if (curPos-scrollStep < minScrollPos) {	var newPos = minScrollPos; } else {	var newPos = (parseInt(curPos)-scrollStep);	}
		var leftPos = newPos+'px';		
	    $('#horNavWrapper ul').stop();
	    $('#horNavWrapper ul').animate({ 
	        left: leftPos
	    }, 300 , 'linear', function(e) { updateNavigation();});
		return false;
	});
	
	$('.previousNavButton a').bind("click", function(e){
		var curPos = getCurrentPosition();
		if ((parseInt(curPos)+scrollStep) > 0) { var newPos = 0; } else {	var newPos = (parseInt(curPos)+scrollStep);	}
		var leftPos = newPos+'px';
	    $('#horNavWrapper ul').stop();
	    $('#horNavWrapper ul').animate({ 
	        left: leftPos
	    }, 300 , 'linear', function(e) { updateNavigation(); });
		return false;
	});
	
	$('.paraItem').bind("click", function(e){
		$('.paraItem').removeClass("active");
		$(this).toggleClass("active");
	});

	if (activeElementPosition >= (barWidth-100)) {
		var newPos = -(activeElementPosition - (barWidth/2) + (activeElementWidth/2));
		if (newPos < minScrollPos) { newPos = minScrollPos; }
		
		$('#horNavWrapper ul').animate({ 
	        left: newPos
	    }, 0 , 'linear', function(e) { updateNavigation(); });
	}
	
	var currentUrlAnchor = parseInt(self.document.location.hash.substring(1));
	debugThis('Init [ currentUrlAnchor: '+currentUrlAnchor+' ]');
	
	if (currentUrlAnchor > 0) {
		$('.paraItem').removeClass("active");
		$('#paraNav_'+currentUrlAnchor).toggleClass("active");
		checkPosition(currentUrlAnchor);
	}
	updateNavigation();
	
	// de hele boel zichtbaar maken...
	$('#horNavWrapper ul').css('visibility','visible');
}
function checkPosition( current ) {
	if (current != null && $('#paraNav_'+current) && $('#paraNav_'+current).length) {
		var barWidth = 980;
		var totalWidth = getTotalWidth();
		var minScrollPos = -(totalWidth - barWidth);
		var curPos = getCurrentPosition();
		
		var elementLeft = $('#paraNav_'+current).position().left;
		var elementRight = elementLeft + $('#paraNav_'+current).outerWidth();
		
		if (parseInt(elementLeft) < parseInt(barWidth)) {
			debugThis('hai!');
			var newPos = 0;
		} else {
			var newPos = barWidth - elementRight - 59;
			if (newPos < minScrollPos) { newPos = minScrollPos; }
		}
		
		debugThis('checkPosition [ elementLeft: '+elementLeft+', curPos: '+curPos+', newPos: '+newPos+',totalWidth: '+totalWidth+' ]')
		
		$('#horNavWrapper ul').animate({ 
	        left: newPos
	    }, 300 , 'linear', function() {
	    	updateNavigation();
	    });

	}
}
function getCurrentPosition() {
	if ($('#horNavWrapper ul').length) {
		curPos = $('#horNavWrapper ul').position().left;
		return curPos;
	} else {
		return 0;
	}
}
function getTotalWidth() {
	var totalWidth = 0;
	$('#horNavWrapper ul li').each( function(i,e) {
		totalWidth = totalWidth + parseInt( $(e).width() );
	});
	return totalWidth;
}
function updateNavigation() {
	var curPos = getCurrentPosition();
	debugThis('updateNavigation[ curPos: '+curPos+' ]');
	var totalWidth = getTotalWidth();
	var minScrollPos = -(totalWidth - 980);	
	if (totalWidth > 980 && curPos > minScrollPos+10) {
		$('.nextNavButton').show()
	} else {
		$('.nextNavButton').hide()
	}
	
	if (curPos < 0) {
		$('.previousNavButton').show()
	} else {
		$('.previousNavButton').hide()
	}
}

function debugThis( string ) {
	if (string == 'reset') {
		$('#debug').val('');
	} else {
		var currentVal = $('#debug').val();
		$('#debug').val( currentVal + string + "\n" );	
	}
}