var varHideSubMenu = true;

function funGetXMLHTTPObject(varType, varTarget, varAsync, varPostVal)
  {
   var xmlHttp     = null;
   var strResponse = null;
   //code for Mozilla, etc.
     if (window.XMLHttpRequest)
         {
          xmlHttp  = new XMLHttpRequest();
         }
    //code for IE
      else if (window.ActiveXObject)
         {
          xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
         }
    //Open the Request
      xmlHttp.open(varType, varTarget, varAsync);
    //Ensure the Header Request is set
      xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    //Send the Request
      xmlHttp.send(varPostVal);
    //Recieve back the response
      strResponse  = xmlHttp.responseText;
    //Return the text
      return strResponse;
  }

  function funHoverLinkMenu(eleParentMenu)
  {
    //Set the Style on the Parent Menu Item
      eleParentMenu.style.color          = "#FFFF00";
      eleParentMenu.style.textDecoration = "underline";
    //Ensure the SubMenu is hidden
      var eleSubMenu = document.getElementById("divSubMenu");
      funOffSubMenuDiv(eleSubMenu);
  }
  
  function funOffLinkMenu(eleParentMenu)
  {
    //Set the Style on the Parent Menu Item
      eleParentMenu.style.color          = "#ffffff";
      eleParentMenu.style.textDecoration = "none";
  }

  function funClickMenuLink(eleLink, txtTarget)
  {
   //Clean up the Header incase they hit the back button
     funOffLinkMenu(eleLink);
     var eleSubMenu = document.getElementById("divSubMenu");
     eleSubMenu.style.display = "none";
   //Navigate to the link location
     eleNavForm        = document.getElementById("frmNavigate");
     eleNavForm.action = txtTarget;
     eleNavForm.submit();
  }
    
  function funHoverParentMenuDiv(eleParentMenu, txtSubMenuSourceId)
  {
    //Get the location for the sub menu
      varLeft = findTrueLeft(eleParentMenu);
      varTop  = findTrueTop(eleParentMenu) + eleParentMenu.offsetHeight;

    //Prep the SubMenu for Display
      var eleSubMenu            = document.getElementById("divSubMenu");
      var eleSource             = document.getElementById(txtSubMenuSourceId);
      //var strHttp               = funGetXMLHTTPObject("POST", txtSubMenuSource, false, "");
      eleSubMenu.innerHTML      = eleSource.innerHTML;
      eleSubMenu.style.left     = varLeft;
      eleSubMenu.style.top      = varTop;
      eleSubMenu.style.position = "absolute";
      varHideSubMenu            = true;

    //Show the SubMenu but wait for the old submenu to disappear first.
      var varClose = setTimeout("funShowSubMenu();",20);
  }

  function funShowSubMenu()
  {
   var eleSubMenu            = document.getElementById("divSubMenu");
   eleSubMenu.style.display  = "block";
  }
  
  function funOffParentMenuDiv(eleParentMenu)
  {
    //Set the Style on the Parent Menu Item
      eleParentMenu.style.color          = "#ffffff";
      eleParentMenu.style.textDecoration = "none";
    //Hide the SubMenu if it's not in use.
      var varClose = setTimeout("funCheckToHideSubmenuDiv();",10);
  }

  function funCheckToHideSubmenuDiv()
  {
   if (varHideSubMenu)
      {
       var eleSubMenu = document.getElementById("divSubMenu");
       eleSubMenu.style.display = "none";
      }
  }
  
  function funHoverSubMenuDiv(eleSubMenu)
  {
   varHideSubMenu = false;
   eleSubMenu.style.display = "block";
  }

  function funOffSubMenuDiv(eleSubMenu)
  {
   varHideSubMenu = true;
   eleSubMenu.style.display = "none";
  }
  
  
  function findTrueLeft(eleTarget)
  {
    var varLeft = 0;
    while (eleTarget.offsetParent)
    {
      varLeft += eleTarget.offsetLeft;
      eleTarget = eleTarget.offsetParent;
    }
    return varLeft - 7;
  }

  function findTrueTop(eleTarget)
  {
    var varTop = 0;
    while (eleTarget.offsetParent)
    {
      varTop += eleTarget.offsetTop;
      eleTarget = eleTarget.offsetParent;
    }
    return varTop;
  }