// =======================================================================
// === TocTree Functions
// === Copyright  Dassault Systemes / Pierre SMEYERS (Jan 30 2006)
// =======================================================================
// === This Javascript Library contains functions used by the TocTree
// === frame of the doc portal.
// === This frame displays the TOC (Table Of Content) as a tree, and
// === maintains a synchronization between the tree view and the main doc
// === frame.
// === Basically, this library contains functions to:
// ===  - build and update the TOC tree,
// ===  - expand and select a node in the TOC tree.
// =======================================================================
// 2006 jul 13 jfs
// 2007 jul 13 jfs replace collapseLeftSide(1) by collapseLeftSide(0)
// 2009 mar 06 jfs update list of media checkvisibility
// 2009 dec 10 vd1 ExpandAll/CollapseAll   
//                 Shows a tooltip to perform ExpandAll/CollapseAll 
//                 Functionality: when user hovers mouse cursor over a TOC Anchor (Plus sign/Minus Sign)
//                 it will show a tooltip which contains a link to show ExpandAll/CollapseAll.
//                 If user clicks on this link it will Expand/Collapse all level children which belong to this node.
// 2010 jan 05 vd1 to resolve problem of TOC sync
//                 new functionality added to check existence of file mentioned in href attribute of ITEM tag if checkvisibility is TRUE.
// 2010 ??? ?? vd1 ExpandAll/CollapseAll functionality removed on IE because it hangs

// 2010 May 05 PH7 Nodes in TOC don't appear(In Enovia_LC for SDS product installation only). Problem with code handling DITEM.
// 2010 Oct 20 PH7 If child nodes do not exist then also the parent node is not displayed.
//                 Implemented the NEW SPECIFICATION that a parent node will be displayed
//                 only when its page exists and at least one of its node is present 
//                 if its checkVisibility is true (which is the default value)
// 2010 Oct 27 JFS Replace SOLIdx files by InstalledList.txt for full-xml release
// 2010 Nov 4  JFS IR-079327V6R2012 Add dir attribute to <ITEM> elements to check visibility
// 2011 Jan 17 JFS Remove Brand nodes also (remove test on parent=="Root")
// 2011 Jan 24 JFS IR-092289V6R2012 new checkVisibility function
// 2011 Feb 16 JFS new media attribute for <DITEM> elements to link visibility to media installation
// 2011 Feb 25 JFS new media attribute for <ITEM> elements also
// 2011 Mar 18 V2E IR-095347V6R2012x Checking folder(module) existence instead of file existence 
// 2011 Mar 21 JFS IR-095347V6R2012x Update Vilas' fix
// 2011 Nov 30 V2E R-140321V6R2013 Expand All functionality does not work for all chapters
//             Problem : name attribute is used to check whether it is a product node or not in DITEM
//             Solution : href attribute is considered instead of name
// 2012 Jan 4  V2E restore HITEM management for CAA
// 2012 June 27th XWY : Performance improvement for abaqus manual
// 2012 Jul 2 V2E IR-154927V6R2013x : Links from Overview pages in V6 documentation take a long time to resolve in IE.
//            Solution : Changed algorthm in such a way that file link is checked loaded document and then makeTOCChildItems is called  
// 2013 May 14 V2E : parameter to open <DITEM> nodes at start
// 			  Solution : When expandOn attribute is set then onclick event of that DITEM node is dispatched.
// 2013 Jul 25 V2E : Display nodes depending on scope, filter parameters.
//                  notmedia attribute also handled 
// 2013 October 30 V2E : Display node depending on contextScope,OfferingScope parameters
// 2013 October 31 JFS : Add default values for contextscope and offeringscope parameters. Add "all" value for contextscope attribute. Add 'noswx' management
// 2014 March 12 V2E : When show parameter is passed do not trigger onClickTocItem event.
// =======================================================================
/*
function buildRelativeLink(locationObj, relativeToLocObj)
ok function resolveImports(node)
function getDItemFromDir(dir)
ok function getNavNodeInfo(node)
ok function getTOCItemFromURL(locationObj)
ok function initTOC()
ok function makeTOCItem(tbodyObj, node)
ok function makeTOCChildItems(containerObj, node)
ok function loadChildrenIfNeeded(rowObj, asynch)
tempo function rebuildSiteMapStructure(doc, parentElt)
ok function onClickTocAnchor(evt)
ok function onClickTocItem(evt)
ok function unselectTocItem()
ok function isCurrentFileSelected()
ok function selectCurrentFile()
*/
// =======================================================================
/**
* Global Variables:
*  - TOC_DATA: contains the TOC XML structure
*  - TOC_SELECTED_ITEM_ROW: the current selected node in the TOC tree 
*  - TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM(TOC row Object): Second level parent for currently selected item.
*  - isClickedOnTOCItem(boolean): tells whether user clicked on a TOC node in TOC tree.
*/
var TOC_DATA = null;
// V2E : IR-031132
// ditemTOC stores the DITEM nodes of TOC
var ditemTOC = null;
var TOC_SELECTED_ITEM_ROW = null;
var http = getHTTPObject();
// HFJ for HITEM
var modifiedDisplayAttributeArray = "";
// HFJ for Reference Node
var referencenodeArray = "";
var globalTOCrowObj = null;
var eventTocItem = false;
var count = 0;
// HFJ for Child Node
var lastDomObj = null;
// HFJ
var globalLastDomObj = null;
// HFJ for checkvisibility
var CV_array = new Array();
var TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM = null;
var isClickedOnTOCItem = false;
var abqPageMap = null; // XWY: --- pauseOnLoad:  association list of child pages to parents; used to open ToC tree as needed
// V2E : 25-Jul-2013
// For scope and filter parameters
var offeringScope;
var contextScope;
var requiredFilter;

// -----------------------------------------------------------------------
/**
* Rebuilds the relative link from the current location
*/

//=========================================================================
//New Functionality added to perform ExpandAll/CollapseAll
// contains ExpandAll/CollapseAll link
var hintcontainer = null;
// anchor object when user place mouse cursur on TOC Anchor
var anchorObj;
// boolean var to know mouse is inside tooltip
var onHintContainer;

//--------------------------------------------------------------------------
// function to check dir attribute
function checkVisibility(bigString, stringToFind) {
    if (bigString.match("^" + stringToFind))
        return true;
    if (bigString.match("\n" + stringToFind))
        return true;
    //alert(stringToFind + " not found");
    return false;
}

//--------------------------------------------------------------------------
// function to check media attribute
function checkMediaVisibility(listOfModules, listOfMedia) {
    var reg = new RegExp("[ ,;]+", "g");
    var mediaArray = listOfMedia.split(reg);
    for (var i = 0; i < mediaArray.length; i++) {
        var media = mediaArray[i];
        if (listOfModules.match("^" + media))
            return true;
        if (listOfModules.match("\n" + media))
            return true;
        //alert(media + " not found");
    }
    return false;
}

//--------------------------------------------------------------------------
/*
* Accepts the URL and returns the module name from URL  
* if module name is not present then returns NULL  
*/
function getModuleName(url) {
    var endIndex;
    endIndex = url.indexOf("/");
    if (endIndex == -1)
        return null;
    else
        return url.substring(0, endIndex);
}

//--------------------------------------------------------------------------------
// function to show tooltip
function showHint(evt) {
    var appName = navigator.appName;
    // To do not show ExpandAll/CollapseAll option in IE
    //if (!(appName.indexOf("Microsoft") != -1)) {
    anchorObj = window.event ? event.srcElement : evt.target;
    if (hintcontainer != null)
        hintcontainer.style.display = "none"
    hintContainer = null;
    hintcontainer = document.createElement("div");
    hintcontainer.className = "hintstyle";
    // take position of anchorObj to show tooltip
    var position = getAbsPos(anchorObj);
    // define position of tooltip
    hintcontainer.style.top = position[1] + 8 + "px";
    hintcontainer.style.left = position[0] + 7 + "px";

    // create link object to show ExpandAll/CollapseAll
    var expandLink = document.createElement("A");
    hintcontainer.appendChild(expandLink);
    expandLink.className = "hinttext";
    var tmpHtml;
    if (anchorObj.src.endsWith("FrameImages/DSDocIcon_tocPlus.png")) {
        tmpHtml = "ExpandAll";
    } else if (anchorObj.src.endsWith("FrameImages/DSDocIcon_tocMinus.png")) {
        tmpHtml = "CollapseAll";
    }
    expandLink.href = "#";
    expandLink.innerHTML = tmpHtml;
    expandLink.onmouseover = onMouseOverLinkStyle;
    expandLink.onmouseout = onMouseOutLinkStyle;
    expandLink.onmouseout = hideHint;
    // to perform ExpandAll when user click on ExpandAll link
    if (tmpHtml == "ExpandAll")
        expandLink.onclick = onClickExpandAll;
    // to perform CollapseAll when user click on CollapseAll link
    else if (tmpHtml == "CollapseAll")
        expandLink.onclick = onClickCollapseAll;
    if (tmpHtml == "ExpandAll") {
        // V2E : IR-031132
        // Only for Product nodes then display "ExpandAll" 
        if (isProductNode(anchorObj))
            document.body.appendChild(hintcontainer);
    }
    else
        document.body.appendChild(hintcontainer);
    // to show tooltip when mouse is out of anchor obj and inside tooltip
    hintcontainer.onmouseover = removeHideHint;
    // to remove tooltip when mouse is out of tooltip
    hintcontainer.onmouseout = hideHintOnMouseOut;
}

