
$(document).ready(function(){
	
	
//	$("#boxNav > li.notActive").remove();
	
	
	if (jQuery.browser.msie && jQuery.browser.version < 7) {
		
		$("#boxNav li").hover( 
			function() {
				$(this).addClass("sfhover");
			},
			function() {
				$(this).removeClass("sfhover");
		
		});
		
	}

	
	// handle synch between 1st lvl nav and 2nd lvl
	var count = 0;
	var menuNr;
	jQuery.each($("#menu").children(), function() {
		if ($(this).attr("id") == "menuActive") {
			menuNr = count;
		}
		count++;
	});
	

	if (menuNr > 0) {
		$("#boxNav").children().eq(menuNr).removeClass("notActive").addClass("active").css("display","block");
	}
	
	//end synch

	$("#boxNav ul:has(a.sel)").css({left:"auto"});
	
	$("#boxNav ul li:has(a.sel)").children("a").addClass("sel").removeClass("notSel");
	
	//var h = $("#boxNav .boxNav2").height()+5;
	
	
	$("#boxNav > li.active a.notSel.lvl2").mouseover( function() {
		$("#boxNav ul:has(a.sel)").css({left:"-999px"});
		$("#boxNav > li.active a.sel.lvl2").mouseover( function() {
			$("#boxNav ul:has(a.sel)").css({left:"auto"});
		});
	});
	
	$("#boxNav > li.active a.notSel.lvl3").mouseover( function() {
		$("#boxNav ul.boxNav4:has(a.sel)").css({left:"-999px"});
		$("#boxNav > li.active a.sel.lvl3").mouseover( function() {
			$("#boxNav ul.boxNav4:has(a.sel.lvl4)").css({left:"auto"});
		});
	});
	
	
	$("#subNavContainer").hover( 
		function() {return null;},
		function() {
			$("#boxNav ul:has(a.sel)").css({left:"auto"});
		}
	);



/*
	$("#hmaxLogo").click( function () {
		$("#subNavContainer").toggle("slow");
	})
*/	



	var maxHeight = 0;
	var containerHeight = 0;
	// handle Navigation Box height
	$("#boxNav li.active ul").each( function () {
		var h = $(this).height();
		//$("body").append($(this).parent().text() + h + "<br>");
		if (maxHeight < h && h < 200 ) {
			maxHeight = h;
		}
		if (maxHeight>20) containerHeight = maxHeight+20;
	
	});




	$("#boxNav ul").height(maxHeight);
	$("#subNavContainer").height(containerHeight);












});
