<?php if (!$prefs->isLocked('sent_mail_folder')): ?>
<script language="JavaScript" type="text/javascript">
<!--

function newChoice_sent_mail_folder(val)
{
    if (val == "") {
        document.prefs.sent_mail.selectedIndex = 0;
        return;
    }
    val = "<?php echo IMP::preambleString() ?>" + val;
    var field = document.prefs.sent_mail;
    for (var i = 0; i < field.options.length; i++) {
        if (field.options[i].value == val) {
            field.selectedIndex = i;
            break;
        }
    }
}

function newFolderName()
{
    if (document.prefs.sent_mail.selectedIndex == 2) {
        var folder = window.prompt('<?php echo addslashes(_("Enter the name for your new sent mail folder")) ?>', document.prefs.sent_mail_new.value ? document.prefs.sent_mail_new.value : '');
        if (folder != '' && folder != null) {
            document.prefs.sent_mail_new.value = folder;
            document.prefs.sent_mail[2].text = '<?php echo addslashes(_("Create a new sent mail folder")) ?> [' + document.prefs.sent_mail_new.value + ']';
        }
    }

    if (document.prefs.sent_mail.selectedIndex == 0) {
        document.prefs.save_sent_mail.checked = 0;
    }
}

//-->
</script>

<?php echo Horde::label('sent_mail', _("Sent mail folder:")) ?><br />
<select name="sent_mail" id="sent_mail" onchange="newFolderName();">
  <option value=""><?php echo _("None") ?></option>
  <option value="-1" selected="selected"><?php echo _("Use Default Value") ?></option>
  <?php echo IMP::flistSelect(_("Create a new sent mail folder"), true, array('INBOX')) ?>
</select>
<input type="hidden" name="sent_mail_new" value="" />
<?php endif; ?>
