    //Variable Declarations
    var targetFrame, type, selectedObject, eventVerify, cntMenuOptions, NodeStatusBarString;
    var URL, myNode, nodeNotes, showNotesClick, treeNodeIndex, treeNodeID, treeNodeHref;
    var nav, ie6_up, nav6_up, usrAgent, isNotesOn, isDownloadOff, isBrowseOff;
    var dispNotes, ActiveTreeViewNumber;
    var oldNodeIndex = -1;
    var bFirstLoad = true;  
    var MenuWidth=0, MenuHeight=0;
    var linkRelIdForDownload = null;

function Init(){

    if(typeof(ShowInaccessibleMessage)!="undefined" && ShowInaccessibleMessage)
    {
        alert(ResInaccessibleMessage);
    }
    if(typeof(ShowSessionExpiredMessage)!="undefined" && ShowSessionExpiredMessage)
    {
        alert(SessionExpiredMessage);
    }
    
    ob_tree_id = document.getElementById("preselected").innerHTML;
    if (TabExist(ob_tree_id))
            SelectInTree(ob_tree_id);
    else
        ChangeTab(0);
    //*****************************************************************
    //Initialization of Variables.
    //FOR IE6.x only
    //ActiveTreeView = (tsHoriz.selectedIndex > 0) ? "tvwEzParts" + tsHoriz.selectedIndex : "tvwEzParts";
    //--ActiveTreeView ="tvwEzParts0";  
    
    //stores the nodeIndex which is currently selected.  FOR IE6.x  
    //treeNodeIndex = document.all(ActiveTreeView).selectedNodeIndex;
     
    //stores the reference page and nodeId which is currently selected.  FOR IE5.x and Netscape 6.x.
    treeNodeHref = treeNodeID = "";
    //Are boolean variables to check which option is selected on the context menu, and what is
    //the client navigator type.
    isDownloadOff = isBrowseOff = isNotesOn = false;
    //usrAgent = navigator.userAgent;
    
    //eventVerify = false;
    //*****************************************************************             
    //cntMenuOptions = 0;
    //var divElements;
    //divElements = document.getElementsByTagName("DIV");
    //cntMenuOptions = 3;
    //if (nav)
    //  divElements[1].style.visibility = "visible";
    //else
    //  divElements[1].style.display = "";

    //*****************************************************************
    //Binding events.

    //Since Netscape Navigator and IE5.x, both the browsers does not directly support the tree component.
    //The tree get formatted in the form of Anchor Tags.  Using getElementByTagName we recognize tree anchor
    //tags and then bind different events to them.
    if (NS6_up)
    {
        //var currentElement, i;
        //i = 0;
        
        //var myDocumentElements = document.getElementsByTagName("A");
        //for(i = 0; i < (myDocumentElements.length - 2); i++)
        //{
        //  currentElement = myDocumentElements[i];
        //  currentElement.addEventListener("mouseover", fillLabel, false);
        //  currentElement.addEventListener("mouseout", emptyLabel, false);
        //  currentElement.addEventListener("mousedown", netscapeMouseDown, false);
        //  currentElement.addEventListener("click", netscapeMouseDown, false);
        //  setTreeNodes(currentElement);
        //}
        document.getElementById("menu").addEventListener("mouseover", donthide, false);
        document.getElementById("menu").addEventListener("mouseout", hideit, false);
    }

    if (!NS && !IE6_up)
    {
    //IE5 and IE5.x Only.
        //var currentElement, i;
        
        //i = 0;
        
        //var myDocumentElements = document.getElementsByTagName("A");
        //for(i = 0; i < (myDocumentElements.length - cntMenuOptions); i++)
        //{
        //  currentElement = myDocumentElements[i];
        //  currentElement.onmouseover = fillLabel;
        //  currentElement.onmouseout = emptyLabel;
        //  currentElement.oncontextmenu = displayLocation;
        //  currentElement.onclick = nodeClick;
        //  setTreeNodes(currentElement);
        //  if (i == 0)
        //      treeNodeID = currentElement.getAttribute("id");
        //}
        menu.onmouseover = donthide;
        menu.onmouseout = hideit;
    }

    if (IE6_up)
    {
        //will get executed for IE6.x, this browser directly support the Microsoft.web.ui.webControls.TreeView Component.
        //so events can be trapped directly.
        //document.all("tsHoriz").attachEvent("onselectedindexchange", tsIndexChange);
        //document.all(ActiveTreeView).onselectedindexchange = selIndexChange;
        //document.all(ActiveTreeView).attachEvent("onexpand", expand);
        //document.all(ActiveTreeView).attachEvent("oncollapse", collapse);
        //document.all(ActiveTreeView).attachEvent("onclick",clickedNode);
        //document.all(ActiveTreeView).oncontextmenu = displayLocation;
        //document.all(ActiveTreeView).onhover = fillLabel;
        //document.all(ActiveTreeView).onunhover = emptyLabel;
        menu.onmouseover = donthide;
        menu.onmouseout = hideit;
        //document.oncontextmenu = function doc(e){return false;}
    }
    //ScrollTreeView();
    //document.all(ActiveTreeView).style.left = 0;
    //document.all(ActiveTreeView).style.top = 0;
    //if (type == null)
    //  setNodeValues(treeNodeIndex);
    //displayStatusBar();
    
    enableImgSearch();
}
function SelectInTree(TabIndex)
{       
    var selId_s = new String();
    var hfld = document.getElementById("TreeSelIDs_"+TabIndex);
    if(typeof(hfld) == "undefined" || hfld == null)return;  
    selId_s = document.getElementById("TreeSelIDs_"+TabIndex).value
    
    //Asigning global variable
    ob_tree_id = TabIndex;  
    var SelectedNode = document.getElementById(selId_s+"_"+GetTabNameByIndex(TabIndex));
    
    if(typeof(SelectedNode)!= "undefined" && SelectedNode != null)
    {   
        ob_t25(SelectedNode);
        var ResType = SelectedNode.firstChild.attributes.RType.value;
        var ModelId = (ResType == "M" 
                    ? SelectedNode.firstChild.attributes.LRId.value 
                    : SelectedNode.firstChild.attributes.ModelID.value);
        if(ModelId != "" && typeof(top.fraToolbar.SelectModel)!="undefined")
            top.fraToolbar.SelectModel(ModelId);
        //manageSchematic(SelectedNode.firstChild.attributes.LRId.value, ResType);
    }
    

    /*if(typeof(document.getElementById('root'))!="undefined")
    {
        ob_t25(document.getElementById('root'))
    }
    else
    {
        alert("SelectedId is not unique or does not exist.")
    }
    //ob_sids=new Array("87","18034","18092");
    ob_tree_id = TabIndex;
    ob_iar = 0;
    ob_sids = selId_s.split(',');
    ob_last = ob_sids[ob_sids.length-1];
    ob_sids.pop();
    ob_t26();*/
}

