/*	ROLLOVER.js
*	
*	Import this file using <script language="javascript" type="text/javascript" src="rollover.js"></script>
*
*	This file includes functions to preload images, turn on rollover states, and turn off rollover states.
*
*	All Javascript code written by Scott Richmond.
*	All Javascript code (c)2000 RainCastle Communications.
*
*/

	
//	set the variables
//	make a new array for the images
pics = new Array();
//	set the number of images to 0 (we don't have any yet)
var pic_count = 0;
	
//	preload image into array.
//	takes the name of the image, its source when on, its source when off
//	called from the <head> tag of the html file
function preload(name,off,on) {
	//	array element will be a new array
	pics[pic_count] = new Array();
	//	0th element is name
	pics[pic_count][0]=name;
	//	1st element is off state source
	pics[pic_count][1] = new Image();
	pics[pic_count][1].src = off;
	//	2nd element is on state source
	pics[pic_count][2] = new Image();
	pics[pic_count][2].src = on;
	//	you're done preloading. add one to the number of images.
	pic_count++;
}
	
//	turn a given image on.
//	takes the name of the image
//	called from the event handler onMouseOver
function on(name) {
	//	cycle through all the elements in pics...
	for (i = 0; i < pic_count; i++) {
		//	...and if the 0th element is 'name'...
		if (pics[i][0] == name) {
			//	...set the source to the on state source.
				document.images[name].src = pics[i][2].src;
				break;
		}
	}
}
	
//	turn off a given image.
//	takes the name of the image
//	called from the event handler onMouseOff
function off(name) {
	//	cycle through all the element in pics...
	for (i = 0; i < pic_count; i++) {
		//	...and if the 0th element is 'name'...
		if (pics[i][0] == name) {
			//	...set the source to the off state source.
				document.images[name].src = pics[i][1].src;
				break;
		}
	}
}