function get_tpl(tpl_selector) {
	var name_tpl_cache = 'tpl_cache_' + tpl_selector;
	if ('undefined' == typeof window[name_tpl_cache]) {
		var tpl=unescape($(tpl_selector).html())
					.replace(/<!--|&lt;!--|\/\*|!\*/g, "<!")
					.replace(/!-->|-->|!--&gt;|--&gt;|\*\/|\*!/g, "!>")
					.replace(/[\r\t\n]/g, " ")
					.replace(/\*+="/g, ' ')
					.replace(/(<!.*?!>)/g, function(){return arguments[0].replace(/&lt;/g, '<').replace(/&gt;/g, '>');})
					.split('<!').join("\r")
					.replace(/(?:^|!>)[^\r]*/g, function(){return arguments[0].replace(/'|\\/g, "\\$&").replace(/\n/g, "\\n");})
					.replace(/\r=(.*?)!>/g, "',$1,'")
					.split("\r").join("');")
					.split('!>').join("write.push('");
		window[name_tpl_cache] = new Function('json', "var write=[];with (json){write.push('"+tpl+"');}return write.join('');");
	}
	return window[name_tpl_cache];
}
jQuery.fn.extend({
	process_tpl: function(tpl_selector, json) {
		//console.debug(json);
		this.html(get_tpl(tpl_selector)(json));
	},
	append_tpl: function(tpl_selector, json) {
		this.append(get_tpl(tpl_selector)(json));
	}
});

