<link rel="search" href="<?php echo Horde::applicationUrl('search.php') ?>" />

<?php if ($conf['user']['allow_folders'] && isset($menu_folders)): ?>
<form action="<?php echo Horde::applicationUrl("mailbox.php") ?>" method="get" name="menu">
<input type="hidden" name="newmail_popup" value="no" />
<?php endif; ?>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
    <td class="menu">

<table border="0" width="100%">
<tr>
<?php

/* IMP menu items */
Menu::printItem(Horde::applicationUrl('mailbox.php?mailbox=INBOX'), _("INBOX"), 'folders/inbox.gif');
if (($imp['base_protocol'] != 'pop3') && $prefs->getValue('use_trash') && $prefs->getValue('trash_folder') !== null) {
    Menu::printItem(Horde::applicationUrl('mailbox.php?thismailbox=' . urlencode(IMP::preambleString() . $prefs->getValue('trash_folder'))) . "&actionID=" . EMPTY_MAILBOX . '&return_url=' . urlencode(Horde::selfURL(true)), addslashes(_("Empty Trash")), 'empty_trash.gif', NULL, NULL, "return window.confirm('" . addslashes(_("Are you sure you wish to empty your trash folder?")) . "');");
}
Menu::printItem(IMP::composeLink(), _("Compose"), 'compose.gif');
if ($conf['user']['allow_folders']) {
    Menu::printItem(Horde::applicationUrl('folders.php'), _("Folders"), 'folders.gif');
}
if (($conf['prefs']['driver'] != '') && ($conf['prefs']['driver'] != 'none')) {
    Menu::printItem(Horde::applicationUrl('prefs.php'), _("Options"), 'prefs.gif', $registry->getParam('graphics', 'horde'));
}
Menu::printItem(Horde::applicationUrl('search.php'), _("Search"), 'search.gif');

/* Horde menu items */
if ($conf['problems']['enabled']) {
    include_once HORDE_BASE . '/lib/Identity.php';
    $prob_identity = new Identity();
    Menu::printItem(Horde::url($registry->getParam('webroot', 'horde') . '/problem.php?email=' . urlencode($prob_identity->getValue('from_addr')) . '&name=' . urlencode($prob_identity->getValue('fullname')) . '&return_url=' . urlencode(Horde::selfURL(true))), _("Problem?"), 'problem.gif', $registry->getParam('graphics', 'horde'));
}

/* Additional site-specific menu items */
if (!empty($additional_items)) echo $additional_items;

/* Online Help */
if ($conf['user']['online_help'] && $browser->hasFeature('javascript')) {
    Menu::printItem(Help::listLink('imp'), _("Help"), 'help.gif', $registry->getParam('graphics', 'horde'));
}

/* Links to other Horde applications. */
if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
    foreach ($conf['menu']['apps'] as $app) {
        Menu::printItem(Horde::url($registry->getInitialPage($app)),
                        $registry->getParam('name', $app), $registry->getParam('icon', $app), '');
    }
}

/* Logout */
if ($registry->getMethod('auth/logout') == 'imp' && empty($imp['direct_access'])) {
    Menu::printItem(Horde::url($registry->getParam('webroot', 'horde') . '/login.php?reason=logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'));
} else {
    Menu::printItem(Horde::applicationUrl('login.php?reason=logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'));
}

?>

<td width="100%">&nbsp;</td><!-- spacer -->

<?php if ($conf['user']['allow_folders'] && isset($menu_folders)): ?>
<td class="light" align="center" nowrap="nowrap" valign="<?php echo ($prefs->getValue('menu_view') == 'icon') ? 'middle' : 'bottom' ?>">
    <a class="menuitem" href="" onclick="folderSubmit(true); return false;" onmouseover="window.status='<?php echo _("Open Folder") ?>'; return true;" onmouseout="window.status=''; return true;">
<?php
if ($prefs->getValue('menu_view') == 'icon' || $prefs->getValue('menu_view') == 'both') {
    echo Horde::img('folders/folder_open.gif', 'alt="' . _("Open Folder") . '"');
    if ($prefs->getValue('menu_view') == 'both') {
        echo '<br />';
    }
}
if ($prefs->getValue('menu_view') != 'icon') {
    echo _("Open Folder");
}
?>
    </a>
</td>
<td class="light" align="right" nowrap="nowrap">
    <?php echo Horde::formInput() ?>
    <select name="mailbox" onchange="folderSubmit()"><?php echo $menu_folders ?></select>
</td>
<?php endif; ?>

</tr>
</table>

    </td>
</tr>
</table>
<?php if ($conf['user']['allow_folders'] && isset($menu_folders)): ?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
var loading;
function folderSubmit(clear)
{
    if (document.menu.mailbox[document.menu.mailbox.selectedIndex].value != '') {
        if (loading == null || clear != null) {
            loading = true;
            document.menu.submit();
        }
    }
}
// -->
</script>
<?php endif; ?>

<br />
