/* DYNAMIC STATIC NAV */
var navTx;
function wnNavReset(){
	clearTimeout(navTx);
	$wn(".wnLevel2:visible").hide();
	$wn(".cur").show();
}

function launchDynamicNav(){
	var h = 24;
	var t = 38;
	$wn(".wnMainMenu .wnHorizontal .wnStatic .wnSublevel").css({"z-index": "1000"});

	$wn(".wnStatic .wnLevel1 li:first").attr("rel", "1");
	$wn(".wnStatic .wnLevel1 li:first").siblings("li").each(function(){
		$wn(this).attr("rel", "1");
		if(!$wn(this).find("ul").length){
			$wn(this).append("<ul class='wnLevel2 wnSublevel' style='height: "+ h +"px; top: "+ t +"px; display: none;'><li class='wnFirstNode wnOn'><span><a href=''>&nbsp;</a></span></li></ul>");
		}
	});
	$wn(".wnStatic .wnLevel2 li:first").attr("rel", "2");
	$wn(".wnStatic .wnLevel2 li:first").siblings("li").each(function(){
		$wn(this).attr("rel", "2");
	});
	
	var subnavPos = $(".wnMenuSpacer").offset();
	if($wn(".wnLevel2:visible").attr("class") != null){
		//IF A SUB NAV IS PRESENT FOR THE CURRENT CATEGORY
		$wn(".wnLevel2:visible").addClass("cur");
		$wn(".wnLevel2").css({"height": h + "px", "top": t +"px"});
	}else{
		//IF A SUB NAV IS NOT PRESENT FOR THE CURRENT CATEGORY
		$wn("#WNMenuCol1 .wnMenuSpacer").height(h);
		$wn(".wnLevel2").css({"height": h +"px", "top": subnavPos.top +"px", "left": subnavPos.left +"px", "width": ($wn(".wnMenuSpacer").width()-2) +"px", "overflow": "hidden"});
	}
	//$wn("ul.wnLevel1 li.wnFirstNode .wnLeft").css("padding-left","3px");
	$wn("ul.wnLevel1 li[rel='1']").bind("mouseenter", function(){
		clearTimeout(navTx);
		$wn(".wnLevel2:visible").hide();
		$wn(this).find(".wnLevel2").addClass("wnOn").css({"display": "block"});
	});
	$wn("ul.wnLevel1 li[rel='2']").bind("mouseenter", function(){
		clearTimeout(navTx);
	});
	
	$wn("#WNMenuCol1").bind("mouseleave", function(){
		clearTimeout(navTx);
		navTx = setTimeout(function(){
			wnNavReset();
		}, 500);
	});	
}

$wn(document).ready(function(){
	launchDynamicNav();
});

/*
var navTx;
function wnNavReset(){
	$(".wnLevel2:visible").hide();
	$(".wnLevel2[rel='cur']").show();
}$(document).ready(function(){
	$(".wnMenuSpacer").css({"display": "block", "height": "30px", "top": "38px", "background": "#ffffff"});
	var subnavPos = $(".wnMenuSpacer").offset();
	if($(".wnLevel2:visible").attr("class") != null){
		//IF A SUB NAV IS PRESENT FOR THE CURRENT CATEGORY
		$(".wnLevel2:visible").attr("rel", "cur");
		$(".wnLevel2").css({"height": "30px", "top": "38px"});
	}else{
		//IF A SUB NAV IS NOT PRESENT FOR THE CURRENT CATEGORY
		$(".wnLevel1 .wnFirstNode").append("<ul class='wnLevel2 wnSublevel' rel='cur'><li class='wnFirstNode'><span><a href=''>&nbsp;</a></span></li></ul>");
		$(".wnLevel2").css({"height": "24px", "top": subnavPos.top+"px", "left": (subnavPos.left+2) +"px", "width": ($(".wnMenuSpacer").width()-2) +"px", "overflow": "hidden"});
	}	$("ul.wnLevel1 li[depth='1']").bind("mouseenter", function(){
		clearTimeout(navTx);
		$(".wnLevel2:visible").hide();
		$(this).children($(".wnLevel2")).addClass("wnOn").css({"display": "block"});
	});
	
	$("ul.wnLevel1 li[depth='2']").bind("mouseenter", function(){
		clearTimeout(navTx);
	});
	
	$("ul.wnLevel1 li").bind("mouseleave", function(){
		$("ul.wnLevel2 li").addClass("wnOn");
		$("ul.wnLevel2 li a").css({
			"font-size":"11px",
			"font-weight":"700",
			"color":"#BC1A1B"
		});
		clearTimeout(navTx);
		navTx = setTimeout("wnNavReset()", 250);
	});
	
});
*/

