// (c) 4-Dimensions
// Laatste update: 11-2009
function closeBox() {
	// Sluit box, transparantielaag en foto
	$("#box").fadeOut("fast");
	$("#trans").fadeOut("slow");
	$("#photo").fadeOut("fast");
	// Moet ook weg, anders staan dezelfde thumbnails bij het volgende album
	$(".albumNav").fadeOut("fast");
}
// Als javascript 'klaar staat'
$(document).ready(function(){
	// Klik op thumbnail
	$('.albumNav span').click(function() {
		// Verwijder 'oude' foto en titel
		$('#imgID').remove();
		$('#imgTitle').remove();
		// Voeg nieuwe foto in
		$('#photo').append('<img id="imgID" src="'+$(this).attr("id")+'" />');
		// Mooi effect
		$("#photo img").fadeIn("normal");
		// Als er een titel meegegeven is, laat titel zien
		if (!$(this).attr("title") == "") {
			$('#photo').append('<h2 id="imgTitle">'+$(this).attr("title")+'</h2>');
		}
	});
	// Klik op link om album te openen
	$('a.album').click(function() {
		// Verschoon eventuele foto uit ander album
		$('#imgID').remove();
		$('#imgTitle').remove();
		// Open box, transparatielaag en foto
		$("#box").fadeIn("fast");
		$("#trans").fadeIn("slow");
		$("#photo").fadeIn("fast");
		// Zorgt ervoor dat het juiste album geopend wordt met mooi effect
		$($(this).attr('id').replace('album-','#showalbum-')).fadeIn("fast");
		// Als er een alt-tag is opgegeven, gebruik die foto als eerste
		if (!$(this).attr("alt") == "") {
			$('#photo').append('<img id="imgID" src="'+$(this).attr("alt")+'" />');
			$("#photo img").fadeIn("normal");
		}
	});
	// Klik op transparantie sluit album
	$('#trans').click(function() {
		closeBox();
	});
	// Klik op kruisje sluit album
	$('.close').click(function() {
		closeBox();
	});
});
