<?php $tabindex = 1 ?>
<?php if (isset($conf['utils']['spellchecker'])): ?>
<form action="<?php echo Horde::applicationUrl('spelling.php') ?>" method="post" name="spelling" target="impspelling">
<input type="hidden" name="message" value="" />
<input type="hidden" name="spell_lang" value="" />
</form>
<?php endif; ?>

<?php if ($prefs->getValue('auto_expand')): ?>
<iframe id="autoexpand" name="autoexpand" style="width:0px;height:0px;border-width:0px" src="<?php echo Horde::applicationUrl('expand.php') ?>"></iframe>
<?php endif; ?>

<form method="post" name="compose"<?php if ($imp['file_upload']) echo ' enctype="multipart/form-data"'; ?> action="<?php echo Horde::addParameter(Horde::url('compose.php'), 'uniq', md5(microtime())) ?>">
<?php if ($imp['file_upload']): ?>
<?php if ($browser->hasQuirk('broken_multipart_form')): ?>
<input type="hidden" name="msie_formdata_is_broken" value="" />
<?php endif; ?>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $imp['file_upload'] ?>" />
<?php endif; ?>
<?php Horde::pformInput() ?>
<input type="hidden" name="actionID" value="" />
<?php if (isset($messageCacheID)): ?>
<input type="hidden" name="messageCache" value="<?php echo $messageCacheID ?>" />
<?php endif; ?>
<input type="hidden" name="spellcheck" value="" />
<input type="hidden" name="index" value="<?php echo htmlspecialchars(Horde::getFormData('index')) ?>" />
<input type="hidden" name="page" value="<?php echo htmlspecialchars(Horde::getFormData('page')) ?>" />
<input type="hidden" name="start" value="<?php echo htmlspecialchars(Horde::getFormData('start')) ?>" />
<input type="hidden" name="popup" value="<?php echo htmlspecialchars(Horde::getFormData('popup')) ?>" />
<input type="hidden" name="thismailbox" value="<?php echo htmlspecialchars(Horde::getFormData('thismailbox')) ?>" />
<input type="hidden" name="attachmentAction" value="" />
<input type="hidden" name="reloaded" value="1" />
<?php if ($availRichtext): ?>
<input type="hidden" name="richtext" value="<?php echo $useRichtext ?>" />
<?php endif; ?>
<?php if ((Horde::getFormData('is_reply') == 1) || (($actionID == 'reply') || ($actionID == 'reply_all') || ($actionID == 'reply_list'))): ?>
<input type="hidden" name="is_reply" value="1" />
<input type="hidden" name="in_reply_to" value="<?php echo htmlspecialchars($header['inreplyto']) ?>" />
<input type="hidden" name="references" value="<?php echo htmlspecialchars($header['references']) ?>" />
<?php endif; ?>

<table border="0" width="100%" align="center" cellpadding="0" cellspacing="1">
  <tr class="header">
    <td colspan="2" class="header">
      <b>&nbsp;<?php echo htmlspecialchars($title) ?></b> - <?php echo strftime($conf['compose']['date_format']) ?>
    </td>
  </tr>
</table>

<br />
<?php IMP::status(); ?>

<table border="0" width="100%" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td>&nbsp;</td>
    <td>
      <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td nowrap="nowrap" align="left">
            <input name="submitBtn1" type="button" class="button" onclick="document.compose.actionID.value='send_message'; uniqSubmit();" value="<?php echo _("Send Message") ?>" />
<?php if ($conf['user']['allow_folders']): ?>
            <input name="submitBtn2" type="button" class="button" onclick="document.compose.actionID.value='save_draft'; uniqSubmit();" value="<?php echo _("Save Draft") ?>" />
<?php endif; ?>
            <input name="submitBtn3" type="button" class="button" onclick="confirmCancel();" value="<?php echo _("Cancel Message") ?>" />
          </td>
          <td align="right" style="padding:2px"><?php echo Help::link('imp', 'compose-buttons') ?>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
