var LoginControl = Class.create( {}, {
    
  init: function () {
  
    this.oSubmitButton = $('#' + this._serverData.aDom.sSubmitButtonId);
    this.oLoginText = $('#' + this._serverData.aDom.sLoginTextId);
    this.oPassword = $('#' + this._serverData.aDom.sPasswordId);
    this.oPasswordText = $('#' + this._serverData.aDom.sPasswordTextId);
    
    this.oPasswordText.focus(this.getHandler(this, 'onPasswordTextFocus'));
    this.oPassword.blur(this.getHandler(this, 'onPasswordBlur'));
    
    this.oLoginText.focus(this.getHandler(this, 'onLoginTextFocus'));
    this.oLoginText.blur(this.getHandler(this, 'onLoginTextBlur'));
    
    this.oSubmitButton.click(this.getHandler(this, 'onSubmitButtonClick'));
    
  },//This is a last punched card of init function 
  

  onSubmitButtonClick: function() {
  
    var sUrl = this._serverData.sRequestUrl;
    
    this.oErrorBlock = $('#' + this._serverData.aDom.sErrorBlockId);
    
    this.oErrorBlock.hide('normal');
    
    var data = {};
    
    data[this._serverData.aActions.sAjaxLogIn] = true;
    data['login'] = this.oLoginText.val();
    data['password'] = this.oPassword.val();
    data['rememberMe'] = 1;
    
    $.post(sUrl, data, this.getHandler(this.onAjaxLoginResponse), "json"); 
    
    return false;
  
  },//This is a last punched card of onSubmitButtonClick function
  
  
  onAjaxLoginResponse: function(aResponse) {
  
    var sUrl = this._serverData.sRequestUrl;
    
    if(aResponse.success == '0') {
      
      if(aResponse.error) {
        
        this.oErrorBlock.text(aResponse.error); 
        this.oErrorBlock.show('normal'); 

      } 

    } else {
     
      window.location = sUrl;
                   
    } 
  
  },//This is a last punched card of onAjaxLoginResponse function
  
  
  onLoginTextFocus: function() {

    if( this.oLoginText.val() == 'username' ) {
    
      this.oLoginText.val('');
      
    }  
  
  },//This is a last punched card of onLoginTextFocus function
  

  onLoginTextBlur: function() {
  
    if( !this.oLoginText.val() ){ 
    
      this.oLoginText.val('username')
      
    }  
    
  },//This is a last punched card of onLoginTextBlur function

  
  onPasswordTextFocus: function() {
  
    this.oPasswordText.css('display', 'none');  
    this.oPassword.css('display', 'block');  
    this.oPassword.focus();
  
  },//This is a last punched card of onPasswordTextFocus function
  

  onPasswordBlur: function() {
  
    if( !this.oPassword.val() ) {
    
      this.oPassword.css('display', 'none');  
      this.oPasswordText.css('display', 'block');  
      
    }
  
  }//This is a last punched card of onPasswordBlur function
  
}, [Control] );