/* 
 * currentPage()
 * Author: John Wright
 * Requires: Safe Window Onload Script: 
 *   http://javascript.miningco.com/library/scripts/blsafeonload.htm
 *   (Alternately, change the last line to:
 *     body.onload = currentPage;
 *   Be aware that you will not be able to use any other onload scripts
 *   if you don't SafeAddOnload().)
 * Purpose:
 *   Checks to see if any of the links on the page point to the
 *   current document.  If so, it sets the id of the parent element
 *   (which is, hopefully, an <li>) to "thispage", so the tab appears
 *   to be "open".  See http://audiointuition.com/style.css to see 
 *   how this works.
 *
 * You are free to do whatever you like with this code.  An attribution
 * (in the code itself--not on your site) would be nice.
 */

function currentPage() {
	if (!document.getElementsByTagName) return
	/* This way we can use uri.match */
	uri = new String(document.location);
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.parentNode.parentNode.id == "navlist") {
			if (anchor.href == uri) {
				anchor.parentNode.id = "thispage";
			} else if ( anchor.href.match("gallery") &&
			            uri.match("gallery") ) {
				anchor.parentNode.id = "thispage";
			}
		}
	}
}

SafeAddOnload(currentPage);
