//XMLParser.js
//Kitchen-sink parser for XML-RPC, GuiLib and Freeance Config
//If you just need XML-RPC parsing, use XMLRPC_Reply.js

function XMLParser(xmlResponseDoc)
{
  this.xmlDoc = xmlResponseDoc||null;   // XmlDocument
  if (this.xmlDoc == null)
  return (this);
};

XMLParser.prototype.setResponseByDoc = function(xmlResponseDoc)
{
  if (!xmlResponseDoc) return;
  this.xmlDoc = xmlResponseDoc;
};

XMLParser.prototype.setResponseByStr = function(XMLParserStr)
{
  if (!XMLParserStr) return;
  if (this.xmlDoc == null)
    this.xmlDoc = XmlDocument.create();
  this.xmlDoc.loadXML(XMLParserStr);
};

/**********************************************************
               Fault Response Functions
***********************************************************/

XMLParser.prototype.isFault = function()
{
  if (this.xmlDoc == null) return true;
  return (this.xmlDoc.getElementsByTagName("fault").length > 0);
};

XMLParser.prototype.getFaultCode = function()
{
  if (this.xmlDoc == null) return (-1);
  if (!this.isFault()) return (-1);
  var members = this.xmlDoc.getElementsByTagName("member");
  for (var lcv = 0;lcv < members.length; lcv++)
  {
    var nameElem = members[lcv].getElementsByTagName("name").item(0);
    if ((nameElem == null) || (nameElem.childNodes.length == 0))  // should never happen
      return (-1);
    var nameStrNode = nameElem.childNodes.item(0);  // grab the text node
    if (nameStrNode.nodeValue == 'faultCode')
    {
      var codeNode = members[lcv].getElementsByTagName("int").item(0);  // node holding the value
      if ((codeNode == null) || (codeNode.childNodes.length == 0)) // should never happen
        return (-1);
      return (codeNode.childNodes.item(0).nodeValue);
    }
  }
  return (-1);
};

XMLParser.prototype.getFaultString = function()
{
  if (this.xmlDoc == null) return ("");
  if (!this.isFault()) return ("");
  var members = this.xmlDoc.getElementsByTagName("member");
  for (var lcv = 0;lcv < members.length; lcv++)
  {
    var nameElem = members[lcv].getElementsByTagName("name").item(0);
    if ((nameElem == null) || (nameElem.childNodes.length == 0))  // should never happen
      return ("");
    var nameStrNode = nameElem.childNodes.item(0);  // grab the text node
    if (nameStrNode.nodeValue == 'faultString')
    {
      var codeNode = members[lcv].getElementsByTagName("string").item(0);  // node holding the value
      if ((codeNode == null) || (codeNode.childNodes.length == 0)) // should never happen
        return ("");
      return (codeNode.childNodes.item(0).nodeValue);
    }
  }
  return ("");
};

/**********************************************************
                      Main Parser
***********************************************************/

XMLParser.prototype.getObject = function()
{
  if (this.xmlDoc == null)
    return null;
  if (arguments.length > 0)
  {
    switch (arguments[0])
    {
      case 'guiDefinition':
        return (this.getObjectRecurse(this.xmlDoc.getElementsByTagName("widget_config").item(0)),arguments[1]);
        break;
      case 'mapConfig':
        return (this.parseMapConfig(this.xmlDoc.getElementsByTagName("map").item(0)));
        break;
      case 'templateConfig':
        return (this.parseTemplateConfig(this.xmlDoc.getElementsByTagName("templates").item(0)));
        break;
      case 'applicationConfig':
        return (this.parseApplicationConfig(this.xmlDoc.getElementsByTagName("applicationConfig").item(0)));
        break;
      case 'queryConfig':
        return (this.getObjectRecurse(this.xmlDoc.getElementsByTagName("queryConfig").item(0)));
        break;
      case 'emailConfig':
        return (this.parseEMailConfig(this.xmlDoc.getElementsByTagName(arguments[0]).item(0)));
      case 'measureConfig':
        return (this.parseMeasureConfig(this.xmlDoc.getElementsByTagName(arguments[0]).item(0)));
        break;
      case 'extensionConfig':
        return(this.parseExtensionConfig(this.xmlDoc.getElementsByTagName('extensionConfig').item(0)));
        break;
      default:
        return (this.getObjectRecurse(this.xmlDoc.getElementsByTagName("value").item(0)));
    }
  }
  else
    return (this.getObjectRecurse(this.xmlDoc.getElementsByTagName("value").item(0)));
};

