function setNavigation() 
{
	var $parents = $('#menu-hoofdnavigatie > li:has(ul) > a');
	
	$parents.each(function()
	{
		$(this).click(function()
		{
			var $target = $(this).previous();
			$('.sub-menu:visible').slideUp();
			$target.slideToggle();
			return false;
		});
	});
	
	$('#menu-hoofdnavigatie > li:not(#menu-item-12):has(ul)').hover(function(){
			$(this).addClass('parent');
		},function(){
			$(this).removeClass('parent');		
		});
}
function correctHeight()
{
	// 170px (header) + 60px (footer) = 230px + 1px
	var maxH = parseInt($('#wrapper').height()) - 231,
		targetH= parseInt($('#menu-hoofdnavigatie').height());
	if (maxH > targetH) { $('#menu-hoofdnavigatie').css('height',maxH + 'px'); }
}

$(document).ready(function(){
	// Fix layout
	correctHeight();
	$(window).resize(function() { correctHeight(); });
	// Click behavior
	setNavigation();
});
