var ROLLOVER_CLASSNAME = 'rollover';
var OFF_SUFFIX = '_1';
var ON_SUFFIX = '_2';

function enableMenuImageRollovers(){
	var imgs = getElementsByTagAndClassName('img',ROLLOVER_CLASSNAME);
	for(var i = 0; i < imgs.length; i++){
		var img=imgs[i];
		//Create a couple of new image objects.
		var imgOn = new Image();
		var imgOff = new Image();
		//Set their source (this triggers the browser to load them).
		imgOn.src=img.src.replace(OFF_SUFFIX,ON_SUFFIX);
		imgOff.src=img.src.replace(ON_SUFFIX,OFF_SUFFIX);
		//Bind them to the original image.
		img.imgOn = imgOn;
		img.imgOff = imgOff;
		//Switch to them on mouseover/mouseout.
		img.onmouseover=function() {
			this.src=this.imgOn.src;
		}
		img.onmouseout=function() {
			this.src=this.imgOff.src;
		}
	}
}

function getElementsByTagAndClassName(tagName, className){
	var items = new Array();
	var elems = document.getElementsByTagName(tagName);
	for(var i = 0; i < elems.length; i++){
		var elem = elems[i];
		var classNames = elem.className.split(" ");
		for (var j = 0; j < classNames.length; j++){
			if(classNames[j] == className){
				items.push(elem);
			}
		}
	}
	return items;
}

if (window.onload){
	//Hang on to any existing onload function.
	var existingOnload = window.onload;
}

window.onload=function(ev){
	//Run any onload that we found.
	if (existingOnload){
		existingOnload(ev);
	}
	//Don't bother loading unless getElementsByTagName is supported.
	if (document.getElementsByTagName){
		enableMenuImageRollovers();
	}
};