


function RunwayRequest(callback, id)
{
   this.result = null;
   this.callback = callback;   
   this.xmlRequest = new XmlRequest(this, id);
   this.responseType = null;
   this.id = id;
   this.params = new Array();
}

RunwayRequest.prototype.setParameter = function(name, value) {
   this.params[name] = value;
}

RunwayRequest.prototype.getParameter = function(name) {
   return this.params[name];
}

RunwayRequest.prototype.getId = function() {
   return this.id;
}

RunwayRequest.prototype.getAffectedCount = function() {
   try {
      var node = this.result.getElementsByTagName("affectedCount").item(0);
      return node.firstChild.data;
   }
   catch (e) {
      return "-1";
   }
}

RunwayRequest.prototype.getTag = function(tagname) {
   try {
      var node = this.result.getElementsByTagName(tagname).item(0);
      return node.firstChild.data;
   }
   catch (e) {
      return "-1";
   }
}

RunwayRequest.prototype.getTags = function(tagname) {
   try {
      var node = this.result.getElementsByTagName(tagname);
      return node;
   }
   catch (e) {
      return "-1";
   }
}

RunwayRequest.prototype.getRawText = function() {
   return this.result;
}

RunwayRequest.prototype.documentReady = function() {
   if (this.result == null) {
      if (this.responseType == "xml") {
         this.result = this.xmlRequest.getXMLDocument();
      }
      else {
         this.result = this.xmlRequest.getText();
      }
      this.callback(this);
   }
}

RunwayRequest.prototype.loadText = function(url) {
   this.responseType = "text";
   this.xmlRequest.send(url,null,true);
}

RunwayRequest.prototype.loadXML = function(url) {
   this.responseType = "xml";
   this.xmlRequest.send(url,null,true);
}

//both working in the IE and FF
RunwayRequest.prototype.getResultData = function(recordIndex, fieldName) {  
  try {
      var node =  this.result.getElementsByTagName("resultSet").item(0);
      var record = node.childNodes;
      
      for (i=0; i < record.length; i++) 
      {
         if ((record[i].nodeType != 3)&&(record[i].nodeType != 8) && recordIndex == record[i].getAttribute('id')) 
         {
            var field = record[i].childNodes;
            for(var j = 0; j < field.length; j++)
            {
               if ((field[j].nodeType != 3)&&(field[j].nodeType != 8) && fieldName == field[j].getAttribute('name'))
               {
                  return field[j].childNodes[0].data;
               }
            
            }
         } 
      }
      return "";
      
   } catch(e) {
      return "";
   }
}