// Path to the navigation images that should be cached
var navPath = "/images/nav/";
// File extension for the images used in the primary nav
var navImgExt = "gif";
// Array of nav images to cache
var navImgs = new Array("homeB", "actionB", "schedulesB", "memberB", "shopB", "infoB");

/**
 * Class that defines what browser agent the client has.
 */
function BrowserObj(){
	var name = navigator.appName.toLowerCase();
	var info = navigator.appVersion.toLowerCase();
	var ver = parseInt(info);
	this.ns = (name.indexOf('netscape') != -1) ? true : false;
	this.ie = (name.indexOf('microsoft internet explorer') != -1) ? true : false;
	this.ns4 = (this.ns && parseInt(ver) == 4) ? true : false;
	this.ns5 = (this.ns && parseInt(ver) == 5) ? true : false;
	this.ie4 = (this.ie && info.indexOf('msie 4') != -1) ? true : false;
	this.ie5 = (this.ie && info.indexOf('msie 5') != -1) ? true : false;
	this.ie6 = (this.ie && info.indexOf('msie 6') != -1) ? true : false;
	this.min = (ver >= 4) ? true : false;
	//alert("User agent: " + navigator.appName + " - " + info);
}
var browser = new BrowserObj();

/**
 * Returns a reference to an object that has an id associated with it.
 *
 * @param	elmtID - String identifying the ID attribute for the element
 * @return	Object
 */
function getElmtRef(elmtID){
	if (document.getElementById){
		return document.getElementById(elmtID);
	} else if (document.all){
		return document.all[document.getElementById];
	} else {
		return null;
	}
}

/**
 * Preloads images into page.  Multiple calls to this function
 * may be required if the images reside in different folders, or
 * if the images have different file extensions.
 * IMPORTANT: If the images are intended to be used for rollovers,
 * you must follow a certain naming convention for the image
 * names used in the imgs array, along with a certain convention
 * for the actual image files.
 *
 * @param	dir  - String identifying path to images
 * @param	ext  - String the file extension for the images
 * @param	imgs - String the file extension for the images
 */
function cacheImages(dir, ext, imgs) {
	if (imgs.length > 0) {
		for (var i = 0; i < imgs.length; i++){
			var imgName = imgs[i];
			// Caching rollover images
			if (imgName.charAt(imgName.length - 1) == 'B'){
				eval(imgName + "_off =  new Image");
				eval(imgName + "_off.src = \'" + dir + imgName + "_off." + ext + "\'");
				eval(imgName + "_on =  new Image");
				eval(imgName + "_on.src = \'" + dir + imgName + "_on." + ext + "\'");
			}
			// Caching normal images not intended for rollovers
			else {
				eval(imgName + " = new Image");
				eval(imgName + ".src = \'"+ dir + imgName + "." + ext + "\'");
			}
		}
	}
}
cacheImages(navPath, navImgExt, navImgs);

/**
 * Button onMouseOver event handler
 *
 * @param	imgNav - String identifying the name of the image
 */	
function imgOn(imgName) {
	document[imgName].src = eval(imgName + "_on.src");
}

/**
 * Button onMouseOut event handler
 *
 * @param	imgNav - String identifying the name of the image
 */	
function imgOff(imgName) {
	document[imgName].src = eval(imgName + "_off.src");
}