
/*
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*/

// arrays for images to rotate
var imgAr = new Array();
imgAr[0] = new Array(
'/img/home-slideshow/10.jpg',
'/img/home-slideshow/01.jpg',
'/img/home-slideshow/03.jpg',
'/img/home-slideshow/04.jpg',
'/img/home-slideshow/02.jpg',
'/img/home-slideshow/05.jpg',
'/img/home-slideshow/09.jpg',
'/img/home-slideshow/06.jpg',
'/img/home-slideshow/08.jpg',
'/img/home-slideshow/11.jpg',
'/img/home-slideshow/12.jpg',
'/img/home-slideshow/07.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('img0',3500,0);
  new rotateImgObj('img1',3200,1);
  new rotateImgObj('img2',4500,2);
  new rotateImgObj('img3',3500,3);

// 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()",4000);  
  }
}

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);
}

