/* New boolean var is added to work in some app pages*/

var check_for_load_complete;
check_for_load_complete = false;

function HighlightNavTab()
{
var BodyIDSplit=new Array();
var bodyTagList = document.getElementsByTagName('body');

for(var bodytag=0; bodytag<bodyTagList.length; bodytag++)
{
 BodyIDSplit=bodyTagList[bodytag].getAttribute('id').replace(/-$/g,'').split('-');
 EntireBodyID=bodyTagList[bodytag].getAttribute('id');
}

/* BodyIDSplit is array with each element of the body id */

// Stores segment ID and match with the body ID
var segment = document.getElementById("nav-segment");
if (!segment) return;
var segmentLiID = segment.getElementsByTagName('li');
for (var seg=0;seg<segmentLiID.length ;seg++ )
{
  for (var body=0;body<BodyIDSplit.length ;body++ )
   {
    if (segmentLiID[seg].getAttribute('id') == BodyIDSplit[body])				
     {
	segmentLiID[seg].className = "selected";
	//Below if condition is to remove the extra slash from the Segment nav
	if (seg<(segmentLiID.length-1))
	{
	segmentLiID[seg+1].className = "unselected";
	}
    }
  }
} // Ends segment process

//Stores section ID and match with the body ID
var section = document.getElementById("nav-section");
if (!section) return;
var sectionLiID = section.getElementsByTagName('li');
for (var sec=0;sec<sectionLiID.length ;sec++ )
{
  for (var body=0;body<BodyIDSplit.length ;body++ )
   {
    if (sectionLiID[sec].getAttribute('id') == BodyIDSplit[body])
     {
	sectionLiID[sec].className = "selected";
	//Below if condition is to remove the extra slash from the section nav
	if (sec<(sectionLiID.length-1))
	{
	sectionLiID[sec+1].className = "unselected";
	}
     }
   }
} // Ends Section Process

 // Start the left nav process

 // First see if we can find the id strightup
 var selectItem = document.getElementById("ln-"+EntireBodyID);
 if (selectItem != null) {
 // the body id found in entirety - highlight it, and expand any parents
	selectItem.className = "selected";
	var currentItems = BodyIDSplit[0];
        for (var body=1;body<BodyIDSplit.length ;body++ ) {
		currentItems = currentItems + "-" +BodyIDSplit[body];
		var expandItem = document.getElementById("ln-"+currentItems+"-index");
		// Modification to highlight categories
		if ((expandItem != null)&&(expandItem.className != null)) {
			  if (expandItem.className=="selected") {
				expandItem.className="selected expanded";
			  }
			  else {
				expandItem.className="expanded";
			  }
		}
		else if (expandItem != null) { 
		// End modifications
				expandItem.className="expanded";
		// closing ifs of modification
		} // end closing ifs
	}
	    
   }

// Do it the old way if the entire ln- id was not found
else {
//Stores Left Nav ID and match with the body ID
var navRoot = document.getElementById("nav-page");
if (!navRoot) return;
var navRootLiID = navRoot.getElementsByTagName('li');
for (var nav=0;nav<navRootLiID.length; nav++ )
{
   for (var body=0;body<BodyIDSplit.length ;body++)
    {
    /* replace method in the below if condition is to reomve _, mcafee and and string from the body ID*/
    if (navRootLiID[nav].getAttribute('id') == BodyIDSplit[body].replace(/^(m+c+a+f+ee)|(and)/g,''))
    {
     if(navRootLiID[nav].childNodes.length>2)
	navRootLiID[nav].className = "expanded";
     else navRootLiID[nav].className = "selected";
    }
  }
}
} // Ends Left Nav Process

//Decalre below boolean var as true as some app pages need it's value as true

check_for_load_complete = true;

} // Function HighlightNavTab ends 
window.onload=HighlightNavTab;

