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

// 'horizontal Bar' style: menu items that use this ItemStyle are 40px wide, have 10px gaps
// between them, no popout indicator (the ">" in some menus) or popout indicator position,
// 0px padding of the text within items, #336699 background colour, a hover colour of #6699CC,
// 'highText' is the stylesheet class used for the menu text both normally and when highlighted,
// no border styles, 'null' means fully opaque items (set them to numbers between 0 and 100 to
// enable semitranslucency), and the 'hand'/'default' cursors are used for linked/submenu items.


var hBar = new ItemStyle(120, 5, '', 0, 0, '', '', '', '', '', '', null, null, 'hand', 'default');

var dBlue = new ItemStyle(20, 0, '<img src="images/folderopen.gif">', -20, 3, '#666699', '#336699', 'itemText', 'itemHover', 'itemBorder', 'itemBorder', null, null, 'hand', 'default');
var dTop = new ItemStyle(20, 0, '', 0, 0, '', '', 'crazyText', 'crazyHover', '', '', null, null, 'hand', 'default');

// *** (2) MENU DATA ***
//
var pMenu = new PopupMenu('pMenu');
with (pMenu)
{

// *** MOVE OR CENTRE THE MENU HERE ***

//startMenu('root', false, 'page.winW()/2 - pMenu.menu.root[0].menuW/2', 0, 17, hBar); // Centres.
//startMenu('root', false, 10, 'page.scrollY()', 17, hBar); // Floats with window as you scroll.
//startMenu('root', false, 10, 0, 17, hBar, 'frameName'); // To create in subframe.
// The 'root' menu is horizontal, positioned at (x = 10, y = 0) and is 17px high, and items
// by default use the colours and dimensions in the 'hBar' ItemStyle defined above.
// This menu is also positioned over a similarly-coloured table in the HTML document above.


startMenu('root', false, '150', 95, 20, hBar);

// *****************  Top menu  ***********************
// *******************************************************

// The text is a space then 'File', and this item pops out the 'mFile' submenu when moused over as
// we've set 'sm:' as the action type.
addItem('De Bond', 'mBond', 'sm:',dTop , 100, 10);
addItem('Verenigingen', 'mVerenigingen', 'sm:',dTop, 130, 10);
addItem('Wedstrijd uitslagen', 'mWedstrijden', 'sm:',dTop, 170, 10);

// To open a file in a frame named 'main' we would use the following syntax:
// addItem('Text', 'file.html', 'parent.main');
// Next is an example of a Javascript function embedded in the menu, to open a new window...
// Also, note the extra optional 4th and 5th parameters -- this menu item is 80px long,
// rather than the default length from the ItemStyle.


// ************    De Bond     ***************
// *******************************************

startMenu('mBond', true, 0, 25, 138, dBlue);

addItem('Intro', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/de-bond.htm")', 'js:');
addItem('De Historie van de Gezellig Samenzijn', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/historie.htm")', 'js:','',36,0);
addItem('Historische verslagen jaarvergaderingen', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/geschiedenis/jaarvergaderingen/jaarvergaderingen overzicht.htm")', 'js:','',36,0);
addItem('GS Regelementen', 'mRegel', 'sm:','',20,0);
addItem('GS Statuten', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/statuten/statuten.htm")', 'js:','',20,0);
addItem('Het bestuur','window.open("http://www.gezelligsamenzijn.nl/bond-gs/adres-bestuursleden-GS.xls")', 'js:');
addItem('Klasse indeling 2012','window.open("http://www.gezelligsamenzijn.nl/bond-gs/klasse-indeling/klassenindeling-2012.xls")', 'js:');
addItem('Lezingen', 'mLezing', 'sm:','',20,0);
addItem('Materiaalbeheerder', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/materiaal/materiaal.htm")', 'js:');



// *** GS Regelementen ***
startMenu('mRegel', true, 142, -0, 138, dBlue);
addItem('Wedstrijd regelement', 'mainDiv.load("bond-gs/regelementen/wedstrijd-regelement.htm")', 'js:');
addItem('GS-RL  wedstrijd', 'mainDiv.load("bond-gs/regelementen/gs-rl-regelement.htm")', 'js:');


// *** GS Lezing ***
startMenu('mLezing', true, 142, -0, 138, dBlue);
addItem('Aansprakelijkheid', 'mainDiv.load("diversen/aansprakelijkheid/aansprakelijkheid.htm")', 'js:');




// ******    De Verenigingen    ************
// *******************************************

startMenu('mVerenigingen', true, 0, 25, 138, dBlue);
addItem('GS Overzicht','window.open("http://www.gezelligsamenzijn.nl/de-verenigingen/adressen-gs.xls")', 'js:');
addItem('Landkaart Bond G.S.',  
'window.open("http://www.hbsdester.com/bond-gs/map-gs/map-gs.htm","pop","width=800,height=600,left=0,top=0,scrollbars=no")', 'js:');
addItem('GS verenigingen<br>met eigen website', 'mGswebsites', 'sm:','',36,0);


// *** GS verenigingen ***
startMenu('mGsver', true, 142, 0, 138, dBlue);
addItem('Bond G.S.','window.open("http://www.gezelligsamenzijn.nl")', 'js:');
addItem('----------------------',  'mainDiv.load("")', 'js:');




// *** GS websites ***
startMenu('mGswebsites', true, 142, -38, 178, dBlue);
addItem('Bond G.S.','window.open("http://www.gezelligsamenzijn.nl")', 'js:');
addItem('----------------------',  'mainDiv.load("")', 'js:');
addItem('Boukoul - Soranus','window.open("http://www.soranusboukoul.nl")', 'js:');
addItem('Haler-Uffelse - Grensschutters','window.open("http://www.degrensschutters.nl")', 'js:');
addItem('Heel - De Zonnebloem','window.open("http://www.handboogheel.nl ")', 'js:');
addItem('Heibloem - Heideroosje','window.open("http://www.heideroosjeheibloem.nl")', 'js:');
addItem('Herkenbosch - Boschjagers','window.open("http://www.boschjagers.nl")', 'js:');
addItem('Heythuysen - O.V.U.','window.open("http://www.onzevrijeuren.nl")', 'js:');
addItem('Horn - Wilhelmina','window.open("http://www.hbvwilhelmina.nl/")', 'js:');
addItem('Myhl (D) - Silberpfeil','window.open("http://www.bsc-silberpfeil.de")', 'js:');
addItem('Neer - Vriendschap en Strijd','window.open("http://www.vriendschapenstrijd.nl")', 'js:');
addItem('Nimrod - Echt','window.open("http://www.hbs-nimrod.nl ")', 'js:');
addItem('Pey-Echt - H.B.S. de Ster','window.open("http://www.hbsdester.com")', 'js:');
addItem('Posterholt - Ontspanning na arbeid','window.open("http://www.hbs-onaposterholt.nl ")', 'js:');
addItem('Roggel - Ons Genoegen ','window.open("http://www.hbv-onsgenoegen.nl")', 'js:');
addItem('Slek-Echt - Zwarte Roos','window.open("http://www.dezwarteroos.com")', 'js:');
addItem('Vlodrop - De Snelle Pijl','window.open("http://www.desnellepijl.com")', 'js:');



// ***************    Wedstrijd uitslagen  **********************
// *******************************************************

startMenu('mWedstrijden', true, 0, 25, 138, dBlue);
// The URLs are set to # here, be sure to replace them with your path/file names or JS functions!
// Also note how all the types are '', indicating these links open in the current frame.

addItem('Bonds/Nationaal<br>concours', 'mBondsnat', 'sm:','',36,0);
addItem('GS / Regio Limburg', 'mGsool', 'sm:','',20,0);
addItem('Pers Kamp. 2011','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/pers-kamp/2011/pers-kamp-2011-resultaat-deelnemers.xls")', 'js:');
addItem('Korps Kamp. 2011','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/korps/2011/Uitslag%20korpskampioenschap%202011.doc")', 'js:');
addItem('Fotos Pers/Korps 2011','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/korps/2011/kampioenschappen_bond_gezellig_samenzijn_2011/index.html")', 'js:');
addItem('Veteranen', 'mvet', 'sm:');



//*** Veteranen***
startMenu('mvet', true, 142, 0, 138, dBlue);
addItem('Vet treffen 2010','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/veteranen/uitslag-veteranentreffen-2010.doc")', 'js:');
addItem('Vet Kamp. 2011','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/veteranen/uitslag-veteranenkamp-2011.doc")', 'js:');






// Bonds Wedstrijden
startMenu('mBondsnat', true, 142, 0, 138, dBlue);
addItem('2008', 'mBC2008', 'sm:');
addItem('2009', 'mBC2009', 'sm:');
addItem('2010', 'mBC2010', 'sm:');
addItem('2011', 'mBC2011', 'sm:');


//*** Bonds Nationaal Concoursen 2008***
startMenu('mBC2008', true, 142, 0, 138, dBlue);
addItem('1e Bonds Concours','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2008/Uitslag 1e bonds 2008.pdf")', 'js:');
addItem('Nat. Jub concours Heibloem','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2008/uitslagenlijst-NC-Heidebloem-2008.xls")', 'js:');
addItem('Nat. Conc. Slek-Echt','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2008/uitslagenlijst-NC-Slek-Echt-2008.xls")', 'js:');
addItem('2e Bonds Concours','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2008/uitslagenlijst-2e-bonds-Slek-Echt-2008-gs.xls")', 'js:');
addItem('3e Bonds Concours','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2008/Uitslagenlijst-3e-bonds-Heibloem.xls")', 'js:');


//*** Bonds Nationaal Concoursen 2009***
startMenu('mBC2009', true, 142, 0, 138, dBlue);
addItem('1e Bonds Concours','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2009/uitslagenlijst 1e BC 2009.xls")', 'js:');
addItem('Nat. Jub concours Haler','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2009/Uitslag jub concours GS.doc")', 'js:');
addItem('Nat. Conc. Melick','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2009/uitslagenlijst NC Melick 2009.xls")', 'js:');
addItem('2e Bonds Concours','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2009/uitslagenlijst 2e BC 2009.xls")', 'js:');


//*** Bonds Nationaal Concoursen 2010***
startMenu('mBC2010', true, 142, 0, 138, dBlue);
addItem('1e Bonds Leveroy','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagenlijst-1e-bonds-Leveroy.xls")', 'js:');
addItem('Nationaal Boukoul','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagenlijst-OC-Boukoul.xls")', 'js:');
addItem('Nationaal Linne','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagenlijst-NC-Linne-2010.xls")', 'js:');
addItem('Nationaal Roggel','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagenlijst-NC-Roggel.xls")', 'js:');
addItem('2e Bonds Posterholt','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagenlijst-2e-bonds-Posterholt.xls")', 'js:');
addItem('3e Bonds Myhl','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2010/uitslagen-3e-BC-Myhl.xls")', 'js:');

//*** Bonds Nationaal Concoursen 2011***
startMenu('mBC2011', true, 142, 0, 138, dBlue);
addItem('1e Bonds Boukoul','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2011/1e-BC-Boukoul-2011.xls")', 'js:');
addItem('2e Bonds Boukoul','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2011/2e-BC-Boukoul-2011.xls")', 'js:');
addItem('3e Bonds Baexem','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2011/3e-BC-Baexem-2011.xls")', 'js:');
addItem('4e Bonds Neer','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2011/4e-BC-Neer-2011.xls")', 'js:');
addItem('5e Bonds Neer','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/bonds-nat/2011/5e-BC-Neer-2011.xls")', 'js:');



// *** GS - OOL ***
startMenu('mGsool', true, 142, -0, 138, dBlue);
addItem('Selectie','window.open("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/gs-ool/bondsteams.doc")', 'js:');
// addItem('OOL - GS', 'mainDiv.load("http://www.gezelligsamenzijn.nl/bond-gs/wedstrijden/gs-ool/1e_gs-ool_wedstrijd.htm")', 'js:');

}


// *** (3) MENU EFFECTS AND ANIMATION ***


// addMenuBorder(menuObject, ItemStyle,
//  opacity of border, 'border colour', border width, 'padding colour', padding width);
// Opacity is a number from 0 to 100, or null for no filter, like the ItemStyles.

addMenuBorder(pMenu, window.dBlue, null, '#666666', 0, '#ffffff', 0);

// [opacity, 'layer colour', X offset, Y offset, Width Difference, Height difference]

addDropShadow(pMenu, window.dBlue,
 [40,"#333333",6,6,-4,-4], [40,"#666666",4,4,0,0]);

if (!isOp && navigator.userAgent.indexOf('rv:0.')==-1)
{
pMenu.showMenu = new Function('mN','menuAnim(this, mN, 20)');
pMenu.hideMenu = new Function('mN','menuAnim(this, mN, -10)');

}


// *** (4) 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 if required.
 var popOldOL = window.onload;
 window.onload = function()
 {
  if (popOldOL) popOldOL();
  pMenu.update();
  //anotherMenu.update();
 }
}


var nsWinW = window.innerWidth, nsWinH = window.innerHeight, popOldOR = window.onresize;
window.onresize = function()
{
 if (popOldOR) popOldOR();
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) history.go(0);
 pMenu.position();
 //anotherMenu.position();
}

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


// NS4 can't reliably capture clicks on layers, so here's a workaround.
if (isNS4)
{
 document.captureEvents(Event.CLICK);
 document.onclick = function(evt)
 {
  with (pMenu) if (overI) click(overM, overI);
  //with (anotherMenu) if (overI) click(overM, overI);
  return document.routeEvent(evt);
 }
}

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




// ANIMATION:
//

function menuAnim(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>0) lyr.vis('visible');
  // Also raise showing layers above hiding ones.
  lyr.sty.zIndex = 1001 + dir;

  // Alpha fade in IE5.5+. Mozilla's opacity isn't well suited to this as it's an inheritable
  // property rather than a block-level filter, and it's slow, but uncomment and try it perhaps.
  // WARNING: This looks funny if you're mixing opaque and translucent items e.g. solid menus
  // with dropshadows. If you're going to use it, make sure all your alpha values for a given
  // menus are numbers, or they're all null (solid).
  //if (isIE && window.createPopup) lyr.alpha(counter&&(counter<100) ? counter : null);

  // 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/200),0.75) );
  // Remove clipping in NS6 on completion, seems to help old versions.
  if ((isDOM&&!isIE) && (counter>=100)) lyr.sty.clip='';

  // Increment the counter and if it hasn't reached the end (10 steps either way),
  // set the timer to call the show/hide function again in 40ms.
  counter += dir;
  if (counter>100) counter = 100;
  else if (counter<0) { counter = 0; lyr.vis('hidden') }
  else timer = setTimeout(menuObj.myName+'.'+(dir>0?'show':'hide')+'Menu("'+menuName+'")', 40);
 }
}

// Here's the alternative IE5.5+ filter animation function.
function menuFilterShow(menuObj, menuName, filterName)
{
 var mD = menuObj.menu[menuName][0];
 with (mD.lyr)
 {
  sty.filter = filterName;
  var f = ref.filters;
  if (f&&f.length&&f[0]) f[0].Apply();
  vis('visible');
  if (f&&f.length&&f[0]) f[0].Play();
 }
}



// BORDERS AND DROPSHADOWS:
//
function addMenuBorder(mObj, iS, alpha, bordCol, bordW, backCol, backW)
{
 // Loop through the menu array of that object, finding matching ItemStyles.
 for (var mN in mObj.menu)
 {
  var mR=mObj.menu[mN], dS='<div style="position:absolute; background:';
  if (mR[0].itemSty != iS) continue;
  // Loop through the items in that menu, move them down and to the right a bit.
  for (var mI=1; mI<mR.length; mI++)
  {
   mR[mI].iX += bordW+backW;
   mR[mI].iY += bordW+backW;
  }
  // Extend the total dimensions of menu accordingly.
  mW = mR[0].menuW += 2*(bordW+backW);
  mH = mR[0].menuH += 2*(bordW+backW);

  // Set the menu's extra content string with divs/layers underneath the items.
  if (isNS4) mR[0].extraHTML += '<layer bgcolor="'+bordCol+'" left="0" top="0" width="'+mW+
   '" height="'+mH+'" z-index="980"><layer bgcolor="'+backCol+'" left="'+bordW+'" top="'+
   bordW+'" width="'+(mW-2*bordW)+'" height="'+(mH-2*bordW)+'" z-index="990"></layer></layer>';
  else mR[0].extraHTML += dS+bordCol+'; left:0px; top:0px; width:'+mW+'px; height:'+mH+
   'px; z-index:980; '+(alpha!=null?'filter:alpha(opacity='+alpha+'); -moz-opacity:'+(alpha/100):'')+
   '">'+dS+backCol+'; left:'+bordW+'px; top:'+bordW+'px; width:'+(mW-2*bordW)+'px; height:'+
   (mH-2*bordW)+'px; z-index:990"></div></div>';
 }
}


function addDropShadow(mObj, iS)
{
 // Pretty similar to the one above, just loops through list of extra parameters making
 // dropshadow layers (from arrays) and extending the menu dimensions to suit.
 for (var mN in mObj.menu)
 {
  var a=arguments, mD=mObj.menu[mN][0], addW=addH=0;
  if (mD.itemSty != iS) continue;
  for (var shad=2; shad<a.length; shad++)
  {
   var s = a[shad];
   if (isNS4) mD.extraHTML += '<layer bgcolor="'+s[1]+'" left="'+s[2]+'" top="'+s[3]+'" width="'+
    (mD.menuW+s[4])+'" height="'+(mD.menuH+s[5])+'" z-index="'+(arguments.length-shad)+'"></layer>';
   else mD.extraHTML += '<div style="position:absolute; background:'+s[1]+'; left:'+s[2]+
    'px; top:'+s[3]+'px; width:'+(mD.menuW+s[4])+'px; height:'+(mD.menuH+s[5])+'px; z-index:'+
    (a.length-shad)+'; '+(s[0]!=null?'filter:alpha(opacity='+s[0]+'); -moz-opacity:'+(s[0]/100):'')+
    '"></div>';
   addW=Math.max(addW, s[2]+s[4]);
   addH=Math.max(addH, s[3]+s[5]);
  }
  mD.menuW+=addW; mD.menuH+=addH;
 }
}
