if (typeof Array.prototype.push == "undefined") 
  Array.prototype.push = function(str) { this[this.length] = str; }

var loaders = [];

/* forms:select1 control */

function Enable(id)
{
  var obj = document.getElementById(id);
  if (obj)
    obj.disabled = false;
}

function Disable(id)
{
  var obj = document.getElementById(id);
  if (obj)
    obj.disabled = true;
}

function SetEnabled(test, id)
{
  if (test)
    Enable(id);
  else
    Disable(id);
}

function EnableSelect1(id)
{
  var obj = document.forms[0][id];
  if (obj)
  {
    if (obj.length)
    {
      for (var b = 0; b < obj.length; b++)
        obj[b].disabled = false;
    }
    else
      obj.disabled = false;
  }
}

function DisableSelect1(id)
{
  var obj = document.forms[0][id];
  if (obj)
  {
    if (obj.length)
    {
      for (var b = 0; b < obj.length; b++)
      {
        obj[b].disabled = true;
        obj[b].checked = false;
      }
    }
    else
    {
      obj.disabled = true;
      obj.checked = false;
    }
  }
}

function SetEnabledSelect1(test, id)
{
  if (test)
    EnableSelect1(id);
  else
    DisableSelect1(id);
}

function SetDisabledSelect1(test, id)
{
  if (test)
    DisableSelect1(id);
  else
    EnableSelect1(id);
}

function EnableSelect1Open(id)
{
  var obj = document.forms[0][id];
  if (obj)
  {
    if (obj.length)
    {
      for (var b = 0; b < obj.length; b++)
        obj[b].disabled = false;
    }
    elseFODT0003
      obj.disabled = false;
  }
}

function DisableSelect1Open(id)
{
  var obj = document.forms[0][id];
  if (obj)
  {
    if (obj.length)
    {
      for (var b = 0; b < obj.length; b++)
      {
        obj[b].disabled = true;
        obj[b].checked = false;
      }
    }
    else
    {
      obj.disabled = true;
      obj.checked = false;
    }
  }
  var openId = id + ".open";
  DisableClear(openId);
}

function SetEnabledSelect1Open(test, id)
{
  if (test)
    EnableSelect1Open(id);
  else
    DisableSelect1Open(id);
}

function SetDisabledSelect1Open(test, id)
{
  if (test)
    DisableSelect1Open(id);
  else
    EnableSelect1Open(id);
}

function EnableSelect(id)
{
  var notDone = true;
  for (var i = 1; notDone; ++i)
  {
    var gid = id + i.toString();
    var obj = document.getElementById(gid);
    if (obj)
      obj.disabled = false;
    else
      notDone = false;
  }
}

function DisableSelect(id)
{
  var notDone = true;
  for (var i = 1; notDone; ++i)
  {
    var gid = id + i.toString();
    var obj = document.getElementById(gid);
    if (obj)
    {
      obj.checked = false;
      obj.disabled = true;
    }
    else
      notDone = false;
  }
}

function SetEnabledSelect(test, id)
{
  if (test)
    EnableSelect(id);
  else
    DisableSelect(id);
}

function SetDisabledSelect(test, id)
{
  if (test)
    DisableSelect(id);
  else
    EnableSelect(id);
}

function DisableClear(id)
{
  var obj = document.getElementById(id);
  if (obj)
  {
    obj.disabled = true;
    obj.value = '';
  }
}

function SetDisabled(test, id)
{
  if (test)
    Disable(id);
  else
    Enable(id);
}

function Check(id)
{
  var obj = document.getElementById(id);
  if (obj)
    obj.checked = true;
}

function Uncheck(id)
{
  var obj = document.getElementById(id);
  if (obj)
    obj.checked = false;
}

function IsChecked(id)
{
  var obj = document.getElementById(id);
  if (obj)
    return obj.checked;
  else
    return false;
}

function GetValue(id)
{
  var obj = document.getElementById(id);
  if (obj)
    return obj.value;
  else
    return "";
}

function ToggleDisplay(id)
{
  var obj = document.getElementById(id);
  if (obj && obj.style.display)
  {
    if (obj.style.display != 'none')
      obj.style.display = 'none';
    else
      obj.style.display = 'block';
  }
}

/* xml loading code */

function EventHandler(obj, methodName)
{
  return function (e) 
  { 
     var evt = e ? e : window.event;
     return obj[methodName](evt); 
  };
}

function XmlLoader(url, callback)
{
  if (arguments.length > 0)
    this.construct(url, callback);
}