XMLParser.prototype.getObjectRecurse = function(newNode)  //(theNode,<widgetParent|mapConfig>)
{
  var theNode = newNode;
  var i = 0;
  if (this.xmlDoc == null) return null;
    switch (theNode.nodeName)
    {
      case 'declarations':
        this.parseDeclarations(theNode);
        break;
      case 'controls':
        this.parseControls(theNode);
        break;
      case 'widget_definitions':
        this.parseWidget_definitions(theNode,arguments[1]);
        break;
      case 'guiWidget':
        this.parseGuiWidget(theNode,arguments[1]);
        break;
      case 'panel':
        this.parsePanel(theNode,arguments[1]);
        break;
      case 'tabPanel':
        this.parseTabPanel(theNode,arguments[1]);
        break;
      case 'imagePanel':
        this.parseImagePanel(theNode,arguments[1]);
        break;
      case 'button':
        this.parseButton(theNode,arguments[1]);
        break;
      case 'textButton':
        this.parseTextButton(theNode,arguments[1]);
        break;
      case 'imageButton':
        this.parseImageButton(theNode,arguments[1]);
        break;
      case 'toggleButton':
        this.parseToggleButton(theNode,arguments[1]);
        break;
      case 'radioButton':
        this.parseRadioButton(theNode,arguments[1]);
        break;
      case 'emailPanel':
        this.parseEMailPanel(theNode,arguments[1]);
        break;
      case 'mapPanel':
        this.parseMapPanel(theNode,arguments[1]);
        break;
      case 'vmapPanel':
        this.parseVmapPanel(theNode,arguments[1]);
        break;
      case 'layerPanel':
        this.parseLayerPanel(theNode,arguments[1]);
        break;
      case 'bufferPanel':
        this.parseBufferPanel(theNode,arguments[1]);
        break;
      case 'coordConvPanel':
        this.parseCoordConvPanel(theNode,arguments[1]);
        break;
      case 'emailConfig':
        this.parseEMailConfig(theNode,arguments[1]);
        break;
      case 'measurePanel':
        this.parseMeasurePanel(theNode,arguments[1]);
        break;
      case 'printManagerPanel':
        this.parsePrintManagerPanel(theNode,arguments[1]);
        break;
      case 'bookmarkPanel':
        this.parseBookmarkPanel(theNode,arguments[1]);
        break;
      case 'labelPanel':
        this.parseLabelPanel(theNode,arguments[1]);
        break;
      case 'labelIndex':
        this.parseLabelIndex(theNode,arguments[1]);
        break;
      case 'savedQueryIndex':
        this.parseSavedQueryIndex(theNode,arguments[1]);
        break;
      case 'loginPanel':
        this.parseLoginPanel(theNode,arguments[1]);
        break;
      case 'queryPanel':
        this.parseQueryPanel(theNode,arguments[1]);
        break;
      case 'selectionPanel':
        this.parseSelectionPanel(theNode,arguments[1]);
        break;
      case 'position':
        var positionData = new Array();
        positionData["left"] = this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"left")]);
        positionData["top"] = this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"top")]);
        positionData["zpos"] = this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"zpos")]);
        return positionData;
        break;
      case 'size':
        var sizeData = new Array();
        sizeData["width"] = this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"width")]);
        sizeData["height"] = this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"height")]);
        return sizeData;
        break;
      case 'left':
      case 'top':
      case 'zpos':
      case 'width':
      case 'height':
      case 'visibility':
      case 'style':
      case 'label':
      case 'imageName':
      case 'partOfExtension':
      case 'tooltip':
      case 'onTooltip':
      case 'offTooltip':
      case 'buttonState':
      case 'useRollover':
      case 'enableDrag':
      case 'groupName':
      case 'imageSource':
      case 'scaleImage':
      case 'orientation':
      case 'caption':
      case 'setActive':
      case 'useScroll':
      case 'pageType':
      case 'usePageControl':
      case 'color':
      case 'font':
      case 'fontSize':
      case 'valueFontSize':
      case 'cellSpacing':
        if (this.__helper__getNextElementNamedChildNode(theNode,0,"value")!= -1)
          return (this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"value")]));
        else
        {
          return null;
        }
        break;
      case 'childWidgets':
        for (i=0; i<theNode.childNodes.length; i++)
          this.getObjectRecurse(theNode.childNodes[i],arguments[1]);
        break;
      case 'widget_config':
        for (i=0; i<theNode.childNodes.length; i++)
          this.getObjectRecurse(theNode.childNodes[i]);
        break;
      case 'value':
        return(this.getObjectRecurse(theNode.childNodes[this.__helper__getNextElementChildNode(theNode,0)]));
        break;
      case 'definedValue':
        return (document.getGuiValueById(this.decodeSTRING(theNode)));
        break;
      case 'widgetAttribute':
        return this.parseWidgetAttributeValue(theNode);
        break;
      case 'activeTheme':
      case 'themeGroupMember':
      case 'resultTemplate':
      case 'fieldList':
      case 'themeName':
      case 'slaveType':
      case 'styleSheet':
      case 'resourceId':
      case 'mapId':
      case 'widgetId':
      case 'attributeName':
      case 'op':
      case 'string':
        return(this.decodeSTRING(theNode));
        break;
      case 'expression':
        return (this.parseExpression(theNode));
        break;
      case 'queryConfig':
        var queryConfig = new Object;
        queryConfig.queries = new Object;
        queryConfig.groups = new Object;
        for (var childIndex=this.__helper__getNextElementNamedChildNode(theNode,0,"definedQuery");childIndex!=-1;childIndex=this.__helper__getNextElementNamedChildNode(theNode,childIndex+1,"definedQuery"))
          queryConfig.queries[theNode.childNodes[childIndex].getAttribute("id")] = this.parseDefinedQuery(theNode.childNodes[childIndex]);
        for (var childIndex=this.__helper__getNextElementNamedChildNode(theNode,0,"queryGroup");childIndex!=-1;childIndex=this.__helper__getNextElementNamedChildNode(theNode,childIndex+1,"queryGroup"))
          queryConfig.groups[theNode.childNodes[childIndex].getAttribute("id")] = this.parseQueryGroup(theNode.childNodes[childIndex]);
        return queryConfig;
        break;
      case 'definedQuery':
        return (this.parseDefinedQuery(theNode));
        break;
      case 'queryGroup':
        return (this.parseQueryGroup(theNode));
        break;
      case 'tolerance':
      case 'maxSelect':
      case 'limit':
      case 'i4':
      case 'int':
        for (i=0; i<theNode.childNodes.length; i++)
          this.getObjectRecurse(theNode.childNodes[i]);
        return(this.decodeINT(theNode));
        break;
      case 'boolean':
        return(this.decodeBOOLEAN(theNode));
        break;
      case 'boundBoxPercentMin':
      case 'double':
        for (i=0; i<theNode.childNodes.length; i++)
          this.getObjectRecurse(theNode.childNodes[i]);
        return(this.decodeDOUBLE(theNode));
        break;
      case '#text':
      case '#comment':
        break;
      case 'dateTime.iso8601': return(this.decodeDATETIME(theNode)); break;
      case 'base64': return(this.decodeBASE64(theNode)); break;
      case 'array': return(this.decodeARRAY(theNode)); break;
      case 'struct': return(this.decodeSTRUCT(theNode)); break;
      default: alert('unknown node type: '+theNode.nodeName); break;
    }
};

/**********************************************************
              Generic data handling
***********************************************************/

XMLParser.prototype.decodeSTRING = function(theNode)
{
  if (theNode.childNodes.length > 0) // has textNode
    return (theNode.childNodes[0].nodeValue);
  else return ('');
};

XMLParser.prototype.decodeINT = function(theNode) // leaf node
{
  var theSTRING = this.decodeSTRING(theNode);
  return (parseInt(theSTRING,10));
};

XMLParser.prototype.decodeBOOLEAN = function(theNode)
{
  var theSTRING = this.decodeSTRING(theNode);
  return (parseInt(theSTRING) == 1);
};

XMLParser.prototype.decodeDOUBLE = function(theNode)
{
  var theSTRING = this.decodeSTRING(theNode);
  return (parseFloat(theSTRING));
};

XMLParser.prototype.decodeDATETIME = function(theNode) {};
XMLParser.prototype.decodeBASE64 = function(theNode) {};
XMLParser.prototype.decodeSTRUCT = function(theNode)
{
  var thisStruct = new Array();
  for (var lcv = 0; lcv < theNode.childNodes.length; lcv++)
  {
    var memberNode = theNode.childNodes[lcv];
    if (memberNode.nodeName == "member")
    {
      var valueNameNode = memberNode.getElementsByTagName("name").item(0);
      var valueNameStr = this.decodeSTRING(valueNameNode);
      thisStruct[valueNameStr] = this.getObjectRecurse(memberNode.getElementsByTagName("value").item(0));
    }
  }
  return (thisStruct);
};

XMLParser.prototype.decodeARRAY = function(theNode)
{
  var thisArray = new Array();
  var thisArrayPos = 0;

  var dataNode = theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"data")];
  var valueNodePos = 0;
  while (valueNodePos >= 0)
  {
    valueNodePos = this.__helper__getNextElementNamedChildNode(dataNode,valueNodePos,"value");
    if (valueNodePos >= 0)
    {
      var valueNode = dataNode.childNodes[valueNodePos];
      thisArray[thisArrayPos] = this.getObjectRecurse(valueNode.firstChild);
      thisArrayPos++;
    }
    if (valueNodePos >= 0) valueNodePos++;
  }
  return (thisArray);
};

XMLParser.prototype.parseExpression = function(expressionNode)
{
  var value1Index = this.__helper__getNextElementNamedChildNode(expressionNode,0,"value");
  var value2Index = this.__helper__getNextElementNamedChildNode(expressionNode,value1Index+1,"value");
  var operatorIndex = this.__helper__getNextElementNamedChildNode(expressionNode,0,"op");
  var value1 = this.getObjectRecurse(expressionNode.childNodes[value1Index]);
  var value2 = this.getObjectRecurse(expressionNode.childNodes[value2Index]);
  var operator = this.getObjectRecurse(expressionNode.childNodes[operatorIndex]);
  var returnValue = 0;
  switch (operator)
  {
    case 'add':
      returnValue = value1+value2;
      break;
    case 'subtract':
    case 'sub':
      returnValue = value1-value2;
      break;
    case 'multiply':
    case 'mpy':
      returnValue = value1*value2;
      break;
    case 'divide':
    case 'div':
      returnValue = value1/value2;
      break;
    default:
      alert("Unknown operator in expression: \""+operator+"\"");
      returnValue = null;
      break;
  }
  return returnValue;
};

