
function ShowRelDivBMenu(DivID, nearObjID, _divOffsetLeft, _divWidth)
{
	var oCurDiv = document.getElementById(DivID);
	if (!oCurDiv)	return;
	if (oCurDiv.style.display == "none")
	{
		var obj_a = document.getElementById(nearObjID);
		if(obj_a)
		{
			off = GetTotalOffset(obj_a);
			if(off.Left + _divOffsetLeft + _divWidth + 15>document.body.clientWidth)
				oCurDiv.style.left = document.body.clientWidth - _divWidth - 15;
			else
				oCurDiv.style.left = off.Left + _divOffsetLeft;
			oCurDiv.style.top = off.Top+18;
		}
		oCurDiv.style.display = "block";
	}
}

var iDivTimerBMID = -1;
var mcMenuDivId = "";
function PrepareClosing(_divId)
{
	mcMenuDivId = _divId;
	iDivTimerBMID = window.setInterval(_closeDiv, 300);
}

function CancelClosing()
{
	if(iDivTimerBMID>=0)
	{
		window.clearInterval(iDivTimerBMID);
		iDivTimerBMID = -1;
	}
}

function _closeDiv()
{
	if(iDivTimerBMID>=0)
	{
		window.clearInterval(iDivTimerBMID);	
		iDivTimerBMID = -1;
		var oCurDiv = document.getElementById(mcMenuDivId);
		mcMenuDivId = "";
		if (!oCurDiv)	return;
		oCurDiv.style.display = "none";
	}
}

function GetTotalOffset(eSrc)
{
	this.Top = 0;
	this.Left = 0;
	while (eSrc)
	{
		this.Top += eSrc.offsetTop;
		this.Left += eSrc.offsetLeft;
		eSrc = eSrc.offsetParent;
	}
	return this;
}