/* ----------
	CodeBank - rollover2a.js

	This is an advanced version of the rollover code in rollover.js. This code automatically runs through the images in the document
	while preloading, cutting out the need to list all of the images beforehand.

    Revisions to Included File:
        Each image to be rolled over needs to have the NAME tag added, with "bt_X", X = base name of image
 	    i.e. <img name="bt_home" ...>
        The anchor wrapping that image requires the onMouseOver="ChangeImages(X)" and onMouseOut="ChangeImages(X)" attributes.
 	    i.e. <a href="..." onMouseOver="ChangeImages(bt_home)" onMouseOut="ChangeImages(bt_home)">
  	    The body tag of the included file requires the onLoad="PreloadImages()" attribute.

    Revisions to This File:
		None!

	Revisions to Graphics:
	    Each image used for rollovers must follow this naming convention:
		    Normal (unrolled) image - basename.gif
			Rolled image            - basename-over.gif


    General Revisions:
		2000 04 26 - Added some more semi-colons.
		           - modified the code a little bit so the -over.gif is not needed in the name; that will now be assumed.
				   - changed the variable names to make the code easier to understand two weeks from now 
	    2000 05 15 - Created the LoadRollover function for greater portability
---------- */

lastEvent = "";			// Needed because there is because in the undefind script in box Netscape and IE.

function ChangeImages(ImageName) {

	if (lastEvent==""||lastEvent=="onmouseout")	{
		currentEvent = "onmouseover";
	} else if (lastEvent=="onmouseover") {
		currentEvent = "onmouseout";
	}
	lastEvent = currentEvent;

	if (document.images && (preLoadFlag == true)) {

		if (currentEvent=="onmouseover") {	
			document.images[ImageName].src = ImageList[ImageName].RolledImage;
		} else {
			document.images[ImageName].src = ImageList[ImageName].NormalImage;
		}
	}	
}


/*
function ChangeImages(ImageName) {


	if (parent.lastEvent == "undefined") {
		parent.currentEvent = "onmouseover";
	} else if (parent.lastEvent=="onmouseout")	{
		parent.currentEvent = "onmouseover";
	} else if (parent.lastEvent=="onmouseover") {
		parent.currentEvent = "onmouseout";
	}


	parent.lastEvent = parent.currentEvent;

	if (document.images && (preLoadFlag == true)) {

		if (parent.currentEvent=="onmouseover") {	
			document.images[ImageName].src = ImageList[ImageName].RolledImage;
		} else {
			document.images[ImageName].src = ImageList[ImageName].NormalImage;
		}
	}	
}

*/

var preLoadFlag = false;
var CurrentRoll = "blah";

function LoadRollover( ImageName, NormalPath, RolledPath ) {
	// Preload and store the rollover image information

	// This has been seperated from the PreLoadImages function to make it easier
	// to use this page is crazy pages like the Empire main page, or other pages 
	// that can have multiple rollovers on one image

	// Rollover   = the name of the variable to hold the rollover image structure
	// ImageName  = the name of the image which rolls over
	// NormalPath = the path of the normal state GIF
	// RolledPage = the path of the rolled over state GIF
	
	// preload the image - this is all these two lines do
	TempImage = new Image();
	TempImage.src = RolledPath;
	
	// create the Rollover image structure
	RollingImage = new Object();
	RollingImage.Name = ImageName;
	RollingImage.NormalImage = NormalPath;
	RollingImage.RolledImage = RolledPath;

	return RollingImage;
}

function PreLoadImages() {
	if (document.images) {

		ImageList = new Object();

		for(count=0;count<document.images.length;count++) {
			ImageName = document.images[count].name;
			if (ImageName.substring(0,3)=="bt_") {
				RolledPath = ImageName.substring(3, ImageName.length) + "-over.gif";
				ImageList[ImageName] = LoadRollover( ImageName, document.images[count].src, RolledPath );
			}
		}
		preLoadFlag = true;
	}
}