/**********************************************************
                  Helper Functions
***********************************************************/

XMLParser.prototype.__helper__getNextElementChildNode = function(aNode,firstpos)
{
  var foundpos = -1;
  for (var lcv=firstpos;(lcv < aNode.childNodes.length) && (foundpos == -1); lcv++)
    if (aNode.childNodes[lcv].nodeType == 1)
      foundpos = lcv;
  return (foundpos);
};

XMLParser.prototype.__helper__getNextElementNamedChildNode = function(aNode,firstpos,nodeName)
{
  for (var lcv=firstpos;lcv < aNode.childNodes.length; lcv++)
    if ((aNode.childNodes[lcv].nodeType == 1) && (aNode.childNodes[lcv].nodeName == nodeName))
      return(lcv);
  return (-1);
};
XMLParser.prototype.__helper__getRemainingNextElementNamedChildNodes = function(aNode,firstpos,nodeName)
{
  var nodeCollection = new Array();
  for (var lcv=firstpos;lcv < aNode.childNodes.length; lcv++)
    if ((aNode.childNodes[lcv].nodeType == 1) && (aNode.childNodes[lcv].nodeName == nodeName))
      nodeCollection[nodeCollection.length] = aNode.childNodes[lcv];
  return (nodeCollection);
};


/**********************************************************
                 GUI Parser Functions
***********************************************************/
XMLParser.prototype.parseDeclarations = function(declarationNode)
{
  var childNodeIndex = 0;
  for (childNodeIndex=this.__helper__getNextElementNamedChildNode(declarationNode,0,"value");childNodeIndex!=-1;childNodeIndex=this.__helper__getNextElementNamedChildNode(declarationNode,childNodeIndex+1,"value"))
  {
    if ((declarationNode.childNodes[childNodeIndex].getAttribute("id")!= null))
      OBJECT_MANAGER.setGuiValue(declarationNode.childNodes[childNodeIndex].getAttribute("id"), this.getObjectRecurse(declarationNode.childNodes[childNodeIndex]));
  }
};

XMLParser.prototype.parseControls = function(controlNode)
{
  var childNodeIndex = 0;
  for (childNodeIndex=this.__helper__getNextElementChildNode(controlNode,0);childNodeIndex!=-1;childNodeIndex=this.__helper__getNextElementChildNode(controlNode,childNodeIndex+1))
  {
    var currentNode = controlNode.childNodes[childNodeIndex];
    if ((currentNode.getAttribute("id")!= null))
    {
      switch (currentNode.nodeName)
      {
        case 'radioButtonGroup':
          var newControl = new RadioButtonGroup(currentNode.getAttribute("id"));
          break;
        case 'map':
          var newControl = new Map(currentNode.getAttribute("id"),null);
          break;
        case 'labelControl':
          if ((OBJECT_MANAGER.getGuiValueById('extensions')) && (OBJECT_MANAGER.getGuiValueById('extensions')['markup']))
            if(OBJECT_MANAGER.getGuiValueById('extensions')['markup'].enabled)
            {
              var newMapId = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(controlNode.childNodes[childNodeIndex],0,"mapId")]);
              var newControl = new LabelControl(currentNode.getAttribute("id"),null, newMapId);
            }
          break;
        case 'queryControl':
          var queryList = new Object;
          if (this.__helper__getNextElementNamedChildNode(currentNode,0,"queryGroup")!= -1)
          {
            var queryGroupId = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"queryGroup")]);
          }
          else
            var queryGroupId = null;
          var newResultTarget = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(controlNode.childNodes[childNodeIndex],0,"resultTarget")]);
          var newLoadImage = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(controlNode.childNodes[childNodeIndex],0,"loadImage")]);
          var newControl = new QueryControl(currentNode.getAttribute("id"), queryGroupId, null, newResultTarget, newLoadImage);
          break;
        case 'selectionControl':
          var newMapId = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(controlNode.childNodes[childNodeIndex],0,"mapId")]);
          var newControl = new SelectionControl(currentNode.getAttribute("id"),null,newMapId);
          break;
        default:
          alert("Unknown Control:  \""+controlNode.childNodes[childNodeIndex].nodeName+"\"");
      }
    }
  }
};

XMLParser.prototype.parseWidget_definitions = function(definitionNode, newParent)
{
  var childNodeIndex = 0;
  for (var i=0; i<definitionNode.childNodes.length; i++)
    this.getObjectRecurse(definitionNode.childNodes[i],newParent);  //process document level guiWidgets
};

XMLParser.prototype.parseGuiWidget = function(widgetNode, parentWidget)
{
  var childNodeIndex = 0;
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  var newWidget = new GuiWidget(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["style"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")!=-1)
    this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")],newWidget);
};

XMLParser.prototype.parseButton = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  var newWidget = new Button(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["style"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")!=-1)
    this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")],newWidget);
};

XMLParser.prototype.parseTextButton = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseTextButtonAttributes(widgetNode, parentWidget);
  var newWidget = new TextButton(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["label"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")!=-1)
    this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")],newWidget);
};

XMLParser.prototype.parsePanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parsePanelAttributes(widgetNode, parentWidget);
  var newWidget = new Panel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["style"],  attributeArray["drag"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")!=-1)
    this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")],newWidget);
  return;
};

XMLParser.prototype.parseTabPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseTabPanelAttributes(widgetNode, parentWidget);
  var newTabPanel = new TabPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["orientation"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"tabWidgets")!=-1)
  {
    var activeTabIndex = -1;
    var tabCount = 0;
    var tabWidgetsNode = widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"tabWidgets")];
    for (var tabNodeIndex=this.__helper__getNextElementNamedChildNode(tabWidgetsNode,0,"tab");tabNodeIndex!=-1;tabNodeIndex=this.__helper__getNextElementNamedChildNode(tabWidgetsNode,tabNodeIndex+1,"tab"))
    {
      var tabNode = tabWidgetsNode.childNodes[tabNodeIndex];
      var tabAttributes = new Array();
      if (tabNode.getAttribute("id") != null)
        tabAttributes["id"] = tabNode.getAttribute("id");
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"caption")!=-1)
        tabAttributes["caption"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"caption")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"setActive")!=-1)
        tabAttributes["setActive"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"setActive")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"useScroll")!=-1)
        tabAttributes["useScroll"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"useScroll")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"pageType")!=-1)
        tabAttributes["pageType"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"pageType")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"usePageControl")!=-1)
        tabAttributes["usePageControl"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"usePageControl")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"imageName")!=-1)
        tabAttributes["imageName"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"imageName")]);
      if (this.__helper__getNextElementNamedChildNode(tabNode,0,"partOfExtension")!=-1)
        tabAttributes["partOfExtension"] = this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"partOfExtension")]);
      
      var okToLoad = true;
      if (tabAttributes["partOfExtension"])
      {
        if (!OBJECT_MANAGER.getGuiValueById('extensions')[tabAttributes["partOfExtension"]])
          okToLoad = false;
        else
          if (!OBJECT_MANAGER.getGuiValueById('extensions')[tabAttributes["partOfExtension"]].enabled)
            okToLoad = false;
      }
      if (okToLoad)
      {
        if (tabAttributes["setActive"])
          activeTabIndex = tabCount;
        var newTab = newTabPanel.addTab(tabAttributes["id"],tabAttributes["caption"],tabAttributes["setActive"],tabAttributes["useScroll"],tabAttributes["pageType"],tabAttributes["usePageControl"],tabAttributes["imageName"]);
        if (this.__helper__getNextElementNamedChildNode(tabNode,0,"childWidgets")!=-1)
        {
          var fakeContentWidget = new Object();
          fakeContentWidget.element = newTab.page.content;
          this.getObjectRecurse(tabNode.childNodes[this.__helper__getNextElementNamedChildNode(tabNode,0,"childWidgets")],fakeContentWidget);
        }
        tabCount++;
      }
    }
    if (activeTabIndex == -1)  // must have either been forgotten or only setActive's have not been enabled.  set first tab.
      newTabPanel.setActiveTab(newTabPanel.firstTab);
  }
};

