// (1) ITEMSTYLES - These define the colour and size of menu items. Compulsory.
// (2) MENU DATA - These specify the text and links in the menu. Compulsory.
// (3) EVENTS - Activate the menu(s), and choose creation mode (Dynamic / Fast) etc. I recommend
//     you read it, but you only really need to change it if you want multiple menus on one page,
//     or are trying to combine this with other JavaScripts.
// (4) ANIMATION - Change or remove menu animation here. Multiple menu users need to edit this.
// (5) FRAMESETS - Read this if you're using the menu across frames. Otherwise delete it.
// (6) OPTIONAL CODE - Extra features like adding clicking to 'sm:' items or status messages etc.
//     on mouseover. You can skip or delete this section.



// *** (1) ITEMSTYLES ***


var mainBar = new ItemStyle(30, 10, '', 0, 7, '#AA0000', '#000000', 'itemText', 'itemHover', 'itemBorder', 'itemBorder',
 null, null);

var subM = new ItemStyle(24, 0, '&gt;', -15, 3, '#AA0000', '#000000', 'itemText', 'itemHover',
 'itemBorder2', 'itemBorder2', null, null);

var crazy = new ItemStyle(22, 1, '&gt;', -15, 2, '#666699', '#CC6600', 'crazyText', 'crazyHover',
 'crazyBorder', 'crazyBorderOver', 80, 90);


// *** (2) MENU DATA ***

var pMenu = new PopupMenu('pMenu');
with (pMenu)
{

startMenu('root', true, 10, 240, 125, mainBar)

addItem('<center>UC Martial Arts</center>', 'home', 'sm:');
addItem('<center>Taekwondo</center>', 'tkd', 'sm:');
addItem('<center>Instructors</center>', 'instructors.html', '');
addItem('<center>Contact Us</center>', 'contactus.html', '');
//addItem('<center>Officers</center>', 'officers.html', '')
addItem('<center>Events</center>', 'mEvents', 'sm:');
addItem('<center>Media</center>', 'mMedia', 'sm:');
addItem('<center>Links</center>', 'links.html', '');
//addItem('<center>Fees</center>', 'fees.html', '');
//addItem('<center>Members</center>', 'members_login.php', '');

startMenu('home', true, 120, 15, 130, subM);
addItem('About the Club', 'index.html', '');
addItem('Lesson Schedule', 'index.html#schedule', '');
addItem('Fees', 'index.html#fees', '');

startMenu('tkd', true, 120, 15, 100, subM);
addItem('History', 'taekwondo.html#history', '');
addItem('Philosophy', 'taekwondo.html#philosophy', '');
addItem('Benefits', 'taekwondo.html#benefits', '');
addItem('Belt System', 'taekwondo.html#rank', '');

startMenu('mEvents', true, 120, 15, 100, subM);
addItem('Calendar', 'events.html', '');
addItem('Belt Tests', 'events.html#belttests', '');
addItem('Events', 'events.html#events', '');

startMenu('mMedia', true, 120, 15, 100, subM);
//addItem('Pictures', '/php-cgi/gallery/', '');
addItem('Pictures','window.open("http://www.ucmartialarts.org/gallery")', 'js:', subM, 25);
addItem('Movies', 'movies.html', '');
addItem('Articles', 'articles.html', '');







// You can also assign hide or show delays (in milliseconds) to the menus. Defaults are:
//showDelay = 0;
//hideDelay = 500;
// Specify hideDelay as zero if you want to disable autohiding, and showDelay as a couple of
// hundred if you don't want the menus showing instantaneously when moused over.


}


// *** (3) EVENTS ***


if (!isNS4)
{
 // Write menus now in non-NS4 browsers, by calling the "Fast" mode .update(true) method.
 pMenu.update(true);
 //anotherMenu.update(true);
}
else
{
 // For Netscape 4, back up the old onload function and make a new one to update our menus.
 // This is the regular "Dynamic" mode menu update, it works in IE and NS6 too.
 var popOldOL = window.onload;
 window.onload = function()
 {
  if (popOldOL) popOldOL();
  pMenu.update();
  //anotherMenu.update();
 }
}


// Other events must be assigned, these are less complicated, just add or remove menu objects.

window.onresize = function()
{
 ns4BugCheck();
 pMenu.position();
 //anotherMenu.position();
}

window.onscroll = function()
{
 pMenu.position();
 //anotherMenu.position();
}

if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = function(evt)
{
 pMenu.click();
 //anotherMenu.click();
 if (isNS4) return document.routeEvent(evt);
}


// A small function that refreshes NS4 on window resize to avoid bugs, called above.
var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
function ns4BugCheck()
{
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload()
}

// Activate the useful 'onscroll' event for non-Microsoft browsers.
if (!isIE || window.opera)
{
 var nsPX=pageXOffset, nsPY=pageYOffset;
 setInterval('if (nsPX!=pageXOffset || nsPY!=pageYOffset) ' +
 '{ nsPX=pageXOffset; nsPY=pageYOffset; window.onscroll() }', 50);
}





