	$(document).ready(function(){	
	
		$("#showcase").imageLoader({
		
			images: [
				{ src: 'images/elements/home/large-fly.png', id: 'fly' },
				{ src: 'images/elements/home/large-surf.png', id: 'surf' },
				{ src: 'images/elements/home/large-jump.png', id: 'jump' },
				{ src: 'images/elements/home/large-race.png', id: 'race' },
				{ src: 'images/elements/home/large-relax.png', id: 'relax' }
			],
	
			splashScreenImage: 'images/elements/home/ajax-loader.gif',
			enableSplashScreenText: 0
		
		}, function(){
		
			$('#showcase img').each(function() {
				$(this).wrap('<li><a href="facilities/' + this.id + '.html" /><\/li>');
			});
				
			$('#showcase img:first').fadeIn(1500, function() {
			
				$('#slideshowNav').html("");
						
				$('#showcase').cycle({
					fx: 'fade',
					speed: 1000,
					// easing: 'easeOutBack',
					timeout: 6000,
					pause: 1,
					pager: '#slideshowNav',
					pagerEvent: 'mouseover',
					pauseOnPagerHover: true,
					allowPagerClickBubble: true,
					slideExpr: 'img',
					cleartypeNoBg: true,
					pagerAnchorBuilder: function(idx, slide) {
						return '<li class="tab' + idx + '"><a href="facilities/' + slide.id + '.html">' + slide.alt + '<\/a><\/li>';
					}
				});
						
			});		
			
		});
		
	});	
		
		var scrollSpeed = 100; 		// Speed in milliseconds
		var step = 1; 				// How many pixels to move per step
		var current = 0;			// The current pixel row
		var imageHeight = 351;		// Background image height
		var headerHeight = 351;		// How tall the header is.
		
		//The pixel row where to start a new loop
		var restartPosition = -(imageHeight - headerHeight);
		
		function scrollBg(){
		
			//Go to next pixel row.
			current -= step;
		
			//If at the end of the image, then go to the top.
			if (current == restartPosition){
				current = 0;
			}
		
			//Set the CSS of the header.
			$('#featuresBg').css("background-position","0 "+current+"px");				
		}
		
		//Calls the scrolling function repeatedly
		var init = setInterval("scrollBg()", scrollSpeed);

