function getElement(id) {
    if (document.getElementById(id) != null) return document.getElementById(id);
    else if (document.all != null) return document.all[id];
    else if (document.layers != null) return document.layers[id];
    else return null;
}

function SetVisibility(id, show) {
    getElement(id).style.display = (show ? 'block': 'none');
}


function AddListOption(list, text, value) {
    var newOption = new Option(text, value);
    list.options[list.length] = newOption;
}

function DeleteListOption(list, index) { 
    if (list.length > 0) list.options[index] = null;
}

function MoveAllListOptions(listFrom, listTo) {
    for (var lup = listFrom.length - 1; lup >=0; lup--) listFrom.options[lup].selected = true;
    MoveListOptions(listFrom, listTo);
}

function MoveListOptions(listFrom, listTo) {
    var selectedText = new Array();
    var selectedValues = new Array();
    var selectedCount = 0;

    for (var lup = listFrom.length - 1; lup >=0; lup--) {
        if (listFrom.options[lup].selected) {
            selectedText[selectedCount] = listFrom.options[lup].text;
            selectedValues[selectedCount] = listFrom.options[lup].value;
            DeleteListOption(listFrom, lup);
            selectedCount++;
        }
    }
  
    for (var lup = selectedCount - 1; lup >= 0; lup--) {
        AddListOption(listTo, selectedText[lup], selectedValues[lup]);
    }
}
