var Tween = (function(){
	function startInterval(instance){
		instance.playing = setInterval(function(){instance.animate()}, instance.intervalRate);
	}

	function constructor(id, property, initial, end, time){
		this.obj = id;
		this.prop = property;
		this.init = initial;
		this.current = initial;
		this.time = time;
		this.end = end;
		this.final = end;
		this.intervalRate = 15;
	}
	
	constructor.prototype.play = function(){
		this.stop();
		this.final = this.end;
		startInterval(this);
	};
	
	constructor.prototype.stop = function(){
		clearInterval(this.playing);
	};
	
	constructor.prototype.rewind = function(){
		this.stop();
		this.final = this.init;
		startInterval(this);
	};
	
	constructor.prototype.animate = function(){
		this.current += (this.final-this.current)/Math.sqrt(Math.abs(this.time*100));
		this.obj.style[this.prop] = this.current.toString()+'px';
		if(Math.round(this.current*100) == this.final*100){
				this.stop();
		}
	};

	return constructor;
}
)();
