
/* Last Modified $Date: 2/10/03 11:33a $ by $Author: Csamant $ (Version history stored in Source Control) */

/*
 * This function highlights an image
 *
 * @param	image - the name of the image to be flipped
 * @param	dir - path to image dir (ex: "../images/nav/")
 * @param	imgName - optional, if name attribute is different from the image file name
 */
function over(image, dir, imgName) { 
	if (document.images) {
		var img = (imgName) ? findObject(imgName) : findObject(image);
		// store reference to old image for the out function
		img.rsrc = img.src;
		//check for pin state make sure the pinned nav image doesn't flip between its pin and on states onmouseover
		if (img.src.indexOf('_pin.gif') == -1) {  
			img.src = dir + image + "_on.gif";
		}
	}
}

/**
 * This function restores an image
 *
 * @param	image - the name of the image to be flopped
 * @param	imgName - optional, if name attribute is different from the image file name
 */
function out(image) {
	if (document.images) {
		var img = findObject(image);
		// set source to stored reference to the old image
		img.src = img.rsrc;
	}
}

/*
 * This function highlights an image
 *
 * @param	image - the name of the image to be flipped
 * @param	dir - path to image dir (ex: "../images/nav/")
 * @param	imgName - optional, if name attribute is different from the image file name
 */
function pin(image, dir, imgName, suffix) { 
	if (!suffix) suffix = "_pin.gif";
	if (document.images) {
		var img = (imgName) ? findObject(imgName) : findObject(image);
		// store reference to old image for the out function
		img.rsrc = img.src;
		img.src = dir + image + suffix;
	}
}

function preload(list, dir, suffix) {
    if (document.images) {
		// image object array
		var imgs = new Array();
		// loop through list
		for (i=0; i < list.length; i++) {
			imgs[i] = new Image();
			imgs[i].src = dir + list[i] + suffix;
		}
	}
}

// adapted from MM_findObj

function findObject(name, doc) {

	// get document, if it hasn't been passed
	if (!doc) doc = document;

	// declare object reference
	var obj;

	// check document and document.all collections	
	if (!(obj = doc[name]) && doc.all) {
		obj = doc.all[name];
	}
	
	// check document.layers collection
	if (!obj && document.layers) {
		for (var i = 0; !obj && i < doc.layers.length; i++) {	
			obj = findObject(name, doc.layers[i].document);
		}
	}
		
	if (!obj && doc.getElementById) {
		obj = doc.getElementById(name);
	}
	
	return obj;
}

