/* support/js/mr-menus323.js - menu systems, MartinRinehart.com
Copyright 2012, Martin Rinehart */

/* Table of Contents
  63 I. The Global 
  65     A. MRmenus323 - Object 
  72     B. MRmenus323.home_func() For logo click. 
  85     C. MRmenus323.home - 
  89     D. MRmenus323.go() For navigation. 
  98 II. Menu-Related Constants 
  99     A. Menu Class 
 101         1. MRmenus323.MENU_STYLE - Default styles. 
 104     B. MenuItem Class 
 106         1. MRmenus323.MENU_ITEM_STYLE - Default styles. 
 121         2. MRmenus323.MENU_ITEM_STYLE_hover - Mouseover. 
 127         3. MRmenus323.MENU_ITEM_STYLE_nohover - Mouseout. 
 133         4. MRmenus323.MENU_ITEM_STYLE_punched - Punched in. 
 140         5. MRmenus323.MENU_ITEM_STYLE_unpunched - Not punched in. 
 147 III. Menu Classes 
 149     A. Menu Class 
 151         1. Menu Instance Basics 
 153             a) MRmenus323.Menu() 
 185             b) MRmenus323.Menu.prototype.remove() 
 193             c) MRmenus323.Menu.prototype.toString() 
 207         2. Menu Instance Methods 
 209             a) MRmenus323.Menu.prototype.layout() Horizontal layout. 
 237             b) MRmenus323.Menu.prototype.punch() 
 245             c) MRmenus323.Menu.prototype.unpunch_all() 
 256     B. MenuItem Class 
 258         1. MenuItem Instance Basics 
 260             a) MRmenus323.MenuItem() 
 294             b) MRmenus323.MenuItem.prototype.remove() 
 298             c) MRmenus323.MenuItem.prototype.toString() 
 303         2. MenuItem Class Methods 
 305             a) MRmenus323.MenuItem.click() Click event handler. 
 324             b) MRmenus323.MenuItem.mouseout() End hover event handler. 
 331             c) MRmenus323.MenuItem.mouseover() Hover event handler. 
 338 IV. MR.com Menu Data 
 340     A. Menus 
 343         1. MRmenus323.MenusTableColumns - 
 345         2. MRmenus323.MenusTableData - 
 374     B. Items In Menus 
 377         1. MRmenus323.ItemsInMenusColumns - 
 379         2. MRmenus323.ItemsInMenusData - 
 420     C. MenuItems 
 423         1. MRmenus323.MenuItemsColumns - 
 425         2. MRmenus323.MenuItemsData - 
 653     D. Menu Tables 
 655         1. MRmenus323.MenusTable - 
 659         2. MRmenus323.MenuItemsTable - 
 663         3. MRmenus323.ItemsInMenusTable - 
 667     E. Menu Getters 
 669         1. MRmenus323.get_data() 
 685 V. Book Page Turners 
 687     A. Page Turner Styles 
 689         1. MRmenus323.turner_styles - 
 705         2. MRmenus323.turner_prev_styles - 
 713         3. MRmenus323.turner_next_styles - 
 721     B. Page Turners 
 723         1. MRmenus323.page_turners() Builder 
*/
// alert( 'starting to load menus.js' );
/**I The Global */

/** Object */
var MRmenus323 = {
    COLOR_default_background: '#f0f0ff',
    COLOR_default_border: '#a0a0ff',
    COLOR_hover: 'white'
};

/** For logo click. 
Returns the location through the first forward slash following, if present,
'MR23' (or the first slash, if no 'MR23'). 
This is correct on the website and on the office computers. */
MRmenus323.home_func = function () {

    var str = window.location.href; // the full location
    var key_loc = str.indexOf( 'MR23' ); // local drive root
    var post_slash = str.indexOf( "/", key_loc ) + 1; // first '/' after root
    return str.substr( 0, post_slash ); // chars 0 thru the above '/'

} // end: home_func()

/** 
Online, home is '/'. In office, home is '.../MR23/'. */
MRmenus323.home = MRmenus323.home_func();

/** For navigation. */
MRmenus323.go = function ( loc ) { window.location = MRmenus323.home + loc; }
MRmenus323.go_fe = function ( loc )
        { MRmenus323.go( 'frontend-engineering/' + loc ) }; 
MRmenus323.go_fe_a = function ( loc )
        { MRmenus323.go( 'frontend-engineering/artists/' + loc ) }; 
MRmenus323.go_fe_e = function ( loc )
        { MRmenus323.go( 'frontend-engineering/engineers/' + loc ) }; 

/**I Menu-Related Constants */
    /**A Menu Class */

