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

<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>

<noscript>
</table></td></tr>
<tr>
    <td class="header" valign="middle">

        <table border="0" width="100%" cellpadding="0">
        <tr class="header">
            <td class="header">
                <input type="submit" name="edit" class="button" value="<?php echo _("Edit") ?>" />
                <input type="submit" name="delete" class="button" value="<?php echo _("Delete") ?>" />
            </td>
        </tr>
        </table>

    </td>
</tr>

<tr><td class="item"><table border="0">
</noscript>

<?php else: ?>
<input type="hidden" name="identity" value="<?php echo $to_edit ?>" />
<?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) . '" ' : '' ?>/><br />
<?php else: ?>
<input type="hidden" name="id" <?php echo isset($to_edit) ? 'value="' . $identity->getValue('id', $to_edit) . '" ' : '' ?>/><br />
<?php endif; ?>

<?php if (!$prefs->isLocked('fullname')): ?>
<?php echo _("Your full name:") ?><br />
<input name="fullname" size="30" maxlength="60" class="fixed" <?php echo isset($to_edit) ? '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 echo isset($to_edit) ? '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 echo isset($to_edit) ? 'value="' . $identity->getValue('replyto_addr', $to_edit) . '" ' : '' ?>/><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 echo isset($to_edit) ? $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 echo isset($to_edit) && $identity->getValue('sig_dashes', $to_edit) ? 'checked="checked" ' : '' ?>/>
<label for="sig_dashes"><?php echo _("Precede your signature with dashes ('-- ')") ?></label><br />
<?php endif; ?>

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

<?php if (!$prefs->isLocked('save_sent_mail')): ?>
<input type="checkbox" id="save_sent_mail" name="save_sent_mail" value="1" <?php echo isset($to_edit) && $identity->getValue('save_sent_mail', $to_edit) ? 'checked="checked" ' : '' ?>/>
<label for="save_sent_mail"><?php echo _("Save sent mail") ?></label><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 echo $identity->getValue('sent_mail_folder', $to_edit) == '' ? ' 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=<?php echo 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=<?php echo IDENT_DELETE ?>" value="<?php echo _("Delete") ?>" />&nbsp;');
</script>
<?php else: ?>
    <input type="submit" name="save" class="button" onclick="document.identities.actionID.value=<?php echo 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::applicationUrl('prefs.php?group=personal', true) ?>'" value="<?php echo _("Cancel") ?>" />
</td></tr></table>

</form>
