function AdRotator(imgTagNameAttribute, adURLs, adImageURLs, adTexts, rotationTime, adRotatorVarName) {
 this.imgTagNameAttribute = imgTagNameAttribute
 this.adURLs = adURLs
 this.adImageURLs = adImageURLs
 this.adTexts = adTexts
 this.rotationTime = rotationTime
 this.adRotatorVarName = adRotatorVarName
 this.index = 0;
 this.adImages = new Array(adImageURLs.length);
 for(var i=0; i<adImageURLs.length; ++i) {
  this.adImages[i] = new Image();
  this.adImages[i].src = adImageURLs[i];
 }
 this.writeHTML = AdRotator_writeHTML;
 //this.start = AdRotator_start;
 //this.rotate = AdRotator_rotate;
 this.handleClick = AdRotator_handleClick;
}

function AdRotator_writeHTML() {
 document.write('<p align="center">');
 document.write('<a href="javascript:void(0)" onMouseOver="window.status=\''+this.adTexts[0]+'\';return true\;" onMouseOut="window.status=\'\'\;" ');

 //document.write('<a href="javascript:void(0)"');
 document.write('onclick="'+this.adRotatorVarName+'.handleClick()\;window.status=\'\'\;">');
 document.write('<img name="'+this.imgTagNameAttribute+'" border="0" ');
 document.write('src="'+this.adImageURLs[0]+'">');
 document.write('</a></p>');
}

function AdRotator_start() {
 window.setInterval(this.adRotatorVarName + '.rotate()', this.rotationTime);
}

function AdRotator_rotate() {
 ++this.index;
 this.index %= this.adImageURLs.length;
 document.images[this.imgTagNameAttribute].src = this.adImages[this.index].src;
}

function AdRotator_handleClick() {
 setTimeout("window.top.location.href = '"+this.adURLs[this.index]+"'",500);
}

//Define the total number of Ads to rotate.
var numAds = 20;
var idxNum = 0;
var theAds = new Array();
var theURL = new Array(numAds);
var theTEXT = new Array(numAds);
var theImage = new Array(numAds);
var urls = new Array(numAds);
var imageNames = new Array(numAds);
var texts = new Array(numAds);

//Define Text
theTEXT[0] = "Click to Enter | TC3Imagery";
theTEXT[1] = "Click to Enter | TC3Imagery";
theTEXT[2] = "Click to Enter | TC3Imagery";
theTEXT[3] = "Click to Enter | TC3Imagery";
theTEXT[4] = "Click to Enter | TC3Imagery";
theTEXT[5] = "Click to Enter | TC3Imagery";
theTEXT[6] = "Click to Enter | TC3Imagery";
theTEXT[7] = "Click to Enter | TC3Imagery";
theTEXT[8] = "Click to Enter | TC3Imagery";
theTEXT[9] = "Click to Enter | TC3Imagery";
theTEXT[10] = "Click to Enter | TC3Imagery";
theTEXT[11] = "Click to Enter | TC3Imagery";
theTEXT[12] = "Click to Enter | TC3Imagery";
theTEXT[13] = "Click to Enter | TC3Imagery";
theTEXT[14] = "Click to Enter | TC3Imagery";
theTEXT[15] = "Click to Enter | TC3Imagery";
theTEXT[16] = "Click to Enter | TC3Imagery";
theTEXT[17] = "Click to Enter | TC3Imagery";
theTEXT[18] = "Click to Enter | TC3Imagery";
theTEXT[19] = "Click to Enter | TC3Imagery";



//Define URLs
theURL[0] = "who01.html";
theURL[1] = "who01.html";
theURL[2] = "who01.html";
theURL[3] = "who01.html";
theURL[4] = "who01.html";
theURL[5] = "who01.html";
theURL[6] = "who01.html";
theURL[7] = "who01.html";
theURL[8] = "who01.html";
theURL[9] = "who01.html";
theURL[10] = "who01.html";
theURL[11] = "who01.html";
theURL[12] = "who01.html";
theURL[13] = "who01.html";
theURL[14] = "who01.html";
theURL[15] = "who01.html";
theURL[16] = "who01.html";
theURL[17] = "who01.html";
theURL[18] = "who01.html";
theURL[19] = "who01.html";

//Define Image Paths for Banners
theImage[0] = "images/where/bryant-park-tree-ny.jpg";
theImage[1] = "images/who/chinatown-checkers.jpg";
theImage[2] = "images/who/chuck-kneeling.jpg";
theImage[3] = "images/who/explosion-men.jpg";
theImage[4] = "images/where/grandmas-bedroom.jpg";
theImage[5] = "images/what/hollywood-breaking.jpg";
theImage[6] = "images/who/hoola-girl.jpg";
theImage[7] = "images/why/hostage-haircut.jpg";
theImage[8] = "images/who/jessica-reading.jpg";
theImage[9] = "images/who/kaori-subway.jpg";
theImage[10] = "images/where/lady-of-the-woods.jpg";
theImage[11] = "images/who/lemonade-stand.jpg";
theImage[12] = "images/who/lost-at-last.jpg";
theImage[13] = "images/where/paraty-brasil.jpg";
theImage[14] = "images/who/pink-alara.jpg";
theImage[15] = "images/who/sand-shark-girl.jpg";
theImage[16] = "images/why/sexy-lamp.jpg";
theImage[17] = "images/who/sofia-vampire.jpg";
theImage[18] = "images/who/susie-of-la-honda.jpg";
theImage[19] = "images/what/ukiah-sunflowers.jpg";

function createClass(url, image, text) {
	this.url = url;
	this.image = image;
	this.text = text;
}

for (k=0; k < numAds; k++) {
	theAds[k] = new createClass(theURL[k], theImage[k], theTEXT[k]);
}

var randNum = Math.floor(Math.random() * numAds);
var endNum = numAds - randNum;

for (j=randNum; j < numAds; j++) {
 urls[idxNum] = theAds[j].url;
 imageNames[idxNum] = theAds[j].image;
 texts[idxNum] = theAds[j].text;
 idxNum = ++idxNum;
}

if (randNum > 0) {
	for (j=0; j < randNum; j++) {
 		urls[idxNum] = theAds[j].url;
 		imageNames[idxNum] = theAds[j].image;
 		texts[idxNum] = theAds[j].text;
		idxNum = ++idxNum;
	}
}
ar1 = new AdRotator("adImage", urls, imageNames, texts, 10000, "ar1");