<script language="JavaScript" type="text/javascript">
<!--
function deleteCategory(id)
{
    document.prefs.managementActionID.value = <?php echo NAG_DELETE_CATEGORY ?>;
    document.prefs.category_id.value = id;
    document.prefs.submit();
}

function renameCategory(id)
{
    var name = window.prompt('<?php echo addslashes(_("Please enter a new name for this category:")) ?>\n', '');

    if (name != null && name != '') {
        document.prefs.managementActionID.value = <?php echo NAG_RENAME_CATEGORY ?>;
        document.prefs.category_name.value = name;
        document.prefs.category_id.value = id;
        document.prefs.submit();
    }
}

function addCategory()
{
    var name = window.prompt('<?php echo addslashes(_("Please enter a name for the new category:")) ?>\n', '');

    if (name != null && name != '') {
        document.prefs.managementActionID.value = <?php echo NAG_ADD_CATEGORY ?>;
        document.prefs.category_name.value = name;
        document.prefs.submit();
    }
}


//-->
</script>
<input name='managementActionID' value="" type="hidden" />
<input name='category_id' value="" type="hidden" />
<input name='category_name' value="" type="hidden" />
<table border="0">
<tr>
  <td colspan="2"><?php echo sprintf(_("Any tasks in a category that is deleted will become <b>%s</b>."), _("Unfiled")) ?><br/><br/></td>
</tr>

<?php
$categories = Nag::listCategories();
foreach ($categories as $key => $name):
?>
<tr>
  <td><b><?php echo $name ?></b></td>
  <td>
<?php if ($name != _("Unfiled")): ?>
    <a href='#' onclick="deleteCategory('<?php echo $key ?>'); return false;"><?php echo _("Delete") ?></a>&nbsp;|&nbsp;
    <a href='#' onclick="renameCategory('<?php echo $key ?>'); return false;"><?php echo _("Rename") ?></a>
<?php else: ?>
    <i><?php echo _("Cannot be changed.") ?></i>
<?php endif; ?>
  </td>
</tr>
<?php endforeach; ?>

<tr>
  <td>
    <b><a href='#' onclick="addCategory(); return false;"><?php echo _("Create a New Category") ?></a></b>
  </td>
  <td>&nbsp;</td>
</tr>

<tr>
  <td colspan="2"><br/><?php echo _("These changes can not be undone!") ?></td>
</tr>
</table>
