function PhotoRotator(imgTagNameAttribute, adURLs, adImageURLs, rotationTime,
  PhotoRotatorVarName) {
 this.imgTagNameAttribute = imgTagNameAttribute
 this.adURLs = adURLs
 this.adImageURLs = adImageURLs
 this.rotationTime = rotationTime
 this.PhotoRotatorVarName = PhotoRotatorVarName
 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 = PhotoRotator_writeHTML
 this.start = PhotoRotator_start
 this.rotate = PhotoRotator_rotate
 this.handleClick = PhotoRotator_handleClick
}

function PhotoRotator_writeHTML() {
 document.write('<p align="center">')
 document.write('<a href="javascript:void(0)" ')
 document.write('onclick="'+this.PhotoRotatorVarName+'.handleClick()">')
 document.write('<img name="'+this.imgTagNameAttribute+'" border="0" ')
 document.write('src="'+this.adImageURLs[0]+'">')
 document.write('</a></p>')
}

function PhotoRotator_start() {
 window.setInterval(this.PhotoRotatorVarName + '.rotate()', this.rotationTime)
}

function PhotoRotator_rotate() {
 ++this.index
 this.index %= this.adImageURLs.length
 document.images[this.imgTagNameAttribute].src = this.adImages[this.index].src
}

function PhotoRotator_handleClick() {
 setTimeout("window.location.href = '"+this.adURLs[this.index]+"'",500)
}



