// *** (3) EVENTS ***


if (!isNS4)
{
 pMenu.update(true);
 pMenu2.update(true);
}
else
{
 var popOldOL = window.onload;
 window.onload = function()
 {
  if (popOldOL) popOldOL();
  pMenu.update();
  pMenu2.update();
 }
}


window.onresize = function()
{
 ns4BugCheck();
 pMenu.position();
 pMenu2.position();
}

window.onscroll = function()
{
 pMenu.position();
 pMenu2.position();
}

if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = function(evt)
{
 pMenu.click();
 pMenu2.click();
 if (isNS4) return document.routeEvent(evt);
}


var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
function ns4BugCheck()
{
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload()
}

if (!isIE || window.opera)
{
 var nsPX=pageXOffset, nsPY=pageYOffset;
 setInterval('if (nsPX!=pageXOffset || nsPY!=pageYOffset) ' +
 '{ nsPX=pageXOffset; nsPY=pageYOffset; window.onscroll() }', 50);
}





// *** (4) ANIMATION ***

function menuClip(menuObj, menuName, dir)
{
 var mD = menuObj.menu[menuName][0];
 if (!mD.timer) mD.timer = 0;
 if (!mD.counter) mD.counter = 0;
 with (mD)
 {
  clearTimeout(timer);
  if (!lyr || !lyr.ref) return;
  if (dir==1) lyr.vis('visible');
  lyr.sty.zIndex = 1001 + dir;
  lyr.clip(0, 0, menuW+2, (menuH+2)*Math.pow(Math.sin(Math.PI*counter/20),0.75) );
  counter += dir;
  if (counter==11) { counter = 10; if (isDOM&&!isIE) lyr.sty.clip='' }
  else if (counter<0) { counter = 0; lyr.vis('hidden') }
  else timer = setTimeout(menuObj.myName+'.'+(dir==1?'show':'hide')+'Menu("'+menuName+'")', 40);
 }
}


if (!window.opera)
{
 pMenu.showMenu = new Function('mN','menuClip(pMenu, mN, 1)');
 pMenu.hideMenu = new Function('mN','menuClip(pMenu, mN, -1)');
 pMenu2.showMenu = new Function('mN','menuClip(pMenu2, mN, 1)');
 pMenu2.hideMenu = new Function('mN','menuClip(pMenu2, mN, -1)');
}



// *** (6) OPTIONAL CODE ***   DELETE IF YOU'RE NOT USING THESE!

/*
pMenu.onclick = function() { with (this)
{
 if (overM == 'root' && overI == 1) status = 'Congratulations, you\'ve mastered clicking!';
 if (overM == 'root' && overI == 2) location.href = 'edit.html';
}}

pMenu.onmouseover = function() { with (this)
{
 with (menu[overM][overI]) if (!type) status = href;
}}
pMenu.onmouseout = function() { status = '' }
*/

function changeMenu() { with (pMenu)
{
 startMenu('mNewMenu', true, 0, 22, 130, subM);
 addItem('<b>TwinHelix Designs:</b><br>Extreme DHTML.<br>Small Code.<br>Click to Visit...',
  'window.open("http://www.twinhelix.com")', 'js:', subM, 70);

 actMenu = 'root';
 nextItem = 4;
 addItem('&nbsp; Dynamism...', 'mNewMenu', 'sm:', hBar, 80);

 update();
}}


function moveRoot()
{
 with (pMenu.menu.root[0].lyr) x( (x()<100) ? 100 : 10);
}

// End Hide -->