document.observe('dom:loaded', function() {
	var select_ort = $$('[name=ort]')[0];
	select_ort.observe('change', function(event) {
		change_options(Event.element(event).value);
	});
	
	if(typeof(Global.suborte_selected) != 'undefined') {
		change_options($$('[name=ort]')[0].value);
		//$$('option[value=' + Global.suborte_selected + ']')[0].selected = 'selected="selected"';
		var suborte = $$('option[value=' + Global.suborte_selected + ']')[0];
		suborte.selected = true;
	}
});

function change_options(top_id) {
	var select_suborte = $$('[name=ort_sub]')[0];
	select_suborte.innerHTML = '';
	Global.suborte.each(function(item) {
		if(top_id == item.top) {
			var option = Builder.node('option', { value: item.id }, [
				item.ort
			]);
			select_suborte.appendChild(option);
		}
	});
}
