

var eBanShow = null;
var eMenuShow = null;


function document_click()
{
if ("clsBanShow" != window.event.srcElement.className && null != eMenuShow) HideMenu();
}

function document_keypress()
{
if ("27" == window.event.keyCode && null != eMenuShow) HideMenu();
}

function window_blur()
{
if (null != eMenuShow) HideMenu();
}

// -----------------------------------------------------------------------
// Cache/Uncache functions to store and bind if menu shown
// -----------------------------------------------------------------------

function CacheAndBind()
{
window.CachedClick = document.onclick;
window.CachedKeypress = document.onkeypress;
window.CachedBlur = window.onblur;
document.onclick = document_click;
document.onkeypress = document_keypress;
window.onblur = window_blur;
}

function UncacheAndRebind()
{
document.onclick = window.CachedClick;
document.onkeypress = window.CachedKeypress;
window.onblur = window.CachedBlur;
}

// -----------------------------------------------------------------------
// HideMenu and ShowMenu functions
// -----------------------------------------------------------------------

function HideMenu()
{
eMenuShow.style.visibility = "hidden";
eMenuShow = null;
eBanShow.className = "clsBan";
eBanShow = null;
UncacheAndRebind();
}

function ShowMenu(eSrc)
{
eMenuShow = document.all["divMenu" + eSrc.expItemNum];
eBanShow = eSrc;
eBanShow.className = "clsBanShow";
if (null != eMenuShow) eMenuShow.style.visibility = "visible";
CacheAndBind();
}

// -----------------------------------------------------------------------
// FindTD function used in NavBar event-handlers to determine TD ancestor
// -----------------------------------------------------------------------

function FindTD(eSrc,eContainer)
{
while (eContainer.contains(eSrc))
{
if ("TD" == eSrc.tagName) return eSrc;
eSrc = eSrc.parentElement;
}
return false;
}

// -----------------------------------------------------------------------
// NavBar event-handlers (bound below)
// -----------------------------------------------------------------------

function Ban_mouseover(eContainer)
{
var eSrc = FindTD(window.event.srcElement,eContainer);
if (FindTD(window.event.fromElement,eContainer) != eSrc)
{
if ("clsBan" == eSrc.className)
{
eSrc.className = "clsBanOver";
if (null != eMenuShow)
{
HideMenu();
ShowMenu(eSrc);
}
}
}
}

function Ban_mouseout(eContainer)
{
var eSrc = FindTD(window.event.srcElement,eContainer);
if (FindTD(window.event.toElement,eContainer) != eSrc)
{
if ("clsBanOver" == eSrc.className) eSrc.className = "clsBan";
}
}

function Ban_click(eContainer)
{
window.event.cancelBubble = true;
var eSrc = FindTD(window.event.srcElement,eContainer);
if ("clsBanOver" == eSrc.className)
{
if (null != eMenuShow) HideMenu();
ShowMenu(eSrc);
}
else if ("clsBanShow" == eSrc.className)
{
if (null != eMenuShow) HideMenu();
eSrc.className = "clsBanOver";
}
}

// -----------------------------------------------------------------------
// HackURL function used in Menu_click to create unique c-frame frameset in Menu_click
// -----------------------------------------------------------------------

function HackURL(sURL)
{
var dDate = new Date().getTime();
var sFrameURL = sURL.substring(0,sURL.indexOf("#"));
var sHash = sURL.substring(sURL.indexOf("#"));
if ("" != sFrameURL)
{
if (-1 < location.protocol.indexOf("file:")) return sHash.substring(1);
else return sFrameURL + "?" + dDate + sHash;
}
else return sURL;
}

// -----------------------------------------------------------------------
// Menu event-handlers (bound inline at time of menu creation)
// -----------------------------------------------------------------------

function Menu_hover()
{
var eSrc = window.event.srcElement;
if ("clsMenu" != eSrc.className) eSrc.className = ("" == eSrc.className ? "clsBanOver" : "");
}

function Menu_click()
{
HideMenu();
top.location.href = HackURL(window.event.srcElement.expURL);
}

// -----------------------------------------------------------------------
// NavBar event binding
// -----------------------------------------------------------------------

if ("object" == typeof(tblBanner))
{
tblBanner.onmouseover = new Function("Ban_mouseover(this);");
tblBanner.onmouseout = new Function("Ban_mouseout(this);");
tblBanner.onselectstart = new Function("return false;");
tblBanner.onclick = new Function("Ban_click(this);");
}
