// $Log: mainMenu.js,v $
// Revision 1.2  2002/07/22 02:42:25  Administrator
// Changed the menu for the ceritification template.
//
var ns6=document.getElementById&&!document.all?1:0
var head="display:''"
var folder=''

var display_url=0 
var indent=0

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
if (ie5||ns6)
var menuobj=document.getElementById("ie5menu")
var contexts = new Array("bmc86362/","~bmc88/","~andre.and.kim/","www/");
var debug = 0;



function findVirtualPath(loc, rootEndStr)
{
    if(loc.indexOf(rootEndStr) <0)
    {
        return null;
    }
    virtualPath = loc.substring(loc.indexOf(rootEndStr)+rootEndStr.length);
    if (virtualPath.lastIndexOf(".htm") >= 0)
    {
        //virtualPath = virtualPath.substring(0,virtualPath.lastIndexOf(".htm"));
        if (virtualPath.lastIndexOf("/") >= 0)
            virtualPath = virtualPath.substring(0,virtualPath.lastIndexOf("/"));
        else
            virtualPath = "";
    }
    return virtualPath;
}

function findVirtualPaths(reff)
{
    urlstr = null;

    for (loop=0; loop < contexts.length; loop++) 
    {
        urlstr = findVirtualPath(reff, contexts[loop]);
        if (debug > 0)
            document.writeln("<BR>" + reff+",url#" + loop + ":" + urlstr);        
        if (urlstr || urlstr == "")
            break;
    }; 
    
    return urlstr;
}


function expandit(curobj)
{
    folder= (ns6 ?  curobj.nextSibling.nextSibling:
                    document.all[curobj.sourceIndex+1])
    //alert(folder.className)
    if (folder.className == "andre")
    {
        //alert(folder.src)
        str = folder.src.substring(0, folder.src.lastIndexOf("/"))
        //alert(folder.src + "--" + str)
        folder.src = (folder.src.indexOf("minus.gif") > -1 ? str + "/plus.gif" :
                     ( folder.src.indexOf("plus.gif") > -1 ? str + "/minus.gif" : str + "/shim.gif"))
        folder= (ns6 ?  curobj.nextSibling.nextSibling.nextSibling:
                        document.all[curobj.sourceIndex+2])
    }

    // 
    folder.style.marginLeft = (folder.style.display=="none" ? "1em" : "5em")
    folder.style.display = (folder.style.display=="none" ? "" : "none")
}


function findFolderToOpen(name, root,sourceIndex,endIndex){
    var url 
    var beginIndex = sourceIndex
    
    while (sourceIndex <= endIndex)
    {
        folder = (ns6 ? root.nextSibling : document.all[sourceIndex])
        if (folder && folder.className == 'menuitems')
        {
            url = folder.getAttribute("url")
            if (url)
            {
                if (url.indexOf(name) >= 0)
                {
                    //document.write('-found' + url + ":<br>" + folder.parentNode.sourceIndex)
                    first = true
                    while (document.all[folder.parentNode.sourceIndex-1].getAttribute("url"))
                    {
                        //document.write('<br>' + beginIndex + '[' + sourceIndex)
                        //document.write('<br>' + document.all[folder.parentNode.sourceIndex-1].getAttribute("url"))
                        expandit(document.all[folder.parentNode.sourceIndex-1])
                        if (first)
                        {
                            document.all[folder.sourceIndex-1].style.backgroundColor="orange"
                            first = false
                        }
                    }
                    
                }
            }
        }
        sourceIndex++
    }
}



function addLeaf(url, name, nodes, node)
{
   // var expandit = 'onClick="expandit(this)"'
   // var expandnode = 'class="andre"'
    var bgcolor = new Array();
    bgcolor[0] = 'background-color:blue;color:white;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'
    bgcolor[1] = 'background-color:7777ff;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;'
    bgcolor[2] = 'background-color:ccccff;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;'
    
    
    if (!name) {
        name = 'empty'
    }
//    if (node) {
//        expandit = ''
//        expandnode = ''
//    }
    
	// url is empty or is link to same page
	if (url && url.indexOf('#') != 0)
	{
    		document.writeln('  <div width=65  style="'+bgcolor[indent]+'"><a href="'+url+'" url="'+url+'" style="'+bgcolor[indent]+'margin-left:'+indent+'em;">'+name+'</a></div>')
    		//nodes[nodes.length] = '  <div width=65  style="'+bgcolor[indent]+'"><a href="'+url+'" url="'+url+'" style="'+bgcolor[indent]+'margin-left:'+indent+'em;">'+name+'</a></div>'
    	}
    	else
    	{
    		document.writeln('  <div width=65  style="'+bgcolor[indent]+'"><div style="'+bgcolor[indent]+'cursor:hand;margin-left:'+indent+'em;">'+name+'</div></div>')
    		//nodes[nodes.length] = '  <div width=65  style="'+bgcolor[indent]+'"><div style="'+bgcolor[indent]+'cursor:hand;margin-left:'+indent+'em;">'+name+'</div></div>'
    	}
    	
    nodes[nodes.length] = new Array()
    
    return nodes[nodes.length-1]
}       


function printNode(root)
{
    for (var i=0; i < root.length; i++) {
        if (!(root[i] instanceof Array))
        {
            document.writeln( root[i] )
        }
        else
        {
           //document.writeln('array' + root[i] )
           // document.writeln('      <div class="menuitems" style="display:"> ')
            printNode(root[i])
           // document.writeln('</div>')
        }
    }
}


/*

// Creating the menu layer 
document.writeln('<div id="ie5menu" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none style="left: 10px; top: 149px; width: 138px; height: 443px; visibility: visible; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000">')

//createNode('index.html', 'NODE 1'

var root = new Array()
addLeaf('#','GE DNS Home',root)
var leaf = addLeaf('#','About GE DNS',root)
addLeaf('#','Org Charts',leaf)
addLeaf('#','Mission',leaf)
addLeaf('#','Vision',leaf)
addLeaf('#','Charter',leaf)
leaf = addLeaf("#",'Departements',root)
var leaf2 = addLeaf('#','Transportation',leaf)
addLeaf('#','About Transp.',leaf2)
addLeaf('#','Indicators',leaf2)
leaf2 = addLeaf('#','Operations',leaf)
addLeaf('#','About Ops.',leaf2)
addLeaf('#','Indicators',leaf2)
leaf2 = addLeaf('#','Biz Support',leaf)
addLeaf('#','About Biz Support.',leaf2)
addLeaf('#','Indicators',leaf2)
leaf2 = addLeaf('#','BPSM',leaf)
addLeaf('#','About BPSM',leaf2)
addLeaf('#','Indicators',leaf2)
leaf2 = addLeaf('#','Support Svc',leaf)
addLeaf('#','About Support Svc',leaf2)
addLeaf('#','Indicators',leaf2)
leaf2 = addLeaf('#','Security',leaf)
addLeaf('#','About Security',leaf2)
addLeaf('#','Indicators',leaf2)

addLeaf('#','Indicators',root)
leaf = addLeaf("#",'Facilities',root)
addLeaf('#','About Facilities',leaf)
addLeaf('#','Log a Request',leaf)
addLeaf('#','Status Check',leaf)

leaf = addLeaf("#",'Administration',root)
addLeaf('#','AMS Admin',leaf)
addLeaf('#','SWI Admin',leaf)




printNode(root)


// END OF LAYER 
document.writeln('</div>')
*/
