// Syntaxes:    *** READ THIS SECTION CAREFULLY! ***
//
// menu[menuNumber][0] = new Menu('menu ID', left, top, width, 'mouseover colour',
//  'background colour', 'border colour', 'stylesheet class');
// Left and Top are measured on-the-fly relative to the top-left corner of its trigger, or
// for the root menu, the top-left corner of the page.
//
// menu[menuNumber][itemNumber] = new Item('Text', 'URL', height of menu item, additional 
//  spacing to next menu item, number of target menu to popout);
//
// If no target menu (popout) is desired, set it to 0. All menus must trace back their
// targets to the root menu! That is, every menu must be targeted by one item somewhere.
// Even if you're making your own root menu, you must still specify its settings here.

var menu = new Array();

// Default colours passed to most menu constructors (just passed to functions, not
// a global variable - makes things easier to change later).
var defOver = '#336699', defBack = '#003366', defBorder = '#000000';

// Default height of menu items - the spacing to the next item, actually.
var defHeight = 22;

// Menu 0 is the special, 'root' menu from which everything else arises.
menu[0] = new Array();
// Pass a few different colours, as an example.
menu[0][0] = new Menu('rootMenu', 0, 0, 80, '#669999', '#006666', defBorder, 'item');
// Notice how the targets are all set to nonzero values...
menu[0][1] = new Item('Home', 'indexmain.htm', defHeight, 0, 0);
menu[0][2] = new Item('Info', '#', defHeight, 0, 1);
menu[0][3] = new Item('Thisweek', '#', defHeight, 0, 2);
menu[0][4] = new Item('Updates', '#', defHeight, 0, 3);
menu[0][5] = new Item('Newsreleases', '#', defHeight, 0, 7);
menu[0][6] = new Item('Grapevine', '#', defHeight, 0, 6);
menu[0][7] = new Item('Mission', '#', defHeight, 0, 8);
menu[0][8] = new Item('Beliefs', '#', defHeight, 0, 9);

