// JavaScript Document
var img1_ar = new Array("sulin_laser.jpg", "anbar0417_science.jpg", "lindsay_Home.jpg", "jim2009317.jpg", "moore_2009.jpg", "buseck_Jan09.jpg","angell2009.jpg", "010609.jpg");

// for the second set of rotating images 
var img2_ar = new Array("pic1.jpg", "pic2.jpg", "asusign.jpg", "pic4.jpg", "sunset2.jpg", "pic8.jpg", "pic9.jpg", "pic10.jpg");
var img3_ar = new Array("JC_Cover.jpg", "lara_cover.jpg", "charlene_cover.jpg","michael_Mcdowell.jpg", "zofia.jpg","chenxiang_cover.jpg");
// If all the images you wish to display are in the same location, you can specify the path here 
rotateImgObj.imagesPath = "/images/spotlights/";
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;
  }
}

// shuffle arrays set up above 
img1_ar.shuffle();
img2_ar.shuffle();
img3_ar.shuffle();
function initImgRotation() {
  // create rotating image objects here 
  // arguments: image name, rotation speed
  var rotator1 = new rotateImgObj('img1',9000);
  // add the images to rotate into that image object (point to arrays set up above)
  rotator1.addImages(img1_ar);
  rotator1.rotate();
    
  var rotator2 = new rotateImgObj('img2',5000);
  rotator2.addImages(img2_ar);
  rotator2.rotate();
  
  
   var rotator3 = new rotateImgObj('img3',5000);
  rotator3.addImages(img3_ar);
  
  rotator3.rotate();
  
  // starts rotation for all defined rotateImgObjs
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);
}

rotateImgObjs = []; // holds all rotating image objects defined
// constructor 
function rotateImgObj(nm,s) {
  this.speed = s; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm]; // get reference to the image object
  this.index = rotateImgObjs.length; rotateImgObjs[this.index] = this;
  this.animString = "rotateImgObjs[" + this.index + "]";
  
  this.addImages = addRotatingImages;
  this.rotate = rotateImg;
}

// preloads images
function addRotatingImages(ar) {
  this.imgObj.imgs = [];
  for (var i=0; i<ar.length; i++) {
    this.imgObj.imgs[i] = new Image();
    this.imgObj.imgs[i].src = rotateImgObj.imagesPath + ar[i];
  }
}

// controls rotation
function rotateImg() {
  var ctr = Math.floor( Math.random() * this.imgObj.imgs.length );
  if (ctr == this.ctr) ctr = (ctr > 0)? --ctr: ++ctr;
  this.ctr = ctr;
  if ( typeof this.imgObj.filters != "undefined" ) {
 		this.imgObj.style.filter = 'blendTrans(duration=1)';
    this.imgObj.filters.blendTrans.Apply();
  }
  this.imgObj.src = this.imgObj.imgs[this.ctr].src;
  if ( typeof this.imgObj.filters != "undefined" ) this.imgObj.filters.blendTrans.Play();    
}


function newwin()
{
var targeturl="/tour/tourstart.asp"
newwind=window.open("/tour/tourstart.asp","myNewWindow","resizable=yes,menubar=no,location=no,toolbars=no,scrollbars=no")
if (document.all){

newwind.resizeTo(800,600)
}
newwin.location=targeturl,target='myNewWindow'
newwind.focus()   
  //if (autoclose){
    //window.onunload = function(){newwin.close()}
 // }
//window.self.close()
}
