//*** This script creates rollovers for images with the id
//*** starting with "ROLLn_" or "ROLCn_"
//*** ROLLn_filename with no extension will create an n+1 state rollover
//*** ROLCn_filename with no extension  will create an n+1 state rollover plus a click image
//*** images must be .gif
//*** files for rollover end in "_ROLLx.gif" where x is a single digit indicating rollover number, starting at 0 going to 9
//*** files for click end in "_CLICK.gif" 
//
//window.onload=rolloverInit;
//var rollNum=0; //tracks which rollover image we are on
//var nRolls=0;  //number of rollovers

function rolloverInit(){
	for (var i=0; i<document.images.length; i++){				
		var idstring=document.images[i].id;
		if (idstring.substring(0,3)=="ROL") {
			setupRollover(document.images[i]);
		}
	}
}

function setupRollover(thisImage) {
	thisImage.nRolls=parseInt(thisImage.id.substring(4,5))+1;
	thisImage.rollNum=0;
	thisImage.outImage=new Image();
	thisImage.outImage.src=thisImage.src;
	thisImage.onmouseout=rollOut;
	thisImage.overImage=new Array(thisImage.nRolls);
	for (var i=0; i<thisImage.nRolls; i++){
		thisImage.overImage[i]=new Image();
		thisImage.overImage[i].src=thisImage.id.substring(6)+"_ROLL"+i+".gif";
	}
	thisImage.onmouseover=rollOver;
	
	if (thisImage.id.substring(0, 4)=="ROLC"){
		thisImage.clickImage=new Image();
		thisImage.clickImage.src=thisImage.id.substring(6)+"_CLICK.gif";
		thisImage.onclick=rollClick;
	}
}

function rollOver(){
	this.src=this.overImage[this.rollNum].src;
	this.rollNum++;
	if (this.rollNum==this.nRolls) this.rollNum=0;
}

function rollOut(){
	this.src=this.outImage.src;
}

function rollClick(){
	this.src=this.clickImage.src;
}