// V2E : IR-031132
// This function determines current node is product Node or NOT
function isProductNode(anchorObj) {
    var rowNode = anchorObj.parentNode.parentNode;
    if (rowNode.childNodes[1].childNodes.length == 2) {
        var textChild = rowNode.childNodes[1].childNodes[1];
        var data = textChild.innerHTML;
        data = data.replace(/&nbsp;/g, " ");
        data = data.replace(/&amp;/g, "&");
        var temp = rowNode.getAttribute("id");
        // IR-140321V6R2013   
        try {
            // V2E : id=@href... 
            temp = temp.substring(5);
        }
        catch (e) {
        }
        for (var i = 0; i < ditemTOC.length; i++) {
            if (temp.toLowerCase() == ditemTOC[i].getAttribute("href").toLowerCase())
                return true;
        }
    }
    return false;
}

// function to remove tooltip
function hideHint() {
    if (hintcontainer != null)
        hintcontainer.style.display = "none";
    hintcontainer = null;
    anchorObj.onmouseout = hideHint;
}

// to change link display properties when mouse is over link
function onMouseOverLinkStyle() {
    onHintContainer = true;
    if (hintcontainer != null) {
        var expandLink = hintcontainer.getElementsByTagName("A")[0];
        expandLink.className = "hintlink";
    }
}

// to change link display properties when mouse is out of link
function onMouseOutLinkStyle() {
    if (hintcontainer != null) {
        var expandLink = hintcontainer.getElementsByTagName("A")[0];
        expandLink.className = "hinttext";
        onHintContainer = false;
    }
}

// function to prevent removal of tooltip if mouse cursur is out of anchorObj and inside tooltip 
function removeHideHint() {
    anchorObj.onmouseout = '';
}

// function to set remove tooltip on anchorObj when mouse is out of tooltip
function setHint() {
    anchorObj.onmouseout = hideHint();
}

// function to remove tooltip when mouse is out of tooltip
function hideHintOnMouseOut() {
    if (onHintContainer == true) {
    } else if (onHintContainer == false) {
        hideHint();
    }
}
//=========================================================================
function buildRelativeLink(locationObj, relativeToLocObj) {
    var loc_tokens = null;
    if (relativeToLocObj == null)
        relativeToLocObj = window.location;
    var curRootURL = relativeToLocObj.pathname;
    curRootURL = curRootURL.replace(/\\/g, "/");
    loc_tokens = curRootURL.split("/");
    // --- remove last token (the file)
    loc_tokens.splice(loc_tokens.length - 1, 1);
    // --- remove blank tokens
    while (loc_tokens.length > 0 && loc_tokens[0].length == 0)
        loc_tokens.splice(0, 1);

    // --- retrieve link href
    var link = locationObj.pathname;
    link = link.replace(/\\/g, "/");
    var linkTokens = link.split("/");
    // --- remove blank tokens
    while (linkTokens.length > 0 && linkTokens[0].length == 0)
        linkTokens.splice(0, 1);

    // --- compute relative link
    var idx = 0;
    while (loc_tokens[idx] == linkTokens[idx])
        idx++;
    // --- rebuild relative link
    var relLink = null;
    for (var j = idx; j < loc_tokens.length; j++)
        relLink = relLink == null ? ".." : relLink + "/..";
    for (var j = idx; j < linkTokens.length; j++)
        relLink = relLink == null ? linkTokens[j] : relLink + "/" + linkTokens[j];

    //DebugMessage("link: '"+link+"': "+linkTokens+" ("+linkTokens.length+" items) --> rel link: '"+relLink+"' (unmatch at "+idx+": '"+linkTokens[idx]+"'!='"+loc_tokens[idx]+"')");
    return relLink;
}

