<?php
if (empty($FORMNAME))
    $FORMNAME = 'signin';
else
    $NOFORM = true;
?>
<?php if (empty($NOFORM)) { ?>
  <form method="post" action="<?php echo $request->getPostURL() ?>" accept-charset="UTF-8" name="<?php echo $FORMNAME?>">
  <?php echo HiddenInputs($request->getArgs(), false, array('auth')) ?>
<?php } ?>
<?php if ($user->isSignedIn()) {
  $SignOutB = $WikiTheme->makeButton(_("Sign Out"), "javascript:SignOut();", 'wikiaction');
?>
<span>
  <?php echo fmt("You are signed in as %s", WikiLink($user->getId(), 'auto')) ?>
  <?php echo $SEP?>
</span>
  <script type="text/javascript"><!--
    document.write('<input type="hidden" name="auth[logout]" value="0" />');
    function SignOut(form) { 
      var form = document.forms["<?php echo $FORMNAME?>"];
      form.elements["auth[logout]"].value = 1;
      form.submit();
    }
    document.write('<?php echo $SignOutB?>'); // -->
  </script>
  <noscript>
    <?php echo Button("submit:auth[logout]", _("Sign Out"), 'wikiaction') ?>
  </noscript>
<?php } else {
  $SignInInput = HTML::input(array('type' => 'text',
                                   'name' => "auth[userid]",
                                   'size' => 12,
                                   'maxlength' => 256,
                                   'onchange' => "SignIn(this.form);"));
  $SignInInput->addTooltip(_("Enter your UserId to sign in")) 
?>
  <script type="text/javascript"> <!--
    function SignIn(form) {
      <?php /* (comment out:)
      if (window.focus) {
        window.open('/EditingPolicy.html',<!-- url -->
                    'PleaseReadThisFirst',<!-- window name -->
                    'width=600,height=430,scrollbars=yes,resizable=yes,toolbar=yes');
      }
      */ ?>
      form.submit();
    }
    //-->
    document.write('&nbsp;<?php echo 
    _("Sign In")
    ?>');
  </script>
  <?php echo $SignInInput ?>
<?php } ?>
<?php if (empty($NOFORM)) { ?>
  </form>
<?php } ?>
