function bannerimage(url,link,alt) {
  this.link = link;
  this.url = url;
  this.alttag = alt;
  this.imageobj = new Image();
  this.imageobj.src = url;
}

function rotatingbanner(width,height) {
  this.width = width;
  this.height = height;
  this.imageboxobject = null;
  this.imagelist = new Array();
  this.currentimageno = null;

  this.addimage = function(url,link,alt) {
    var temp = new bannerimage(url,link,alt);
    this.imagelist[this.imagelist.length] = temp;
  };

  this.render = function() {
    document.write("<div id='imagebox' style='width:"+width+"px;height:"+height+"px;overflow:hidden;text-align:center;'/>");
    this.imageboxobject = document.getElementById('imagebox');
    this.rotate();
    document.write("</div>");
  };

  this.rotate = function() {
    if (this.imagelist.length<=1 && this.currentimageno!=null) return; 
    this.currentimageno = Math.floor(Math.random()*this.imagelist.length);
    var currentimage = this.imagelist[this.currentimageno];
    this.imageboxobject.innerHTML = "<a href='"+currentimage.link+"'><img src='"+currentimage.url+"' alt='"+currentimage.alttag+"' title='"+currentimage.alttag+"' border='2' width='"+this.width+"' height='"+this.height+"' id='rotateimage'></a>";
  }
}
