Animation = new Object();
Animation.fps = 15;
Animation.items = new Array();
Animation.timer = null;
Animation.timerInterval = 33;

//
// Adds a new animation to the queue
//
Animation.add = function(anim)
{
	Animation.items.push(anim);
}


//
// Ends all animations
//
Animation.end = function()
{
	window.clearTimeout(Animation.timer);
}


//
// Executes an animation step
//
Animation.execute = function()
{
	var anim;
	
	for (var i = 0; i < Animation.items.length; i++)
	{
		anim = Animation.items[i];
		
		if (anim && anim.execute)
		{
			anim.execute();
		}
	}

	Animation.timer = window.setTimeout(function(){Animation.execute()}, Animation.timerInterval);
}


//
// Initializes the animation system
//
Animation.load = function()
{
	Animation.timer = window.setTimeout(function(){Animation.execute()}, Animation.timerInterval);
}


//
// Removes an animation from the queue
//
Animation.remove = function(anim)
{
	for (var i = 0; i < Animation.items.length; i++)
	{
		if (Animation.items[i] == anim)
		{
			Animation.items.splice(i,1);
		}
	}
}


// check for common script
if (!Tactica)
{
	alert("Required script 'scripts/tactica.js' is missing. Did you forget a script tag?");
}

// add startup script
Tactica.addLoadFunction(Animation.load);

