$(document).ready(function() {	
	
	// Splash
	if ($('#splash').length) {
		function removeSplash() {
			// If the browser supposrt CSS transitions, use that (it performs better)
			if ($('html').hasClass('csstransitions'))
				$('#splash').addClass('hideSplash');
			// If the browser does not support CSS transitions, use JS
			else {
				$('#splash').fadeOut(1000); // Fadeout time in ms
				// When changing the fadeout time, make sure to also change it in stylesheet.css (lines 178-181 [transition:opacity 2s, visibility 2s 2s;])
			}
		}
		
		// Remove the splash early if some one clicks enter
		$('#splash a[href="#enter"]').bind('click', function(e) {
			removeSplash();
			
			$(this).blur();
			e.preventDefault();
		});
		
		var t = setTimeout(function(){
			removeSplash();
		}, 2000); // Time before automatically fading out the splash, in ms
	}
	
	// Homepage gallery
	if ($('#gallery').length) {
		$('ul#gallery').cycle({
			fx: 'fade',
			delay: 3500, // Delay before starting, should match the time above for automatically fading out the splash
			timeout: 3000, // Milliseconds between slide transitions
			speed: 1000 // speed of the transition
		});
	}	
});
