
function initImgRotation() {
  var rotator1 = new rotateImgObj('img1',2500);
  rotator1.addImages("6364d3f0f495b6ab9dcf8d3b5c6e0b011.jpg", "c16a5320fa475530d9583c34fd356ef51.jpg","33e75ff09dd601bbe69f3510391521891.jpg","34173cb38f07f89ddbebc2ac9128303f1.jpg","6ea9ab1baa0efb9e19094440c317e21b1.jpg");
  rotator1.rotate();
  
  rotateImgObj.start();  
}

rotateImgObj.imagesPath = "../files/";
rotateImgObjs = [];

function rotateImgObj(nm,s) {
  this.speed=s; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm]; 
  this.index = rotateImgObjs.length; rotateImgObjs[this.index] = this;
  this.animString = "rotateImgObjs[" + this.index + "]";
}

rotateImgObj.prototype = {
  addImages: function() {
    this.imgObj.imgs = [];
    for (var i=0; i<arguments.length; i++) {
      this.imgObj.imgs[i] = new Image();
      this.imgObj.imgs[i].src = rotateImgObj.imagesPath + arguments[i];
    }
  },

  rotate: function() {
    if (this.ctr < this.imgObj.imgs.length-1) this.ctr++;
    else this.ctr = 0;
    this.imgObj.src = this.imgObj.imgs[this.ctr].src;
  }
}

rotateImgObj.start = function() {
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);                     
}
