/*---------------------  
		THIS FILE REQUIRES THE INCLUSION OF:
    sniffer.js
    FOR BROWSER DETECTION
-----------------------------------*/

/*---------------------  
		Initialization
		Called from the onLoad() inside the body tag
		Calls functions to initialize rollover images
		and dynamic menu items
		
-----------------------------------*/
var nameArray = new Array(); // array of rollover image names
var buttons = null;

function init_rollover() {
		GetImageNames(document);
    buttons = new ImageArray(nameArray);
		
}


	


/*--------------------------
		Image rollover routines
		
---------------------------------------*/

/*---------------
		GetImageNames
		
		Compiles the rollover image aray by looking for all images
		on the page that have a name attribute.
		
		If the image has a name, it is assumed that it is a rollover
		image and is placed in the array after splitting the filename
		into the path/filename and the extension for use later when
		building the filenames of the on/off states.
		
		*/

function GetImageNames(obj) {
	var ftypeExp = /\.[^\.]*$/;   // regular expression used to split the filename string
	var idExp = /_\d*$/;          // idExp not used yet
	var fnameString;
	var extString;
	var srcString;
	
	// look for all the images in the object passed to the function
	
	for(var i = 0; i<obj.images.length; i++) {
		if (obj.images[i].name != "" && obj.images[i].onabort == null) { // only look for ones with a name attribute set
																		 // Allow this to be disabled by putting dummy
																		 // text in the onabort attribute.
			srcString = obj.images[i].src;
			fnameString = srcString.split(ftypeExp)[0];  // grab the filename without the extension
			extString = srcString.match(ftypeExp)[0];			 // grab the extension
			nameArray[obj.images[i].name] =   // put all the info in an array, including a reference
				{fname:fnameString, 						//  to the image object itself to modify later
				 ftype:extString,
				 objRef:obj.images[i]};
		}
	}
	
	// since netscape nests layers within layers, we must parse all layers by recursion
	if (is_nav && !is_nav6up) {
		for (var i=0; i < obj.layers.length; i++) {
			GetImageNames(obj.layers[i].document);
		}
	}
}



/*-------------------
		ImageArray
		Arguments: imageNames - an array created by GetImageNames
		Returns:   imgArray - an array of image objects with state information
		
		*/


function ImageArray(imageNames) {
    var imgArray = new Array();

		// set state information for each image collected by GetImageNames
    for(var imgRef in imageNames) {
			imgArray[imgRef] = new Object();
			imgArray[imgRef].state = "norm";       // default to normal/off state
      imgArray[imgRef].norm = new Image();
			
			// build the filnames for the normal and highlighted state
			imgArray[imgRef].norm.src = imageNames[imgRef].fname + imageNames[imgRef].ftype;
      imgArray[imgRef].norm_over = new Image();
			imgArray[imgRef].norm_over.src = 
	    	imageNames[imgRef].fname + "_over" + imageNames[imgRef].ftype;
    }
    return imgArray;
}


/*-----------------
		RollOn
			set the rollover image in the on/highlighted state
*/

function RollOn(imageName) {
	if(buttons != null) {
    srcType = buttons[imageName].state + "_over";
    nameArray[imageName].objRef.src = buttons[imageName][srcType].src;
    
	}
}

/*-----------------
		RollOff
			set the rollover image in the off/normal state
*/

function RollOff(imageName) {
	if(buttons != null) {
    srcType = buttons[imageName].state;
    nameArray[imageName].objRef.src = buttons[imageName][srcType].src;
	}
}
