var Bryantpark = {}
Bryantpark.menu = new (function()
{
	var sections = ['plan_your_visit','things_to_do','about_us','hold_an_event'];
	var dropdownItems = ['dropdown_1', 'dropdown_2', 'dropdown_3', 'dropdown_4'];
	var dropdown = 'dropdown'
	var self = this;
	
	var equalizeHeights = function()
	{
		var highest = 0;
		for(var i = 0; i < sections.length; i++)
		{
			var currentSectionHeight = $('.'+sections[i]+':last').height();
			highest = (currentSectionHeight > highest) ? currentSectionHeight : highest;
		}
		
		for(var i = 0; i < sections.length; i++)
		{
			$('.'+sections[i]+':last').height(highest);
		}
	}
	
	var setActive = function(who)
	{
		if(!who)
		{
			$('#'+dropdown).removeClass();
			$('#'+dropdown).addClass('hidden');
		}
		
		for(var i = 0; i < sections.length; i++)
		{
			if(sections[i] == who)
			{
				// section match
				$('.'+sections[i]).addClass('active')[0];
				$('#'+dropdown).addClass(dropdownItems[i]);
				$('#'+dropdown).removeClass('hidden');
			}
			else
			{
				// section does not match
				$('.'+sections[i]).removeClass('active');
			}
		}	
	}
	
	self.init = function()
	{
		equalizeHeights();
		for(var i = 0; i < sections.length; i++)
		{
			$('.' + sections[i]).mouseenter(
				function()
				{
					setActive($(this).attr('class'));
					
				});
				
			$('.' + sections[i]).mouseleave(
				function()
				{
					setActive(null);
				});
		}
	}
});

// Executes when DOM is ready to be manipulated.
$(document).ready(function(){ Bryantpark.menu.init(); });