/* This function can be run at any point after the top nav is dropped into the page.
   It will compare the top nav HREFs to the page URL and assign a class to the appropriate, 
   selected top nav list item. To force a top nav item to be selected,
   first give it a unique id and then pass that ID into the function.
*/
function topNavSelector(optionalID) {
// page URL after '.com' directory (for URL matching purposes)
var pageSubURL = decodeURI(document.location.pathname);

//strip 'index' file reference from URL (for comparison purposes)
if(pageSubURL.indexOf("/index.") >= 0) { pageSubURL = pageSubURL.substring( 0,pageSubURL.indexOf("/index.")+1 ); }


try {
	if(!optionalID) {
		topNavDiv = document.getElementById("topNav");
		aArray = topNavDiv.getElementsByTagName("a");
		for(var i = 0; i < aArray.length; ++i) {
			
			var testHref = aArray[i].pathname;
			if(testHref.indexOf("/") != 0) { testHref = "/" + testHref; } // IE doesn't include beginning slash
			
			//strip 'index' file reference from link URLs (for comparison purposes)
			if(testHref.indexOf("/index.") >= 0) { testHref = testHref.substring( 0,testHref.indexOf("/index.")+1 ); }

			if(pageSubURL == testHref) {
				// set as selected
				aArray[i].className += " bold";
				break;
			} // if(pageSubURL ==...
		}// for i
	} else {
		document.getElementById(optionalID).className += " bold";
	}// else
} catch(err) {}
}

// enable image rotation
$(document).ready(function () {
	$("#rotation_images").cycle({
		fx: "fade",
		speed: 1000,
		timeout: 4000
	});
});