menu[1] = new Array();
// The File menu is positioned 0px across and 22 down from its trigger, and is 80 wide.
// All text in this menu has the stylesheet class 'item' -- see the <style> section above.
menu[1][0] = new Menu('InfoMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[1][1] = new Item('Services', 'serv01sundays.htm', defHeight, 0, 0);
menu[1][2] = new Item('Retirement homes', 'serv02sundays.htm', 40, 0, 0);
// Non-zero target means this will trigger a popout -- menu[4] which is the 'Reopen' menu.
menu[1][3] = new Item('Links', 'links.htm', defHeight, 0, 0);
//menu[1][4] = new Item('', '#', defHeight, 0, 0);

menu[2] = new Array();
menu[2][0] = new Menu('ThisweekMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[2][1] = new Item('Activities', 'this_week.htm', defHeight, 0, 0);
menu[2][2] = new Item('Prayer', 'this_week_prayer.htm', defHeight, 0, 0);
menu[2][3] = new Item('Noticeboard', 'noticeboard.htm', defHeight, 0, 0);

menu[3] = new Array();
menu[3][0] = new Menu('UpdatesMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[3][1] = new Item('Updates', 'updates.htm', defHeight, 0, 0);
//menu[3][2] = new Item('', '#', defHeight, 0, 0);
//menu[3][3] = new Item('', '#', defHeight, 0, 5);

menu[4] = new Array();
// This is across but not down... a horizontal popout (with crazy colours :)...
menu[4][0] = new Menu('GrapeMarMenu', 85, 0, 120, '#333366', '#666699', '#663399', 'crazy');
menu[4][1] = new Item('Cover page', 'gvinemar01_01.htm', defHeight, 0, 0);
menu[4][2] = new Item('Leading article', 'gvinemar01_02.htm', defHeight, 0, 0);
menu[4][3] = new Item('Gift Aid', 'gvinemar01_03.htm', defHeight, 0, 0);
menu[4][4] = new Item('Tape Ministry', 'gvinemar01_04.htm', defHeight, 0, 0);
menu[4][5] = new Item('Departmental notes', 'gvinemar01_05.htm', defHeight, 0, 0);

menu[5] = new Array();
// Leftwards popout with a negative x relative to its trigger.
menu[5][0] = new Menu('aboutMenu', -85, -00, 80, defOver, defBack, defBorder, 'item');
menu[5][1] = new Item('Index', 'our_beliefs.htm', defHeight, 5, 0);
menu[5][2] = new Item('We are a<br>Baptist Church', 'pp1_baptist_church.htm', 50, 0, 0);
menu[5][3] = new Item('Baptism &<br>Membership', 'pp2_baptism_chmemb.htm', 40, 0, 0);
menu[5][4] = new Item('Church<br>Structures', 'pp3_structures.htm', 40, 0, 0);

menu[6] = new Array();
menu[6][0] = new Menu('GrapevineMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[6][1] = new Item('Introduction', 'grapevineindex.htm', defHeight, 0, 0);
menu[6][2] = new Item('Feb/Mar', '#', defHeight, 0, 4);
//menu[6][3] = new Item('Apr/May', '#', defHeight, 0, 0);

menu[7] = new Array();
menu[7][0] = new Menu('NewsreleasesMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[7][1] = new Item('News index', 'news.htm', defHeight, 0, 0);
menu[7][2] = new Item('Noticeboard', 'noticeboard.htm', defHeight, 0, 0);

menu[8] = new Array();
menu[8][0] = new Menu('MissionMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[8][1] = new Item('Bourner Aug', 'bourneraug.htm', defHeight, 0, 0);
menu[8][2] = new Item('Bourner Mar', 'bournermarch.htm', defHeight, 0, 0);
//menu[8][3] = new Item('', '#', defHeight, 0, 0);

menu[9] = new Array();
menu[9][0] = new Menu('BeliefsMenu', 0, 22, 80, defOver, defBack, defBorder, 'item');
menu[9][1] = new Item('Beliefs', '#', defHeight, 0, 5);
//menu[9][2] = new Item('', '#', defHeight, 0, 0);


// Now, this next bit of script will write our own custom root menu -- a horizontal
// one, as the defaults are all vertical with borders. Even if you are writing your
// own root menu, you must still specify the names, colours and targets above -- the
// positions are calculated on the fly and hence are ignored.
//   Basically, you must duplicate the output of the writeMenus() function. Just work
// from this example. The item id's must be the name of the root menu followed by the
// item number for the script to recognise them, and remember to change the mouseProps
// to the right numbers for each item you add!

// Syntax: startDL('id', x, y, width, height, 'visibility', '#background colour or null
//  for transparent', '#border colour or null for no border', Z-Index of div or layer,
//  'additional properties (such as mouseovers)');
// It returns a string of HTML text comprising the opening tag of a div or layer.

// mouseProps(menu, item) returns the 'onMouseEvent' properties for a specific menu item,
// passed as 'additional properties' to startDL. Just cut and paste below, or allow the
// script to write its own root menu.

// endDL is a variable containing either '</div>' or '</layer>', so add it afterwards.

// Returns <div or layer id="..." style="..."> -- the opening tag of the root menu.
// Change this if you want to  *** MOVE THE MENU BAR AROUND *** etc.
newRoot = startDL('rootMenu', 0, 0, '100%', 17, 'hidden', '#006666', null, 100, '');

 // Add the opening tag of the first menu item div, with mouse properties!
 newRoot += startDL('rootMenu1', 5, 0, 40, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 1));
 // Content of tag and the end of the tag. Replace this with images etc...?
 newRoot += '<a class="item" href="indexmain.htm">&nbsp; Home</a>' +
  endDL;

 newRoot += startDL('rootMenu2', 55, 0, 80, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 2));
 newRoot += '<span class="item" style="cursor: default">&nbsp; Info</span>' + endDL;

 newRoot += startDL('rootMenu3', 95, 0, 80, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 3));
 newRoot += '<span class="item" style="cursor: default">&nbsp; This Week</span>' + endDL;

 newRoot += startDL('rootMenu4', 175, 0, 60, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 4));
 newRoot += '<span class="item" style="cursor: default">&nbsp; Updates</span>' + endDL;

 // Now, let's add a non-popout item just for fun.
 // mouseProps are still necessary as they handle highlighting etc.
 newRoot += startDL('rootMenu5', 245, 0, 100, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 5));
newRoot += '<span class="item" style="cursor: default">&nbsp; News releases</span>' + endDL;
 
newRoot += startDL('rootMenu6', 355, 0, 75, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 6));
 newRoot += '<span class="item" style="cursor: default">&nbsp; Grapevine</span>' + endDL;

 newRoot += startDL('rootMenu7', 430, 0, 55, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 7));
 newRoot += '<span class="item" style="cursor: default">&nbsp; Mission</span>' + endDL;
 
newRoot += startDL('rootMenu8', 490, 0, 60, 17, 'inherit', '#006666', null, 100,
  mouseProps(0, 8));
 newRoot += '<span class="item" style="cursor: default">&nbsp; Beliefs</span>' + endDL;

newRoot += endDL;

// Pass this two strings. The first is either a variable containing HTML which, if passed,
// will be written to the document in place of an auto-generated vertical root menu. The
// 'newRoot' variable above is an example of a custom horizontal root menu. If you want a
// vertical menu like the one one my site, try writeMenus(null, '&gt;') which is easier
// for new users. You'll have to change all the positions of course, but you can get rid
// of the entire newRoot section above. The second string is the popout indicator HTML -
// currently a 'greater than' sign, try an image tag...?
 
writeMenus(newRoot, '&gt;');


// This is a quick snippet that captures all clicks on the document and hides the menus
// every time you click. Use if you want.

if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = clickHandle;

function clickHandle(evt)
{
 if (isNS4) document.routeEvent(evt);
 hideAllBut(0);
}


// Show root menu command - place in an onLoad="..." type function if you want.
eval(docObj + menu[0][0].id + styObj + '.visibility = "visible"');


// This is just the moving command for the example. *** DELETE ME! ***
// Either that or set a <body onresize="centreMenus()"> event handler to a function like
// this... pick up either window.innerWidth (in NS) or document.body.clientWidth (in DOM
// browsers), halve it, subtract a few hundred px, and set that as rM.left.
function moveRoot()
{
 rM = eval(docObj + menu[0][0].id + styObj);
 if (parseInt(rM.top) < 40) rM.top = 40;
 else rM.top = 0;
}