// =======================================================================
// === Navigation Structure Functions
// =======================================================================
// -----------------------------------------------------------------------
/**
* Resolves recursively all <IMPORT> tags in the given XMLToc node
*/
function resolveImports(node) {
    var path = parent.parent.document.URL;
    var filestring = "";
    var filestring1 = "";
    var tempArray;
    var destdir = "";
    if (path.match("//") && (!path.match("///"))) {
        path = path.replace(/\/\//, "///");
        path = path.replace(/\\/g, "/");
        relpath = path.substring(8, path.lastIndexOf('/') + 1);
        //relpath = "examples/SCM/jfsPRJ201DOC_Dev/ICONS/frame.doc/src/";
    }
    if (path.match("http:///")) {
        path = path.replace(/http:\/\/\//, "http://");
        relpath = path.substring(7, path.lastIndexOf('/') + 1);
    }

    var i = 0;
    while (i < node.childNodes.length) {
        if (node.childNodes[i].nodeType != 1) // nodeType = 1 : Element
        {
            i++;
            continue;
        }

        if (node.childNodes[i].nodeName == "IMPORT") {
            var importNode = node.childNodes[i];
            try {
                var newNode = loadXML(importNode.getAttribute("href")).getElementsByTagName('Root')[0];
                // --- add all children
                while (newNode.firstChild != null) {
                    var curchild = newNode.firstChild;
                    newNode.removeChild(curchild);
                    if (curchild.nodeType == 1 && curchild.nodeName != "parsererror")
                        node.insertBefore(curchild, importNode);
                }
            }
            catch (e) {
                // --- import XML not found
            }
            // --- now remove the IMPORT node
            node.removeChild(importNode);
        }

        // Dimport for file system
        // HFJ 27 july 2007 changed to else if after a mail request. 
        else if (node.childNodes[i].nodeName == "DIMPORT") {
            var xmlHttpRequest;
            try {
                var importNode = node.childNodes[i];
                destdir = node.childNodes[i].getAttribute("dir");
                var destdir1 = destdir;

                try {
                    destdir = relpath + "" + destdir;
                    var Fo = new ActiveXObject("Scripting.FileSystemObject");
                    var direct = Fo.GetFolder(destdir);
                    var FSo = new Enumerator(direct.Files);
                    for (i = 0; !FSo.atEnd(); FSo.moveNext()) {
                        if (FSo.item().type == "XML Document")
                            var file = FSo.item().name;
                        var fullfilename = destdir + "\\" + file;
                        try {
                            var newNode = loadXML(fullfilename).getElementsByTagName('Root')[0];
                            while (newNode.firstChild != null) {
                                var curchild = newNode.firstChild;
                                newNode.removeChild(curchild);
                                if (curchild.nodeType == 1 && curchild.nodeName != "parsererror")
                                    node.insertBefore(curchild, importNode);
                            }
                        }
                        catch (e) {
                            // --- import XML not found
                        }
                    }
                }
                catch (exp) {
                    //Dimport for webserver
                    // indexfile.xml is a file present in the server which will have the list of XML files
                    //present in CAA-partners directory
                    try {
                        destdir = node.childNodes[i].getAttribute("dir");
                        var contentsfile = destdir + "\\indexfile.xml";
                        var filenode = null;
                        filenode = loadXML(contentsfile).getElementsByTagName("title");
                        var fullfilename1;
                        for (var k = 0; k < filenode.length; k++) {
                            try {
                                fullfilename1 = destdir + "\\" + filenode[k].childNodes[0].nodeValue;
                                var newNode = loadXML(fullfilename1).getElementsByTagName('Root')[0];
                                while (newNode.firstChild != null) {
                                    var curchild = newNode.firstChild;
                                    newNode.removeChild(curchild);
                                    if (curchild.nodeType == 1 && curchild.nodeName != "parsererror")
                                        node.insertBefore(curchild, importNode);
                                }
                            }
                            catch (e) {
                                // --- import XML not found
                            }
                        }
                    }
                    catch (exep) {
                        //
                    }
                }
                // at last remove
                // --- now remove the IMPORT node
            }
            catch (ex) {
                //
            }
            node.removeChild(importNode);
        }
        else {
            // --- non import node: recursivity
            resolveImports(node.childNodes[i]);
            i++;
        }
    }
}

// -----------------------------------------------------------------------
/**
* Returns the DOM object associated to the DITEM with given directory
*/
function getDItemFromDir(dir) {
    var lookForName = "DIR@" + dir;
    var rows = document.getElementsByTagName("TR");
    for (var i = 0; i < rows.length; i++) {
        if (rows[i].name != null && rows[i].name == lookForName)
            return rows[i];
    }
    return null;
}

// -----------------------------------------------------------------------
/**
* Returns navigation node information.
* Returns an object with fields:
*  - id: the node id (unique)
*  - name or title (for cnfxml files): the display name
*  - icon: the associated icon (if any)
*  - link: the associated link
*  - isNode: tells whether if the node has children (true) or not (false)
*/
function getNavNodeInfo(node) {
    var ret = new Object();
    ret.id = null;
    ret.name = null;
    ret.link = null;
    ret.icon = null;
    ret.isNode = true;
    //	ret.isChildrenLoaded = true;
    //  HFJ reference Node
    ret.referenceNode = null;

    if (node.nodeName == "DITEM") {
        // --- dynamic item
        ret.isNode = true;
        //		ret.isChildrenLoaded = false;
    }
    else {
        // --- static item
        ret.isNode = node.hasChildNodes();
        //		ret.isChildrenLoaded = true;
    }

    // --- href
    var href = node.getAttribute("href");

    // HFJ --- reference node
    ret.referenceNode = node.getAttribute("referencenode");

    // --- name or title
    ret.name = node.getAttribute("name");
    if (ret.name == null) {
        ret.name = node.getAttribute("title");
        if (ret.name == null) {
            if (href == null) {
                ret.name = "???";
            }
            else {
                // --- filename without extension
                var idx1 = href.lastIndexOf('/');
                var idx2 = href.lastIndexOf('.');
                if (idx2 < 0) idx2 = href.length;
                ret.name = href.substring(idx1 + 1, idx2);
            }
        }
    }

    // --- icon
    ret.icon = node.getAttribute("icon");

    // --- compute link: it may be relative to parent DITEM directory
    // --- get DITEM parent node
    var ditemFather = getFatherNode("DITEM", node.parentNode);
    if (ditemFather == null) {
        ret.link = href;
    }
    else {
        var dir = ditemFather.getAttribute("dir");
        if (dir == null) {
            ret.link = href;
        }
        else {
            if (href.match("../")) {
                //alert("href ../ "+href);
                var hrefnew = href;
                hrefnew = hrefnew.replace("../", "");
                ret.link = hrefnew;
            }
            else {
                //alert("href "+href);
                ret.link = dir + "/" + href;
            }
            //ret.link = dir+"/"+href;
        }
    }

    // --- id: it contains the link
    if (ret.link != null)
        ret.id = "HREF@" + ret.link;

    // XWY : --- pauseOnLoad: allow pauses in building the TOC DOM tree from a structure file
    ret.pause = false;
    if (node.getAttribute("pauseOnLoad") && node.getAttribute("pauseOnLoad") == "yes") {
        ret.pause = true;
    }

    return ret;
}

// -----------------------------------------------------------------------
/**
* Returns the DOM object in the TOC tree associated to the given url.
*/
function getTOCItemFromURL(locationObj) {
    // --- compute relative document path
    var url = buildRelativeLink(locationObj, parent.parent.location);
    //	DebugMessage("getTOCItemFromURL: '"+url+"'");

    // --- 1: compute TOC item id and directory
    var objId = "HREF@" + url;
    var directory = null;
    var args = extractParamsFromLocation(locationObj);
    if (args["dir"] != null) {
        // --- dir passed as an argument in the URL
        directory = args["dir"];
        // --- the TOC item id contains the directory
        objId = objId + "?dir=" + directory;
    }
    else {
        // --- extract dir from the url
        var idx = url.lastIndexOf("/");
        if (idx >= 0) {
            directory = url.substr(0, idx);
            idx = directory.lastIndexOf("/");
            if (idx >= 0)
                directory = directory.substr(idx + 1);
        }
    }

    // --- 2: try to retrieve the associated DOM object by ID
    var domObj = document.getElementById(objId);

    // HFJ for HITEM

    if (domObj != null) {
        // HFJ for Reference Node
        //---------------------------------
        if (lastDomObj != null)// for child Node processing
        {
            if (eventTocItem) {
                lastDomObj = globalTOCrowObj;
                //eventTocItem = false; // hfj
                //count = 1;
                return globalTOCrowObj;
            }

            /* if(count == 1)
            {
            lastDomObj = globalTOCrowObj;
            //eventTocItem = false;
            count = 0;
            //count = 2;
            //alert("eventTocItem "+eventTocItem);
            return globalTOCrowObj;
            }*/


            var childModdomObj;
            if (document.getElementsByTagName) {
                if (lastDomObj.nextSibling != null) {
                    var el = lastDomObj.nextSibling.getElementsByTagName("tr");

                    for (var j = 0; j < el.length; j++) {
                        if (el[j] != null) {
                            //alert(objId+"aaa...\n"+el[j].id);
                            if (objId.match(el[j].id) != null) {
                                childModdomObj = el[j];
                                //lastDomObj = childModdomObj; // hfj coment opened for multiple bug highlight.

                                if (el[j].id == "") // hfj for later multiple highlight bug .
                                {
                                    // This bug is after using HITEM which is not match with ODT sent. 

                                    lastDomObj = domObj;
                                    return domObj;

                                }

                                lastDomObj = childModdomObj; // hfj coment opened for multiple bug highlight.
                                return childModdomObj;
                            }
                        }
                    }
                }
            }
        }
        else {
            lastDomObj = domObj;
            return domObj;
        }
        // ---- end 
        // HFJ for reference node 
        if (referencenodeArray != null)// for reference Node processing
        {
            var splitReferencenodeArray = referencenodeArray.split("+");

            var moddomObj;
            editedobjIdidx = objId.indexOf("@");
            var editedobjId = objId.substr(editedobjIdidx + 1);

            for (i = 0; i < splitReferencenodeArray.length; i++) {
                arrayHITEMidx = splitReferencenodeArray[i].indexOf("#");

                var arrVal = splitReferencenodeArray[i].substr(arrayHITEMidx + 1);
                arrVal = arrVal.replace(" ", "")
                if (document.getElementsByTagName) {
                    var el = document.getElementsByTagName("tr");
                    for (var j = 0; j < el.length; j++) {
                        var vPar = el[j].parent;

                        if (vPar != null) {
                            if ((splitReferencenodeArray[i].match(vPar)) && (el[j].referencenode != null) && (arrVal.match(editedobjId))) {
                                moddomObj = el[j];
                                lastDomObj = moddomObj;
                                //alert(moddomObj.parent+"\n...\n"+moddomObj.innerHTML);
                                return moddomObj;
                            }
                        }
                    }
                }
            }
            //hfj for begining multiple node highlight when catia page is first shown.
            //lastDomObj = domObj;
            return domObj;
        }
        else {
            lastDomObj = domObj;
            return domObj;
        }
        // ---- end
        lastDomObj = domObj;
        return domObj;
    }
    else {
        editedobjIdidx = objId.indexOf("@");
        var editedobjId = objId.substr(editedobjIdidx + 1);

        var splitModifiedDisplayAttributeArray = modifiedDisplayAttributeArray.split("+");

        for (i = 0; i < splitModifiedDisplayAttributeArray.length; i++) {
            arrayHITEMidx = splitModifiedDisplayAttributeArray[i].indexOf("#");

            var arrVal = splitModifiedDisplayAttributeArray[i].substr(arrayHITEMidx + 1);
            arrVal = arrVal.replace(" ", "")

            if (editedobjId.match(arrVal) != null) {
                var parentDisplayAttributeArray = splitModifiedDisplayAttributeArray[i].substr(0, arrayHITEMidx);

                parentDisplayAttributeArray = parentDisplayAttributeArray.replace(" ", "");
                var newobjId = "HREF@" + parentDisplayAttributeArray;
                var newdomObj = document.getElementById(newobjId);

                if (newdomObj != null) {
                    lastDomObj = newdomObj;
                    return newdomObj;
                }
            }
        }
    }
    //
    // --- object not found: it must not be loaded yet (child of a ditem?)
    if (directory == null) {
        // --- no dir
        DebugMessage("Could not find DocNode from url '" + url + "': no directory.");
        return null;
    }

    // --- find the ditem DOM object by ID
    //	var productRow = document.getElementById("PRD@"+directory);
    //	var ditemRow = document.getElementById("HREF@"+getProductHREF(directory));
    var ditemRow = getDItemFromDir(directory);
    if (ditemRow == null) {
        // TODO
        DebugMessage("Could not find DITEM DOM obj with dir: " + directory);
        return null;
    }
    // --- load children if need be
    if (!loadChildrenIfNeeded(ditemRow, false)) {
        return null;

    }

    // --- now the associated DOM object should be here
    var domObj = document.getElementById(objId);
    if (domObj == null) {
        DebugMessage("Could not find DocNode from url '" + url + "'.");
        return null;
    }
    //lastDomObj = domObj;
    return domObj;

}

// V2E : 25-jul-2013
/*
* Initilizes the requiredFilter,offeringScope and contextscope variables
*/

function setScopeFilter() {

    var args = extractParamsFromLocation(parent.parent.location);

    if (args["offeringscope"] != null) {
        var scope1 = args["offeringscope"];
        offeringScope = scope1.toString().split(",");
    } else {
        //offeringScope = ['all' ];
        offeringScope = ['innov'];
    }

    if (args["contextscope"] != null) {
        var scope2 = args["contextscope"];
        contextScope = scope2.toString().split(",");
    } else {
        //contextScope = ['all'];
        contextScope = ['onpremise'];
    }

    if (args["filter"] != null) {

        var tempFilter = args["filter"];
        var isSet = false;

        if (!(typeof tempFilter === 'string')) {
            requiredFilter = ["all"];
            isSet = true;
        }
        if (!isSet)
            requiredFilter = tempFilter.toString().split(",");
    } else {
        requiredFilter = ["all"];
    }
}

/*
* V2E : 25-oct-2013
* OfferingScope match : at least one scope must match
*/
function isOfferingScopeMatch(nodeScope, offeringScope) {

    if (nodeScope == null)
        return true;
    for (var i = 0; i < offeringScope.length; i++) {
        for (var j = 0; j < nodeScope.length; j++) {
            if (offeringScope[i] === nodeScope[j])
                return true;
        }
    }

    return false;
}

/*
*  V2E : 25-Oct-2013
*  ContextScope match : at least one scope must match.
*  Special case 'swx' since lots of nodes are expected to be "onpremise,cloud", we replace it by "noswx"
*/
function isContextScopeMatch(nodeScope, contextScope) {

    if (nodeScope == null)
        return true;
    if (nodeScope[0] == 'noswx') {
        if (contextScope[0] == 'swx')
            return false;
        else
            return true;
    }
    for (var i = 0; i < contextScope.length; i++) {
        for (var j = 0; j < nodeScope.length; j++) {
            if (contextScope[i] === nodeScope[j])
                return true;
        }
    }

    return false;
}


/*
* V2E : 25-jul-2013
* Filter match is OR match ; at least one filter should match
*/

function isFilterMatch(nodeFilter, requiredFilter) {

    if (nodeFilter == null)
        return false;
    for (var i = 0; i < requiredFilter.length; i++) {
        for (var j = 0; j < nodeFilter.length; j++) {
            if (requiredFilter[i] === nodeFilter[j])
                return true;
        }
    }

    return false;
}

// =======================================================================
// === TOC Tree Functions
// =======================================================================
// -----------------------------------------------------------------------
/**
* Initializes the toc tree with the XML 'XMLToc' argument
* Expands and selects the path of the document passed with the URL 'doc' argument
*/
function initTOC() {
    DebugMessage("initTOC");
    //alert("initTOC");
    if (TOC_DATA != null)
    // --- already loaded: skip
        return;

    setScopeFilter();

    // --- 0: Get parameters from top parent url arguments
    // XMLToc = xml TOC description file
    var args = extractParamsFromLocation(parent.parent.location);
    var xmlTocFile = args["XMLToc"];
    if (xmlTocFile == null) {
        //alert("xmlTocFile = null");
        var args2 = extractParamsFromLocation(parent.location);
        xmlTocFile = args2["XMLToc"];
        if (xmlTocFile == null) {
            //alert("xmlTocFile2 = null");
            xmlTocFile = "TOC.xml";
        }
    }
    // collapse
    var collapsereq = args["collapse"];
    if (collapsereq == null) {
        var args2 = extractParamsFromLocation(parent.location);
        collapsereq = args2["collapse"];
    }

    // --- 1: Load XML TOC info
    var tocData = null;
    try {
        //alert("load " + xmlTocFile);
        tocData = loadXML(xmlTocFile).lastChild;
        resolveImports(tocData);
    }
    catch (e) {
        DebugMessage("Warning: couldn't load common navigation links.");
    }

    // --- 2: Create list of installed products for checkvisibility functionality   
    try {
        //alert("read InstalledList.txt");

        var fileList = new Array();
        // JFS 2010 October 20
        fileList[0] = "InstalledList.txt";
        for (var i = 0; i < fileList.length; i++) {
            var CV_idxRootNode = "";
            //alert(fileList[i]+" "+fileList.length);
            try {
                CV_idxRootNode = loadFile_mod(fileList[i], "txt");
            }
            catch (e) {
                continue;
            }
            CV_array = CV_idxRootNode + CV_array;
        }
    }
    catch (e) {
        //alert("catch "+e.toString());
    }

    // --- 3: Empty page DOM
    while (document.body.firstChild != null)
        document.body.removeChild(document.body.firstChild);

    // --- 4: Build TOC
    makeTOCChildItems(document.body, tocData);

    /*
    // --- tests
    var prdFile = "CATIA_INDEXFile.DSidx";
    DebugMessage("load '"+prdFile+"': '"+loadFile(prdFile, "txt")+"'");
  
    var ssmFile = "asmug_C2/asmugssm.htm";
    DebugMessage("load '"+ssmFile+"' as text: '"+loadFile(ssmFile, "txt")+"'");
    DebugMessage("load '"+ssmFile+"' as html: '"+loadFile(ssmFile, "html")+"'");
    */

    TOC_DATA = tocData;
    // V2E : IR-031132
    // Stored the DITEM info into the ditemTOC  
    ditemTOC = TOC_DATA.getElementsByTagName("DITEM");
    // --- 5: Select first file to open
    selectCurrentFile();

    // --- 6: Collapse on request
    if (collapsereq == "true")
        (top.frames["LeftFS"].frames["TocBar"]).collapseLeftSide(0);
}

// -----------------------------------------------------------------------
/**
* Creates the TOC children items in the TOC tree.
* This function creates the required DOM objects to represent a children items in the TOC tree.
*/
function makeTOCChildItems(containerObj, node, expandAll) {
    //alert("makeTOCChildItems node[" + node.getAttribute("name") + "]");

    // --- 0.initialize Checkvisibility variables
    var added = 0;    // (DITEM or ITEM) child visible counter
    var dCounter = 0; // DITEM child counter
    var dFlag = null; // DITEM child not visible counter
    var iFlag = 0;    // ITEM child counter

    // --- 1.create <TABLE> and <TBODY> elements
    var childrenTable = document.createElement("TABLE"); containerObj.appendChild(childrenTable);
    childrenTable.className = "Toc";
    var childrenTBody = document.createElement("TBODY"); childrenTable.appendChild(childrenTBody);

    // --- 2.manage children
    for (var i = 0; i < node.childNodes.length; i++) {
        // manage only element nodes
        if (node.childNodes[i].nodeType != 1)
            continue;
        if (node.childNodes[i].nodeName == "HITEM") {
            //modifiedDisplayAttributeArray += node.getAttribute("href")+"#"+node.childNodes[i].getAttribute("dir")+"+";
        }
        else {
            var nodeChild = node.childNodes[i];

            var nocheckvisibility = nodeChild.getAttribute("checkvisibility") == "FALSE" || nodeChild.getAttribute("checkvisibility") == "false";
            var checkvisibility = nodeChild.getAttribute("checkvisibility") == "TRUE" || nodeChild.getAttribute("checkvisibility") == "true";
            var nodecheckvisibility = false;
            // V2E : 25-jul-2013
            // Check for scope and filter parameter match
            var isShowNode = false;
            var isShowMedia = true;
            // V2E : Check for filter and scopes
            var nodeScopeOffering = node.childNodes[i].getAttribute("offeringscope");
            var nodeScopeContext = node.childNodes[i].getAttribute("contextscope");
            var nodeFilter = node.childNodes[i].getAttribute("filter");
            if (nodeScopeOffering != null) {
                nodeScopeOffering = nodeScopeOffering.split(",");
            }
            if (nodeFilter != null) {
                nodeFilter = nodeFilter.split(",");
            }
            if (nodeScopeContext != null) {
                nodeScopeContext = nodeScopeContext.split(",");
            }
            if (isOfferingScopeMatch(nodeScopeOffering, offeringScope) || nodeScopeOffering[0] === "" || offeringScope[0].toString() === "all" || nodeScopeOffering[0].toString() === "all") {
                if (isContextScopeMatch(nodeScopeContext, contextScope) || nodeScopeContext[0] === "" || contextScope[0].toString() === "all" || nodeScopeContext[0].toString() === "all") {
                    if (nodeFilter == null || isFilterMatch(nodeFilter, requiredFilter) || nodeFilter[0] === "" || requiredFilter[0].toString() === "all") {
                        isShowNode = true;
                    }
                }
            }

            var mod_childTocNoMedia = node.childNodes[i].getAttribute("notmedia");
            if (mod_childTocNoMedia != null && checkMediaVisibility(CV_array, mod_childTocNoMedia)) {
                isShowMedia = false;
            }

            // <DITEM> elements : defaut value for checkvisibility = true
            // unless not requested, check whether this child node is be displayed
            if (nodeChild.nodeName == "DITEM" && !nocheckvisibility) {
                if (isShowNode && isShowMedia) {
                    nodecheckvisibility = true;
                    var childTocFile = node.childNodes[i].getAttribute("childtoc");
                    if (childTocFile != null) {
                        dCounter++;
                        // Check whether module indicated in dir attribute is referenced in InstalledList.txt
                        var mod_childTocDir = node.childNodes[i].getAttribute("dir");
                        if (mod_childTocDir != null && !checkVisibility(CV_array, mod_childTocDir)) {
                            //alert("Do not display DITEM child node[" + node.getAttribute("name") + "] dir[" + mod_childTocDir + "]");
                            if (dFlag == null)
                                dFlag = 0;
                            dFlag++;
                            //dNode = node;
                            continue;
                        }
                        // Check whether a module indicated in media attribute is referenced in InstalledList.txt
                        var mod_childTocMedia = node.childNodes[i].getAttribute("media");
                        if (mod_childTocMedia && !checkMediaVisibility(CV_array, mod_childTocMedia)) {
                            //alert("Do not display DITEM child node[" + node.getAttribute("name") + "] media[" + mod_childTocMedia + "]");
                            if (dFlag == null)
                                dFlag = 0;
                            dFlag++;
                            //dNode = node;
                            continue;
                        }
                        // Manage child
                        makeTOCItem(childrenTBody, node.childNodes[i]);
                        added++;
                    }
                    // V2E : 14-May-2013
                    // Sometime TOC node to be expanded when loaded.
                    try {
                        var expandTest = node.childNodes[i].getAttribute("expandOn");
                        // V2E : 12-March-2014
                        // When Show parameter is also passed do not trigger event again.
                        var args = extractParamsFromLocation(parent.parent.location);
                        if (expandTest != null && expandTest == "yes" && args["show"] == null) {
                            var nodeInf = getNavNodeInfo(node.childNodes[i])
                            var nodeTR = document.getElementById(nodeInf.id);

                            var nodeAnchorImg = nodeTR.childNodes[1].childNodes[1];
                            // V2E : 21-Oct-2013
                            // icon node may or may not present
                            if (typeof (nodeAnchorImg) == "undefined")
                                nodeAnchorImg = nodeTR.childNodes[1].childNodes[0];

                            var evt = document.createEvent("MouseEvents");

                            evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                            nodeAnchorImg.dispatchEvent(evt);

                        }
                    } catch (e) {

                    }
                }
            } // <DITEM> elements
            // <ITEM> elements : defaut value for checkvisibility = false (because most <ITEM> elements are topics)
            // if requested, check whether this child node is be displayed
            else if (nodeChild.nodeName == "ITEM" && checkvisibility) {
                if (isShowNode && isShowMedia) {
                    nodecheckvisibility = true;
                    var isfileexist = true;
                    // Check whether a module indicated in media attribute is referenced in InstalledList.txt
                    var mod_childTocMedia = node.childNodes[i].getAttribute("media");
                    if (mod_childTocMedia != null && !checkMediaVisibility(CV_array, mod_childTocMedia)) {
                        //alert("Do not display child node[" + node.getAttribute("name") + "] media[" + mod_childTocMedia + "]");
                        isfileexist = false;
                    }
                    // OK, Media installed
                    if (isfileexist) {
                        // Check whether module indicated in dir attribute (optional) is referenced in InstalledList.txt
                        var mod_childTocDir = node.childNodes[i].getAttribute("dir");
                        if (mod_childTocDir != null) {
                            if (!checkVisibility(CV_array, mod_childTocDir)) {
                                //alert("Do not display child node[" + node.getAttribute("name") + "] dir[" + mod_childTocDir + "]");
                                isfileexist = false;
                            }
                        }
                        // V2E : If dir(optional) attribute is not present then extract module name from HREF attribute
                        // or check existence of file mentioned in href attribute of ITEM tag(LAST OPTION)
                        else {
                            var tempUrl = nodeChild.getAttribute("href");
                            // V2E : Extract the Module name from href
                            var moduleName = getModuleName(tempUrl);
                            if (moduleName != null) {
                                if (!checkVisibility(CV_array, moduleName)) {
                                    isfileexist = false;
                                }
                            }
                            // V2E : if Module name is not present in href attribute then check for existence of file
                            // Please note : href value can be href="abc.html"
                            else {
                                var loc = parent.parent.document.URL;
                                var url = loc.replace("DSDoc.htm", tempUrl);
                                isfileexist = isFileExist(url);
                            }
                        }
                        // if exist make this node
                        var deletedNode = false;
                        if (isfileexist) {
                            // Manage child and check whether it contains children
                            deletedNode = makeTOCItem(childrenTBody, node.childNodes[i]); // PH7 NEW SPECIFICATION
                            //alert("deletedNode [" + deletedNode + "]");
                            added++;
                        }
                        //iFlag++;
                        if (deletedNode == false && isfileexist) {// if this 'ITEM' node was deleted because of its checkvisibility..
                            iFlag++; // PH7: NEW SPECIFICATION: There is at least one ITEM node.
                        }
                    } // OK, Media installed
                }
            } // <ITEM> elements
            // checkvisibility not requested
            else {
                // Manage child
                // V2E : 25-jul-2013
                if (nodeChild.nodeName != "ITEM" && nodeChild.nodeName != "DITEM") {
                    makeTOCItem(childrenTBody, node.childNodes[i]);
                    added++;
                    iFlag++; //checkvisibility is not mentioned
                }
                else {
                    if (isShowNode) {
                        makeTOCItem(childrenTBody, node.childNodes[i]);
                        added++;
                        iFlag++; //checkvisibility is not mentioned
                    }
                } // checkvisibility not requested
            }
        } // for (var i = 0; i < node.childNodes.length; i++)
    }
    // --- 3.check whether the node is to be deleted
    var deletedCurrentNode = false;
    //alert("node [" + node.getAttribute("name") + "] iFlag[" + iFlag + "] dCounter[" + dCounter + "] dFlag[" + dFlag + "] nodecheckvisibility[" + nodecheckvisibility + "]");
    if (iFlag == 0 &&                          // PH7 NEW SPECIFICATION : There are no ITEM children
      (dCounter == dFlag || dCounter == 0) &&    // : None of the DITEMS' page exist or there are no DITEMs.
      nodecheckvisibility) // and node's checkvisibility is TRUE.
    {
        dFlag = 0;
        var fatherNode = getFatherNode("TR", containerObj);
        var preChild = fatherNode.previousSibling;
        //if (node.parentNode.nodeName!= "Root")
        {
            //preChild.removeNode(true);
            var grandfather = preChild.parentNode;
            grandfather.removeChild(preChild);
            deletedCurrentNode = true;
            //alert("Delete node[" + node.getAttribute("name") + "]");
        }
    }

    if (added == 0)
        DebugMessage("Added 0 child in node " + node.getAttribute("name"));

    return deletedCurrentNode;
}

// -----------------------------------------------------------------------
/**
* Creates a TOC item in the TOC tree.
* This function creates the required DOM objects to represent a node in the TOC tree.
*/
function makeTOCItem(tbodyObj, node, expandAll) {
    /*
    if (node.getAttribute("name") != null)
    alert("makeTOCItem node name[" + node.getAttribute("name") + "]");
    else
    alert("makeTOCItem node title[" + node.getAttribute("title") + "]");
    */

    // --- 1: get name, link and icon
    var nodeInfo = getNavNodeInfo(node);

    //HFJ for reference attribute
    var parNode = node.parentNode;
    var parNodeInfo = getNavNodeInfo(parNode);

    // --- 2: build DOM elements
    //	DebugMessage("building node '"+nodeName+"'...");
    //IE only	var nodeRow = tbodyObj.insertRow();
    var nodeRow = document.createElement("TR"); tbodyObj.appendChild(nodeRow);
    nodeRow.className = "TocItem";
    nodeRow.id = nodeInfo.id;
    ////
    nodeRow.parent = parNodeInfo.link + "#" + nodeInfo.link; //HFJ for reference node
    nodeRow.referencenode = nodeInfo.referenceNode;
    if (node.nodeName == "DITEM" && node.getAttribute("dir") != null)
        nodeRow.name = "DIR@" + node.getAttribute("dir");

  nodeRow.TOC_NODE = node;
  //IE only	var anchorCell = nodeRow.insertCell();
  var anchorCell = document.createElement("TD");nodeRow.appendChild(anchorCell);
  anchorCell.className = "TocAnchor";
  var anchorImg = document.createElement("IMG");anchorCell.appendChild(anchorImg);
  //IE only	var itemCell = nodeRow.insertCell();
  var itemCell = document.createElement("TD");nodeRow.appendChild(itemCell);
  itemCell.noWrap = true;
  if (nodeInfo.icon != null) {
    var itemIcon = document.createElement("IMG");itemCell.appendChild(itemIcon);
    itemIcon.className = "TocIcon";
    itemIcon.src = nodeInfo.icon;
    itemIcon.align = "absmiddle";
  }

    var itemLink = document.createElement("A"); itemCell.appendChild(itemLink);
    itemLink.className = "TocLink";
    var tmpTitle = nodeInfo.name.replace(/\\/g, "");
    var tmpHtml = tmpTitle.replace(/ /g, "&nbsp;");
    itemLink.innerHTML = tmpHtml;
    itemLink.title = tmpTitle;
    itemLink.onclick = onClickTocItem;

    if (nodeInfo.link != null) {
        itemLink.target = MAIN_FRAMENAME;
        itemLink.href = nodeInfo.link;

        // by LQA 12-09-06
        //for SITEM to display the corresponding link in top window
        if (node.nodeName == "SITEM")
            itemLink.target = "_top";
    }
    else {
        // TODO?
        itemLink.target = MAIN_FRAMENAME;
        itemLink.href = "FrontmatterMap/DSDocHome.htm";
    }

    // --- manage leaf or node item
    if (!nodeInfo.isNode) {
        // --- this is a leaf (no child)
        anchorImg.src = "FrameImages/DSDocIcon_tocFile.png";
        return false;
    }

    // --- this is a node (has children)
    anchorImg.src = "FrameImages/DSDocIcon_tocPlus.png";
    anchorImg.onclick = onClickTocAnchor;
    // if (!(navigator.appName.indexOf("Microsoft") != -1)) {
    if (anchorImg.src.endsWith("FrameImages/DSDocIcon_tocPlus.png") || anchorImg.src.endsWith("FrameImages/DSDocIcon_tocMinus.png")) {
        // to show tooltip for ExpandAll/CollapseAll when mouse is over anchorObj
        anchorImg.onmouseover = showHint;
        // to remove tolltip of ExpandAll/CollapseAll when mouse is out of anchorObj
        anchorImg.onmouseout = hideHint;
    }
    // }

    // --- now create the children row
    //IE only	var childrenRow = tbodyObj.insertRow();
    var childrenRow = document.createElement("TR"); tbodyObj.appendChild(childrenRow);
    childrenRow.className = "TocCollapsed";
    //IE only	var vCell = childrenRow.insertCell();
    var vCell = document.createElement("TD"); childrenRow.appendChild(vCell);
    vCell.className = "TocV";
    var blankImg = document.createElement("IMG"); vCell.appendChild(blankImg);
    blankImg.src = "FrameImages/DSDocIcon_tocBlank.gif";
    //IE only	var childrenCell = childrenRow.insertCell();
    var childrenCell = document.createElement("TD"); childrenRow.appendChild(childrenCell);
    childrenCell.className = "TocChildren";

    // XWY : --- pauseOnLoad: stop here when requested
    if (nodeInfo.pause) {
        return false;
    }

    // <DITEM> elements children are not managed at first display
    // V2E : HITEM management
    if (node.nodeName == "DITEM" && expandAll != true) {
        for (i = 0; i < node.childNodes.length; i++) {
            if (node.childNodes[i].nodeName == "HITEM") {
                modifiedDisplayAttributeArray += node.getAttribute("href") + "#" + node.childNodes[i].getAttribute("dir") + "+";
            }
        }
        return;
    }

    // --- Manage children
    return makeTOCChildItems(childrenCell, node, expandAll);
}

// XWY: --- pauseOnLoad: 
// In order to speed initial creation of the Abaqus ToC, we pause on building at certain nodes in
// the structure files.  However, when we jump to pages which correspond to unbuilt ToC parts, we
// must have an efficient way to build and open just what's needed.  The abqPageMap associates child
// pages to their parents so that, given a target far out in the unbuilt ToC tree, we can traverse
// back to a point on the tree which is already open.  Making this association list takes only a
// modest amount of time (in contrast to actually building the ToC), so we do it for each book on
// the first expansion of the book.

function makeAbqPageMap(node) {
    if (abqPageMap == null) { abqPageMap = new Object(); }
    while (node.parentNode != null && node.nodeName != "DITEM") { node = node.parentNode; }
    // for each book, we make an association list
    var book = node.getAttribute("href");
    book = book.replace(/\/.*$/, "");
    if (node.nodeName == "DITEM" && abqPageMap[book] == undefined) {
        var processingStack = [];
        processingStack.unshift(node, null);
        var n; var p;
        var nhref; var phref;
        var data = new Object;
        while (processingStack.length > 0) {
            n = processingStack.shift();
            p = processingStack.shift();
            // make associations such as "pt01ch02s03atm04.htm" -> "pt01ch02s03.htm" (child to parent)
            if (n.nodeType == 1 && n.getAttribute("href") != "" && !n.getAttribute("href").match(/#/)) {
                if (p == null) { data[n.getAttribute("href")] = ""; }
                else { data[n.getAttribute("href")] = p.getAttribute("href"); }
                if (n.childNodes.length > 0) {
                    for (var i = 0; i < n.childNodes.length; i++) {
                        processingStack.unshift(n.childNodes[i], n);
                    }
                }
            }
        }
        abqPageMap[book] = data;
    }
    return true;
}

// --- pauseOnLoad: 
//
// This function is called only after getTocItemFromSecondLevelParent and getTOCItemFromURL have failed
// to return a tocitem, and the function is also just a no-op if the directory of locationObj is not an
// Abaqus directory.
//
// We're given a url which is the location of the page in the right window.  Its location relative
// to the containing book gives a path by which we can determine (a) the book we're in and (b) the
// htm file we want to find as a referent in the ToC.  Using the abqPageMap we trace from the target
// page back up to the book page.  Somewhere in between or at the top is a node already open in the
// ToC.  From there we walk back down to the target, building the ToC as we go.
function getTOCItemFromURLThroughXMLStructure(locationObj) {
    // beginning taken from getTOCItemFromURL
    var url = buildRelativeLink(locationObj, window.parent.parent.location);
    var objId = "HREF@" + url;
    var directory = "unknown"; // used to know our "book"
    if (url.match(/#/)) { url = url.replace(/#.*$/, ""); }  // open ToC to this url, and retrieve objId
    var target = url;          // file we seek
    var idx = url.lastIndexOf("/");
    if (idx >= 0) {
        directory = url.substr(0, idx);
        target = url.substr(idx + 1);
        idx = directory.lastIndexOf("/");
        if (idx >= 0)
            directory = directory.substr(idx + 1);
    }
    if (!directory.match(/^Mpe/)) { return null; } // Outta here if we're looking for something other than Abaqus

    // We may not have loaded any of the Abaqus docs yet, and we have to at least guarantee the presence of the top
    // level Abaqus books.  We are assuming that only SIMULIA docs may reference Abaqus docs.
    loadChildrenIfNeeded(document.getElementById("HREF@FrontmatterMap/DSDocAbaqus.htm"));
    var topnode = document.getElementById("HREF@" + directory + "/book01.htm");
    makeAbqPageMap(topnode.TOC_NODE);

    // We can go from target to an open point in the ToC by tracing through the abqPageMap.
    var pathToTarget = new Object(); // used to record how to get back to target; this is an inverse to abqPageMap
    var child = target;              // child and parent are names of pages, e.g. pt02ch03s07atm02.htm
    var parent = null;
    var domObj = document.getElementById("HREF@" + directory + "/" + child); // we're here because this is null
    while (!domObj) {                     // keep going until we hit the ToC
        parent = abqPageMap[directory][child];
        pathToTarget[parent] = child;
        child = parent;
        domObj = document.getElementById("HREF@" + directory + "/" + child);
    }

    // now build the ToC from domObj down to target
    while (child != target) {
        loadChildrenIfNeeded(document.getElementById("HREF@" + directory + "/" + child), true);
        child = pathToTarget[child];
    }
    return document.getElementById(objId);
}




// -----------------------------------------------------------------------
/**
* Loads DITEM children if not done yet.
* This function also creates the DOM objects representing the DITEM children
* under the DITEM leaf in the TOC tree.
* retuns true if children were loaded
* V2E :IR-154927V6R2013x 
* requestedOBJ : ObjectId of the requiered obj
* fromSecondLevel : if this function called from getTocItemfromSecondLevelParent()
*/
function loadChildrenIfNeeded(rowObj, asynch, requestedOBJ, fromSecondLevel) {
    var childrenRow = rowObj.nextSibling;
    if (childrenRow == null)
        return false;

    // --- load children nodes if need be
    var childrenCell = childrenRow.cells[1];
    var childrenTable = childrenCell.firstChild;
    if (childrenTable != null || rowObj.TOC_NODE.getAttribute("loaded"))
        return false;

    // --- child TOC has to be loaded

    // --- mark DITEM as "loaded"
    rowObj.TOC_NODE.setAttribute("loaded", true);

    // --- show "..." while loading site map
    var waitingSpan = document.createElement("SPAN");
    waitingSpan.className = "TocWaiting";
    waitingSpan.innerHTML = "loading...";
    childrenCell.appendChild(waitingSpan);
    window.status = "Loading...";

    // XWY : --- pauseOnLoad: if TOC_NODE actually has children, we must have paused; so let's resume
    if (rowObj.TOC_NODE.getAttribute("pauseOnLoad") &&
      rowObj.TOC_NODE.getAttribute("pauseOnLoad") == "yes" &&
      rowObj.TOC_NODE.firstChild != null) {
        makeAbqPageMap(rowObj.TOC_NODE);
        makeTOCChildItems(childrenCell, rowObj.TOC_NODE);
        childrenCell.removeChild(waitingSpan);
        window.status = "";
        return true;
    }


    // --- 2: load child TOC structure
    var childTocRootNode = null;
    var childTocFile = rowObj.TOC_NODE.getAttribute("childtoc");
    if (childTocFile != null) {
        // --- cnfxml file format (built) does not contain yet the 'name'
        // --- comment out this when done (MLP)
        /*
        if(childTocFile.endsWith(".cnfxml"))
        {
        // --- load the <productTag>ssm.htm and explore the DOM
        var directory = rowObj.TOC_NODE.getAttribute("dir");
        var idx = directory.indexOf('_');
        var productTag = idx < 0 ? directory : directory.substr(0, idx);
        var ssmFile = directory+"/"+productTag+"ssm.htm";
        var siteMapContent = null;
        try {
        siteMapContent = loadFile(ssmFile, "txt");
        } catch(e) { }
      
        if(siteMapContent != null)
        {
        // --- create an hidden div
        var hiddenDiv = document.createElement("DIV");
        hiddenDiv.style.display = "none";
        // --- load the site map in the hidden div
        hiddenDiv.innerHTML = siteMapContent;
        
        // --- build the site map structure
        childTocRootNode = rebuildSiteMapStructure(rowObj.TOC_NODE.ownerDocument, hiddenDiv);
        }
        }
        else
        */
        {
            // --- load the XML 
            //	var siteMapXMLFile = "../"+rowObj.TOC_NODE.getAttribute("ID")+"/structure.cnfxml";
            try {
                childTocRootNode = loadXML(childTocFile).getElementsByTagName('Root')[0];
                // Added PSR to enable IMPORT within DITEM
                resolveImports(childTocRootNode);
            }
            catch (e) {
                alert("Warning: couldn't load common navigation links.");
            }
        }
    }

    // --- treat errors (TOC not found)
    if (childTocRootNode == null) {
        // --- add children node 'not found'
        waitingSpan.innerHTML = "not found";
        waitingSpan.className = "TocNotFound";
        window.status = "Error: TOC not found.";
        return false;
    }
    // V2E :IR-154927V6R2013x 
    // Checking whether to call makeTocChildItems or not depending on file link is found in loaded doc
    if (fromSecondLevel == true) {
        var test = requestedOBJ.lastIndexOf("/");
        var testLink = requestedOBJ.substring(test + 1);
        var isPresentInFile = false;
        for (var i = 0; i < childTocRootNode.childNodes.length; i++) {
            isPresentInFile = testForExistance(childTocRootNode.childNodes[i], testLink);
            if (isPresentInFile == true)
                break;
        }
        // if requested object found then Call MakeTOCChildItems()
        if (isPresentInFile == true) {
            // --- build DOM children
            makeTOCChildItems(childrenCell, rowObj.TOC_NODE);

            // --- remove waiting SPAN
            childrenCell.removeChild(waitingSpan);
            // --- reset status
            window.status = "";
            // --- reset status
            return true;
        }
        else {
            // --- remove loaded attribute
            rowObj.TOC_NODE.removeAttribute("loaded");

            childrenCell.removeChild(waitingSpan);
            // --- reset status
            window.status = "";
            return false;
        }

    }


    // --- add child TOC to DITEM node
    while (childTocRootNode.firstChild != null) {
        // --- remove node
        var node = childTocRootNode.firstChild;
        childTocRootNode.removeChild(node);
        // --- then append to TOC_NODE
        if (node.nodeType == 1)
            rowObj.TOC_NODE.appendChild(node);
    }

    // --- build DOM children
    makeTOCChildItems(childrenCell, rowObj.TOC_NODE);

    // --- remove waiting SPAN
    childrenCell.removeChild(waitingSpan);

    // --- reset status
    window.status = "";

    return true;

}

/*  V2E :IR-154927V6R2013x 
* Function  to check if url exist in nodeOBJ 
*/
function testForExistance(nodeOBJ, testLink) {
    var returnTest = false;
    var hrefAttValue;
    var hrefAttValue = "";

    try {
        hrefAttValue = nodeOBJ.getAttribute("href");
    }
    catch (e) {
    }

    if (testLink.indexOf(hrefAttValue) > 0)
        return true;
    var i = nodeOBJ.childNodes.length;
    i--;
    while (i >= 0) {
        returnTest = testForExistance(nodeOBJ.childNodes[i], testLink);
        if (returnTest == true)
            break;
        i--;
    }

    return returnTest;

}


// -----------------------------------------------------------------------
/**
* Builds the site map structure by analysing the ssm.htm file DOM.
*/
function rebuildSiteMapStructure(doc, parentElt) {
    var smRoot = doc.createElement("Root");
    var curPath = [smRoot];
    for (var i = 0; i < parentElt.childNodes.length; i++) {
        var elt = parentElt.childNodes[i];
        if (elt.nodeName == "P" && elt.className != null && elt.className.substr(0, 3) == "ssm") {
            // --- this is a site map node: create
            var newNode = doc.createElement("ITEM");
            var linkElts = elt.getElementsByTagName("A");
            if (linkElts == null || linkElts.length == 0) {
                DebugMessage("No link found in site map node " + elt);
            }
            else {
                if (linkElts.length > 1)
                    DebugMessage("" + linkElts.length + " links found in site map node " + elt + ". Taking first.");

                var relLink = buildRelativeLink(linkElts[0]);
                newNode.setAttribute("href", relLink);

                // --- retreive link text
                //				var linkText = linkElts[0].innerHTML;
                var linkText = linkElts[0].lastChild.nodeValue; // equivalent to innerText
                linkText = linkText.replace(/[\n\r\f]+/g, " "); // --- replaces return chars with blanks
                linkText = linkText.replace(/[ ]+/g, " "); // --- replaces a serie of blank with one blank
                newNode.setAttribute("name", linkText);
            }

            // --- append the node to its parent
            var level = parseInt(elt.className.substr(3));
            if (level == 2 && elt.style.marginLeft) {
                // --- extract left margin size
                var units = elt.style.marginLeft.substr(elt.style.marginLeft.length - 2, 2);
                //				DebugMessage("units: "+units);
                if (units == "px") {
                    var len = parseInt(elt.style.marginLeft.substr(0, elt.style.marginLeft.length - 2));
                    level += (len - 25) / 25;
                }
            }
            curPath[level] = newNode;
            curPath[level - 1].appendChild(newNode);
        }
    }
    return smRoot;
}

// -----------------------------------------------------------------------
/**
* Anchor icon click handler
* Expands and collapses TOC items
*/
function onClickTocAnchor(evt) {
    var obj = window.event ? event.srcElement : evt.target;

    //	DebugMessage("expand: "+obj.nodeName);
    // --- click on the anchor icon: collapse or expand children
    var rowObj = getFatherNode("TR", obj);
    var childrenRow = rowObj.nextSibling;
    if (childrenRow == null)
        return;
    var anchorIcon = obj;
    if (childrenRow.className == "TocCollapsed") {
        // --- expand
        childrenRow.className = "TocExpanded";
        anchorIcon.src = "FrameImages/DSDocIcon_tocMinus.png";

        loadChildrenIfNeeded(rowObj, true);
    }
    else {
        // --- collapse
        childrenRow.className = "TocCollapsed";
        anchorIcon.src = "FrameImages/DSDocIcon_tocPlus.png";
    }
    //if (!(navigator.appName.indexOf("Microsoft") != -1)) {
    hintcontainer.style.display = "none";
    // to show tooltip for ExpandAll/CollapseAll after user click on anchorObj
    showHint();
    // }
}

// -----------------------------------------------------------------------
/**
* TOC item link click handler
* Selects a TOC item
*/
function onClickTocItem(evt) {
    // difference IE & mozilla
    isClickedOnTOCItem = true;
    var linkObj = window.event ? event.srcElement : evt.target;
    var rowObj = getFatherNode("TR", linkObj);
    //HFJ for reference node.
    globalTOCrowObj = rowObj;
    eventTocItem = true;

    // --- 1: unselect current selection
    unselectTocItem();

    // --- reset synchronize button
    var syncLink = parent.frames["TocBar"].document.getElementById("SyncToc");
    syncLink.className = "SyncTocOff";

    // --- 2: select this item
    TOC_SELECTED_ITEM_ROW = rowObj;
    setTopToSecondLevelParent(rowObj);
    TOC_SELECTED_ITEM_ROW.className = "TocCurItem";

    // --- 3: expand children if needed
    var childrenRow = rowObj.nextSibling;
    if (childrenRow != null && childrenRow.className == "TocCollapsed") {
        // --- expand
        childrenRow.className = "TocExpanded";
        var anchorIcon = rowObj.cells[0].firstChild;
        anchorIcon.src = "FrameImages/DSDocIcon_tocMinus.png";

        // --- load children nodes if need be
        loadChildrenIfNeeded(rowObj, true);
    }
}

// -----------------------------------------------------------------------
/**
* Unselects the current selected item in TOC
*/
function unselectTocItem() {
    // --- 1: unselect current selection
    if (TOC_SELECTED_ITEM_ROW != null) {
        TOC_SELECTED_ITEM_ROW.className = "TocItem";
        TOC_SELECTED_ITEM_ROW = null;
    }
}

// -----------------------------------------------------------------------
/**
* Returns true if the current displayed file (in frame 'Main')
* is the current selection in TOC and visible (not collapsed path).
*/
///*
function isCurrentFileSelected() {

    if (TOC_DATA == null)
    // --- TOC now loaded yet: exit
        return true;

    var mainWin = parent.parent.frames["RightFS"].frames[MAIN_FRAMENAME];
    if (!isWindowLoaded(mainWin))
        return true;
    //hfj for eleminiting sync button
    //if(TOC_SELECTED_ITEM_ROW == null)
    //{
    // --- no selection yet: select file and expand
    //   selectCurrentFile();
    //  return true;
    // }
    selectCurrentFile(); //hfj for testing.
    ////
    // --- there is a selection: retrieive TOC item associated to the current url and check
    //hfj new
    var itemRow = getTOCItemFromURL(mainWin.document.location);

    if (itemRow == null) {
        // --- corresponding TOC item cannot be found: return true

        return true;
    }

    if (itemRow != TOC_SELECTED_ITEM_ROW)
        return false;
    // --- check that TOC_SELECTED_ITEM_ROW is displayed
    var curRow = itemRow;
    while (curRow != null) {
        var childrenRow = getFatherNode("TR", curRow.parentNode);
        if (childrenRow == null)
            break;
        if (childrenRow.className != "TocExpanded")
            return false;
        curRow = childrenRow.previousSibling;
    }
    return true;
}

// -----------------------------------------------------------------------
/**
* Expands and selects the current document file in the TOC
*/
function selectCurrentFile() {
    if (TOC_DATA == null)
    // --- TOC not loaded yet: exit
        return;

    // --- 1: update TOC path
    var mainWin = parent.parent.frames["RightFS"].frames[MAIN_FRAMENAME];
    if (!isWindowLoaded(mainWin))
        return;

    // --- first unselect current path
    unselectTocItem();

    // --- then select and expand the current doc path
    var itemRow = null
    // to resolve TOC sync problem
    // if user click on a link outside of TOC tree this section will execute
    if (TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM != null && !isClickedOnTOCItem) {
        itemRow = getTocItemFromSecondLevelParent(TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM);
    }
    if (itemRow == null) {
        itemRow = getTOCItemFromURL(mainWin.document.location);
    }
    // XWY: if an itemRow has not yet been found, use the following method on Abaqus docs.
    if (itemRow == null) {
        itemRow = getTOCItemFromURLThroughXMLStructure(mainWin.document.location);
    }
    //alert("itemRow "+itemRow.innerHTML );
    if (itemRow == null)
        return;

    // --- 1: expand path
    var curRow = itemRow;
    while (curRow != null) {
        var childrenRow = getFatherNode("TR", curRow.parentNode);
        if (childrenRow == null)
            break;
        childrenRow.className = "TocExpanded";
        // -- set minus icon
        curRow = childrenRow.previousSibling;
        if (curRow != null) {
            var anchorIcon = curRow.cells[0].firstChild;
            anchorIcon.src = "FrameImages/DSDocIcon_tocMinus.png";
        }
    }
    // --- 2: select item
    TOC_SELECTED_ITEM_ROW = itemRow;
    TOC_SELECTED_ITEM_ROW.className = "TocCurItem";

    // --- 3: scroll item into view
    var container = document.body;
    var obj = TOC_SELECTED_ITEM_ROW;
    var absPosition = getAbsPos(obj);
    var top = absPosition[1];
    //	DebugMessage("about to scroll into view. top="+top+", height="+obj.offsetHeight+", scrollTop="+container.scrollTop+", clientHeight="+container.clientHeight);
    if (top < container.scrollTop)
    // --- obj is above scroll view
        container.scrollTop = top;
    else if (top + obj.offsetHeight > container.scrollTop + container.clientHeight)
    // --- obj is under scroll view
        container.scrollTop = top + obj.offsetHeight - container.clientHeight;
    //no: always scrolls	TOC_SELECTED_ITEM_ROW.scrollIntoView(true);
    //alert("itemRow "+itemRow.innerHTML );
}

//--------------------------------------------------------------
function getHTTPObject() {
    var xmlhttp;

    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)  // Windows HTML Object
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        if (!xmlhttp) {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    return xmlhttp;
}

//--------------------------------------------------------------
function clearFlag() {
    eventTocItem = false;
    globalTOCrowObj = null;
    globalLastDomObj = lastDomObj;
}

//=================================================================================================
// Functions for ExpandAll/CollapseAll
//--------------------------------------------------------------
function expandAll(rowObj, obj) {
    var childrenRow = rowObj.nextSibling;
    if (childrenRow == null)
        return;
    var anchorIcon = obj;
    if (childrenRow.className == "TocCollapsed") {
        // --- expand
        childrenRow.className = "TocExpanded";
        anchorIcon.src = "FrameImages/DSDocIcon_tocMinus.png";
        setTimeout(function () { introduceDelay(rowObj) }, 0);
    }
}
//--------------------------------------------------------------
// This function will display the children while complete processing is to be done.
// Intended to give the Firefox like beahaviour to IE   
function introduceDelay(rowObj) {
    //load if children present
    loadChildrenIfNeeded(rowObj, true);
    // search for present children
    expandAllChildren(rowObj, true);
}
//--------------------------------------------------------------
function onClickExpandAll() {
    var obj = anchorObj; //window.event ? event.srcElement : evt.target;
    var rowObj = getFatherNode("TR", obj);
    expandAll(rowObj, obj);
    // to remove tooltip after clicking on ExpandAll/CollapseAll link inside tooltip
    hideHint();
}
//--------------------------------------------------------------
function expandAllChildren(rowObj, asynch) {
    // take next element 
    var childrenRow = rowObj.nextSibling;
    //take all TR element under childrenRow
    var anchorElements = childrenRow.getElementsByTagName("TR");
    var isOneExe = false;
    for (var i = 0; i < anchorElements.length; i++) {
        var anchor = anchorElements[i];
        if (anchor.className == "TocItem") {
            var imgs = anchor.getElementsByTagName("IMG");
            for (var j = 0; j < imgs.length; j++) {
                var anchorIcon = imgs[j];
                if (anchorIcon.src.endsWith("FrameImages/DSDocIcon_tocPlus.png")) {
                    expandAll(anchor, anchorIcon);
                }
            }
        }
    }
    return true;
}
//--------------------------------------------------------------
function onClickCollapseAll() {
    var obj = anchorObj; //window.event ? event.srcElement : evt.target;
    var rowObj = getFatherNode("TR", obj);
    collapseAll(rowObj, obj);
    // to remove tooltip after clicking on ExpandAll/CollapseAll link inside tooltip
    hideHint();
}
//--------------------------------------------------------------
function collapseAll(rowObj, obj) {
    var childrenRow = rowObj.nextSibling;
    if (childrenRow == null)
        return;
    var anchorIcon = obj;
    if (childrenRow.className == "TocExpanded") {
        // search for present children
        collapseAllChildren(rowObj, true);
        childrenRow.className = "TocCollapsed";
        anchorIcon.src = "FrameImages/DSDocIcon_tocPlus.png";
    }
}
//--------------------------------------------------------------
function collapseAllChildren(rowObj, asynch) {
    // take next element 
    var childrenRow = rowObj.nextSibling;
    //take all TR element under childrenRow
    var anchorElements = childrenRow.getElementsByTagName("TR");
    var isOneExe = false;
    for (var i = 0; i < anchorElements.length; i++) {
        var anchor = anchorElements[i];
        if (anchor.className == "TocItem") {
            var imgs = anchor.getElementsByTagName("IMG");
            for (var j = 0; j < imgs.length; j++) {
                var anchorIcon = imgs[j];
                if (anchorIcon.src.endsWith("FrameImages/DSDocIcon_tocMinus.png")) {
                    collapseAll(anchor, anchorIcon);
                }
            }
        }
    }
    return true;
}
// End of Functions for ExpandAll/CollapseAll
//=================================================================================================

//===================================================================================================
// To resolve problems of TOC synchronization

// To set TOC second level parent from top for currently selected node
//--------------------------------------------------------------
function setTopToSecondLevelParent(curClickedItem) {
    var topLevel = getTopLevelFromCurrentNode(curClickedItem);
    TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM = getSecondLevelParent(topLevel, curClickedItem);
}
//--------------------------------------------------------------
// To get no. of levels of TOC for currently selected node
function getTopLevelFromCurrentNode(currentClickedItem) {
    var topLevel = 0;
    var topLevelObj = currentClickedItem;
    var curLevelObj = currentClickedItem;
    while (topLevelObj != null) {
        topLevelObj = getFatherNode("TR", curLevelObj.parentNode);
        if (topLevelObj != null) {
            if (topLevelObj.innerHTML == curLevelObj.innerHTML) {
                topLevel++;
                break;
            }
        }
        topLevel++;
        curLevelObj = topLevelObj
    }
    return topLevel;
}
//--------------------------------------------------------------
// To take TOC Parent for currently selected node 
// take argument 
// 1) no. of total level from currently selected node
// 2) currently selected node 
function getTargetedParent(totalLevel, curLevelParent) {
    var secondLevelParent = curLevelParent;
    for (var j = 1; j <= totalLevel; j++) {
        secondLevelParent = getFatherNode("TR", secondLevelParent.parentNode);
    }
    return secondLevelParent;
}
//--------------------------------------------------------------
// To take TOC secend level parent from top for currently selected node
function getSecondLevelParent(ultimateLevel, currentItem) {
    var secondLevelParent = null;
    switch (ultimateLevel) {
        case 5:
            secondLevelParent = getTargetedParent(3, currentItem);
            break;
        case 4:
            secondLevelParent = getTargetedParent(2, currentItem);
            break;
        case 3:
            secondLevelParent = getTargetedParent(1, currentItem);
            break;
        default:
            return null;
    }
    return secondLevelParent;
}
//--------------------------------------------------------------
// To take currently selected node from TOC secend level parent from top
function getTocItemFromSecondLevelParent(tocSecondLevelParent) {
    // to take window which shows currently selected page.
    var mainWin = parent.parent.frames["RightFS"].frames[MAIN_FRAMENAME];
    // to take url for selected node
    var locationObj = mainWin.document.location;
    var url = buildRelativeLink(locationObj, parent.parent.location);
    // build object Id of selected node
    var objId = "HREF@" + url;
    var directory = null;
    // to know directory in which selected node resides
    var args = extractParamsFromLocation(locationObj);
    if (args["dir"] != null) {
        directory = args["dir"];
        objId = objId + "?dir=" + directory;
    } else {
        var idx = url.lastIndexOf("/");
        if (idx >= 0) {
            directory = url.substr(0, idx);
            idx = directory.lastIndexOf("/");
            if (idx >= 0)
                directory = directory.substr(idx + 1);
        }
    }
    // return selected node
    return getTargetedTocItem(TOC_SECOND_LEVEL_FOR_CUR_SEL_ITEM.childNodes[1].childNodes[0].childNodes[0], objId);
}
//--------------------------------------------------------------
//  To take currently selected node
// take two arguments
// 1) rowObj: TOC seceond level parent from top for previously selected node
// 2) objId: objId for currently selected item
function getTargetedTocItem(rowObj, objId) {
    var targetedObj = null;
    if (rowObj != null) {
        var rows = null;
        // all children of rowObj
        rows = rowObj.childNodes;

        if (rows != null) {
            for (var j = 0; j < rows.length; j++) {
                var row = rows[j];
                if (row != null) {
                    // check if objId match with id of child
                    if (row.id == objId) {
                        // match found 
                        targetedObj = row;
                        // break the loop
                        break;
                        // if child is having children
                    } else if (row.className == "TocItem" || row.className == "TocCurItem") {
                        // take next sibling
                        var childrenRow = row.nextSibling;
                        // check whether this node is collapsed
                        if (childrenRow != null && childrenRow.className == "TocCollapsed") {
                            childrenRow.className = "TocExpanded";
                            var anchorIcon = row.cells[0].firstChild;
                            anchorIcon.src = "FrameImages/DSDocIcon_tocMinus.png";
                            // load this node children
                            loadChildrenIfNeeded(row, true, objId, true);
                            // look for target in loaded children
                            var tmpObj = null;
                            try {
                                // V2E: IR-154927V6R2013x 
                                // With changes to loadchildrenIfNeeded
                                // Sometimes it does not call makeTOCChildIems So there are no childrens
                                if (row.nextSibling.childNodes[1].childNodes[0].childNodes[0] != null)
                                    tmpObj = getTargetedTocItem(row.nextSibling.childNodes[1].childNodes[0].childNodes[0], objId);

                            }
                            catch (e) {
                            }
                            // target not found
                            if (tmpObj == null) {
                                // collapse this node
                                collapseIt(row);
                                // target found
                            } else if (tmpObj != null) {
                                // set the target
                                targetedObj = tmpObj;
                                // break the loop
                                break;
                            }
                            // check whether this node is expanded
                        } else if (childrenRow != null && childrenRow.className == "TocExpanded") {
                            // look for target in children
                            var tmpObj = getTargetedTocItem(row.nextSibling.childNodes[1].childNodes[0].childNodes[0], objId);
                            // target found
                            if (tmpObj != null) {
                                // set target
                                targetedObj = tmpObj;
                                // break the loop
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    // return target
    return targetedObj;
}
//--------------------------------------------------------------
// to collapse expanded node
function collapseIt(rowObj) {
    var childRow = rowObj.nextSibling;
    if (childRow != null && childRow.className == "TocExpanded") {
        childRow.className = "TocCollapsed";
        var anchorIcon = rowObj.cells[0].firstChild;
        anchorIcon.src = "FrameImages/DSDocIcon_tocPlus.png";
    }
}
// End of methods for TOC sync problem
//==============================================================================================================

//==============================================================================================================
// To verify existence of file mentioned on href attribute in ITEM tag
function isFileExist(url) {
    var appName = navigator.appName;
    var oHttp = null;
    var isfileexist = false;
    if (appName.indexOf("Netscape") != -1) {
        if (window.XMLHttpRequest) {
            oHttp = new XMLHttpRequest();
        }
    } else if (appName.indexOf("Microsoft") != -1) {
        if (window.ActiveXObject) {
            oHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (oHttp == null) {
            oHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    if (oHttp != null) {
        // open a connection with head method 
        try {
            oHttp.open("HEAD", url, false);
            oHttp.send(null);
            if (oHttp.status == 404)
                isfileexist = false
            else
                isfileexist = true;
        } catch (e) {
        }
    }
    return isfileexist;
}
