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 fotoboekje()
{
	$('#kolomrechts .fotos .fotogroot p img').load(function()
	{
		$('#kolomrechts .fotos .fotogroot').height(this.height);
	});
	
	// Bij klik op foto deze foto in vergroting zetten
	var imgLoader = null;
	var link = $("#kolomrechts .fotos ul li a:first");
							
	$("#kolomrechts .fotos ul a").mouseover(function()
	{
		// als de ingeladen foto hetzelfde is als de hover foto deze niet veranderen
		if($('#kolomrechts .fotos .fotogroot p img').attr("src") == datamap +"/"+ this.rel)
			return false;
		
		link = this;
		$('#kolomrechts .fotos .fotogroot p').fadeOut(200, function()
		{
			// foto preloaden
			var imgLoader = new Image();  
			imgLoader.onload = function()	
			{
				$('#kolomrechts .fotos .fotogroot').animate({ height: imgLoader.height }, 500);
				$('#kolomrechts .fotos .fotogroot p img').attr({ src: imgLoader.src, alt: $(link).attr("title") });
				$('#kolomrechts .fotos .fotogroot p').fadeIn(200);
			}
			imgLoader.src = datamap +"/"+ link.rel;	
			
			$('#kolomrechts .fotos .fotogroot p a').attr("href", link.href);
		});
	});	
	
	$("#kolomrechts .fotos ul li a").lightBox({
		// Configuration related to overlay
		overlayBgColor: 		'#D0EAF8',	
		overlayOpacity:			0.8,
		imageLoading:			submap + '/img/lightbox/ico-loading.gif',
		imageBtnPrev:			submap + '/img/lightbox/btn-prev.gif',	
		imageBtnNext:			submap + '/img/lightbox/btn-next.gif',	
		imageBtnClose:			submap + '/img/lightbox/btn-close.gif',
		imageBlank:				submap + '/img/lightbox/blank.gif',
		txtImage:				'Afbeelding',	
		txtOf:					'van de'
	});
	
	$('#kolomrechts .fotos .fotogroot p a').click(function() { $(link).trigger("click"); return false; });
}


$(function()
{
	$("#opgeleverde-projecten .overzicht li").hoverClick();   
	
	/* 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>div").hide();
					$("#menu>li").not(this).removeClass("hover");
					
					$(this).addClass("hover");
					$(">div", this).show();	
					//$(">div>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();
	
	
	/* ------------------------- */
	/* Formulier focus op velden */
	/* ------------------------- */
	$(":input").focus(function() {
		$(this).addClass("veldfocus");
	});
	$(":input").blur(function() {
		$(this).removeClass("veldfocus");
	});


	
});

sIFR.replaceElement(named({ sSelector:"#main h1", sFlashSrc: submap + "/fla/frutiger.swf", sColor:"#68bce7", sBgColor:"#FFFFFF", sWmode:"transparent" }));
sIFR.replaceElement(named({ sSelector:"#main h2", sFlashSrc: submap + "/fla/frutiger.swf", sColor:"#68bce7", sBgColor:"#FFFFFF", sWmode:"transparent" }));



