//////////////////////////////////////////////////////////////////////////////////// AutoRollover// Copyright (C) 2004 Homeboyz Interactive, Inc.// License: BSD// $Id: autoRollover.js,v 1.3 2004/04/01 22:13:31 j Exp $////////////////////////////////////////////////////////////////////////////////////// Automatically turn images with class "autoRollover" into// rollover images where the hover-state image is filename_hover.ext,// e.g. if you have:////	<img src="images/foo.gif" class="autoRollover" />//// then there must be an image called "images/foo_hover.gif"//// The script does not check if the hover image exists!//////////////////////////////////////////////////////////////////////////////////
function autoRollover(){
	if (document.getElementById)	{		var searchRegex = /autoRollover/i;		var images = document.getElementsByTagName("img");		for (var i = 0; i < images.length; i++)		{			// If image has class "autoRollover"			if (-1 != images[i].className.search(searchRegex))			{				var src = images[i].src;				var lastDotPosition = src.lastIndexOf(".");				var srcExt = src.substring(lastDotPosition, src.length);				var hoverSrc = src.substring(0, lastDotPosition) + "_hover" + srcExt;				images[i].hImg = new Image();				images[i].hImg.src = hoverSrc;				images[i].oImg = new Image();				images[i].oImg.src = images[i].src;				// Gallery addition: the mainImageId of filename.ext is filename				var lastSlashPosition = src.lastIndexOf("/");				var mainImageId = src.substring(lastSlashPosition + 1, lastDotPosition);				images[i].setAttribute("mainImageId", mainImageId);				images[i].onmouseover = function()				{					this.src = this.hImg.src;				}				images[i].onmouseout = function()				{					this.src = this.oImg.src;				}			}		}	}}if (typeof window.addEventListener != "undefined")	window.addEventListener("load", autoRollover, false);else if (typeof document.addEventListener != "undefined")	document.addEventListener("load", autoRollover, false);else if (typeof window.attachEvent != "undefined")	window.attachEvent("onload", autoRollover);else{	if (typeof window.onload == "function")	{		window.currentOnload = window.onload;		window.onload = function()		{			window.currentOnload();			autoRollover();		}	}	else		window.onload = autoRollover;}