
//  **************************************************************************
//  GLOBAL 'MAIN MENU' SUPPORT
//  site/main_menu/menu_support.js
//  (C) 2007 Peter Newman
//  **************************************************************************

// ===========================================================================
// not_yet_implemented
// ===========================================================================

function not_yet_implemented() {
    alert( "Not Yet Implemented!" ) ;
    }

// ===========================================================================
// about_the_kiwi_party
// ===========================================================================

function about_the_kiwi_party() {

    // -----------------------------------------------------------------------

    new wos1_WebOS_Window( {
        width               :   '90%'                               ,
        height              :   '90%'                               ,
        title               :   'Kiwi Party Documentation...'       ,
        document_url        :   get_url__for_target( 'about' )      ,
        control_buttons     :   '#o'                                ,
        status_bar_buttons  :   [   {   title           :   'OK / Cancel'   ,
                                        onclick_close   :   undefined
                                        }
                                    ]
        } ) ;

    // -----------------------------------------------------------------------

    }

// ===========================================================================
// frequently_asked_questions
// ===========================================================================

function frequently_asked_questions() {

    // -----------------------------------------------------------------------

    new wos1_WebOS_Window( {
        width               :   '90%'                               ,
        height              :   '90%'                               ,
        title               :   'Kiwi Party Documentation...'       ,
        document_url        :   get_url__for_target( 'faq' )        ,
        control_buttons     :   '#o'                                ,
        status_bar_buttons  :   [   {   title           :   'OK / Cancel'   ,
                                        onclick_close   :   undefined
                                        }
                                    ]
        } ) ;

    // -----------------------------------------------------------------------

    }

// ===========================================================================
// show_contact_details
// ===========================================================================

var contact_details_popup ;

var contact_details_popup_attributes ;

// ---------------------------------------------------------------------------

