//
// menu.js 
//
var inmenu   = false;
var lastmenu = 0;

function PointTo(id,c,descr) {
   i            = GetStyleObject(id);
   i.color      = c;
   i.fontWeight = "bold";
   window.status = descr;
}
function UnPointTo(id,c) {
   i            = GetStyleObject(id);
   i.color      = c;
   i.fontWeight = "normal";
   window.status = "";
}

function Menu(current,width,descr) {
 inmenu   = true;
 oldmenu  = lastmenu;
 lastmenu = current;
 if (oldmenu) Erase(oldmenu);
 m                   = GetObject("menu-"  + current);
 c                   = GetStyleObject("color-" + current);
 c.color             = "#F7BA47";
 c.fontWeight        = "bold";
 box                 = GetStyleObject(current);
 trueX = GetRealLeft(m);
 trueY = GetRealTop(m);
 box.left            = trueX + 137;
 box.top             = trueY - 16;
 box.visibility      = "visible";
 box.backgroundColor = "#e7e7f3";
 box.width           = width + "px";
 window.status       = descr;
}

function Erase(current) {
   if (inmenu && lastmenu == current) return;
   c                   = GetStyleObject("color-" + current);
   box                 = GetStyleObject(current);
   box.visibility      = "hidden";
   c.color             = "#ffffff";
   c.fontWeight        = "bold";
}                 

function Timeout(current) {
   inmenu = false;
   window.setTimeout("Erase('" + current + "');",500);
   window.status = "";
}

function MHighlight(menu, item,descr) {
   inmenu              = true;
   lastmenu            = menu;
   obj                 = GetStyleObject(item);
   obj.color           = "#990033";
   obj.fontWeight      = "bold";
   window.status       = descr;
}

function MUnhighlight(menu, item) {
   Timeout(menu);
   obj = GetStyleObject(item);
   obj.color           = "#003366";
   obj.fontWeight      = "normal";
   window.status = "";
}

function MHighlightH(menu, item,descr) {
   inmenu              = true;
   lastmenu            = menu;
   obj                 = GetStyleObject(item);
   obj.color           = "#ffffff";
   obj.fontWeight      = "bold";
   window.status       = descr;
}

function MUnhighlightH(menu, item) {
   Timeout(menu);
   obj = GetStyleObject(item);
   obj.color           = "#ffffff";
   obj.fontWeight      = "normal";
   window.status = "";
}

function GetObject(id) {
   if (document.getElementById) return document.getElementById(id);
   else if (document.layers)    return document.layers[id];
   else if (document.all)       return document.all[id];
   else { alert("DHTML support not found.");
          return false;}
}

function GetStyleObject(id) {
   if (document.getElementById) return document.getElementById(id).style;
   else if (document.layers)    return document.layers[id];
   else if (document.all)       return document.all[id].style;
   else { alert("DHTML support not found.");
          return false;}
}

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;
}
   