window.addEvent('domready', function(){

	if (window.vars.templates) {
		var options = [];
		window.vars.templates.each(function(template) {
			options.push(new Element('option', {value: template, html: template, selected: window.vars.template == template ? 'selected' : ''}));
		});

		$$('body')[0].grab(
			new Element('div').setStyles({
				position: 'absolute',
				top: 0,
				right: 0,
				zIndex: 9999999
			}).grab(
				new Element('form',{method: 'post'}).grab(
					new Element('p').setStyle('margin', 0).grab(
						new Element('select',{name: 'change_template'}).adopt(options).addEvent('change',function(){
							this.getParent('form').submit();
						})
					)
				)
			)
		);
	}
});


