// JavaScript Document for BBC Laboratories

/*this code was taken from an example in the book 'Visual Quickstart Guide: JavaScript & Ajax 6th Edition' by Tom Negrino and Dori Smith*/

window.onload = rolloverInit;

function rolloverInit() {
	for (var i=0; i<document.images.length; i++){
		if (document.images[i].parentNode.tagName == "A"){
			setupRollover(document.images[i]);
		}
	}
}/*end of rolloverInit function that checks for the number of images that are enclosed in <a> tags; in other words, images that are links*/

function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	
	thisImage.overImage = new Image();
	thisImage.overImage.src = "../buttons/" + thisImage.id + "_on.gif";
	thisImage.onmouseover = rollOver;
}//end of setupRollover function

function rollOver() {
	this.src = this.overImage.src;
}//end of rollOver function

function rollOut() {
	this.src = this.outImage.src;
}//end of rollOut function