function enableImgSearch()
{
    if(top.fraToolbar.document.images["ImgSearch2"] != null)
    {

        top.fraToolbar.document.images["ImgSearch2"].src = "Icons/REFRESH.gif"; 
        top.fraToolbar.document.images["ImgSearch2"].disabled = false;
    }
}

function disableImgSearch()
{   
    if(top.fraToolbar.document.images["ImgSearch2"] != null)
    {
        top.fraToolbar.document.images["ImgSearch2"].src = "Icons/REFRESH_disable.gif"; 
        top.fraToolbar.document.images["ImgSearch2"].disabled = true;
    }
}

function displayStatusBar(e){
//  if (NodeStatusBarString != null)
    if(IE)      
        LogError("LinkRelID: "+event.srcElement.parentElement.attributes.LRId.value);
    else
        LogError("LinkRelID: "+e.currentTarget.attributes.LRId.value);
}

/*function tsIndexChange()
{
    ActiveTreeView = (tsHoriz.selectedIndex > 0) ? "tvwEzParts" + tsHoriz.selectedIndex : "tvwEzParts";
    document.all(ActiveTreeView).onselectedindexchange = selIndexChange;
    document.all(ActiveTreeView).attachEvent("onexpand", expand);
    document.all(ActiveTreeView).attachEvent("oncollapse", collapse);
    document.all(ActiveTreeView).attachEvent("onclick",clickedNode);
}*/

