var scFr=self.PopupMenu?self:(parent.PopupMenu?parent:top);function popEvt(str,each){var PML=scFr.PopupMenu.list,mN;for(var objName in PML)with(PML[objName]){if(each)for(mN in menu)with(menu[mN][0]){if((!par&&scFr==self)||(par&&par.substring(par.lastIndexOf('.')+1)==self.name))eval(str)}else eval(str)}};var scrFn,popOL=window.onload,popUL=window.onunload,popOR=window.onresize,popOS=window.onscroll,nsWinW=window.innerWidth,nsWinH=window.innerHeight,nsPX=window.pageXOffset,nsPY=window.pageYOffset;document.popOC=document.onclick;if(scFr.PopupMenu){if(!self.page)var isNS4=scFr.isNS4,page={};if(scFr!=self)for(var f in scFr.page)page[f]=scFr.page[f];page.win=self;popEvt('self[objName]=PML[objName]',0);if(!isNS4)popEvt('update(true,mN)',1);window.onload=function(){if(popOL)popOL();if(isNS4){popEvt('update(false,mN)',1);setInterval(scrFn,50)}if(!scFr.isOp)window.onunload=new Function('if(popUL)popUL();popEvt("for(var i=0;i<menu[mN].length;i++)menu[mN][i].lyr=null",1)')};if(popOS||(''+popOS!='undefined'))window.onscroll=function(){if(popOS)popOS();popEvt('position(mN)',1)};else{scrFn='if(nsPX!=pageXOffset||nsPY!=pageYOffset){nsPX=pageXOffset;nsPY=pageYOffset;popEvt("position(mN)",1)}';if(!isNS4)setInterval(scrFn,50)}function resizeBugCheck(){if(nsWinW!=innerWidth||nsWinH!=innerHeight)location.reload()};if(scFr.isOp&&!document.documentElement&&!self.opFix)self.opFix=setInterval('resizeBugCheck()',500);window.onresize=function(){if(popOR)popOR();if(isNS4)resizeBugCheck();popEvt('position(mN)',1)};if(isNS4)document.captureEvents(Event.CLICK);document.onclick=function(evt){popEvt('if(isNS4&&overI)click(overM,overI);if(!overI&&hideDocClick)over("root",0)',0);return document.popOC?document.popOC(evt):(isNS4?document.routeEvent(evt):self.uNdEfInEd)}}




// NAVIGATION BY KEYPRESSES
//
// This allows users to navigate menus by pressing keys.
// You can navigate by the arrow keys, press [Enter] to navigate, and [Esc] to quit.
// It's not NS4 compatible, as NS4 doesn't allow arrow key detection, and it works best if all
// your menus are positioned relatively (i.e. their offsets are numbers, not strings).
// Opera also refuses to not scroll with arrowpresses, so I've put in a nasty hack there :).
//
// To activate: Paste the script below at the end of the POP_EVENTS file.
// Then, in your menu data file (either POP_DATA or your frameset), you must give each of your
// menu objects a 'focusKey' property so they respond to keypresses, along with optional other
// properties to set which other keys must be pressed at the time. You must pick a key combination
// that is not already used as a shortcut by the browser itself. For example, insert these lines
// below the startMenu and addItem commands to set CTRL+ALT+M as the activation key for that menu:
//pMenu.focusKey = 'm';
//pMenu.focusCtrl = true;
//pMenu.focusAlt = true;
//pMenu.focusShift = false;


window.keyMenu = null;
document.popKD = document.onkeydown;
document.onkeydown = function(evt)
{
 evt = evt||window.event;
 var key = evt.charCode||evt.keyCode, ret = true;

 var PML = scFr.PopupMenu.list;
 for (var pm in PML)
 {
  var fK = (PML[pm].focusKey||'').charCodeAt(0);
  if (evt.ctrlKey==PML[pm].focusCtrl && evt.altKey==PML[pm].focusAlt &&
   evt.shiftKey==PML[pm].focusShift && (key==fK || key+32==fK))
  {
   if (keyMenu == PML[pm]) key = 27;
   else keyMenu = PML[pm];
  }
 }

 if (keyMenu) with (keyMenu)
 {
  if (typeof keyMenu.keyScrY != 'number') keyMenu.keyScrY = page.scrollY();
  ret = false;

  if (!overM || !overI) over('root', 1);
  var dir = 0, mD = menu[overM][0], iD = menu[overM][overI];
  // Now, why does Opera return values >50,000 for arrow keys? :P
  // Anyway, we set the 'direction' based on the key presses and menu orientation.
  if (key == 38 || key == 57373) dir = mD.isVert ? -1 : -2;
  if (key == 40 || key == 57374) dir = mD.isVert ? 1 : 2;
  if (key == 37 || key == 57375) dir = mD.isVert ? -2 : -1;
  if (key == 39 || key == 57376) dir = mD.isVert ? 2 : 1;
  // Escape and Enter, two special keys.
  if (key == 13) click(overM, overI);
  if (key == 27) { over('', 0); keyMenu = null; return 1 }

  if (dir == 1 || dir == -1)
  {
   // Move the highlighted item up and down the current menu.
   overI += dir;
   if (overI >= menu[overM].length) overI -= menu[overM].length - 1;
   if (overI < 1)
   {
    // If we move back past the first item, return to the parent of non-root menus.
    if (!mD.isRoot) { overM = mD.parentMenu; overI = mD.parentItem }
    else overI += menu[overM].length - 1;
   }
   over(overM, overI);
  }
  else if (dir)
  {
   // Either shift to a submenu or go back to the parent menu.
   // For menus in the same frame I attempt to do some position detecting.
   if (iD.type == 'sm:')
   {
    var tM = menu[iD.href][0];
    if ((tM.par != mD.par) || (dir*parseInt(tM['off'+(mD.isVert?'X':'Y')]) >= 0))
    {
     dir = 0;
     keyMenu.over(iD.href, 1);
    }
   }
   if (dir && !mD.isRoot)
   {
    var pM = menu[mD.parentMenu];
    var nextItem = mD.parentItem + (mD.isVert != pM[0].isVert ? dir/2 : 0);
    nextItem = Math.max(1, Math.min(nextItem, pM.length-1));
    keyMenu.over(mD.parentMenu, nextItem);
   }
  }
 }

 return this.popKD ? this.popKD(evt)&&ret : ret;
};

document.popKP = document.onkeypress;
document.onkeypress = function(evt)
{
 if (keyMenu && scFr.isOp) setTimeout('scrollTo(page.scrollX(), '+keyMenu.keyScrY+')', 10);
 return this.popKP ? this.popKP(evt)&&!keyMenu : !keyMenu;
};





