var current = 1;
var next = 2;
var delay = 5000;
var speed = 5000;

$( function(){
	initAnimation();
});

function initAnimation(){
	window.setTimeout( animate, delay );
}

function animate(){

	// move current to top
	$('#i'+current).css( 'z-index', '100' );

	// move next to bottom, and show
	$('#i'+next).css( 'z-index', '50' ).show();
	
	// fade out current
	$('#i'+current).fadeOut( speed, initAnimation );
	
	// adjust numbers for next time
	if( ( current += 1 ) >= 4 ) current = 1;
	if( ( next += 1 ) >= 4 ) next = 1;
}