/*function setTreeNodes(currentElement)
{
    //is executed for both Netscape6.x and IE5.x
    var posType, posNotes, posID, currentType, currentNotes, currentID, currentHref;
    //===========================================================================================
    //The string which comes from the server is in the form of
    //Type=xxxx, Notes=xxxx, Index=xxxx, and here we are fetching the values for all not the
    //constant text like Type=/Notes=/Index=, and assign to element properties, which can be
    //fetched later on.
    posTitle = 0;
    posType = 0;
    posNotes = 0;
    posID = 0;
    currentTitle = "";
    currentHref = "";
    currentNotes = "";
    currentType = "";
    currentID = "";
    
    currentHref = currentElement.getAttribute("href");

    if(currentHref.indexOf("type=", 0) >= 0)
    {
        posTitle = currentHref.indexOf("text=", 0);
        posType = currentHref.indexOf("type=", 0);
        posNotes = currentHref.indexOf("notes=", 0);
        posID = currentHref.indexOf("index=", 0);
        
        currentTitle = currentHref.substring(posTitle, posType);
        currentType = currentHref.substring(posType, posNotes);
        currentNotes = currentHref.substring(posNotes, posID);
        currentID = currentHref.substring(posID, currentHref.length);
        currentHref = currentHref.substring(0, posTitle);
    }
    //===========================================================================================
    //The string which comes from the server is in the form of
    //Type=xxxx, Notes=xxxx, Index=xxxx, and here we are fetching the values only except the part before =.
    //Since sometimes Notes can be empty also, so with conditions we are checking if the values are present or not.

        if ((trim(currentTitle) != "") && (currentTitle.length > 5))
            currentTitle = currentTitle.substring(5, currentTitle.length);
        else
            currentTitle = "";
                    
        if ((trim(currentType) != "") && (currentType.length > 5))
            currentType = currentType.substring(5, currentType.length);
        else
            currentType = "";

        
        if ((trim(currentNotes) != "") && (currentNotes.length > 6))
            currentNotes = currentNotes.substring(6, currentNotes.length);
        else
            currentNotes = "";

    
        if ((trim(currentID) != "" ) && (currentID.length > 8))
            currentID = currentID.substring(6, currentID.length);
        else
            currentID = "";
    //===========================================================================================   
    //setting different attributes/properties which are supported by Netscape/IE.   
    //to store the Type of node, Notes associated with Nodes, and the Href.
    
    while(currentTitle.indexOf("%20",0) > 0)
    {
        currentTitle = currentTitle.replace("%20"," ");
        currentTitle = currentTitle.replace("&nbsp;"," ");
    }
    
    currentElement.setAttribute("title", currentTitle);
    currentElement.setAttribute("id", currentID);
    currentElement.setAttribute("href", currentHref);
    
    if (nav6_up)
    {
        currentElement.setAttribute("nodeType", currentType);
    }
    else
    {
        currentElement.setAttribute("text", currentType);
        currentElement.setAttribute("tag", currentNotes);
    }

}*/
//===========================================================================================   

        function ltrim ( s )
        {
            if(s == null) return "";
            return s.replace( /^\s*/, "" );
        
        }
//================================================================================================
        function rtrim ( s )
        {
            if(s == null) return "";
            return s.replace( /\s*$/, "" );
        
        }
//================================================================================================
        function trim ( s )
        {
            if(s == null) return "";
            return rtrim(ltrim(s));
        
        }

//*****************************************************************
//Function Definitions.
function netscapeMouseDown(e)
{
    selectedObject = this;
    if (e.which == 3)
    {
        displayLocation(e);
    }
    else
    {
        if (selectedObject == null) return false;
        nodeClick();
    }
}

/*function nodeClick()
{
    disableImgSearch();
    
    treeNodeID = selectedObject.getAttribute("id");
    type = trim(selectedObject.getAttribute("nodeType"));
    if ( trim(type) == "z" || trim(type) == "Z")
    {
        top.parent.document.getElementById("fragrid").style.visibility = "visible";
        //top.parent.document.all("fragrid").style.display = "";
    }
    else
    {
        top.parent.document.getElementById("fragrid").style.visibility = "hidden";
        //if (trim(type) != "") 
            //top.parent.document.all("fragrid").style.display = "none";
    }

    if ( trim(type) == "z" || trim(type) == "Z" || trim(type) == "u" || trim(type) == "U")
        top.fraToolbar.DisableZoom();
}*/

