var timer = 0;
var shown = false;

function hideProductsMenu() {
	document.getElementById('productsMenuWrapper').className = 'showDropdown';
	setProductMenuBoxHeight();
}

function setProductMenuBoxHeight() {
	document.getElementById('productsMenuBox').style.height = document.getElementById('productsMenuFirstItem').offsetHeight+'px';
}

function showDropdown() {
	clearTimeout(timer);
	if (!shown) {
		setProductMenuBoxHeight();
		document.getElementById('productsMenu').className = 'shown';
		shown = true;
	}
}

function triggerTimer() {
	timer = setTimeout('hideDropdown()', 150);
}

function hideDropdown() {
	document.getElementById('productsMenu').className = '';
	shown = false;
}