dw_Rotator.restartDelay = 500; // delay onmouseout before call to rotate
dw_Rotator.col=[];

/*Rotator*/
function dw_Rotator(name,speed,path) {

/*jmeno rotatoru*/
this.name=name;
/*rychlost rotace*/
this.speed=speed||4500;
/*cesta k obrazkum*/
this.path=path||"";
/*aktualni obrazek*/
this.ctr=0;
/*citac*/
this.timer=0;
/*pole obrazku*/
this.imgs=[];
this.altimgs=[];
this.index=dw_Rotator.col.length;
dw_Rotator.col[this.index]=this;
this.animString="dw_Rotator.col["+this.index+"]";
};

/*addImages*/
dw_Rotator.prototype.addImages=function() {
var img;
for(var i=0;arguments[i];i++)
  {
  img=new Image();
  img.src=this.path+arguments[i];
  this.imgs[this.imgs.length]=img;
  }
};

/*addImages*/
dw_Rotator.prototype.addAltImages=function() {
var img;
for(var i=0;arguments[i];i++)
  {
  img=new Image();
  img.src=this.path+arguments[i];
  this.altimgs[this.altimgs.length]=img;
  }
};

/*start*/
dw_Rotator.start=function() {
var len=dw_Rotator.col.length,obj;
for(var i=0;i<len;i++)
  {
  obj=dw_Rotator.col[i];
  if(obj&&obj.name) obj.timer=setTimeout(obj.animString+".rotate()",obj.speed);
  }
};

/*rotate*/
dw_Rotator.prototype.rotate=function(){
clearTimeout(this.timer);
this.timer=null;
if(this.ctr<this.imgs.length-1)
  this.ctr++;
else
  this.ctr=0;

var imgObj=document.images[this.name];
if(imgObj)
  {
  imgObj.src=this.imgs[this.ctr].src;
  this.timer=setTimeout(this.animString+".rotate()",this.speed);
  }
};

dw_Rotator.highlight=function(n){
var obj=dw_Rotator.col[n];
var imgObj=document.images[obj.name];
if(imgObj)
  {
  imgObj.src=obj.altimgs[obj.ctr].src;
  }
};
dw_Rotator.unhighlight=function(n){
var obj=dw_Rotator.col[n];
var imgObj=document.images[obj.name];
if(imgObj)
  {
  imgObj.src=obj.imgs[obj.ctr].src;
  }
};
