var imageDir = "../images/";

window.onload = function(){
	//get all elements that have the class 'ro'
	rOvers = getElementsByClass('ro');
	//loop through the elements and set rollOver and rollOut actions
	for(i=0;i<rOvers.length;i++){
		addEvent(rOvers[i],'mouseover',rollOver);
		addEvent(rOvers[i],'mouseout',rollOut);
	}
	if (isStopped) { //this isn't part of the rollover, this is to stop the SitePal from speaking automatically.	
		stopSpeech(); 
	}
}
function rollOver(){
	//get and parse the image's file name
	imgSourceName = this.src;
	lastSlash = imgSourceName.lastIndexOf("/");
	imgSourceName = imgSourceName.substring(lastSlash+1);
	imgSourceName = imgSourceName.split(".");
	baseName = imgSourceName[0];
	extension = imgSourceName[1];
	//add _over
	baseName += "_over";
	//set the image's source
	this.src = imageDir+baseName+"."+extension;
}
function rollOut(){
	//get and parse the image's file name
	imgSourceName = this.src;
	lastSlash = imgSourceName.lastIndexOf("/");
	imgSourceName = imgSourceName.substring(lastSlash+1);
	imgSourceName = imgSourceName.split(".");
	baseName = imgSourceName[0];
	extension = imgSourceName[1];
	//find _over
	overPos = baseName.lastIndexOf("_over");
	//remove _over
	baseName = baseName.substring(0,overPos);
	//set the image's source 
	this.src = imageDir+baseName+"."+extension;
}

/*
attachEvent
author: John Resig
link:http://ejohn.org/projects/flexible-javascript-events/
*/
function addEvent( obj, type, fn ) {
	if(obj.attachEvent){obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	}
	else obj.addEventListener( type, fn, false );
}
/*
getElementsByClass
author: dustin diaz
link: http://www.dustindiaz.com/getelementsbyclass/
*/
function getElementsByClass(searchClass) {
	var classElements = new Array();
		node = document;
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}