$(function() {
		   
	/* Formulier */
	$(".formmodule input, .formmodule textarea").focus(function(){	$(this).addClass("focus");	});
	$(".formmodule input, .formmodule textarea").blur(function(){	$(this).removeClass("focus");	});
	
	$(".formmodule input.button").hover(
		function()	{	$(this).addClass("hover");		},
		function()	{	$(this).removeClass("hover");	}
	);
	
	
	/* Submenu */
	var menu = {};
	
	menu.laatstGeopend = null;
	menu.timeoutTime = 2000;
	menu.timeout = null;
	
	menu.init = function()
	{
		// dmv tabben het menu kunnen opnenen
		$("#menu > ul > li > a").focus(function()	{
			$("#menu > ul li").removeClass("hover");
			$(this.parentNode).addClass("hover");
		});
		
		$("#menu > ul > li > ul > li > a").focus(function()	{
			$("#menu > ul li").removeClass("hover");
			$(this.parentNode).addClass("hover");
			$(this.parentNode.parentNode.parentNode).addClass("hover");
		});
		
		$("#menu > ul > li a").blur(function()	{
			$("#menu > ul li").removeClass("hover");
		});
		
		
		/* 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);
					
					// 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();
	
	
	/* UI Effect - Wij werken voor */
	/*var effect = function(el, n, o) {
		$.extend(o, {
			easing: "easeOutQuint"
		});
		
		$(el).hover(
			function() {
				$(".wij_werken_voor ul li div").hide();
				$("div", this).show(n, o, 1000);
			}, 
			function() {
				$("div", this).hide(); 
			}
		);
	
	};
	effect(".wij_werken_voor ul li", "drop", { direction: "down" });*/

	
	/* Zoekfunctie || Wij werken voor */
	$("#zoekformulier, .wij_werken_voor ul li").hover(
		function()	{	$(this).addClass("hover");		},
		function()	{	$(this).removeClass("hover");	}
	);
	
	$("#zoekformulier>fieldset>input")
		.focus(function()	{
			$(this.parentNode.parentNode).addClass("hover2");
		})
		.blur(function()	{
			$(this.parentNode.parentNode).removeClass("hover2");
		});
	
	/* Cycle projecten in uitvoering */
	$('.projecten_in_uitvoering ul').cycle({
        fx		: 'scrollHorz',
        speed	: 'slow',
        timeout	: 7000,
        pager	: '#nav',
		pause	: 1
    });
    
    /* Cycle enkele referenties */
    $('ul.enkele_referenties').cycle({
    	fx		: 'scrollHorz',
    	speed	: 'slow',
    	timeout	: 5000,
    	pager	: '#nav',
    	pause	: 1
    });
	
	// default value bij formulieren
	$("input:text[title], textarea[title]").each(function() { 
		$(this).defaultvalue( $(this).attr("title") );
	});
	
});


Cufon.replace('.projecten_in_uitvoering h3, \
			  .maincontent .intro_pagina_kop p, \
			  .maincontent h2, \
			  #footer .balk h3, \
			  .wij_werken_voor h3, \
			  .three_buckets h3, \
			  #twitter h3, \
			  .uitgelicht h3');

/*sIFR.replaceElement(named({ sSelector:".projecten_in_uitvoering h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".home .maincontent h2", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#000000", sBgColor:"#FFFFFF", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".maincontent .intro_pagina_kop p", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#e57b07", sBgColor:"#FFFFFF", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".maincontent h2", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:"#footer .balk h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".wij_werken_voor h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".three_buckets h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:"#twitter h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:".uitgelicht h3", sFlashSrc: submap+"/fla/dinregular.swf", sColor:"#FFFFFF", sBgColor:"#333333", sWmode:"transparent" }));*/

function header_film( pagina )
{
	var s1 = new SWFObject(submap +"/fla/header_film.swf", "single", "704", "250", "8");
	s1.addParam("allowfullscreen","false");
	s1.addParam("menu","false");
	s1.addParam("wmode","transparent");	
	s1.addVariable("bestand", submap +"/fla/header_film/"+ pagina);			
	s1.write($(".header_film")[0]);	
}

/** 
 * jquery.defaultvalue 
 * @param	string	defaultvalue
*/
$.fn.defaultvalue = function( defVal )
{
	return this.each(function()
	{
		var $input = $(this);
		if($input.val() == "" || $input.val() == defVal)
		{
			$input.addClass("defaultvalue").val(defVal);
		}
		
		$input
			.focus(function() {
				if($input.val() == defVal) 
					$input.val("").removeClass("defaultvalue");
			})
			.blur(function(){
				if($input.val() == "") 
					$input.addClass("defaultvalue").val(defVal);
			});
	});
};


