function getEvent (e)
{
    if (e==null)
        e = event ;
    return e.target || e.srcElement;
}

function showMenu (e, baseId, menuId)
{
        e = getEvent(e) ;
        var base = document.getElementById(baseId) ;
        var menu = document.getElementById(menuId) ;
	if (e!=menu)
	{
            var srcElement = base ;
            var x = 0 ;
            var y = 0 ;
            var h = srcElement.offsetHeight ;
            while (srcElement!=null)
            {
                x += srcElement.offsetLeft ;
                y += srcElement.offsetTop ;
                srcElement = srcElement.offsetParent ;
            }
            menu.style.left = x ;
            menu.style.top = y+h ;
            menu.style.visibility = "visible" ;
        }
}

function hideMenu (e, menuId)
{
        e = getEvent(e) ;
        var menu = document.getElementById(menuId) ;
	if (e!=menu)
	{
		menu.style.visibility = "hidden" ;
		menu.style.left = -1000 ;
		menu.style.top = -1000 ;
	}
}

function showElement (elementId)
{
    var e = document.getElementById(elementId) ;
    if (e!=null)
	    e.style.display = "inline" ;
}

function hideElement (elementId)
{
    var e = document.getElementById(elementId) ;
    if (e!=null)
	    e.style.display = "none" ;
}

function showElementTest (elementId)
{
	showElement(elementId) ;
	return true ;
}

function hideElementTest (elementId)
{
	hideElement(elementId) ;
	return true ;
}

function hideLayer (layerId)
{
	hideElement(layerId) ;
}

function showParentElement (elementId)
{
    var e = parent.document.getElementById(elementId) ;
    if (e!=null)
	    e.style.display = "inline" ;
}

function hideParentElement (elementId)
{
    var e = parent.document.getElementById(elementId) ;
    if (e!=null)
	    e.style.display = "none" ;
}

function showParentElementTest (elementId)
{
	showParentElement(elementId) ;
	return true ;
}

function hideParentElementTest (elementId)
{
	hideParentElement(elementId) ;
	return true ;
}

//deprecated
function showLayer (parentLayerId, showLayerId, hideLayerId)
{
	hideElement(hideLayerId) ;
	showElement(showLayerId) ;
}

//deprecated
function showLayerTest (parentLayerId, showLayerId, hideLayerId)
{
	showLayer(parentLayerId,showLayerId,hideLayerId) ;
	return true ;
}

//deprecated
function showWindowLayer (parentLayer, showLayer, hideLayer)
{
    showLayer.style.display = "inline" ;
    hideLayer.style.display = "none" ;
}

//deprecated
function showWindowLayerTest (parentLayer, showLayer, hideLayer)
{
	showWindowLayer(parentLayer,showLayer,hideLayer) ;
	return true ;
}
