////////////////////////////////////////////////////////////////////////
// Filename: rollover.js
// Desc:     Generic mouse rollover script for shared use.
// Author:   Relevant Arts Enterprise, Inc. <http://www.relevantarts.com/>
//           John A. Lock <jlock@relevantarts.com>
// Created:  1997-Oct-15
////////////////////////////////////////////////////////////////////////

// Define the rollover images if the browser supports what we're about to do.
if (document.images) {
	var rollover = new Array();
	rollover[0] = "about";
	rollover[1] = "services";
	rollover[2] = "products";
	rollover[3] = "clients";
	rollover[4] = "contact";
}

// Generic page setup to initialize variables, break out
// of frames, and preload the rollover images.
var rollover_image_path = "img/";
var rollover_on_suffix = "-on.jpg";
var rollover_off_suffix = "-off.jpg";

// Get setup to do rollovers on this page.
function Init(FrameOK) {
	// If we're framed, break out of it, unless a parm is passed saying it's OK
	if ((FrameOK != "framed") && (self != top)) {
		top.location.href = self.location.href;
	}
	// Preload the images in the rollover array if the browser supports it.
	if (document.images) {
		// Iterate thru all the rollover entries to preload the browser cache.
		for (ctr = 0; ctr < rollover.length; ctr++) {
			var item = rollover[ctr];
			document["on" + ctr] = new Image();
			document["on" + ctr].src = rollover_image_path + item + rollover_on_suffix;
		}
	}
}

// This function is called by event handlers to swap images. Any number
// of parameters may be passed. If the object currently contains the "on"
// version, reload it with the "off" version and vice-versa.
function swap() {
	// If the browser can't do this, quit.
	if (!document.images) return;
	// Iterate through all passed parameters
	for (ctr = 0; ctr < swap.arguments.length; ctr++) {
		parm = swap.arguments[ctr];
		if (parm.indexOf("=") == -1) {
			// If the "off" version is currently loaded, replace with the "on" version
			// and vice-versa.
			document[parm].src = (document[parm].src.indexOf(rollover_off_suffix) > -1) ? rollover_image_path + parm + rollover_on_suffix : rollover_image_path + parm + rollover_off_suffix;
		}
	}
}
