/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return;
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		/* Added newimgover to accomodate _on _off _sel image names */
		if (aImages[i].className == 'imgover' || aImages[i].className == 'button' || aImages[i].className == 'newimgover') {
			var src = aImages[i].getAttribute('src');
			/* Determine "file type" and "hover source" */
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			if (aImages[i].className == 'newimgover') {
			        var TestType = src.lastIndexOf('_sel.gif');
			        if (TestType < 0) {
			                var hsrc = src.replace('_off.gif', '_on.gif');
			        }
			        else {
			                var hsrc = src.replace('_sel.gif', '_on.gif');
			        }
			}
			else {
			        var hsrc = src.replace(ftype, '_on'+ftype);
			}
                        /* Update the array with the gathered image information */
			aImages[i].setAttribute('hsrc', hsrc);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			/* What to do when the user hovers */
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			
			/* What to do when the user "un-hovers */
			aImages[i].onmouseout = function() {
				if (sTempSrc) this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;
