$(function(){	
	$(".subNavLevel1").click(function(){
		if ($(this).children("ul").css("display") != "block"){
			$(".subNavLevel1").children("ul").hide();
			$(".subNavLevel2").children("ul").hide();
			$(".subNavLevel1").children("a").css("color","#000000");
			$(".subNavLevel1").css("background","url(images/sub/arrow-left-small.gif) 10px 5px no-repeat");
			$(this).children("ul").show();
			$(this).children("a").css("color","#000000");
			$(this).css("background","url(images/sub/arrow-down-small.gif) 7px 8px no-repeat");
		}
	});
	$(".subNavLevel2").click(function(){
		if ($(this).children("ul").css("display") != "block"){
			$(".subNavLevel2").children("ul").hide();
			$(".subNavLevel2").children("a").css("color","#000000");
			$(".subNavLevel2").children("a").css("background","url(images/sub/arrow-left-small.gif) 2px 1px no-repeat");
			$(this).children("ul").show();
			$(this).children("a").css("color","#000000");
			$(this).children("a").css("background","url(images/sub/arrow-down-small.gif) 0px 5px no-repeat");
		}
		if (!$(this).hasClass("subNavOnWhole")){
			$(".subNavLevel2").removeClass("subNavOnWhole");
			$(this).addClass("subNavOnWhole");
		}
	});
	
	$(".subNavLevel2").hover(
		function(){
			$(this).css({
				"background-image":"url(images/sub/overlay-yellow-whole-bkg.gif)",
				"background-position":"-3px -4px",
				"background-repeat":"no-repeat"
			});
		},
		function(){
			$(this).css({
				"background-image":""
			});
		}
	);
	
	$(".subNavLevel3").hover(
		function(){
			if ( !$(this).hasClass("eySubNavCurrent") ){
				$(this).css("background-color","#fde64b");
			}
		},
		function(){
			if ( !$(this).hasClass("eySubNavCurrent") ){
				$(this).css("background-color","#ffffff");
			}
		}
	);
	
	if ( $(".subNavLevel3").hasClass("eySubNavCurrent") ) {
		console.log("level3");
		$(".eySubNavCurrent").parent().css("display","block");
		$(".eySubNavCurrent").parent().parent().addClass("subNavOnWhole");
		$(".eySubNavCurrent").parent().parent().children("a").css("background","url(images/sub/arrow-down-small.gif) 0px 5px no-repeat");
		$(".eySubNavCurrent").parent().parent().parent().parent().css("background","url(images/sub/arrow-down-small.gif) 7px 8px no-repeat");
		$(".eySubNavCurrent").parent().parent().parent().css("display","block");
	} else if ( $(".subNavLevel2").hasClass("eySubNavCurrent") ) {
		console.log("level2");
		$(".eySubNavCurrent").addClass("subNavOnWhole");
		$(".eySubNavCurrent").children("ul").css("display","block");
		$(".eySubNavCurrent").children("a").css("background","url(images/sub/arrow-down-small.gif) 0px 5px no-repeat");
		$(".eySubNavCurrent").parent("ul").css("display","block");
		console.log("level2 end");
	} else if ( $(".subNavLevel1").hasClass("eySubNavCurrent") ) {
		console.log("level1");
		$(".eySubNavCurrent").css("background","url(images/sub/arrow-down-small.gif) 7px 8px no-repeat");
		$(".eySubNavCurrent").children("ul").css("display","block");
		console.log("level1 end");
	}
});
