function showText(id) {
  var el = document.getElementById(id);
  var p1 = document.getElementById(window.imglocal);
  if (el && p1) {
    el.style.display = 'inline';
    p1.style.display = 'none';
  }
}

function hideText(id) {
  var el = document.getElementById(id);
  var p1 = document.getElementById(window.imglocal);
  if (el && p1) {
    el.style.display = ''; // back to its natural state
    p1.style.display = 'inline';
  }
}

function initRollovers() {
	if (!document.getElementById) return

    /* Use vars in the window so if they're not defined things still work */
	window.imglocal = ''
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	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, '_o'+ftype);
			var hdiv = src.replace(ftype, '');
			hdiv = hdiv.substring(hdiv.lastIndexOf('/') + 1, hdiv.length);

			if (hdiv.substring(hdiv.length - 2, hdiv.length) == '_n') {
				window.imglocal = hdiv.substring(0, hdiv.length - 2);
				document.getElementById(window.imglocal).style.display = 'inline';
				continue;
			}

			aImages[i].setAttribute('hsrc', hsrc);
			aImages[i].setAttribute('hdiv', hdiv);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
				showText(this.getAttribute('hdiv'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
				hideText(this.getAttribute('hdiv'));
			}
		}
	}
}

window.onload = initRollovers;

