var flavorOn = false;
function showTab(tab) {
	flavorOn = true;
	var menuItem = document.getElementById("menbar");
	menuItem.style.left = (findPosX(document.getElementById(tab)) - 10) + "px";
	menuItem.style.top = (findPosY(document.getElementById(tab)) + document.getElementById(tab).offsetHeight - 8) + "px";
	menuItem.style.display="block";
}
function hideTab(tab){
	menuItem = document.getElementById(tab);
	setTimeout('delayHideMenus(menuItem)', 200);
}

function delayHideMenus(){
	if (document.getElementById("menbar").style.display == "block"){
	
		if(!flavorOn){

			document.getElementById("menbar").style.display="none";
			//document.getElementById("image1").src = "images/flavor.gif";
		}
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function openPopup( a, width, height, scroll ) {

	//var left = (screen.width) ? ( screen.width - width ) / 2 : 0;
	//var top = (screen.height) ? ( screen.height - height ) / 2 : 0;
	winProperties = "height=" + height + ",width=" + width + (scroll ? ",scrollbars" : "" );
  var popup = window.open( a,"popup", winProperties);
  popup.focus();
  return ( popup == null );
}