XMLParser.prototype.parseImagePanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseImagePanelAttributes(widgetNode, parentWidget);
  var newWidget = new ImagePanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["imageSource"],  attributeArray["scaleImage"],attributeArray["imageWidth"],attributeArray["imageHeight"]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")!=-1)
    this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"childWidgets")],newWidget);
};

XMLParser.prototype.parseImageButton = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseImageButtonAttributes(widgetNode, parentWidget);
  var newWidget = new ImageButton(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["imageName"], attributeArray["tooltip"]);
};

XMLParser.prototype.parseRadioButton = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseRadioButtonAttributes(widgetNode, parentWidget);
  var newWidget = new RadioButton(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["imageName"], attributeArray["tooltip"],null, attributeArray["group"]);
};

XMLParser.prototype.parseToggleButton = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseToggleButtonAttributes(widgetNode, parentWidget);
  var newWidget = new ToggleButton(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], attributeArray["imageName"], attributeArray["onTooltip"], attributeArray["offTooltip"], attributeArray["state"], attributeArray["useRollover"]);
};

/**********************************************************
        Attribute Decoding Functions For GUI Widgets
***********************************************************/

XMLParser.prototype.parseGuiWidgetAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = new Array();
  attributeArray["id"] = widgetNode.getAttribute("id");
  if (parentWidget != null)
    attributeArray["parentElement"] = parentWidget.element;
  else
    attributeArray["parentElement"] = null;
  attributeArray["size"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"size")]);
  attributeArray["position"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"position")]);
  attributeArray["visibility"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"visibility")]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"style") != -1)
    attributeArray["style"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"style")]);
  else
    attributeArray["style"] = null;
  return attributeArray;
};

XMLParser.prototype.parsePanelAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["drag"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"enableDrag")]);
  return attributeArray;
};

XMLParser.prototype.parseTabPanelAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["orientation"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"orientation")]);
  return attributeArray;
};

XMLParser.prototype.parseImagePanelAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["imageSource"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageSource")]);
  attributeArray["scaleImage"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"scaleImage")]);
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageWidth") > -1)
    attributeArray["imageWidth"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageWidth")].childNodes[0]);
  else
    attributeArray["imageWidth"] = null;
  if (this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageHeight") > -1)
    attributeArray["imageHeight"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageHeight")].childNodes[0]);
  else
    attributeArray["imageHeight"] = null;
  return attributeArray;
};

XMLParser.prototype.parseTextButtonAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["label"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"label")]);
  return attributeArray;
};

XMLParser.prototype.parseImageButtonAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["imageName"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageName")]);
  attributeArray["tooltip"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"tooltip")]);
  return attributeArray;
};

XMLParser.prototype.parseRadioButtonAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseImageButtonAttributes(widgetNode, parentWidget);
  attributeArray["group"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"groupName")]);
  return attributeArray;
};

XMLParser.prototype.parseToggleButtonAttributes = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode, parentWidget);
  attributeArray["imageName"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"imageName")]);
  attributeArray["onTooltip"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"onTooltip")]);
  attributeArray["offTooltip"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"offTooltip")]);
  attributeArray["state"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"buttonState")]);
  attributeArray["useRollover"] = this.getObjectRecurse(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"useRollover")]);
  return attributeArray;
};

XMLParser.prototype.parseWidgetAttributeValue = function(widgetAttributeNode)
{
  var widgetName = this.getObjectRecurse(widgetAttributeNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetAttributeNode,0,"widgetId")]);
  var attributeName = this.getObjectRecurse(widgetAttributeNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetAttributeNode,0,"attributeName")]);
  return OBJECT_MANAGER.getWidgetAttribute(widgetName, attributeName);
};

/******************************************
          EMail Specific Widgets
*******************************************/

XMLParser.prototype.parseEMailPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new EMailPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

/******************************************
          Map Specific Widgets
*******************************************/

XMLParser.prototype.parseMapPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new MapPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseVmapPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new VmapPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseLayerPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new LayerPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseBufferPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  attributeArray["resultTarget"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"resultTarget")]);
  var newWidget = new BufferPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"],attributeArray["resultTarget"]);
};

XMLParser.prototype.parseCoordConvPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new CoordConvPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseMeasurePanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new MeasurePanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parsePrintManagerPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new PrintManagerPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseBookmarkPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new BookmarkPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseLabelPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  attributeArray["labelControlId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"labelControlId")]);
  var newWidget = new LabelPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["labelControlId"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseLabelIndex = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  attributeArray["labelControlId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"labelControlId")]);
  var newWidget = new LabelIndexPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["labelControlId"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseSavedQueryIndex = function(widgetNode, parentWidget)
{
  if ((OBJECT_MANAGER.getGuiValueById('extensions')["savedQueries"]) && (OBJECT_MANAGER.getGuiValueById('extensions')["savedQueries"].enabled))
  {
    var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
    var newWidget = new SavedQueryIndexPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"]);
  }
};

XMLParser.prototype.parseLoginPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["mapId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"mapId")]);
  var newWidget = new LoginPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["mapId"]);
};

XMLParser.prototype.parseQueryPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["queryControlId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"queryControlId")]);
  var newWidget = new QueryPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["queryControlId"]);
};

XMLParser.prototype.parseSelectionPanel = function(widgetNode, parentWidget)
{
  var attributeArray = this.parseGuiWidgetAttributes(widgetNode,parentWidget);
  attributeArray["selectionControlId"] = this.decodeSTRING(widgetNode.childNodes[this.__helper__getNextElementNamedChildNode(widgetNode,0,"selectionControlId")]);
  var newWidget = new SelectionPanel(attributeArray["id"], attributeArray["parentElement"], attributeArray["position"]["left"], attributeArray["position"]["top"], attributeArray["position"]["zpos"], attributeArray["size"]["width"], attributeArray["size"]["height"], attributeArray["visibility"], null, attributeArray["selectionControlId"]);
};

/**********************************************************
          Freeance Config Parsing Functions
***********************************************************/
XMLParser.prototype.parseApplicationConfig = function(appNode)
{
  var appConfig = new Array();
  appConfig.id = this.decodeSTRING(appNode.childNodes[this.__helper__getNextElementNamedChildNode(appNode,0,"applicationId")]);
  appConfig.organization = this.decodeSTRING(appNode.childNodes[this.__helper__getNextElementNamedChildNode(appNode,0,"organization")]);
  appConfig.title = this.decodeSTRING(appNode.childNodes[this.__helper__getNextElementNamedChildNode(appNode,0,"title")]);
  appConfig.administrator = this.decodeSTRING(appNode.childNodes[this.__helper__getNextElementNamedChildNode(appNode,0,"administrator")]);
  appConfig.adminEmail = this.decodeSTRING(appNode.childNodes[this.__helper__getNextElementNamedChildNode(appNode,0,"adminEmail")]);
  var mapUnitIndex = this.__helper__getNextElementNamedChildNode(appNode,0,"mapUnits");
  appConfig.mapUnits=((mapUnitIndex > -1)?(this.decodeSTRING(appNode.childNodes[mapUnitIndex])):('FT')),  
  
  OBJECT_MANAGER.setGuiValue("ApplicationConfig", appConfig);
  return appConfig;
};

XMLParser.prototype.parseMeasureConfig = function(configNode)
{
  var config = null;
  if (configNode != null)
  {
    config = new Array();
    config.distanceMeasureUnits = this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'distanceMeasureUnits')]);
    config.distanceColor = this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'distanceColor')]);
    config.distanceThickness = this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'distanceThickness')]);
  }
  OBJECT_MANAGER.setGuiValue('MeasureConfig',config);
  return (config);
};

