﻿// JScript File

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
				obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
				obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function hideMenuLayers() {
	for (i=0; i<mLayers.length; i++) {
		l = document.getElementById(mLayers[i]);
		if (l) l.style.visibility='hidden'
	}
}

function showMenuLayer(divId, adjustToId, adjustSide) {
    
	theLayer = document.getElementById(divId)
	adjustImg = document.getElementById(adjustToId)
	if (!theLayer || !adjustImg) return

	//if (theLayer.style.display!='block') hideMenuLayers()
	leftPos = findPosX(adjustImg)
	topPos = findPosY(adjustImg)
	topPos = topPos
	if (adjustSide == 'right') {
		leftPos = leftPos - parseInt(theLayer.style.width) + parseInt(adjustImg.width) - 40
	}
	else {
	}
	
	theLayer.style.left = leftPos + 'px'
	theLayer.style.top = topPos + 'px'
	theLayer.style.visibility='visible';
}


function doMenuLayer(divId, adjustToId, adjustSide) {
    
    theLayer = document.getElementById(divId);
    if (theLayer.style.visibility=='hidden')
         showMenuLayer(divId, adjustToId, adjustSide);
    else
         theLayer.style.visibility='hidden'
}