function show_contact_details() {

    // -----------------------------------------------------------------------
    // Don't pop-up if already popped-up...
    // -----------------------------------------------------------------------

    if ( contact_details_popup ) {
        return ;
        }

    // -----------------------------------------------------------------------
    // If the "Contact Details..." popup's attribute string hasn't yet been
    // created, create it...
    // -----------------------------------------------------------------------

    if ( !contact_details_popup_attributes ) {
        var popup_width  = Math.min( 600 , Math.round( wos1__get_viewport_width()  ) ) ;
        var popup_height = Math.min( 250 , Math.round( wos1__get_viewport_height() ) ) ;
        contact_details_popup_attributes = 'width=' + popup_width + 'px,height=' + popup_height + 'px,center=1,resize=1,scrolling=1' ;
        }

    // -----------------------------------------------------------------------
    // Open the "Contact Details..." popup window...
    // -----------------------------------------------------------------------

    // -----------------------------------------------------------------------
    // var uniquevar = dhtmlwindow.open(
    //                      uniqueID        ,
    //                      contenttype     ,
    //                      contentsource   ,
    //                      title           ,
    //                      attributes      ,
    //                      [recalonload]
    //                      )
    // - - - - - - - - - - - - - - - - - - -
    // PARAMETERS:-
    //
    //      uniquevar:      Whenever you call dhtmlwindow.open() the first
    //                      time to create and open a new window, you
    //                      should assign it to an arbitrary but unique
    //                      variable. It is through this variable that you
    //                      can later invoke additional methods to
    //                      manipulate the opened window.
    //
    //      uniqueID:       The first parameter of dhtmlwindow.open(), this
    //                      should be an arbitrary but unique ID, used by
    //                      the script to create the "ID" attribute of the
    //                      window's primary DIV container.
    //
    //      contenttype:    This parameter tells the script the content
    //                      type you'll be loading into the window. The
    //                      four valid values are: "iframe", "inline",
    //                      "ajax", or "div". See the next parameter for
    //                      more info.
    //
    //      contentsource:  This parameter specifies the content itself to
    //                      show inside the window, and varies depending on
    //                      the former "contenttype" parameter.
    //
    //                      For "iframe" content, specify the URL to the
    //                      page in question (ie: "http://www.google.com").
    //
    //                      For "inline" content, specify the complete HTML
    //                      you wish to show, though remember to backslash
    //                      any special JavaScript characters such as
    //                      apostrophes (ie: "<b>I\'m the window content to
    //                      show</b>").
    //
    //                      For "ajax" content, specify the relative path
    //                      to the external page on your site from the
    //                      current page to show (ie: "../external.htm").
    //
    //                      And finally, for "div" content, first, define a
    //                      DIV on the page with a unique ID attribute and
    //                      probably hidden (using style="display:none"),
    //                      then, use the DIV's id (ie: "mydiv") as the
    //                      parameter;s value.
    //
    //      title:          Arbitrary text that will be shown as the title
    //                      of the window.
    //
    //      attributes:     Set this parameter to toggle the various
    //                      display attributes of the window when it's
    //                      created, such as its dimensions, position on
    //                      the page etc. Separate each attribute with a
    //                      comma (,). Here they are in full force:
    //
    //                      - - - - - - - - - - - - - - - - - - - - - - -
    //                      Attribute       Description
    //                      - - - - - - -   - - - - - - - - - - - - - - -
    //                      width=600px     Width of the window, in px.
    //
    //                      height=450px    Height of the window, in px.
    //
    //                      left=30px       Horizontal position of the
    //                                      window relative to the window
    //                                      viewpoint (left/top edge of the
    //                                      visible window).
    //
    //                      top=100px       Vertical position of the window
    //                                      relative to the window
    //                                      viewpoint.
    //
    //                      center=1|0      Sets whether window should be
    //                                      centered on the page. If
    //                                      defined supersedes the left/top
    //                                      attributes above. 1=yes, 0=no.
    //
    //                      resize=1|0      Sets whether window should be
    //                                      resizable. 1=yes, 0=no.
    //
    //                      scrolling=1|0   Sets whether window should
    //                                      contain scrollbars (when
    //                                      needed). 1=yes, 0=no.
    //                      - - - - - - - - - - - - - - - - - - - - - - -
    //
    //                      Remember to separate each attribute with a
    //                      comma. All of them are optional, though you
    //                      should at least declare the width/height
    //                      attributes for a presentable window to be
    //                      created:
    //
    //                          "width=450px,height=200px,center=1,scrolling=1"
    //
    //      recalonload:    This is an optional parameter that should only
    //                      be used when you're opening up a DHTML window
    //                      automatically as the page is loading (versus
    //                      clicking on a link for example). By defining
    //                      and setting this parameter to a value of
    //                      "recal", the script will reposition the DHTML
    //                      window after the document has fully loaded to
    //                      take into account any scrolling of the document
    //                      that might have occured prior.
    // -----------------------------------------------------------------------

    var contact_details_html = '<center><h1>Contact Details</h1>' +
        '<p style="margin-bottom:0;">For enquiries about the <strong>Kiwi Party</strong>, contact:-</p>' +
        '<img src="' + url_contact_details_dir + '/admin.gif">' +
        '<br><br>' +
        '<p style="margin-bottom:0;">For enquiries about <strong>this</strong>' +
        ' (the official Kiwi Party) <strong>website</strong>, contact:-</p>' +
        '<img src="' + url_contact_details_dir + '/webmaster.gif">' +
        '<br></center>' ;

    // -----------------------------------------------------------------------

    contact_details_popup = dhtmlwindow.open(
        'contact_details'                   ,
        'inline'                            ,
        contact_details_html                ,
        'Contact...'                        ,
        contact_details_popup_attributes
        ) ;

    // -----------------------------------------------------------------------

    contact_details_popup.onclose = function () {
        contact_details_popup = undefined ;
        return true ;
        }

    // -----------------------------------------------------------------------
    // Center the popup (within the browser window)...
    //
    // NOTE!
    // -----
    // We shouldn't need to do this  - since we asked "dhtmlwindow.open()"
    // to center the window.
    //
    // But the "dhtmlwindow.open()" centering doesn't work very well.  So we
    // manually center the popup ourselves...
    // -----------------------------------------------------------------------

    contact_details_popup.moveTo('middle','middle') ;

    // -----------------------------------------------------------------------
    // That's that!
    // -----------------------------------------------------------------------

    }

// ===========================================================================
// options_slash_preferences
// ===========================================================================

var options_popup ;
var options_popup_attributes ;

