sub reg
{
    my $sUserRegName = param('username');
    $sUserRegName = ($sUserRegName =~ /^(\w{3,10})$/) ? $1 : translate('insertname');
    $sUserRegName = lc $sUserRegName;
    my $email = param('email');
#     my %vars = (
#                 title  => 'reg',
#                 user   => 'guest',
#                 action => 'makeUser',
#                 file   => "$m_hrSettings->{cgi}{bin}/Content/reg.pl",
#                 sub    => 'make',
#                 right  => 0
#     );
#     my $qstring  = createSession(\%vars);
    my $register = translate('register');
#     my %parameter = (
#                      path   => $m_hrSettings->{cgi}{bin} . '/templates',
#                      style  => $m_sStyle,
#                      title  => $register,
#                      server => $m_hrSettings->{cgi}{serverName},
#                      id     => "reg$id",
#                      class  => 'reg',
#     );
#     my $window    = new HTML::Window(\%parameter);
    my $t_regtext = translate('t_regtext');
    print qq(<table  border="0" cellpadding="0" cellspacing="10" summary="contentLayout" width="100%"><tr><td valign="top" align="center">);
    print 
        br()
      . qq(
      <div align="center">$t_regtext<br/>
      <form onsubmit="submitForm(this,'makeUser','makeUser');return false;" method="get">
	<label for="username">Name</label><br/>
	<input type="text" name="username" id="username" title="Bitte geben Sie ihren Namen  ein." value="$sUserRegName" size="20" maxlength="10" alt="Login" align="left"/>
	<br/>
	<label for="email">Email</label><br/><input type="text" name="email" value="$email" id="email" size="20" maxlength="200" alt="email" align="left"/><br/>
	<input type="hidden" name="action" value="makeUser"/>
	<br/>
	<input type="submit"  name="submit" value="$register" size="15" alt="$register" align="left"/>
	</form>
	</div>);
    print '</td></tr></table>';
}

sub make
{

    my $fr           = 0;
#     my $fingerprint  = param('fingerprint');
    my $sUserRegName = param('username');
    my $email        = param('email');
    my $tlt          = translate('register');
#     my %parameter = (
#                      path   => $m_hrSettings->{cgi}{bin} . '/templates',
#                      style  => $m_sStyle,
#                      title  => $tlt,
#                      server => $m_hrSettings->{cgi}{serverName},
#                      id     => "reg$id",
#                      class  => 'reg',
#     );
#     my $window = new HTML::Window(\%parameter);
#     print br() . $window->windowHeader();
    SWITCH: {

        if (defined $sUserRegName) {
            if ($m_oDatabase->isMember($sUserRegName)) {
                print translate('userexits');
                $fr           = 1;
                $sUserRegName = undef;
            }
        } else {
            print translate('wrongusername');
            $fr = 1;
        }
#         if ($m_oDatabase->hasAcount($email)) {
#             print translate('haveacount');
#             $fr           = 1;
#             $sUserRegName = undef;
#         }else{
#                 print translate('else');
#             }
        unless (defined $email) {
            print translate('nomail');
            $fr = 1;
        }
        &reg() if ($fr);
        last SWITCH if ($fr);

        use Mail::Sendmail;
        my $pass = int(rand(1000) + 1) x 3;
        my %mail = (
                    To      => "$email",
                    From    => $m_hrSettings->{'admin'}{'email'},
                    subject => translate('mailsubject'),
                    Message => translate('regmessage') . translate('username') . ": $sUserRegName " . translate('password') . ":$pass"
        );
        sendmail(%mail) or warn $Mail::Sendmail::error;
#         $m_oDatabase->addUser($sUserRegName, $pass, $email);
        my $trlogin = translate('next');
        print 
qq(<div align="center" id="form"><form  action=""  target="_parent" method="post"  name="Login"  onSubmit="return checkLogin()"><label for="user">Name</label><br/>$sUserRegName<input type="hidden" id="user" name="user" value="$sUserRegName" size="18" maxlength="50" alt="Login" align="left"><br/><label for="password">Password</label><br/>$pass<input type="hidden" name="action" value="login"/><input type="hidden" id="password" name="pass" value ="$pass" size="18" maxlength="50" alt="password" align="left"/><br/><br/><input type="submit"  name="submit" value="$trlogin" size="15" maxlength="15" alt="submit" align="left"/></form><a  class="link" href="$link">$trreg</a></div>);
    }
#     clearSession();
#     print $window->windowFooter();
}
1;
