var JS_PRC = "C:\\dh\\web\\PRC\\1\\HTM\\prc.js (2534 lines) 2010-03-09 00:44 Rachel Bartlett";
/**********************************************************************/
/*                                                                    */
/*                            P R C . J S                             */
/*                            -----------                             */
/*                                                                    */
/* This is the standard Javascript library for the Paul Rosenfels     */
/* Community website (rosenfels.org), which uses HML, an HTML Macro   */
/* Language implemented in Perl. Many of these functions implement    */
/* HML "macros".                                                      */
/*                                                                    */
/* A macro like <<dialog>>, for example, will be compiled by HML      */
/* into a call to prc_dialog(). Other compilation patterns include    */
/*                                                                    */
/*   <<dialog, 'parm'>>    <script>prc_dialog('parm');</script>       */
/*   <</dialog>>           <script>prc_dialog_end();</script>         */
/*                                                                    */
/* See hml.pl for more information.                                   */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*                                                                    */
/* The following sequences of macros generate tables:                 */
/*                                                                    */
/*         <<dialog>> -> <<speech>> -> <</dialog>>                    */
/*      <<footnotes>> -> <<fnote>>  -> <</footnotes>>                 */
/*           <<menu>> -> <<choice>> -> <</menu>>                      */
/*                                                                    */
/* Normally the <<speech>> macro would be mirrored by a <</speech>>   */
/* macro. Instead I let the <<speech>> macro set a global flag named  */
/* prc_in_a_speech to true. All <<speech>> and <</dialog>> macros     */
/* first issue <</speech>>. If this flag is off, it simply exits,     */
/* but if it is on, appropriate code is generated and the flag reset. */
/*                                                                    */
/* Equivalent logic eliminates the need for an explicit <</fnote>     */
/* macro.                                                             */
/*                                                                    */
/* There is no <</choice>> macro, because everything must be          */
/* specified in the <<choice>> macro. Only the page name is required, */
/* however, and possibly the anchor. These are used to search the     */
/* pagetree array to find default values for the other parameters.    */
/*                                                                    */
/* Currently, <<dialog>> is implemented as a <<floating_table>>.      */
/* Rows in such tables appear as islands of pastel colors.            */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*                                                                    */
/* Most of these functions write to the document using                */
/* document.write(), but some return the content to be written and    */
/* leave it to the calling function to do the document.write().       */
/* Names of the latter type are usually suffixed with _code.          */
/* See, for example, prc_staff_code(). Since this is where the real   */
/* work is done, prc_staff() trivially degenerates to something like  */
/*                                                                    */
/*     function prc_staff(...)                                        */
/*     {                                                              */
/*         document.write(prc_staff_code(...));                       */
/*     }                                                              */
/*                                                                    */
/*--------------------------------------------------------------------*/
/*  This was library designed and written by Rachel Bartlett in 2008  */
/**********************************************************************/
x_log("\nJS_PRC: '" + JS_PRC + "'");
if (x_is_empty(JS_PLX))
{
    alert("Please load 'plx.js' before 'prc.js'.");
}
x_log("\nplx_javascript_version: '" + plx_javascript_version + "'");

/*--------------------------------------------------------------------*/
/*                          Global Constants                          */
/*--------------------------------------------------------------------*/
// Has prc_menu_type been set?
if (x_is_empty(prc_menu_type))
{
    var prc_menu_type = 'DH';
x_log("\nWARNING: The prc_menu_type variable has not been set by "
+ "the HML compiler and will default to '" + prc_menu_type + "'.");
}

// Are we running in production mode on the server or on Rachel's test workstation?
var prc_mode = new String("PROD");
if (location.protocol == "file:") prc_mode = "TEST";
x_log("\nprc_mode: '" + prc_mode + "'");

// Offsets into the page descriptors:
var DEPTH   = 0;                      // depth within the page hierarchy
var NODE    = 1;           // outline number (generated algorithmically)
var PUBDATE = 2;                                     // publication date
var PAGE    = 3;                                             // filename
var ANCHOR  = 4;                                      // optional anchor
var TITLE   = 5;                                                // title
var COMMENT = 6;                                              // comment
var PARMS   = 7;                                                // parms
var DESCLEN = 8;             // (variables in each each page descriptor)

// Foreground color:
var PRC_FG_MAROON     = '800000';                       // 'dark maroon'
var PRC_FG_DARK_GRAY  = '444444';                           // dark gray
var PRC_FG_GRAY       = '999999';                                // gray

// Background colors:
var PRC_BG_WHEAT      = 'F5DEB3';                             // 'wheat'
var PRC_BG_WHITE      = 'FFFFFF';                               // white
var PRC_BG_GRAY       = '888888';                                // gray
var PRC_BG_LIGHT_GRAY = 'EEEEEE';                          // light gray

// Border colors:
var PRC_BD_BLACK      = '000000';                               // black

// Cycling background colors:
var PRC_BG_MINT_GREEN = 'CCFFCC';                          // mint-green
var PRC_BG_WINE       = 'DFD5D6';                        // wine-colored
var PRC_BG_GOLD       = 'FFEEAA';                       // creamy-orange
var PRC_BG_HOT_PINK   = 'FFDDDD';                            // hot-pink

// var PRC_BG_WHEAT      = x_rgb(245, 222, 179);              // 'wheat'
// var PRC_BG_HOT_PINK   = x_rgb(255, 221, 221);             // hot-pink
// var PRC_BG_MINT_GREEN = x_rgb(204, 255, 204);           // mint-green
// var PRC_BG_WINE       = x_rgb(223, 213, 214);         // wine-colored

var PRC_WEBSITE  = new String("The Paul Rosenfels Community");
var PRC_DOMAIN   = new String("rosenfels.org");
var PRC_HOSTNAME = new String("www." + PRC_DOMAIN);
var PRC_HOMEPAGE = new String("http://" + PRC_HOSTNAME);
var PRC_DFLT_EXT = new String(".htm");
var PRC_SLASH    = new String("/");

var PRC_YAHOO_GROUP_URL = new String
(
    "http://groups.yahoo.com/group/paul-rosenfels/"
);

/*--------------------------------------------------------------------*/
/*                Make sure we're in the right domain                 */
/*                                                                    */
/*      Here's an example of a 'wrong' domain:                        */
/*                                                                    */
/*        location.protocol = 'http:';                                */
/*        location.hostname = 'www.ninthstreetcenter.org';            */
/*        location.pathname = '/Rants.htm';                           */
/*        location.search   = '?timeline=wraparound';                 */
/*                                                                    */
/*--------------------------------------------------------------------*/
// alert("location.protocol: \"" + location.protocol + "\""
//   + "\nlocation.hostname: \"" + location.hostname + "\""
//   + "\nlocation.pathname: \"" + location.pathname + "\""
//   + "\n  location.search: \"" +   location.search + "\"");
if (location.protocol == 'http:'
&&  location.hostname != PRC_HOSTNAME)
{
    normalize_hostname();
}

/*--------------------------------------------------------------------*/
/*                          Global Variables                          */
/*--------------------------------------------------------------------*/
// Attributes of current page:
var prc_ptx     = -1;                                  // pagetree index
var prc_depth   = -1;
var prc_node    = new String();
var prc_pubdate = new String();
var prc_page    = new String();
var prc_anchor  = new String();
var prc_title   = new String();
var prc_comment = new String();
var prc_parms   = new String();

// Flags extracted from 'prc_parms' in pagetree.js:
var prc_age_flag      = new String();        // '-new', '-updated', etc.
var prc_hidden_flag   = new String();                       // '-hidden'
var prc_language_flag = new String();      // '-german', '-french', etc.

var prc_num_children = 0;            // does current page have children?

var prc_cycling_bgcolors =
[
    PRC_BG_MINT_GREEN, PRC_BG_GOLD, PRC_BG_WINE
];
var prc_cycling_bgcolor_index = 0;            // next color index to use
var prc_cycling_bgcolor_dimen =       // normally cycle through 3 colors
    prc_cycling_bgcolors.length;
x_log("\nprc_cycling_bgcolor_dimen: '" + prc_cycling_bgcolor_dimen + "'");
var prc_debug_setting         = 0;
var prc_resources_used        = new Array();
var prc_table_depth           = 0;
var prc_timeline              = [-1, -1, -1, -1, -1];

var prc_menu_title   = new String();
var prc_menu_choices = new String();

/*--------------------------------------------------------------------*/
/*                          Context trackers                          */
/*--------------------------------------------------------------------*/
var prc_in_an_fnote   = false;
var prc_in_a_speech   = false;
var prc_speech_column = 0;

/*--------------------------------------------------------------------*/
/*                 Get parameters from the url string                 */
/*--------------------------------------------------------------------*/
x_get_url_parms();
if (plx_url_parms.hasOwnProperty("debug"))
{
    prc_debug_setting = plx_url_parms["debug"];
}

/*--------------------------------------------------------------------*/
/*             Override default values declared in plx.js             */
/*--------------------------------------------------------------------*/
x_snapshot_img_dir('pix');                           // see x_snapshot()
x_snapshot_frame_caption_style
(
      "font-size: 13; "
    + "font-weight: bold; "
    + "color: #" + PRC_BG_WHITE + "; "
    + "background-color: #" + PRC_BG_GRAY + ";"
);
x_hover_style
(
      "font-size: 12; "
    + "color: #" + PRC_FG_MAROON + "; "
    + "background-color: #" + PRC_BG_LIGHT_GRAY + "; "
    + "border: #" + PRC_BG_WHITE + " 4px solid;"
);
// x_hover_width(500);

/**********************************************************************/
/*                                                                    */
/*                E X T E R N A L   F U N C T I O N S                 */
/*                                                                    */
/**********************************************************************/
/*--------------------------------------------------------------------*/
/*                        One-line HML macros                         */
/*--------------------------------------------------------------------*/
function prc_b()      {document.write("<b>");     }
function prc_b_end()  {document.write("</b>");    }
function prc_bi()     {document.write("<b><i>");  }
function prc_bi_end() {document.write("</i></b>");}
function prc_i()      {document.write("<i>");     }
function prc_i_end()  {document.write("</i>");    }
function prc_u()      {document.write("<u>");     }
function prc_u_end()  {document.write("</u>");    }

function prc_PAC()  {prc_pub('-book', 1962, 'PAC' , "Psychoanalysis and Civilization")}
function prc_LAP()  {prc_pub('-book', 1966, 'LAP' , "Love and Power", "The Psychology of Interpersonal Creativity")}
function prc_HPCP() {prc_pub('-book', 1971, 'HPCP', "Homosexuality: The Psychology of the Creative Process", "")}
function prc_WKP()  {prc_pub('-book', 1991, 'WKP' , "We Knew Paul", "Conversations with Friends and Students of Paul Rosenfels")}

