$(document).ready(function() { 
	
	
	$("#side-nav .nav-button").hover(
	
		function() { 
			
			$(this).addClass('nav-button-over');
			
			$(".sub-nav").hide();
			
	
			
			$(this).find('.sub-nav').show();
			
			if($(this).index()>6) {
				
				$(this).find('.sub-nav').css({
					
					"bottom":"0px"
					
				});
				
			} else {
			
				$(this).find('.sub-nav').css({
					
					"top":"0px"
					
				});
				
				var myIndex = $(this).index();
				var subItems = $(this).find('.sub-nav li').length;
				if(subItems >=3 && myIndex>=1) {
					
					$(this).find('.sub-nav').css({
						
						"top":"-"+(myIndex*31)+"px"
						
					});
					
				}
				
			}
			
		},
		function() { 
			
			$(this).removeClass('nav-button-over');
			
			$(this).find('.sub-nav').hide();
			
		}
	
	);
	
	$(".sub-nav-button").hover(
	
		function() {
			
			$(this).addClass('sub-nav-over');
		
		},
		function() {
			
			$(this).removeClass('sub-nav-over');
			
		}
	
	);

	
});


/*
	$(document).ready(function(){
		
		/// SHOW AND HIDE SUB MENUS
		$(".dropdownheader").hover(
			
			function() {

				hideAllHoverLinks();
			
				$(this).addClass('hoverdiv');
			
				$("#dropdownlist"+$(this).attr('divid')).show();
			
			},
			function() {
				//$("#dropdownlist"+$(this).attr('divid')).hide();
			}
		);
		
		/// SHOW AND HIDE SUB MENUS
		$("#right_content").hover(

			function() {
			
				hideAllHoverLinks();
			
			},
			function() {
				
			}
			
		);

		/// SHOW AND HIDE SUB MENUS
		$("#hb_head_cell").hover(

			function() {
			
				hideAllHoverLinks();
			
			},
			function() {
				
			}
			
		);
		
		/// IND SUB LINK HOVER
		$(".indnavlink").hover(
			
			function() {
				$(this).addClass('indnavlink_over');
			},
			function() {
				$(this).removeClass('indnavlink_over');
			}
			
		);
		
		$(".indnavlink").click(function() { 
			
			var href= $(this).find("a").attr("href");
			document.location.href=href;
			
			
		})
		
	});
	
	function hideAllHoverLinks() {

		$(".dropdownheader").each(function(){
			$(this).removeClass('hoverdiv');
		});
			
		$(".dropdownlist").each(function(){
			$(this).hide();
		});
		
	}

*/
