var cycleTime = 8000;

fadeFour = function() {
	$( 'img#img4' ).fadeOut( 'slow', function() {
											$( 'img#img0' ).css('z-index', 5);
											$( 'img#img1' ).css('z-index', 4);
											$( 'img#img2' ).css('z-index', 3);
											$( 'img#img3' ).css('z-index', 2);
											$( 'img#img4' ).css('z-index', 1); 
											$( 'img#img4' ).show();
											setTimeout("fadeZero()", cycleTime);
											} 
							);
}
fadeThree = function() {
	$( 'img#img3' ).fadeOut( 'slow', function() {
											$( 'img#img0' ).css('z-index', 4);
											$( 'img#img1' ).css('z-index', 3);
											$( 'img#img2' ).css('z-index', 2);
											$( 'img#img3' ).css('z-index', 1);
											$( 'img#img4' ).css('z-index', 5); 
											$( 'img#img3' ).show();
											setTimeout("fadeFour()", cycleTime);
											} 
							);
}

fadeTwo = function() {
	$( 'img#img2' ).fadeOut( 'slow', function() {
											$( 'img#img0' ).css('z-index', 3);
											$( 'img#img1' ).css('z-index', 2);
											$( 'img#img2' ).css('z-index', 1);
											$( 'img#img3' ).css('z-index', 5);
											$( 'img#img4' ).css('z-index', 4); 
											$( 'img#img2' ).show();
											setTimeout("fadeThree()", cycleTime);
											} 
							);			
}

fadeOne = function() {
	$( 'img#img1' ).fadeOut( 'slow', function() {
											$( 'img#img0' ).css('z-index', 2);
											$( 'img#img1' ).css('z-index', 1);
											$( 'img#img2' ).css('z-index', 5);
											$( 'img#img3' ).css('z-index', 4);
											$( 'img#img4' ).css('z-index', 3);
											$( 'img#img1' ).show();
											setTimeout("fadeTwo()", cycleTime); 
											} 
							);	
}
fadeZero = function() {
	$( 'img#img0' ).fadeOut( 'slow', function() {
											$( 'img#img0' ).css('z-index', 1);
											$( 'img#img1' ).css('z-index', 5);
											$( 'img#img2' ).css('z-index', 4);
											$( 'img#img3' ).css('z-index', 3);
											$( 'img#img4' ).css('z-index', 2); 
											$( 'img#img0' ).show();
											setTimeout("fadeOne()", cycleTime);
											} 
							);			
}

$(document).ready( function () {
	setTimeout("fadeZero()", cycleTime);  
} );