function anim(left,top,width,height,img,imgwidth,imgheight,dx,dy,dt,n) {
  // width, height - x, y sizes for animation viewport
  // img - image containing frames animation
  // imgwidth, imgheight - sizes of image
  // dx, dy - distance to scroll per frame of animation
  // dt - time to view each frame
  // n - times to loop through animation
  this.left = left;
  this.top  = top;
  this.width = width;
  this.height = height;
  this.img = new Image();
  this.img.src = img;
  this.imgwidth = imgwidth;
  this.imgheight = imgheight;
  this.dx = dx;
  this.dy = dy;
  this.dt = dt;
  this.n = n;
  this.id = 'clipanim'+anim.counter++;
  document.write('<style type="text/css">\n',
		 '  #'+this.id+'a {\n',
		 this.left || this.top ? '    position:absolute;\n' : '    position:relative;\n',
		 this.left ? '    left:'+this.left+';\n' : '',
		 this.top ? '    top:'+this.top+';\n' : '',
		 '    width:'+this.width+';\n',
		 '    height:'+this.height+';\n',
		 '    overflow:hidden;\n',
		 '  }\n',
		 '  #'+this.id+'b {\n',
		 '    position:absolute;\n',
		 '  }\n',
		 '</style>\n');
  anim[this.id] = this;
}

anim.counter = 0;

anim.prototype.output = function() {
  document.write('<div id="'+this.id+'a"><div id="'+this.id+'b"\n',
		 '><table border="0" cellspacing="0" cellpadding="0"\n',
		 '><tr><td\n',
		 '><img src="'+this.img.src+'" height="'+this.imgheight+'" width="'+this.imgwidth+'" alt=""\n',
		 '></td><td\n',
		 '><img src="'+this.img.src+'" height="'+this.imgheight+'" width="'+this.imgwidth+'" alt=""\n',
		 '></td></tr><tr><td\n',
		 '><img src="'+this.img.src+'" height="'+this.imgheight+'" width="'+this.imgwidth+'" alt=""\n',
		 '></td><td\n',
		 '><img src="'+this.img.src+'" height="'+this.imgheight+'" width="'+this.imgwidth+'" alt=""\n',
		 '></td></tr></table\n',
		 '></div></div>\n');
  if (document[this.id+'a']) {	/* nn specific */
    var my = document[this.id+'a'].clip;
    my.x = 0;
    my.y = 0;
    my.width = this.width;
    my.height = this.height;
    return true;
  } else if (document.all[this.id+'a']) {
    return true;
  } else {
    return false;
  }
}

anim.prototype.scroll = function() {
  if (document[this.id+'a']) {	/* nn specific */
    var my = document[this.id+'a'].document[this.id+'b'];
    my.left = Math.round((my.left+this.dx-this.imgwidth)%this.imgwidth);
    my.top = Math.round((my.top+this.dy-this.imgheight)%this.imgheight);
  } else if (document.all[this.id+'a']) { /* ie specific */
    var my = document.all[this.id+'a'].document.all[this.id+'b'].style;
    my.pixelLeft = Math.round((my.pixelLeft+this.dx-this.imgwidth)%this.imgwidth);
    my.pixelTop = Math.round((my.pixelTop+this.dy-this.imgheight)%this.imgheight);
  }
}

anim.prototype.start = function() {
  if (document[this.id+'a']) {	/* nn specific */
    var my = document[this.id+'a'].clip;
    my.x = 0;
    my.y = 0;
    my.width  = this.width;
    my.height = this.height;
  }
  this.timer = setInterval('anim.'+this.id+'.scroll()', this.dt);
}

anim.prototype.stop = function() {
  if (this.timer) clearInterval(this.timer);
  this.timer = false;
}

anim.prototype.rewind = function() {
  this.stop();
  if (document[this.id+'a']) {	/* nn specific */
    var my = document[this.id+'a'].document[this.id+'b'];
    my.left = 0;
    my.top = 0;
  } else if (document.all[this.id+'a']) { /* ie specific */
    var my = document.all[this.id+'a'].document.all[this.id+'b'].style;
    my.pixelLeft = 0;
    my.pixelTop = 0;
  }
}

anim.prototype.moveto = function(left,top) {
  if (document[this.id+'a']) {	/* nn specific */
    var my = document[this.id+'a'];
    my.left = left;
    my.top = top;
  } else if (document.all[this.id+'a']) { /* ie specific */
    var my = document.all[this.id+'a'].style;
    my.pixelLeft = left;
    my.pixelTop  = top;
  }
}
