
var G_ON;
var G_PANELTIMER;

var g_sPanelId = null;

function drawPanel()
{
	//jQuery("#"+g_sPanelId).fadeIn("fast");
	jQuery("#"+g_sPanelId).show();
}

function erasePanel()
{
	if (g_sPanelId != null)
	{
		window.clearInterval(G_PANELTIMER);

		jQuery("#"+g_sPanelId).hide();

		g_sPanelId = null;
	}
}

function checkFlag()
{
	//alert(G_ON);
	
	switch (G_ON)
	{
		case 0:
			erasePanel();
			break;
		case 1:
			keepPanel();
			break;
	}
}

function showPanel(sPanelId, sBtnId)
{
	//alert(sPanelId+" , "+sBtnId);

	if (g_sPanelId != null && g_sPanelId != sPanelId)
	{
		hidePanel();
		erasePanel();
	}

	G_ON = 1;
	
	g_sPanelId = sPanelId;

	o = jQuery("#"+sBtnId).position();
	
	jQuery("#"+g_sPanelId).css("left", o.left);
	jQuery("#"+g_sPanelId).css("top", o.top+jQuery("#"+sBtnId).height());
	
	drawPanel();
	
	G_PANELTIMER = window.setInterval(checkFlag, 100);
}

function hidePanel()
{
	G_ON = 0;
}

function keepPanel()
{
	G_ON = 1;
}