// JavaScript Document
var i = new Image;
i.src = 'images/ajax-loader.gif';
var slide_started = false;
$(function() {
	$('#s3 img').eq(0).load(function(){
		doSlide();
	});
	
	$('#pause').click(function(){
		$('#s3').cycle('pause');
		$(this).hide().next().show();
		return false;
	});
	
	$('#play').css({display:'none'}).click(function(){
		$('#s3').cycle('resume');
		$(this).hide().prev().show();
		return false;
	});
	
	$('#s3').css({
		background: 'url(images/ajax-loader.gif) center center no-repeat'
	});
	
});

function doSlide() {
	if (!slide_started) {
		slide_started = true;
		$('#s3').animate({opacity:0}, 500, function(){ // fade out preloader
			$('#s3 img').show();
			$('#s3').css({background: 'none'}).animate({opacity: 1}, 500, function(){ // fade in
				$('#s3').css({background: 'none'}).cycle({
					fx:     'fade',
					speed:   1000,
					timeout: 3000,
					next:   '#next2',
					prev:   '#prev2'
				});
			});
		});
	}
}

setTimeout(function(){
	doSlide();
}, 2500);