/* Code created by Corin Nguyen - www.ockhamdesign.com */

var offSuffix = "UP";
var hovSuffix = "OVER";
var offLength = offSuffix.length;
var hovLength = hovSuffix.length;
var onLength = onSuffix.length;

var selectedID = "";

function roll(e, img)
{
	switch (e.type)
		{
		case "mouseover":return display("mouseover",img);break;
		case "mouseout" :return display("mouseout",img);break;
		case "mousedown" :return display("mousedown",img);break;
		}
	return true;
}

function display(state,img)	
{
	var imgSrc,posDot,prevSrc,posDot2,previousImage;
	if((posDot=(imgSrc=new String(img.src)).lastIndexOf('.'))<0)return true;
	
	
	if (state == "mousedown")
	{
		if (selectedID != "")
		{
			if((posDot2=(prevSrc=new String(selectedID.src)).lastIndexOf('.'))<0)return true;
			previousImage = prevSrc.substring(0,posDot2-onLength) + offSuffix + 
			prevSrc.substring(posDot2,prevSrc.length);
			document.images[selectedID.name].src = previousImage;
		}
		img.src = imgSrc.substring(0,posDot-hovLength)+ onSuffix + imgSrc.substring(posDot,imgSrc.length);
		selectedID = img;
	}
	
	if (selectedID != img)
	{
		switch (state) {
		case "mouseover"  :img.src = imgSrc.substring(0,posDot-offLength)+ hovSuffix + imgSrc.substring(posDot,imgSrc.length);break;
		case "mouseout" :img.src = imgSrc.substring(0,posDot-hovLength)+ offSuffix + imgSrc.substring(posDot,imgSrc.length);break;
		}
	}

	return true;
}
