/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
$(document).ready(function(){

closetimer = 0;
	if($("#nav")) {
		$("#nav b").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$("#nav i").removeClass("hover");
				$(this).parent().next().fadeOut("slow");
				$(this).removeClass("hover");
			}
			else {
				$("#nav b").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$("#nav i").removeClass("hover");
				$("#nav ul:visible").fadeOut("slow");
				$(this).parent().next().fadeIn("slow");
			}
			return false;
		});

		$("#nav i").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$(this).parent().next().slideUp(500);
				$(this).removeClass("hover");
			}
			else {
				$("#nav i").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").slideUp(500);
				$("#nav em").removeClass("hover");
				$("#nav ul ul:visible").slideUp(500);
				$(this).parent().next().slideDown(500);
			}
			return false;
		});

		$("#nav em").mouseover(function() {
		clearTimeout(closetimer);
			if(this.className.indexOf("hover") != -1) {
				$(this).parent().next().fadeOut("slow");
				$(this).removeClass("hover");
			}
			else {
				$("#nav em").removeClass();
				$(this).addClass("hover");
				$("#nav ul ul ul:visible").fadeOut("slow");
				$(this).parent().next().fadeIn("slow");
			}
			return false;
		});

		$("#nav").mouseover(function() {
		clearTimeout(closetimer);
		});

		$("#nav").mouseout(function() {
			closetimer = window.setTimeout(function(){
			$("#nav ul ul ul:visible").fadeOut("slow");
			$("#nav em").removeClass("hover");
			$("#nav ul ul:visible").slideUp(500);
			$("#nav i").removeClass("hover");
			}, 2000);
		}); 
	}
});
