$(document).ready(function(){
	homepage();
	subpage();

	var snelheid = 100;
	$('#menu > li').each(function(){
		$(this).hover(
			function(){
				$(this).siblings().find('ul').fadeOut(snelheid,function(){ $(this).css('visibility','hidden'); });
				$(this).addClass('huidig2');
				//if (!$(this).hasClass('huidig')){
				//	$('#menu > .huidig').addClass('hover');
				//}
				$(this).find('ul').css('visibility','visible').fadeIn(snelheid);
			},
			function(){
				//if (!$(this).hasClass('huidig'))
				//console.log($(this).find('ul').count);
				$(this).find('ul').fadeOut(snelheid);
				$(this).removeClass('huidig2');
				$('#menu > li').removeClass('hover');
			}
		);
	});

	$('#menu').hover(function(){},function(){
		//$('#menu li.huidig ul').css('visibility','visible').fadeIn(snelheid);
	});
});

function homepage(){
	//$('#content').css('height','255px');
	//$('#contentwrapper').css('visibility','visible');
	$('a').each(function(){
		var hreflocatie = $(this).attr('href');
		if (hreflocatie && hreflocatie.indexOf('#')===-1){
			$(this).click(function(){
				$(this).removeAttr('href');
				$('.submenu').fadeOut();
				//$('#content').slideUp('',function(){location.href = hreflocatie;});
				$('#content').animate({height:'0',paddingBottom:'0'},400,function(){location.href = hreflocatie;});
			});
		}
	});
}
function subpage(){
	var hoogte = $('#contentwrapper').height();
//	var hoogte = hoogte < 255 ? 255 : hoogte;
	$('#contentwrapper').fadeOut(0,function(){
		$(this).css('visibility','visible').fadeIn(400);
		$('#content').animate({height:hoogte+'px'},400);
	});
}
