///////////////////////////////////////////////
//                                           //
// This file contains the left and top menus //
//                                           //
///////////////////////////////////////////////

// Menu items:
//     1st element: Menu name
//     2nd element: Menu URL
//
items = new Array
(
    'Home',                      'index.htm',
    //'Double Dulcimer Gathering', 'dd/index.htm',
    'Store',                     'store.htm',
    'By-Laws',                   'bylaws.htm',
    'Constitution',              'constitution.htm',
    'Officers',                  'officers.htm',
    'Events',                    'events.htm',
    'Newsletters',               'newsletters.htm',
    'Photos',                    'photos.htm',
    'Dulcimer Class',            'class.htm',
    'Related Links',             'links.htm'
);

// Display left menu
//
// Input:
//     sel     = Menu item to select
//     basedir = Optional argument indicating the location of the base directory
//     allow   = Optional argument indicating whether to allow selected menu item to
//               be selected
//
function leftMenu(sel, basedir, allow)
{
    with(document)
    {
        write('<td class="MainLeft">');
        write('<table class="LeftMenu" border="0">');

        // For each menu item
        for (idx = 0; idx < items.length; idx += 2)
        {
            // Form link
            if (basedir)
            {
                link = basedir + '/' + items[idx + 1];
            }
            else
            {
                link = items[idx + 1];
            }
            
            // Form text
            text = '<nobr>' + items[idx] + '</nobr>';

            write('<tr class="LeftMenu">');

            // If this is the selected item,
            if (sel == items[idx])
            {
                write('<td class="LeftMenuSel">');

                // If selected item can be selected,
                if (allow)
                {
                    // Display selected item as a link
                    write('<a class="LeftMenuSel" href="' + link + '">' +
                        text + '</a>');
                }
                // Else,
                else
                {
                    // Display selected item as text
                    write(text);
                }

                write('</td>');
            }
            // Else,
            else
            {
                // Display item as a link
                write('<td class="LeftMenuUnsel">' +
                    '<a class="LeftMenuUnsel" href="' + link + '">' +
                    text + '</a></td>');
            }

            write('</tr>');
        }

        write('</table>');
        write('</td>');
    }
}

// Display bottom menu
//
// Input:
//     sel     = Menu item to select
//     basedir = Optional argument indicating the location of the base directory
//
function bottomMenu(sel, basedir)
{
    with(document)
    {
        write('<tr valign="top">');
        write('<td class="MainLeft">&nbsp;</td>');
        write('<td class="BottomMenu">');
        write('<p class="BottomMenu">');

        // For each menu item
        for (idx = 0; idx < items.length; idx += 2)
        {
            // If not first item,
            if (idx > 0)
            {
                // Display bar
                write('<span class="BottomMenuSel">&nbsp;|&nbsp;</span>');
            }

            // Form text
            text = '<nobr>' + items[idx] + '</nobr>';

            // If this is the selected item,
            if (sel == items[idx])
            {
                // Display selected item as text
                write(text);
            }
            // Else,
            else
            {
                // Form link
                if (basedir)
                {
                    link = basedir + '/' + items[idx + 1];
                }
                else
                {
                    link = items[idx + 1];
                }

                // Display selected item as a link
                write('<a href="' + link + '">' + text + '</a>');
            }
        }

        write('</p>');
        write('</td>');
        write('</tr>');
    }
}