<?php if (!$prefs->isLocked('default_identity')): ?>
    <td class="light" valign="middle" align="right"><b><?php echo Horde::label('identity', _("Identity")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
        <tr>
          <td align="left">
            <input type="hidden" name="last_identity" value="<?php echo $identity->getDefault() ?>" />
            <select id="identity" name="identity" tabindex="<?php echo $tabindex++ ?>" onchange="change_identity(this.selectedIndex)">
<?php foreach ($select_list as $key => $select): ?>
              <option value="<?php echo $key ?>"<?php if ($key == $identity->getDefault()) echo ' selected="selected"' ?>><?php echo htmlspecialchars($select) ?></option>
<?php endforeach; ?>
            </select>
          </td>
<?php else: ?>
    <td class="light" align="right"><b><?php echo _("From") ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
        <tr>
<?php if (!$prefs->isLocked('from_addr')): ?>
          <td align="left"><input type="text" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="from" value="<?php echo htmlspecialchars($from) ?>" /></td>
<?php else: ?>
          <td align="left"><b>&nbsp;<?php echo htmlspecialchars($from) ?></b></td>
<?php endif; ?>
<?php endif; ?>
          <td align="right"><?php echo Help::link('imp', 'compose-from') ?>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td class="light" align="right" valign="middle"><b><?php echo Horde::label('to', _("To")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
<?php if (is_array($header['to'])): $first_to = true; ?>
<?php foreach ($header['to'] as $to_item): ?>
        <tr>
<?php if (count($to_item) > 1): ?>
          <td align="left">
            <table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="350">
                  <select id="to" tabindex="<?php echo $tabindex++ ?>" name="to_list[<?php echo htmlspecialchars($to_item[0]) ?>]" style="width:350px">
                    <option value="" selected="selected"><?php echo _("Please select or edit right next:") ?></option>
<?php for ($i = 1; $i < count($to_item); $i++): ?>
                    <option value="<?php echo htmlspecialchars($to_item[$i]) ?>"><?php echo htmlspecialchars($to_item[$i]) ?></option>
<?php endfor; ?>
                  </select>
                </td>
                <td width="150">
                  <input type="text" size="15" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="to_field[<?php echo htmlspecialchars($to_item[0]) ?>]" value="<?php echo htmlspecialchars($to_item[0]) ?>" style="width:150px" />
                </td>
              </tr>
            </table>
          </td>
<?php else: ?>
          <td align="left"><input type="text" id="to" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="to_field[]" value="<?php echo htmlspecialchars($to_item) ?>" /></td>
<?php endif; ?>
<?php if ($first_to): $first_to = false; ?>
          <td align="right"><?php echo Help::link('imp', 'compose-to') ?>&nbsp;</td>
<?php else: ?>
          <td>&nbsp;</td>
<?php endif; ?>
        </tr>
<?php endforeach; ?>
        <tr>
          <td align="left"><input type="text" id="to" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="to_new" /></td>
          <td>&nbsp;</td>
        </tr>
<?php else: ?>
        <tr>
          <td align="left"><input type="text" id="to" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="to" value="<?php echo htmlspecialchars($header['to']) ?>" <?php echo ($browser->hasFeature('iframes')) ? 'onchange="expandField(this)" /><span id="expandingto" style="color:red;visibility:hidden;">' . _("Expanding...") . '</span>' : '/>'; ?></td>
          <td align="right"><?php echo Help::link('imp', 'compose-to') ?>&nbsp;</td>
        </tr>
<?php endif; ?>
      </table>
    </td>
  </tr>

<?php if ($conf['compose']['allow_cc']): ?>
  <tr>
    <td class="light" align="right" valign="middle"><b><?php echo Horde::label('cc', _("Cc")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
<?php if (is_array($header['cc'])): $first_cc = true; ?>
<?php foreach ($header['cc'] as $cc_item): ?>
        <tr>
<?php if (count($cc_item) > 1): ?>
          <td align="left">
            <table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="350">
                  <select id="cc" tabindex="<?php echo $tabindex++ ?>" name="cc_list[<?php echo htmlspecialchars($cc_item[0]) ?>]" style="width:350px">
                    <option value="" selected="selected"><?php echo _("Please select or edit right next:") ?></option>
<?php for ($i = 1; $i < count($cc_item); $i++): ?>
                    <option value="<?php echo htmlspecialchars($cc_item[$i]) ?>"><?php echo htmlspecialchars($cc_item[$i]) ?></option>
<?php endfor; ?>
                  </select>
                </td>
                <td width="150">
                  <input type="text" size="15" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="cc_field[<?php echo htmlspecialchars($cc_item[0]) ?>]" value="<?php echo htmlspecialchars($cc_item[0]) ?>" style="width:150px" />
                </td>
              </tr>
            </table>
          </td>
<?php else: ?>
          <td align="left"><input type="text" id="cc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="cc_field[]" value="<?php echo htmlspecialchars($cc_item) ?>" /></td>
<?php endif; ?>
<?php if ($first_cc): $first_cc = false; ?>
          <td align="right"><?php echo Help::link('imp', 'compose-cc') ?>&nbsp;</td>
<?php else: ?>
          <td>&nbsp;</td>
<?php endif; ?>
        </tr>
<?php endforeach; ?>
        <tr>
          <td align="left"><input type="text" id="cc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="cc_new" /></td>
          <td>&nbsp;</td>
        </tr>
<?php else: ?>
        <tr>
          <td align="left"><input type="text" id="cc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="cc" value="<?php echo htmlspecialchars($header['cc']) ?>" <?php echo ($browser->hasFeature('iframes')) ? 'onchange="expandField(this)" /><span id="expandingcc" style="color:red;visibility:hidden;">' . _("Expanding...") . '</span>' : '/>' ?></td>
          <td align="right"><?php echo Help::link('imp', 'compose-cc') ?>&nbsp;</td>
        </tr>
<?php endif; ?>
      </table>
    </td>
  </tr>
<?php endif; ?>

<?php if ($conf['compose']['allow_bcc']): ?>
  <tr>
    <td class="light" align="right" valign="middle"><b><?php echo Horde::label('bcc', _("Bcc")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
<?php if (is_array($header['bcc'])): $first_bcc = true; ?>
<?php foreach ($header['bcc'] as $bcc_item): ?>
        <tr>
<?php if (count($bcc_item) > 1): ?>
          <td align="left">
            <table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="350">
                  <select id="bcc" tabindex="<?php echo $tabindex++ ?>" name="bcc_list[<?php echo htmlspecialchars($bcc_item[0]) ?>]" style="width:350px">
                    <option value="" selected="selected"><?php echo _("Please select or edit right next:") ?></option>
<?php for ($i = 1; $i < count($bcc_item); $i++): ?>
                    <option value="<?php echo htmlspecialchars($bcc_item[$i]) ?>"><?php echo htmlspecialchars($bcc_item[$i]) ?></option>
<?php endfor; ?>
                  </select>
                </td>
                <td width="150">
                  <input type="text" size="15" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="bcc_field[<?php echo htmlspecialchars($bcc_item[0]) ?>]" value="<?php echo htmlspecialchars($bcc_item[0]) ?>" style="width:150px" />
                </td>
              </tr>
            </table>
          </td>
<?php else: ?>
          <td align="left"><input type="text" id="bcc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="bcc_field[]" value="<?php echo htmlspecialchars($bcc_item) ?>" /></td>
<?php endif; ?>
<?php if ($first_bcc): $first_bcc = false; ?>
          <td align="right"><?php echo Help::link('imp', 'compose-bcc') ?>&nbsp;</td>
<?php else: ?>
          <td>&nbsp;</td>
<?php endif; ?>
        </tr>
<?php endforeach; ?>
        <tr>
          <td align="left"><input type="text" id="bcc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="bcc_new" /></td>
          <td>&nbsp;</td>
        </tr>
<?php else: ?>
        <tr>
          <td align="left"><input type="text" id="bcc" size="55" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="bcc" value="<?php if (empty($header['bcc']) && $prefs->getValue('self_bcc')) { echo htmlspecialchars($identity->getFromAddress()); } else {echo htmlspecialchars($header['bcc']); } ?>" <?php echo ($browser->hasFeature('iframes')) ? 'onchange="expandField(this)" /><span id="expandingbcc" style="color:red;visibility:hidden;">' . _("Expanding...") . '</span>' : '/>' ?></td>
          <td align="right"><?php echo Help::link('imp', 'compose-bcc') ?>&nbsp;</td>
        </tr>
<?php endif; ?>
      </table>
    </td>
  </tr>
<?php endif; ?>

  <tr>
    <td class="light" align="right" valign="middle"><b><?php echo Horde::label('subject', _("Subject")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
        <tr>
          <td align="left"><input type="text" id="subject" tabindex="<?php echo $tabindex++ ?>" class="fixed" name="subject" value="<?php echo htmlspecialchars($header['subject']) ?>" size="55" <?php if ($browser->isBrowser('msie')) echo 'onkeydown="subjectTab();" ' ?>/></td>
          <td align="right"><?php echo Help::link('imp', 'compose-subject') ?>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>

<?php
    $set_priority = $prefs->getValue('set_priority');
    $locked_charset = $prefs->isLocked('sending_charset');
?>
<?php if ($set_priority || !$locked_charset): ?>
  <tr>
    <td class="light" valign="middle" align="right"><b><?php echo ($locked_charset) ? Horde::label('priority', _("Priority")) : Horde::label('charset', _("Charset")) ?>&nbsp;</b></td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
        <tr>
<?php if (!$locked_charset): ?>
          <td>
            <select id="charset" name="charset" tabindex="<?php echo $tabindex++ ?>">
<?php foreach ($nls['encodings'] as $charset => $name): ?>
              <option value="<?php echo $charset ?>"<?php if (strtolower($charset) == strtolower($encoding)) echo ' selected="selected"'?>><?php echo $name ?></option>
<?php endforeach; ?>
            </select>
          </td>
<?php endif; ?>

<?php if ($set_priority): ?>
<?php $priority = substr(Horde::getFormData('x_priority', '3'), 0, 1); ?>
<?php if (!$locked_charset): ?>
          <td align="right" valign="middle"><?php echo Horde::label('priority', _("Priority")) ?>&nbsp;</td>
<?php endif; ?>
          <td align="left">
            <select id="priority" name="x_priority" tabindex="<?php echo $tabindex++ ?>">
              <option value="1 (Highest)"<?php if ($priority == '1)') echo ' selected="selected"' ?>>1 (<?php echo _("Highest") ?>)</option>
              <option value="2 (High)"<?php if ($priority == '2') echo ' selected="selected"' ?>>2 (<?php echo _("High") ?>)</option>
              <option value="3 (Normal)"<?php if ($priority == '3') echo ' selected="selected"' ?>>3 (<?php echo _("Normal") ?>)</option>
              <option value="4 (Low)"<?php if ($priority == '4') echo ' selected="selected"' ?>>4 (<?php echo _("Low") ?>)</option>
              <option value="5 (Lowest)"<?php if ($priority == '5') echo ' selected="selected"' ?>>5 (<?php echo _("Lowest") ?>)</option>
            </select>
          <td align="right"><?php echo Help::link('imp', 'compose-priority') ?>&nbsp;</td>
<?php endif; ?>

        </tr>
      </table>
    </td>
  </tr>
<?php endif; ?>

  <tr>
    <td class="light" align="right" valign="top"><b><?php echo _("Options") ?>&nbsp;</b></td>
    <td class="control">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            <table border="0" width="100%" cellspacing="1" cellpadding="0">
              <tr valign="middle">
<?php if ($registry->hasMethod('contacts/search')): ?>
<?php $contacts_url = Horde::applicationUrl('contacts.php'); ?>
                <?php echo Menu::createItem($contacts_url, _("Address Book"), 'addressbook-red.gif', NULL, 'contacts', 'window.open(\'' . $contacts_url . '\', \'contacts\', \'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=650,height=350,left=100,top=100\'); return false;', 'item', 'widget'); ?>
                <?php echo Menu::createItem('', _("Expand Names"), 'expand.gif', NULL, NULL, "document.compose.actionID.value='compose_expand_addr'; uniqSubmit(); return false;", 'item', 'widget'); ?>
<?php endif; ?>
<?php if (!empty($conf['utils']['spellchecker'])): ?>
                <?php echo Menu::createItem('', _("Spell Check"), 'spellcheck.gif', NULL, NULL, "document.compose.actionID.value='spell_check'; uniqSubmit(); return false;", 'item', 'widget'); ?>
<?php endif; ?>
<?php if ($conf['compose']['special_characters']): ?>
<?php $sc_url = $registry->getParam('webroot', 'horde') . '/util/special_characters.php'; ?>
                <?php echo Menu::createItem($sc_url, _("Special Characters"), 'keyboard.gif', $registry->getParam('graphics', 'horde'), 'characters', 'window.open(\'' . $sc_url . '\', \'chars\', \'height=220,width=400\'); return false;', 'item', 'widget'); ?>
<?php endif; ?>
<?php if ($imp['file_upload']): ?>
                <?php echo Menu::createItem('#attachments', _("Attachments"), 'manage_attachments.gif', NULL, NULL, NULL, 'item', 'widget'); ?>
<?php endif; ?>
              </tr>
            </table>
          </td>
          <td align="right" class="item" rowspan="2" valign="middle"><?php echo Help::link('imp', 'compose-options') ?>&nbsp;</td>
        </tr>
        <tr>
          <td>
            <table border="0" width="100%" cellspacing="1" cellpadding="0">
              <tr>
<?php
    if ($conf['user']['allow_folders'] && !$prefs->isLocked('save_sent_mail')):
?>
                <td valign="bottom" class="item" align="left">
                  <input id="ssm" type="checkbox" name="save_sent_mail"<?php if ($ssm_check) echo ' checked="checked"'; ?> />
                  <?php echo Horde::label('ssm', _("Save a copy in ")) ?>
<?php
    $sent_mail_folder = $identity->getSentmailFolder(null, Horde::getFormData('sent_mail_folder'));
    if ($conf['user']['select_sentmail_folder'] && !$prefs->isLocked('sent_mail_folder')) {
    $folders = IMP::flistSelect('', false, array('INBOX'), $sent_mail_folder);
    echo ' <select tabindex="' . $tabindex++ . '" name="sent_mail_folder">' . $folders . '</select>';
} else {
    if (!empty($sent_mail_folder)) {
        $sent_mail_folder = '&quot;' . IMP::displayFolder($sent_mail_folder) . '&quot;';
    }
    echo '<span id="sent_mail_folder">' . $sent_mail_folder . '</span></label>';
}
?>
                </td>
<?php endif; ?>
<?php
    $d_read = $prefs->getValue('disposition_request_read');
    $d_deliv = $prefs->getValue('disposition_request_delivery');
?>
<?php if ($conf['compose']['allow_receipts'] && (($d_read != 'never') || ($d_deliv != 'never'))): ?>
                <td valign="bottom" class="item" align="left">
                  <table border="0" cellspacing="0" cellpadding="0">
<?php if ($d_read != 'never'): ?>
                    <tr>
                      <td><input id="rrr" type="checkbox" name="request_read_receipt"<?php if (($d_read != 'ask') || (Horde::getFormData('request_read_receipt') == 'on')) echo ' checked="checked"'; ?> /></td>
                      <td><?php echo Horde::label('rrr', _("Request a Read Receipt")) ?></td>
                    </tr>
<?php endif; ?>
<?php if ($d_deliv != 'never'): ?>
                    <tr>
                      <td><input id="rdr" type="checkbox" name="request_delivery_confirmation"<?php if (($d_deliv != 'ask') || (Horde::getFormData('request_delivery_confirmation') == 'on')) echo ' checked="checked"'; ?> /></td>
                      <td><?php echo Horde::label('rdr', _("Request Delivery Confirmation")) ?></td>
                    </tr>
<?php endif; ?>
                  </table>
                </td>
<?php endif; ?>
              </tr>

<?php if ($availRichtext): ?>
              <tr>
                <td colspan="2">
                  <table border="0" width="100%" cellspacing="0" cellpadding="1">
                    <tr>
                      <td valign="middle" class="item" align="left" width="20px">
                        <?php Horde::pimg('compose.gif', _("Switch Composition Method"), 'align="middle"') ?>
                      </td>
                      <td valign="middle" class="item" align="left">
                        <?php Horde::plink('', _("Switch Composition Method"), '', '', 'document.compose.richtext.value=' . (($useRichtext) ? 0 : 1) . '; uniqSubmit(); return false;') ?>
                        <?php echo ($useRichtext) ? _("Switch to plain text composition") : _("Switch to HTML composition") ?></a>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
<?php endif; ?>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>
    <td class="item">
<?php if ($useRichtext): ?>
      <input type="hidden" name="messageHTML" />
      <textarea class="composebody" tabindex="<?php echo $tabindex++ ?>" name="message" rows="20" cols="<?php echo $prefs->getValue('wrap_width') ?>" style="display:none"><?php echo htmlspecialchars($msg) ?></textarea>
      <object name="editor" id="editor" style="background-color:buttonface" data="<?php echo $registry->getParam('webroot', 'horde') ?>/util/editor/designmode/editor.php" width="640" height="350" type="text/x-scriptlet" viewastext="viewastext"></object>
<?php else: ?>
      <textarea class="composebody" tabindex="<?php echo $tabindex++ ?>" name="message" rows="20" cols="<?php echo $prefs->getValue('wrap_width') ?>"><?php echo htmlspecialchars($msg) ?></textarea>
<?php endif; ?>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>
    <td>
      <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td nowrap="nowrap" align="left">
            <input name="submitBtn4" type="button" class="button" onclick="document.compose.actionID.value='send_message'; uniqSubmit();" value="<?php echo _("Send Message") ?>" />
<?php if ($conf['user']['allow_folders']): ?>
            <input name="submitBtn5" type="button" class="button" onclick="document.compose.actionID.value='save_draft'; uniqSubmit();" value="<?php echo _("Save Draft") ?>" />
<?php endif; ?>
            <input name="submitBtn6" type="button" class="button" onclick="confirmCancel();" value="<?php echo _("Cancel Message") ?>" />
          </td>
          <td align="right" style="padding:2px"><?php echo Help::link('imp', 'compose-buttons') ?></td>
        </tr>
<?php if ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime')): ?>
        <tr>
          <td class="item" nowrap="nowrap" align="left">
            &nbsp;<?php echo Horde::label('encrypt_options', _("Encryption Options")) ?>:&nbsp;
            <select id="encrypt_options" name="encrypt_options">
<?php
    $encryptOpt = Horde::getFormData('encrypt_options');
    require IMP_TEMPLATES . '/compose/encrypt_list.inc';
?>
            </select>
          </td>
          <td class="item" align="right"><?php echo Help::link('imp', 'compose-options-encrypt') ?>&nbsp;</td>
        </tr>
<?php if ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')): ?>
        <tr>
          <td class="item" nowrap="nowrap" align="left">
            <input id="pap" type="checkbox" name="pgp_attach_pubkey" <?php if (Horde::getFormData('pgp_attach_pubkey', $prefs->getValue('pgp_attach_pubkey'))) echo 'checked="checked" ' ?>/>
            <?php echo Horde::label('pap', _("Attach a copy of your PGP public key to your message?")) ?>
          </td>
          <td class="item" align="right"><?php echo Help::link('imp', 'pgp-compose-attach-pubkey') ?>&nbsp;</td>
        </tr>
<?php endif; ?>
<?php endif; ?>
      </table>
    </td>
  </tr>

<?php if ($imp['file_upload']): ?>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>

  <tr class="header">
    <td colspan="2" height="25" class="header">
      <b>&nbsp;<a name="attachments"></a><?php echo _("Attachments") ?></b>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>
    <td class="item" align="left">
      <table border="0" width="100%" cellpadding="0">
        <tr>
<?php if ($imp_compose->haveMaxAttachments()): ?>
          <td align="left" colspan="2">
            <?php echo _("Maximum number of attachments reached.") ?>
            <input type="hidden" name="submitBtn7" onclick="attach('add_attachment', 'add');" />
          </td>
<?php elseif (!$imp_compose->maxAttachmentSize()): ?>
          <td align="left" colspan="2">
            <?php echo _("Maximum total attachment size reached.") ?>
            <input type="hidden" name="submitBtn7" onclick="attach('add_attachment', 'add');" />
          </td>
<?php else: ?>
          <td align="left">
            <input name="<?php echo IMP_COMPOSE_UPLOAD ?>" tabindex="<?php echo $tabindex++ ?>" type="file" size="30" class="fixed" />&nbsp;
            <select name="file_disposition">
              <option value="attachment" selected="selected"><?php echo _("Attachment") ?></option>
              <option value="inline"><?php echo _("Inline") ?></option>
            </select>&nbsp;
            <input type="button" name="submitBtn7" class="button" onclick="attach('add_attachment', 'add');" value="<?php echo _("Attach") ?>" />
            <br />
            (<?php echo _("Maximum Attachment Size") . ': ' . number_format($imp_compose->maxAttachmentSize()) . ' ' . _("bytes") ?>)
          </td>
          <td align="right" valign="middle"><?php echo Help::link('imp', 'compose-attach') ?>&nbsp;</td>
<?php endif; ?>
        </tr>
      </table>
    </td>
  </tr>

<?php if ($imp_compose->numberOfAttachments()): ?>
  <tr>
    <td>&nbsp;</td>
    <td class="item">
      <table border="0" width="100%" cellpadding="0">
        <tr>
          <td align="left">
            <table class="item" border="0" cellpadding="1" cellspacing="2">
<?php
    $mime_contents = &new MIME_Contents(new MIME_Part());
    $localeinfo = NLS::getLocaleInfo();

    foreach ($imp_compose->getAttachments() as $file_num => $mime) {
        $file_num++;
        $disposition = $mime->getDisposition();
        $viewer = &$mime_contents->getMIMEViewer($mime);
        require IMP_TEMPLATES . '/compose/attachments.inc';
    }
?>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4" align="left"><b><?php echo _("Total Attachments Size:") ?></b> <?php echo number_format($imp_compose->sizeOfAttachments() / 1024, 2, $localeinfo['decimal_point'], '') ?> <?php echo _("KB") ?></th>
              </tr>
              <tr>
                <td colspan="4"><?php echo Horde::img('reload.gif', _("Refresh"), 'align="middle" hspace="2"') ?><a href="" onclick="attach('update_attachment', 'update'); return false;"><?php echo _("Update Attachment Information") ?></a></td>
              </tr>
            </table>
          </td>
          <td align="right" valign="top"><?php echo Help::link('imp', 'compose-attachments') ?>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
<?php endif; ?>
<?php endif; ?>

</table>
</form>

<?php if ($useRichtext): ?>
<script language="JavaScript" type="text/javascript" event="onload" for="window">
var _html = "<?php echo str_replace(array("\n", "\r"), array('\n', ''), addslashes(Horde::getFormData('messageHTML'))) ?>";
// Glue to populate the editor with the existing message text.
if (_html != "") {
    document.compose.editor.setHTML(_html);
} else {
    document.compose.editor.setText(document.compose.message.value);
}
</script>
<?php endif; ?>