// *** (4) ANIMATION ***
//
// Each menu object you create by default shows and hides its menus instantaneously.
// However you can override this behaviour with custom show/hide animation routines.
// I have included an example clipping animation below. Feel free to edit it, or delete
// this entire section if you don't like the animation to turn it off.
//   If you've created several menu objects, you must assign the animation functions to
// each of them to override the default if you want them all to animate. Also note that not
// all browsers can clip happily, such as Opera, so they don't have these functions assigned.

// This is the clipping animation function. Customisers: My lyr.clip() command gets passed the
// parameters (x1, y1, x2, y2) so you might want to adjust the direction etc. Oh, and I'm
// adding 2 to the dimensions to be safe due to different box models in some browsers.
// Another idea: add some if/thens to test for specific menu names...?
function menuClip(menuObj, menuName, dir)
{
 // The array index of the named menu (e.g. 'mFile') in the menu object (e.g. 'pMenu').
 var mD = menuObj.menu[menuName][0];
 // Add timer and counter variables to the menu data structure, we'll need them.
 if (!mD.timer) mD.timer = 0;
 if (!mD.counter) mD.counter = 0;
 with (mD)
 {
  // Stop any existing animation.
  clearTimeout(timer);
  // If the layer doesn't exist (cross-frame navigation) quit.
  if (!lyr || !lyr.ref) return;
  // Show the menu if that's what we're doing.
  if (dir==1) lyr.vis('visible');
  // Also raise showing layers above hiding ones.
  lyr.sty.zIndex = 1001 + dir;
  // Clip the visible area. Tweak this if you want to change direction/acceleration etc.
  lyr.clip(0, 0, menuW+2, (menuH+2)*Math.pow(Math.sin(Math.PI*counter/20),0.75) );
  // Increment the counter and if it hasn't reached the end (10 steps either way) set the timer.
  // Clear the clipping value in DOM browsers as early NS6 versions are quite terrible at this.
  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);
 }
}


// Add the effect to the 'pMenu' menu object for supported browsers. Opera doesn't support clipping
// so we turn it off, neither does IE4/Mac.
if (!window.opera)
{
 pMenu.showMenu = new Function('mN','menuClip(pMenu, mN, 1)');
 pMenu.hideMenu = new Function('mN','menuClip(pMenu, mN, -1)');
 // Add it to other menu objects like this...
 //anotherMenu.showMenu = new Function('mN','menuClip(anotherMenu, mN, 1)');
 //anotherMenu.hideMenu = new Function('mN','menuClip(anotherMenu, mN, -1)');
}






// *** (5) FRAMESETS ***





// *** (6) OPTIONAL CODE ***   DELETE IF YOU'RE NOT USING THESE!
//
// If you want, you can assign functions to handle mouse events like mouse over/out/click.
// You'll want to use these for assigning click actions to 'sm:' items or status messages etc.
// 'with (this)' means use the properties of the menu object, like overM and overI which
// are the current menu name and item number.
// To uncomment and activate, delete the /* and */ at the start and end.

/*
pMenu.onclick = function() { with (this)
{
 // Do actions depending on the item that the mouse was over at the time of the click.
 // You may with to use nested IFs or 'switch' statements etc. if you're familiar with JS.
 if (overM == 'root' && overI == 1) status = 'Congratulations, you\'ve mastered clicking!';
 if (overM == 'root' && overI == 2) location.href = 'edit.html';
}}

// Set the status message to the URL if the 'action type' is nothing, and clear on mouseout.
pMenu.onmouseover = function() { with (this)
{
 // By now, you either have my JS Object Browser script from my site or you need it... try
 // embedding in an IFrame and typing 'pMenu' into its Go To field to see the menu internals.
 with (menu[overM][overI]) if (!type) status = href;
}}
pMenu.onmouseout = function() { status = '' }
*/



// This illustrates changing the contents of the menu -- delete this, it's unnecessary...
// This DOES NOT WORK in Opera yet (as of v6.00 at time of writing) by the way.
function changeMenu() { with (pMenu)
{
 // If your modifications are quite extensive, probably hide the menu before commencing
 // them, as the script relies on the menu array in realtime to handle highlighting etc.
 //over('root', 0);
 //menu.root[0].lyr.vis('hidden');

 // Create a whole new menu...
 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);

 // Alter just the 'Visit My Site' menu item to pop it out... setting nextItem tells the
 // addItem() command which item number we are up to in the sequence.
 actMenu = 'root';
 nextItem = 4;
 addItem('&nbsp; Dynamism...', 'mNewMenu', 'sm:', hBar, 80);

 // Call the update function to implement our changes.
 update();
}}


// This is just the moving command called when you click the feature list.
function moveRoot()
{
 with (pMenu.menu.root[0].lyr) x( (x()<100) ? 100 : 10);
}
