$(document).ready(function() {
	$(".ms-navSubMenu2").wrap("<div class='subMenuWrapper'></div>");
		
	$("table.ms-navheader").each(function(){
		$(this).parent().parent().next().find(".subMenuWrapper").data("selected", "0");
		
		var section = $(this).find("a");
		
		if(section.attr("href") == window.location.pathname)
			$(this).parent().parent().next().find(".subMenuWrapper").data("selected", "1");		
		
		$(this).data("section", section.text());
		$(this).parent().parent().next().find(".subMenuWrapper").data("section", section.text());
	});
	
	$(".subMenuWrapper:not(:has(.ms-selectednav)):not(:data(selected=1))").hide(function(){
		$(this).parent().parent().hide();
	});
	
	$("table.ms-navheader").mouseenter(function(){
		var section = $(this).data("section");
		$(".subMenuWrapper:not(:has(.ms-selectednav)):not(:data(section=" + section + ")):not(:data(selected=1))").slideUp(800, function(){
			$(this).parent().parent().hide();
		});
		$(this).parent().parent().next().show().find(".subMenuWrapper").slideDown(800);
	});

	//$("#leftContent,#rightContent").addClass('contentWebPart');
	//$(".contentWebPart > table").addClass('innerContentWebPart');
	
	//$(".innerContentWebPart").wrap("<div class='gradient1'></div>");
	//$(".innerContentWebPart").wrap("<div class='gradient3'></div>");
	
	//$(".gradient1:first").addClass('leftWebPart');
	
	$(".ms-navheader td").hover(
		function() {
			$(this).addClass('ms-navheaderhover');
		},
		function() {
			$(this).removeClass('ms-navheaderhover');
		}
	)
	.click(function() {
		location = $(this).find("a")[0].href;
	});
	
	$(".ms-navitem td").hover(function(){
		$(this).find("a").addClass("subMenuHover");
	},	function(){
		$(this).find("a").removeClass("subMenuHover");
	});
	
	$(".ms-bottomNavContainer td").click(function() {
		location = $(this).find("a")[0].href;
	});
});