$(function() {
	// ready handler IE initializer
	// needs to: set initial state of tabs
	
	var currentPath = document.location.pathname;
	var pathArray = currentPath.split("/");
	pathArray.shift();
	pathArray.shift(); // get rid of fi
	pathArray.shift(); // get rid of fihome
	var toplevelSelected = pathArray[0];
	var secondlevelSelected = pathArray.length >= 2 ? pathArray[1] : null;
	
	$("ul")
		.css("list-style-image","none");

	$("#searchlink").click(function () {
		$("#searchform").submit();
	});
	//	setup event handlers
	$("li.toplevel")
		.find("ul.secondlevel").hide()
		.end()
		.hoverIntent ({
			timeout: 350,
			over: function() {
				$("li.toplevel img").css("background-color","#5a1534");
				$("li.toplevel ul.secondlevel").hide();
				$(this).find("img").css("background-color","#853358");
				var sl = $(this).find("ul.secondlevel");
				sl.show();
			},
			out: function() {
				if(this.id != toplevelSelected) {
					$(this).find("img").css("background-color","#5a1534");
					$(this).find("ul.secondlevel").hide();
				}
				if($("ul.secondlevel:not(:hidden)").size()==0) {
					$("li#"+toplevelSelected+".toplevel img")
						.css("background-color","#853358");
					$("li#"+toplevelSelected+".toplevel ul.secondlevel").show()
						.children("li#"+secondlevelSelected).children("a")
							.css("text-decoration","underline");
				}
			}
		});
			
	
	$("li#"+toplevelSelected)	
		.find("img")
			.css("background-color","#853358");
			
	$("li#"+toplevelSelected)
		.find("ul.secondlevel")
			.show()
			.children("li#"+secondlevelSelected)
			.children("a")
			.css("text-decoration","underline");

});