XMLParser.prototype.parseEMailConfig = function(configNode)
{
  var config = null;
  if (configNode != null)
  {
    config = new Array();
    config.allowMapImages = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowMapImages')]) == 'true');
    config.allowSearchResults = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowSearchResults')]) == 'true');
    config.allowBufferResults = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowBufferResults')]) == 'true');
    config.allowSelectionResults = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowSelectionResults')]) == 'true');
    config.allowMessageBody = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowMessageBody')]) == 'true');
    config.allowFeedbackButton = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'allowFeedbackButton')]) == 'true');
    config.forceFeedbackMode = (this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'forceFeedbackMode')]) == 'true');
    config.mapImageHandle = this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'mapImageHandle')]);
    config.vmapImageHandle = this.decodeSTRING(configNode.childNodes[this.__helper__getNextElementNamedChildNode(configNode,0,'vmapImageHandle')]);
  }
  OBJECT_MANAGER.setGuiValue('emailConfig',config);
  return (config);
};

XMLParser.prototype.parseExtensionConfig = function(extensionConfigNode)
{
  var extensions = new Array();
  var extensionNodes = extensionConfigNode.getElementsByTagName('extension');
  for(var lcv=0; lcv < extensionNodes.length;lcv++)
  {
    var extension = extensionNodes[lcv];
    var name = extension.getAttribute('name');
    var enabled = extension.getAttribute('enabled');
    extensions[name] = new Array();
    extensions[name].enabled = (enabled == 'true')?true:false;
  }
  OBJECT_MANAGER.setGuiValue('extensions',extensions);
  return(extensions);
};

XMLParser.prototype.parseTemplateConfig = function(templateRootNode)
{
  var templates = new Object();
  var htmlString = '';
  for (var templateIndex = this.__helper__getNextElementNamedChildNode(templateRootNode,0,"template");templateIndex!=-1;templateIndex=this.__helper__getNextElementNamedChildNode(templateRootNode,templateIndex+1,"template"))
  {
    for (var lcv=0;lcv < templateRootNode.childNodes[templateIndex].childNodes.length;lcv++)
    {
      if (templateRootNode.childNodes[templateIndex].childNodes.item(lcv).nodeType == 4)
        htmlString = templateRootNode.childNodes[templateIndex].childNodes.item(lcv).nodeValue;
    }
    templates[templateRootNode.childNodes[templateIndex].getAttribute("id")] = htmlString;
  }
  OBJECT_MANAGER.setGuiValue('templates', templates);
  return templates;
};

XMLParser.prototype.parseMapConfig = function(mapNode)
{
  var mapConfig = new Array();
  mapConfig['id'] = mapNode.getAttribute("id");
  mapConfig["resourceId"] = this.getObjectRecurse(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"resourceId")]);
  mapConfig["imsHostname"] = this.decodeSTRING(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"imsHostname")]);
  mapConfig["previousStates"] = this.decodeINT(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"previousStates")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"vicinityMap")!=-1)
    mapConfig['vmap'] = this.parseVMapConfig(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"vicinityMap")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"themeDefinitions")!=-1)
    mapConfig['themes'] = this.parseThemeDefinitions(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"themeDefinitions")]);
  mapConfig["activeTheme"] = this.getObjectRecurse(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"activeTheme")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"themeGroupDefinitions")!=-1)
    mapConfig['themeGroups'] = this.parseThemeGroupDefinitions(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"themeGroupDefinitions")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"legendAttributes")!=-1)
    mapConfig['legendAttributes'] = this.parseLegendAttributes(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"legendAttributes")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"labelConfig")!=-1)
    mapConfig['labelConfig'] = this.parseLabelConfig(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"labelConfig")]);
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"loginQuery")!=-1)
    mapConfig['loginQuery'] = this.parseMapLoginQuery(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"loginQuery")]);
  var printConfigTags = this.__helper__getRemainingNextElementNamedChildNodes(mapNode,0,"pdfPrintConfig");
  if (printConfigTags.length > 0){
    mapConfig.printConfig = this.parsePdfPrintConfig(printConfigTags[0]);
  }
  else{
    mapConfig.printConfig = new Object;
    mapConfig.printConfig.templates = new Array;
    mapConfig.printConfig.defaultTemplate = -1;
  }
  var projectionId = 0;
  var projectionIdx = this.__helper__getNextElementNamedChildNode(mapNode,0,'projectionId');
  if(projectionIdx!=-1)
    projectionId=(mapNode.childNodes[projectionIdx].getAttribute('value')!=null)?(parseInt(mapNode.childNodes[projectionIdx].getAttribute('value'))):(this.decodeINT(mapNode.childNodes[projectionIdx]));
  mapConfig.projectionId = projectionId;
  if (this.__helper__getNextElementNamedChildNode(mapNode,0,"exportConfig")!=-1)
    mapConfig['exportConfig'] = this.parseMapExportConfig(mapNode.childNodes[this.__helper__getNextElementNamedChildNode(mapNode,0,"exportConfig")]);
  OBJECT_MANAGER.setGuiValue(mapConfig['id'], mapConfig);
  return mapConfig;
};

XMLParser.prototype.parseVMapConfig = function(vmapNode)
{
  var vmapConfig = new Array();
  var childNodeIndex = 0;
  vmapConfig['id'] = vmapNode.getAttribute("id");
  vmapConfig["resourceId"] = this.getObjectRecurse(vmapNode.childNodes[this.__helper__getNextElementNamedChildNode(vmapNode,0,"resourceId")]);
  vmapConfig["slaveType"] = this.getObjectRecurse(vmapNode.childNodes[this.__helper__getNextElementNamedChildNode(vmapNode,0,"slaveType")]);
  vmapConfig["boundBoxPercentMin"] = this.getObjectRecurse(vmapNode.childNodes[this.__helper__getNextElementNamedChildNode(vmapNode,0,"boundBoxPercentMin")]);
  vmapConfig["styleSheet"] = this.getObjectRecurse(vmapNode.childNodes[this.__helper__getNextElementNamedChildNode(vmapNode,0,"styleSheet")]);
  return vmapConfig;
};

XMLParser.prototype.parseThemeDefinitions = function (newNode)
{
  var themeDefinitions = new Array();
  for (themeIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"theme");themeIndex!=-1;themeIndex=this.__helper__getNextElementNamedChildNode(newNode,themeIndex+1,"theme"))
  {
    themeDefinitions[newNode.childNodes[themeIndex].getAttribute("id")] = this.parseTheme(newNode.childNodes[themeIndex]);
  }
  return themeDefinitions;
};

