// <![CDATA[

var ActionsWidget = Class.create(
{
	initialize: function()
	{
		var actions  = $$('div#actions-list div.action');
		this.actions = $A();
		this.timer   = null;
		this.opened  = 0;
		
		for(var i=0, len=actions.length; i<len; i++)
		{
			var action  = actions[i].cleanWhitespace();
			var details = action.childElements();

			this.actions.push({'container': action, 'title': details[0], 'details': details[1].hide()});
			
			this.actions[i].container.observe('mouseover', this.toggleDetails.bind(this, i));
//			this.actions[i].container.observe('mouseout',  this.closeDetails.bind(this, i));
		}
		
		this.openDetails(this.opened);
	},
	
	toggleDetails: function(i)
	{
		if(i!= this.opened && !this.timer)
		{
			new Effect.Parallel
			(
				[
					new Effect.SlideUp(this.actions[this.opened].details, {sync: true}),
					new Effect.SlideDown(this.actions[i].details, {sync: true})
				],
				{
					duration: .25,
					beforeStart: function(){ this.timer = true;	}.bind(this),
					afterFinish: function(){ this.timer = false; this.opened = i; }.bind(this)
				}
			);
		}
	},
	
	openDetails: function(i)
	{
		this.actions[i].details.show();
	}
});

document.observe("dom:loaded", function()
{
	var actionsList = new ActionsWidget();
});

// ]]>