var options_question_css_on_entry ;
var options_question_css_required ;

var options_question_elt_on_entry ;
var options_question_elt_required ;

// ---------------------------------------------------------------------------

function options_slash_preferences__toggle_CSS() {

    // -----------------------------------------------------------------------

    var CSS_html ;

    if ( options_question_css_required ) {
        options_question_css_required = false ;
        CSS_html = 'No' ;

    } else {
        options_question_css_required = true ;
        CSS_html = 'Yes' ;

        }

    // -----------------------------------------------------------------------

    var el = document.getElementById( 'options_slash_preferences_CSS' ) ;

    if ( el ) {
        el.innerHTML = CSS_html ;
        }

    // -----------------------------------------------------------------------

    }

// ---------------------------------------------------------------------------

function options_slash_preferences__toggle_ELT() {

    // -----------------------------------------------------------------------

    var ELT_html ;

    if ( options_question_elt_required ) {
        options_question_elt_required = false ;
        ELT_html = 'No' ;

    } else {
        options_question_elt_required = true ;
        ELT_html = 'Yes' ;

        }

    // -----------------------------------------------------------------------

    var el = document.getElementById( 'options_slash_preferences_ELT' ) ;

    if ( el ) {
        el.innerHTML = ELT_html ;
        }

    // -----------------------------------------------------------------------

    }

// ---------------------------------------------------------------------------

function options_slash_preferences__OK() {

    // -----------------------------------------------------------------------
    // Local variables...
    // -----------------------------------------------------------------------

    var refresh_the_page = false ;

    // -----------------------------------------------------------------------
    // CSS...
    // -----------------------------------------------------------------------

    //  ----------------------------------------------------------------------
    //  webos__set_question_css( true|false )
    //  - - - - - - - - - - - - - - - - - - -
    //  Sets the:-
    //      COOKIE_NAME__QUESTION_CSS
    //
    //  cookie to either:-
    //      false ==> 0, or;
    //      true  ==> 1.
    //
    //  RETURNS
    //      Nothing
    //  ----------------------------------------------------------------------

    if ( options_question_css_required != options_question_css_on_entry ) {
        webos__set_question_css( options_question_css_required ) ;
        refresh_the_page = true ;
        }

    // -----------------------------------------------------------------------
    // Emergency Layout Tables...
    // -----------------------------------------------------------------------

    //  ----------------------------------------------------------------------
    //  webos__set_question_elt( true|false )
    //  - - - - - - - - - - - - - - - - - - -
    //  Sets the:-
    //      COOKIE_NAME__QUESTION_ELT
    //
    //  cookie to either:-
    //      false ==> 0, or;
    //      true  ==> 1.
    //
    //  RETURNS
    //      Nothing
    //  ----------------------------------------------------------------------

    if ( options_question_elt_required != options_question_elt_on_entry ) {
        webos__set_question_elt( options_question_elt_required ) ;
        refresh_the_page = true ;
        }

    //  ----------------------------------------------------------------------
    // Close the window...
    //  ----------------------------------------------------------------------

    options_popup.hide() ;

    //  ----------------------------------------------------------------------
    //  Refresh the page (but only if necessary)...
    //  ----------------------------------------------------------------------

    if ( refresh_the_page ) {
        window.location.reload() ;
        }

    //  ----------------------------------------------------------------------
    // That's that!
    //  ----------------------------------------------------------------------

    }

// ---------------------------------------------------------------------------

