var navTimer = null;


function toggleNavBarMenu(parentId) {
	$(".navPanelBox").hide();
	if (parentId && parentId.length > 1) {$("#navPanel_" + parentId).show();}
	/*return;
	if ($("#navPanel_" + parentId).height() > 10) {
		$("#navPanel_" + parentId).css({height: "0px"});
	} else {
		$("#navPanel_" + parentId).css({height: "70px", width: "600px"}).show();
	}*/
}

$(document).ready(function(){

	/* Event handlers */
	$("div.TopNavBarList li.NavPanelLink").bind("mouseup", function(event) {
		loginButtonSticky = true;
		var myElement = $(this);
		// Hide all the panels
		$(".navPanelBox").hide();
		toggleNavBarMenu($(this).parent().attr("id"));
	});

	$("div.TopNavBarList li.NavPanelLink a").mouseover(function(event) {
		if (navTimer) {clearTimeout(navTimer);}
		// Hide all the panels
		$(".navPanelBox").hide();
		// Now show the desired navPanelBox (by ID)
		toggleNavBarMenu($(this).parent().attr("id"));
		//$("a", this).css({fontStyle: "none", textDecoration: "none", backgroundImage: "url(/AgentFiles/HomeCards/10001/WebImages/HC251/hover-btn.png)", backgroundRepeat: "no-repeat", backgroundPosition: "8px 0px"});
		$("div.TopNavBarList li.NavPanelLink a").removeClass("HoverTab");
		$(this).addClass("HoverTab");
	});
	$("div.TopNavBarList li.NavPanelLink").click(function(event) { 
		$("div.TopNavBarList li.NavPanelLink a")
			.removeClass("HoverTab")
			.removeData("sticky");
		$("a", this)
			.addClass("HoverTab")
			.data("sticky", true);
		//$("a", this).css({fontStyle: "none", textDecoration: "none", backgroundImage: "url(/AgentFiles/HomeCards/10001/WebImages/HC251/hover-btn.png)", backgroundRepeat: "no-repeat", backgroundPosition: "8px 0px"});
	});
	$("div.TopNavBarList").mouseout(function(event) {
		navTimer = setTimeout("toggleNavBarMenu()", 300);
	});
	$("div.TopNavBarList").mouseover(function(event) {
		clearTimeout(navTimer);
	});
	$("div.submenu").mouseover(function(event) {
		clearTimeout(navTimer);
	});
	$("div.submenu").mouseout(function(event) {
		navTimer = setTimeout("toggleNavBarMenu()", 300);
	});
});