/*function clickedNode()
{        
    bFirstLoad = false;
    var obj = event.srcElement;
    if (obj == null) return;
    var node = obj.getTreeNode(obj.clickedNodeIndex);
    if (node == null) return;
    if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID") != null)
        document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID").value = node.getAttribute("id");
    var bExpandable = node.getAttribute("expandable");
    if(oldNodeIndex != obj.clickedNodeIndex && bExpandable)
        disableImgSearch();
    // expand/collapse on click
    if(obj.getAttribute("ExpandOnlyOnClick")=="false"){
        node.setAttribute("EXPANDED", !node.getAttribute("EXPANDED"));
        if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand") != null)
            document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand").value = node.getAttribute("EXPANDED");
        return;
    }
    
    try
    {
        // only expand on click
        if (node != null)
        {
            if(node.getAttribute("EXPANDED") == false)
                node.setAttribute("EXPANDED", true);    
            if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand") != null)
                document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand").value = node.getAttribute("EXPANDED");
            if (document.getElementById("SelectedID") != null)
                document.getElementById("SelectedID").value = node.getAttribute("id");
        }
    }
    catch(ex){LogError("Unable to Expand Node"); }
    if (obj.clickedNodeIndex != null)
        setNodeValues(obj.clickedNodeIndex);
    //if (node != null)
    //  manageNotes( node.getAttribute("id") );
}*/

/*function expand()
{
    var obj = event.srcElement;
    if (obj == null) return;
    var node = obj.getTreeNode(obj.clickedNodeIndex);
    if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID") != null)
        document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID").value = node.getAttribute("id");
    if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand") != null)
        document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand").value = true;
}*/

/*function collapse()
{
    var obj = event.srcElement;
    if (obj == null) return;
    var node = obj.getTreeNode(obj.clickedNodeIndex);
    if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID") != null)
        document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedID").value = node.getAttribute("id");
    if (document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand") != null)
        document.getElementById(document.all(ActiveTreeView).getAttribute("id") + "SelectedExpand").value = false;
}*/
  
/*function selIndexChange()
{   
    //For IE6.x
    var treeNodeIndex = window.event.newTreeNodeIndex;
    
    treeNodeID = document.all(ActiveTreeView).getTreeNode(treeNodeIndex).getAttribute("id"); 
    manageNotes(treeNodeID);
    
    if (ie6_up)
    {
        //Sets the value of different global variables whenever a tree node get Clicked.
        //for IE6.x 
        setNodeValues(treeNodeIndex);
    }   
    
//Added By Sandeep For Send To Functionality
//Toolbar Form has 2 hidden controls, which stores the value of last resource clicked.
//One is for Id of the node and other is for Type of the node
    type = document.all(ActiveTreeView).getTreeNode(treeNodeIndex).getAttribute("type");
    if (top.parent.frames("fraToolbar")!=null)
        top.parent.frames("fraToolbar").PrintEnable();
    if(type.toUpperCase()=='Z')
        top.parent.frames("fraToolbar").PrintEnable();
    else
        top.parent.frames("fraToolbar").PrintDisable();
        
    if (trim(type) == 's' || trim(type) == 'S' || trim(type) == 'u' || trim(type) == 'U')
        top.parent.frames("fraToolbar").DisableZoom();
    
    eventVerify = true;
}*/

/*function setNodeValues(nodeIndex)
{
    if (nodeIndex == null) return;
    myNode = document.all(ActiveTreeView).getTreeNode(nodeIndex);
    if(myNode == null) return;
    oldNodeIndex = nodeIndex;
    targetFrame = trim(myNode.getAttribute("target"));
    URL = trim(myNode.getAttribute("navigateUrl"));
    type = trim(myNode.getAttribute("type"));
    if (typeof(top.parent.fraToolbar)!=undefined&&top.parent.fraToolbar != null)
        top.parent.fraToolbar.ResourceType = type;
    if (type=="m"){
        top.parent.fraToolbar.SelectModel(myNode.getAttribute("id"));
    }
    else
    {
        if(myNode.getAttribute("nodeData"))
            top.parent.fraToolbar.SelectModel(myNode.getAttribute("nodeData"));         
    }
    
    if (document.getElementById("StatusBarString") != null)
        var lStatuses = document.getElementById("StatusBarString").value;
        var NodeID = ";;" + myNode.getAttribute("id") + "==";
        var lFoundIdx = lStatuses.indexOf(NodeID) + 2;
        var larray
        if ( lFoundIdx > 1){
            larray = lStatuses.substr(lFoundIdx).split(";;");
            larray = larray[0].split("==");
            NodeStatusBarString = larray[1];
            displayStatusBar();
        }
}  */

