$(function() {
	
	//Fotoboekje
		
	
	
	$('#fotoboekje .fotoboekthumb a:first').addClass('actief').show();
	$('#fotoboekje .fotoboekthumb a:not(:first)').hide();			
	$('.fotoboekthumb').append('<span href="#" class="previous" /><span href="#" class="next" />')
		
	aantalFotos = $('.fotoboekthumb a').length;	
	if (aantalFotos > 1){
	$('#fotoboekje .previous').css('display','none');			
	}else{
	$('#fotoboekje .previous').css('display','none');		
	$('#fotoboekje .next').css('display','none');	
	}
	
	
	function toggle(nieuwefoto){		
			
			if	(aantalFotos > 1){
				if (nieuwefoto == 1){
					$('#fotoboekje .previous').fadeOut(250);
					$('#fotoboekje .next').fadeIn(250);
				}
				
				if (nieuwefoto > 1 && nieuwefoto < aantalFotos){
					$('#fotoboekje .previous').fadeIn(250);
					$('#fotoboekje .next').fadeIn(250);
				}
				
				if (nieuwefoto == aantalFotos){
					$('#fotoboekje .next').fadeOut(250);
					$('#fotoboekje .previous').fadeIn(250);					
				}
			}	
	}	
	
		
	
	function ShowFoto(nieuwefoto, currentFoto){		
		var nieuwefoto = nieuwefoto;
				
		$('#fotoboekje .fotoboekthumb. a.actief').fadeOut(500);		
		$('#fotoboekje .fotoboekthumb a:nth-child('+ (nieuwefoto) +')').fadeIn(500);					
		
		toggle(nieuwefoto);
				
		$('.fotoboekthumb a.actief').removeClass('actief');
		$('#fotoboekje .fotoboekthumb a:nth-child('+ (nieuwefoto) +')').addClass('actief');		
	}
	
	window.ShowFoto = ShowFoto;
	
	$('#fotoboekje .next').click(function(){				
		var currentFoto = $('.fotoboekthumb a').filter('.actief').index()+1;						
		ShowFoto(currentFoto + 1,currentFoto);		
		return false;	
	});
	
	$('#fotoboekje .previous').click(function(){
		var currentFoto = $('.fotoboekthumb a.actief').index()+1;		
		ShowFoto(currentFoto - 1,currentFoto);
		return false;	
	});		
	
});

