/**
 * @author Christian Flanagan
 */
$(document).ready(
	function() {
		// On hover over menu
		$("ul.menu li:not(ul.submenu li)").hover( // Negate inclusion of submenu list items
			function() {
				// Get the class name for this object.
				var $className = $(this).attr("className");
				// If not the currently selecte page,
				if($className != "current") {
					// On hover over, add class hover.
					$(this).addClass("hover");
					// Show submenu (Replace fadeIn with show() or slideDown("fast").)
					// Replace 100 with "fast", "slow", "def" (default == 400) or 
					// another numeric value (1000 == 1 sec.).
					$(this).find("ul.submenu").fadeIn(100).show();
					if($className == "menuTitle") {
						$(this).css("cursor","default");
					}
				}
			},
			function(){
				// On hover out, remove class hover.
				$(this).removeClass("hover");
				// Hide submenu (Replace fadeOut with slideDown("fast"). Don't use hide().)
				$(this).find("ul.submenu").fadeOut(100);
			}
		);
		// On hover over submenu
		$("ul.submenu li").hover(
			function() {
				var $className = $(this).attr("className");
				if($className != "current") {
					// On hover over, add class subhover
					$(this).addClass("subhover");
				} else {
					$(this).css("cursor","default");
				}
			},
			function() {
				$(this).removeClass("subhover");
			}
		);
		// Make the list item clickable and disable 
		// the anchor link for top level menu items.
		$("ul.menu li").click(
			function() {
				var $className = $(this).attr("className");
				// For top level menus with submenus and list item for the current web page,
				// do nothing when clicked.
				if($className != "menuTitle hover" && $className != "current") {
					window.location = $(this).find("a").attr("href");
					return false;
				}
			}
		);
		// For the current page (if it doesn't have a submenu), disable its anchor link.
		$("ul.menu li.current a").click(
			function() {
				return false;
			}
		);
		// Make the list item clickable and disable
		// the anchor link for submenu items.
		$("ul.submenu li").click(
			function() {
				var $className = $(this).attr("className");
				// If submenu is the current web page,
				// do nothing when clicked.
				if ($className != "current") {
					window.location = $(this).find("a").attr("href");
					return false;
				}
			}
		);
	}
);