XMLParser.prototype.parseTheme = function (themeNode)
{
  var themeAttributes = new Array();
  themeAttributes["id"] = themeNode.getAttribute("id");
  themeAttributes["hideTheme"] = themeNode.getAttribute("hideTheme");
  if (themeAttributes["hideTheme"] == null)
    themeAttributes["hideTheme"] = false;
  else
    themeAttributes["hideTheme"] = themeAttributes["hideTheme"] == 'true';
  themeAttributes["themeName"] = this.getObjectRecurse(themeNode.childNodes[this.__helper__getNextElementNamedChildNode(themeNode,0,"themeName")]);
  if (this.__helper__getNextElementNamedChildNode(themeNode,0,"selectOptions")!=-1)
    themeAttributes["selectOptions"] = this.parseThemeSelectOptions(themeNode.childNodes[this.__helper__getNextElementNamedChildNode(themeNode,0,"selectOptions")]);
  else
    themeAttributes["selectOptions"] = null;
  if (this.__helper__getNextElementNamedChildNode(themeNode,0,"bufferOptions")!=-1)
    themeAttributes["bufferOptions"] = this.parseThemeBufferOptions(themeNode.childNodes[this.__helper__getNextElementNamedChildNode(themeNode,0,"bufferOptions")]);
  else
    themeAttributes["bufferOptions"] = null;
  themeAttributes["visibility"] = false;
  themeAttributes["altLegends"] = new Array();
  
  var altLegends = themeNode.getElementsByTagName('altLegend');
  for(var lcv=0;lcv < altLegends.length;lcv++)
  {
    var currentNode = altLegends[lcv];
    themeAttributes["altLegends"][lcv] = new Object;
    themeAttributes["altLegends"][lcv].legendName = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"legendName")]);
    themeAttributes["altLegends"][lcv].legendLabel = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"legendLabel")]);
  }
  return themeAttributes;
};

XMLParser.prototype.parseThemeSelectOptions = function(newNode)
{
  var selectAttributes = new Array();
  selectAttributes["styleSheet"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"styleSheet")]);
  selectAttributes["fieldList"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"fieldList")]);
  selectAttributes["limit"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"limit")]);
  selectAttributes["tolerance"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"tolerance")]);
  selectAttributes["idField"] = this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"idField")]);
  selectAttributes["keyField"] = this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"keyField")]);
  var zoomExtentRatioIndex = this.__helper__getNextElementNamedChildNode(newNode,0,"zoomExtentRatio");
  if (zoomExtentRatioIndex == -1)
    selectAttributes["zoomExtentRatio"] = 1.2;
  else
    selectAttributes["zoomExtentRatio"] = this.decodeDOUBLE(newNode.childNodes[zoomExtentRatioIndex]);
  var keyFieldTypeIndex = this.__helper__getNextElementNamedChildNode(newNode,0,"keyFieldType");
  selectAttributes["keyFieldType"] = ((keyFieldTypeIndex!=-1)?(this.decodeINT(newNode.childNodes[keyFieldTypeIndex])):(12));
  selectAttributes["resultTemplate"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"resultTemplate")]);
  var sqlParamsIndex = this.__helper__getNextElementNamedChildNode(newNode,0,"sqlParams");
  if (sqlParamsIndex > -1)
    selectAttributes["sqlParams"] = this.parseChainedQuerySqlParams(newNode.childNodes[sqlParamsIndex]);
  else
    selectAttributes["sqlParams"] = null;
  return selectAttributes;
};

XMLParser.prototype.parseChainedQuerySqlParams = function(sqlParamsNode)
{
  var sqlParams = new Array();
  var sqlParamNodeList = sqlParamsNode.getElementsByTagName('sqlParam');
  for(var lcv=0;lcv < sqlParamNodeList.length;lcv++)
  {
    var theNode = sqlParamNodeList[lcv];
    sqlParams[lcv] = new Object;
    sqlParams[lcv]["pdqIdentifier"] = this.decodeSTRING(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"pdqIdentifier")]);
    sqlParams[lcv]["fieldList"] = new Array();
    var fieldListNode = theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"fieldList")];
    var fieldNodeList = fieldListNode.getElementsByTagName('field');
    for(var fieldIndex=0;fieldIndex < fieldNodeList.length;fieldIndex++)
    {
      var fieldListIndex = sqlParams[lcv]["fieldList"].length;
      sqlParams[lcv]["fieldList"][fieldListIndex] = new Object();
      sqlParams[lcv]["fieldList"][fieldListIndex]["fieldName"] = this.decodeSTRING(fieldNodeList[fieldIndex].getElementsByTagName("fieldName")[0]);
      sqlParams[lcv]["fieldList"][fieldListIndex]["pdqFieldName"] = this.decodeSTRING(fieldNodeList[fieldIndex].getElementsByTagName("pdqFieldName")[0]);
    }
    if (this.__helper__getNextElementNamedChildNode(theNode,0,"queryType") > -1)
    {
      sqlParams[lcv]["queryType"] = this.decodeSTRING(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"queryType")]);
      sqlParams[lcv]["numRows"]   = this.decodeINT(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"numRows")]);
      sqlParams[lcv]["startAt"] = this.decodeINT(theNode.childNodes[this.__helper__getNextElementNamedChildNode(theNode,0,"startAt")]);
    }
    else  // do not want.  use full select instead
    {
      sqlParams[lcv]["queryType"] = '';
      sqlParams[lcv]["numRows"] = 0;
      sqlParams[lcv]["startAt"] = 0;
    }
  }
  return(sqlParams);
};

XMLParser.prototype.parseThemeBufferOptions = function(newNode)
{
  var bufferAttributes = new Object;
  bufferAttributes["styleSheet"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"styleSheet")]);
  bufferAttributes["fieldList"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"fieldList")]);
  bufferAttributes["limit"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"limit")]);
  bufferAttributes["resultTemplate"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"resultTemplate")]);
  bufferAttributes["invalidTemplate"] = this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"invalidTemplate")]);
  bufferAttributes["maxSelect"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"maxSelect")]);
  var sqlParamsIndex = this.__helper__getNextElementNamedChildNode(newNode,0,"sqlParams");
  if (sqlParamsIndex > -1)
    bufferAttributes["sqlParams"] = this.parseChainedQuerySqlParams(newNode.childNodes[sqlParamsIndex]);
  else
    bufferAttributes["sqlParams"] = null;
  if (this.__helper__getNextElementNamedChildNode(newNode,0,"filterQueries") != -1)
  {
    var queryListNode = newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"filterQueries")];
    bufferAttributes["filterQueries"] = new Object;
    for (var queryIndex = this.__helper__getNextElementNamedChildNode(queryListNode,0,"query");queryIndex!=-1;queryIndex=this.__helper__getNextElementNamedChildNode(queryListNode,queryIndex+1,"query"))
    {
      bufferAttributes["filterQueries"][this.decodeSTRING(queryListNode.childNodes[queryIndex])] = null;
    }
  }
  else
    bufferAttributes["filterQueries"] = null;
  if (this.__helper__getNextElementNamedChildNode(newNode,0,"export_csv")!=-1)
  {
    if (!bufferAttributes["export"])
      bufferAttributes["export"] = new Object;
    bufferAttributes["export"].csv = new Object;
    if(this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"export_csv")]) == 'true')
    {
      bufferAttributes["export"].csv.enabled = true;
      bufferAttributes["export"].csv.delim = this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"export_csv_delim")]);
      if(this.decodeSTRING(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"export_csv_includefieldnames")])=='true')
        bufferAttributes["export"].csv.includeFieldNames = true;
      else
        bufferAttributes["export"].csv.includeFieldNames = false;
    }
    else
      bufferAttributes["export"].csv.enabled = false;
  }
  return bufferAttributes;
};

