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

function Transfer(actID, form)
{
    if (form == 1) {
        document.messages.targetMbox.value = document.messages.target1.options[document.messages.target1.selectedIndex].value;
    } else {
        document.messages.targetMbox.value = document.messages.target2.options[document.messages.target2.selectedIndex].value;
    }

    // Check for a mailbox actually being selected.
    if (document.messages.targetMbox.value == '*new*') {
        var newFolder = window.prompt('<?php echo addslashes(_("You are copying/moving to a new folder.")) . '\n' . addslashes(_("Please enter a name for the new folder:")) ?>\n', '');
        if (newFolder != null && newFolder != '') {
            document.messages.newMbox.value = 1;
            document.messages.targetMbox.value = newFolder;
            document.messages.actionID.value = actID;
            document.messages.submit();
        }
    } else {
        if (document.messages.targetMbox.value == '') {
            window.alert('<?php echo addslashes(_("You must select a target mailbox first.")) ?>');
        } else {
            document.messages.actionID.value = actID;
            document.messages.submit();
        }
    }
}

function Submit(actID)
{
    document.messages.actionID.value = actID;
    document.messages.submit();
}

var V = 0;
function view(action, part, mime)
{
    param = "menubar=yes,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes";
    window.open('<?php echo str_replace('&amp;', '&', Horde::url('view.php?thismailbox=' . urlencode(IMP::getThisMailbox()) . '&index=' . $index)) ?>' + '&id=' + part + '&actionID=' + action + '&mime=' + mime, '<?php echo uniqid(rand()) . $index ?>' + tr(part), param);
    V++;
}

function tr(badval)
{
    retval = '';
    for (i = 0; i < badval.length; i++) {
        if (badval.charAt(i) == '.') {
            retval += '_';
        } else {
            retval += badval.charAt(i);
        }
    }
    return retval;
}

function updateFolders(form)
{
    if (form == 1) {
        document.messages.target2.selectedIndex = document.messages.target1.selectedIndex;
    } else {
        document.messages.target1.selectedIndex = document.messages.target2.selectedIndex;
    }
}

// -->
</script>
