var subNavCollection = new Array();
var navCount = 0;
var selectedClassName = "currentSection";
var mainNavListName = "PrimaryNav";

function sfHover() {
	if (document.all&&document.getElementById) {
	
	// Start with the primary nav 
	navRoot = document.getElementById(mainNavListName);
		for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
			
	// find the li's		
			if (node.nodeName=="LI") {
			subNavCollection[navCount] = new Array();
			
	// Store the active class state
	
				if (node.className.indexOf(selectedClassName) != -1) {
				activeState = true;
				} else {
				activeState = false;
				}
			subNavCollection[navCount]["className"] = activeState;	
				
				for (j=0; j<node.childNodes.length; j++) {
				subNavNode = node.childNodes[j];
					
		// Grab the first links Id, then the id of the secondary nav
		
					if (subNavNode.nodeName=="A") {
					subNavCollection[navCount]["mainNav"] = subNavNode.id;
					}
					if (subNavNode.nodeName=="OL") {
					subNavCollection[navCount]["subNav"] = subNavNode.id;
					}
				}
		
		// Set mouseover events on the li's, attaching a call to activate functions and IE over styles
		
				if (node.hasChildNodes()) {	
					node.onmouseover=function() {
						if (this.firstChild.id) {
						anchorLinkId = this.firstChild.id;
						activateSubNav(anchorLinkId);
						}
					this.className+=" over";
					}
					node.onmouseout=function() {
						if (this.firstChild.id) {
							var mainId = deactivateSubNav();	

                        	activateSubNav(mainId); /* BH - turn support back on */
						}
					this.className=this.className.replace(" over", "");
					}
				}
			
			// increase the number of items in our stored array
			navCount++;	
			}
		}
	}
}

function activateSubNav(mainNav) {
var numOfNavItems = subNavCollection.length;

	for (a=0; a<numOfNavItems; a++) {
	var subNavId = subNavCollection[a]["subNav"];
	var mainNavId = subNavCollection[a]["mainNav"];
	var navClass = subNavCollection[a]["className"];
	
	// Turn everything off, then turn on whats highlighted
	
			if (document.getElementById(subNavId)) {
			document.getElementById(subNavId).style.display = "none";
			}
			if (mainNavId == mainNav) {
			document.getElementById(subNavId).style.display = "block";	
			}
	
	}
}

function deactivateSubNav () {
	var numOfNavItems = subNavCollection.length;
	var id = "PN-Support"
	for (a=0; a<numOfNavItems; a++) {
		var subNavId = subNavCollection[a]["subNav"];
		var mainNavId = subNavCollection[a]["mainNav"];
		var navClass = subNavCollection[a]["className"];
	
		// Turm all the nav item off, then turn on what was active
		if(subNavId) {
			if (document.getElementById(subNavId) && navClass) {
				document.getElementById(subNavId).style.display = "block";
			} else if (document.getElementById(subNavId)) {
				document.getElementById(subNavId).style.display = "none";	
			} else {
			}
		}
		if (mainNavId == "PN-Ayuda") {
			id = "PN-Ayuda";
		}
		if(mainNavId == "PN-BusinessSupport"){
 			id = "PN-BusinessSupport";
		}
	}
	return id;
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

