// simple Template engine class defenition
xtTemplate = function(config){	
	this.init(config)
}

xtTemplate.prototype = {		
	init: function(config){
	
		this.template 	= config.template.toString()
		this.tv			= config.tv
		
		// template vars separator
		this.SEPARATOR_LEFT		= '\\[\\['
		this.SEPARATOR_RIGHT	= '\\]\\]'
	},
	// parse template and get compiled html
	parse: function() {
		if(typeof this.template == 'string') {
			for(var variable in this.tv) {
				var re = new RegExp(this.SEPARATOR_LEFT + variable + this.SEPARATOR_RIGHT,'g')
				this.template = this.template.replace(re,this.tv[variable])
			}
			return this.template
		}
		else {
			return "Template error: invalid template type"
		}
	}
}
