var dropMenu=null;
var rightMenu=null;
var titleMenu=null;
var highlightedItem=null;

var titleColour='pink'
var menuColour='white'
var itemColour='pink'
document.onclick= new Function("showMenu(null,null)")

function getPos(el,sProp) {
var iPos = 0
while (el!=null) {
iPos+=el["offset" + sProp]
el = el.offsetParent
}

return iPos
}

function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}




function showMenu(topMenu,newMenu) {
if (newMenu) {
newMenu.style.display='';
/*newMenu.style.pixelLeft = getPos(topMenu,"Left")
newMenu.style.pixelTop = getPos(topMenu,"Top") + topMenu.offsetHeight
*/
newMenu.style.left = getRealLeft(topMenu) 
newMenu.style.top = getRealTop(topMenu) + topMenu.offsetHeight

}
if ((newMenu!=dropMenu) && (dropMenu)){
dropMenu.style.display='none'
if (rightMenu){
 rightMenu.style.display='none'
 }
} /*Save the current drop menu to a variable*/

if (topMenu) {
topMenu.style.background = titleColour;
}
if ((topMenu!=titleMenu) && (titleMenu)){
titleMenu.style.background = menuColour;
}

if (highlightedItem){
highlightedItem.style.background=menuColour;
}
titleMenu = topMenu;
dropMenu=newMenu;
}
 
function showSubMenu(currentMenu,newRightMenu, menuWidth, subMenuWidth) {
if (currentMenu){
if (newRightMenu) {
newRightMenu.style.display='';
newRightMenu.style.left = getRealLeft(currentMenu) + menuWidth/*width of menu new*/
newRightMenu.style.top = getRealTop(currentMenu)
newRightMenu.style.width = subMenuWidth;
}
}
if ((newRightMenu!=rightMenu) && (rightMenu)){
 rightMenu.style.display='none'
 }
/*Save the current right menu to a variable*/
 rightMenu=newRightMenu
 } 

function highlightItem(currentItem) {
if (currentItem) {
currentItem.style.background=itemColour;
}
if ((currentItem!=highlightedItem) && (highlightedItem)){
highlightedItem.style.background=menuColour
}
highlightedItem = currentItem
}
