tfx_animation = new Object();
tfx_animation.list = new Array();
tfx_animation.timer = null;
tfx_animation.timerInterval = 33;


//
// Adds a new animation to the queue
//
tfx_animation.add = function(anim)
{
	tfx_animation.list.push(anim);
}


//
// Ends all animations
//
tfx_animation.end = function()
{
	window.clearInterval(tfx_animation.timer);
}


//
// Executes an animation step
//
tfx_animation.execute = function()
{
	var anim;
	
	for (var i = 0; i < tfx_animation.list.length; i++)
	{
		anim = tfx_animation.list[i];
		
		if (anim && anim.execute)
		{
			anim.execute();
		}
	}
}


//
// Initializes the animation system
//
tfx_animation.init = function()
{
	tfx_animation.timer = window.setInterval("tfx_animation.execute()", tfx_animation.timerInterval);
}


//
// Removes an animation from the queue
//
tfx_animation.remove = function(anim)
{
	for (var i = 0; i < tfx_animation.list.length; i++)
	{
		if (tfx_animation.list[i] == anim)
		{
			tfx_animation.list.splice(i,1);
		}
	}
}

if (window.addEventListener) window.addEventListener("load", tfx_animation.init, null);
else if (window.attachEvent) window.attachEvent("onload", tfx_animation.init);