<script language="JavaScript" type="text/javascript">
<!--

function AnySelected()
{
    for (i = 0; i < document.contacts.elements.length; i++) {
        if (document.contacts.elements[i].checked) return true;
    }
    return false;
}

function ListUpdate() 
{
    key = document.targetList.listList[document.targetList.listList.selectedIndex].value
    document.contacts.targetList.value = key;

    if (key == "*new*") {
        var newList = window.prompt('<?php echo addslashes(_("You are creating a distribution list.")) . '\n' . addslashes(_("Please enter the name of the new list:")) ?>\n', '');
        if (newList != null && newList != '') {
            document.contacts.targetNew.value = 1;
            document.contacts.targetList.value = newList;
        }
    }
}


function Submit(actID)
{
    if (AnySelected()) {
        document.contacts.actionID.value = actID;
        document.contacts.submit();
    } else {
        window.alert('<?php echo addslashes(_("You must select at least one contact first.")) ?>');
    }
}

function Sort(col, direction)
{
    document.contacts.sortby.value = col;
    document.contacts.sortdir.value = direction;
    document.contacts.submit();
}

function SelectAll()
{
    state = document.select1.filter.options[document.select1.filter.selectedIndex].value;

    for (i = 0; i < document.contacts.elements.length; i++) {
        document.contacts.elements[i].checked = (parseInt(state) == 1);
    }

    document.select1.reset();
}

//-->
</script>