/** Default styles. */
MRmenus323.MENU_STYLE = { height: '23px', position: 'absolute' };
    
    /**A MenuItem Class */ 

/** Default styles. */
MRmenus323.MENU_ITEM_STYLE = {
        backgroundColor: MRmenus323.COLOR_default_background,
        border: '2px outset ' + MRmenus323.COLOR_default_border,
        fontFamily: 'sans-serif',
        fontSize: '8pt',
        // fontWeight: 'bold',
        height: '15px',
        left: '1px',
        overflow: 'hidden',
        position: 'absolute',
        textAlign: 'center',
        top: '0px'
    };
    
/** Mouseover. */    
MRmenus323.MENU_ITEM_STYLE_hover = {
        backgroundColor: '#ffffff',
        cursor: 'pointer'
    };
    
/** Mouseout. */    
MRmenus323.MENU_ITEM_STYLE_nohover = {
        backgroundColor: '#f0f0ff',
        cursor: 'default'
    };
    
/** Punched in. */
MRmenus323.MENU_ITEM_STYLE_punched  = {
        border:  '2px inset #fcfcfc',
        color:   '#a0a0a0',
        padding: '1px 0px 0px 1px'
    };
    
/** Not punched in. */    
MRmenus323.MENU_ITEM_STYLE_unpunched = {
        border:  '2px outset #fcfcfc',
        color:   '#000000',
        padding: ''
    };

/**I Menu Classes */

    /**A Menu Class */

        /**1 Menu Instance Basics */

/** */
MRmenus323.Menu = function ( parent, left, top, width, items, punched ) {

    if ( punched === undefined ) { punched =  -1; }
    if ( items   === undefined ) { items   =  []; }
    if ( width   === undefined ) { width   = 100; }
    if ( top     === undefined ) { top     =   0; }
    if ( left    === undefined ) { left    =   0; }
    if ( parent  === undefined ) { parent  = document.body; }
    
    this.parent = parent;
    this.div = MRlib323.create_attached_element( 
            parent, 'div', '', MRmenus323.MENU_STYLE );
    this.div.style.left = left + 'px';
    this.div.style.top  = top  + 'px';
    this.width = width;
    this.div.style.width = width + 'px';
     
    this.items = items;
    // Note: create menu items from right to left for correct stacking. 
    for ( var i in items ) { // e.g., '0' thru '4'
        var j = '' + ( items.length - 1 - parseInt(i, 10) ); // '4' thru '0'
        var mi_data = items[ j ];
        var is_punched = ( j == punched ); // j is a string, cannot '==='
        this.items[ j ] = new MRmenus323.MenuItem( 
                this, this.div, mi_data, is_punched );
    }
    
    this.layout();
    
} // end: Menu()

/** */
MRmenus323.Menu.prototype.remove = function () {

    for ( var i in this.items ) { this.items[ i ].remove(); }
    MRlib323.delete_element( this.div );

} // end: Menu.remove()

/** */
MRmenus323.Menu.prototype.toString = function () {

    return 'Menu{' +
        'parent=' + parent +
        ',div=' + this.div +
        ',left=' + this.div.style.left +
        ',top=' + this.div.style.top +
        ',items=[' + this.items + ']' +
        // ',items=' + MRlib323.toString(this.items) +
    '}';
    
} // end: Menu.toString()

        /**1 Menu Instance Methods */

/** Horizontal layout. */
MRmenus323.Menu.prototype.layout = function ( wid ) {
        
    if ( wid !== undefined ) { 
        this.width = wid; 
        this.div.style.width = wid + 'px';
    }

    var space_at_ends = 1,
        space_between_items = 0,
        nitems = this.items.length;
        
    var item_space = this.width - ( 2 * space_at_ends ) - 
            ( (nitems - 1) * space_between_items );

    var wpi = Math.floor( item_space / nitems ); // width per item

    var left = space_at_ends;
    for ( var i in this.items ) {
        var item = this.items[ i ];
        var j = parseInt( i, 10 );
        item.span.style.left = left + 'px';
        item.span.style.width = wpi - 4 + 'px'; // 4 for 2 px border width
        left += wpi + space_between_items;
    }

} // end: layout()

/** */
MRmenus323.Menu.prototype.punch = function ( menu_item ) {
    this.unpunch_all();
    MRlib323.object_attach_props( menu_item.span.style,
            MRmenus323.MENU_ITEM_STYLE_punched );
    this.punched = menu_item;            
} // end: Menu.punch()

