function ActionButton(
	oElement,	
	aStates,
	oLabelElement
	) {
	
	this.oElement = oElement;		
	this.oLabelElement = oLabelElement || oElement;
	this.aStates = aStates;		
	this.iState = 0;
	
	var oThis = this;
	
	this.fOuterHandler = function() {
		
		oThis.processClick();
		
	};
		
	this.enable();
	this.setState(0);
		
}

ActionButton.CLASS_NAME_ACTIVE   = 'button-active';
ActionButton.CLASS_NAME_DISABLED = 'button-disabled';

ActionButton.prototype = {
	
	getState : function(iState) {
		
		return this.iState;
		
	},
	
	setState : function(iState) {
		
		if(this.aStates[this.getState()].sClassName) {
			this.removeClass(this.aStates[this.getState()].sClassName);
		}
		
		if(this.aStates[iState].sClassName) {
			this.addClass(this.aStates[iState].sClassName);
		}
		
		if(this.aStates[iState].sLabel) {
			this.oLabelElement.innerHTML = this.aStates[iState].sLabel;
		}
		
		this.iState = iState;
		
	},
	
	getNextState : function() {
		
		if(this.getState() == this.aStates.length - 1) {
			return 0;
		}
		else {
			return this.getState() + 1;
		}
		
	},
	
	enable : function() {
		
		Common.Event.add(
			this.oElement,
			'click',
			this.fOuterHandler
			);
			
		this.removeClass(ActionButton.CLASS_NAME_DISABLED);
					
	},
	
	disable : function() {
		
		Common.Event.remove(
			this.oElement,
			'click',
			this.fOuterHandler
			);
			
		this.addClass(ActionButton.CLASS_NAME_DISABLED);
		
	},
	
	addClass : function(sClassName) {
		
		Common.Class.add(
			this.oElement,
			sClassName	
			);
		
	},
	
	removeClass : function(sClassName) {
		
		Common.Class.remove(
			this.oElement,
			sClassName
			);
		
	},
	
	processClick : function() {				
		
		if(this.aStates[this.getState()].fHandler) {			
			this.aStates[this.getState()].fHandler();
		}
		
		this.setState(this.getNextState());
		
	}
	
};