$(document).ready(function(){
     $('a.lightbox').fancybox({
		'titleShow'		: true,
		'titlePosition' : 'inside'
	});

	$('ul#media').jcarousel({
        vertical: true,
        scroll: 3,
		speed: 'slow'
    });

// Fade in thumbnail images and banner images
	$('.jcarousel-prev').hide();
	$('.jcarousel-next').hide();
	$('.album-wrapper span').hide();
	$('a.thumbnail').children('img').each(function() {
		// Hide the image
		$(this).hide().stop();

		// Create the image resource
		var $t  = $(this);
		var img = new Image();
		img.onload = function() {
			$t.fadeIn(function(){
				//fade in image title when image has been loaded
				$(this).siblings('span').fadeIn('slow');
				
				//is last element loaded?
				if($('a.thumbnail>img').last().attr('src') === $(this).attr('src')){
					//Display next and previous buttons when all images are loaded
					$('.jcarousel-prev').fadeIn('slow');
					$('.jcarousel-next').fadeIn('slow');
				}
			});
		}

		// Load the image
		img.src = $(this).attr('src');
	});
});

