//

// Object name: RollOver

//

// Author: Eric Byrnes, Hybridigital

//

// Parameters: OffSrc - relative path to 'Off' image

//             OnSrc - relative path to 'On' image

//

// Usage: 1) include the Javascript source file within the HTML header, i.e.

//           <SCRIPT LANGUAGE="Javascript" SRC="../rollover.js">

//

//        2) create new Rollover objects for each rollover, passing the source for

//           the 'Off' image and 'On' image, i.e.

//           rollimage = new RollOver("/images/OffImage.gif","/images/OnImage.gif");

//

//        3) call it within the HTML

//           <A HREF="xxx" onMouseOver="rollimage.On('target')" onMouseOut="rollimage.Off('target')">

//           <IMG NAME="target" SRC="<default>"></A>

//           where

//           - rollimage is the object created in step 2

//           - target is either the image object or the name of the image object to

//             apply the rollover to

//

// Attributes: state - OFF or ON

// Methods: On(target) - turns object 'on' (overlays image named target with 'On' image)

//          Off(target) - turns object 'off' (overlays image named target with 'Off' image)

//          Toggle(target) - toggles object state for image named target

//

// Modification Log

// ERB  20-OCT-1999  Initial release.

// ERB  08-NOV-9999  Updated for Netscape compatibility

// ERB  08-FEB-2000  Updated for Netscape 3.x compatibility



//

// Method functions for Rollover object below

function RollOverOn(target) {



	if (document.images) {

		if (typeof (target) == "string") {

			if (typeof (eval(document[target])) == "object") {

				document[target].src = this.OnImage.src;

			}

		} else if (typeof (target) == "object") {

			target.src = this.OnImage.src;

		}

	}

	this.State = "ON";

}



function RollOverOff(target) {



	if (document.images) {

		if (typeof (target) == "string") {

			if (typeof (eval(document[target])) == "object") {

				document[target].src = this.OffImage.src;

			}

		} else if (typeof (target) == "object") {

			target.src = this.OffImage.src;

		}

	}

	this.State = "OFF";

}



function RollOverToggle(target) {



	// change state attribute

	if (this.State == "OFF")

		this.On(target)

	else

		this.Off(target);

}



// MAIN RollOver object

function RollOver(OffSrc, OnSrc) {



	if (document.images) {

		// create on object for the 'Off' state

		this.OffImage = new Image();

		// initialize 'off' property object

		this.OffImage.src = OffSrc;



		// create on object for the 'On' state

		this.OnImage = new Image();

		// initialize 'on' property object

		this.OnImage.src = OnSrc;

	}



	// initialize attributes

	this.State = "OFF";



	// set up methods for 'On', 'Off', and 'Toggle'

	this.Off = RollOverOff;

	this.On = RollOverOn;

	this.Toggle = RollOverToggle;

}

