<?
global $user , $lang;

if ( !\System::getSystemSettings( 'register' ) )
{
  ?>
    <div class="alert">
      <?=$lang -> getTrans( 'T_REJESTRACJA_ZAMKNIETA' );?>
    </div>
  <?
}
else
{
  ?>
  <div class="registration_form">
    <form method="POST" id="user_register" class="form_designer">
      <input type="hidden" name="check" value="<?\System::getSessionVar( 'token' );?>">
      <input type="hidden" name="action" value="user_registration">
      <table>
        <tr>
          <td colspan="2" id="r_login_check"></td>
        </tr>
        <tr>
          <th class="header right" style="padding: 0px 0px 10px;"><?=$lang -> getTrans( 'T_LOGIN' );?>:</th>
          <td class="row"><input type="text" name="r_login" id="r_login" onChange="checkRegisterForm( 'login' )"></td>
        </tr>
        <tr>
          <td colspan="2" id="r_password_check"></td>
        </tr>
        <tr>
          <th class="header right" style="padding: 0px 0px 10px;"><?=$lang -> getTrans( 'T_HASLO' );?>:</th>
          <td class="row"><input type="password" name="r_password" id="r_password" onChange="checkRegisterForm( 'password' )"></td>
        </tr>
        <tr>
          <th class="header right" style="padding: 0px 0px 10px;"><?=$lang -> getTrans( 'T_HASLO_POWTORZ' );?>:</th>
          <td class="row"><input type="password" name="r_password_re" id="r_password_re" onChange="checkRegisterForm( 'password' )"></td>
        </tr>
        <tr>
          <td colspan="2" id="r_email_check"></td>
        </tr>
        <tr>
          <th class="header right" style="padding: 0px 0px 10px;"><?=$lang -> getTrans( 'T_EMAIL' );?>:</th>
          <td class="row"><input type="text" name="r_email" id="r_email" onChange="checkRegisterForm( 'email' )"></td>
        </tr>
        <tr>
          <td></td>
          <td class="row center">
            <input type="button" value="<?=$lang -> getTrans( 'T_REJESTRUJ' );?>" onClick="registerUser()">
          </td>
        </tr>
      </table>
    </form>
  </div>
  <?
}
?>
<script type="text/javascript">
  var r_login     = false;
  var r_password  = false;
  var r_email     = false;
  function checkRegisterForm( param )
  {
    var value = $( '#r_' + param ).val();
    if ( param == 'password' )
      var value2 = $( '#r_' + param + '_re' ).val();
    $.prompt('<?=$lang -> getTrans( 'T_TRWA_SPRAWDZANIE' );?>');
    xajax_checkRegisterForm( param , value , value2 );
  }
  function registerUser()
  {
    if ( !r_login || !r_password || !r_email )
      $.prompt( '<?=$lang -> getTrans( 'T_BLEDY_REJESTRACJA_FORMULARZ' );?>' , { buttons: { <?=$lang -> getTrans( 'T_ZAMKNIJ' );?>: true }, focus: 1 });
    else
    {
      $.prompt('<?=$lang -> getTrans( 'T_TRWA_REJESTRACJA' );?>');
      xajax_registerUser( $( "#r_login" ).val() , $( "#r_password" ).val() , $( "#r_email" ).val() );
    }
  }
</script>