/*
	Themeplaty3 JavaScript interfész
	================================
*/

function Themeplaty3()
{
	this.vars = new Object;
	this.labels = new Object;
}

Themeplaty3.prototype.setVar = function (_name, _value)
{
	this.vars[_name] = _value;
}

Themeplaty3.prototype.setLabels = function (_labels)
{
	this.labels = _labels;
}

Themeplaty3.prototype.parse = function (_code)
{
	_code = _code.replace(/"/g, "\\\"");

	/* labels */
	_code = _code.replace(/{#((\w)+)}/g, "\"+ this.labels['label']['$1'] +\"");

	/* echo */
	_code = _code.replace(/{(\$((\w|\[|\]\')+))}/g, "\"+ this.vars['$2'] +\"");
	
	// Feldolgozás
	_code = eval("\"" + _code + "\"");

	return _code;
}

//
// DEPRECATED
// AJAX features
//
Themeplaty3.prototype.include = function (_path)
{
	var var_list = "&";

	for(var i in this.vars)
	{
		var_list += "vars[" + i + "]=" + escape(this.vars[i]) + "&";
	}

	return data_request("themeplaty_include", "path=" + _path + "&" + var_list);
}

Themeplaty3.prototype.load = function (_path)
{
	return data_request("themeplaty_import", "path=" + _path);
}
