var displayed = false;
var ready = true;
var product_height = $("#product_link").height();

function readyMenu()
{
	ready = true;
}

$(function() {
	$("#product_link").mouseenter(function() {
		if(ready == true && displayed == false)
		{
			$("#sub").slideDown(200, function() {
											  
				// Calculate bottom of expanded menu
				var position = $(this).position();
				var left = position.left;
				
				var menu_height = $(this).height();
				
				
				// Increase height of #product_link div to cover menu
				var height = $("#product_link").height();
				var new_height = height + menu_height;
				$("#product_link").css("height", new_height);
				
				displayed = true;
			});
		}
	});
	
	$("#product_link").mouseleave(function() {
		if(displayed == true)
		{
			$("#sub").slideUp(200, function() {
				// Return #product_link div to normal height
				$("#product_link").css("height", product_height);
				
				displayed = false;
				ready = false;
				setTimeout("readyMenu()", 100);
			});
		}
	});
	
});