//This method is managing all the frame sizeing, based on the type of node is clicked.
//The node can be a modal, schematic, shell, bmp/gif/jpg image, URL.
function manageSchematic(LinkRelId, res_type)
{
    
    ManageFramesVisibility(res_type);
    if(LinkRelId == 0)return;
    if (trim(res_type.toLowerCase()) == "x")
    {
      window.open("wfrmSchematic.aspx?linkRelId="+LinkRelId, "_blank");
    }
    else
    {
       top.fraimage.location.href = "wfrmSchematic.aspx?linkRelId="+LinkRelId;
    }
}
function manageNotes(linkRelId)
{
    top.fraNotes.location.href = "wfrmNotes.aspx?LinkRelID=" + linkRelId;
}
function ManageFramesVisibility(res_type)
{
    if (res_type == null) res_type = "NONE";

    var lFlag = (res_type.toUpperCase() == "Z") ? 1 : 0;
    top.ProcessVisible(lFlag);
}
/*function manageNotes_type(id, res_type){  
    if (res_type == null) return;   
    var lFlag = (res_type.toUpperCase() == "Z") ? 1 : 0;
    top.ProcessVisible(lFlag);
    if(id==0)return;

    top.fraimage.location.href = "wfrmSchematic.aspx?linkRelId=" +id;*/
    /*try{  
        if( top.parent.fraNotes.document.getElementById("LinkRelId")==null||
            top.parent.fraNotes.document.getElementById("LinkRelId").value != id &&
            (top.parent.fraimage.document != null && (top.parent.fraimage.document.getElementById("hIsNotelinkRelId") == null ||
            top.parent.fraimage.document.getElementById("hIsNotelinkRelId").value.toLowerCase() == "false")))       
        {
            var ind = document.all(ActiveTreeView).selectedNodeIndex;
            var node = document.all(ActiveTreeView).getTreeNode(ind);
            if(!bFirstLoad || (node.getParent != null) || (node.getParent == null && node.getAttribute("Expandable") == false))
                top.parent.fraNotes.location.href = "wfrmNotes.aspx?LinkRelID=" + id;       
        }   
    }
    catch(ex){
        return;
    }       
}*/
/*function manageNotes(id)
{   
    if(typeof(top.fraToolbar) != undefined&&top.fraToolbar != null&&typeof(top.fraToolbar.ResourceType) != undefined&&top.fraToolbar.ResourceType != null)
        manageNotes_type(id, top.fraToolbar.ResourceType);          
}*/
function displayLocation(e)
{
//This Procedure gets called when ever user right clicks on the tree.
//This procedure traps the x and y cordinates on the screen and then display the Context Menu
//at that position.  e is the event handle, which is passed implicitly by the netscape navigator.
    
    var VDiff, HDiff, Top, Left;
    if(IE6_up)
        event.cancelBubble = true;
    else if(NS6_up)
        e.cancelBubble = true;

    if (NS6_up)
    { 
        //For Netscape Navigator 6 and heigher
        //type = trim(selectedObject.getAttribute("nodeType"));
        type = e.currentTarget.attributes.RType.value;
        treeNodeHref = "wfrmSchematic.aspx?linkRelId=" + e.currentTarget.attributes.LRId.value;
        linkRelIdForDownload = e.currentTarget.attributes.LRId.value;

        //if the user has right clicked on a shell then enable the browse and download options.
        shellSelected(type);
        if (e.type == "contextmenu")        
        {           
            MenuWidth = (document.getElementById('menu').clientWidth > 0 ? document.getElementById('menu').clientWidth : MenuWidth);
            MenuHeight =(document.getElementById('menu').clientHeight > 0 ? document.getElementById('menu').clientHeight : MenuHeight);     
            
            Top = e.clientY + document.body.scrollTop;
            Left = e.clientX + document.body.scrollLeft;    
        
            //alert("document.body.clientHeight: " + document.body.clientHeight);
            //alert("menu.clientHeight: "+document.getElementById('menu').clientHeight);

            VDiff = (MenuHeight + e.clientY) - document.body.clientHeight;
            HDiff = (MenuWidth + e.clientX) - document.body.clientWidth;

            Top-= (VDiff > 0 ? MenuHeight : 0);
            Left-= (HDiff > 0 ? HDiff+5: 0);
            
            document.getElementById("menu").style.top = Top;
            document.getElementById("menu").style.left = Left;

            document.getElementById("menu").style.display = '';
            document.getElementById("menu").style.visibility = 'visible';
            return false;
        }
    }
    else if (!NS)
    {   
        type = event.srcElement.parentElement.attributes.RType.value;       
        treeNodeHref = "wfrmSchematic.aspx?linkRelId=" + event.srcElement.parentElement.attributes.LRId.value;
        linkRelIdForDownload = event.srcElement.parentElement.attributes.LRId.value;

        //if the user has right clicked on a shell then enable the browse and download options.
        shellSelected(type);

        if(event.type == "contextmenu")
        {
            Top = event.clientY + document.body.scrollTop;
            Left = event.clientX + document.body.scrollLeft;    
                
            VDiff = (document.getElementById('menu').clientHeight + event.clientY) - document.body.clientHeight;
            HDiff = (document.getElementById('menu').clientWidth + event.clientX) - document.body.clientWidth;

            Top-= (VDiff > 0 ? document.getElementById('menu').clientHeight : 0);
            Left-= (HDiff > 0 ? HDiff+5: 0);
            
            document.all['menu'].style.pixelTop = Top;
            document.all['menu'].style.pixelLeft = Left;
            document.getElementById("menu").style.display = '';
            document.getElementById("menu").style.visibility = 'visible';
            return false;
        }       
    }
    return false;
}

