function GUI_ResourceManager()
{

  // inherit from XML_Loader ...
  this.prototype = new XML_Loader();
  for (prop in this.prototype)
    this[prop] = this.prototype[prop];



  this.GetResource = function(id)
  {
    return this.m_resources[id];
  }


  this.OnXmlLoaded = function(xmlDoc)
  {
    // parse the XML ...

    //=========================================
    // get the style definitions ...
    //=========================================

    var styleObjects = xmlDoc.getElementsByTagName('style');
    if (styleObjects)
    {
      var numStyles = styleObjects.length;
      for (var i = 0; i < numStyles; i++)
      {
        var styleObject = new Array();
        var numTags = styleObjects[i].childNodes.length;
        for (var j = 0; j < numTags; j++)
          if (styleObjects[i].childNodes[j].tagName != undefined)
          {
            var object = styleObjects[i].childNodes[j];
            var objectValue = object.firstChild.nodeValue;
            styleObject[object.tagName] = objectValue;
          }
        this.m_resources[styleObject['id']] = styleObject;
      }
    }



    //========================================
    // get the menu definitions ...
    //========================================

    var menuObjects = xmlDoc.getElementsByTagName('menu');
    if (menuObjects)
    {
      var numMenus = menuObjects.length;
      for (var i = 0; i < numMenus; i++)
      {
        var menu = CreateMenu(false, menuObjects[i]);
        this.m_resources[menu.m_GUI_ID] = menu;
      }
    }



    //========================================
    // get the page control definitions ...
    //========================================

    var pageControlObjects = xmlDoc.getElementsByTagName('pageControl');
    if (pageControlObjects)
    {
      var numPageControls = pageControlObjects.length;
      for (var i = 0; i < numPageControls; i++)
      {
        var numAttr = pageControlObjects[i].attributes.length;
        var id = '';
        var style = '';
        for (var j = 0; j < numAttr; j++)
        {
          switch (pageControlObjects[i].attributes[j].name)
          {
            case 'id':
            case 'ID':
              id = pageControlObjects[i].attributes[j].value;
              break;

            case 'style':
            case 'STYLE':
              style = pageControlObjects[i].attributes[j].value;
              break;
          }
        }

        var pageControl = new GUI_PageControl();
        var styleDef = this.GetResource(style);

        var numChildNodes = pageControlObjects[i].childNodes.length;
        for (var j = 0; j < numChildNodes; j++)
        {
          var obj = pageControlObjects[i].childNodes[j];
          if (obj.tagName)
            styleDef[obj.tagName] = obj.childNodes[0].nodeValue;
        }

        pageControl.SetStyles(styleDef);
        this.m_resources[id] = pageControl;
      }
    }



    //========================================
    // get the dialog definitions ...
    //========================================

    var dialogObjects = xmlDoc.getElementsByTagName('dialog');
    if (dialogObjects)
    {
      var numDialogs = dialogObjects.length;
      for (var i = 0; i < numDialogs; i++)
      {
        var numAttr = dialogObjects[i].attributes.length;
        var dialogID = '';
        var dialogStyle = '';
        for (var j = 0; j < numAttr; j++)
        {
          switch (dialogObjects[i].attributes[j].name)
          {
            case 'id':
            case 'ID':
              dialogID = dialogObjects[i].attributes[j].value;
              break;

            case 'style':
            case 'STYLE':
              dialogStyle = dialogObjects[i].attributes[j].value;
              break;
          }
        }

        var dialog = new GUI_Dialog();
        var numChildNodes = dialogObjects[i].childNodes.length;
        var style = this.GetResource(dialogStyle);
        for (var j = 0; j < numChildNodes; j++)
        {
          var obj = dialogObjects[i].childNodes[j];
          if (obj.tagName)
          {
            var objValue = obj.childNodes[0].nodeValue;
            switch (obj.tagName)
            {
              case 'content':
                dialog.SetContent(objValue);
                break;
              case 'caption':
                dialog.SetCaption(objValue);
                break;
              case 'visible':
                dialog.SetVisibility((objValue == true) || (objValue == 'true'));
                break;
              case 'width':
                dialog.SetWidth(objValue);
                break;
              case 'height':
                dialog.SetHeight(objValue);
                break;
              case 'close':
                style['close'] = objValue;
                break;
              case 'minimize':
                style['minimize'] = objValue;
                break;
              case 'menu':
                style['menu'] = objValue;
                break;
            }
          }
        }

        dialog.SetStyles(style);
        this.m_resources[dialogID] = dialog;
      }
    }

    m_loaded = true;
    if (this.m_onLoad)
      this.m_onLoad();
  }



  // member variable declarations ...
  this.m_onXmlLoaded = this.OnXmlLoaded;
  this.m_onLoad = 0;
  this.m_resources = new Array();
}


var g_resourceManager = new GUI_ResourceManager();

