<script language="JavaScript">
var d = new Array(<!--#echo var="anim_num" -->);
if (document.images) { // Preloaded images
   for (var i=1; i<=<!--#echo var="anim_num" -->; i++) {
      d[i] = new Image();
      d[i].src = "<!--#echo var=anim_path -->"+i+".jpg";
   }
}

function timeimgs(numb) { // Reusable timer
 thetimer = setTimeout("imgturn('" +numb+ "')", 2500);
}

function imgturn(numb) { // Reusable image turner
 if (document.images) {
  if (numb > <!--#echo var="anim_num" -->) { // This will loop the image
   document["anim_img"].src = d[1].src;
   timeimgs('1');
  } else { 
   document["anim_img"].src = d[numb].src;
   timeimgs(numb = ++numb);
  }
 }
}
timeimgs(2);
</script>