XmlLoader.prototype.construct = function(url, callback)
{
  this.url      = url;
  this.callback = callback;
  this.active   = false;
}

XmlLoader.prototype.doReadyStateChange = function (evt)
{
  if (this.document.readyState == 4) 
  {
    if ((this.document.status) &&
        (this.document.status == 200))
      this.callback(this.document.responseXML);
    else
      this.callback(this.document);
  }
}

XmlLoader.createCallback = function (obj, methodName)
{
  return function (xmlDoc) 
  { 
    return obj[methodName](xmlDoc); 
  };
}

XmlLoader.prototype.load = function ()
{
  if (this.active == false)
  {
    var handler = EventHandler(this, 'doReadyStateChange');
    if (window.XMLHttpRequest)
    {
      try
      {
        this.document = new XMLHttpRequest();
        if (this.document != null)
        {
          this.document.open("GET", this.url, true);
          this.document.onreadystatechange = handler;
          this.document.send(null);
          return true;
        }
        else
        {
          return false;
        }
      }
      catch (e)
      {
          alert("caught " + e);
          return false;
      }
    }
    else if (document.implementation && document.implementation.createDocument)
    {
      this.document = document.implementation.createDocument("", "", null);

      if (this.document.addEventListener)
        this.document.addEventListener("load", handler, false);
      this.document.load(this.url);
      return true;
    }
    else if (window.ActiveXObject)
    {
      this.document = new ActiveXObject("Microsoft.XMLDOM");
      this.document.onreadystatechange = handler;
      this.document.load(this.url);
      return true;
    }
    else
    {
      return this.loadFromFrame();
    }
  }
}

XmlLoader.prototype.loadFromFrame = function()
{
  var create = (document.getElementById('xmlLoader') == null);

  if (create)
  {
    xmlDoc = document.createElement('div');
    xmlDoc.id = 'xmlLoader';
    xmlDoc.style.visibility = 'hidden'; 
    xmlDoc.style.position = 'absolute';
    xmlDoc.style.top = '0px'; 
    xmlDoc.style.left = '0px';
    xmlDoc.innerHTML = '<iframe src="'+this.url+'" name="xml" height="0" width="0"><\/iframe>';
  }

  if (!this.timer) 
  {
    var handler = EventHandler(this, 'frameLoader');
    this.timer = window.setInterval(handler, 100);
  }

  if (create)
    document.body.appendChild(xmlDoc);

  return true;
}

XmlLoader.prototype.frameLoader = function (evt)
{
  if (window.frames['xml'].document)
  {
    window.clearInterval(this.timer);
    this.timer = null;
    this.frameLoaded();
    this.document = window.frames['xml'].document;
    this.callback(this.document);
  }
}

XmlLoader.prototype.isSupported = function ()
{
  if (window.XMLHttpRequest)
  {
    try
    {
      var request = new XMLHttpRequest();
      if (request != null)
        return true;
    }
    catch (e)
    {
    }
  }

  if (document.implementation && document.implementation.createDocument)
  {
     try
     {
       var tmp = document.implementation.createDocument("", "", null);
       if ((tmp != null) && (tmp.load != null))
         return true;
     }
     catch (e)
     {
     }
  }

  if (window.ActiveXObject)
  {
     try
     {
       var tmp = new ActiveXObject("Microsoft.XMLDOM");
       if (tmp != null)
         return true;
     }
     catch (e)
     {
     }
  }

  // frame version
  if (window.setInterval && 
      window.frames &&
      document.createElement &&
      document.getElementById)
   return true;
  
  return false;
}

function changeClass(node, name)
{
  if (node.className)
    node.className = name;
}