function shellSelected(type)
{
//This procedure accepts the type parameter, to check whether the right clicked node is 
//Shell or not.  If Yes then enables the Download and Browse Options, otherwise not.
    if (type == 's' || type == 'S' || type == 'z' || type == 'Z')
    {
        isDownloadOff = false;
        setContextMenuOnn("Download");
        isBrowseOff = false;
        setContextMenuOnn("Browse");
    }
    else
    {
        isDownloadOff = true;
        setContextMenuOff("Download");
        isBrowseOff = true;
        setContextMenuOff("Browse");
    }               
}

function setContextMenuOff(obj)
{
//This procedure accepts the id of the context menu options and disable it.  Accepts the 
//Id as parameters of the selected menu option.
    if (!NS)
    {
      var object = document.all(obj);
    } else if(NS6_up)
    {
       var object = document.getElementById(obj);
    }
    //if (obj == "showNotes") isNotesOn = false;
    
    /*if (IE6_up)
        object.disabled = true;         */
    object.className = 'disabled';
}

function setContextMenuOnn(obj)
{
//This procedure accepts the id of the context menu options and enables it.  Accepts the 
//Id as parameters of the selected menu option.
    if (!NS)
    {
        var object = document.all(obj);
    } else if(NS6_up)
    {
        //For Netscape Navigator 6 and heigher
        if (obj == "showNotes")
        {
            var objects = document.getElementsByTagName("a");
            var object = objects[12];
        }
        else
            var object = document.getElementById(obj);
    }
    if (obj == "showNotes") isNotesOn = true;
    
    //object.disabled = false;
    /*if (!IE6_up || NS6_up)
        object.style.color = 'black';*/
    object.className = 'enabled';
    //object.style.display = 'block';
}

function fillLabel()
{
//This procedure gets called when the mouseover/hover event gets fired, of any node.  and fills in the
//label with value in, which gets checked when user right clicks on the node.
    document.getElementById("lblNodeId").innerText = "IN";
}

