<script language="JavaScript" type="text/javascript">
<!--
function checkCategory() {
    if (document.memo.memo_category.value == '*new*') {
        var newCategory = window.prompt('<?php echo addslashes(_("You are creating a new category.")) . '\n' . addslashes(_("Please enter a name for the new category:")) ?>\n', '');
        if (newCategory != null && newCategory != '') {
            document.memo.new_category.value = newCategory;
        } else {
            window.alert("<?php echo addslashes(_("You must enter a new category name.")) ?>");
            return false;
        }
    } else if (document.memo.memo_category.value == '') {
        window.alert("<?php echo addslashes(_("You must select a category.")) ?>");
        return false;
    }
    return true;
}
//-->
</script>
<form method="post" name="memo" enctype="multipart/form-data" action="<?php echo Horde::selfURL() ?>">
<input type="hidden" name="actionID" value="<?php echo MNEMO_SAVE_MEMO ?>" />
<input type="hidden" name="memo" value="<?php echo $memo_id ?>" />
<input type="hidden" name="new_category" value="" />
<input type="hidden" name="memolist_original" value="<?php echo $memolist_id ?>" />
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr><td align="left" class="header"><b><?php echo $title ?></b></td></tr>
</table>

<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
    <td class="item" nowrap="nowrap" align="right" valign="top"><b><?php echo _("Note Text") ?>:</b>&nbsp;</td>
    <td class="item" width="100%">
        <textarea name="memo_body" cols="80" rows="20"><?php echo htmlspecialchars($memo_body) ?></textarea>
    </td>
</tr>
<?php if (!$prefs->isLocked('default_notepad') && count($notepads = Mnemo::listNotepads())): ?>
<tr>
    <td class="item" nowrap="nowrap" align="right" valign="top"><b><?php echo _("Notepad") ?>:</b>&nbsp;</td>
    <td class="item" width="100%">

    <select id="notepad_target" name="notepad_target">
    <?php
    foreach ($notepads as $id => $notepad) {
      if ($notepad->hasPermission(Auth::getAuth(), _PERMS_EDIT)) {
          $sel = ($id == $memolist_id) ? ' selected="selected"' : '';
          echo sprintf('<option value="%s"%s>%s</option>',
                $id, $sel, $notepad->getShareName()) . "\n";
      }
    } ?>
    </select>

    </td>
</tr>
<?php else: ?>
<input type="hidden" name="notepad_target" value="<?php echo htmlspecialchars(Auth::getAuth()) ?>" />
<?php endif; ?>
<tr>
    <td class="item" align="right" valign="top"><b><?php echo _("Category") ?>:</b>&nbsp;</td>
    <td class="item" width="100%">
        <?php echo Mnemo::buildCategoryWidget('memo_category', $memo_category, true) ?>
    </td>
</tr>
</table>

<br />
<table border="0" align="center" width="100%" cellspacing="0" cellpadding="0">
<tr>
    <td>
        <input type="submit" class="button" value="<?php echo _("Save Note") ?>" onclick="return checkCategory();" />&nbsp;
        <input type="reset" class="button" value="<?php echo _("Undo Changes") ?>" />
    </td>
</tr>
</table>
</form>
