// rollovers for images ... use <img class="imgover" ... /> or 
// <input type="image" class="imgover" /> to invoke.  Save the rollover
// image with "_over" suffix, and in the same folder as the non-rollover image.
// For example, menuitem.gif and menuitem_over.gif should be saved in the same folder.
function initRollovers() {
	//check for incompatible browser
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	
	// declare image and input element variables
	var aInputs = document.getElementsByTagName("input");
	var aImg = document.getElementsByTagName('img');
	var aImages = new Array();
	
	// loop that finds the input elements
	for(var i = 0; i < aInputs.length; i++)
	{
		aImages[i] = aInputs.item(i);
	}
	// loop that finds all image elements and adds to 
	// inputs for total images that need swapping
	for(var i = 0; i < aImg.length; i++)
	{
		aImages[i + aInputs.length] = aImg.item(i);
	}

	// looks for images or inputs that have the imgover class and runs the following methods
	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			// adds the mouseover event
			aImages[i].onmouseover = function() {
			
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			// adds the mouseout event
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
