$(document).ready(function(){
  rotatePics(1);
});

function rotatePics(currentPhoto) {
  var numberOfPhotos = $(".home-img li, h3").length;
  currentPhoto = currentPhoto % numberOfPhotos;
  
  $('.home-img li, h3').css(
  {'display': 'inline'
}
  );
  $(".home-img li, h3").eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
    $(".home-img li, h3").each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotatePics(++currentPhoto);}, 6000);
  });
}

