<script language="JavaScript" type="text/javascript">
<!--
function setFocus()
{
    if (document.horde_login.horde_user.value == "") {
        document.horde_login.horde_user.focus();
    } else {
        document.horde_login.horde_pass.focus();
    }
}
function submit_login(e)
{
    if (typeof e != 'undefined' && !enter_key_trap(e)) {
        return;
    }

    if (document.horde_login.horde_user.value == "") {
        alert("<?php echo addslashes(_("Please provide your username and password")) ?>");
        document.horde_login.horde_user.focus();
        return false;
    } else if (document.horde_login.horde_pass.value == "") {
        alert("<?php echo addslashes(_("Please provide your username and password")) ?>");
        document.horde_login.horde_pass.focus();
        return false;
    } else {
        document.horde_login.loginButton.disabled = true;
<?php if (!empty($ie_clientcaps)): ?>
        try {
            document.horde_login.ie_version.value = objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}", "componentid");
        } catch (e) {
        }
<?php endif; ?>
        document.horde_login.submit();
        return true;
    }
}
//-->
</script>

<form name="horde_login" method="post" action="<?php echo Horde::selfUrl(false, true, false, true) ?>"<?php echo $conf['menu']['always'] ? ' target="_parent"' : '' ?>>
<input type="hidden" name="url" value="<?php echo Util::getFormData('url') ?>" />
<?php if (!empty($ie_clientcaps)): ?>
<input type="hidden" name="ie_version" value="" />
<?php endif; ?>

<div id="menu">
 <span style="float:right">
  <?php
  $menu = &new Menu(HORDE_MENU_MASK_NONE);
  echo $menu->render();
  ?>
 </span>
 <h1 style="text-align:center"><?php printf(_("Welcome to %s"), $registry->get('name')) ?></h1>
</div>

<br class="spacer" />
<?php $notification->notify(array('listeners' => 'status')) ?>

<table width="100%"><tr><td align="center"><table width="300" align="center">

<?php if (!empty($reason)): ?>
<tr>
  <td colspan="2" class="tooltip"><?php echo $reason ?></td>
</tr>
<?php endif; ?>

<tr>
    <td align="right" class="light"><b><?php echo _("Username") ?></b>&nbsp;</td>
    <td align="left"><input class="fixed" type="text" name="horde_user" value="<?php echo Util::getFormData('horde_user') ?>" /></td>
</tr>

<tr>
    <td align="right" class="light"><b><?php echo _("Password") ?></b>&nbsp;</td>
    <td align="left"><input class="fixed" type="password" name="horde_pass" value="" /></td>
</tr>

<?php if (!$prefs->isLocked('language')): ?>
<tr>
    <td align="right" class="light"><b><?php echo _("Language") ?></b></td>
    <td align="left" class="light"><?php echo $langs ?></td>
</tr>
<?php endif; ?>

<tr>
    <td>&nbsp;</td>
    <td class="light"><input name="loginButton" class="button" value="<?php echo _("Log in") ?>" type="submit" onclick="return submit_login();" /></td>
</tr>

<?php if ($conf['signup']['allow'] && $auth->hasCapability('add')): ?>
<tr>
    <td>&nbsp;</td>
    <td class="light"><?php echo Horde::link(Util::addParameter(Horde::url($registry->get('webroot', 'horde') . '/signup.php'), 'url', Util::getFormData('url')), _("Sign up if not registered"), 'light') . _("Sign up if not registered") ?></a></td>
</tr>
<?php endif; ?>
<?php if ($auth->hasCapability('resetpassword')): ?>
<tr>
    <td>&nbsp;</td>
    <td class="light"><?php echo Horde::link(Util::addParameter(Horde::url($registry->get('webroot', 'horde') . '/services/resetpassword.php'), 'url', Util::getFormData('url')), _("Forgot your password?"), 'light') . _("Forgot your password?") ?></a></td>
</tr>
<?php endif; ?>

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

<?php if (@is_readable(HORDE_BASE . '/config/motd.php')) require HORDE_BASE . '/config/motd.php'; ?>

<script language="JavaScript" type="text/javascript">
<!--
<?php if (!$prefs->isLocked('language')):
    $lang_url = Horde::applicationUrl('login.php', true);
    if (($url = Util::getFormData('url'))) {
        $lang_url = Util::addParameter($lang_url, 'url', $url, false);
    }
    $lang_url = Util::addParameter($lang_url, 'new_lang', '', false);
?>
function selectLang()
{
    // We need to reload the login page here, but only if the user
    // hasn't already entered a username and password.
    if (document.horde_login.horde_user.value == '' &&
        document.horde_login.horde_pass.value == '') {
        var lang_page = '<?php echo $lang_url ?>' + document.horde_login.new_lang[document.horde_login.new_lang.selectedIndex].value;
        self.location = lang_page;
    }
}
<?php endif; ?>

if (parent.frames.horde_main) {
    document.horde_login.target = '_parent';
}

// Set up the enter keytrap code.
if (typeof document.captureEvents != 'undefined') {
    document.captureEvents(Event.KEYPRESS);
    document.onkeypress = submit_login;
}
//-->
</script>
