
// When the DOM is ready
$('document').ready(function(){
	// Set Fancybox defaults
	$.fn.fancybox.defaults.overlayColor = '#000';
	$.fn.fancybox.defaults.overlayOpacity = 0.7;
	$.fn.fancybox.defaults.hideOnContentClick = false;
	$.fn.fancybox.defaults.padding = 0;

	// Fancybox links
	$('a.fancybox').fancybox({
		titlePosition : 'inside'
	});
	
	//  Fade in thumbnail images
	$('div[class="images"] ul li a, a.thumbnail, .image a, #banner').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();
		}
		
		// Load the image
		img.src = $(this).attr('src');
	});

	// Horizontal jCarousel
	$('.jcarousel-h').each(function() {
		// Note that we only activate the carousel with 2 or more images
		if($(this).children().length > 2) {
			$(this).jcarousel({
				scroll : 2
			});
		}
	});

	// Vertical jCarousel
	$('.jcarousel-v').each(function() {
		// Note that we only activate the carousel with 3 or more images
		if($(this).children().length > 3) {
			$(this).jcarousel({
				vertical : true,
				scroll : 3
			});
		}
	});

	// Sponsor logo's jCarousel
	$('.jcarousel-skin-sponsor').each(function() {
		// Note that we only activate the carousel with 3 or more images
		if($(this).children().length > 3) {
			$(this).jcarousel({
				scroll : 1,
				auto: 1,
				wrap: 'last',
				easing: 'easeInOutQuint',
				buttonNextHTML: null,
				buttonPrevHTML: null,
				animation: 1000
			});
		}
	});
});
