<form method="post" name="accounts" action="<?php echo Horde::applicationUrl('fetchmail.php') ?>" onsubmit="return checkSubmit()">
<input type="hidden" name="actionID" value="fetchmail_account_fetch"/>

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

<tr valign="top"><td class="item">
<?php echo _("Your accounts:") ?><br />
<select name="account" class="fixed" onchange="javascript:newChoice()">
    <option value="-1"><?php echo _("Select an account") ?></option>
<?php for ($i = 0; $i < count($accounts); $i++): ?>
    <option value="<?php echo $i ?>"><?php echo $accounts[$i] ?></option>
<?php endfor; ?>
</select>
</td></tr>

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

<tr valign="top"><td class="item">

<input type="hidden" name="edit_account" value="<?php echo !empty($to_edit) ? $to_edit : '' ?>" />
<?php echo _("Account's name:") ?><br />
<input name="id" size="30" maxlength="60" class="fixed" <?php echo !empty($to_edit) ? 'value="' . $account->getValue('id', $to_edit) . '" ' : '' ?>/><br />

<?php echo _("Protocol:") ?><br />
<select name="protocol">
<?php foreach ($protocols as $key => $val): ?>
    <option value="<?php echo $key?>"<?php echo (!empty($to_edit) && ($account->getValue('protocol', $to_edit) == $key)) ? ' selected="selected"' : '' ?>><?php echo $val ?></option>
<?php endforeach; ?>
</select><br />

<?php echo _("Server:") ?><br />
<input name="server" size="30" maxlength="60" class="fixed" <?php echo !empty($to_edit) ? 'value="' . $account->getValue('server', $to_edit) . '" ' : '' ?>/><br />

<?php echo _("Username:") ?><br />
<input name="username" size="30" maxlength="60" class="fixed" <?php echo !empty($to_edit) ? 'value="' . $account->getValue('username', $to_edit) . '" ' : '' ?>/><br />

<?php echo _("Password:") ?><br />
<input name="password" size="30" maxlength="60" class="fixed" type="password" <?php echo !empty($to_edit) ? 'value="' . $account->getValue('password', $to_edit) . '" ' : '' ?>/><br />

<?php if ($conf['user']['allow_folders']) { ?>
    <?php echo _("Remote Mailbox:") ?><br />
    <input name="rmailbox" size="30" maxlength="60" class="fixed" <?php echo !empty($to_edit) ? 'value="' . $account->getValue('rmailbox', $to_edit) . '" ' : '' ?>/><br />

    <?php echo _("Local Mailbox:") ?><br />
    <select name="lmailbox">
        <?php echo IMP::flistSelect('', false, array(), !empty($to_edit) ? $account->getValue('lmailbox', $to_edit) : '') ?>
    </select>
<?php } ?><br />

<input type="checkbox" name="onlynew" value="1" <?php echo (!empty($to_edit) && $account->getValue('onlynew', $to_edit)) ? 'checked="checked" ' : '' ?>/>
<?php echo _("Get only new messages (IMAP only)") ?><br />

<input type="checkbox" name="markseen" value="1" <?php echo (!empty($to_edit) && $account->getValue('markseen', $to_edit)) ? 'checked="checked" ' : '' ?>/>
<?php echo _("Mark messages as seen (IMAP only)") ?><br />

<input type="checkbox" name="del" value="1" <?php echo (!empty($to_edit) && $account->getValue('del', $to_edit)) ? 'checked="checked" ' : '' ?>/>
<?php echo _("Delete fetched messages from server") ?><br /><br />

<input type="hidden" name="loginfetch" />

<?php if ($conf['fetchmail']['show_account_colors']): ?>
<?php $colors = array('purple', 'lime', 'teal', 'blue', 'olive', 'fuchsia', 'navy', 'aqua'); ?>
<?php echo _('Color Indicator: '); ?><br />
<table>
    <tr>
        <td>&nbsp;&nbsp;</td>
<?php foreach ($colors as $color): ?>        
        <td bgcolor="<?php echo $color ?>">
            <input type="radio" name="acctcolor" value="<?php echo $color ?>" <?php echo (!empty($to_edit) && $account->getValue('acctcolor', $to_edit) == $color) ? 'selected="selected" ' : '' ?>/>
        </td>
<?php endforeach; ?>
    </tr>
</table>
<br />
<?php else: ?>
<input type="hidden" name="acctcolor" />
<?php endif; ?>

</td></tr></table></td></tr>
<tr>
    <td valign="middle">
        <table border="0" cellpadding="0"><tr>
            <td class="item">
                <input type="submit" name="fetch" class="button" onclick="document.accounts.actionID.value='fetchmail_account_fetch';return true" value="<?php echo _("Fetch")?>" />
                <input type="button" name="cancel" class="button" onclick="<?php echo $cancel_js?>" value="<?php echo _("Cancel") ?>" />
            </td>
        </tr>
        </table>

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

</td></tr>
<tr><td>
</td></tr>
<tr>
   <td class="item">
   <b><?php echo _("Status")?>:</b>
<?php if (is_a($result, 'PEAR_Error')): ?>
   <span id="stat"><?php echo $result->getMessage() ?></span>
<?php elseif (is_null($result)): ?>
   <span id="stat">&nbsp;</span>
<?php elseif ($result > 0): ?>
   <span id="stat"><?php echo sprintf(_("%s messages were fetched..."), $result) ?></span>
<?php else: ?>
   <span id="stat"><?php echo _("No messages to fetch...") ?></span>
<?php endif; ?>
   </td>
</tr>

</table>

</form>