XMLParser.prototype.parseThemeGroupDefinitions = function (newNode)
{
  var themeGroupDefinitions = new Object();
  for(var groupIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"themeGroup");groupIndex!=-1;groupIndex=this.__helper__getNextElementNamedChildNode(newNode,groupIndex+1,"themeGroup"))
  {
    var groupNode = newNode.childNodes[groupIndex];
    var groupNameIndex = this.__helper__getNextElementNamedChildNode(groupNode,0,"themeGroupName");
    if (groupNameIndex==-1)
      var groupName = escapeHTML(groupNode.getAttribute("name"));
    else
      var groupName = this.decodeSTRING(groupNode.childNodes[groupNameIndex]);
    themeGroupDefinitions[groupName] = new Array;
    for (var groupMemberIndex = this.__helper__getNextElementNamedChildNode(groupNode,0,"themeGroupMember");groupMemberIndex!=-1;groupMemberIndex=this.__helper__getNextElementNamedChildNode(groupNode,groupMemberIndex+1,"themeGroupMember"))
    {
      var groupMemberNode = groupNode.childNodes[groupMemberIndex];
      var groupMemberName = this.decodeSTRING(groupMemberNode);
      themeGroupDefinitions[groupName][groupMemberName] = groupMemberName;
    }
  }
  return themeGroupDefinitions;
};

XMLParser.prototype.parseLegendAttributes = function (newNode)
{
  var legendAttributes = new Array();
  legendAttributes["width"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"width")]);
  legendAttributes["height"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"height")]);
  legendAttributes["color"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"color")]);
  legendAttributes["font"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"font")]);
  legendAttributes["fontSize"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"fontSize")]);
  legendAttributes["valueFontSize"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"valueFontSize")]);
  legendAttributes["cellSpacing"] = this.getObjectRecurse(newNode.childNodes[this.__helper__getNextElementNamedChildNode(newNode,0,"cellSpacing")]);
  return legendAttributes;
};

XMLParser.prototype.parseMapExportConfig = function(newNode)
{
  var exportConfig = new Object;
  exportConfig.enabled = newNode.getAttribute('enabled');
  return exportConfig;
};

XMLParser.prototype.parsePdfPrintConfig = function (newNode)
{
  var printConfig = new Object;
  printConfig.templates = new Array;
  printConfig.defaultTemplate = parseInt(newNode.getAttribute('defaultTemplate'));
  for(var templateIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"template");templateIndex!=-1;templateIndex=this.__helper__getNextElementNamedChildNode(newNode,templateIndex+1,"template"))
  {
    var templateNode = newNode.childNodes[templateIndex];
    var template = new Object;
    template.displayName = this.decodeSTRING(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"displayname")]);
    template.templateName = this.decodeSTRING(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"templatename")]);
    template.orientation = templateNode.getAttribute('orientation');
    template.unit = templateNode.getAttribute('unit');
    template.width = parseFloat(templateNode.getAttribute('width'));
    template.height = parseFloat(templateNode.getAttribute('height'));
    printConfig.templates[printConfig.templates.length] = template;
  }
  if ((printConfig.templates.length > 0)&&(printConfig.defaultTemplate==-1))
    printConfig.defaultTemplate = 0;
  if (printConfig.templates.length==0)
    printConfig.defaultTemplate = -1;
  printConfig.activeTemplate = printConfig.defaultTemplate;
  return printConfig;
};

XMLParser.prototype.parseLabelConfig = function (newNode)
{
  var labelConfig = new Object;
  labelConfig["pointLabels"] = new Object;
  for(var labelIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"pointLabel");labelIndex!=-1;labelIndex=this.__helper__getNextElementNamedChildNode(newNode,labelIndex+1,"pointLabel"))
  {
    var currentNode = newNode.childNodes[labelIndex];
    var nameIndex = this.__helper__getNextElementNamedChildNode(currentNode,0,'labelName');
    if (nameIndex==-1)
      var labelId = currentNode.getAttribute("id");
    else
      var labelId = this.decodeSTRING(currentNode.childNodes[nameIndex]);
    labelConfig.pointLabels[labelId] = new Object;
    labelConfig.pointLabels[labelId].styleSheet = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"styleSheet")]);
    labelConfig.pointLabels[labelId].sampleURL = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"sampleURL")]);
    labelConfig.pointLabels[labelId].description = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"description")]);
  }
  labelConfig["textLabels"] = new Object;
  for(var labelIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"textLabel");labelIndex!=-1;labelIndex=this.__helper__getNextElementNamedChildNode(newNode,labelIndex+1,"textLabel"))
  {
    var currentNode = newNode.childNodes[labelIndex];
    var nameIndex = this.__helper__getNextElementNamedChildNode(currentNode,0,'labelName');
    if (nameIndex==-1)
      var labelId = currentNode.getAttribute("id");
    else
      var labelId = this.decodeSTRING(currentNode.childNodes[nameIndex]);
    labelConfig.textLabels[labelId] = new Object;
    labelConfig.textLabels[labelId].styleSheet = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"styleSheet")]);
    labelConfig.textLabels[labelId].sampleCSS  = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"sampleCSS")]);
    labelConfig.textLabels[labelId].sampleText = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"sampleText")]);
  }
  labelConfig["lineLabels"] = new Object;
  for(var labelIndex=this.__helper__getNextElementNamedChildNode(newNode,0,"lineLabel");labelIndex!=-1;labelIndex=this.__helper__getNextElementNamedChildNode(newNode,labelIndex+1,"lineLabel"))
  {
    var currentNode = newNode.childNodes[labelIndex];
    var nameIndex = this.__helper__getNextElementNamedChildNode(currentNode,0,'labelName');
    if (nameIndex==-1)
      var labelId = currentNode.getAttribute("id");
    else
      var labelId = this.decodeSTRING(currentNode.childNodes[nameIndex]);
    labelConfig.lineLabels[labelId] = new Object;
    labelConfig.lineLabels[labelId].styleSheet = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"styleSheet")]);
    labelConfig.lineLabels[labelId].color = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"color")]);
    labelConfig.lineLabels[labelId].thickness = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"thickness")]);
    labelConfig.lineLabels[labelId].description = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"description")]);
  }
  return labelConfig;
};

XMLParser.prototype.parseMapLoginQuery = function(queryNode)
{
  var definedQueryNode = queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"definedQuery")];
  return this.parseDefinedQuery(definedQueryNode);
};

XMLParser.prototype.parseQueryGroup = function(groupNode)
{
  var groupId = groupNode.getAttribute("id");
  var queryGroup = new Array;
  var queryIndex = 0;
  for (var childIndex=this.__helper__getNextElementNamedChildNode(groupNode,0,"query");childIndex!=-1;childIndex=this.__helper__getNextElementNamedChildNode(groupNode,childIndex+1,"query"))
  {
    queryGroup[queryIndex] = this.decodeSTRING(groupNode.childNodes[childIndex]);
    queryIndex++;  
  }  
  OBJECT_MANAGER.setGuiValue(groupId, queryGroup);
  return queryGroup;
};

