//
// menu.js 
//
var inmenu   = false;
var lastmenu = 0;
var mainmenudflt = "#f1f3f7";
var mainmenuroll = "#031851";
var submenudflt   =  "#f1f3f7";
var submenuroll   = "#031851";

//
// to highlight main menu item with NO drop down menu
//
function PointTo(id,descr,hcolor) {
   atagid = "a-" + id;
   a            = GetStyleObject(atagid);
   if (hcolor==null) a.color = mainmenuroll; 
   else a.color = hcolor;
   a.fontWeight = "bold";
   window.status = descr;
}

//
// to unhighlight main menu item with NO drop down menu
//
function UnPointTo(id) {
   atagid = "a-" + id;
   a            = GetStyleObject(atagid);
   a.color      = mainmenudflt;
   a.fontWeight = "bold";
   window.status = "";
}

//
// to highlight bannerdrop menu item 
//
function PointToDrop(id,descr) {
   dtagid = "d-" + id;
   d            = GetStyleObject(dtagid);
   d.fontWeight = "bold";
   window.status = descr;
}

//
// to unhighlight bannerdrop menu item 
//
function UnPointToDrop(id) {
   dtagid = "d-" + id;
   d            = GetStyleObject(dtagid);
   d.fontWeight = "normal";
   window.status = "";
}

//
// to display drop down menu on rollover
//
function Menu(current,width,descr) {
 inmenu   = true;
 oldmenu  = lastmenu;
 lastmenu = current;
 if (oldmenu) Erase(oldmenu);
 l                   = GetStyleObject("l-"  + current);
 l.backgroundImage = "url(graphics/buttonh1.jpg)";
 r                   = GetStyleObject("r-"  + current);
 r.backgroundImage = "url(graphics/buttonh1.jpg)";
 a                   = GetStyleObject("a-" + current);
 a.color             = mainmenuroll;
 a.fontWeight        = "bold";
 m                  = GetObject("m-"  + current);
 trueX = GetRealLeft(m);
 trueY = GetRealTop(m);
 box                 = GetStyleObject(current);
 box.left            = trueX - 1;
 box.top             = trueY + 18;
 box.visibility      = "visible";
 box.width           = width + "px";
 window.status = descr;
}

//
// to remove drop down menu on mouseout
//
function Erase(current) {
   if (inmenu && lastmenu == current) return;
   l                   = GetStyleObject("l-"  + current);
   l.backgroundImage = "url(graphics/button.jpg)";
   r                   = GetStyleObject("r-"  + current);
   r.backgroundImage = "url(graphics/button.jpg)";
   a                   = GetStyleObject("a-" + current);
   a.color             = mainmenudflt;
   a.fontWeight        = "bold";
   a.textDecoration   = "none";
   box                 = GetStyleObject(current);
   box.visibility      = "hidden";
}                 

//
// to delay calling Erase function to determine
// to mouse is moved down into submenu area
//
function Timeout(current) {
   inmenu = false;
   window.setTimeout("Erase('" + current + "');",2000);
   window.status = "";
}

//
// to highlight a submenu item on rollover
//
function MHighlight(menu, item,descr) {
   inmenu              = true;
   lastmenu            = menu;
   a                   = GetStyleObject("a-" + menu);
   a.color             = mainmenudflt;
   obj                 = GetStyleObject(item);
   obj.color           = submenuroll; 
   obj.fontWeight      = "bold";
   window.status = descr;
}

//
// to unhighlight a submenu item on mouseout
//
function MUnhighlight(menu, item) {
   Timeout(menu);
   obj = GetStyleObject(item);
   obj.color           = submenudflt;
   obj.fontWeight      = "bold";
   window.status = "";
}

//
// to obtain the desired object in different browser models
//
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;}
}

//
// to obtain the desired syle element in different browser models
//
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;}
}

//
// to obtain the left offset of an element
//
function GetRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

//
// to obtain the top offset of an element
//
function GetRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}
   