function prc_SUBJECTIVITY() {prc_pub('-mono', 1974, 'SUBJECTIVITY', "Subjectivity and Objectivity", "Further Aspects of Psychological Growth")}
function prc_FUN()          {prc_pub('-mono', 1975, 'FUN'         , "The Relationship of Adaptation and Fun and Pleasure to Psychological Growth")}
function prc_EXHAUSTION()   {prc_pub('-mono', 1976, 'EXHAUSTION'  , "Psychic Exhaustion and the Growth Process")}
function prc_NATURE()       {prc_pub('-mono', 1977, 'NATURE'      , "The Nature of Civilization", "A Psychological Analysis")}
function prc_MATURITY()     {prc_pub('-mono', 1978, 'MATURITY'    , "The Nature of Psychological Maturity")}
function prc_RENEGADE()     {prc_pub('-mono', 1979, 'RENEGADE'    , "A Renegade Psychiatrist's Story", "An Introduction to the Science of Human Nature")}
function prc_FREUD()        {prc_pub('-mono', 1980, 'FREUD'       , "Freud and the Scientific Method")}
function prc_LETTERS()      {prc_pub('-mono', 1981, 'LETTERS'     , "Letters to Dean")}
function prc_HANDBOOK()     {prc_pub('-mono', 1987, 'HANDBOOK'    , "A Ninth Street Center Handbook")}
function prc_WOMAN()        {prc_pub('-mono', 2006, 'WOMAN'       , "Letters to a Young Woman")}

