//
// JavaScript Document
// RollOver by laplima
//
// For each image (e.g. "bt.*") inside a <a> tag and of class "rollover"
// there must exist a corresponding image (e.g. "bt-over.*") inside the
// same directory (the specific extension doesn't matter).
//

addLoadListener(rolloverInit);

function rolloverInit() {
	for (var i=0; i<document.images.length; i++)
		if (document.images[i].parentNode.tagName == "A" && document.images[i].className == "rollover")
			setupRollover(document.images[i]);
}

function setupRollover(thisImage) {
	var source = thisImage.src;
	var ext = source.substr(source.length-4);	// e.g. ".png"

	thisImage.outimg = new Image;
	thisImage.outimg.src = source;
	thisImage.onmouseout = rollout;
	
	thisImage.overimg = new Image;
	thisImage.overimg.src = source.replace(ext,"-over"+ext);
	thisImage.onmouseover = rollover;
}

function rollout() {
	this.src = this.outimg.src;
}

function rollover() {
	this.src = this.overimg.src;
}

