$(function() {
    $('.slider > :first').show();
    setTimeout(rotate, 5000);
});

function rotate() {
  var c = $('.slider > :visible').css({ 'z-index': 2 }).fadeOut(2000, function() {
    setTimeout(rotate, 5000);
  }).next().css({ 'z-index': 1 }).fadeIn(2000);
  if(c.length == 0) $('.slider > :first').css({ 'z-index': 1 }).fadeIn(2000);
}