function emptyLabel()
{
//This procedure gets called when the mouseout/unhover event gets fired, of any node. and empties the
//label value, which gets checked when user right clicks on the node.
    document.getElementById("lblNodeId").innerText = "";
}

function donthide()
{
    //This procedure shows the Context Menu. and get fired when the mouse is over the context menu.
    if (!NS)
        document.all['menu'].style.display = '';
    else if (NS6_up)
        document.getElementById("menu").style.visibility = 'visible';
}

function hideit()
{
    //This procedure hides the Context Menu. and get fired when the mouse moves out of the context menu.
    if (!NS)
        document.all['menu'].style.display = 'none';
    else if (NS6_up)
        document.getElementById("menu").style.visibility = 'hidden';
}

function setSelectionOn(obj)
{
//This procedure gets called when user moves the mouseover any option in the context menu.
//and, this procedure changes the display style of that particular option.  Accepts the 
//Id as parameters of the selected menu option.
    if (!IE6_up || NS6_up)
    {
        if (obj == "showNotes" && !isNotesOn) return;
    }
    
    if (!NS)
    {
        //For All Versions of IE
        var object = document.all(obj);
    }
    if(NS6_up)
    {
        //For Netscape Navigator 6 and heigher
        var object = document.getElementById(obj);
    }
    
    if (obj == "Download" && isDownloadOff) return;
    if (obj == "Browse" && isBrowseOff) return;
    if (obj == "showNotes" && !isNotesOn) return;
    
    /*if (NS || !IE6_up)
        object.style.color = 'white';
    
    object.style.backgroundColor = 'darkblue';*/
    object.className = 'onn';
    object.style.display = 'block';
}

function setSelectionOff(obj)
{
//This procedure gets called when mouseout event is fired of any option in the context menu.
//and, this procedure changes the display style of that particular option.  Accepts the 
//Id as parameters of the selected menu option.
    var object = document.getElementById(obj);
    
    if (obj == "Download" && isDownloadOff) return;
    if (obj == "Browse" && isBrowseOff) return;
    if (obj == "showNotes" && !isNotesOn) return;
    //if (NS || !IE6_up )
    //  object.style.color = 'black';
        
    //object.style.backgroundColor = 'lightgrey';
    object.className = 'off';
}

function contextMenuClick(action, e)
{
    if(IE && e.srcElement.parentNode.className != "onn")
        return;
    else if (!IE && e.currentTarget.className != "onn")
        return;
        
    hideit();
    switch (action)
    {
        /*case "NOTES":
            manageNotes(document.all(ActiveTreeView).getTreeNode(treeNodeIndex).getAttribute("id"));
            break;*/
        
        default:
        {
		if ( (type.toUpperCase() == 'Z') && (action.toUpperCase() == 'DOWNLOAD') && (linkRelIdForDownload != null) )
		{
			var hiddenIFrameDPT = document.getElementById('IFrameDownloadPartsTable');
			var hiddenIFrameIMG = document.getElementById('IFrameDownloadImage');

			if (hiddenIFrameDPT == null)
			{
				hiddenIFrameDPT = getHiddenIFrame('IFrameDownloadPartsTable');
				document.body.appendChild(hiddenIFrameDPT);
			}

			if (hiddenIFrameIMG == null)
			{
				hiddenIFrameIMG = getHiddenIFrame('IFrameDownloadImage');
				document.body.appendChild(hiddenIFrameIMG);
			}

			hiddenIFrameIMG.src = treeNodeHref+"&action=" + action;
			hiddenIFrameDPT.src = "wfrmItemGrid.aspx?linkRelId=" + linkRelIdForDownload  + "&action=DOWNLOAD_PART_TABLE";
		}
		else
			window.open(treeNodeHref+"&action=" + action ,"fraimage");
        }
            break;
    }
}

function LogError(msg)
{   
    if(IE6_up)
        window.status = msg;
    else
        window.status = msg;
    return true;
}

//--[ Returns new IFrame with style like hidden ]--
function getHiddenIFrame(iframeName)
{
	var newIFrame = document.createElement('iframe');
	newIFrame.setAttribute('id', iframeName);
	newIFrame.style.border = '0px';
	newIFrame.style.width = '0px';
	newIFrame.style.height = '0px';
            
	return newIFrame;
}
