[- 
use Embperl::Form::Validate;
use File::Basename ;

$epf1 = new Embperl::Form::Validate([ -key => 'user_email', required => 1, 
                                     -key => 'user_password', 
                                        required => 1,
                                        length_min => 5],
                                   'login');

$epf2 = new Embperl::Form::Validate([ -key => 'user_email', required => 1],
                                   'newuser');


$r = shift 


-]
    <script>
    [+ do { local $escmode = 0 ; $epf1 -> get_script_code } +]
    [+ do { local $escmode = 0 ; $epf2 -> get_script_code } +]
    </script>


  [$ if not $udat{user_id}$]
    [$ if ($fdat{-newuser} || $dat{-newpassword}) && !$r -> {error}$]
    <p>[= loginnew =]</P>
    [$else$]
    <p>[= login1 =]</P>
    [$endif$]

    <form action="[+ $param[0] +]" method="POST" name="login" onSubmit="return epform_validate_login()">
        <table>
            <tr>
                <td class="cText">[= user_email =]</td>
                <td class="cInput"><input type="text" name="user_email"></td>
            </tr>
            <tr>
                <td class="cText">[= user_password =]</td>
                <td class="cInput"><input type="password" name="user_password"></td>
            </tr>
        </table>
        <p>
        <input type="submit" name="-login" value="[= login =]">
        [$ hidden $]
        </p>
    </form>

    <p>[= cookie_note =]</p>

    [$ if (!$fdat{-newuser} && !$dat{-newpassword}) ||$r -> {error} $]

    <hr>
    <P ALIGN="left">[= login2 =]</P>

    <P ALIGN="left">[= login3 =]</P>

    <form action="[+ $r -> app -> posturl('login.epl') +]" method="POST" name="newuser" onSubmit="return epform_validate_newuser()">
        <table>
            <tr>
                <td class="cText">[= user_email =]</td>
                <td class="cInput"><input type="text" name="user_email"></td>
            </tr>
        </table>
        <p>
        <input type="submit" name="-newuser" value="[= newuser =]">
        <input type="submit" name="-newpassword" value="[= newpassword =]">
        [$ hidden $]
        </p>
    </form>
    [$ endif $]
  [$ else $]
    <form action="[+ $param[0] +]" method="POST">
        <p>
        [= already_logged_in_as =] [+ $udat{user_email} +]
        [$ if $udat{user_admin} $]
        [Admin]
        [$ endif $]
        <p>
        [= logoff =]
        <p>
        <input type="submit" name="-logout" value="[= logout =]">
        [$ hidden $]
        </p>
    </form>
  [$ endif $]
