$(document).ready(function() { $('#imagerotate ul li').not(".active").hide(); setInterval(imgrot,5000); });

function imgrot() {
  var $active = $('#imagerotate ul li.active');
  if ( $active.length == 0 ) $active = $('#imagerotate ul li:last');
  var $next =  $active.next().length ? $active.next() : $('#imagerotate ul li:first');
  $active.addClass('last-active').removeClass("active").fadeOut("slow",function(){
    $next.addClass('active').fadeIn("slow");
  });
}
