function AnimCls(name, div)
{
 this.wait = 5;
 this.div = div;
 this.name = name;
 this.inwait = false;
 this.img = new Image();
 this.images = new Array();
 
 this.intval = function(mixed_var, base)
 {
  var tmp;
  if(typeof(mixed_var) == 'string')
  {
   tmp = parseInt(mixed_var);
   if(isNaN(tmp)) return 0;
    else return tmp.toString(base || 10);
  }
  else if(typeof(mixed_var) == 'number')
   return Math.floor(mixed_var);
  else return 0;
 };
 
 this.ImgAdd = function(img, txt)
 {
  var ind = this.images.length;
  this.images[ind] = new Array(img, txt);
 };
 
 this.Start = function(wait)
 {
  this.ind = 0;
  wait = this.intval(wait);
  if(wait > 0) this.wait = wait;
  if(this.images.length > 0)
   setTimeout(this.name+'.NextImg(\'Start\');', 10);
 };
 
 
 this.NextImg = function(from)
 {
  if(this.ind >= this.images.length) this.ind = 0;
  this.img.src = this.images[this.ind][0];
  this.OnLoadImg();
 }
 
 this.OnLoadImg = function()
 {
  if(this.inwait)
   return setTimeout(this.name+'.OnLoadImg()', 1000);
  
  this.SetWait(true); setTimeout(this.name+'.SwapImg(0, 1);', 1);
  setTimeout(this.name+'.SetWait(false);', (this.wait*1000));
  
  this.ind++; setTimeout(this.name+'.NextImg(\'OnLoadImg\');', 500);
 };
 
 this.SwapImg = function(set, dlt)
 {
  if((set==0)&&(dlt<0)) return;

  i = this.intval(set);
  obj = document.getElementById(this.div);
  obj.style.filter = "alpha(opacity="+(100-i)+")";
  obj.style.opacity = (100-i)/100;

  if((set==100)&&(dlt>0))
  {
   obj.style.backgroundImage = "url('"+this.img.src+"')";
   dlt = -1*dlt;
  };

  set = set + dlt;
  set = (set<0 ? 0 : set); set = (set>100 ? 100 : set);
  setTimeout(this.name+'.SwapImg('+set+', '+dlt+');', 5);
 };
 this.SetWait = function(set)
 {
  this.inwait = set;
 };
};
