// rollovers.js// EnSky's JavaScript image swapping code// After discovering about 1 million different ways to implement rollovers// this collection of scripts seems to do the job in a pretty flexible and extensible// manner. Hopefully the comments explain how to use the scripts.// You should strip comments when embedding these scripts in actual pages// Last Updated: 25-Jul-00/* functions that implement the rollovers */// this function loads the rollover images into the browser's cache// the images to load are defined in the dynImages array// the cached image objects are stored in the cachedImages array // called onload - page has loaded before we start to load the rollover imagesfunction preloadImages() {	if (document.images) {		// iterate thru the dynImages array...		for (var imgName in dynImages) {			// for each entry in the dynImages array, create an array in the cachedImages array			// these arrays may contain n image objects, representing n image states			cachedImages[imgName] = new Array()			for (var i = 0; i < dynImages[imgName].length; i++) {				cachedImages[imgName][i] = new Image				cachedImages[imgName][i].src = imagePath + dynImages[imgName][i]			}		}		}	return true}		// this function, called onload, will add references to any named images in layers to // global document.images array - copying the MSIE object model// add if the page uses layersfunction NS_flattenImages (documentObj) {	if (document.layers) {		var me = NS_flattenImages		if (!documentObj) {			documentObj = window.document //top-level document is default value		}		/* add references to global document.images array */		for (var i = 0; i < documentObj.images.length; i++) {			var img = documentObj.images[i]			if (img.name && !document.images[img.name]) {				document.images[img.name] = img			}		}				/* recursively search through layers for images */		for (var i = 0; i <  documentObj.layers.length; i++) {			me(documentObj.layers[i].document) //recurse		}			}	return true}// use this function as the onmouseover handlerfunction roll_over(imgName) {	var img, rollSrc	if (document.images && imagesCached) {		img = document.images[imgName]		rollSrc = cachedImages[imgName][1].src		img.src = rollSrc	}	return true}// use this function as the onmouseout handlerfunction roll_out(imgName) {	var img, defaultSrc	if (document.images && imagesCached) {		img = document.images[imgName]		defaultSrc = cachedImages[imgName][0].src		img.src = defaultSrc	}	return true}// sample onload handlerfunction initPage () {	imagesCached = preloadImages()	if ( document.layers && (document.layers.length > 0) )		NS_flattenImages();}