UI.Animation =
{
	// Determines whether functions are running or not
	animating: false,
	// Animation Queue
	queue: new Array,
	amount: 0,
	
	
	// Els = Array of elements to animate.
	// Type = type of animation, currently we only have Show and Hide
	add: function(els,type)
	{
		var th = UI.Animation;
		
		th.queue[th.queue.length] = [els,type];
		
		if(th.animating==false) th.animate();
	},
	
	animate: function()
	{
		var th = UI.Animation;
		
		if(th.animating==false) th.animating==true;
		if(th.queue.length>0)
		{
			if(th.queue[0][1]=='show')
			{
				th.queue[0][0].className='show';
			}
			else if(th.queue[0][1]=='destroy')
			{
				for(var x=0;x<th.queue.length;x++)
				{
					if(th.queue[x][1]=='destroy') th.queue[x][0].className='destroy';
					else break;
				}
			}
		}
		else th.animating=false;
	},
	
	finished: function(el,animType)
	{
		var th = UI.Animation;
		
		switch(animType)
		{
			case 'showAnimation':
				th.queue.splice(0,1);
				break;
			case 'destroyAnimation':
				$D(el);
				th.queue.splice(0,1);
				break;
		}
		th.animate();
	}
};
