var huidige_fotoIndex = 0;
var slideshowInterval = null;

// slideshow starten
function startSlideshow()
{				
	slideshowInterval = setInterval(volgendeFoto, 4000);
}


// slideshow stoppen
function stopSlideshow()
{
	clearInterval(slideshowInterval);
}


// volgende foto tonen
function volgendeFoto()
{
	if(huidige_fotoIndex++ >= fotos[huidige_categorie].length-1)
		huidige_fotoIndex = 0;
			
	showFoto( huidige_categorie, huidige_fotoIndex );
}


// foto laten zien
function showFoto( categorie, fotoIndex )
{
	var preloader = new Image();
	preloader.alt = '';
	preloader.onload = function()
	{					
		$("#slideshow .foto").append(preloader);
		$(preloader).hide().fadeIn(700, function()
		{
			if($.browser.msie)	{
				$("#slideshow .foto img:eq(0)").css({ filter: "", height: 1, width: 1 });
				setTimeout(function() { $("#slideshow .foto img:eq(0)").remove(); }, 10);
			}
			else	{
				 $("#slideshow .foto img:eq(0)").remove();	
			}
		});
	};
	
	preloader.src = fotoMap + fotos[categorie][fotoIndex];
}


// navigatie vorige/volgende
$("#slideshow .navigatie a").click(function() 
{ 
	stopSlideshow();
	
	aantal_fotos = fotos[huidige_categorie].length-1;
	
	switch(this.className)		{
		case 'volgende':
			if(huidige_fotoIndex++ >= aantal_fotos)
				huidige_fotoIndex = 0;
			break;
			
		case 'vorige':
			if(huidige_fotoIndex-- <= 0)
				huidige_fotoIndex = aantal_fotos;
			break;
	}
	
	showFoto( huidige_categorie, huidige_fotoIndex );
});			


// categorie kiezen
$("#slideshow .categorie a").click(function() 
{ 
	stopSlideshow();
	
	$("#slideshow .categorie li").removeClass("actief");
	$(this).parent().addClass("actief");
	
	huidige_categorie = this.className;
	huidige_fotoIndex = 0;
	
	showFoto( huidige_categorie, huidige_fotoIndex );
});


// bij hover het menu laten zien
/*$("#slideshow .holder").hover(
	function() { $("#slideshow .menu").animate({ height: 'show', opacity: 'show' }); },
	function() { $("#slideshow .menu").animate({ height: 'hide', opacity: 'hide' }); }
);*/	


// slideshow starten
startSlideshow();