/** */
MRmenus323.Menu.prototype.unpunch_all = function () {

    for ( var i in this.items ) {
        var item = this.items[ i ];
        MRlib323.object_attach_props( item.span.style,
                MRmenus323.MENU_ITEM_STYLE_unpunched );
    }

} // end: unpunch_all()

    /**A MenuItem Class */

        /**1 MenuItem Instance Basics */

/** */
MRmenus323.MenuItem = function ( 
        parent_menu, parent_element, mi_data, punched ) {

    this.parent_menu = parent_menu;
    var self = this; // passed to 'onclick' handler
    
    /* Note: it will be the DOM element, here called 'this.span', that receives
    and responds to, and is 'this' in, the onclick event handler. */

    this.parent  = parent_element; // the DOM element
    this.prompt  = mi_data[0];
    this.title   = mi_data[1];
    this.action  = new Function( mi_data[2] );
    
    this.span = MRlib323.create_attached_element( parent_element, 'span', '',
            MRmenus323.MENU_ITEM_STYLE );
        if ( punched ) {
            MRlib323.object_attach_props( this.span.style, 
                    MRmenus323.MENU_ITEM_STYLE_punched );
        } else {
                MRlib323.object_attach_props( this.span.style, 
                        MRmenus323.MENU_ITEM_STYLE_unpunched );
        }
        this.span.innerHTML     = this.prompt;
        this.span.title         = this.title
        
        this.span.onmouseout    = MRmenus323.MenuItem.mouseout;
        this.span.onmouseover   = MRmenus323.MenuItem.mouseover;
        this.span.onclick       = function () {
                MRmenus323.MenuItem.click( self, this ); }
    
} // end: MenuItem()

/** */
MRmenus323.MenuItem.prototype.remove = function () {
        MRlib323.delete_element( this.span ); }

/** */
MRmenus323.MenuItem.prototype.toString = function () {
    return 'MenuItem{' + 'prompt=' + this.prompt + '}';
}

        /**1 MenuItem Class Methods */

/** Click event handler. */
MRmenus323.MenuItem.click = function ( menu_item, dom_element ) {

    var is_not_punched = not_punched( dom_element );
    
    if ( is_not_punched ) {
        menu_item.parent_menu.punch( menu_item );
        MRlib323.object_attach_props( 
                dom_element.style, MRmenus323.MENU_ITEM_STYLE_punched );
    }
    
    menu_item.action();
    
    function not_punched( dom_elem ) {
        return dom_elem.style.borderStyle === 'outset';
    }
    
} // end: MenuItem.click()

/** End hover event handler. */
MRmenus323.MenuItem.mouseout = function () { 
    for ( var prop in MRmenus323.MENU_ITEM_STYLE_nohover ) {
        this.style[ prop ] = MRmenus323.MENU_ITEM_STYLE_nohover[ prop ];
    }
} // end: MenuItem.mouseout()

/** Hover event handler. */
MRmenus323.MenuItem.mouseover = function () { 
    for ( var prop in MRmenus323.MENU_ITEM_STYLE_hover ) {
        this.style[ prop ] = MRmenus323.MENU_ITEM_STYLE_hover[ prop ];
    }
} // end: MenuItem.mouseover()

/**I MR.com Menu Data */

    /**A Menus */

/** */    
MRmenus323.MenusTableColumns = ['ID','Name'];

/** */
MRmenus323.MenusTableData = [
    [  0, 'Main'],
    [  1, 'Main w/home'],
    
    [  9, 'Knowits'],
    
    [ 10, 'Knowit V1'],
    [ 11, 'V1 front, chaps, apndxs, back'],
    [ 12, 'V1 font matter'],
    [ 13, 'V1 chapter companions'],
    [ 14, 'V1 appendices'],
    
    [100, 'Artists'],
    [110, 'Artists\' Effects'],
    [120, 'Artists\' Gradients'],
    [130, 'Artists\' Morphs'],
    
    [200, 'Engineers'],
    [204, 'Fe E Tools'],
    [205, 'Frontend Team'],
    [210, 'Engineers HTML'],
    [230, 'Engineers Basic JavaScript'],
    [260, 'Engineers Regular Expressions'],
    
    [400, 'Pages'],
    [500, 'Early_Sites'],
    // 600, contacts, if needed
    
    [1010, 'V1 Listings, Chapter 01']
];
// alert( 'Menus OK' );    

/** */    
MRmenus323.ItemsInMenusColumns = ['MenuID','MenuItemID'];

