jQuery(function( $ ){
	
	// alert($("#sidebar_nav").height());
	
	//$("#sidebar_background").css("height", $("#sidebar_nav").height()-3);
	//$("#sidebar_background_top").css("top", -5);
	//$("#sidebar_background_bottom").css("top", $("#sidebar_nav").height()-3);
	//$("#factoria_description").css("top", $("#sidebar_nav").height()+5);
	
	$("#top_nav li ul.subnav" ).each(function(i){
		// $(this).height();
		$(this).prev().find(".middle").css("height", $(this).height()-36);
	});
	
	$("#top_nav li").mouseenter(function(){
		$(this).find("ul").css("display", "block");
		$(this).find(".subnav_background").css("top", 276);
		$(this).find("a").addClass("hovered");
	});

	$("#top_nav li").mouseleave(function(){
		$(this).find("ul").css("display", "none");
		$(this).find(".subnav_background").css("top", -2000);
		$(this).find("a").removeClass("hovered");
	});

	$("#left_nav li ul.subnav" ).each(function(i){
		// $(this).height();
		$(this).prev().find(".middle").css("height", $(this).height()-30);
	});
	
	$("#left_nav li ul.subnav li ul.subnav" ).each(function(i){
		// $(this).height();
		$(this).prev().find(".middle").css("height", $(this).height()-30);
	});
	
	$("#left_nav li").mouseenter(function(){
		$(this).find("ul").css("top", $(this).position().top-2);
		$(this).find(".subnav_background").css("top", $(this).position().top-6);
		$(this).find("a").addClass("hovered");
	});

	$("#left_nav li").mouseleave(function(){
		$(this).find("ul").css("top", -2000);
		$(this).find(".subnav_background").css("top", -2000);
		$(this).find("a").removeClass("hovered");
	});
	
	// $("#left_nav li:has(ul)").attr("href", "#");

	$("#left_nav li:has(ul)").each(function(i){
		$(this).children().attr("href", "#");
	});

	$("#right_nav li:has(ul)").each(function(i){
		$(this).children().attr("href", "#");
	});
	
});
