Deeplinking.Action = function() {
	this.param = null;
	this.params = {
		page: 0
	};
	this.parent = null;
	this.ajax = null;
};

Deeplinking.Action.prototype = {
	apply: function() {
		var parent = this;
		//var pageNum = parseInt(this.param.split("page")[1])-1;
		try {
			this.ajax.abort();
		} catch(e) {  }
		this.parent.container.addClass("spinner");
		this.fireAjax();
		/*this.ajax = $.getJSON(this.parent.url+"page-"+pageNum, function(request) {
			parent.parent.container.html(request.html).removeClass("spinner");
			$("body").trigger("paginator-count", [request.count, parent.parent.containerPrefix]);
		});*/
		/*this.ajax = this.parent.container.load(this.parent.url+"page-"+pageNum, function() {
			parent.parent.container.removeClass("spinner");
			$("body").trigger("paginator-count", [request.count, parent.parent.containerPrefix]);
		});*/
		paginator.recheckSelections(this.params.page);
	},
	
	fireAjax: function() {
		var parent = this;
		this.ajax = $.getJSON(this.parent.url, this.params, function(request) {
			parent.parent.container.html(request.html).removeClass("spinner");
			$("body").trigger("paginator-count", [request.count, parent.parent.containerPrefix, parent.params.page+1]);
		});
	},
	
	start: function(param, obj) {
		this.param = param;
		this.parent = obj;
		this.params.page = parseInt(this.param.split("page")[1])-1;
		this.apply();
	}
};
