function getPos(el)
{
	if (!el || !el.offsetParent)return false;
	var res=Array()
	res["left"] = el.offsetLeft;
	res["top"] = el.offsetTop;
	var objParent = el.offsetParent;
	while (objParent.tagName.toUpperCase()!="BODY")
	{
		res["left"] += objParent.offsetLeft;
		res["top"] += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	res["right"]=res["left"]+el.offsetWidth;
	res["bottom"]=res["top"]+el.offsetHeight;
	return res;
}

function mPopup(id, obj)
{
   posArr = getPos(obj);
   menuEl = document.getElementById(id);
   menuEl.style.left = (posArr['left'] + posArr['right'] - menuEl.width)/2 + 'px';
   menuEl.style.top = posArr['bottom'];
   menuEl.style.display = 'block';
}

function menuPopup(id, x, y)
{
   menuEl = document.getElementById(id);
   var bodyWidth = Number(document.body.clientWidth);
   if (bodyWidth > 870) 
      menuEl.style.left = ((bodyWidth-870)/2 + x) + 'px';
   else
      menuEl.style.left = x+'px';
   menuEl.style.top = y+'px';
   menuEl.style.display = 'block';
}

function openDialog(href, width, height, resizable,wnd_name)
{
   if (!width)
      width = 300;
   if (!height)
      height = 300;
   if (!resizable)
      resizable = 'yes';
   w=window.open(href, wnd_name, "height="+height+",width="+width+",resizable="+resizable+",directories=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
   w.focus();
}

