jQuery(document).ready(function() {
	var winHeight = jQuery(window).height();
//	alert(winHeight);
/*	 jQuery("ul#nav li").each(function (i) {
		
      });
*/	jQuery("ul#nav li").hover(
		  function () {
			jQuery(this).find('ul').show();
			var ulHeight = jQuery(this).find('ul').height();
			var newHeight = ulHeight * 2/3;
			if(ulHeight>200){
				jQuery(this).find('ul').css("top",- newHeight);
				}
		  }, 
		  function () {
			 jQuery(this).find('ul').hide();
		  }
    );
	jQuery("ul#nav li ul").hover(
      function () {
        jQuery(this).parent().find('a:first').addClass('active');
		jQuery(this).css("display","block");
      }, 
      function () {
        jQuery(this).parent().find('a:first').removeClass('active');
		jQuery(this).css("display","none");
      }
    );
});
