//	Image Roll-Over Script
//	OIL, Incorporated
//	Version 1.3.1
//	Oct 22, 2002
//	J. Vose
//	Revisions:
//	1.3    01-22-2004  J.Vose  Added capability to handle "on" states, ie: images whose normal display ends in "_f3", "_f4", etc.
//	1.3.1  03-04-2004  J.Vose  Minor fixes 

var imgsCached = false;

function cacheImages(){
	cacheImagesInDoc(document);
	imgsCached=true;
	}
function cacheImagesInDoc(d){
	var ext;ids=new Object();
	for(i=0; i<d.images.length; i++){
		img=d.images[i];
		is=img.src;
		var mo=""+img.onmouseover;
		var fun=-1;
		//	Check if this image has the ImageRollOver Script onmouseover 
		//	event handler, if so, cache the over image for it
		if((fun=mo.indexOf("swapImage")>=0)&&((ext=is.indexOf(".gif"))>=0)&&(is.lastIndexOf("/")>=0)){
		
			//	Check to see if swapImage is swapping a different 
			//	image, instead of the one with the event handler
			
			var numb=Number.NaN;
			var stateStr="";
			//	Build the name of the roll over image
			//	Check if the image has an ending of _f3 or _f4, etc, if so,
			//	remove this ending before adding the _f2, this allows for handling of 
			//	images with "on" states that still need to "roll-over" to _f2
			if(is.indexOf("_f")>0){
				//	Get "state", number after "_f" string
				stateStr=is.indexOf("_f");
				numb=is.substring(stateStr+2,ext);
				}
			//	If state is a number, build the imgSrc variable without
			//	the "_fx" ending, otherwise just add "_f2" to base file name
			if(!isNaN(parseInt(numb))&&(stateStr!="")){
				imgSrc=is.substring(0,stateStr) + "_f2";
				}
			else imgSrc=is.substring(0,ext) + "_f2";
			
			if(!document["cache"+imgSrc]){
				document["cache"+imgSrc]=new Image();
				document["cache"+imgSrc].src=imgSrc+".gif";
				}
			}
		}
	}

//	Swap the image source
function swapImage(img,off){
	var ending="";
	if(typeof img=="string"){
		img=findObjInFrames(window,img);
		}
	if(!img||(typeof img!="object")||(!img.src))return;
	if((img.src.indexOf("_f")>=0)&&off){
		if(img.offState)ending=img.offState;
		var pos=img.src.indexOf("_f");
//		alert("src=" + img.src.substring(0,pos)+ending+img.src.substring(pos+3));
		img.src=img.src.substring(0,pos)+ending+img.src.substring(pos+3);
		}
	//	Swap Image to 'on' state, save 'state' number for off state if graphic
	//	source has a "_fx" ending, where "x" is the state number
	else if(!off){
		var ext; var is=img.src;
		if(((ext=is.indexOf(".gif"))>=0)&&((is.indexOf("shim"))<0)){
			if(is.indexOf("_f")>0){
				//	Get "state", number after "_f" string
				stateStr=is.indexOf("_f");
				numb=is.substring(stateStr,ext);
				ext=stateStr;
				img.offState=numb;
				}
			else img.offState=null;// reset off state if not used
			newSrc=img.src.substring(0,ext) + "_f2.gif";
			img.src=newSrc;
			}
		}
	}
