//<script type="text/javascript">
/*************************************************************************
  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
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// image file names go in these arrays
//randImgObj.set1 = new Array( "weld_splash1.gif",  "weld_splash2.gif", "weld_splash3.gif", "weld_splash4.gif", "weld_splash5.gif", "weld_splash6.gif" );
randImgObj.set1 = new Array( "mds002.jpg", "mds020.jpg",  "mds005.jpg", "mds006.jpg", "mds015.jpg", "mds019.jpg", "mds026.jpg" );
randImgObj.set1.cur = 0

randImgObj.set2 = new Array( "right1.gif", "right2.gif", "right3.gif" );
randImgObj.set2.cur = 1


// for the second set of rotating images 
//randImgObj.set2 = new Array("antenna1.jpg","antenna2.jpg","antenna3.jpg","antenna4.jpg" );
//randImgObj.set2.cur = 1

// for the second set of rotating images 
//randImgObj.set3 = new Array("network1.jpg","network2.jpg","network3.jpg","network4.jpg" );
//randImgObj.set3.cur = 2

// If all the images you wish to display are in the same location, you can specify the path here 
randImgObj.imagesPath = "/images/rotate/";

// No need to edit code below this line 
/////////////////////////////////////////////////////////////////////
Array.prototype.shuffle = function() { 
  var i, temp, i1, i2;
  for (i=0; i<this.length; i++) { 
    i1 = Math.floor( Math.random() * this.length );
    i2 = Math.floor( Math.random() * this.length );
    temp = this[i1];
    this[i1] = this[i2];
    this[i2] = temp;
  }
}

randImgObjs = []; // holds all random rotating image objects defined
// constructor 
function randImgObj(s) {
  this.speed=s; this.ctr=0; this.timer=0;  
  this.index = randImgObjs.length; randImgObjs[this.index] = this;
  this.animString = "randImgObjs[" + this.index + "]";
}

randImgObj.prototype = {
  addImages: function(ar) { // preloads images
    this.imgObj.imgs = [];
    for (var i=0; ar[i]; i++) {
      this.imgObj.imgs[i] = new Image();
      this.imgObj.imgs[i].src = randImgObj.imagesPath + ar[i];
    }
  },

  rotate: function() { // controls rotation
	//use for random images
    //var ctr = Math.floor( Math.random() * this.imgObj.imgs.length );
    //if (ctr == this.ctr) ctr = (ctr > 0)? --ctr: ++ctr;

//alert( 'index=[' + this.imgObj.imgs.cur + ']');

	//use for sequential images
    var ctr = this.ctr + 1;
    if (ctr == this.imgObj.imgs.length) ctr = 0;
//alert( 'ctr=[' + ctr + ']');

//alert( 'this.ctr=[' + this.ctr + ']');

    this.ctr = ctr;
    if ( typeof this.imgObj.filters != "undefined" ) {
   		this.imgObj.style.filter = 'blendTrans(duration=1)';
      if (this.imgObj.filters.blendTrans) this.imgObj.filters.blendTrans.Apply();
    }
    this.imgObj.src = this.imgObj.imgs[this.ctr].src;
    if ( typeof this.imgObj.filters != "undefined" && this.imgObj.filters.blendTrans )
      this.imgObj.filters.blendTrans.Play();    
  }
}

// sets up rotation for all defined randImgObjs
randImgObj.start = function() {
  for (var i=0; i<randImgObjs.length; i++) 
    randImgObjs[i].timer = setInterval(randImgObjs[i].animString + ".rotate()", randImgObjs[i].speed);                     
}

randImgObj.setUpImg = function(imgAr, sp, w, h) {
  var rotator, img, imgStr = "";
  rotator = new randImgObj(sp);
  randImgObjs[randImgObjs.length-1].imgAr = imgAr;

//uncomment this to random the starting order
//  imgAr.shuffle();
  
  //use this for random images
  img = imgAr[ Math.floor( Math.random() * imgAr.length ) ]; 
  
  //use this for sequential order
  img = imgAr[ 0 ]; 
  
  imgStr += '<img src="' + randImgObj.imagesPath + img + '" alt="" ';
  imgStr += 'name="img' + (randImgObjs.length-1) + '" width="' + w + '" height="' + h + '" border=0>';
  
  //imgStr += 'name="img' + (randImgObjs.length-1) + '" width="' + w + '" align="top" border=0>';
  //imgStr += 'name="img' + (randImgObjs.length-1) + '" height="' + h + '" border=0>';
  document.write(imgStr); 
}

function initRandRotation() {
  for (var i=0; randImgObjs[i]; i++) {
    var rotator = randImgObjs[i];
    rotator.imgObj = document.images["img" + i]; // get reference to the image object
    rotator.addImages(rotator.imgAr);
    rotator.rotate();
  }
  randImgObj.start();  
}
//</script>
