var fadeDuration=2000;
var slideDuration=4000;
var currentIndex=1;
var nextIndex=1;
$(document).ready(function(){
  $("#cycle img").hide();
  $("#cycle img:nth-child("+nextIndex+")").show().animate({opacity: 1.0}, fadeDuration);
  var timer = setInterval("nextSlide()",slideDuration);
})
 
function nextSlide(){
  nextIndex =currentIndex+1;
  if(nextIndex> $("#cycle img").length){
    nextIndex =1;
  }
  $("#cycle img:nth-child("+nextIndex+")").show().animate({opacity: 1.0}, fadeDuration);
  $("#cycle img:nth-child("+currentIndex+")").animate({opacity: 0.0}, fadeDuration).hide();
  currentIndex = nextIndex;
}

