$(document).ready(
   function() {
      $('.mainnav li').hover(
         function() {
            $(this).find('ul:first').css({visibility: 'visible', display: 'none'}).slideDown(200);
         },
         function() {
            $(this).find('ul:first').css({visibility: 'hidden'});
         }
      );
   }
);

/**
 * Sets active menu item
**/
$(document).ready(function() {
   $('.' + activeMenuID).children("a").addClass("active");
   
   //hide all of the child navigation
   $(".sidenav").children("li").children("ul").hide();
   
   //if we're on the main nav item then show its children
   $(".sidenav").children('.' + activeMenuID).children("ul").show();   
   
   //if we're on a child nav item then show the parent
   //there are two different levels so we're hardcoding in the functionality
   $('.' + activeMenuID).parent("ul").parent("li").children("ul").show();
   $('.' + activeMenuID).parent("ul").parent("li").parent("ul").parent("li").children("ul").show();
});