function prc_pub(a_type, a_year, a_abbreviation, a_title, a_subtitle)
{
    var call = new String("prc_pub('" + a_type + "', " + a_year + ", '"
        + a_abbreviation + "', \"" + a_title + "\", \"" + a_subtitle + "\");");
x_log("\n" + call);

    var prefix = new String("<a href='" + a_abbreviation + ".htm'>");
    var suffix = new String("</a>");
    var result = new String("");
    var errmsg = new String();
    if (a_type == '-book')
    {
       result = "<b><i>" + a_title;
//        if (x_isnt_empty(a_subtitle)) result += ": " + a_subtitle;
       result += "</i></b>";
    }
    else if (a_type == '-mono')
    {
       result = "<b>" + a_title;
//        if (x_isnt_empty(a_subtitle)) result += ": " + a_subtitle;
       result += "</b>";
    }
    else
    {
        errmsg = "Invalid type, '" + a_type + "', in " + call;
        result = errmsg;
    }
    result = prefix + result + suffix;
x_log("\n => '" + result + "'.");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                       plx function wrappers                        */
/*--------------------------------------------------------------------*/
function      prc_dots(a_count)
{document.write(x_dots(a_count))}
function      prc_dropcap(a_letter)
{document.write(x_dropcap(a_letter))}
function      prc_hover_hint(a_text_html, a_hint_html, a_left, a_top)
{document.write(x_hover_hint(a_text_html, a_hint_html, a_left, a_top))}
function      prc_hover_link(a_text_html, a_link_html, a_hint_html)
{document.write(x_hover_link(a_text_html, a_link_html, a_hint_html))}
function      prc_snapshot(a_filespec, a_resize, a_parms, a_caption)
{document.write(x_snapshot(a_filespec, a_resize, a_parms, a_caption))}

/*--------------------------------------------------------------------*/
/*                       prc function wrappers                        */
/*--------------------------------------------------------------------*/
function prc_h1(a_title) {document.write(prc_h_code(1, a_title));}
function prc_h2(a_title) {document.write(prc_h_code(2, a_title));}
function prc_h3(a_title) {document.write(prc_h_code(3, a_title));}
function prc_h4(a_title) {document.write(prc_h_code(4, a_title));}
function prc_h5(a_title) {document.write(prc_h_code(5, a_title));}
function prc_h6(a_title) {document.write(prc_h_code(6, a_title));}

function        prc_analog     (a_analog, a_flags)
{document.write(prc_analog_code(a_analog, a_flags))}
// function        prc_choice     (a_page, a_anchor, a_title, a_comment, a_parms)
// {document.write(prc_choice_code(a_page, a_anchor, a_title, a_comment, a_parms))}
function        prc_email_link     ()
{document.write(prc_email_link_code())}
function        prc_floating_row     ()
{document.write(prc_floating_row_code())}
function        prc_floating_row_end     ()
{document.write(prc_floating_row_end_code())}
function        prc_link     (a_page, a_anchor, a_title)
{document.write(prc_link_code(a_page, a_anchor, a_title))}
function        prc_staff     (a_person, a_service, a_resize, a_parms, a_caption)
{document.write(prc_staff_code(a_person, a_service, a_resize, a_parms, a_caption))}

/*--------------------------------------------------------------------*/
/*                    prc_all_collages() function                     */
/*--------------------------------------------------------------------*/
function prc_all_collages()
{
x_log("\nprc_all_collages();");
    prc_floating_table("border=00");
    var px, vpx;              // picture index and visible picture index
    for (px = 0, vpx = 0; px < piclist.length; px++, vpx++)
    {
        if (piclist[px].substr(0, 3) != 'rb_'
        ||  piclist[px] == 'rb_2009_call_for_essays_480x367.png')
        {
            vpx--;
            continue;
        }
        var year = piclist[px].substr(3, 4);
        var column = 1 + (vpx %2);
x_log("\ncolumn " + column + ": '" + piclist[px] + "'");
        if (column == 1) prc_floating_row();
        document.write("\n<td>");
        prc_snapshot(piclist[px], '38%', '', '[&copy; ' + year + ' Rachel Bartlett]');
        document.write("\n</td>");
        if (column == 2) prc_floating_row_end();
    }
    if (column == 1) prc_floating_row_end();
    prc_floating_table_end();
}

/*--------------------------------------------------------------------*/
/*                     prc_analog_code() function                     */
/*--------------------------------------------------------------------*/
function prc_analog_code(a_analog, a_flags)
{
x_log("\nprc_analog_code('" + a_analog + "', '" + a_flags + "');");
    var PRC_FG_RED           = 'FF0000';
    var PRC_FG_BLUE          = '0000FF';
    var PRC_BG_PINK          = 'FFCCCC';
    var PRC_BG_EGGSHELL_BLUE = 'CCCCFF';
    var result = '';
    var errmsg = '';
    var color = '#' + PRC_FG_MAROON, bgcolor = '#' + PRC_BG_WHEAT;
    if (a_flags == '-f')                                     // feminine
    {
        color   = PRC_FG_RED;
        bgcolor = PRC_BG_PINK;
    }
    else if (a_flags == '-m')                               // masculine
    {
        color   = PRC_FG_BLUE;
        bgcolor = PRC_BG_EGGSHELL_BLUE;
    }
    else
    {
        errmsg = new String("Invalid flag, '" + a_flags + "' in prc_analog(\""
            + a_analog + "\", '" + a_flags + "').");;
x_log("\n => " + errmsg);
        return errmsg;
    }
    result = new String("<span style='"
        + "color: #" + color + "; "
        + "background-color: #" + bgcolor + "; "
        + "'>&nbsp;" + a_analog + "&nbsp;</span>");
x_log("\n => " + result);
    return result;
}

/*--------------------------------------------------------------------*/
/*                       prc_analogs() function                       */
/*--------------------------------------------------------------------*/
function prc_analogs(a_feminine, a_masculine)
{
x_log("\nprc_analogs('" + a_feminine + "', '" + a_masculine + "')");
    var result = prc_floating_row_code()
        + "<td align=right>"     + a_feminine  + "</td>"
        + "<td align=left>"      + a_masculine + "</td>"
        + prc_floating_row_end_code();
x_log(" => '" + result + "'");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                        prc_body() function                         */
/*--------------------------------------------------------------------*/
function prc_body()
{
    var result = new String();
x_log("\nP R C _ B O D Y ( ) -----------------------------------------------------");
x_log("\npagetree.length: '" + pagetree.length + "'");
    prc_page   = x_page();
    prc_anchor = x_anchor();
x_log("\nprc_page: '"   + prc_page   + "'");
x_log("\nprc_anchor: '" + prc_anchor + "'");

    var period = prc_page.lastIndexOf(".");
    if (period > -1)
    {
x_log("\nperiod: '" + period + "'");
        prc_page = prc_page.substr(0, period);
x_log("\nprc_page: '"   + prc_page   + "'");
    }

    prc_ptx = prc_index(prc_page, prc_anchor);
// Not every anchor has to be in the pagetree. If it's
// not there, trying looking up just the page name alone.
    if (prc_ptx == -1 && prc_anchor != '')
    {
        prc_ptx = prc_index(prc_page, '');
    }
// If a page isn't in the pagetree, just default to the home page.
    if (prc_ptx == -1)
    {
        prc_ptx = 0; // Switch to home page
    }
    prc_depth   = pagetree[prc_ptx + DEPTH   ];
    prc_node    = pagetree[prc_ptx + NODE    ];
    prc_pubdate = pagetree[prc_ptx + PUBDATE ];
    prc_page    = pagetree[prc_ptx + PAGE    ]; // in case of spelling error
    prc_anchor  = pagetree[prc_ptx + ANCHOR  ];
    prc_title   = pagetree[prc_ptx + TITLE   ];
    prc_comment = pagetree[prc_ptx + COMMENT ];
    prc_parms   = pagetree[prc_ptx + PARMS   ];

x_log("\n   prc_depth: '"  + prc_depth    + "'");
x_log("\n    prc_node: '"  + prc_node     + "'");
x_log("\n prc_pubdate: '"  + prc_pubdate  + "'");
x_log("\n    prc_page: '"  + prc_page     + "'");
x_log("\n  prc_anchor: '"  + prc_anchor   + "'");
x_log("\n   prc_title: \"" + prc_title    + "\"");
x_log("\n prc_comment: \"" + prc_comment  + "\"");
x_log("\n   prc_parms: \"" + prc_parms    + "\"");

    prc_age_flag      = x_get_parm(prc_parms, ['-new', '-updated']);
    prc_hidden_flag   = x_get_parm(prc_parms, ['-hidden']);
    prc_language_flag = x_get_parm(prc_parms, ['-german', '-french', '-spanish']);

x_log("\n     prc_age_flag: \"" + prc_age_flag      + "\"");
x_log("\n  prc_hidden_flag: \"" + prc_hidden_flag   + "\"");
x_log("\nprc_language_flag: \"" + prc_language_flag + "\"");

    prc_num_children = prc_number_of_children();

    prc_derive_timeline                           // derive prc_timeline
    (
        prc_page,
        prc_anchor
    );

/*--------------------------------------------------------------------*/
/*                             Home Page                              */
/*--------------------------------------------------------------------*/
    if (prc_page == 'index' && prc_anchor == '')
    {
        result += "\n<table border=00 width='100%' "
            + "cellpadding=6 cellspacing=0><tr>"

// Use height in pixel ('x125') for resize parm because
// document.body.clientHeight doesn't exist at this point:
            + "\n<td width=250 bgcolor=#" + PRC_BG_WHEAT + ">"
            + prc_staff_code('paul', '-picture', 'x125', '-center -nocaption')
            + "</td>"

//             + "\n<td></td>"

            + "\n<td align=center valign=middle bgcolor=#" + PRC_BG_WHEAT + ">"
            + "<h1 style='margin: 0;'>" + PRC_WEBSITE + "</h1>"
            + "\n<p style='margin-top: 24; text-align: center;'><i>"
            + "Social progress through personal growth</i></p></td>"

            + "</tr></table>";
// alert(result);
    }

/*--------------------------------------------------------------------*/
/*                           NOT Home Page                            */
/*--------------------------------------------------------------------*/
    else
    {
        result += "\n<table border=00 width='100%' "
            + "cellpadding=6 cellspacing=0><tr>"

            + "\n<td bgcolor=#" + PRC_BG_WHEAT + ">"
            + "<span onclick='location = index.htm;'>"
            + "<h2 style='text-align: left; margin: 0;'>"
            + PRC_WEBSITE + "</h2></span>";

        result += "\n<p class='timeline'>";
        if (prc_menu_type == 'DH')
        {
            result += "<a href='index.htm'><b>HOME</b></a>";
        }

x_log("\nplx_url_parms[\"timeline\"]: " + plx_url_parms["timeline"] + ".");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*            Unless the page is hidden, show its timeline            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
        if (prc_hidden_flag == '')
        {
            var timeline_type = new String();
            if (plx_url_parms.hasOwnProperty("timeline"))
            {
                timeline_type = plx_url_parms["timeline"];
            }
            var tlx;
            var arrow = "&minus;>";
            var tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
            var indent = tab;
            for (tlx = 1; tlx < prc_depth; tlx++)
            {
                if (timeline_type == 'wraparound')
                {
                    result += "\n&nbsp;" + arrow + "&nbsp;";
                }
                else // if (timeline_type == 'staircase')
                {
                    result += "\n<br>" + indent;
                }
                var depth    = pagetree[prc_timeline[tlx] + DEPTH   ];
                var pubdate  = pagetree[prc_timeline[tlx] + PUBDATE ];
                var page     = pagetree[prc_timeline[tlx] + PAGE    ];
                var anchor   = pagetree[prc_timeline[tlx] + ANCHOR  ];
                var title    = pagetree[prc_timeline[tlx] + TITLE   ];
x_log("\n[" + prc_timeline[tlx] + "] " + depth + " '" + pubdate + "' '" + page + anchor + "' \"" + title + "\"");

// Don't need breaks in the timeline:
                title = title.replace(/ /g, "&nbsp;");
                title = title.replace(/<br>/gi, "&nbsp;");
// Soften breaks in title:
//                 title = x_soften_breaks(title);

                result += "<a href='" + page
                    + PRC_DFLT_EXT + anchor + "'><b>" + title;
//                 if (prc_mode == "TEST")
//                 {
//                     result += " (" + page + anchor + ")";
//                 }
                result += "</b></a>";
                indent += tab;
            }
        }
        result += "</p>";
        result += "</td>";

// Use absolute client width and height because
// document.body.clientWidth doesn't exist yet:
        result += "\n<td align=center bgcolor=#" + PRC_BG_WHEAT + ">"
            + "<img src='pix/" + prc_random_paul_thumbnail()
            + "' width=100 height=100></td></tr></table>";
    }
x_log(result);
x_log("\n----------------------------------------------------- P R C _ B O D Y ( )");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                      prc_body_end() function                       */
/*--------------------------------------------------------------------*/
function prc_body_end()
{
x_log("\nP R C _ B O D Y _ E N D ( ) ---------------------------------------------");
    var result = new String();
    result += "\n<div style='text-align: center; margin-top: 16;'>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                     Language and Sibing Menus                      */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (prc_language_flag) prc_language_menu();
    if (prc_menu_type == 'DH') prc_sibling_menu();

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                            Search Form                             */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "<form name='prc_search_form' "
        + "action='javascript:prc_search();'>"
        + "<input name='prc_search_input' type='text' size=64>"
        + "&nbsp;&nbsp;<input type='submit' value='Search'>"
        + "</form>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                         Table of Contents                          */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (prc_menu_type == 'DH') result += "\n" + prc_table_of_contents();

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                            Bottom Panel                            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n<table border=00 bgcolor=#" + PRC_BG_WHEAT + " "
        + "width='100%' cellspacing=0 cellpadding=0 "
        + "style='border-width: 0px; border-color: black;'>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                             First row                              */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n<tr>\n<td colspan=9 style='padding-bottom: 4;'>"
        + "<h6 style='font-size: 16; text-align: center;'>"
        + "\n<a href='index.htm'>"
        + "<b>" + PRC_WEBSITE + "</b></a> Website"
        + "\n<big>&copy;</big> 1997-" + x_yyyy() + " Dean Hannotte"
        + "\n</td></tr>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                      Second row, first column                      */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

    result += "\n<tr><td valign=top style='padding-left: 16;'><h6>"

      + "Formerly <a href='nsc/index.htm'>"
        + "<b>The Ninth Street Center, Inc.</b></a>"

        + "\n<br>All content by " + prc_staff_code('dean')
        + " except where otherwise indicated"

        + "\n<br>Web design and programming by " + prc_staff_code('rachel')

//         + "\n<br>Keep up to date by subscribing to "
//         + "our <a href='rss.xml'><b>RSS feed</b></a> "
//         + "<a href='rss.xml'><img border=0 width=16 height=16 "
//         + "src='pix/rss_icon_16x16.png'></a>"

        + "\n<br>Write to us at " + prc_email_link_code();

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                           Second column                            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n</h6>"
        + "</td><td valign=top align=right style='padding-right: 16;'>"
        + "\n<h6>Join the " + prc_link_code(PRC_YAHOO_GROUP_URL,
          "", "<b>Paul Rosenfels Yahoo Group</b>");

    var mod_date = new String();
x_log("\ndocument.lastModified: '" + document.lastModified + "'");
    if (x_isnt_empty(document.lastModified))
    {
        mod_date = document.lastModified;
        mod_date = mod_date.substr(6, 4)
                 + mod_date.substr(0, 2)
                 + mod_date.substr(3, 2);
    }
    result += "\n<br>This page was published on " + x_format_yyyymmdd(prc_pubdate)
        + "\n<br>and last modified on " + x_format_yyyymmdd(mod_date);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                         Menu System Credit                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (prc_menu_type == 'UDM4')
    {
        result += "\n<br><a href=\"http://www.udm4.com\"><b>UDM4</b></a>"
            + " menu system by <a href=\"http://brothercake.com\">"
            + "<b>BrotherCake</b>&nbsp;"
            + "<img src='udm-resources/favicon.gif' border=0></a>";
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                         Statistics Credit                          */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n<br>Statistics by: <!-- Site Meter -->"
        + "<script type='text/javascript' "
        + "src='http://s13.sitemeter.com/js/counter.js?"
        + "site=s13rosenfels'>"
        + "</script>"
        + "<noscript>"
        + "<a href='http://s13.sitemeter.com/stats.asp?"
        + "site=s13rosenfels' target='_top'>"
        + "<img src='http://s13.sitemeter.com/meter.asp?"
        + "site=s13rosenfels' "
        + "alt='Site Meter' border=0></a>"
        + "</noscript>"
        + "<!-- Copyright (c)2009 Site Meter -->";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                           AddThis Button                           */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//     result += '\n<br><!-- AddThis Button BEGIN -->'
//         + '<a href="http://www.addthis.com/bookmark.php?v=250" '
//         + 'onmouseover="return addthis_open(this, "", "[URL]", "[TITLE]")" onmouseout="addthis_close()" onclick="return addthis_sendto()">'
//         + '<img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/>'
//         + '</a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=dhannotte"></script>'
//         + '<!-- AddThis Button END -->';

    result += "</h6></td></tr>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                             Third Row                              */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n<tr><td colspan=9><span onClick='x_peek();'>"
        + "<h6 style='text-align: center; margin-left: 32; margin-right:32;'>"

        + "\nIn links, <img src='pix/link_is_external_13x15.gif'> "
        + "means that page is external to this site."

        + "\nIn menus, <img src='pix/bullet_green_14x13.gif'> "
        + "means the link is active, "
        + "<img src='pix/bullet_yellow_14x13.gif'>means you're "

        + "\nalready on that page, and <img src='pix/bullet_red_14x13.gif'> "
        + "means that page is under construction. "

//         + "\n<br>Pages in non-English languages "
//         + "will have a yellow background."

        + "\nIf the frame thickens when you mouse over a "
        + "picture, you can enlarge it with a single click. "

        + "\n<br><b><i>Truth is a work in progress. "
        + "We like our diamonds rough.</i></b>"

//         + "\n<br>Don't expect any polished gems on this site."

        + "</h6></span></td></tr>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                           PayPal Button                            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                            Flag Counter                            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "<tr><td align=center colspan=9><h6>"
//         + "<big><b>We have been viewed in the following countries</b></big>"
        + "<table><tr><td>"
        + "<a href='http://s03.flagcounter.com/more/ThW'>"
        + "<img border=0 src='http://s03.flagcounter.com/count/ThW"
        + "/bg="     + PRC_BG_WHEAT
//         + "/bg="     + PRC_BG_MINT_GREEN
        + "/txt="    + PRC_FG_MAROON
        + "/border=" + PRC_BD_BLACK
//         + "/border=" + PRC_BG_MINT_GREEN
        + "/columns=9"
        + "/maxflags=60"
        + "/viewers=0"
        + "/labels=1"
        + "/'></a></td></tr></table>";

    result += "</h6></td></tr></table></div></body>";

x_log("\nResources used:"); var resource;
while (resource = prc_resources_used.shift())
{x_log("\n " + resource)}

x_log("\n--------------------------------------------- P R C _ B O D Y _ E N D ( )");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                     prc_child_menu() function                      */
/*--------------------------------------------------------------------*/
function prc_child_menu(a_page, a_anchor, a_title)
{
x_log("\nprc_child_menu('" + a_page + "', '" + a_anchor + "', \"" + a_title + "\");");
    var result = new String();
    var ptx, page, anchor, title;
    if (x_isnt_empty(a_page))
    {
        page   = a_page;
        anchor = a_anchor;
        title = "";
        var ptx = prc_index(page, anchor);
        if (ptx > -1) {title = pagetree[ptx + TITLE]}
    }
    else
    {
        ptx    = prc_ptx;
        page   = prc_page;
        anchor = prc_anchor;
        title  = prc_title;
    }
    if (x_isnt_empty(a_title)) {title = a_title}
x_log("\npage: '" + page + "', anchor: '" + anchor + "', title: \"" + title + "\"");

x_log("\nDisplaying a child menu for '" + page + anchor + "'.");
    prc_menu(title);
    prc_child_choices(ptx);
    prc_menu_end();
}

/*--------------------------------------------------------------------*/
/*                    prc_child_choices() function                    */
/*--------------------------------------------------------------------*/
function prc_child_choices(a_ptx)
{
x_log("\nprc_child_choices(" + a_ptx + ");");
    var ptx = a_ptx;
x_log("\nptx: " + ptx);
    var depth = pagetree[ptx + DEPTH];
x_log("\ndepth: " + depth);
    for (ptx += DESCLEN; ptx < pagetree.length; ptx += DESCLEN)
    {
        if (pagetree[ptx + DEPTH] > depth + 1) continue;
        if (pagetree[ptx + DEPTH] < depth + 1) break;
        var page    = pagetree[ptx + PAGE   ];
        var anchor  = pagetree[ptx + ANCHOR ];
        var title   = pagetree[ptx + TITLE  ];
        var comment = pagetree[ptx + COMMENT];
        var parms   = pagetree[ptx + PARMS  ];
// x_log("\n   page: '"  + page    + "'" );
// x_log("\n anchor: '"  + anchor  + "'" );
// x_log("\n  title: \"" + title   + "\"");
// x_log("\ncomment: \"" + comment + "\"");
// x_log("\n  parms: \"" + parms   + "\"");
        prc_choice(page, anchor, title, comment, parms);
    }
}

/*--------------------------------------------------------------------*/
/*                       prc_choice() function                        */
/*                                                                    */
/* WARNING: a_page can either be a name or a numeric index            */
/*          into the pagetree.                                        */
/*--------------------------------------------------------------------*/
function prc_choice(a_page, a_anchor, a_title, a_comment, a_parms)
{
x_log("\nprc_choice('"
+ a_page    + "', '"
+ a_anchor  + "', \""
+ a_title   + "\", \""
+ a_comment + "\", '"
+ a_parms   + "');");

    var ptx     = 0;
    var errmsg  = new String();
    var result  = new String();

    var page    = new String(a_page);
    var anchor  = new String(a_anchor);
    var title   = new String();
    var comment = new String();
    var parms   = new String();

// Lookup page name (or validate index):
    ptx = prc_index(a_page, a_anchor);

// A page/anchor might not be in the sitemap if it's an external
// URL that is explicitly referred to only in calls to <<choice>>,
// and all parameters are given in the call.
// That's why we can't do the following:
//     if (ptx == -1)
//     {
//         errmsg = "Page/Anchor '" + a_page + a_anchor + "' not found.";
//         document.write("<big><b>" + errmsg + "</b></big>");
//     }

// If page name (or index) is found in pagetree,
// default to the standard parameters:
    if (ptx > -1)
    {
        page    = pagetree[ptx + PAGE   ];
        anchor  = pagetree[ptx + ANCHOR ];
        title   = pagetree[ptx + TITLE  ];
        comment = pagetree[ptx + COMMENT];
        parms   = pagetree[ptx + PARMS  ];
    }
// If not, is it an explicit url?
    else if (x_isnt_external_link(page + anchor))
    {
x_log("\nERROR: '" + page + anchor + "' is NOT an external link!");
        return '';
    }

// Allow parameters overrides in the call:
    if (x_isnt_empty(a_title)  ) title   = a_title  ;
    if (x_isnt_empty(a_comment)) comment = a_comment;
    if (x_isnt_empty(a_parms)  ) parms   = a_parms  ;

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*            Remove breaks from the title and the comment            */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    title   = title.replace(/<br>/gi, " ");
    comment = comment.replace(/<br>/gi, " ");

x_log("\n => '"
+ page    + "', '"
+ anchor  + "', \""
+ title   + "\", \""
+ comment + "\", '"
+ parms   + "'");

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                Have we offered this title already?                 */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (prc_used_resource_already("title=" + title))
    {
x_log("\nSuppressing this choice because it was already offered on this page.");
        return '';
    }
    prc_resources_used.push("title=" + title);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                     Extract the flag settings                      */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    var age_flag      = x_get_parm(parms, ['-new', '-updated']);
    var hidden_flag   = x_get_parm(parms, ['-hidden']);
    var language_flag = x_get_parm(parms, ['-german', '-french', '-spanish']);

    if (age_flag || hidden_flag || language_flag)
    {
x_log("\nage_flag: '" + age_flag + "', hidden_flag: '" + hidden_flag + "', language_flag: '" + language_flag + "'");
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                  Should we keep this page hidden?                  */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (hidden_flag)
    {
x_log("\nSuppressing this choice because '" + page + anchor + "' is '" + hidden_flag + "'.");
        return '';
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*           Should we draw a rule in front of this choice?           */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//     if (hrule_flag)
//     {
//         result += "<tr><td colspan=9 bgcolor=yellow>&nbsp;</td></tr>";
//         result += "<tr><td colspan=9><hr></td></tr>";
//         result += "<tr><td></td><td><hr></td></tr>";
//     }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*             Should we use a special background color?              */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//     var bgcolor = new String();
//     if (language_flag == '-german') bgcolor = "bgcolor='yellow'";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*          Are we pointing to an internal or external page?          */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    var href = new String();
    var link_is_external = x_is_external_link(page);
    if (page != '')
    {
        if  (link_is_external)
        {
            href = page;                                     // external
        }
        else
        {
            href = page + PRC_DFLT_EXT + anchor;             // internal
        }
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                     What kind of link is this?                     */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    var link_is_active = false;
    var on_this_page   = false;
    var page_not_ready = false;
    result += "<tr><td width=22 valign=top>";

    if (page == "" && anchor == "")
    {
        page_not_ready = true;
        result += "<img src='pix/bullet_red_14x13.gif' border=0>";
    }
    else if (page == prc_page && anchor == prc_anchor)
    {
        on_this_page = true;
        result += "<img src='pix/bullet_yellow_14x13.gif' border=0>";
    }
    else
    {
        link_is_active = true;
        result += "<a href='" + href + "'>";
        result += "<img src='pix/bullet_green_14x13.gif' border=0>";
        result += "</a>";
    }
    result += "</td>\n<td>";
    if (link_is_active) result += "<a href='" + href + "'>";
    result += "\n<b>" + title;
//     if (prc_mode == "TEST")
//     {
//         result += " (" + page + anchor + ")";
//     }
    result += "</b>";
    if (link_is_external)
    {
        result += "&nbsp;<img border=0 "
            + "src='pix/link_is_external_13x15.gif'>";
    }
    if (link_is_active) result += "</a>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                     Append a flag if requested                     */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (age_flag == '-new')
    {
        result += "&nbsp;&nbsp;&nbsp;"
            + "<img border=0 src='pix/new_28x11.gif'>";
    }
    else if (age_flag == '-updated')
    {
        result += "&nbsp;&nbsp;&nbsp;"
            + "<img border=0 src='pix/updated_60x12.gif'>";
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                   Append a comment if requested                    */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    if (comment != "")
    {
        result += "\n<br>&nbsp;&nbsp;&nbsp;<span style='color: #"
            + PRC_FG_DARK_GRAY + ";'>" + comment + "</span>";
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                      Save the generated code                       */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "</td></tr>";
    prc_menu_choices += result;
x_log("\nprc_choice(...) => \"" + result + "\".<p>Exiting prc_choice()<p>");
}

/*--------------------------------------------------------------------*/
/*                       prc_collage() function                       */
/*--------------------------------------------------------------------*/
function prc_collage(a_key, a_resize, a_parms, a_caption)
{
x_log("\nprc_collage('" + a_key + "', '" + a_resize + "', '" + a_parms + "', '" + a_caption + "');");
    if (x_is_empty(a_key))
    {
        alert("<<collage>>: Search argument required/missing.");
        return;
    }
    var resize = '80%';
    var parms = '-center';
    var caption = new String();
    if (x_isnt_empty(a_resize) ) resize = a_resize  ;
    if (x_isnt_empty(a_parms)  ) parms = a_parms    ;
    if (x_isnt_empty(a_caption)) caption = a_caption;
    for (px = 0; px < piclist.length; px++)
    {
        if (piclist[px].substr(0, 3) != 'rb_') continue;
        if (piclist[px].search(a_key) > -1) break;
    }
    if (px >= piclist.length)
    {
        alert("<<collage>>: Search argument '" + a_key + "' "
            + "not found among collage names.");
        return;
    }
    var year = piclist[px].substr(3, 4);
    if (caption == '')
    {
        caption = "[&copy; " + year + " Rachel Bartlett]<br>"
        + "<a href='rbCollages.htm'>See all of Rachel's collages</a>";
    }
    prc_snapshot(piclist[px], resize, parms, caption);
}

/*--------------------------------------------------------------------*/
/*                       prc_credit() function                        */
/*--------------------------------------------------------------------*/
function prc_credit()
{
    var result = new String();
    if (prc_page.substr(0, 2) == 'mb')
    {
        result = "<p class=right>&mdash; Michael Ballin "
            + "is an Associate Professor Emeritus of the "
            + "<br>Department of English, Wilfrid "
            + "Laurier University Waterloo, Ontario.";
    }
x_log("\nprc_credit() = '" + result + "'");
    document.write(result);
    return result;
}
/*--------------------------------------------------------------------*/
/*                   prc_cycling_bgcolor() function                   */
/*--------------------------------------------------------------------*/
function prc_cycling_bgcolor()
{
    var result = prc_cycling_bgcolors[prc_cycling_bgcolor_index];
// x_log("\nprc_cycling_bgcolor() => '"
// + prc_cycling_bgcolors[prc_cycling_bgcolor_index]
// + "' (" + prc_cycling_bgcolor_index + ")");
    prc_cycling_bgcolor_index
        = ++prc_cycling_bgcolor_index
        %   prc_cycling_bgcolor_dimen;
    return result;
}

/*--------------------------------------------------------------------*/
/*                        prc_debug() function                        */
/*--------------------------------------------------------------------*/
function prc_debug(a_setting)
{
x_log("\nChanging 'prc_debug_setting' from '" + prc_debug_setting + "' to '" + a_setting + "'.");
    prc_debug_setting = a_setting;
}

/*--------------------------------------------------------------------*/
/*                      prc_debug_end() function                      */
/*--------------------------------------------------------------------*/
function prc_debug_end()
{
x_log("\nChanging 'prc_debug_end_setting' from '" + prc_debug_setting + "' to '0'.");
    prc_debug_end_setting = 0;
}

/*--------------------------------------------------------------------*/
/*                   prc_derive_timeline() function                   */
/*--------------------------------------------------------------------*/
function prc_derive_timeline(a_page, a_anchor)
{
x_log("\nprc_derive_timeline('" + a_page + "', '" + a_anchor + "');");
    var ptx, depth, node, pubdate, page, anchor, title;
    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        depth    = pagetree[ptx + DEPTH  ];
        node     = pagetree[ptx + NODE   ];
        pubdate  = pagetree[ptx + PUBDATE];
        page     = pagetree[ptx + PAGE   ];
        anchor   = pagetree[ptx + ANCHOR ];
        title    = pagetree[ptx + TITLE  ];
        prc_timeline[depth] = ptx;
        if (page == a_page && anchor == a_anchor) break;
    }
}

/*--------------------------------------------------------------------*/
/*                       prc_dialog() function                        */
/*--------------------------------------------------------------------*/
function prc_dialog(a_dimen)
{
x_log("\nprc_dialog('" + a_dimen + "');");
    if (x_is_empty(a_dimen))
    {
        prc_cycling_bgcolor_dimen = 2;          // default to 2 colors
x_log("\nprc_cycling_bgcolor_dimen defaults to '2'.");
    }
    else
    {
        if (a_dimen == '*')
        {
x_log("\nprc_cycling_bgcolors.length: '" + prc_cycling_bgcolors.length + "'");
            prc_cycling_bgcolor_dimen = prc_cycling_bgcolors.length;
        }
        else
        {
            prc_cycling_bgcolor_dimen = a_dimen;
        }
    }
x_log("\nprc_cycling_bgcolor_dimen: '" + prc_cycling_bgcolor_dimen + "'");
    prc_floating_table();
}

/*--------------------------------------------------------------------*/
/*                     prc_dialog_end() function                      */
/*--------------------------------------------------------------------*/
function prc_dialog_end()
{
    prc_floating_table_end();
}

/*--------------------------------------------------------------------*/
/*                     prc_email_link_code() function                 */
/*--------------------------------------------------------------------*/
function prc_email_link_code()
{
    var result = x_email
    (
        x_yyyy() + '@' + PRC_DOMAIN,
        x_yyyy(),
        PRC_DOMAIN,
        "subject=(Sent from '" + location + "')"
    );
    return result;
}

/*--------------------------------------------------------------------*/
/*                  prc_floating_row_code() function                  */
/*--------------------------------------------------------------------*/
function prc_floating_row_code()
{
    return "<tr bgcolor='" + prc_cycling_bgcolor() + "'>";
}

/*--------------------------------------------------------------------*/
/*                prc_floating_row_end_code() function                */
/*--------------------------------------------------------------------*/
function prc_floating_row_end_code()
{
    return "</tr>";
}

/*--------------------------------------------------------------------*/
/*                   prc_floating_table() function                    */
/*--------------------------------------------------------------------*/
function prc_floating_table(a_parms)
{
    var parms = a_parms;
    if (x_is_empty(a_parms )) parms = '';
    parms += " align=center width=0 cellspacing=16 cellpadding=8 "
        + "\n style='margin-top: 16; margin-bottom: 16; "
        + "background-image: url(pix/background_1_100x100.jpg);'";
    prc_table(parms);
}

/*--------------------------------------------------------------------*/
/*                 prc_floating_table_end() function                  */
/*--------------------------------------------------------------------*/
function prc_floating_table_end()
{
    prc_table_end();
}

/*--------------------------------------------------------------------*/
/*                       prc_fnote() function                         */
/*--------------------------------------------------------------------*/
function prc_fnote(a_num)
{
// NOTE: Footnote links only work in IE because Firefox doesn't
// seem to support <a name=''> tags generated in Javascript.
    prc_fnote_end();
    var num = new String();
    if (x_isnt_empty(a_num)) num = a_num;
    var result = new String("<tr><td align=right valign=top>");
    if (x_browser() == 'IE')
    {
        result += "<a name='#FNOTE_" + num + "'></a>"
                + "<a href='#FNREF_" + num + "'>";
    }
    result += "&nbsp;" + num + ".&nbsp;"
    if (x_browser() == 'IE') result += "</a>";
    result += "</td><td>";
    document.write(result);
    prc_in_an_fnote = true;
}

/*--------------------------------------------------------------------*/
/*                      prc_fnote_end() function                      */
/*--------------------------------------------------------------------*/
function prc_fnote_end()
{
    if (prc_in_an_fnote == false) return;
    prc_in_an_fnote = false;
    document.write("</td></tr>");
}

/*--------------------------------------------------------------------*/
/*                       prc_fnref() function                         */
/*--------------------------------------------------------------------*/
function prc_fnref(a_num)
{
// NOTE: Footnote links only work in IE because Firefox doesn't
// seem to support <a name=''> tags generated in Javascript.
    var num = new String();
    if (x_isnt_empty(a_num)) num = a_num;
    var result = new String();
    if (x_browser() == 'IE')
    {
        result += "<a name='#FNREF_" + num + "'></a>"
                + "<a href='#FNOTE_" + num + "'>";
    }
    result += "<b><sup>&nbsp;" + num + "&nbsp;</sup></b>";
    if (x_browser() == 'IE') result += "</a>";
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                      prc_footnotes() function                      */
/*--------------------------------------------------------------------*/
function prc_footnotes(a_title)
{
    var title = new String('Footnotes');
    if (x_isnt_empty(a_title)) title = a_title;
    prc_table("cellpadding=4");
    document.write("<tr><td colspan=9 align=center>"
        + "<b>" + title + "</b></td></tr>");
}

/*--------------------------------------------------------------------*/
/*                    prc_footnotes_end() function                    */
/*--------------------------------------------------------------------*/
function prc_footnotes_end()
{
    prc_fnote_end();
    prc_table_end();
}

/*--------------------------------------------------------------------*/
/*                       prc_h_code() function                        */
/*                                                                    */
/* This macro only exists to support "soft breaks" in the title,      */
/* whethor given as a parameter or grabbed from the pagetree table.   */
/*--------------------------------------------------------------------*/
function prc_h_code(a_level, a_title)
{
x_log("\nprc_h" + a_level + "(" + a_title + ");");
    var title = new String();
    if (x_isnt_empty(a_title)) {title = a_title}
    else if (a_level == 1)
    {
        title = prc_title;
// If there is an anchor, the title will name the section of the
// page the anchor points to. Find the title of the page itself:
        if (prc_anchor != '')
        {
x_log("\nprc_anchor: '" + prc_anchor + "'");
            ptx   = prc_index(prc_page);
            title = pagetree[ptx + TITLE];
        }
    }
    else
    {
        title = "<<h" + a_level + ">>: 'title' operand required/missing.";
    }
x_log("\ntitle: '" + title + "'");
// Don't need redundant blanks:
    title = title.replace(/ <br>/g, "<br>");
// Soften breaks in title:
    title = x_soften_breaks(title);
// x_log("\ntitle: '" + title + "'");
// Don't need text highlighting if in an <H1> tagset:
    title = title.replace(/<b>/gi, "");
    title = title.replace(/<i>/gi, "");
    title = title.replace(/<\/b>/gi, "");
    title = title.replace(/<\/i>/gi, "");
    title = title.replace(/<<b>>/gi, "");
    title = title.replace(/<<i>>/gi, "");
    title = title.replace(/<<bi>>/gi, "");
    title = title.replace(/<<\/b>>/gi, "");
    title = title.replace(/<<\/i>>/gi, "");
    title = title.replace(/<<\/bi>>/gi, "");
// x_log("\ntitle: '" + title + "'");
// Don't need quotes or category designations:
    title = title.replace(/&quot;/g, "");
    title = title.replace(/ \[article\]/, "");
    title = title.replace(/ \[column\]/, "");
    title = title.replace(/ \[editorial\]/, "");
    title = title.replace(/ \[essay\]/, "");
    title = title.replace(/ \[essays\]/, "");
    title = title.replace(/ \[fiction\]/, "");
    title = title.replace(/ \[letter to the editor\]/, "");
    title = title.replace(/ \[memoir\]/, "");
    title = title.replace(/ \[poem\]/, "");
// x_log("\ntitle: '" + title + "'");
x_log("\nprc_h" + a_level + "('" + title + "') => '<h" + a_level + ">" + title + "</h" + a_level + ">'");
    return "\n<h" + a_level + ">" + title + "</h" + a_level + ">";
}

/*--------------------------------------------------------------------*/
/*                        prc_index() function                        */
/*                                                                    */
/* The argument to this function can be either                        */
/*                                                                    */
/*     1) a numeric index into the pagetree table, in which case      */
/*        it will be validity-checked and then returned, or           */
/*                                                                    */
/*     2) a page and anchor pair, which will then be looked up        */
/*         in the pagetree table and the index returned.              */
/*                                                                    */
/* If the argument is invalid, this function returns -1.              */
/*                                                                    */
/*--------------------------------------------------------------------*/
function prc_index(a_page, a_anchor)
{
    if (typeof a_page   == 'undefined') a_page   = new String("");
    if (typeof a_anchor == 'undefined') a_anchor = new String("");
    var ptx;
    var errmsg = new String();
    if (typeof a_page == 'number')
    {
        ptx = a_page;
        if (ptx < 0)
        {
            errmsg = "prc_index(" + ptx + "): Index is less than 0.";
x_log("\n" + errmsg);
            return -1;
        }
        if (ptx > pagetree.length - DESCLEN)
        {
            errmsg = "prc_index(" + ptx + "): Index is greater than "
                + pagetree.length - DESCLEN + ".";
x_log("\n" + errmsg);
            return -1;
        }
        if (ptx % DESCLEN)
        {
            errmsg = "prc_index(" + ptx + "): Index is not a multiple of "
                + DESCLEN + ".";
x_log("\n" + errmsg);
            return -1;
        }
x_log("\nprc_index(" + ptx + ") => " + ptx);
        return ptx;
    }

// Since a Windows server will return the "Psychiatry.htm" page
// if "psychiatry.htm" is entered, we need to find out the correct
// page name by doing case-insensitive lookups. The easiest way
// to accomplish this is by translating each operand to upper case.
    var upper_case_page   = a_page.toUpperCase();
    var upper_case_anchor = a_anchor.toUpperCase();
    if (upper_case_page == "" && upper_case_anchor == "")
    {
        errmsg = "prc_index('', ''): Page name required/missing.";
x_log("\n" + errmsg);
        return -1;
    }
x_log("\nupper_case_page: '" + upper_case_page + "', upper_case_anchor: '" + upper_case_anchor + "'");
    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        var this_upper_case_page, this_upper_case_anchor;
        this_upper_case_page   = pagetree[ptx + PAGE  ];
        this_upper_case_anchor = pagetree[ptx + ANCHOR];
        this_upper_case_page   = this_upper_case_page.toUpperCase();
        this_upper_case_anchor = this_upper_case_anchor.toUpperCase();
// x_log("\nIn upper case, pagetree[" + ptx + "]: '" + this_upper_case_page + this_upper_case_anchor + "'.");
        if (upper_case_page == this_upper_case_page && upper_case_anchor == this_upper_case_anchor)
        {
            if (a_page   != pagetree[ptx + PAGE]
            ||  a_anchor != pagetree[ptx + ANCHOR])
            {
x_log("\nCorrecting case of '" + a_page + a_anchor + "' to '" + pagetree[ptx + PAGE] + pagetree[ptx + ANCHOR] + "'.");
            }
x_log("\nprc_index('" + a_page + "', '" + a_anchor + "') => " + ptx);
            return ptx;
        }
    }
    errmsg = "prc_index('" + a_page + "', '" + a_anchor + "'): Page/anchor not found in page tree.";
x_log("\n" + errmsg);
    return -1;
}

/*--------------------------------------------------------------------*/
/*                    prc_james_analogs() function                    */
/*--------------------------------------------------------------------*/
function prc_james_analogs(a_feminine, a_masculine)
{
x_log("\nprc_james_analogs('" + a_feminine + "', '" + a_masculine + "');");
    var result = new String();
    if (x_isnt_empty(a_feminine))
    {
        result += prc_floating_row_code()
            + "<td align=right>" + a_feminine  + "</td>"
            + "<td align=left>"  + a_masculine + "</td>"
            + prc_floating_row_end_code();
        document.write(result);
        return;
    }
    prc_floating_table();
    prc_james_analogs("<b>TENDER-MINDED</b>", "<b>TOUGH-MINDED</b>");
    prc_james_analogs("rationalistic<br>(going by principles)", "empiricist<br>(going by facts)");
    prc_james_analogs("intellectualistic"   , "sensationalistic");
    prc_james_analogs("idealistic"          , "materialistic");
    prc_james_analogs("optimistic"          , "pessimistic");
    prc_james_analogs("religious"           , "irreligious");
    prc_james_analogs("free-willist"        , "fatalistic");
    prc_james_analogs("monistic"            , "pluralistic");
    prc_james_analogs("dogmatical"          , "skeptical");
    prc_floating_table_end();
}

/*--------------------------------------------------------------------*/
/*                      prc_keywords() function                       */
/*--------------------------------------------------------------------*/
function prc_keywords()
{
    document.write("science of human nature, philosophical anthropology, "
        + "moral philosophy, humanistic psychology, personal development, "
        + "interpersonal creativity, social progress, introversion, "
        + "extroversion, femininity, masculinity, psychological polarity, "
        + "character specialization, homosexuality, gay liberation");
}

/*--------------------------------------------------------------------*/
/*                    prc_language_menu() function                    */
/*--------------------------------------------------------------------*/
function prc_language_menu()
{
x_log("\nprc_language_menu();");
    var menu_title = new String();
    if (prc_language_flag == '-german')
    {
        menu_title = "Mehr Texte auf Deutsch";
    }
    else if (prc_language_flag == '-french')
    {
        menu_title = "More French Content";
    }
    else if (prc_language_flag == '-spanish')
    {
        menu_title = "More Spanish Content";
    }
    prc_menu(menu_title);
    var ptx;
    var rx = 0;
    var rows = new Array();
    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        var page  = pagetree[ptx + PAGE ];
        var title = pagetree[ptx + TITLE];
        var parms = pagetree[ptx + PARMS];
        var language_flag = x_get_parm(parms, ['-german', '-french', '-spanish']);
        if (language_flag == prc_language_flag)
        {
// x_log("\n ptx: " + ptx + ", page: '" + page + "', title: \"" + title + "\".");
             rows[rx++] = ptx;
        }
    }
    rows = x_sort_table_selection_by_column(pagetree, rows, TITLE);
x_log("\ntypeof rows: " + (typeof rows) + ", rows.length: " + rows.length);

    for (rx = 0; rx < rows.length; rx++)
    {
x_log("\nrows[rx]: " + rows[rx] + ", title: '" + pagetree[rows[rx] + TITLE] + "'");
        prc_choice(rows[rx]);
    }
x_log("\nDisplaying a '" + prc_language_flag + "' language menu.");
    prc_menu_end();
}

/*--------------------------------------------------------------------*/
/*                      prc_link_code() function                      */
/*                                                                    */
/*    If a_page ends in '\' then you're linking to a folder rather    */
/*    than to a page which can be exected to end in PRC_DFLT_EXT.     */
/*--------------------------------------------------------------------*/
function prc_link_code(a_page, a_anchor, a_title)
{
// alert("prc_link_code('" + a_page + "', '" + a_anchor + "', '" + a_title + "');");

    var page             = a_page      ;
    var ext              = PRC_DFLT_EXT;
    var anchor           = a_anchor    ;
    var title            = a_title     ;
    var link_is_external = false       ;
    var link_is_folder   = false       ;
    var result           = new String();


    if  (page.length >= 7 && page.substr(0, 7) == "http://")
    {
        link_is_external = true;
        ext              = new String("");
    }
    if  (link_is_external && page.charAt(page.length - 1) == PRC_SLASH)
    {
        link_is_folder = true;
        ext            = new String("");
    }
    if (x_is_empty(a_page  )) page   = '';
    if (x_is_empty(a_anchor)) anchor = '';
    if (x_is_empty(a_title ))
    {
        var ptx = prc_index(page, anchor);
        if (ptx == -1)
        {
            result += "<big><b>*** Page \"" + page
                + anchor + "\" not found ***</b></big>";
            return result;
        }
        title = pagetree[ptx + TITLE];
        title = title.replace(/<br>/gi, " ");
    }
    result += "<a href='" + page + ext + anchor + "'>" + title;
    if  (link_is_external)
    {
        result += "&nbsp;<img border=0 "
            + "src='pix/link_is_external_13x15.gif'>";
    }
    result += "</a>";
// alert("result: '" + result + "'.");
    return result;
}

/*--------------------------------------------------------------------*/
/*                        prc_menu() function                         */
/*                                                                    */
/*      The prc_menu() function generates tables that are 1)          */
/* centered, 2) have top and bottom margins that default to 16, and   */
/* 3) have left and right margins that default to 80.                 */
/*                                                                    */
/*      Specifying left and right margins in Firefox cancels the      */
/* effect of align=center, however. To avoid this, we encapsulate our */
/* table in another table that is centered but has no width, which    */
/* lets both tables grow to be as wide as necessary, but with a       */
/* minimum left and right margin.                                     */
/*                                                                    */
/*      If all the choices specified are empty because they were      */
/* already offered early in the page, then we don't want to show      */
/* even the menu title. For this reason, all code generated by        */
/* prc_menu() and prc_choice() is saved until prc_menu_end() is       */
/* issued, at which time we can see if any choices are to be          */
/* displayed.                                                         */
/*                                                                    */
/*--------------------------------------------------------------------*/
function prc_menu(a_title)
{
x_log("\nprc_menu('" + a_title + "');");
    prc_menu_title = '';
    if (x_isnt_empty(a_title)) prc_menu_title = a_title;
x_log("\nprc_menu_title = '" + prc_menu_title + "'.");
}

/*--------------------------------------------------------------------*/
/*                      prc_menu_end() function                       */
/*--------------------------------------------------------------------*/
function prc_menu_end()
{
x_log("\nprc_menu_end();");
    if (x_is_empty(prc_menu_choices))
    {
x_log("\nAll menu choices were suppressed, so we will suppress this entire menu.");
        return '';
    }
x_log("\nprc_menu_title = '" + prc_menu_title + "'.");
    prc_table("align=center width=0");
    document.write("<tr><td>");
    prc_table("style='margin-top: 16; margin-bottom: 16; "
        + "margin-left: 80; margin-right: 80;'");
    if (prc_menu_title)
    {
        document.write("<tr><td colspan=9 align=center bgcolor=#"
            + PRC_BG_WHEAT + ">" + prc_menu_title + "</td></tr>");
        prc_menu_title = '';
    }
x_log("\nprc_menu_choices = \"" + prc_menu_choices + "\".");
    document.write(prc_menu_choices);
    prc_menu_choices = '';
    prc_table_end();
    document.write("</td></tr>");
    prc_table_end();
    return '';
}

/*--------------------------------------------------------------------*/
/*                 prc_notable_pages_menu() function                  */
/*--------------------------------------------------------------------*/
function prc_notable_pages_menu(a_title)
{
    var ptx;
    var title = new String(PRC_WEBSITE);
    if (x_isnt_empty(a_title)) {title = a_title}
    prc_menu(title);
    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        var page    = pagetree[ptx + PAGE   ];
        var anchor  = pagetree[ptx + ANCHOR ];
        var comment = pagetree[ptx + COMMENT];
        if (page == '' || comment == '') continue;
        if (page.substr(0, 7) == 'http://') continue;
        if (page.substr(0, 7) == 'https:/') continue;
        prc_choice(page, anchor);
    }
    prc_menu_end();
}

/*--------------------------------------------------------------------*/
/*                 prc_number_of_children() function                  */
/*--------------------------------------------------------------------*/
function prc_number_of_children(a_parent_page, a_parent_anchor)
{
x_log("\nprc_number_of_children('" + a_parent_page + a_parent_anchor + "')");
    var parent_page, parent_anchor, result = 0;
    if (x_is_empty(a_parent_page))
    {
         parent_page   = prc_page;
         parent_anchor = prc_anchor;
    }
    else
    {
         parent_page   = a_parent_page;
         parent_anchor = a_parent_anchor;
    }
    var ptx = prc_index(parent_page, parent_anchor) + DESCLEN;
    var depth = pagetree[ptx] + DEPTH;
// x_log("\nfor(ptx = " + ptx + "; pagetree[ptx + DEPTH] >= " + depth + "; ptx += " + DESCLEN + ")");
    for
    (
        ptx;
        pagetree[ptx + DEPTH] >= depth;
        ptx += DESCLEN
    )
    {
// x_log("\nptx: " + ptx + ": " + pagetree[ptx + DEPTH] + " '" + pagetree[ptx + PAGE] + pagetree[ptx + ANCHOR] + "' \"" + pagetree[ptx + TITLE] + "\"");
        if (pagetree[ptx + DEPTH] > depth) continue;
        result++;
    }
x_log("\nprc_number_of_children('" + a_parent_page + a_parent_anchor + "')");
x_log(" => " + result);
    return result;
}

/*--------------------------------------------------------------------*/
/*                      prc_page_num() function                       */
/*--------------------------------------------------------------------*/
function prc_page_num(a_page_num)
{
    document.write("page&nbsp;" + a_page_num);
}

/*--------------------------------------------------------------------*/
/*                     prc_page_quote() function                      */
/*--------------------------------------------------------------------*/
function prc_page_quote()
{
    document.write("<p class='page_quote'>");
}

/*--------------------------------------------------------------------*/
/*                   prc_page_quote_end() function                    */
/*--------------------------------------------------------------------*/
function prc_page_quote_end()
{
    document.write("</p>");
}

/*--------------------------------------------------------------------*/
/*                     prc_pull_quote() function                      */
/*--------------------------------------------------------------------*/
function prc_pull_quote(a_flags, a_quote)
{
    var result = new String
    (
          "<td bgcolor='#" + PRC_BG_WHITE + "' align='" + a_flags + "' width=175>"
        + "<img src='pix/quote_open 175x29.gif'><p "

        + "style='margin-left: 8; margin-right: 8; "
        + "color: #"                      // copied from x_hover_style()
        + PRC_FG_MAROON + "; font-size: 12; "
        + "background-color: #" + PRC_BG_LIGHT_GRAY + "; "
        + "border: #" + PRC_BG_WHITE + " 4px solid;'>"

        + a_quote + "</p><img src='pix/quote_close 175x28.gif'></td>"
    );
    var errmsg = new String();
    if      (a_flags == '-right') result =  "<td></td>" + result;
    else if (a_flags == '-left' ) result += "<td></td>";
    else
    {
         errmsg = "Invalid flags, '<big><b>" + a_flags
             + "</big></b>', in invocation of <<pull_quote>>.";
         result = errmsg;
    }
    result = "<table border=00 align='" + a_flags.substr(1) + "'><tr>"
        + result + "</tr></table>";
x_log("\nprc_pull_quote('" + a_flags + "', \"" + a_quote + "\") => \"" + result + "\".");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                 prc_random_paul_picture() function                 */
/*--------------------------------------------------------------------*/
function prc_random_paul_picture()
{
    var paul_pix =
    [
        "Paul_at_home_in_the_kitchen_730x487.jpg",
        "Paul_in_front_of_St._Mark[039]s_Church_in_the_Bowery_541x561.jpg",
        "Paul_on_the_Staten_Island_Ferry_545x565.jpg",
//         "Paul_washing_dishes_577x363.jpg",
        "Paul_washing_dishes_287x287.jpg",
        "Paul_with_mug_583x589.jpg"
    ];
    var result = '';

    while (result == '')
    {
        result = paul_pix[Math.floor(Math.random() * paul_pix.length)];
        x_parse_imgsrc(result);
        if (prc_used_resource_already("paulimg=" + plx_parse_imgsrc_caption))
        {
            result = '';
        }
    }
    prc_resources_used.push("paulimg=" + plx_parse_imgsrc_caption);
    return result;
}

/*--------------------------------------------------------------------*/
/*                prc_random_paul_thumbnail() function                */
/*--------------------------------------------------------------------*/
function prc_random_paul_thumbnail()
{
    var paul_thumbs =
    [
        "Paul_at_home_in_the_kitchen_200x200.jpg",
        "Paul_in_front_of_St._Mark[039]s_Church_in_the_Bowery_200x200.jpg",
        "Paul_on_the_Staten_Island_Ferry_200x200.jpg",
        "Paul_washing_dishes_200x200.jpg",
        "Paul_with_mug_200x200.jpg"
    ];
    var result = '';

    while (result == '')
    {
        result = paul_thumbs[Math.floor(Math.random() * paul_thumbs.length)];
        x_parse_imgsrc(result);
        if (prc_used_resource_already("paulimg=" + plx_parse_imgsrc_caption))
        {
            result = '';
        }
    }
    prc_resources_used.push("paulimg=" + plx_parse_imgsrc_caption);
    return result;
}

/*--------------------------------------------------------------------*/
/*                       prc_search() function                        */
/*--------------------------------------------------------------------*/
function prc_search()
{
x_log("\nprc_search();");
x_log("\nprc_search_form.prc_search_input.value: '"
       + prc_search_form.prc_search_input.value + "'");
    if (prc_search_form.prc_search_input.value == '')
    {
        alert("Please enter a search argument.");
        prc_search_form.prc_search_input.focus();
        return;
    }
    var new_loc = new String
    (
        "http://www.google.com/search?&q=" + encodeURI
        (
            prc_search_form.prc_search_input.value
            + " site:rosenfels.org "
        )
    );
x_log("\nGoing to '" + new_loc + "'.");
    location = new_loc;
}

/*--------------------------------------------------------------------*/
/*                    prc_sibling_menu() function                     */
/*--------------------------------------------------------------------*/
function prc_sibling_menu()
{
x_log("\nprc_sibling_menu();");
    var tlx, parent_page, parent_anchor, number_of_children;
x_log("\nprc_depth: " + prc_depth);
    for (tlx = prc_depth; tlx > 0; tlx--)
    {
        if (prc_depth == 1)                                 // HOME PAGE
        {
            prc_notable_pages_menu();
            return;
        }
        parent_page   = pagetree[prc_timeline[tlx - 1] + PAGE  ];
        parent_anchor = pagetree[prc_timeline[tlx - 1] + ANCHOR];
x_log("\nparent_page: '" + parent_page + "'");
x_log("\nparent_anchor: '" + parent_anchor + "'");
        if (x_isnt_empty(parent_page))
        {
// If this ancestor has more than one child, show them:
            number_of_children = prc_number_of_children
            (
                parent_page, parent_anchor
            );
            if (number_of_children > 1)
            {
                prc_child_menu(parent_page, parent_anchor);
                return;
            }
        }
        else
        {
x_log("\nThis ancestor has only one child. Try the next ancestor.");
        }
    }
}

/*--------------------------------------------------------------------*/
/*                        prc_site() function                         */
/*--------------------------------------------------------------------*/
function prc_site()
{
    var result = new String(PRC_WEBSITE);
    return result;
}

/*--------------------------------------------------------------------*/
/*                       prc_speech() function                        */
/*                                                                    */
/*        The first column of a speech row can be the value of        */
/*    a_column, or it can immediately follow the <<speech>> macro.    */
/*                                                                    */
/*                   There are usually two columns.                   */
/*                Column 1 generates <<floating_row>>.                */
/*              <</speech>> generates <</floating_row>>.              */
/*                                                                    */
/*--------------------------------------------------------------------*/
function prc_speech(a_column)
{
    var result = new String();
    if (prc_speech_column == 2) prc_speech_end();
    prc_speech_column++;

    if (prc_speech_column == 1)
    {
        result += prc_floating_row_code() + "<td align=right valign=top>";
    }
    else
    {
        result += "</td><td valign=top>";
    }
    if (x_isnt_empty(a_column))
    {
        result += a_column + "</td><td valign=top>";
        prc_speech_column++;
    }
    prc_in_a_speech = true;
// x_log("\nprc_speech('" + a_column + "') => '" + result + "'");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                     prc_speech_end() function                      */
/*--------------------------------------------------------------------*/
function prc_speech_end()
{
    if (!prc_in_a_speech) return;
    prc_speech_column = 0;
    prc_in_a_speech = false;
    var result = new String("</td>" + prc_floating_row_end_code());
// x_log("\nprc_speech_end() => '" + result + "'");
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                     prc_staff_code() function                      */
/*--------------------------------------------------------------------*/
function prc_staff_code
(
    a_person, a_service, a_resize, a_parms, a_caption
)
{
    var person  = '';
    var service = '-contact';
    var resize  = '20%';
    var parms   = '';
    var caption = '';

    var errmsg  = '';
    var result  = '';

    if (x_isnt_empty(a_person) ) person  = a_person;
    if (x_isnt_empty(a_service)) service = a_service;
    if (x_isnt_empty(a_resize) ) resize  = a_resize;
    if (x_isnt_empty(a_parms)  ) parms   = a_parms;
    if (x_isnt_empty(a_caption)) caption = a_caption;

    if (service != '-contact' && service != '-picture' && service != '-menu')
    {
        errmsg = "Invalid service in \"<<staff, '"
            + person + "', '" + service + "', ...>>\".";
        x_log("\n" + errmsg);
        result += " [<b>" + errmsg + "</b>] ";
    }

    if (person == 'bob')
    {
        if (service == '-menu')
        {
            staff_menu('bf', "Bob's Pages");
        }
        else if (service == '-picture')
        {
            result += x_snapshot('Bob_Fink_1200x1600.jpg', resize, parms, caption);
        }
        else if (service == '-contact')
        {
            result += x_email
            (
                "Bob&nbsp;Fink",
                "bob." + x_yyyy(),
                PRC_DOMAIN,
                "subject=(Sent from '" + location + "')"
            );
        }
    }
    else if (person == 'dean')
    {
        if (service == '-picture')
        {
//             result += x_snapshot('Dean_Hannotte_1504x1000.jpg', resize, parms, caption);
            result += x_snapshot('Dean_Hannotte_1350x1350.jpg', resize, parms, caption);
        }
        else if (service == '-contact')
        {
            result += x_email
            (
                "Dean&nbsp;Hannotte",
                "dean." + x_yyyy(),
                PRC_DOMAIN,
                "subject=(Sent from '" + location + "')"
            );
        }
        else
        {
            errmsg = "Invalid service in \"<<staff, '"
                + person + "', '" + service + "', ...>>\".";
            x_log("\n" + errmsg);
            result += " [<b>" + errmsg + "</b>] ";
        }
    }
    else if (person == 'john')
    {
        if (service == '-picture')
        {
            result += x_snapshot('John_Calhoun_312x315.jpg', resize, parms, caption);
        }
        else if (service == '-contact')
        {
            result += "<b>John Calhoun</b>";
        }
        else
        {
            errmsg = "Invalid service in \"<<staff, '"
                + person + "', '" + service + "', ...>>\".";
            x_log("\n" + errmsg);
            result += " [<b>" + errmsg + "</b>] ";
        }
    }
    else if (person == 'laurie')
    {
        if (service == '-menu')
        {
            staff_menu('lb', "Laurie's Pages");
        }
        else if (service == '-picture')
        {
            result += x_snapshot('Laurie_Bell_452x343.jpg', resize, parms, caption);
        }
        else
        {
            errmsg = "Invalid service in \"<<staff, '"
                + person + "', '" + service + "', ...>>\".";
            x_log("\n" + errmsg);
            result += " [<b>" + errmsg + "</b>] ";
        }
    }
    else if (person == 'michael')
    {
        if (service == '-menu')
        {
            staff_menu('mb', "Michael's Pages");
        }
        else if (service == '-picture')
        {
            result += x_snapshot('Michael_Ballin_346x376.jpg', resize, parms, caption);
        }
        else
        {
            result += x_email
            (
                "Michael Ballin",
                "michael." + x_yyyy(),
                PRC_DOMAIN,
                "subject=(Sent from '" + location + "')"
            );
        }
    }
    else if (person == 'paul')
    {
        if (service == '-picture')
        {
            result += x_snapshot(prc_random_paul_picture(), resize, parms, caption);
        }
        else
        {
            errmsg = "Invalid service in \"<<staff, '"
                + person + "', '" + service + "', ...>>\".";
            x_log("\n" + errmsg);
            result += " [<b>" + errmsg + "</b>] ";
        }
    }
    else if (person == 'rachel')
    {
        if (service == '-menu')
        {
            staff_menu('rb', "Rachel's Pages");
        }
        else if (service == '-picture')
        {
//             result += x_snapshot('Rachel_Bartlett_1000x665.jpg', resize, parms, caption);
            result += x_snapshot('Rachel_Bartlett_950x950.jpg', resize, parms, caption);
        }
        else
        {
            result += x_email
            (
                "Rachel&nbsp;Bartlett",
                "rachel." + x_yyyy(),
                PRC_DOMAIN,
                "subject=(Sent from '" + location + "')"
            );
        }
    }
    else if (person == 'tony')
    {
        if (service == '-menu')
        {
            staff_menu('tr', "Tony's Pages");
        }
        else if (service == '-picture')
        {
            result += x_snapshot('Tony_Rostron_195x199.jpg', resize, parms, caption);
        }
        else
        {
            errmsg = "Invalid service in \"<<staff, '"
                + person + "', '" + service + "', ...>>\".";
            x_log("\n" + errmsg);
            result += " [<b>" + errmsg + "</b>] ";
        }
    }
    else
    {
        errmsg = "Invalid person, '" + person + "', in call to <<staff>>.";
        x_log("\n" + errmsg);
        result += " [<big><b>" + errmsg + "</b></big>] ";
    }

x_log("\nprc_staff_code('" + a_person + "', '" + a_service + "', '" + a_resize + "', '" + a_parms + "', '" + a_caption + "')");
x_log("\n => '" + result + "'");
    return result;
}

/*--------------------------------------------------------------------*/
/*                        prc_table() function                        */
/*--------------------------------------------------------------------*/
function prc_table(a_parms)
{
    prc_table_depth++;
    var result = "<table";
    if (prc_debug_setting == 1)
    {
        var table_borders = ['#000000', '#ff0000',
            '#00ff00', '#0000ff', '#808080'];
        result += " border=04 bordercolor=\""
            + table_borders[prc_table_depth] + "\"";
    }
    if (x_isnt_empty(a_parms))
    {
        result += "\n " + a_parms + "\n";
    }
// If none of the following attributes were specified,
// they'll default to the following values:
    result += " align=center cellpadding=0 cellspacing=0>";
x_log("\n" + prc_table_depth + ": " + result);
//     if (prc_debug_setting == 1)
//     {
// alert(prc_table_depth + " prc_table(\"" + a_parms + "\");\n => \"" + result + "\".");
//     }
    document.write(result);
}

/*--------------------------------------------------------------------*/
/*                      prc_table_end() function                      */
/*--------------------------------------------------------------------*/
function prc_table_end()
{
    var result = "</table>";
x_log("\n" + prc_table_depth + ": " + result);
    document.write(result);
    prc_table_depth--;
}

/*--------------------------------------------------------------------*/
/*                  prc_table_of_contents() function                  */
/*--------------------------------------------------------------------*/
function prc_table_of_contents()
{
x_log("\nP R C _ T A B L E _ C O N T E N T S ( ) ---------------------------------");
    var result = new String();

// NOTE: In Firefox tag attributes can't be names only,
//       they must have attributes following a keyword.
//       "selected" won't work, but "selected=\"selected\"" will.
//       This has something to do with Firefox's greater
//       allegiance to the sillier rules of XHTML.

    result += "\n<form name=prc_toc "
        + "style='margin-top: 16; margin-bottom: 16;'>"
        + "\n<select name=f_page"
        + "\n onChange='window.location = "
        + "document.prc_toc.f_page.options["
        + "document.prc_toc.f_page.selectedIndex].value;'>"
        + "\n<option selected=\"selected\" value=''>\n";

    result += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

// Firefox needs a bit more padding:
    if (x_browser() != 'IE')
    {
        result += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    }

    result += "\nTable of Contents</option>";

//     result += "\n<optgroup label='This is an optgroup.'>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n</optgroup>";
//     result += "\n<optgroup label='This is another optgroup.'>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n</optgroup>";
//     result += "\n<optgroup label='This is a third optgroup.'>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n<option>This is an option.</option>";
//     result += "\n</optgroup>";

    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        var depth   = pagetree[ptx + DEPTH  ];
        var node    = pagetree[ptx + NODE   ];
        var pubdate = pagetree[ptx + PUBDATE];
        var page    = pagetree[ptx + PAGE   ];
        var anchor  = pagetree[ptx + ANCHOR ];
        var title   = pagetree[ptx + TITLE  ];
        var comment = pagetree[ptx + COMMENT];
        var parms   = pagetree[ptx + PARMS  ];

// x_log("\ndepth: " + depth
//  + ", node: '" + node
//  + "', pubdate: '" + pubdate
//  + "', page/anchor: '" + page + anchor
//  + "', title: \"" + title
//  + "\", comment: \"" + comment
//  + "\", parms: \"" + parms + "\"");

        var hidden = x_get_parm(parms, ['-hidden']);
        if (hidden)
        {
x_log("\n'" + page + anchor + "' is '" + hidden + "'.");
            continue;
        }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                         Start <option> tag                         */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
        var href = new String();
        if (page != "")
        {
            href = page + PRC_DFLT_EXT + anchor;
            if  (page.substr(0, 7) == "http://")
            {
                href = page;
            }
        }

        result += "\n<option value='" + href + "'";

// NOTE: the disabled= attribute is ignored by IE7 and below!
        if (page == "")
        {
// x_log("\n'" + page + "' isn't up yet (\"" + title + "\")");
            result += " disabled=\"disabled\"";
        }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                        Assemble title style                        */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
// NOTE: the font-size: and font-weight: attributes are ignored by IE!
        result += " style='font-size:" + (16 - depth) + ";";
        if (depth < 2) result += " font-weight: bold;";
        if (page == prc_page && anchor == prc_anchor)
        {
// x_log("\n'" + page + "' is the page we're on (\"" + title + "\")");
            result += " background-color: #" + PRC_BG_WHEAT + ";";
        }
        else if (page == "")
        {
// x_log("\n'" + page + "' isn't up yet (\"" + title + "\")");
// NOTE: the disabled= attribute is ignored by IE7 and below!
            if (x_browser() == 'IE' && x_browser_version() < 8)
            {
                 result += " color: #" + PRC_FG_GRAY + ";";
            }
        }
        result += "'>";

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                               Indent                               */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
        if (depth > 0) result += "\n";
        for (tlx = 1; tlx <= depth; tlx++)
        {
// BUG: When there is a jump in effective font
//      size, the indent is disproportional!
            result += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                       Show title (and page)                        */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
        result += "\n " + node + "&nbsp;&nbsp;" + title;
//         if (prc_mode == "TEST")
//         {
//             result += " (" + page + anchor + ")";
//         }
        result += "</option>";
    }

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                            End of form                             */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    result += "\n</select>\n</form>";
// x_log(result + "\n");
x_log("\n--------------------------------- P R C _ T A B L E _ C O N T E N T S ( )");
    return result;
}

/*--------------------------------------------------------------------*/
/*               prc_ultimate_dropdown_menu() function                */
/*--------------------------------------------------------------------*/
function  prc_ultimate_dropdown_menu()
{
    document.write("\n<script type='text/javascript' "
        + "src='udm-resources/udm-dom.js'></script>"
        + "\n<script type='text/javascript' "
        + "src='udm-resources/udm-mod-keyboard.js'></script>");
}

/*--------------------------------------------------------------------*/
/*                prc_used_resource_already() function                */
/*--------------------------------------------------------------------*/
function prc_used_resource_already(a_resource)
{
    var rx;
    for (rx = 0; rx < prc_resources_used.length; rx++)
    {
        if (a_resource == prc_resources_used[rx])
        {
x_log("\nprc_used_resource_already('" + a_resource + "') => 1");
            return 1;
        }
    }
x_log("\nprc_used_resource_already('" + a_resource + "') => 0");
    return 0;
}

/*--------------------------------------------------------------------*/
/*                        prc_wiki() function                         */
/*--------------------------------------------------------------------*/
function prc_wiki(a_article, a_display)
{
    document.write(x_wiki(a_article, a_display) + "&nbsp;"
        + "<img border=0 src='pix/link_is_external_13x15.gif'>");
}

/*--------------------------------------------------------------------*/
/*                        prc_yyyy() function                         */
/*--------------------------------------------------------------------*/
function prc_yyyy(a_resource)
{
    document.write(x_yyyy());
}

/**********************************************************************/
/*                                                                    */
/*                I N T E R N A L   F U N C T I O N S                 */
/*                                                                    */
/**********************************************************************/

/*--------------------------------------------------------------------*/
/*                       staff_menu() function                        */
/*--------------------------------------------------------------------*/
function staff_menu(a_initials, a_title)
{
x_log("\nstaff_menu('" + a_initials + "', \"" + a_title + "\");");
    prc_menu(a_title);
    var ptx;
    var page = new String();
    var title = new String();
    var rx = 0;
    var rows = new Array();
    for (ptx = 0; ptx < pagetree.length; ptx += DESCLEN)
    {
        page  = pagetree[ptx + PAGE ];
        title = pagetree[ptx + TITLE];
        if (page != '' && page.substr(0, 2) == a_initials)
        {
x_log("\n ptx: " + ptx + ", page: '" + page + "', title: \"" + title + "\".");
             rows[rx++] = ptx;
        }
    }
    rows = x_sort_table_selection_by_column(pagetree, rows, TITLE);
x_log("\ntypeof rows: " + (typeof rows) + ", rows.length: " + rows.length);
    for (rx = 0; rx < rows.length; rx++)
    {
x_log("\nrows[rx]: " + rows[rx] + ", title: '" + pagetree[rows[rx] + TITLE] + "'");
        prc_choice(rows[rx]);
    }
    prc_menu_end();
}

/*--------------------------------------------------------------------*/
/*                   normalize_hostname() function                    */
/*--------------------------------------------------------------------*/
function normalize_hostname()
{
    var new_loc = PRC_HOMEPAGE;
    if (location.hostname == 'www.ninthstreetcenter.org'
    ||  location.hostname == 'ninthstreetcenter.org')
    {
// Google 'define' sends people to 'ninthstreetcenter.org/Glossary.htm'!
        if (location.pathname == '/Glossary.htm')
        {
            new_loc = PRC_HOMEPAGE + '/nsc/Glossary.htm';
        }
        else
        {
            alert("You are being redirected to the new Paul Rosenfels "
                + "Community website at '" + PRC_HOMEPAGE + "'.");
        }
    }
    location = new_loc;
}

//     if (location.search != '')
//     {
//         var url_parms = location.search.substr(1);
// x_log("url_parms: '" + url_parms + "'");
//         var upx1, upx2, ampersand, equalsign;
//         for (upx1 = 0; upx1 < url_parms; upx1++)
//         {
//             if url_parms.charAt(upx1)
//         }
//         if (url_parms.substr(0, 9) == 'timeline=')
//         {
//             prc_timeline_type = url_parms.substr(9);
// x_log("prc_timeline_type: '" + prc_timeline_type + "'");
//         }
//     }

// /*--------------------------------------------------------------------*/
// /*                        x_log_obj() function                        */
// /*--------------------------------------------------------------------*/
// function x_log_obj(a_object_name)
// {
// x_log("\n-------------------------------------------------------------------------");
// //     x_log("\n" + a_object_name + ": " + x_obj(a_object_name));
//     x_log("\n" + x_obj(a_object_name));
// x_log("\n-------------------------------------------------------------------------");
// }
//
// var plx_obj_depth = 0;
// var plx_obj_indent = new String('');
//
// /*--------------------------------------------------------------------*/
// /*                          x_obj() function                          */
// /*--------------------------------------------------------------------*/
// function x_obj(a_object_name)                             // 20021030 DH
// {
// x_log("\nx_obj(\"" + a_object_name + "\");");
//     plx_obj_depth++;
// // x_log("\nplx_obj_depth == " + plx_obj_depth + ".");
//     plx_obj_indent = '';
//     for (dx = 0; dx + 1 < plx_obj_depth; dx++)
//     {
//         plx_obj_indent += '. ';
//     }
// // x_log("\nplx_obj_indent == '" + plx_obj_indent + "'.");
//     var result = plx_obj_indent + a_object_name + ': ';
// // x_log("\nBefore issuing \"object_value = eval('" + a_object_name + "');\" ...");
//     object_value = eval(a_object_name);
//     typeof_object_value = typeof object_value;
// // x_log("\n After issuing \"object_value = eval('" + a_object_name + "');\" ...");
// x_log("\ntypeof_object_value == '" + typeof_object_value + "'.");
// x_log("\nobject_value == '" + object_value + "'.");
//     if (typeof_object_value == 'string')
//     {
//         result += "'" + object_value + "' (typeof_object_value)";
//     }
//     else
//     {
//         result += object_value + ' (' + typeof_object_value + ')';
//     }
//     if (typeof_object_value == 'object')
//     {
//         if (plx_obj_depth < 3)
//         {
//             for (var elem in object_value)
//             {
// x_log("\nelem == '" + elem + "'.");
//                 result += "\n" + x_obj(a_object_name + "." + elem);
//             }
//         }
//     }
//     plx_obj_depth--;
// // x_log("\n ... returning '" + result + "'.");
//     return result;
// }

/**********************************************************************/
/*                               E N D                                */
/**********************************************************************/