function newImage(arg)
{
  if (document.images) 
  {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages(node, imgsrc) 
{
  if (node && imgsrc)
  {
    node.src = imgsrc;
  }
}


/* tree code */

var treeConfig = new TreeConfig('images/plus.gif', 'images/minus.gif', 'images/dot.gif', 'contents/', '.xml', '.htm');

function preloadTreeImages() 
{
  if ((document.images) && (treeConfig != null))
  {
    treeConfig.preload();
  }
}

function TreeConfig(plus, minus, link, loadDir, xmlExtension, htmExtension)
{
  this.plus        = plus;
  this.minus       = minus;
  this.link        = link;
  this.preload     = treeConfigPreload;
  this.images      = new Array();
  this.loadDir     = loadDir;
  this.targetFrame = null;
  this.hrefPrefix  = null;
  this.xmlExt      = xmlExtension;
  this.htmExt      = htmExtension;
}

function treeConfigPreload()
{
  if (this.images.length == 0)
  {
    this.images[0]     = new Image();
    this.images[0].src = this.plus;
    this.images[1]     = new Image();
    this.images[1].src = this.minus;
    this.images[2]     = new Image();
    this.images[2].src = this.link;
  }
}

var treeNodeLoading = null;
var treeNodeXmlDoc  = null;

function isTreeLoadingSupported()
{
    if (window.XMLHttpRequest)
    {
      try
      {
        var request = new XMLHttpRequest();
        if (request != null)
          return true;
      }
      catch (e)
      {
      }
    }

    if (document.implementation && document.implementation.createDocument)
    {
       try
       {
         var tmp = document.implementation.createDocument("", "", null);
         if ((tmp != null) && (tmp.load != null))
           return true;
       }
       catch (e)
       {
       }
    }

    if (window.ActiveXObject)
    {
       try
       {
         var tmp = new ActiveXObject("Microsoft.XMLDOM");
         if (tmp != null)
           return true;
       }
       catch (e)
       {
       }
    }

    return false;
}

var treeLoadingSupported = isTreeLoadingSupported()

function treeGetChildUl()
{
  return getChildUl(this.node);
}

function getChildUl(ulNode)
{
  if (ulNode && ulNode.childNodes)
  {
    for (var cj=0; cj < ulNode.childNodes.length; cj++)
    {
      if ((ulNode.childNodes[cj].nodeName == 'ul') ||
          (ulNode.childNodes[cj].nodeName == 'UL'))
        return ulNode.childNodes[cj];
    }
  }
  return null;
}

function getChildImg(liNode)
{
  if (liNode && liNode.childNodes)
  {
    for (var cj=0; cj < liNode.childNodes.length; cj++)
    {
      if ((liNode.childNodes[cj].nodeName == 'img') ||
          (liNode.childNodes[cj].nodeName == 'IMG'))
        return liNode.childNodes[cj];
    }
  }
  return null;
}

function treeNodeLoad()
{
  var url = treeConfig.loadDir + treeNodeLoading.next + treeConfig.xmlExt;

  if (treeNodeLoading != null)
  {
    if (window.XMLHttpRequest)
    {
      try
      {
        treeNodeXmlDoc = new XMLHttpRequest();
        if (treeNodeXmlDoc != null)
        {
          treeNodeXmlDoc.open("GET", url, true);
          treeNodeXmlDoc.onreadystatechange = treeNodeXmlHttpLoader;
          treeNodeXmlDoc.send(null);
        }
      }
      catch (e)
      {
      }
    }
    else if (document.implementation && document.implementation.createDocument)
    {
      treeNodeXmlDoc = document.implementation.createDocument("", "", null);

      if (treeNodeXmlDoc.addEventListener)
        treeNodeXmlDoc.addEventListener("load", treeNodeLoaded, false);
      treeNodeXmlDoc.load(url);
    }
    else if (window.ActiveXObject)
    {
      treeNodeXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      treeNodeXmlDoc.onreadystatechange = treeNodeLoader;
      treeNodeXmlDoc.load(url);
    }
    else
    {
      return null;
    }
  }
}


function treeNodeLoader()
{
  if (treeNodeXmlDoc.readyState == 4)
    treeNodeLoaded();
}

function treeNodeXmlHttpLoader()
{
  if (treeNodeXmlDoc.readyState == 4) 
  {
    if (treeNodeXmlDoc.status == 200) 
    {
      treeNodeXmlDoc = treeNodeXmlDoc.responseXML;
      treeNodeLoaded();
    } 
  }
}

function treeNodeLoaded()
{
  var tmpNode = treeNodeLoading;
  var tmpDoc  = treeNodeXmlDoc;
  treeNodeLoading = null;
  treeNodeXmlDoc  = null;
  tmpNode.onLoaded(tmpDoc);
}


function waggleNode()
{
  toggleNode(this, null);
}

function Viewer(doc, path)
{
  this.doc  = doc;
  this.path = path;
}

function viewNode(doc, path)
{
  if (doc && path && doc.getElementById)
  {
    var slash   = path.indexOf('/');
    var top = null;
    if (slash != -1)
      top = path.substring(0, slash);
    else
      top = path;
		  
    var node = doc.getElementById(top);
    if (node)
    {
      if (!(node.tree))
        node.tree = new Tree(node);
      node.tree.view = path.substring(1);
      node.tree.expand();
    }
  }
}

function expandNode(node, url)
{
  if (!(node.tree))
    node.tree = new Tree(node, url);

  if (node.childUl() == null)
    node.tree.onClick();

  node.tree.expand();
}

function toggleNode(node, url)
{
  if (!(node.tree))
    node.tree = new Tree(node, url);
  node.tree.onClick();
}

function clickTreeToggle()
{
  this.previousSibling.onclick();
}

function constructTree(node, next)
{
  node.tree    = new Tree(node, next);
  if (node.addEventListener == null)
    node.onclick = waggleNode;
  else
    node.addEventListener("click", waggleNode, false);
}

function Tree(node, next)
{
  this.node     = node.parentNode;
  this.onLoaded = treeLoaded;
  this.loading  = null;
  
  this.id       = node.id.substring(1);
  if (next)
    this.next   = next;
  else
    this.next   = this.id;

  this.children = null;
  this.expand   = treeExpand;
  this.collapse = treeCollapse;
  this.childUl  = treeGetChildUl;

  var ul = this.childUl();
  if (ul == null)
  {
    if (treeLoadingSupported == true)
      this.onClick = treeLoad;
    else
      this.onClick = treeNoLoad;
  }
  else
    this.onClick = treeToggle;
}

function treeClick()
{
  if (this.node && this.node.childNodes)
  {
    for (var cj=0;cj< this.node.childNodes.length;cj++)
    {
      if ((this.node.childNodes[cj].nodeName == 'a') ||
          (this.node.childNodes[cj].nodeName == 'A'))
      {
        var aNode = this.node.childNodes[cj];
        aNode.click();
        return;
      }
    }
  }
}

function treeLoad()
{
  if ((this.xmlDoc == null) && 
      (treeNodeLoading == null) &&
      document.createElement && 
      document.createTextNode)
  {
    treeNodeLoading = this;
    this.loading = document.createElement('ul');
    this.onClick = treeToggle;

    var listItem = document.createElement('li');
 
    var loadingImage = document.createElement('img');
    loadingImage.setAttribute('src', treeConfig.link);
    loadingImage.setAttribute('alt', '*');
    listItem.appendChild(loadingImage);

    var textNode = document.createTextNode("loading...");
    listItem.appendChild(textNode);
    this.loading.appendChild(listItem);
    this.node.appendChild(this.loading);

    treeNodeLoad();
  }
}

function treeFrameLoad()
{
  var nid = treeNodeLoading.next;
  var slash = nid.lastIndexOf('/');
  if (slash != -1)
    nid = nid.substring(slash + 1, nid.length);

  treeNodeLoading.nid = nid;

  var url = treeConfig.loadDir + nid + treeConfig.xmlExt;
  
  var create = (!document.getElementById('treeFrameDiv'+nid));

  if (create)
  {
    xmlDoc = document.createElement('div');
    xmlDoc.id = 'treeFrameDiv';
    xmlDoc.style.visibility = 'hidden'; 
    xmlDoc.style.position = 'absolute';
    xmlDoc.style.top = '0px'; 
    xmlDoc.style.left = '0px';
    xmlDoc.innerHTML = '<iframe src="'+url+'" name="treeFrame'+nid+'" height="0" width="0"><\/iframe>';
  }

  if (!window.treeTimer) 
    window.treeTimer = window.setInterval('treeFrameLoader();',100); 

  if (create)
    document.body.appendChild(xmlDoc);


  return true;
}

function treeFrameLoader()
{
  var frameName = 'treeFrame' + treeNodeLoading.nid;

  if (window.frames[frameName].document)
  {
    window.clearInterval(window.treeTimer);
    window.treeTimer = null;
    treeFrameLoaded();
  }
}

function treeFrameLoaded()
{
  var tmpNode = treeNodeLoading;
  var tmpDoc  = window.frames['treeFrame' + treeNodeLoading.nid].document;
  var div = document.getElementById('treeFrameDiv' + treeNodeLoading.nid);
  treeNodeLoading = null;
  treeNodeXmlDoc  = null;
  tmpNode.onLoaded(tmpDoc);
}


function treeNoLoad()
{
  if (!document.createElement || !document.childNodes)
    return;

  if ((this.xmlDoc == null) && 
      (treeNodeLoading == null) &&
      document && document.location)
  {
    treeNodeLoading = this;

    if (document.createTextNode)
    {
      this.loading = document.createElement('ul');
      this.onClick = treeToggle;

      var listItem = document.createElement('li');
 
      var loadingImage = document.createElement('img');
      loadingImage.setAttribute('src', treeConfig.link);
      loadingImage.setAttribute('alt', '*');
      listItem.appendChild(loadingImage);

      var textNode = document.createTextNode("loading...");
      listItem.appendChild(textNode);
      this.loading.appendChild(listItem);
      this.node.appendChild(this.loading);
    }

    if (this.id)
    {
      treeFrameLoad()
/*
      var h    = document.location.pathname;
      var root = h.substring(0, h.lastIndexOf("/") + 1);
      document.location = root + this.id + ".htm#" + this.id;
*/
    }
  }
}


function treeToggle()
{
  if (this.node)
  {
    var ulNode = this.childUl();

    if (ulNode != null)
    {
      var expanded = ulNode.style.display != 'none';
  
      if (expanded)
        this.collapse();
      else
        this.expand();
    }
  }
}

function treeExpand()
{
  if (this.node)
  {
    var ulNode = null;
    var imgNode = null;
    for (var cj=0;cj< this.node.childNodes.length;cj++)
    {
      if ((this.node.childNodes[cj].nodeName == 'ul') ||
          (this.node.childNodes[cj].nodeName == 'UL'))
      {
        ulNode = this.node.childNodes[cj];
        if (ulNode.style.display == 'block')
        {
          if (this.view == null)
          {
            return;
          }
        }
      }
      else if ((this.node.childNodes[cj].nodeName == 'img') ||
               (this.node.childNodes[cj].nodeName == 'IMG'))
      {
        imgNode = this.node.childNodes[cj];
      }
    }

    if (ulNode != null)
    {
      if (this.children)
      {
        for (var j=0;j< this.children.length;j++)
        {
          var child = this.children[j];
          if (child)
          {
            var match = (this.view != null) && 
              (child.id.length <= this.view.length) &&
              (((child.id.length == this.view.length) && 
                (child.id == this.view)) ||
               ((this.view.substring(0, child.id.length) == child.id) &&
                (this.view.charAt(child.id.length) == '/')));
            if (match == true)
            {
              child.view = this.view;
              child.expand();
            }
            else
              child.collapse();
          }
        }
  
        this.view = null;
        ulNode.style.display = 'block';
        if (imgNode != null)
        {
          imgNode.setAttribute('src', treeConfig.minus);
          imgNode.setAttribute('alt', '-');
        }
        return;
      }
      else if (ulNode.childNodes)
      {
        var children = new Array(ulNode.childNodes.length);
        for (var cj=0;cj< ulNode.childNodes.length;cj++)
        {
          var childNode = ulNode.childNodes[cj];

          var childUl = getChildUl(childNode);
          if (childUl)
          {
            var childImg = getChildImg(childNode);
            if (childImg) 
            {
              if (!(childImg.tree))
                childImg.tree = new Tree(childImg);

              children[cj] = childImg.tree;
            }
          }
          else
            children[cj] = null;

          var child = children[cj];
          if (child)
          {
            var match = (this.view != null) && (child.id) &&
              (child.id.length <= this.view.length) &&
              (((child.id.length == this.view.length) && 
                (child.id == this.view)) ||
               ((this.view.substring(0, child.id.length) == child.id) &&
                (this.view.charAt(child.id.length) == '/')));
            if (match == true)
            {
              child.view = this.view;
              child.expand();
            }
            else
              child.collapse();
          }
        }

        this.children = children;
        this.view = null;
        ulNode.style.display = 'block';
        if (imgNode != null)
        {
          imgNode.setAttribute('src', treeConfig.minus);
          imgNode.setAttribute('alt', '-');
        }
        return;
      }
    }
    else
    {
      this.onClick();
    }
  }
}

function treeCollapse()
{
  if (this.node)
  {
    for (var cj=0;cj< this.node.childNodes.length;cj++)
    {
      if ((this.node.childNodes[cj].nodeName == 'ul') ||
          (this.node.childNodes[cj].nodeName == 'UL'))
      {
        var ulNode = this.node.childNodes[cj];
        if (ulNode.style.display == 'none')
          return;
        else
          ulNode.style.display = 'none';
      }
      else if ((this.node.childNodes[cj].nodeName == 'img') ||
               (this.node.childNodes[cj].nodeName == 'IMG'))
      {
        var imgNode = this.node.childNodes[cj];
        imgNode.setAttribute('src', treeConfig.plus);
        imgNode.setAttribute('alt', '+');
      }
    }
  }
}

function treeLoaded(xmlDoc)
{
  if (this.loading != null)
  {
    var unorderedList = this.loading;
    this.loading = null;

    unorderedList.removeChild(unorderedList.firstChild);

    if (xmlDoc.documentElement && 
        xmlDoc.documentElement.tagName && 
        xmlDoc.documentElement.tagName.toUpperCase() == 'HTML' ) 
      return false;

    for (var xj=0; xj < xmlDoc.childNodes.length;xj++)
    {
      if (xmlDoc.childNodes[xj].nodeName == 'treefragment')
      {
        var tree = xmlDoc.childNodes[xj];
        for (var cj=0;cj< this.node.childNodes.length;cj++)
        {
          if ((this.node.childNodes[cj].nodeName == 'img') ||
              (this.node.childNodes[cj].nodeName == 'IMG'))
          {
            var imgNode = this.node.childNodes[cj];
            if (tree.childNodes.length > 0)
            {
              imgNode.setAttribute('src', treeConfig.minus);
              imgNode.setAttribute('alt', '-');
            }
            else
            {
              imgNode.setAttribute('src', treeConfig.link);
              imgNode.setAttribute('alt', '*');
            }
            break;
          }
        }
        this.children = buildTree(document, tree, unorderedList, this.id, this.view);
      }
    }
  }
}

function buildTree(document, tree, level, id, view)
{
  var match = (view != null) &&  (id == view);

  var submatch = (view != null) && 
                 (id.length < view.length) &&
                 (view.substring(0, id.length) == id) &&
                 (view.charAt(id.length) == '/');

  if (submatch == true)
    level.style.display = 'block';

  var children = new Array(tree.childNodes.length);

  for (var j = 0; j < tree.childNodes.length;j++)
  {
        var child = tree.childNodes[j];

        if (child.nodeType != 1) continue;
        if (child.nodeName != "node") continue;

        var childId   = child.getAttribute('id');
        var childId2   = id+'/'+childId;
        var submatch2 = (view != null) && 
                 (childId2.length < view.length) &&
                 (view.substring(0, childId2.length) == childId2) &&
                 (view.charAt(childId2.length) == '/');

        var next      = child.getAttribute('next');
        var href      = child.getAttribute('href');
        var text      = child.getAttribute('text');
        var className = child.getAttribute('class');

        var listItem  = document.createElement('li');
        var imgNode   = document.createElement('img');
        var textNode  = document.createTextNode(text);
        var link      = document.createElement('a');
        var matchid   = id + "/" + childId;

        imgNode.setAttribute('id', '_' + matchid);
	if (className != null)
	{
          link.className = className;
          link.setAttribute('class', className);
	}

        link.setAttribute('title', text);
        link.appendChild(textNode);
        listItem.appendChild(imgNode);
        listItem.appendChild(link);

        if (next != null && next.length != 0)
        {
          constructTree(imgNode, next);
          imgNode.setAttribute('src', treeConfig.plus);
          imgNode.setAttribute('alt', '+');
        }
        else if (child.childNodes.length != 0)
        {
          constructTree(imgNode, next);
          imgNode.tree.onClick = treeToggle;
          imgNode.setAttribute('alt', '+');
          imgNode.setAttribute('src', treeConfig.plus);
          var nextLevel = document.createElement('ul');
          nextLevel.style.display = 'none';

          if (submatch == true)
            imgNode.tree.children = buildTree(document, child, nextLevel, matchid, view);
          else
            imgNode.tree.children = buildTree(document, child, nextLevel, matchid, null);

          listItem.appendChild(nextLevel);
        }
        else
        {
          imgNode.setAttribute('src', treeConfig.link);
          imgNode.setAttribute('alt', '*');
        }

        if (submatch2 == true && imgNode.tree.children == null)
        {
          imgNode.tree.onClick();
        }

        if (imgNode.tree)
          children[j] = imgNode.tree;
        else
          children[j] = null;

        if (href == null)
        {
          if (link.addEventListener == null)
            link.onclick = clickTreeToggle;
          else
            link.addEventListener("click", clickTreeToggle, false);
        }
        else
        {
          // AQ 28-Feb-03 Check for targetFrame and hrefPrefix
          if (treeConfig.targetFrame != null)
            link.setAttribute('target', treeConfig.targetFrame);

          if (treeConfig.hrefPrefix == null)
            link.setAttribute('href', href);
          else
          {
            var id = new String(childId);
            if (id.length > 1)	
            {
              if (id.charAt(0) == "_")
		id = id.substring(1, id.length);
            }
            link.setAttribute('href', treeConfig.hrefPrefix + id);
          }
        }

        level.appendChild(listItem);
  }

  if (match && level.scrollIntoView)
    level.scrollIntoView();

  return children;
}


/*  font size and stylesheet preference */
function setActiveStyleSheet(title) 
{
   var i, a, main;
   for (i=0; (a = document.getElementsByTagName("link")[i]); i++) 
   {
     if (a.getAttribute("rel").indexOf("style") != -1 && 
         a.getAttribute("title")) 
     {
       a.disabled = true;
       if (a.getAttribute("title") == title) 
         a.disabled = false;
     }
   }
}

function getActiveStyleSheet() 
{
  var i, a;
  for (i=0; (a = document.getElementsByTagName("link")[i]); i++) 
  {
    if (a.getAttribute("rel").indexOf("style") != -1 && 
        a.getAttribute("title") && !a.disabled) 
      return a.getAttribute("title");
  }
  return null;
}

var newFontSize = "100%";
var newFontFamily = "";

function setInitialFontSize()
{
  // var fontFamily = readCookie('fontFamily');
  // setFontFamily(fontFamily);
  var fontSize = readCookie('fontSize');
  setFontSize(fontSize);
  setInverseFontSize(fontSize);
  setExampleFontSize(fontSize);
  setFontSizeOption(fontSize);
  // setFontFamilyOption(fontSize);
}

function applyFontSize()
{
  setFontSize(newFontSize);
  setInverseFontSize(newFontSize);
  // setFontFamily(newFontFamily);
}

function setFontSize(size)
{
  if (size != null)
  {
    document.body.style.fontSize = size;
    createCookie('fontSize', size, 3650);
  }
  else
    eraseCookie('fontSize');
}

function setFontFamily(family)
{
  if (family != null)
  {
    document.body.style.fontFamily = family;
    createCookie('fontFamily', family, 3650);
  }
  else
    eraseCookie('fontFamily');
}

function setInverseFontSize(size)
{
  if (document.getElementById)
  {
    if (size != null)
    {
      var inv = 10000/(parseInt(size));
      document.getElementById('fonts').style.fontSize = inv.toString() + "%";
    }
  }
}

function setFontFamilyOption(family)
{
  if (document.getElementById)
  {
    var form = document.getElementById('fonts');
    if ((form != null) && (form.ff))
    {
      if (family != 0)
      {
        for (var i = 0; i < form.ff.length; ++i)
          form.ts[i].checked = (form.ff[i].value == family);
      }
    }
  }
}

function setExampleFontFamily(family)
{
  if (document.getElementById)
  {
    if (family != null)
    {
      newFontFamily = family;
      document.getElementById('example').style.fontFamily = family;
    }
  }
}

function setFontSizeOption(size)
{
  if (document.getElementById)
  {
    var form = document.getElementById('fonts');
    if ((form != null) && (form.ts))
    {
      var sz = (size != null) ? parseInt(size) : parseInt(newFontSize);

      if (!isNaN(sz))
      {
        for (var i = 0; i < form.ts.length; ++i)
          form.ts[i].checked = (form.ts[i].value == sz);
      }
    }
  }
}

function setExampleFontFamily(family)
{
  if (document.getElementById)
  {
    if (family != null)
    {
      newFontFamily = family;
      document.getElementById('example').style.fontFamily = family;
    }
  }
}

function setExampleFontSize(size)
{
  if (document.getElementById)
  {
    if (size != null)
    {
      newFontSize = size;
      var fontSize = readCookie('fontSize');
      if (fontSize == null)
        fontSize = "100%";
      var fs = parseInt(size) * 100/parseInt(fontSize);
      document.getElementById('example').style.fontSize = fs.toString() + "%";
    }
  }
}

function createCookie(name,value,days)
{
  if (days)
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else 
    var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  if (document.cookie != null)
  {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; ++i)
    {
      var c = ca[i];
      while (c.charAt(0)==' ') 
        c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0)   
        return c.substring(nameEQ.length,c.length);
    }
  }
  return null;
}

