
// Cycle through banners
$('.banner').cycle({
	fx : 'fade',
	timeout: 4000,
	speedIn:  2500, 
	speedOut: 1250,
	nowrap : 0
});

// Set Fancybox defaults
$.fn.fancybox.defaults.overlayColor = '#000';
$.fn.fancybox.defaults.overlayOpacity = 0.7;
$.fn.fancybox.defaults.hideOnContentClick = false;
$.fn.fancybox.defaults.titlePosition = "inside";

// Fancybox links
$('a.fancybox').fancybox();

// 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
		});
	}
});

// Fade in images until they are fully loaded
$('.thumbnails-v ul li a, .thumbnails-h ul li a, .thumbnails-h-mini ul li a, .banner, #immo-list ul li a, #tournament-list ul li a').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');
});
