jQuery(function () {
	jQuery('#menu-principal ul li').each(function () {
		var timer = null;
		var temp = false;
		var shown = false;
		var popup = jQuery('div', this).css('opacity', 0);
		jQuery(this).mouseover(function () {
			if (timer) clearTimeout(timer);
			if (temp || shown) { return; } else {
				temp = true;
				popup.css('margin','-120px 0 0 0').animate({
					margin: '-110px 0 0 0',
					opacity: 1
				}, 250, 'swing', function() {temp = false; shown = true; });
			}
			return false;
		}).mouseout(function () {
			if (timer) clearTimeout(timer);
			timer = setTimeout(function () {
				timer = null;
				popup.animate({
					margin: '-130px 0 0 0',
					opacity: 0
				}, 250, 'swing', function () { shown = false; });
			}, 500);
			return false;
		});
	});
});
