/* 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).click(function(){
			window.location = $("a:first", this).attr("href");
		});
	});
	
	return this;
};

$(function() {
	
	$("#productoverzicht ul li").hoverClick();
	$("#productoverzicht ul li img").css("cursor", "pointer");
		
	/* Submenu */
	var menu = {};

	menu.laatstGeopend = null;
	menu.timeoutTime = 2000;
	menu.timeout = null;
	
	menu.init = function()
	{		
		/* hover op li */
		$("#menu>ul>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>ul>li>ul").hide();
					$("#menu>ul>li").not(this).removeClass("hover");
					
					$(this).addClass("hover");
					$(">ul", this).hide().slideDown(300);									
				}
			},
			function() 
			{ 
				// timeout zetten om na x aantal sec te sluiten
				menu.laatstGeopend = this;
				menu.timeout = setTimeout(function()
				{
					$(menu.laatstGeopend).removeClass("hover"); 
					
				}, menu.timeoutTime);
			}
		);
	}

	menu.init();
				
	if ( config.pagina_type == 'frontpage' )
	{
		// Paginatitel op frontpage
sIFR.replaceElement(named({sSelector:".frontpage #content h1", sFlashSrc:config.submap+"/fla/sifr.swf", sColor:"#b30068", sLinkColor:"#b30068", sBgColor:"#FFFFFF", sHoverColor:"#b30068", nPaddingTop:10, nPaddingBottom:10, sWmode:"transparent"}));
	}
	else
	{
		// Paginatitel op IWES pagina's
		sIFR.replaceElement(named({sSelector:"#content h1", sFlashSrc:config.submap+"/fla/sifr.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#000000", nPaddingTop:10, nPaddingBottom:10, sWmode:"transparent"}));
	}
	
});