var aTags = new Array();
var childFound = false;

/* If current page LI has a child UL it displays it block */
function openChildren(node){
	for(var c=0;c<node.childNodes.length;c++){
		if(node.childNodes[c].nodeName=="UL")node.childNodes[c].style.display="block";		
	}
}

/* Runs through all the A tags to find the one matching the url and highlights it */
function highlightMenu(n) {

    // Now get all children of n
	var children = n.childNodes;
	                
    // Loop through the children
	for(var i=0; i < children.length; i++) {    
		
		// get all the 'A' tags
		if(children[i].nodeName == "A"){ 		
			
			// extract the link specified in the a tag
			var thisChannel = children[i].getAttribute("href");
			
			// remove the host address from the front
			var thisChannel = thisChannel.replace(siteHost, "");
			
			// if the current 'A' tag link to a page matches the current page number
			if(thisChannel == currentPage){						
				
				// tell it's immediate parent UL to display
				children[i].parentNode.parentNode.style.display = "block";      
				
				// Display parent A as bold and still #555
				if(children[i].parentNode.parentNode.parentNode.nodeName=="LI"){
					children[i].parentNode.parentNode.parentNode.style.fontWeight = "bold";
				}
				
				// Display all children as normal weight to overwrite previous line
				children[i].parentNode.parentNode.style.fontWeight = "normal";
				
				// add class of selected to current page link
				children[i].parentNode.className = "selected";
				
				// we need to check if our page has children as they should "open"
				openChildren(children[i].parentNode);							
				
				// we need to catch the fact we have the child otherwise it will highlight the rest of this UL block
				childFound = true;
			}			
		}
		// Recurse on each one
		childTag = highlightMenu(children[i]);      					
    }
}