var scrWin = parent, page = new Object(), isNS4 = scrWin.isNS4,
 nsWinW = window.innerWidth, nsWinH = window.innerHeight,
 nsPX = window.pageXOffset, nsPY = window.pageYOffset;
for (var f in scrWin.page) page[f] = scrWin.page[f];
page.win = window;



function isPar(mObj, mN)
{
 var par = mObj.menu[mN][0].par;
 return (par.substring(par.lastIndexOf('.')+1) == window.name);
}




var pMenu = scrWin.pMenu;
var vMenu = scrWin.vMenu;
if (pMenu || vMenu) 
{ // pMenu

function createMenus(mode)
{

 if (pMenu) for (var mN in pMenu.menu) if (isPar(pMenu, mN)) pMenu.update(mode, mN);
 if (vMenu) for (var mN in vMenu.menu) if (isPar(vMenu, mN)) vMenu.update(mode, mN);
 
 if (!scrWin.isIE || window.opera)
  setInterval('if (nsPX!=pageXOffset || nsPY!=pageYOffset) ' +
   '{ nsPX=pageXOffset; nsPY=pageYOffset; window.onscroll() }', 50);
}

function deleteMenus()
{
  if (pMenu) for (var mN in pMenu.menu) if (isPar(pMenu, mN)) pMenu.menu[mN][0].lyr = null;
  if (vMenu) for (var mN in vMenu.menu) if (isPar(vMenu, mN)) vMenu.menu[mN][0].lyr = null;
}


function HighLowLightDo(menu_num) {
  // This relies on keeping the last highlight in the pMenu
  if (!pMenu) {
    return;
  }

  if (pMenu.last_high != -1) {
    pMenu.menu['root'][pMenu.last_high].outCol = "#000099";
    if (vMenu) vMenu.menu['root'][pMenu.last_high].outCol = "#000099";
  }
  pMenu.menu['root'][menu_num].outCol = "#006600";
  if (vMenu) vMenu.menu['root'][menu_num].outCol = "#006600";
  pMenu.update();
  if (vMenu) vMenu.update();
  pMenu.last_high = menu_num;
}

function HighLowLight(menu_num) {
  var timeout = 100;  // Default
  if ((pMenu) && (pMenu.last_high == -1)) {
       timeout = 800; // Give the menu some time to comeup
  }
  setTimeout('HighLowLightDo('+menu_num+')',timeout);
}


window.onload = function()
{
 if (isNS4) createMenus(false);
 window.onunload = deleteMenus;
}
if (!isNS4) createMenus(true);


window.onresize = function()
{
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) history.go(0);
 if (pMenu) pMenu.position();
 if (vMenu) vMenu.position();
}

window.onscroll = function()
{
  if (pMenu) pMenu.position();
  if (vMenu) vMenu.position();
}

if (isNS4)
{
 document.captureEvents(Event.CLICK);
 document.onclick = function(evt)
 {
   if (pMenu) with (pMenu) if (overI) click(overM, overI);
   if (vMenu) with (vMenu) if (overI) click(overM, overI);

  return document.routeEvent(evt);
 }
}


}


// Other functions, not related to the menus
function EnforceFrames()
{
  // If this file is loaded on its own then reload it by setting
  // the address to index.html? plus the file name
  if (self.location == top.location)
    {
      top.location.href = 'index.php?dest=' + 
	self.location.href.substring(1+self.location.href.lastIndexOf('/'),self.location.href.length);
    }
}
