function ActionQueue(
	sControllerUrl
	) {

	this.sControllerUrl	= sControllerUrl;
	this.aActions = [];
	this.iLastProcessingCommandId = 0;

}

ActionQueue.prototype = {

	addAction : function(oAction) {

		this.aActions[this.aActions.length] = oAction;

		oAction.setId(this.aActions.length - 1);
		oAction.setState(Action.STATE_IN_QUEUE);

	},

	getActionById : function(iId) {

		if(this.aActions[iId]) {
			return this.aActions[iId];
		}

	},

	process : function() {

		var sXml = '';

		for(var i = this.iLastProcessingCommandId; i < this.aActions.length; i++) {

			if(this.aActions[i].getState() == Action.STATE_IN_QUEUE) {

				sXml += this.aActions[i].getXml();

				this.aActions[i].setState(Action.STATE_PROCESSING);

				this.iLastProcessingCommandId = i;

			}

		}

		if(sXml == '') {
			return;
		}

		var sRequest = '<request>' + sXml + '</request>';

		var oAjaxHelper = new Ajax.Loader(
			this,
			this.sControllerUrl,
			'POST',
			{
				ajax : sRequest
			},
			{
				bIgnoreCache : true
			}
		);

		oAjaxHelper.send();

	},

	ajaxUpdate : function(oResponse) {
		var
			aResponseActions = oResponse.responseXML.getElementsByTagName('action'),
			oAction
			;

		for(var i = 0; i < aResponseActions.length; i++) {

			oAction = this.getActionById(aResponseActions[i].getAttribute('id'));

			if(oAction) {

				oAction.setState(parseInt(aResponseActions[i].getAttribute('status')));
				oAction.processResult(aResponseActions[i]);

			}

		}

	}

};