// arrays for images to rotate
var imgAr = new Array();
imgAr[0] = new Array(
"js/Adobe_logo.jpg", 
"js/Starwood_logo.jpg",
"js/Ikon_logo.jpg", 
"js/Alcoa_logo.jpg", 
"js/staples_c_logo.jpg", 
"js/NWF_logo.jpg"
);

// preload the images
if (document.images) {
	var rImg = new Array();
	for (var i=0; i<imgAr.length; i++) {
    rImg[i] = new Array();
    for (var j=0; j<imgAr[i].length; j++) {
      rImg[i][j] = new Image(); 
		  rImg[i][j].src = imgAr[i][j];
    	// NOTE: the path to the images!
    	// change it as needed, or include path in imgAr items and remove it here.    
    }
  }
}

function initImgRotation() {
  // create rotating image objects here 
  // arguments: image name, rotation speed, array number
  new rotateImgObj('img1', 2000, 0);
// no need to edit code below this line!
///////////////////////////////////////////////////////////////////////////////////////
  for (var i=0; i<rotateImgObj.ar.length; i++) {
     rotateImgObj.ar[i].timer = setTimeout(rotateImgObj.ar[i].obj + ".rotate()",3000);  
  }
}

rotateImgObj.ar = new Array(); // holds all rotating image objects defined
// constructor for rotating image objects
function rotateImgObj(nm,s,num) {
  this.speed = s; this.num = num; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm];
  this.obj = nm + "object"; eval(this.obj + "=this");
  rotateImgObj.ar[rotateImgObj.ar.length] = this;
}

rotateImgObj.prototype.rotate = rotateImg;
// controls rotation
function rotateImg() {
  if (this.ctr < rImg[this.num].length-1) this.ctr++;
  else this.ctr = 0;
  this.imgObj.src = rImg[this.num][this.ctr].src;
  this.timer = setTimeout(this.obj + ".rotate()",this.speed);
}
