/**********************************************************************
		
	Dynamic Rollovers with Preloader 
	Author: Byran Zaugg
	Date: 2005-10-13	
	Note: Preloader must be called on the onload event.
	Example: <body onload="RollOverPreload()">
			
**********************************************************************/
//Set rollover state names. This MUST be unique from the rest of the 
//filename. Example "_sel." not "sel"
var offState = "_off.";
var onState  = "_over.";
var selState = "_on.";	
		
/**********************************************************************
	START - Preloader
**********************************************************************/	
//array to hold preloaded images
var arrImgPreLoad = new Array();
		
function RollOverPreload() {
	//gets all <img> tags in the document & puts them in an array	
	var arrImgTag = document.getElementsByTagName("img");
	//gets length of array
	l = arrImgTag.length;
			
	for (i = 0; i <= l-1; i++) {
		//gets src property for each <img> tag	
		var str = arrImgTag[i].src;
				
		//looks to see if image is for rollover based on its name (_off.)
		if (str.indexOf(offState) > 0) {
			//changes path to rollover	
			str = str.replace(offState,onState);
			arrImgPreLoad[i] = new Image();
			arrImgPreLoad[i].src = str;
		}
					
		//looks to see if image is for rollover based on its name (_on.)	
		if (str.indexOf(selState) > 0) {
			//changes path to rollover
			str = str.replace(selState,onState);
			arrImgPreLoad[i] = new Image();
			arrImgPreLoad[i].src = str;
		}
	}
}
/*********************************************************************
	END - Preloader
*********************************************************************/
		
/*********************************************************************
	START - Rollovers
*********************************************************************/
//creates global variable
var bottonState = "";
				
function RollOver(oARollover,mAction) {
	// gets all <img> tags inside the passed in argument (<a> tag)
	var imgTag = oARollover.getElementsByTagName("img");
			
	//gets the src value of the first <img> tag 
	var str = imgTag[0].src;
			
	if (mAction == "over") {
		if (str.indexOf(offState) > 0) {
			bottonState = "off";
			imgTag[0].src = str.replace(offState,onState);
		}
				
		if (str.indexOf(onState) > 0) {
			bottonState = "over";
			imgTag[0].src = str.replace(onState,onState);
		}
							
		if (str.indexOf(selState) > 0) {
			bottonState = "on";
			imgTag[0].src = str.replace(selState,onState);
		}
	}
			
	if (mAction == "out") {
		if (bottonState == "off") {
			imgTag[0].src = str.replace(onState,offState);
		}
		if (bottonState == "over") {
			imgTag[0].src = str.replace(onState,onState);
		}
		if (bottonState == "on") {
			imgTag[0].src = str.replace(onState,selState);
		}
	}
}
/*********************************************************************
	END - Rollovers
*********************************************************************/	