Framework.ActionStates = {
	
	show: function(actionState, context, data, options)
	{
		debug("Framework.ActionStates.show(" + actionState + "," + context +")");
		
		actionState = this.getMessageAndType(actionState, context);
		if (!actionState)
		{
			debug("Framework.ActionStates.show() - message not found");
			return false;
		}
		
		debug(actionState);

		if (!options)
		{
			options = {};
		}
		
		if (data)
		{
			var syntax = /(^|.|\r|\n)(%(.*?)%)/;
			var template = new Template(actionState.message, syntax);
			actionState.message = template.evaluate(data);
			options.callbackData = data; //useful to pass along with the onShow function that may be in the options
		}

		Framework.ActionStateMessage.show(actionState.type, actionState.message, options);
		
		return true;
	},
	
	getMessageAndType: function(actionState, context)
	{
		var elementActionState = $('actionStates_' + context);
		if (elementActionState instanceof Element)
		{
			var elmActionState = elementActionState.down('.actionState_' + actionState);
			if (typeof elmActionState === "undefined")
			{
				Framework.Debugging.Console.log('Could not find message for actionstate ' + actionState + ' (context: ' + context + ')', 'error');
				return false;
			}
			
			return {
				'type': elmActionState.getClassData('type'), 
				'message': elmActionState.innerHTML
			};
		}
	},
	
	_eoo: true
};
