/**
 * Classe: Mensage
 *         =======
 *
 *  Propriedades  *******************************
 *    theForm  =>
 *  Metodos Privados  ***************************
 *  Metodos Publicos  ***************************
 *    send      =>
 *    get       =>
 *    seek      =>
 *    _callback =>
 *    _getback  =>
 *    loaded    =>
 */
function Mensage()
{
  /**
   *  Propriedades ==========================================================
   */
  this.objTexto;

  /**
   *  Metodos  ==============================================================
   */
   
  /* metodo init  -------------------------------------------------------  */
  this.init = function(objTxt){
    this.objTexto = objTxt;
  };


  /* metodos send  ------------------------------------------------------  */
  this.send = function() {
    var text, callId;
    var objID = findDOM( 'txtSend', 0 );
    var text = objID.value;
    var callId = jsrsCall( "rpcServer.Studio.php",
                           "Mensage._callback",
                           "MsgServer.write",
                           text,
                           false);
  }// End


  /* metodo get  --------------------------------------------------------  */
  this.get = function() {
//alert('ok');  
    if (this.objTexto)
     {
      var callId = jsrsCall( "rpcServer.Studio.php",
                             "Mensage._callback",
                             "MsgServer.read",
                             "metodoGet"
                             ,false);
    }// End if (this.objTexto)
  }// End
  

  /* metodo validUser  --------------------------------------------------  */
  this.validUser = function(txt){
    var text, callId;
    text = txt;

    var callId = jsrsCall( "rpcServer.Studio.php",
                           "Mensage._returnUser",
                           "MsgServer.seek_user",
                           text,
                           false);
  }// End

  /* metodo returnUser  -------------------------------------------------  */
  this._returnUser = function(text, callId){
    var cmd = text.substr(0,1);
    var msg = text.substr(2);
    
    objID = findDOM('divMSG',0);
    
    if (cmd == '1')
    {
      userName = msg;
      objID.innerHTML="Usuário: " + msg;
      document.forms[0].submit();
    }else
    {
      objID.style.color="#FF0000";
      objID.innerHTML='Usuário ou Senha Inválido...';
    }
  }// End



  /* metodo seek  -------------------------------------------------------  */
  this.seek = function(){
    var text, callId;
    var objID = findDOM( 'e-mail', 0 );
    var text = objID.value;
    var callId = jsrsCall( "rpcServer.Studio.php",
                           "Mensage._getback",
                           "MsgServer.seek",
                           text,
                           false);
  }// End


  /* metodo _callback  --------------------------------------------------  */
  this._callback = function(text, callId) {
//alert('ok');  
    var objID = findDOM( 'boxTexto', 0 );
    objID.value = text;
    //this.boxTexto.value = text;
    setTimeout('Mensage.get()',2000);
  }// End

  /* metodo _getback  ---------------------------------------------------  */
  this._getback = function(text, callId) {
    alert(text);
  }// End


  /* metodo loaded  -----------------------------------------------------  */
  this.loaded = function(){
    var text, callId;
    var callId = jsrsCall( "rpcServer.Studio.php",
                           "Mensage._getback",
                           "MsgServer.loaded",
                           nameCore,
                           false);
  }// End


}// End function Mensage()


var Mensage = new Mensage(); // Pseudo static
Mensage.get();

