var SelectCountryAndCity = new Class( {

	Implements : [ Options, Events ],

	options : {
		elem_id : ''
	},

	initialize : function(element, options) {

		this.setOptions(options);

		this.element = element;

		this.addCity(this.getSelectOptions(this.element)[0], this
				.getSelectOptions(this.element)[1], document
				.id(this.options.elem_id));

	},

	getSelectOptions : function(elem) {
		return elem.getSelected()[0].value.split('|');
	},

	addCity : function(continent, country, update_el) {

		var city = locations[continent.replace(/_/g, ' ')][country.replace(
				/_/g, ' ')];

		update_el.empty();

		if (city.length === 0) {
			new Element('option', {
				text : '---',
				value : ''
			}).inject(update_el);
			return;
		}

		for ( var i = 0; i < city.length; i++) {
			new Element('option', {
				text : city[i],
				value : city[i].replace(/ /g, '_')
			}).inject(update_el);
		}
	}

});
