/* initialize */
var imagerotate_current = 0;

/* rotate images with fade */
function imagerotate(count,time) {
  /* fade out old image */
  if (imagerotate_current != 0) {
    document.getElementById('rotate'+imagerotate_current).style.zIndex = '2';
    window.setTimeout('imagefade('+90+','+imagerotate_current+');',100);
    window.setTimeout('imagefade('+70+','+imagerotate_current+');',200);
    window.setTimeout('imagefade('+50+','+imagerotate_current+');',300);
    window.setTimeout('imagefade('+30+','+imagerotate_current+');',400);
    window.setTimeout('imagefade('+10+','+imagerotate_current+');',500);
    window.setTimeout('imagefade('+0+','+imagerotate_current+');',600);
  }

  /* update counter */
  imagerotate_current++;
  if (imagerotate_current > count) { imagerotate_current = 1; }

  /* fade in new image */
  document.getElementById('rotate'+imagerotate_current).style.zIndex = '1';
  document.getElementById('rotate'+imagerotate_current).style.display = 'inline';
  imagefade(100,imagerotate_current);
  window.setTimeout('imagerotate('+count+','+time+');',time);
}

/* fade image */
function imagefade(opacity, number) { 
  var object = document.getElementById('rotate'+number).style; 
  object.opacity = (opacity / 100); 
  object.MozOpacity = (opacity / 100); 
  object.KhtmlOpacity = (opacity / 100); 
  object.filter = "alpha(opacity=" + opacity + ")"; 
  if (opacity == 0) object.display = 'none';
}
