function History() {
	this.pages = new Array();
	this.position = 0;
	this.enabled = enabled.history;
	this.lock = false;
}
History.prototype.clear = function() {
	this.pages = new Array();
}
History.prototype.disable = function() {
	this.enabled = false;
	this.clear();
}
History.prototype.show = function() {
	if (this.position > 0) {
		$('#ajax_history-back').show();
	} else {
		$('#ajax_history-back').hide();
	}
	if (this.pages.length - 1 - this.position > 0) {
		$('#ajax_history-forward').show();
	} else {
		$('#ajax_history-forward').hide();
	}
}
History.prototype.put = function(func,arr) {
	if (this.lock) {
		this.lock = false;
		return false;
	}
	if (!this.enabled) {
		return false;
	}
	if (this.pages.length == 0) {
		this.pages[0] = [ajax_go_restore,[self_path,false,false,false]];
	}
	this.pages[++(this.position)] = [func,arr];
	if (this.position + 1 < this.pages.length) {
		this.pages.splice(this.position + 1,this.pages.length - 1 - this.position);
	}
	this.show();
	return true;
}
History.prototype.goBack = function(offset) {
	return this.goTo(this.position - (offset || 1));
}
History.prototype.goForward = function(offset) {
	return this.goTo(this.position + (offset || 1));
}
History.prototype.goTo = function(offset) {
	if (!this.enabled) {
		return false;
	}
	this.lock = true;
	if (!offset) {
		offset = 0;
	}
	if ((this.pages.length > offset) && (offset>=0)) {
		this.position = offset;
		this.pages[offset][0](this.pages[offset][1]);
	}
	this.show();
	return false;
}
if (enabled.ajax && enabled.history) {
	var ajaxHistory = new History();
/*	$(function() {
		if (ajaxHistory.enabled) {
			$('body').append('<div id="history"><a href="#" onclick="return ajaxHistory.goBack();">&lt; go back</a></div>');
		}
	});
*/
}
