
var animations=new Array();
var calledInterval=false;

var Animation=function(id,fileName,count){
this.id=id;this.index=0;this.images=generateImages(fileName,count);
}
function generateImages(fileName,count){
var images=new Array();
for(var i=1;i<=count;i++){
var image=new Image();
image.src=fileName.replace('{0}',i);

images[images.length]
=image;
}
return images;
}

function animateImage(id,fileName,count,title,delay){
delay=delay||3500;var anim=new Animation(id,fileName,count);
animations[animations.length]=anim;var imgElem='<img id="'+id+'" src="'+anim.images[0].src+'"';if(title){imgElem+=' alt="'+title+'" title="'+title+'"';}
imgElem+=' />';document.write(imgElem);if(!calledInterval){setInterval('animate()',delay);calledInterval=true;}}
function animate(){for(var i=0;i<animations.length;i++){animations[i].index++;if(animations[i].index==animations[i].images.length){animations[i].index=0;}
document.getElementById(animations[i].id).src=animations[i].images[animations[i].index].src;}}
