$(document).ready(function() {
	
	//determine page URL
	pageURL = document.location.pathname;
	
	$("#topNav a").each(function() {
		linkURL = $(this).attr("href");
		/* strip 'index.php' from path checking */
		pageURL = pageURL.split("index.")[0];
		linkURL = linkURL.split("index.")[0];

		//compare page URL to top nav URLs (bolding current page)
		if(linkURL == pageURL) {
			$(this).addClass("selected");
			$(this).parentsUntil("#topNav").last().find("a:first").addClass("selected");
			//end iteration
			return false;
		}
		
	});
	
	
	// the following block of code hooks up the top nav flyouts
	var flyoutIsOut = false;
	
	$("#topNav > div > div").prev("a").mouseover(function(){
		$("#topNav > div > div").css("display","none");
		$(this).next("div").css("display","block");
	});
	
	$("#topNav > div > div").mouseover(function(){
		$(this).stop().css("display","block");
		flyoutIsOut = true;
	});
	
	$("#topNav > div > div").mouseout(function(){
		$(this).css("display","none");
	});
	
	$("#topNav > div > div").prev("a").mouseout(function(){
		$(this).next("div").css("display","none");
	});
	
});
