/**
 * variabelen met jQuery met een $ beginnen!!!
 */
Cufon.replace('h1');

$(function()
{
	
/* Subsubmenu */
	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).fadeIn(400);									
				}
			},
			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();
	
	// Formulier focus op velden
	$(":input").not("input[type=button], input[type=submit], input[type=radio], input[type=checkbox]").focus(function() { $(this).addClass("veldfocus"); });
	$(":input").not("input[type=button], input[type=submit], input[type=radio], input[type=checkbox]").blur(function() { $(this).removeClass("veldfocus"); });
	
	$("#aanbieding li").hoverClick();
	$("#nieuwsoverzicht li").hoverClick();
	$("#nieuws li").hoverClick();

	// voor internet explorer schaduw achter submenu
	if($.browser.msie)
	{
		$("#menu ul").each(function()
		{
			var schaduw_div = $("<div class='shadow'><div class='box'></div></div>").insertBefore(this);
			
			schaduw_div.width( $(this).innerWidth() + 40 );
			schaduw_div.css({ zoom: 1, position: 'absolute', marginLeft: -15, marginTop: 15 }).css( $(this).offset() );
			
			var schaduw_box = $(".box", schaduw_div);			
			
			schaduw_box.height( $(this).height() ).width( $(this).innerWidth() );
			schaduw_box.css({ backgroundColor: '#fff', zoom: 1, position: 'relative' });
			schaduw_box[0].style.filter = "progid:DXImageTransform.Microsoft.Blur(makeShadow=true, pixelRadius=20 shadowOpacity=0.6, enabled=true);";		
		
			schaduw_div.hide();
		});
	}

});
