/*(function($) {
  $.fn.equalHeights = function(minHeight, maxHeight) {
    tallest = (minHeight) ? minHeight : 0;
    this.each(function() {
      if ($.browser.msie && $.browser.version < 7) { $(this).css("height", ""); }
      $(this).css("min-height", "");
    });
    this.each(function() {
      if ($(this).height() > tallest) {
        tallest = $(this).height();
      }
    });
    if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
    return this.each(function() {
      if ($.browser.msie && $.browser.version < 7) { $(this).css("height", tallest + "px"); }
      $(this).css("min-height", tallest + "px");
    });
  }
})(jQuery);*/


$(document).ready(function() 
{	
	function addMega()
	{
		$(this).addClass("hovering");
		$('.lvl2 a').next().css('left', ($(this).position().left+159)).css('top', $(this).position().top); // positions next sub-level (green)
		//$('li.hovering > div.megadrop_lvl2 > ul').equalHeights(); // brings all <ul> to the same height
		
		var mdd_lvl2 = $('li.hovering > div.megadrop_lvl2');
		if (mdd_lvl2.children().size() < 7) // if level2 megadropdown has only 1 child then get rid off border-right
		{
			mdd_lvl2.find(':last-child').css('border', 0);
		}
	}

	function removeMega()
	{
		$(this).removeClass("hovering");
	}

	var megaConfig = { 
		interval: 50,
		sensitivity: 15,
		over: addMega,
		timeout: 150,
		out: removeMega
	};
	$('li.box').hoverIntent(megaConfig);
	$('.lvl2').hoverIntent(megaConfig);
});
