/***
* ModTree - Module-Based PHP Framework
* (c) Sebastian Bojanowski ( sbojanowski (at) gmail (dot) com )
* Executable actions container Script
***/
var Actions = {
	init : function() {
             this.groups = new Utils.List();
	},
	getGroup : function(groupName) {
	     var group = this.groups.getItemByName(groupName);
             if (group == null)
                  group = this.groups.addItem(new Actions.ActionsGroup(groupName));	
             return group;
	},
        addAction : function(groupName,action) {
             this.getGroup(groupName).addAction(action);
        },
	execute : function(groupName) {
             this.getGroup(groupName).execute();
	}
}
// Action Class
Actions.Action = function(func) {
	this.functionHandler = func;
}
Actions.Action.prototype = {
	execute : function() {
             this.functionHandler();
	}
}
// Actions Group Class
Actions.ActionsGroup = function(name) {
	this.groupName = name;
	this.actions = new Utils.List();
}
Actions.ActionsGroup.prototype = {
	addAction : function(action) {
             this.actions.addItem(action);
        },
        execute : function() {
             this.actions.first();
             while (this.actions.valid()) {
                  this.actions.getItem().execute();
                  this.actions.next();
             }
        },
	getName: function() {	
             return this.groupName; 
	}
}
Actions.init();
