
/*
 * date: Wed Nov 25 21:01:57 EST 2009
 * copyright (c) 2009, Anton Yudin
 */

function MenuManager(fileName, source, value) {
	this.fileName = fileName;
	this.source = source;
	this.value = value;
	this.loadedHtml = null;
	this.selected = 0;


	this.handle = function(content) {
		this.loadedHtml = content;
	}

	this.get = function() {
		var result = this.load(this.fileName);
		return result.replace(source, value);
	}

	this.setup = function(name) {
		this.load(name);
		this.renderCategories();
		this.renderItems();
		this.renderSelectedItem();
		this.renderPager();
	}

	this.load = function(name) {
		ajax_load(
			name,
			'',
			this,
			'handle',
			'text/plain',
			true,
			'GET',
			'text/plain'
		);
		return this.loadedHtml;
	}

}


