function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nLeftPos += eParElement.offsetLeft;
        eParElement = eParElement.offsetParent;
    }
    return nLeftPos;
}

function DL_GetElementTop(eElement)
{
    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}

var listaRozwijalnychMenu;

function showmenu(el,elmnt,pos,offX,offY,shadow,width,brcolor,bgcolor)
{
	var menusToHide = elmnt.substr(0,elmnt.lastIndexOf('-'));
	var tmpTDs  =document.getElementsByTagName("TABLE");
	for (i=0;i<tmpTDs.length;i++) {
		if (tmpTDs[i].id.indexOf(menusToHide)>=0) {
			if (tmpTDs[i].id != elmnt) {
				allowclose(tmpTDs[i].id)
				hidemenu(tmpTDs[i].id);
				//alert (tmpTDs[i].id +" "+ elmnt);
				//document.getElementById(elmnt).container="0";
				//document.getElementById(elmnt).style.display="none";
			}
		}
	}
	var tmpPos=0;
	var l = DL_GetElementLeft(document.getElementById(elmnt+'_layer'));
	var t = parseInt(DL_GetElementTop(document.getElementById(elmnt+'_layer')))+parseInt(el.offsetHeight);
	var l2 = parseInt(DL_GetElementLeft(document.getElementById(elmnt+'_layer')))+parseInt(el.offsetWidth);
	var t2 = DL_GetElementTop(document.getElementById(elmnt+'_layer'));
	var w = parseInt(el.offsetWidth);
	if (pos==0) {
		document.getElementById(elmnt).style.left = l2+offX;
		document.getElementById(elmnt).style.top = t2+offY;
    }
	else {
		document.getElementById(elmnt).style.left = l+offX;
		document.getElementById(elmnt).style.top = t+offY;
	}
	if (shadow!="0") {
		document.getElementById(elmnt).style.filter = "progid:DXImageTransform.Microsoft.dropshadow(OffX=2,OffY=2,Color=#bbbbbb,Positive=true)  blendTrans(duration=0.4";
	}
	else {
		document.getElementById(elmnt).style.filter = "";
	}
	document.getElementById(elmnt).style.borderColor=brcolor;
	document.getElementById(elmnt).style.backgroundColor=bgcolor;
	if (document.all) {
		if (width>0) {
			document.getElementById(elmnt).style.width = width;
		}
		else {
			document.getElementById(elmnt).style.width = w;
		}
	}
	else {
			document.getElementById(elmnt).style.width = width;
			document.getElementById(elmnt).rows[0].cells[0].style.width = width;
	}
	document.getElementById(elmnt).style.display="inline"

	var positionX = parseInt(document.getElementById(elmnt).style.left)+parseInt(document.getElementById(elmnt).offsetWidth);
	var screenX = parseInt(document.body.clientWidth)
	positionX -= parseInt(document.body.scrollLeft);
	if (screenX<positionX) {
		document.getElementById(elmnt).style.left=parseInt(document.getElementById(elmnt).style.left)-(positionX-screenX)-5;
	}
	var positionY = parseInt(document.getElementById(elmnt).style.top)+parseInt(document.getElementById(elmnt).offsetHeight);
	var screenY = parseInt(document.body.clientHeight)
	positionY -= parseInt(document.body.scrollTop);
	if (screenY<positionY) {
		document.getElementById(elmnt).style.top=parseInt(document.getElementById(elmnt).style.top)-(positionY-screenY)-5;
	}

}

function hidemenu(elmnt)
{
	if (document.getElementById(elmnt).container=="0") {
		document.getElementById(elmnt).style.display="none";
	}
}

function keepopen(elmnt)
{
	document.getElementById(elmnt).container="1"
}

function allowclose(elmnt)
{
	document.getElementById(elmnt).container="0"
}