/** */
MRmenus323.ItemsInMenusData = [
    [  1,    0], [  1, 1000], [  1, 2000], [  1,   99], 
                 [  1, 4000], [  1, 5000], [  1, 6000], // Main w/home
                 
    [  9,  100], [  9,  200], [  9,  300], [  9,  400], [  9,  500], // knowits
    
    [ 10,    0], [ 10,   99], [ 10,  100], // home, knowits, v1
    [ 11,  105], [ 11,  101], [ 11,  110], [ 11,  190], 
                 [ 11,  198], // front, chaps, apndxs, back v1
    [ 12,  102], [ 12,  103], [ 12,  104], 
                 [ 12,  105], [ 12,  106], // copy, dedic, ack, toc v1
    [ 13,  111], [ 13,  112], [ 13,  113], [ 13,  114], [ 13,  115],
    [ 13,  116], [ 13,  117], [ 13,  118], [ 13,  119], [ 13,  120],
    [ 13,  121], [ 13,  122], // chapter companion pages, listings
    [ 14,  191], [ 14,  192], // appendices
    
    [100, 1010], [100, 1100], [100, 1200], [100, 1300], // Artists
    [110, 1110], [110, 1120], [110, 1130], [110, 1140], [110, 1150], 
                 [110, 1160], [110, 1170], [110, 1180], // Artists Effects
    [120, 1210], [120, 1220], [120, 1230], [120, 1240], 
                 [120, 1250], // Artists Gradients
    [130, 1310], [130, 1320], [130, 1330], [130, 1340], // Artists Morphs
    
    [200, 2010], [200, 2050], [200, 2100], /*[200, 2200],*/ [200, 2300],
                 /*[200, 2400], [200, 2500],*/ [200, 2600], // Engineers
                 
    [204, 2041], [204, 2042], [204, 2043], [204, 2044], [204, 2045], // FE Tools
    [205, 2051], [205, 2052], [205, 2053], [205, 2054], [205, 2055], // Team
    [210, 2110], [210, 2120], [210, 2130], // Engineers HTML
    [230, 2310], [230, 2315], [230, 2370], [230, 2340], [230, 2380], 
                 [230, 2320], [230, 2330], // Engineers Basic JS
                 
    [260, 2610], [260, 2620], // Regular Expressions

    [400, 4010], [400, 4020], [400, 4030], [400, 4040], // Pages 
                 
    [500, 5010], [500, 5020], [500, 5030], // Early Sites
    
    [1010, 10101], [1010, 10102], // Listings V1
    
];
// alert( 'ItemsInMenus OK' );

    /**A MenuItems */
/*    MenuItem: ID, Prompt, Title, ClickFunc */
    
