function highlight_subnav() {
	// Highlight the right subnav item by comparing the URL with
	// the href of each <a> elt in the <div id="subnav">, or by
	// using the hint if supplied as arguments[0]. The hint 
	// (which is case sensitive) specifies a part of the URL, 
	// useful for actions with lots of parameters. 
	
	var this_page = document.location.href;
	
	// Remove anchor if there is one -- anything following #, including #
	this_page = this_page.replace( /\#.*/, '' );
	
	var hint = "";
	if (arguments[0]) {
		hint = arguments[0];
	}

	var subnav_elts = get_child_links(document.getElementById("subnav"));
	var i = 0;
	for (i = 0; i < subnav_elts.length; i++) {
		var elt = subnav_elts[i];
		if (elt.href == this_page || (hint && elt.href.indexOf(hint) != -1) ) {
			elt.className = elt.className + " current";
		}
	}
	

}


function get_child_links(elt) {
	// Recursively find all <A> elements below this element with id=id
	var all_children = elt.childNodes;
	var link_children = new Array();
	var i = 0;
	for (i = 0; i < all_children.length; i++) {
		var elt = all_children[i];
		// Is it a link?
		if (elt.nodeName == "A") {
			link_children = link_children.concat(elt);
		}
		// Any children?
		if (elt.childNodes) {
			link_children = link_children.concat( get_child_links(elt) );
		}
	}
	
	return link_children;
}


function show_subnav(id) {
	ul = document.getElementById('subnav_' + id);
	if (ul) {
		ul.style.display = 'block';
	}
}