startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

function initImgRotation() {
  // create rotating image objects here 
  // arguments: image name, rotation speed
  var rotator1 = new rotateImgObj('img1',2500);
  // add the images to rotate into that image object  
  rotator1.addImages("LexusBeforeHiResText.jpg","LexusAfterHiResText.jpg");
  //rotator1.rotate();
  
  rotateImgObj.start();
}

function loadAfterImage() {
  // create loader image object here 
  // arguments: image name
  var loader1 = new loadImgObj('img1');
  // add the image into that image object  
  loader1.addImages("LexusAfterHiResText.jpg");
  loader1.load();
}

function loadBeforeImage() {
  // create loader image object here 
  // arguments: image name
  var loader1 = new loadImgObj('img1');
  // add the image that image object  
  loader1.addImages("LexusBeforeHiResText.jpg");
  loader1.load();
}

function loadImgObj(nm) {
  this.imgObj = document.images[nm]; // get reference to the image object
}

// If all the images you wish to display are in the same location, you can specify the path here 
loadImgObj.imagesPath = "images/";

loadImgObj.prototype = {
  addImages: function() { // preloads images
    this.imgObj.imgs = [];
    for (var i=0; arguments[i]; i++) {
      this.imgObj.imgs[i] = new Image();
      this.imgObj.imgs[i].src = loadImgObj.imagesPath + arguments[i];
    }
  },

  load: function() {
    this.imgObj.src = this.imgObj.imgs[0].src;
  }
}

// If all the images you wish to display are in the same location, you can specify the path here 
rotateImgObj.imagesPath = "images/";

// no need to edit code below 
/////////////////////////////////////////////////////////////////////
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 + "]";
}

rotateImgObj.prototype = {
  addImages: function() { // preloads images
    this.imgObj.imgs = [];
    for (var i=0; arguments[i]; 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;
  }
}

// sets up rotation for all defined rotateImgObjs
rotateImgObj.start = function() {
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);                     
}