XMLParser.prototype.parseDefinedQuery = function(queryNode)
{
  var queryConfig = new Object();
  var requestNode = queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"request")];
  var fieldsNode = queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"fieldList")];
  queryConfig["id"] = queryNode.getAttribute("id");
  queryConfig["description"] = this.decodeSTRING(queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"description")]);
  queryConfig["request"] = new Object;
  queryConfig["request"]["requestMethod"] = this.decodeSTRING(requestNode.childNodes[this.__helper__getNextElementNamedChildNode(requestNode,0,"requestMethod")]);
  queryConfig["request"]["pdqIdentifier"] = this.decodeSTRING(requestNode.childNodes[this.__helper__getNextElementNamedChildNode(requestNode,0,"pdqIdentifier")]);
  var dbtypeIndex = this.__helper__getNextElementNamedChildNode(requestNode,0,"dbtype");
  if (dbtypeIndex==-1)
    queryConfig["request"]["dbtype"] = '';
  else
    queryConfig["request"]["dbtype"] = this.decodeSTRING(requestNode.childNodes[dbtypeIndex]);
  queryConfig["fieldList"] = this.parseQueryFields(fieldsNode);
  if (this.__helper__getNextElementNamedChildNode(queryNode,0,"exportQuery")!=-1)
  {
    queryConfig["export"] = new Object;
    var exportQueryNode = queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"exportQuery")];
    if (this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_csv")!=-1)
    {
      queryConfig["export"].csv = new Object;
      if(this.decodeSTRING(exportQueryNode.childNodes[this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_csv")]) == 'true')
      {
        queryConfig["export"].csv.enabled = true;
        queryConfig["export"].csv.delim = this.decodeSTRING(exportQueryNode.childNodes[this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_csv_delim")]);
        if(this.decodeSTRING(exportQueryNode.childNodes[this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_csv_includefieldnames")])=='true')
          queryConfig["export"].csv.includeFieldNames = true;
        else
          queryConfig["export"].csv.includeFieldNames = false;
      }
      else
        queryConfig["export"].csv.enabled = false;
    }
    if (this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_xml")!=-1)
    {
      queryConfig["export"].xml = new Object;
      if(this.decodeSTRING(exportQueryNode.childNodes[this.__helper__getNextElementNamedChildNode(exportQueryNode,0,"export_xml")]) == 'true')
        queryConfig["export"].xml.enabled = true;
      else
        queryConfig["export"].xml.enabled = false;
    }
  }
  if (this.__helper__getNextElementNamedChildNode(queryNode,0,"resultTemplates")!=-1)
  {
    var templateNode = queryNode.childNodes[this.__helper__getNextElementNamedChildNode(queryNode,0,"resultTemplates")];
    queryConfig["templates"] = new Object;
    if (this.__helper__getNextElementNamedChildNode(templateNode,0,"validTemplate")!=-1)
      queryConfig["templates"]["validTemplate"] = this.decodeSTRING(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"validTemplate")]);
    else
      queryConfig["templates"]["validTemplate"] = null;
    if (this.__helper__getNextElementNamedChildNode(templateNode,0,"invalidTemplate")!=-1)
      queryConfig["templates"]["invalidTemplate"] = this.decodeSTRING(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"invalidTemplate")]);
    else
      queryConfig["templates"]["invalidTemplate"] = null;
    if (this.__helper__getNextElementNamedChildNode(templateNode,0,"emptyTemplate")!=-1)
      queryConfig["templates"]["emptyTemplate"] = this.decodeSTRING(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"emptyTemplate")]);
    else
      queryConfig["templates"]["emptyTemplate"] = null;
    if (this.__helper__getNextElementNamedChildNode(templateNode,0,"pageRows")!=-1)
      queryConfig["templates"]["pageRows"] = this.decodeINT(templateNode.childNodes[this.__helper__getNextElementNamedChildNode(templateNode,0,"pageRows")]);
    else
      queryConfig["templates"]["pageRows"] = null;
  }
  else
    queryConfig["templates"] = null;

  OBJECT_MANAGER.setGuiValue(queryConfig['id'], queryConfig);
  return queryConfig;
};

XMLParser.prototype.parseQueryFields = function(fieldsNode)
{
  var fieldsConfig = new Object;

  for (var fieldIndex=this.__helper__getNextElementChildNode(fieldsNode,0);fieldIndex!=-1;fieldIndex=this.__helper__getNextElementChildNode(fieldsNode,fieldIndex+1))
  {
    var currentNode = fieldsNode.childNodes[fieldIndex];
    var currentField = currentNode.getAttribute("id");
    fieldsConfig[currentField] = new Object;
    fieldsConfig[currentField].fieldType = currentNode.nodeName;
    switch (currentNode.nodeName)
    {
      case 'labelField':
        fieldsConfig[currentField].value = this.decodeSTRING(currentNode);
        break;
      case 'textField':
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"caption") != -1)
          fieldsConfig[currentField].caption = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"caption")]);
        else
          fieldsConfig[currentField].caption = null;
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"fieldName") != -1)
          fieldsConfig[currentField].fieldName = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"fieldName")]);
        else
          fieldsConfig[currentField].fieldName = null;
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"width") != -1)
          fieldsConfig[currentField].width = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"width")]);
        else
          fieldsConfig[currentField].width = null;
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"defaultValue") != -1)
          fieldsConfig[currentField].defaultValue = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"defaultValue")]);
        else
          fieldsConfig[currentField].defaultValue = '';
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"initialValue") != -1)
          fieldsConfig[currentField].initialValue = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"initialValue")]);
        else
          fieldsConfig[currentField].initialValue = '';
        break;
      case 'selectField':
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"caption") != -1)
          fieldsConfig[currentField].caption = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"caption")]);
        else
          fieldsConfig[currentField].caption = null;
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"fieldName") != -1)
          fieldsConfig[currentField].fieldName = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"fieldName")]);
        else
          fieldsConfig[currentField].fieldName = null;
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"default") != -1)
        {
          fieldsConfig[currentField].defaultValue = this.decodeSTRING(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"default")]);
        }
        else
          fieldsConfig[currentField].defaultValue = '';
        if (this.__helper__getNextElementNamedChildNode(currentNode,0,"optionList") != -1)
        {
          fieldsConfig[currentField].optionList = this.parseOptionList(currentNode.childNodes[this.__helper__getNextElementNamedChildNode(currentNode,0,"optionList")]);
        }
        else
          fieldsConfig[currentField].optionList = null;
        break;
      case 'hiddenField':
        break;
      default:
        alert('Unknown query field type: '+currentNode.nodeName);
        break;
    }
  }
  return fieldsConfig;
};

XMLParser.prototype.parseOptionList = function(listParentNode)
{
  var optionList = new Array();
  var optionArrayIndex = 0;
  for (var optionIndex=this.__helper__getNextElementChildNode(listParentNode,0);optionIndex!=-1;optionIndex=this.__helper__getNextElementChildNode(listParentNode,optionIndex+1))
  {
    var currentNode = listParentNode.childNodes[optionIndex];
    switch (currentNode.nodeName)
    {
      case 'option':
        optionList[optionArrayIndex] = new Object;
        optionList[optionArrayIndex].type = 'option';
        optionList[optionArrayIndex].value = currentNode.getAttribute("value");
        optionList[optionArrayIndex].description = this.decodeSTRING(currentNode);
        break;
      case 'optgroup':
        optionList[optionArrayIndex] = new Object;
        optionList[optionArrayIndex].type = 'optgroup';
        optionList[optionArrayIndex].description = currentNode.getAttribute("label");
        optionList[optionArrayIndex].value = this.parseOptionList(currentNode);
        break;
      default:
        break;
    }
    optionArrayIndex++;
  }
  return optionList;
};