/** */
MRmenus323.MenuItemsColumns = ['ID','Prompt','Title','ClickFunc'];
/** */
MRmenus323.MenuItemsData = [
    [   0, 'Home', 'MartinRinehart.com home page.', 
            'MRmenus323.go( "index.html" );'],
    
    [  99, 'Books', 'Books, published and in process.', 
            'MRmenus323.go_fe( "books/books.html" );'],
            
    [ 100, '<i>Pro HTML</i>', 'Professional HTML; ' + 
            'Frontend Engineering series, Volume I of V.', 
            'MRmenus323.go_fe( "books/v1/books-v1.html" );'],      
    [ 101, 'Front&nbsp;Matter', 'Pro HTML copyright page.', 
            'MRmenus323.go_fe( "books/v1/0-front-matter/copyright-v1.html" );'],
    [ 102, 'Copyright', 'Pro HTML copyright page.', 
            'MRmenus323.go_fe( "books/v1/0-front-matter/copyright-v1.html" );'],
    [ 103, 'Dedication', 'Pro HTML front matter, dedication page.', 
            'MRmenus323.go_fe( "books/v1/0-front-matter/dedication-v1.html" );'],
    [ 104, 'Acknowledgements', 
            'Pro HTML front matter, acknowledgements page.', 
            'MRmenus323.go_fe( "books/v1/0-front-matter/acknowledgements-v1.html" );'],
    [ 105, 'TOC', 'Pro HTML front matter, table of contents page.', 
            'MRmenus323.go_fe( "books/v1/0-front-matter/toc-v1.html" );'],
    [ 106, 'Knowit', 
            'Pro HTML front matter, knowledge unit (knowit) introduction.', 
            'MRmenus323.go_fe( ' +
            '"books/v1/0-front-matter/knowit-intro-v1.html" );'],
            
    [ 110, 'Chapters', 'Pro HTML chapter companion pages and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/01/v1-chapter-01.html" );'],
    [ 111, '1', 'Pro HTML chapter 1 companion page and listings.',
            'MRmenus323.go_fe( "books/v1/1-chapters/01/v1-chapter-01.html" );'],
    [ 112, '2', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/02/v1-chapter-02.html" );'],
    [ 113, '3', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/03/v1-chapter-03.html" );'],
    [ 114, '4', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/04/v1-chapter-04.html" );'],
    [ 115, '5', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/05/v1-chapter-05.html" );'],
    [ 116, '6', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/06/v1-chapter-06.html" );'],
    [ 117, '7', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/07/v1-chapter-07.html" );'],
    [ 118, '8', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/08/v1-chapter-08.html" );'],
    [ 119, '9', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/09/v1-chapter-09.html" );'],
    [ 120, '10', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/10/v1-chapter-10.html" );'],
    [ 121, '11', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/11/v1-chapter-11.html" );'],
    [ 122, '12', 'Pro HTML chapter 1 companion page and listings.', 
            'MRmenus323.go_fe( "books/v1/1-chapters/12/v1-chapter-12.html" );'],
            
    [10101, 'L1', 'Pro HTML, Chapter 1, Listing 01',
            ''],
    [10102, 'L2', 'Pro HTML, Chapter 1, Listing 02',
            ''],
            
    [ 190, 'Appendices', 'Pro HTML Appendices', 
            'MRmenus323.go_fe( ' +
            '"books/v1/2-appendices/v1-appendix-a.html" );'],
    [ 191, 'Appendix&nbsp;A', 'Pro HTML Appendix A', 
            'MRmenus323.go_fe( ' +
            '"books/v1/2-appendices/v1-appendix-a.html" );'],
    [ 192, 'Appendix&nbsp;B', 'Pro HTML Appendix B', 
            'MRmenus323.go_fe( ' +
            '"books/v1/2-appendices/v1-appendix-b.html" );'],
    
    [ 198, 'About', '', '',],
            
    [ 200, '<i>Pro CSS</i>', 
            'CSS: Frontend Engineering series, Volume II of V.', 
            'MRmenus323.go_fe( "books/v2/books-v2.html" );'],
    [ 300, '<i>JS Basics</i>', 'JavaScript with Native Objects: ' +
            'Frontend Engineering series, Volume III of V.', 
            'MRmenus323.go_fe( "books/v3/books-v3.html" );'],
    [ 400, '<i>JS + DOM</i>', 'JavaScript with Host Objects: ' +
            'Frontend Engineering series, Volume IV of V.', 
            'MRmenus323.go_fe( "books/v4/books-v4.html" );'],
    [ 500, '<i>JS OOP</i>', 'JavaScript and User Objects: ' + 
            'Frontend Engineering series, Volume V of V.', 
            'MRmenus323.go_fe( "books/v5/books-v5.html" );'],            
            
    [1000, 'Artists', 'The track for designers and UI/UX specialists.',
            'MRmenus323.go_fe_a( "artists.html" );'],            
    [2000, 'Engineers', 'pages for frontend engineers.', 
            'MRmenus323.go_fe_e( "engineers.html" )'],
    [4000, 'Other Pages', 'pages, mostly unpublished, not all geek.', 
            'MRmenus323.go( "pages/pages.html" );'],
    [5000, 'Early&nbsp;Sites', 'Other sites by Martin Rinehart.', 
            'MRmenus323.go( "early-sites/early-sites.html" );'],
    [6000, 'Contact', 'Getting in touch by phone, email and regular mail.', 
            'MRlib323.fader.parent = document.getElementById( "nav" ); ' +
            'MRlib323.fader( "Start with email please. ' + 
            'MartinRinehart' + ' at gmail' + ' dot' + ' com." );'],
    

    [1010, 'Artists\' Home', 'Artists\' track home page.', 
            'MRmenus323.go_fe_a( "artists.html" );'],
    [1100, 'Effects', 'Artist\'s effects home page.', 
            'MRmenus323.go_fe_a( "effects/effects.html" );'],
    [1200, 'Gradients', 'Artist\'s gradients home page.', 
            'MRmenus323.go_fe_a( "gradients/gradients.html" );'],
    [1300, 'Morphs', 'Artist\'s morphs home page.', 
            'MRmenus323.go_fe_a( "morphs/morphs.html" );'],
            
    [1110, 'Fade Ins', 'Fading an element in over time (after optional delay).',
            'MRmenus323.go_fe_a( "effects/effects-fade-ins.html" );'],
    [1120, 'Fade Outs', 'Fading an element out over time (w/optional delay).',
            'MRmenus323.go_fe_a( "effects/effects-fade-outs.html" );'],
    [1130, 'Flashes', 'Flashing an element (NOT RECOMMENDED!).',
            'MRmenus323.go_fe_a( "effects/effects-flashes.html" );'],
    [1140, 'Glimmers', 'Showing a dream-like, teasing glimpse.',
            'MRmenus323.go_fe_a( "effects/effects-glimmers.html" );'],
    [1150, 'Hovers', 'Showing a more substantial tooltip alternative.',
            'MRmenus323.go_fe_a( "effects/effects-hovers.html" );'],
    [1160, 'Popups', 'Like a hover but with optional widgets.',
            'MRmenus323.go_fe_a( "effects/effects-popups.html" );'],
    [1170, 'Shakes', 'Grab attention in a crowded page.',
            'MRmenus323.go_fe_a( "effects/effects-shakes.html" );'],
    [1180, 'Swells', 'Like shakes, another attention-grabbing alternative.',
            'MRmenus323.go_fe_a( "effects/effects-swells.html" );'],
            
    [1210, 'Horizontal', 'Horizontal gradients wash from side-to-side.',
            'MRmenus323.go_fe( ' +
            '"artists/gradients/gradients-horizontal.html" );'],
    [1220, 'Horz. Opposed', 
            'Horizontal gradients wash side-to-center-to-side.',
            'MRmenus323.go_fe_a( "' +
            'gradients/gradients-horizontal-opposed.html" );'],
    [1230, 'Vertical', 'Vertical gradients wash top-to-bottom.',
            'MRmenus323.go_fe_a( "' + 
            'gradients/gradients-vertical.html" );'],
    [1240, 'Vert. Opposed', 'Vertical gradients wash top-to-center-to-bottom.',
            'MRmenus323.go_fe_a( "' + 
            'gradients/gradients-vertical-opposed.html" );'],
    [1250, 'Frame It!', 'Gradient frame, image framing tool.',
            'MRmenus323.go_fe_a( "gradients/frame-it-2.html" );'],

    [1310, 'Size Morphs', 'Swelling (and/or shrinking) DOM elements.', 
            'MRmenus323.go_fe_a( "morphs/morph-sizes.html" );'],
    [1320, 'Location Morphs', 'Moving DOM elements.', 
            'MRmenus323.go_fe_a( "morphs/morph-locations.html" );'],
    [1330, 'Color Morphs', 'Changing backgrounds and border colors.',
            'MRmenus323.go_fe_a( "morphs/morph-colors.html" );'],
    [1340, 'Border Morphs', 'Resizing (and/or reshape) borders.', 
            'MRmenus323.go_fe_a( "morphs/morph-borders.html" );'],
            
    [2010, 'Frontend Tools', 'Frontend engineers\' tools.', 
            'MRmenus323.go_fe_e( "tools/tools.html" );'],
    [2050, 'Frontend Team', 'Team of players who design the frontend.',
            'MRmenus323.go_fe( "team/team.html" );'],
    [2100, 'HTML', 'Engineers\' HTML-related pages.', 
            'MRmenus323.go_fe_e( "html/html.html" );'],
    [2200, 'CSS', 'Engineer\'s CSS-related pages.', ''],
    
    [2300, 'JavaScript', 'Engineers basic JavaScript pages.', 
            'MRmenus323.go_fe_e( "javascript/javascript.html" );'],
            
    [2400, 'DOM Scripting', 'Engineer\'s JavaScript host object pages.', ''],
    [2500, 'JS OOP', 'Engineer\'s object-oriented JavaScript pages.', ''],
    [2600, 'Regex', 'Engineer\'s regular expression pages.', 
            'MRmenus323.go_fe_e( "regex/regex.html" );'],
    
    [2041, 'JSODoc Doc', 'JavaScript Outlining Documentor (documentation).',
            'MRmenus323.go_fe_e( "tools/jsodoc-doc.html" );'],
    [2042, 'JSODoc', 'JavaScript Outlining Documentor (tool).', 
            'MRmenus323.go_fe_e( "tools/jsodoc.html" );'],
    [2043, 'Fluidulator&nbsp;Doc', 
            'Fluid frontend single-purpose calculator (documentation).',
            'MRmenus323.go_fe_e( "tools/fluid-calculator.html" );'], 
    [2044, 'Fluidulator', 'Fluid frontend single-purpose calculator (tool)', 
            'MRmenus323.go_fe_e( "tools/fluidulator.html" );'],
    [2045, 'HTML Fixup', 'Regex-based tool for multi-issue HTML fixups.',
            'MRmenus323.go_fe_e( "tools/html-fixup.html" );'],
            
    [2051, 'Fe E Defined', 'Frontend engineering is a team discipline.', 
            'MRmenus323.go_fe( "team/frontend-engineering-defined.html" );'],
    [2052, 'Fe Design', 'Frontend design is the artists calling.', 
            'MRmenus323.go_fe( "team/frontend-design.html" );'],
    [2053, 'Fe UI/UX', 'User interface / user experience is an expanding ' +
            'design discipline.', 
            'MRmenus323.go_fe( "team/frontend-uiux.html" );'],
    [2054, 'Fe SEO', 'Search engine optimization, so all the hard work gets ' +
            'found.', 
            'MRmenus323.go_fe( "team/frontend-seo.html" );'],
    [2055, 'Fe Programming', 
            'The job of the frontend engineer is programming.', 
            'MRmenus323.go_fe( "team/frontend-programming.html" );'],
    
    [2110, 'Tag History', 'History of W3C, WHATWG and earlier HTML tags.',
            'MRmenus323.go_fe_e( "html/html-tag-history.html" );'],
    [2120, 'Tag History2', 'Research charts, HTML, 1 thru 5, and XHTML tags.',
            'MRmenus323.go_fe_e( "html/html-tag-history2.html" );'],
    [2130, 'HTML 3.2 Numbered', 'Numbering system for HTML 3.2.',
            'MRmenus323.go_fe_e( "html/html-32.html" );'],
            
    [2310, 'Array Qref', 'Array methods quick reference table.', 
            'MRmenus323.go_fe( "books/v3/array-qref.html" );'], 
    [2315, 'Gradients', 'Painting gradients, live!', 
            'MRmenus323.go_fe_e( "javascript/gradients.html" );' ],
    [2320, '<code>undefined</code>', 'Defining JavaScript\'s undefined.', 
            'MRmenus323.go_fe_e( "javascript/undefined.html" );' ],
    [2330, 'XBrowser', 'Programming for all browsers (even MSIE 7).',
            'MRmenus323.go_fe_e( "javascript/xbrowser/xbrowser.html" );'],
    [2340, 'Sorts', 
            'Using functional programming for advanced JavaScript sorts.',
            'MRmenus323.go_fe_e( "javascript/sort-functions.html" );'],
    [2370, 'No&nbsp;Globals', 'Writing JavaScript without creating excess ' +
            'global variables (mostly).', 
            'MRmenus323.go_fe_e( "javascript/no-globals.html" );'],
    [2380, 'Style', 'Writing JavaScript with a top pro\'s style',
            'MRmenus323.go_fe_e( "javascript/simple-code.html" );'],
            
    [2610, 'Regex Intro', 
            'Introduction to regular expressions in JavaScript and Ruby.', 
            'MRmenus323.go_fe_e( "regex/tutorial-re.html" );'],
    [2620, 'Readex', 'Making regular expressions readable (self-documenting).',
            'MRmenus323.go_fe_e( "regex/readex.html" );'],
                        
/*    
    
    [3130, 'Appendices&nbsp;v1', 'Pro HTML appendices.', 
            'MRmenus323.go_fe( "books/v1/appendices-v1.html" );'],
    [3140, 'Back&nbsp;v1', 'Pro HTML back matter.', 
            'MRmenus323.go_fe( "books/v1/back-v1.html" );'], */
    
    [4010, 'Disinflation', 
            'Optimal purchasing under technological disinflation', 
            'MRmenus323.go( "pages/disinflation.html" );'], // Pages
    [4020, 'Genealogy', 
            'Brief genealogy of programming languages.', 'MRmenus323.go( ' +
            '"pages/genealogy-programming-languages.html" );'],
    [4030, 'FreeMind', 'Beginner\'s guide to FreeMind, in a .DOC file.',
            'MRmenus323.go( "pages/beginners-freemind.doc" );'],
    [4040, 'RDBMS Design', 
            'A design method, proven to produce 5th-normal form designs.',
            'MRmenus323.go( "pages/db-design.html" );'],
    
    [5010, 'Java++', 'Early Java (and other software) website.', 
            'MRmenus323.go( "early-sites/mrwebsite_old/index.html" );'], 
            // Earlier website
    [5020, 'Cloud', 'Cloud computing in political website.', 
            'MRmenus323.go( "early-sites/cloud/index.html" );'], // chart site
    [5030, 'RaqFit', 'Racquet sports and health club website.', 
            'MRmenus323.go( "early-sites/racquetfitness/index.html" );']

];

// alert( 'MenuItems OK' );

    /**A Menu Tables */

/** */
MRmenus323.MenusTable = new MRlib323.Table( 'Menus_Table', 
        MRmenus323.MenusTableColumns, MRmenus323.MenusTableData );

/** */;        
MRmenus323.MenuItemsTable = new MRlib323.Table( 'MenuItems_Table',
        MRmenus323.MenuItemsColumns, MRmenus323.MenuItemsData );
        
/** */        
MRmenus323.ItemsInMenusTable = new MRlib323.Table( 'Items_In_Menus_Table',
        MRmenus323.ItemsInMenusColumns, MRmenus323.ItemsInMenusData );
        
    /**A Menu Getters */

/** */
MRmenus323.get_data = function ( menu_id ) {

/* alert( '499: ' + MRmenus323.ItemsInMenusTable.where('MenuID = ' + menu_id).
        join(MRmenus323.MenuItemsTable, 'MenuItemID') ); */
        
    var data = MRmenus323.ItemsInMenusTable.
            where( 'MenuID = ' + menu_id ).
            join( MRmenus323.MenuItemsTable, 'MenuItemID' ).
            select( 'MenuItems_Table.Prompt', 'MenuItems_Table.Title',
                    'MenuItems_Table.ClickFunc' ).
            data;  
            
    return data;
    
} // end: get_data()

/** */
MRmenus323.get_table = function ( menu_id ) {

    var table = MRmenus323.ItemsInMenusTable.
            where( 'MenuID = ' + menu_id ).
            join( MRmenus323.MenuItemsTable, 'MenuItemID' ).
            select( 'MenuItems_Table.Prompt', 'MenuItems_Table.Title',
                    'MenuItems_Table.ClickFunc' );  
            
    return table;
    
} // end: get_table()

/** Get 'x.html' from 'MR...go( "x.html" );'. */
MRmenus323.get_link = function ( str ) {

    var pn = ''; // pathname (may omit prefix)
    
    // a quote (") followed by (anything - $1) then another quote
    if ( str.match(  /\"(.*)\"/  ) ) { 
        pn = RegExp.$1; 
    } else { return ''; }
    
    if ( str.indexOf('go_fe_a') > -1 ) 
            { return '/frontend-engineering/artists/' + pn; }
    if ( str.indexOf('go_fe_e') > -1 ) 
            { return '/frontend-engineering/engineers/' + pn; }
    if ( str.indexOf('go_fe') > -1 ) 
            { return '/frontend-engineering/' + pn; }
            
            
    return pn; // may be path w/o prefix, or empty string
    
}

/**I Book Page Turners */

    /**A Page Turner Styles */

/** */    
MRmenus323.turner_styles = {
    background:     '#f0f0ff',
    border:         '5px solid #a0a0ff',
    borderRadius:   '20px',
    bottom:         '20px',
    fontSize:       '18pt',
    fontWeight:     'bold',
    height:         '50px',
    opacity:        0.5,
    paddingTop:     '20px',
    position:       'fixed',
    textAlign:      'center',
    width:          '80px'
};

/** */
MRmenus323.turner_prev_styles = [
    MRmenus323.turner_styles,
    {
        left:       '20px'
    }
];

/** */
MRmenus323.turner_next_styles = [
    MRmenus323.turner_styles,
    {
        right:      '20px'
    }
];

/**A Page Turners */
    
    /** Builder */
MRmenus323.page_turners = function ( page_prev, page_next, flavor ) { 

    if ( flavor && (flavor === 'v1') ) {
        MRmenus323.turner_styles.backgroundColor = '#d0e0d8';
        MRmenus323.turner_styles.borderColor = '#00ffff';
    }

    var prev_ref, next_ref;
    
    if ( (page_prev !== undefined) && (page_prev !== '') ) {
        prev_ref = MRlib323.create_attached_element( document.body, 'div',
                'prev_div', MRmenus323.turner_prev_styles, 
                {innerHTML: 'PREV'} );
            prev_ref.onmouseover = function () {
                this.style.backgroundColor = MRmenus323.COLOR_hover;
                this.style.cursor = 'pointer';
            }
            prev_ref.onclick = function () { MRmenus323.go( page_prev ); }
            prev_ref.onmouseout = function () {
                this.style.backgroundColor = 
                        MRmenus323.turner_styles.backgroundColor;
                this.style.cursor = 'default';
            }
    }
    
    if ( (page_next !== undefined) && (page_next !== '') ) {

        next_ref = MRlib323.create_attached_element( document.body, 'div',
                'next_div', MRmenus323.turner_next_styles, 
                {innerHTML: 'NEXT'} );
            next_ref.onmouseover = function () {
                this.style.backgroundColor = MRmenus323.COLOR_hover;
                this.style.cursor = 'pointer';
            }
            next_ref.onclick = function () { MRmenus323.go( page_next ); }
            next_ref.onmouseout = function () {
                this.style.backgroundColor = 
                        MRmenus323.turner_styles.backgroundColor;
                this.style.cursor = 'default';
            }
    }
    
} // end: page_turners()    
    

// alert( 'loaded support/js/mr-menus.js' );

/* end of support/js/mr-menus323.js */
