var selectedIndexBeforeChange = 0;

function enableOption(option) {
    option.disabled = false;
    option.style.color = '#000000';
}

function disableOption(option) {
    option.disabled = true;
    option.style.color = '#a0a0a0';
}

function storeSelectedIndexBeforeChange(select) {
    selectedIndexBeforeChange = select.selectedIndex;
}

function unselectDisabledOption(select) {
    if (select.options[select.selectedIndex].disabled) {
        select.selectedIndex = selectedIndexBeforeChange;
    }
}

function getSelectedCsoId(select) {
    var id = select.options[select.selectedIndex].value;

    if(id == null || id == "") {
        id = select.options[selectedIndexBeforeChange].value;
    }

    if(id != null || id != "") {
        id = id.substring(id.lastIndexOf("-") + 1);
    }
    return id;
}
