var tween = {
	add: function(from, to, duration, callback) {
		if (!this.objects) {
			this.objects = [];
		}
		
		var object = {
			from: from,
			change: to - from,
			start: (new Date() - 0),
			duration: duration * 1000,
			callback: callback,
			now: 0
		}
		this.objects.push(object);
		this.update();
	},
	update: function() {
		var self = this;
		
		for (var i=0, len=this.objects.length; i<len; i++) {
			var o = this.objects[i];
			
			if (o) {
				o.now = (new Date() - 0) - o.start;
				o.value = -o.change * (o.now /= o.duration) * (o.now - 2) + o.from;
				o.callback(o.value);
				
				if (o.now > 1) {
					o = null;
					delete this.objects[i];
					this.objects.splice(i, 1);
				}
			}
		}
		
		if (this.objects.length == 0) {
			this.looping = false;
		} else {
			this.looping = true;
		}
		
		if (this.looping) {
			setTimeout(function() {self.update();}, 1);
		}
	}
}