function DomAnimPath(o) {
	this.path=new Array()
	this.source=o
	this.pcount=0
	this.loop=false
	this.done=false
	
	return this
}
DomAnimPath.prototype.addStep=function(xs,ys,f,func) {
	var i=this.path.length
	this.path[i]=new Array()
	this.path[i].xs=xs
	this.path[i].ys=ys
	this.path[i].f=f
	this.path[i].func=func
}
DomAnimPath.prototype.setLoop=function(b) {
	this.loop=b
}
DomAnimPath.prototype.init=function() {
	this.source.x=this.source.getX()
	this.source.y=this.source.getY()
	this.reset()
}

DomAnimPath.prototype.reset=function() {
	this.pcount=0
	this.done=false
	this.fcount=this.path[0].f
}
DomAnimPath.prototype.move=function() {
	if (this.done) return 
	this.source.x+=this.path[this.pcount].xs
	this.source.y+=this.path[this.pcount].ys
	this.source.setXY(this.source.x,this.source.y)
	this.fcount-=1
	if (this.fcount==0) {
		if (this.path[this.pcount].func) this.path[this.pcount].func(this)
		this.pcount++
		if (this.pcount==this.path.length) {
			if (this.loop) this.reset()
			else this.done=true
		} else this.fcount=this.path[this.pcount].f
	}
	
}

DomAnim={
	anims : [],
	interval : 50,
	
	start:function() {
		for (var i=0;i<DomAnim.anims.length;i++) DomAnim.anims[i].init()
		setTimeout('DomAnim.nextFrame()',DomAnim.interval)
	},

	addAnim:function(anim) { 
		DomAnim.anims[DomAnim.anims.length]=anim 
	},
	
	nextFrame:function() {
		for (var i=0;i<DomAnim.anims.length;i++) {
			DomAnim.anims[i].move()
		}
		setTimeout('DomAnim.nextFrame()',DomAnim.interval)
	}
}
