/**
 * Perform group action.
 */
function group_action(listname, list)
{
    switch (list.options[list.selectedIndex].value) {
        case listname + '_GROUPTOOL_SELECTALL':
            select_all(listname);
            list.selectedIndex = 0;
            break;
        case listname + '_GROUPTOOL_DESELECTALL':
            deselect_all(listname);
            list.selectedIndex = 0;
            break;
        default:
            var button = document.getElementById(listname + '_GROUPTOOL_DO');
            button.click();
    }
}

function page_switch_action(listname)
{
    var button = document.getElementById(listname + '_GOTO');
    button.click();
}

/**
 * Change selection mode of all visible list items.
 */
function change_select_all(listname)
{
    var checkBox = document.getElementById('LIST_' + listname + '_selector');
    if (checkBox.checked) select_all(listname);
    else deselect_all(listname);
}

/**
 * Select all visible list items.
 */
function select_all(listname)
{
    var checkBoxes = document.getElementsByName('LIST_' + listname + '_items[]');
    for (i = 0; i < checkBoxes.length; i++) {
        checkBoxes[i].checked = true;
    }
}

/**
 * Deselect all visible list items.
 */
function deselect_all(listname)
{
    var checkBoxes = document.getElementsByName('LIST_' + listname + '_items[]');
    for (i = 0; i < checkBoxes.length; i++) {
        checkBoxes[i].checked = false;
    }
}

/**
 * Highlight active item.
 */
function highlightOn(obj)
{
    obj.className += ' highlight';
}

/**
 * Highlight active item.
 */
function highlightOff(obj)
{
    var str = obj.className;
    str = str.replace(' highlight', '');
    str = str.replace('highlight', '');
    obj.className = str;
}