function eraseCookie(name)
{
  createCookie(name,"",-1);
}


function onLoadSetFontSize(e) 
{
  var fontSize = readCookie('fontSize');
  if (fontSize != "100%")
    setFontSize(fontSize);
  var fontFamily = readCookie('fontFamily');
  if (fontFamily != null && fontFamily != '')
    setFontFamily(fontFamily);
}

loaders.push(onLoadSetFontSize);

function focusLogin()
{
  var fontSize = readCookie('fontSize');
  if (fontSize != "100%")
    setFontSize(fontSize);
  if (document.getElementById)
  {
    var email = document.getElementById('UserEmail');
    if (email && email.focus)
      email.focus();
  }
}

/* tooltips */

function showTooltip(evt, tip)
{
  if (tip != null)
  {
    if (tip.tooltip == null && tip.childNodes)
    {
      var args = new Array();
      for (var a = 2; a < arguments.length; ++a)
      {
        var node = document.getElementById(arguments[a]);
        if (node != null)
          args.push(node);
      }

      tip.tooltip = new Tooltip(tip, args);
      tip.tooltip.popup(evt);
    }
    else
      tip.tooltip.popup(evt);
  }
}

function hideTooltip(tip)
{
  if (tip != null && tip.tooltip != null)
    tip.tooltip.hide();
}

