/* 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()
{
	
	/* --------------------------------	*/
	/* menu						 		*/
	/* --------------------------------	*/
	var menu = {};
	
	menu.laatstGeopend = null;
	menu.timeoutTime = 2000;
	menu.timeout = null;
	
	menu.init = function()
	{
		/* hover op li */
		$("#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>ul").hide();
					$("#menu>li").not(this).removeClass("hover");
					
					$(this).addClass("hover");	
					$(">ul", this).hide().fadeIn(300);
					
					// selectbox in <ie7 verwijderen
					if($.browser.msie && $.browser.version < 7)	{
						$("select").css({ visibility: 'hidden' });	
					}
				}
			},
			function() 
			{ 
				// timeout zetten om na x aantal sec te sluiten
				menu.laatstGeopend = this;
				menu.timeout = setTimeout(function()
				{
					$(menu.laatstGeopend).removeClass("hover"); 
					
					// selectbox in <ie7 tonen
					if($.browser.msie && $.browser.version < 7)	{
						$("select").css({ visibility: 'visible' });	
					}
				}, menu.timeoutTime);
			}
		);
	}

	menu.init();

	// sifr
	if(typeof sIFR == "function")
	{
		// This is the preferred "named argument" syntax
		sIFR.replaceElement(named({sSelector:".categorieen h2", sFlashSrc: config.submap +"fla/helvetica.swf", sColor:"#FFFFFF", sWmode:'transparent'}));
	}

	// default text in zoekbox
	$(".zoeken #txt_zoeken").inputDefaultText({ default_txt:"Zoek op trefwoord of artikel" });
	
	$("form#frm_zoeken").submit( function()
	{
		if ( $(".zoeken #txt_zoeken").val() == "Zoek op trefwoord of artikel" || $(".zoeken #txt_zoeken").val() == "" )
		{
			$(".zoeken #txt_zoeken").focus();
			alert("U heeft geen zoekterm ingevoerd.");
			return false;
		}
	});

});