function Action(name, callbackHandler) {
	this.name = name;
	this.callbackHandler = callbackHandler;
	
	this.result = null;
	this.parameters = new Object();
	
	EventBroadcaster.initialize(this);
	
	this.addListener(this);
	this.setParameter("random", Math.random());
	this.setParameter("ajax", true);
	this.setParameter("action", name);
}

Action.prototype.getName = function() {
	return this.name;
}

Action.prototype.setParameter = function(field, value) {
	this.parameters[field] = value;
	return this;
}

Action.prototype.getParameter = function(field) {
	return this.parameters[field];
}

Action.prototype.getResult = function() {
	return this.result;
}

Action.prototype.evaluateResult = function() {
	return evaluateJson(this.result);
}

Action.prototype.validate = function () {
	return true;
}

Action.prototype.populate = function () {
	
}

Action.prototype.execute = function () {
	if (this.validate()) {
		var self = this;

		$.post("_inc/ajax.php", this.parameters, function(message) {
			self.resultHandler(message);
		});
	} else {
		this.broadcastMessage("onValidationError", this);
	}
	return this;
}

Action.prototype.resultHandler = function (data) {
	this.result = data;
	this.broadcastMessage("onResult", this);
	
	if (this.callbackHandler[this.name] != null)
		this.callbackHandler[this.name](this);
	else
		alert("Undefined callback handler for " + this.name);
}

Action.prototype.onResult = function(thisAction) {
	//hideScreenLocker();
}