function moveTooltip(evt)
{
  if (this != null && this.tooltip != null)
    this.tooltip.move(evt);
}

function Tooltip(tip, nodes) 
{
  this.link  = tip;
  this.node  = document.createElement('div');
  this.node.className = 'tooltip';
  this.node.setAttribute('class', 'tooltip');

  for (var c = 0; c < nodes.length; ++c)
  {
    var target = nodes[c];
    if (target)
    {
      var item = document.createElement('p');
      for (var i = 0; i != target.childNodes.length; ++i)
      {
        var clone = target.childNodes[i].cloneNode(true);
        item.appendChild(clone);
      }
      this.node.appendChild(item);
    }
  }

  document.getElementById('pC').appendChild(this.node);
}

Tooltip.prototype.popup = function (evt)
{
  this.move(evt);

  if (this.link.addEventListener == null)
    this.link.onmousemove = moveTooltip;
  else
    this.link.addEventListener("mousemove", moveTooltip, false);

  this.node.style.display  = 'block';
}


Tooltip.prototype.hide = function ()
{
  this.node.style.display = 'none';

  if (this.link.removeEventListener == null)
    this.link.onmousemove = null;
  else
    this.link.removeEventListener("mousemove", moveTooltip, false);
}

Tooltip.prototype.getStyle = function (obj, property)
{
  if (obj.currentStyle)
  {
    var ar = property.match(/\w[^-]*/g);
    var s = ar[0];

    for (var i = 1; i != ar.length; ++i)
      s += ar[i].replace(/\w/, ar[i].charAt(0).toUpperCase());

    return obj.currentStyle[s]
  }
  else if (document.defaultView.getComputedStyle)
    return document.defaultView.getComputedStyle(obj, null).getPropertyValue(property);
}

