
function loadMenuData() 
{
    try 
    {
        var dynHelps = document.all("divDynamicHelp");
        if(dynHelps == null)
            return;
        if (dynHelps.length == undefined)
            dynHelps = new Array(dynHelps);
        //get menu path
        var ocxObject = new ActiveXObject("ADDYNHELP.AdDynHelpCtrl.1");
        if (ocxObject == null)
            return;
        var strObj = "<object height=\"0\" width=\"0\" id=\"AdDynHelp\" CLASSID=\"clsid:C4B6CE2E-5743-4450-B798-5BE5CEC3BE9D\"></object>";
        dynHelps[0].innerHTML = strObj + dynHelps[0].innerHTML;
        //invoke the mothod of ActiveX control
        var menuPath = (document.getElementById("AdDynHelp")).GetDynHelpFile(getcurpath());
        //define XMLDOMdocument object to analyse the xml file
        var objxml = new ActiveXObject("MSXML2.DOMDocument.3.0");
        objxml.async=false;
        objxml.load(menuPath);
        objxml.setProperty("SelectionLanguage","XPath");
        if (objxml.parseError.errorCode != 0)
            return;
        for (j=0; j<dynHelps.length; j++)
        {
            var dynHelp = dynHelps[j];

            //According to menu's ID in HTML to determine which menu to load in HTML from xml file
            var value = objxml.selectSingleNode("//MenuItem[@ID='" + dynHelp.title + "']");
            var defaultContent=dynHelp.all("DefaultContent");
            if(value!=null)
            {
                var result;
                var re=/:/g;
                result=(value.text).replace(re,"&nbsp;<span class=\"glyphArrow\"><img src=\"images\\ac.menuaro.gif\"></span>");
                //Within the Default Content Node - there are two types of data
                //  1. uis-unspecified tagged text that needs to be replaced
                //  2. plain text
               if(defaultContent.childNodes != null)
                {
                    var children = defaultContent.childNodes;
                    for(i=0;i<=children.length; i++)
                    {
                        var thisNode = defaultContent.childNodes[i];
                        if(thisNode.className=="uis-unspecified") 
                        {
                              defaultContent.removeChild(thisNode);
                        }
                    }
                    var dynText = value.text;
                    var indexOfFirstColon = dynText.indexOf(":");
                    if(indexOfFirstColon != -1)
                    {
                        var splitDynText1 = dynText.substr(0,indexOfFirstColon);
                        var splitDynText2 = dynText.substr(indexOfFirstColon,dynText.length-1);
                        result = splitDynText1 + defaultContent.innerText + splitDynText2;
                        result = result.replace(re,"&nbsp;<span class=\"glyphArrow\"><img src=\"images\\ac.menuaro.gif\"></span>");
                    }
                }
                defaultContent.innerHTML = result;
            }
            else 
            {
                var altContent = dynHelp.all("AltContent");
                if( altContent != null &&
                    altContent.innerHTML !=null &&
                    altContent.innerHTML != "" && 
                    altContent.innerHTML != " ")
                {
                    var relatedContentElements = dynHelp.all("RelatedContent");
                    relatedContentElements[0].className="RelatedContentHidden";
                    relatedContentElements[1].className="RelatedContentHidden";
                    altContent.className="RelatedContent";
                    defaultContent.className="RelatedContentHidden";
                }
            }
        }
    }
    catch(exception)
    {
        // check for "Automation server can't create object"
        if (exception.number & 0x7FFFFFFF == 0x000A01AD)
        {
                  
        }
    }
}

if(window.onload==null)
{
    window.onload=loadMenuData;
}
else
{
    var fnOnload=window.onload;
    window.onload=function(){loadMenuData();fnOnload();}
}

// Gets the Full external path to this CHM File
function getcurpath () 
{
    var path = unescape(location.pathname);
    if( path.indexOf("@MSITStore:") == 0 ) 
    {
        path = path.substring(11,path.length);
    }
    if( path.indexOf("/") == 0 ) 
    {
        path = path.substring(1,path.length);
    }
    var i = path.lastIndexOf("::\\");
    if (i>0)
        path = path.substring(0,i);
    i = path.lastIndexOf("\\")
    path = path.substring(0,i+1);
    return path;
}
