 var oSajax = {
      debug_mode: false,
      request_type: "GET",
      uri: "",
      debug: function (text) {
          if (this.debug_mode) {
              alert("RSD: " + text)
          }
      },
      init: function () {
          this.debug("sajax_init_object() called..")
          var A;
          try {
              A=new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
              try {
                  A=new ActiveXObject("Microsoft.XMLHTTP");
              } catch (oc) {
                  A=null;
              }
          }
          if(!A && typeof XMLHttpRequest != "undefined") {
              A = new XMLHttpRequest();
          }
          if (!A) {
              this.debug("No se puede establecer conexión Ajax");
          }
          return A;
      },
      do_call: function () {
          var i, x, n;
          var post_data;
          var callback=null;
          var uri = this.uri;
          var al = arguments.length;
          var args=new Array();
          if(!al) {
              alert("Se requiere al menos un argumento");
          } else {
              func_name = arguments[0];
              if(al>1) {
                  callback=arguments[1];
                  for(i=2;i<al;i++) {
                      args.push(arguments[i]);
                  }
              }
  
          }
          if (this.request_type == "GET") {
              if (uri.indexOf("?") == -1) {
                  uri = uri + "?rs=" + escape(func_name);
              } else {
                  uri = uri + "&rs=" + escape(func_name);
              }
              for (i = 0; i < args.length; i++) {
                  uri = uri + "&rsargs[]=" + escape(args[i]);
              }
              uri = uri + "&rsrnd=" + new Date().getTime();
              post_data = null;
          } else {
              post_data = "rs=" + escape(func_name);
              for (i = 0; i < args.length; i++) {
                  post_data = post_data + "&rsargs[]=" + escape(args[i]);
              }
          }
          x = this.init();
          x.open(this.request_type, uri, true);
          if (this.request_type == "POST") {
              x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
              x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          }
          var self=this;
          x.onreadystatechange = function() {
              if (x.readyState != 4) {
                  return;
              }
              self.debug("received " + x.responseText);
              var status;
              var data;
              status = x.responseText.charAt(0);
              data = x.responseText.substring(2);
              if (status == "-") {
                  alert("Error: " + data);
              } else if(callback) {
                  callback(data);
              }
          }
          x.send(post_data);
          this.debug(func_name + " uri = " + uri + "/post = " + post_data);
          this.debug(func_name + " a la espera...");
          delete x;
      }
}
