Cufon.replace('h1,\
         #projectoverzicht h2, \
        #projectoverzicht h3, \
        #projectdetail h2, \
        #projectdetail h3, \
        #nieuwsoverzicht li h2 a, \
        #forum-onderwerp h2, \
        #forum-onderwerp .forum-formulier h3');

jQuery.extend( jQuery.easing,
{
	easeOut: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	}
});

/* 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()
{
	
	$("#projectoverzicht li, #nieuwsoverzicht li, #forum_categorieen li").hoverClick();
	
	// Submenu 
	var menu = {};
	
	menu.laatstGeopend = null;
	menu.timeoutTime = 2000;
	menu.timeout = null;
	
	menu.init = function()
	{
		$("#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").not(this).removeClass("hover");
					
					$(this).addClass("hover"); 
					$('div', this).stop().css({ top: 0, opacity: 0 }).animate({top: '43px', opacity: 1}, 600, 'easeOut');
					
					// 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()
				{
					//$('div', this).stop().animate({top: '70px', opacity: 0}, 300, 'easeOut');
					$(menu.laatstGeopend).removeClass("hover");
					
					// selectbox in <ie7 tonen
					if($.browser.msie && $.browser.version < 7)	{
						$("select").css({ visibility: 'visible' });	
					}
				}, menu.timeoutTime);
			}
		);
	}
	menu.init();
	
	// 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"); });

});

// Check login
function checkLoginFormulier(formulier)
{
	melding = '';
	
	//check of meerdere egbruikers aanvinken bestaat
	if( $("#auth_form_cookie[type='hidden']").length > 0)
	{

		//check op login en wachtwoord
		if( $("#form_auth_gebruikersnaam").val() == '' || $("#form_wachtwoord").val() == '' )
		{
			melding = 'Vul svp een gebruikersnaam en wachtwoord in.';
		}
	}
	else
	{
		if( $("#auth_form_cookie :selected").val() == '' && $("#form_auth_gebruikersnaam").val() == '' && $("#form_wachtwoord").val() == '' )
		{
			melding = 'Vul svp een gebruikersnaam en wachtwoord in.';
		}
	}

	if(melding != '' )
	{
		$("#login-melding").html(melding);
		$("#login-melding").css('z-index',460);
		$("#login-melding").fadeIn(200);		
		return false;	
	}
	else
	{
		$("#login-melding").css({display:'none'});
		return true;	
	}

}

