	var fotos = new Array();
	var links = new Array();
	var preload = new Array();
	
	$(document).ready(function(){
	
		if (lang == "nl")
		{
			


			fotos[0] = "modular.jpg";
			fotos[1] = "modular1.jpg";
			fotos[2] = "modular2.jpg";
			fotos[3] = "modular3.jpg";
			fotos[4] = "modular4.jpg";

			links[0] = "/nl/over-akd";
			links[1] = "/nl/over-akd";
			links[2] = "/nl/over-akd";
			links[3] = "/nl/over-akd";
			links[4] = "/nl/over-akd";

		}
		else if (lang == "en")
		{


			fotos[0] = "en-modular.jpg";
			fotos[1] = "en-modular1.jpg";
			fotos[2] = "en-modular2.jpg";
			fotos[3] = "en-modular3.jpg";
			fotos[4] = "en-modular4.jpg";

			links[0] = "/en/about-akd";
			links[1] = "/en/about-akd";
			links[2] = "/en/about-akd";
			links[3] = "/en/about-akd";
			links[4] = "/en/about-akd";
		}
		for (var i = 0; i < fotos.length; i++)
		{
			preload[i] = new Image();
			preload[i].src = "images/"+fotos[i];
		}
	
		initFotoFade();
		featureMenu();
	});
	
	function initFotoFade() {
		
		var websiteBox = $("#content");
		var fotoBox = $("#fading");
		
		/* Hide the original foto */
		
		websiteBox.css({
			'background' : 'transparent',
			'position' : 'absolute',
			'z-index' : '1'
		});
		fotoBox.css({
			'position' : 'absolute',
			'left' : '0',
			'top' : websiteBox.offset().top+"px",
			'width' : '991px',
			'z-index' : '0'
		});
		var initNr = Math.round(Math.random() * fotos.length - 1);
		fotoBox.append("<img id=\"fadeImg\" src=\"images/"+fotos[initNr]+"\" width=\"991\" style=\"display: block; height: "+websiteBox.css("height")+"\" alt=\"\" />");
		websiteBox.append("<a id=\"modular-link\" href=\""+links[initNr]+"\"><img style=\"display: block; width: 400px; height: 185px; border: 0;\" src=\"images/1x1.gif\" alt=\"\" /></a>");
		
		var nextNr = initNr;
		
		if (nextNr < 0) nextNr = 0;
		
		nextImg(nextNr);
	}
	
	function nextImg(nr) {
		
		var CrossFadeDuration = 5;
		var el = document.getElementById("fadeImg");
		if (document.all){
			el.style.filter="blendTrans(duration=2)";
			el.style.filter="blendTrans(duration=CrossFadeDuration)";
			el.filters.blendTrans.Apply();
		}
		el.src = preload[nr].src;
		if (document.all) {
			el.filters.blendTrans.Play();
		}

		$("#modular-link").attr('href', links[nr]);
		
		var next = nr + 1;
		if (next == fotos.length) next = 0;
		
		//var next = nr + 1; //Math.round(Math.random() * fotos.length - 1);
		
		if (next < 0) next = 0;
		
		window.setTimeout(function(){ nextImg(next); }, 10000);
	}
	
	function nrInArray(array, img) {
		for (var i = 0; i < array.length; i++)
		{
			var arrayimg = ""+ array[i];
			img = ""+ img;
			if (array[i] == img) return i;
		}
		return 0;
	}
	
	var featureHover = false;
	
	function featureMenu() {
		$("a.feature").mouseover(function(){
			var marginheight = ($(this).siblings("div").height() / 2) - 15;
			$(this).siblings("div").css({
				'display' : 'block',
				'margin-top' : "-"+marginheight +"px"
			});
			$(this).parent().siblings().children("a.feature").removeClass("feature-active");
			$(this).addClass("feature-active");
			$(this).parent().siblings().children("div").hide();
			featureHover = true;
		});
		$("a.feature").mouseout(function(){
			featureHover = false;
			window.setTimeout(function(){ hideFeature(); }, 500);
		});
		$(".mouseover-box").mouseover(function(){
			featureHover = true;
			$(this).show();
			$(this).siblings("a.feature").addClass("feature-active");
		});
		$(".mouseover-box").mouseout(function(){
			featureHover = false;
			$(this).hide();
			$(this).siblings("a.feature").removeClass("feature-active");
		});
	}
	
	function hideFeature(){
		if (!featureHover)
		{
			$(".mouseover-box").hide();
			$("a.feature").removeClass("feature-active");
		}
	}
	
	
	
	