var TemplatesStore = Class.create({
	initialize:function(templates, selectEltId){
		this.select = $(selectEltId);
		this.printTemplates = new Array;
		for(var i = 0;i<templates.getTemplatesCount(); i++) {
			var template = templates.getTemplate(i);
			this.printTemplates[i] = template;
			var option = document.createElement("option");
			option.innerHTML=template.getFriendlyName()+"("+template.getName()+")";
			option.value=template.getName();
			this.select.appendChild(option);
		}
	},
	getSelectedTemplate:function() {
		var idx = this.select.selectedIndex;
		var name = this.select[idx].value;
		var layer = this.getTemplate(name);
		return layer;
	},
	getTemplate:function(name){
		var t = this.printTemplates.find( function(template){
			return (template.getName() == name);
		});
		return t;
	}
});
