//Ken Brown -SSC 04/11/2007
//Updated 01/11/2008 for EBA website
var Rotatorimg1 = new ImageRotator('img1',3,13,'images/Rotator/die_iron');
var Rotatorimg2 = new ImageRotator('img2',3,6,'images/Rotator/keytag');
var Rotatorimg3 = new ImageRotator('img3',3,5,'images/Rotator/med');

//Ken Brown 04/11/07
function ImageRotator(oName,Interval,numImages,imgPath)
{
	this.number_of_image = numImages;				//<-- Set this to the total number of Images in the Image Directory.
	this.oName = oName;
	this.interval = Interval; 				// delay between rotating images (in seconds)
	this.Timeout;			
	this.random_display = 0; 				// 0 = no, 1 = yes
	this.interval *= 1000;
	this.SetTimer = SetTimer;
	this.ClearTimer = ClearTimer;
	this.imgPath = imgPath;					//Set Pathname

	this.image_index = 1;
	this.SetTimer();
}

function ClearTimer(){
	clearInterval(this.Timeout);
}

function SetTimer(){
	this.Timeout = setInterval("rotateImage('" + this.oName + "')", this.interval);		//Set timeout
}

function generate(x, y)
{
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function getNextImage(Tag) 
{
	if (eval("Rotator" + Tag).random_display) {
		eval("Rotator" + Tag).image_index = generate(0, eval("Rotator" + Tag).number_of_image-1);
	}
	else {
		eval("Rotator" + Tag).image_index = (eval("Rotator" + Tag).image_index+1) % eval("Rotator" + Tag).number_of_image;
	}
	var image_item = eval("Rotator" + Tag).image_index; //Retun Index Number
	//if (image_item == 0)
	//	image_item = 1;
	return(image_item);
}

function rotateImage(ImgTag) {
	if (eval("Rotator" + ImgTag).number_of_image > 0){
 		var image_item = getNextImage(ImgTag); 	  		//Get Image Index
 		document[ImgTag].src = eval("Rotator" + ImgTag).imgPath + image_item + '.jpg' //image_item.src;			//Src Image Tag
		}
}
 //		document[ImgTag].alt = image_item.alt; 			//Add Alt Tag
/*	
 		if(navigator.appName == "Microsoft Internet Explorer"){
 			eval("EWM_AdLink" + ImgTag).href = image_item.link;	//Set Link IE
 		}
 		else{
	 	//	document.links["EWM_AdLink" + ImgTag].href  = image_item.link; //Set Link NS6+
 		}
  		
 	}*/		