/* functie om hele blokken klikbaar te maken, en hover toevoegen */
$.fn.hoverClick = function()
{
	this.each(function()
	{
		$(this).hover(
			function() { $(this).addClass("hover").css("cursor", "pointer"); },
			function() { $(this).removeClass("hover").css("cursor", "pointer"); }
		);
		
		$(this).attr("title", $("a:first", this).attr("title"));
		
		$(this).click(function(){
			window.location = $("a:first", this).attr("href");
		});
	});
	
	return this;
};

$(function()
{
	
	$("#nieuwsoverzicht li").hoverClick();
	
	// Formulier focus op velden
	$(":input").not("input[type=button], input[type=submit]").focus(function() { $(this).addClass("veldfocus"); });
	$(":input").not("input[type=button], input[type=submit]").blur(function() { $(this).removeClass("veldfocus"); });
	
	// Menu
	/* Subsubmenu */
	var menu = {};
	
	menu.laatstGeopend = null;
	menu.timeoutTime = 2000;
	menu.timeout = null;
	
	menu.init = function()
	{	
		var classname = '';
		$("#menu>li").hover(
		function()
		{
			// als laatstegeopend dezelfde is als de huidige, dan de timeout verwijderen
			if($(this).hasClass("hover"))
			{
				clearTimeout(menu.timeout);
			}
			// nieuwe uitschuiven
			else
			{
				$("#menu>li>div").hide();
				$("#menu>li").each(function()
				{
					classname2 = $(this).attr("class").split(" ")[1];
					$(this).removeClass(classname2+" hover");
				});
				
				classname = $(this).attr("class");
				$(this).addClass(classname+'-hover hover');
				$(">div", this).show();	
			}
		},
		function()
		{
			// timeout zetten om na x aantal sec te sluiten
			menu.laatstGeopend = this;
			menu.timeout = setTimeout(function()
			{
				$(menu.laatstGeopend).removeClass(classname+'-hover hover'); 
				
			}, menu.timeoutTime);
		});
	}
	menu.init();

});
