/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
	Modifications by Martin Olson
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	//get array of all images
	var aImages = document.getElementsByTagName('img');
	
	//loop over all images
	for (var i = 0; i < aImages.length; i++) {		
		// if it has our marker class "imgover", do some things to it
		if (aImages[i].className == 'imgover') {
			// get the current img src
			var src = aImages[i].getAttribute('src');
			// set "hsrc" to the same image file but in the "roll" directory
			var hsrc = src.replace('/off/','/roll/');
			hsrc = hsrc.replace('/on/','/roll/');
			
			aImages[i].setAttribute('hsrc', hsrc);
			
			//precache
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			//add onMouseOver and onMouseOut functions
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) {
					sTempSrc = this.getAttribute('src').replace('/off/','/roll/');
					sTempSrc = this.getAttribute('src').replace('/on/','/roll/');
				}
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;