//
// Manages a dropdown for re-populating with Label/URI pairs.
// When an option is selected, the browser will load the corresponding uri. 
//
// initialize: function(id, optionsLabel) 
//	expects the id of a <select> tag and the text for the first nonfunctional option
//
// repopulate:
//	expects an array map of Label/URI pairs for populating the dropdown.
//
var DropdownJump = new Class({
    initialize: function(id, optionsLabel){
        this.selectElement = $(id);
	this.optionsLabel = optionsLabel;
	this.selectElement.setProperty('onchange', 'Javascript:Window.location.pathname = this.options[this.selectedIndex].value');
    },
    repopulate: function(options){
	var option = new Element('option');
	option.appendText(this.optionsLabel);
        this.selectElement.empty();
	option.injectInside(this.selectElement);
	$each(options, function(option, key, selectElement){
		option = new Element('option', {'value':option});
		option.appendText(key);
		option.injectInside(this);
	}, this.selectElement);
    }
});
