function AdRotator(clientid, objs)
{
    this.clientid = clientid;    
    this.imgs = new Array();

    this.zInterval = null;
    this.current=0;
    this.pause=true;
    this.aniPause = 3;
    this.aniTime = 2;
    this.aniSegments = 30;
    this.objs = objs;
    this.lastImage = null;
    var self = this;
    
this.setOpacity = function(obj) {
	if(obj.xOpacity>.99) {
		obj.xOpacity = .99;
		return;
	}
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	if (document.all)
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
}


this.display = function(doUpdate)
{   
    var objs = self.objs;
    
    var update = false;
    
    if (doUpdate) update = true;
    
    var i = self.current;
    var iobj = self.imgs[i];
 
    if (!(iobj.src == "" || iobj.src == null || iobj.src == undefined))
    {
      if (objs[i][6] == "True")
      {	        
	        var nOpacity = iobj.xOpacity;
	
        	nOpacity+=1/self.aniSegments;
        	iobj.xOpacity = nOpacity;
	        self.setOpacity(iobj);



        	if(doUpdate || nOpacity>=0.99) {
          	    var nIndex = self.imgs[i+1]?i+1:0;
        	    iobj.style.display = "none";
		    self.imgs[nIndex].xOpacity = 0;
	            self.setOpacity(self.imgs[nIndex]);
        	    self.imgs[nIndex].style.display = "block";
        	    
		        self.current = nIndex;
		        update = true;
        		setTimeout(self.clientid + "_Ad.display();",objs[self.current][5]*1000);
	        } else {
        		setTimeout(self.clientid + "_Ad.display();",self.aniTime/self.aniSegments*1000);
            }
      } else {
        iobj.style.display = "none";
        self.current = self.imgs[i+1]?i+1:0;
        self.imgs[self.current].style.display = "block";
        self.imgs[self.current].xOpacity = 0.99;
        self.setOpacity(self.imgs[self.current]);
	i = self.current;
        setTimeout(self.clientid + "_Ad.display();",objs[self.current][5] * 1000);
        
        update = true;
      }
    }
    
    if (!update) return;

    var aobj = document.getElementById(self.clientid + "_AdA");
    aobj.style.backgroundImage = "url(" + objs[i][0] + ")";
    
    aobj.href = objs[i][3];
    aobj.target = (objs[i][4] == "True") ? "_blank" : "_self";
}

this.initialize = function()
{
    var objs = self.objs;
    
	for (var i = 0; i < objs.length; i++)
	{
	    self.imgs[i] = document.createElement("IMG");
	    self.imgs[i].style.display = "none";
	    self.imgs[i].src = objs[i][0];
	    self.imgs[i].xOpacity = 0;
	    document.getElementById(self.clientid + "_AdA").appendChild(self.imgs[i]);
	}
	self.display(true);
}

}

