

function getExt(string){
	imgIndex = string.indexOf('images/');
	actSrc = string.slice(imgIndex); 
	imgFile = actSrc.split('.');
	imgType = imgFile[1];	
	return imgType;
}

function init(){
	var imgArray = new Array();
	var imgcount = document.getElementsByTagName('img');
	for (var i = 0; i < imgcount.length; i++){
		// if the class is img, build rollover
		if (imgcount[i].className == "img") {
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');//set, in array, name of the original src
			imgcount[i].src = imgArray[n];// this sets original source and onmouseover events
			imgcount[i].style.visibility = "visible";
			imgcount[i].onmouseover = function(){
				imgOriginSrc = this.getAttribute('src');
				getExt(imgOriginSrc);
				imgNewSrc = imgOriginSrc.slice(0, -8)+"_on."+imgType;
				//alert(imgOriginSrc);
				this.setAttribute('src', imgNewSrc); // set the image
			}
			imgcount[i].onmouseout = function() {
				this.setAttribute('src',imgOriginSrc);
	        }
		}
		// if the imgon is set, then make the image static, w/o rollover states
		if (imgcount[i].className == "imgon"){
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');
			getExt(imgArray[n]);
			imgcount[i].src = imgArray[n].slice(0, -8)+"_on."+imgType;
			imgcount[i].style.visibility = "visible";
		}
	}
}

window.onload=function(){
init();
}
