
var subNavItems = null;
var selectedSubNavItem = null;
var selectedSubSubNavItem = null;
var selectedSubSubSubNavItem = null;

function doLoad() {
	setLocation();

	var section = parent.whatSection();
	subNavItems = getElement(section + "SubNav");
	if (subNavItems) {
		subNavItems.style.display = 'block';
	}
	
	var subSection = parent.whatSubSection();
	selectedSubNavItem = getElement(section + subSection);

	if (selectedSubNavItem) {
		selectedSubNavItem.className += " snLevel1Selected";
		
		var ns = getNextElement(selectedSubNavItem);	// show the children, if any
		if (ns.className == 'snLevel1Items') {
			ns.style.display = 'block';
			
			var subSubSection = parent.whatSubSubSection();
			selectedSubSubNavItem = getElement(section + subSection + subSubSection);
			
			if (selectedSubSubNavItem) {
				selectedSubSubNavItem.className += " snLevel2Selected";
				var nss = getNextElement(selectedSubSubNavItem);	// show the children, if any
				if (nss.className == 'snLevel2Items') {
					nss.style.display = 'block';
					var subSubSubSection =  parent.whatSubSubSubSection();
					selectedSubSubSubNavItem = getElement(section + subSection + subSubSection + subSubSubSection);
					
					if (selectedSubSubSubNavItem) {
						selectedSubSubSubNavItem.className += " snLevel3Selected";	// highlight this item
					//	selectedSubSubNavItem.className = "snLevel2";	// unhighlight the parent
					}
				}	
			}
		}
	}
}


function doResize() {

}

// navigate to a new site section

function navToPage(t) {
	var newLocation = pathPrefix + t.getAttribute('target');
	
	if (newLocation.charAt(newLocation.length - 1) == '/') {
		newLocation += pathSuffix;
	}

	parent.window.location = newLocation;
}

function subNavOver(t) {
	if (t == selectedSubNavItem) return;
	standardOver(t);
}

function subNavOut(t) {
	if (t == selectedSubNavItem) return;
	standardOut(t);
}

function subSubNavOver(t) {
	if (t == selectedSubSubNavItem) return;
	standardOver(t);
}

function subSubNavOut(t) {
	if (t == selectedSubSubNavItem) return;
	standardOut(t);
}

function subSubSubNavOver(t) {
	if (t == selectedSubSubSubNavItem) return;
	standardOver(t);
}

function subSubSubNavOut(t) {
	if (t == selectedSubSubSubNavItem) return;
	standardOut(t);
}

function standardOver(t) {
	t.className += " " + t.className + "Over";
}

function standardOut(t) {
	var classNames = t.className.split(" ");
	t.className = classNames[0];
}

function getElement(id) {
	var e = document.getElementById(id);
	
	return e;
}

function getNextElement(t) {
	// return the next element node
	var nr = t.nextSibling;
	if (nr.nodeType == 1) return nr;
	
	return t.nextSibling.nextSibling;  // skip over the text node
}
