/****
 * Copyright (c) 2009 Christian Zenker <christian.zenker@599media.de>
 * MIT-style license
 ****/
var FiLocale = new Class({
	/**
	 * Constructor
	 * 
	 * @param {Array} The parent Element that holds the entry elements
	 */
	initialize: function(names, links, selectText) {
		if((names.length == links.length) && (names.length > 0)) {
			this.select = new Element('select', {'name': 'filocale[goto]', 'class': 'vendor'})
			this.select.adopt(new Element('option', {'value': '', 'text': selectText}));
			this.select.addEvents({'change': this.jumpToUrl.bindWithEvent(this)});
			
			names.each(function(name, i) {
				this.select.adopt(new Element('option', {'value': links[i], 'text': name}));
			}.bind(this));
			
			var form = new Element('form', {'method': 'get', 'action': '', 'class': 'vendor'}).adopt(this.select);
			$('filocale').erase('html');
			$('filocale').adopt('html', form);
			
		}
	},

	jumpToUrl: function() {
		var jumpUrl = this.select.options[this.select.selectedIndex].value;
		if(jumpUrl.length > 5) {
			window.location.href = jumpUrl;
		}
		
	}
}).implement(new Events);
