var Animator =
{
	animateLinear: function(duration, loops, animation, onCompletion)
	{
		var start = new Date();
		
		var loop = 0;
		tick();
		
		function tick()
		{
			var now = new Date();
			var progress = Math.min(1, (now - start) / duration);
			
			for (var i = 0; i < animation.length; i++) {
				animation[i].tick(progress);
			}
			
			if (progress < 1) {
				setTimeout(tick, 1);
			} else {
				if (++loop < loops || loops == 0) {
					start = now;
					setTimeout(tick, 1);
				} else if (typeof onCompletion != 'undefined') {
					onCompletion();
				}
			}
		}
	}
};

function FadeCssOpacity(element, startOpacity, endOpacity)
{
	this.element = $(element);
	this.startOpacity = startOpacity;
	this.endOpacity = endOpacity;
	this.opacityRange = endOpacity - startOpacity;
	
	// If IE, give element layout
	if (this.element.filters) {
		this.element.style.zoom = '100%';
	}
}

FadeCssOpacity.prototype =
{
	tick: function(progress)
	{
		setCssOpacity(this.element, this.startOpacity + (progress * this.opacityRange));
	}
};
