<form method="post" name="identities" action="<?php echo Horde::applicationUrl('identities.php') ?>" onsubmit="return checkSubmit()">
<input type="hidden" name="actionID" <?php if ($prefs->isLocked('default_identity')) echo 'value="ident_save"'; ?>/>
<?php if ($prefs->isLocked('default_identity')): ?>
<input type="hidden" name="identity" value="<?php echo $to_edit ?>" />
<?php endif; ?>

<table border="0" align="center" width="100%" cellspacing="0" cellpadding="3">
  <tr>
    <td class="header" align="left"><b><?php echo _("Identities") ?></b></td>
  </tr>
  <tr>
    <td class="item">
      <table border="0">

<?php if (!$prefs->isLocked('default_identity')): ?>
        <tr valign="top">
          <td class="item">
            <?php echo _("Your identities:") ?><br />
            <select name="identity" class="fixed" onchange="javascript:newChoice()">
              <option value="-1"><?php echo _("Select an identity") ?></option>
<?php for ($i = 0; $i < count($identities); $i++): ?>
              <option value="<?php echo $i ?>"><?php echo $identities[$i] ?></option>
<?php endfor; ?>
            </select>
          </td>
        </tr>
      </table>
    </td>
  </tr>

  <noscript>
  <tr>
    <td valign="middle">
      <br />
      <input type="submit" name="edit" class="button" value="<?php echo _("Edit") ?>" />
      <input type="submit" name="delete" class="button" value="<?php echo _("Delete") ?>" />
      <br />&nbsp;
    </td>
  </tr>
  </noscript>

  <tr>
    <td class="item">
      <table border="0">
<?php endif; ?>

        <tr valign="top">
          <td class="item">
            <input type="hidden" name="edit_identity" value="<?php echo isset($to_edit) ? $to_edit : '' ?>" />
<?php if (!$prefs->isLocked('default_identity')): ?>
            <?php echo _("Identity's name:") ?><br />
            <input name="id" size="30" maxlength="60" class="fixed" <?php echo isset($to_edit) ? 'value="' . $identity->getValue('id', $to_edit) . '" ' : '' ?>/>
<?php else: ?>
            <input type="hidden" name="id" <?php if (isset($to_edit)) echo 'value="' . $identity->getValue('id', $to_edit) . '" '; ?>/>
<?php endif; ?>
            <br />

<?php if (!$prefs->isLocked('fullname')): ?>
            <?php echo _("Your full name:") ?><br />
            <input name="fullname" size="30" maxlength="60" class="fixed" <?php if (isset($to_edit)) echo 'value="' . $identity->getValue('fullname', $to_edit) . '" '; ?>/><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('from_addr')): ?>
            <?php echo _("Your From: address:") ?><br />
            <input name="from_addr" size="30" maxlength="60" class="fixed" <?php if (isset($to_edit)) echo 'value="' . $identity->getValue('from_addr', $to_edit) . '" '; ?>/><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('replyto_addr')): ?>
            <?php echo _("Your Reply-to: address: <i>(optional)</i>") ?><br />
            <input name="replyto_addr" size="30" maxlength="60" class="fixed" <?php if (isset($to_edit)) echo 'value="' . $identity->getValue('replyto_addr', $to_edit) . '" '; ?>/><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('alias_addr')): ?>
            <?php echo _("Your alias addresses: <i>(optional, enter each address on new line)</i>") ?><br />
            <textarea name="alias_addr" rows="3" cols="40" class="fixed"><?php if (isset($to_edit)) echo implode("\n", $identity->getValue('alias_addr', $to_edit)) ?></textarea><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('tieto_addr')): ?>
            <?php echo _("Addresses to explicitly tie to this identity: <i>(optional, enter each address on new line)</i>") ?><br />
            <textarea name="tieto_addr" rows="3" cols="40" class="fixed"><?php if (isset($to_edit)) echo implode("\n", $identity->getValue('tieto_addr', $to_edit)) ?></textarea><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('signature')): ?>
            <?php echo _("Your signature:") ?><br />
            <span class="fixed">
            <textarea wrap="hard" name="signature" rows="6" cols="<?php echo $prefs->getValue('wrap_width') ?>" class="fixed"><?php if (isset($to_edit)) echo $identity->getValue('signature', $to_edit); ?></textarea><br />
            </span>
<?php endif; ?>

<?php if (!$prefs->isLocked('sig_dashes')): ?>
            <input type="checkbox" id="sig_dashes" name="sig_dashes" value="1" <?php if (isset($to_edit) && $identity->getValue('sig_dashes', $to_edit)) echo 'checked="checked" '; ?>/>
            <?php echo Horde::label('sig_dashes', _("Precede your signature with dashes ('-- ')")) ?><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('sig_first')): ?>
            <input type="checkbox" id="sig_first" name="sig_first" value="1" <?php if (isset($to_edit) && $identity->getValue('sig_first', $to_edit)) echo 'checked="checked" '; ?>/>
            <?php echo Horde::label('sig_first', _("Place your signature before replies and forwards?")) ?><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('save_sent_mail')): ?>
            <input type="checkbox" id="save_sent_mail" name="save_sent_mail" value="1" <?php if (isset($to_edit) && $identity->getValue('save_sent_mail', $to_edit)) echo 'checked="checked" '; ?>/>
            <?php echo Horde::label('save_sent_mail', _("Save sent mail")) ?><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('sent_mail_folder')): ?>
            <?php echo _("Sent mail folder:") ?><br />
            <select name="sent_mail" onchange="newFolderName();">
              <option value=""<?php if ($identity->getValue('sent_mail_folder', $to_edit) == '') echo ' selected="selected"'; ?>><?php echo _("None") ?></option>
              <option value="-1"><?php echo _("Use Default Value") ?></option>
              <?php echo IMP::flistSelect(_("Create a new sent mail folder"), true, array('INBOX'), (isset($to_edit) && ($identity->getValue('sent_mail_folder', $to_edit) != '')) ? IMP::addPreambleString($identity->getValue('sent_mail_folder', $to_edit)) : null) ?>
            </select>
            <input type="hidden" name="sent_mail_new" value="" />
<?php endif; ?>

          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

<br />

<table border="0" align="center" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td nowrap="nowrap">
<?php if (!$prefs->isLocked('default_identity')): ?>
      <input type="submit" name="save" class="button" onclick="document.identities.actionID.value='ident_save';return true" value="<?php echo ($actionID == 'ident_edit') ? _("Change") : _("Create") ?>" />&nbsp;
      <script language="JavaScript" type="text/javascript">
        document.write('<input type="submit" name="delete" class="button" onclick="document.identities.actionID.value=\'ident_delete\';" value="<?php echo _("Delete") ?>" />&nbsp;');
      </script>
<?php else: ?>
      <input type="submit" name="save" class="button" onclick="document.identities.actionID.value='ident_save';return true" value="<?php echo _("Change") ?>" />&nbsp;
<?php endif; ?>
      <input type="submit" name="new" class="button" onclick="clearForm();document.identities.save.value='<?php echo _("Create") ?>';" value="<?php echo _("Reset") ?>" />&nbsp;
      <input type="submit" name="back" class="button" onclick="cancelSubmit=true;document.location.href='<?php echo Horde::addParameter(Horde::applicationUrl('prefs.php', true), 'group', 'personal') ?>'" value="<?php echo _("Return to Personal Information") ?>" />
    </td>
  </tr>
</table>

</form>