function options_slash_preferences() {

    // -----------------------------------------------------------------------
    // Don't pop-up if already popped-up...
    // -----------------------------------------------------------------------

    if ( options_popup ) {
        return ;
        }

    // -----------------------------------------------------------------------
    // If the "Contact Details..." popup's attribute string hasn't yet been
    // created, create it...
    // -----------------------------------------------------------------------

    if ( !options_popup_attributes ) {
        var popup_width  = Math.min( 600 , Math.round( wos1__get_viewport_width()  ) ) ;
        var popup_height = Math.min( 250 , Math.round( wos1__get_viewport_height() ) ) ;
        options_popup_attributes = 'width=' + popup_width + 'px,height=' + popup_height + 'px,center=1,resize=1,scrolling=1' ;
        }

    // -----------------------------------------------------------------------
    // Open the "Options/Preferences..." popup window...
    // -----------------------------------------------------------------------

    // -----------------------------------------------------------------------
    // var uniquevar = dhtmlwindow.open(
    //                      uniqueID        ,
    //                      contenttype     ,
    //                      contentsource   ,
    //                      title           ,
    //                      attributes      ,
    //                      [recalonload]
    //                      )
    // - - - - - - - - - - - - - - - - - - -
    // PARAMETERS:-
    //
    //      uniquevar:      Whenever you call dhtmlwindow.open() the first
    //                      time to create and open a new window, you
    //                      should assign it to an arbitrary but unique
    //                      variable. It is through this variable that you
    //                      can later invoke additional methods to
    //                      manipulate the opened window.
    //
    //      uniqueID:       The first parameter of dhtmlwindow.open(), this
    //                      should be an arbitrary but unique ID, used by
    //                      the script to create the "ID" attribute of the
    //                      window's primary DIV container.
    //
    //      contenttype:    This parameter tells the script the content
    //                      type you'll be loading into the window. The
    //                      four valid values are: "iframe", "inline",
    //                      "ajax", or "div". See the next parameter for
    //                      more info.
    //
    //      contentsource:  This parameter specifies the content itself to
    //                      show inside the window, and varies depending on
    //                      the former "contenttype" parameter.
    //
    //                      For "iframe" content, specify the URL to the
    //                      page in question (ie: "http://www.google.com").
    //
    //                      For "inline" content, specify the complete HTML
    //                      you wish to show, though remember to backslash
    //                      any special JavaScript characters such as
    //                      apostrophes (ie: "<b>I\'m the window content to
    //                      show</b>").
    //
    //                      For "ajax" content, specify the relative path
    //                      to the external page on your site from the
    //                      current page to show (ie: "../external.htm").
    //
    //                      And finally, for "div" content, first, define a
    //                      DIV on the page with a unique ID attribute and
    //                      probably hidden (using style="display:none"),
    //                      then, use the DIV's id (ie: "mydiv") as the
    //                      parameter;s value.
    //
    //      title:          Arbitrary text that will be shown as the title
    //                      of the window.
    //
    //      attributes:     Set this parameter to toggle the various
    //                      display attributes of the window when it's
    //                      created, such as its dimensions, position on
    //                      the page etc. Separate each attribute with a
    //                      comma (,). Here they are in full force:
    //
    //                      - - - - - - - - - - - - - - - - - - - - - - -
    //                      Attribute       Description
    //                      - - - - - - -   - - - - - - - - - - - - - - -
    //                      width=600px     Width of the window, in px.
    //
    //                      height=450px    Height of the window, in px.
    //
    //                      left=30px       Horizontal position of the
    //                                      window relative to the window
    //                                      viewpoint (left/top edge of the
    //                                      visible window).
    //
    //                      top=100px       Vertical position of the window
    //                                      relative to the window
    //                                      viewpoint.
    //
    //                      center=1|0      Sets whether window should be
    //                                      centered on the page. If
    //                                      defined supersedes the left/top
    //                                      attributes above. 1=yes, 0=no.
    //
    //                      resize=1|0      Sets whether window should be
    //                                      resizable. 1=yes, 0=no.
    //
    //                      scrolling=1|0   Sets whether window should
    //                                      contain scrollbars (when
    //                                      needed). 1=yes, 0=no.
    //                      - - - - - - - - - - - - - - - - - - - - - - -
    //
    //                      Remember to separate each attribute with a
    //                      comma. All of them are optional, though you
    //                      should at least declare the width/height
    //                      attributes for a presentable window to be
    //                      created:
    //
    //                          "width=450px,height=200px,center=1,scrolling=1"
    //
    //      recalonload:    This is an optional parameter that should only
    //                      be used when you're opening up a DHTML window
    //                      automatically as the page is loading (versus
    //                      clicking on a link for example). By defining
    //                      and setting this parameter to a value of
    //                      "recal", the script will reposition the DHTML
    //                      window after the document has fully loaded to
    //                      take into account any scrolling of the document
    //                      that might have occured prior.
    // -----------------------------------------------------------------------

    //  ----------------------------------------------------------------------
    //  CSS...
    //  ----------------------------------------------------------------------

    //  ----------------------------------------------------------------------
    //  webos__get_question_css__clean_and_simplified()
    //  - - - - - - - - - - - - - - - - - - - - - - - -
    //  Returns a flag indicating whether or not the user wants to use CSS.
    //
    //  This will be determined from the:-
    //      COOKIE_NAME__QUESTION_CSS
    //
    //  cookie (sent by the user's browser).
    //
    //  But if there is no such cookie - or if that cookie has an invalid
    //  value - we default to TRUE.
    //
    //  NOTE!
    //  ------
    //  This routine issues NO error messages.
    //  ----------------------------------------------------------------------

    options_question_css_on_entry = webos__get_question_css__clean_and_simplified() ;

    options_question_css_required = options_question_css_on_entry ;

    //  ----------------------------------------------------------------------

    var CSS_html ;

    if ( options_question_css_required ) {
        CSS_html = 'Yes' ;

    } else {
        CSS_html = 'No' ;

        }

    //  ----------------------------------------------------------------------
    //  Emergency Layout Tables...
    //  ----------------------------------------------------------------------

    //  ----------------------------------------------------------------------
    //  webos__get_question_elt__clean_and_simplified()
    //  - - - - - - - - - - - - - - - - - - - - - - - -
    //  Returns a flag indicating whether or not the user wants to use ELT.
    //
    //  This will be determined from the:-
    //      COOKIE_NAME__QUESTION_ELT
    //
    //  cookie (sent by the user's browser).
    //
    //  But if there is no such cookie - or if that cookie has an invalid
    //  value - we default to TRUE.
    //
    //  NOTE!
    //  ------
    //  This routine issues NO error messages.
    //  ----------------------------------------------------------------------

    options_question_elt_on_entry = webos__get_question_elt__clean_and_simplified() ;

    options_question_elt_required = options_question_elt_on_entry ;

    //  ----------------------------------------------------------------------

    var ELT_html ;

    if ( options_question_elt_required ) {
        ELT_html = 'Yes' ;

    } else {
        ELT_html = 'No' ;

        }

    // -----------------------------------------------------------------------
    // Create the window content...
    // -----------------------------------------------------------------------

    var options_html = '<center><h1>Options/Preferences</h1>' +
        '<table>' +
        '<tr><td>Use CSS?:</td><td><span id="options_slash_preferences_CSS" class="boldly_subtle_link"' +
            ' onclick="options_slash_preferences__toggle_CSS()">' + CSS_html + '</span></td></tr>' +
        '<tr><td>Allow Emergency Layout Tables?:</td><td><span id="options_slash_preferences_ELT" class="boldly_subtle_link"' +
            ' onclick="options_slash_preferences__toggle_ELT()">' + ELT_html + '</span></td></tr>' +
        '</table>' +
        '<br><br><br>' +
        '<p><span class="boldly_subtle_link" onclick="options_slash_preferences__OK()">OK</span>' +
            ' &nbsp; &nbsp;&nbsp; &nbsp; ' +
        '<span class="boldly_subtle_link" onclick="options_popup.hide()">Cancel</span></p>' +
        '</center><br>' ;

    // -----------------------------------------------------------------------
    // Open/display the window...
    // -----------------------------------------------------------------------

    options_popup = dhtmlwindow.open(
        'options'                       ,
        'inline'                        ,
        options_html                    ,
        'Options/Preferences...'        ,
        options_popup_attributes
        ) ;

    // -----------------------------------------------------------------------

    options_popup.onclose = function () {
        options_popup = undefined ;
        return true ;
        }

    // -----------------------------------------------------------------------
    // Center the popup (within the browser window)...
    //
    // NOTE!
    // -----
    // We shouldn't need to do this  - since we asked "dhtmlwindow.open()"
    // to center the window.
    //
    // But the "dhtmlwindow.open()" centering doesn't work very well.  So we
    // manually center the popup ourselves...
    // -----------------------------------------------------------------------

    options_popup.moveTo('middle','middle') ;

    // -----------------------------------------------------------------------
    // That's that!
    // -----------------------------------------------------------------------

    }

