var Tween = (function(){
	function constructor(obj,property,oHeight,fHeight,time,units,prefix){
		this.obj = obj;
		this.property = property;
		this.oh = oHeight;
		this.fh = fHeight;
		this.intervalRate = 10;
		this.position = 0;
		this.steps = Math.round(time/this.intervalRate);
		this.units = units;
		this.prefix = prefix;
		this.d;
		this.playing;
		this.ease = "easeSin";
	}
	function easeSin(instance){//returns a number between instance.oh and instance.fh
		return (Math.sin((instance.position/instance.steps)*Math.PI/2)*(instance.fh-instance.oh)+instance.oh);
	}
	function startInterval(instance){
		instance.playing = setInterval(function(){instance.animate()}, instance.intervalRate);
	}
	constructor.prototype.play = function(){
		if(this.position == 0){
			 this.stop();
			 this.d = 1;
			 startInterval(this);
		} else if(this.position == this.steps){
			 this.stop();
			 this.d = -1;
			 startInterval(this);
		}
	};
	constructor.prototype.stop = function(){
		clearInterval(this.playing);
	};
	constructor.prototype.animate = function(d){
		this.position += this.d;
		this.obj.style[this.property] = this.prefix+(eval(this.ease))(this)+this.units;
		if(this.position == this.steps || this.position == 0){this.stop();};
	};

	return constructor;
})();