Tooltip.prototype.move = function (evt)
{
  if (evt == null)
    evt = event;

  if (evt != null)
  {
    var top       = 0;
    var left      = 0;
    var width     = 200;
    var winwidth  = 0;

    if (window.pageXOffset != null)
    {
      winwidth  = parseInt(this.getStyle(document.documentElement, 'width'));
      left      = parseInt(evt.pageX) + 10;
      top       = parseInt(evt.pageY) + 20;
    }
    else if (document.documentElement.scrollTop != null)
    {
      winwidth  = parseInt(document.documentElement.clientWidth);
      left      = parseInt(evt.x) + 10 + parseInt(document.documentElement.scrollLeft);
      top       = parseInt(evt.y) + 20 + parseInt(document.documentElement.scrollTop);
    }
    else if (document.body.scrollLeft != null)
    {
      winwidth  = parseInt(document.body.clientWidth);
      left      = parseInt(evt.x) + 10 + parseInt(document.body.scrollLeft);
      top       = parseInt(evt.y) + 20 + parseInt(document.body.scrollTop);
    }

    if (width > (winwidth * 0.75))
    {
      width = winwidth * 0.75;
    }

    if (left < 0)
      left = 0;
    else if ((left + width) > winwidth)
      left = winwidth - width - 10;

    if (top < 0)
      top = 0;

    this.node.style.left  = left + "px";
    this.node.style.width = width + "px";
    this.node.style.top   = top + "px";
    this.node.style.lineHeight = '1em';
  }
}

function gaLoad (acct) {
  var host = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  var s = document.createElement('script');
  s.src = host + 'google-analytics.com/ga.js';
  s.type = 'text/javascript';
  s.onloadDone = false;
  function init () {
    try { var p = _gat._getTracker(acct); p._trackPageview(); }
    catch(err) { };
  }
  s.onload = function () {
    s.onloadDone = true;
    init();
  };

  s.onreadystatechange = function() {
    if (('loaded' === s.readyState || 'complete' === s.readyState) && !s.onloadDone) {
      s.onloadDone = true;
      init();
    }
  };

  document.getElementsByTagName('head')[0].appendChild(s);
}

window.onload = function(e) 
{
  for (var i = 0; i < loaders.length; ++i)
    loaders[i]();
}

