﻿window.onload = rolloverInit;

function rolloverInit() {

    for (var i = 0; i < document.images.length; i++) {
		setupRollover(document.images[i]);
	}
}

function setupRollover(thisImage) {

    if (thisImage.src.lastIndexOf('_off.') > -1) {
        // Set the mouseout image.
        thisImage.outImage = new Image();
		thisImage.outImage.src = thisImage.src;
		thisImage.onmouseout = rollOut;

		// Set the mouseover image.
		thisImage.overImage = new Image();
		thisImage.overImage.src = thisImage.src.slice(0, thisImage.src.lastIndexOf('_')+1) + "over" + thisImage.src.slice(thisImage.src.lastIndexOf("."));
		thisImage.onmouseover = rollOver;	

		// Set the mousedown image.
		thisImage.clickImage = new Image();
		thisImage.clickImage.src = thisImage.src.slice(0, thisImage.src.lastIndexOf('_')+1) + "down" + thisImage.src.slice(thisImage.src.lastIndexOf("."));
		thisImage.onmousedown = rollClick;
	}
}

function rollOut() {
	this.src = this.outImage.src;
}

function rollOver() {
	this.src = this.overImage.src;
}

function rollClick() {
	this.src = this.clickImage.src;
}

function rolloverInitOld() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName == "A"){
			setupRollover(document.images[i]);
		}
	}
}



