
// ***************************************************************************
// site/standard_center_column_content_type.js
// (C) 2007 Peter Newman
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Support routines for handling the 'standard center column content' at
// the client browser...
// ***************************************************************************

// ===========================================================================
// SCCC_get_currently_selected_content_type_name
// ===========================================================================

function SCCC_get_currently_selected_content_type_name() {

    // -----------------------------------------------------------------------
    // SCCC_get_currently_selected_content_type_name()
    // - - - - - - - - - - - - - - - - - - - - - - - -
    // Returns the name of the currently selected 'standard center column
    // content type'.  Unless there's NO currently selected 'standard center
    // column content type', in which case, the empty string ('') is
    // returned.
    //
    // NOTES!
    // ------
    // 1.   The currently selected 'standard center column content type'
    //      is stored in the client browser's:-
    //          COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    //      cookie.
    // 2.   Because a hacker can alter a cookie value without too much
    //      trouble, the value returned from this function SHOULDN'T BE
    //      TRUSTED (it may have been hacked).
    // -----------------------------------------------------------------------

    return SCCC_get_currently_selected_content_type_name__base_routine( '' ) ;

    // -----------------------------------------------------------------------

    }

// ===========================================================================
// SCCC_get_currently_selected_content_type_name__none2home
// ===========================================================================

function SCCC_get_currently_selected_content_type_name__none2home() {

    // -----------------------------------------------------------------------
    // SCCC_get_currently_selected_content_type_name__none2home()
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Returns the name of the currently selected 'standard center column
    // content type'.  Unless there's NO currently selected 'standard center
    // column content type', in which case, "home" is returned.
    //
    // NOTES!
    // ------
    // 1.   The currently selected 'standard center column content type'
    //      is stored in the client browser's:-
    //          COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    //      cookie.
    // 2.   Because a hacker can alter a cookie value without too much
    //      trouble, the value returned from this function SHOULDN'T BE
    //      TRUSTED (it may have been hacked).
    // 3.   "home" is:-
    //      o   A value that might be stored in the:-
    //              COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    //          cookie, and;
    //      o   The default 'standard center column content type' if none
    //          is explicitly specified.
    // 4.   Thus, "home" is returned by this function both:-
    //      o   If it's the value stored in the:-
    //              COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    //          cookie, and;
    //      o   If there's NO:-
    //              COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    //          cookie.
    // -----------------------------------------------------------------------

    return SCCC_get_currently_selected_content_type_name__base_routine( 'home' ) ;

    // -----------------------------------------------------------------------

    }

// ===========================================================================
// SCCC_get_currently_selected_content_type_name__base_routine
// ===========================================================================

function SCCC_get_currently_selected_content_type_name__base_routine(
    default_value
    ) {

    // -----------------------------------------------------------------------
    // NOTE!
    // -----
    // This routine isn't intended to be called directly.  Use either:-
    //      SCCC_get_currently_selected_content_type_name()
    // or;
    //      SCCC_get_currently_selected_content_type_name__none2home()
    // instead.
    // -----------------------------------------------------------------------

/*
    // -----------------------------------------------------------------------
    // quirksmode_readCookie( name )
    // - - - - - - - - - - - - - - -
    // To read out a cookie, call this function and pass the name of the
    // cookie.  Put the returned value in a variable.  Then check if this
    // variable has a value (if the cookie does not exist the variable
    // becomes null, which might upset the rest of your function), then
    // do whatever is necessary.
    //
    // For example:-
    //      var x = quirksmode_readCookie('ppkcookie1')
    //      if (x) {
    //          [do something with x]
    //          }
    //
    // -----------------------------------------------------------------------

    var content_type = quirksmode_readCookie(
                            COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
                            ) ;

*/

    // ===========================================================================
    // function processCookie(
    //      cookieName  ,
    //      func        ,
    //      name        ,
    //      value       ,
    //      days
    //      )
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // Do stuff with cookies.  In particular, support "stacked cookies" (=
    // multiple "name=value" pairs in the one cookies proper).
    //
    // NOTE!
    // -----
    // 1.   To create/use use a stacked cookie; make 'cookieName' and 'name'
    //      different.
    //
    // 2.   The operations available are:-
    //      o   Kill    (delete),
    //      o   Clear   (non-stacked - delete, stacked - remove name/value pair),
    //      o   Set     (add/update the name/value pair creating cookie if needs
    //                  be),
    //      o   Read    (return the value, if present, of the provided named
    //                  element)
    //
    //      cookieName  [required]  -   The name of the cookie.
    //
    //      func        [required]  -   What processing on the cookie is required,
    //                                  i.e. kill (delete), clear (non-stacked -
    //                                  delete, stacked - remove name/value pair),
    //                                  set (add/update the name/value pair creating
    //                                  cookie if needs be), read (return the value,
    //                                  if present, of the provided named element)
    //
    //      name        [required]  -   Identifies the name/value pair to be
    //                                  operated on. If the same as cookieName
    //                                  indicates a non-stacked cookie.
    //
    //      value       [optional]  -   Supplies the data the be associated with the
    //                                  identified named cookie element.
    //
    //      days        [optional]  -   In cases where a cookie is created or
    //                                  updated, this sets the period of validity.
    //                                  Defaults to 365 days.
    //
    // See: "Javascript/PHP Cookies"
    //      kos Haks
    //      http://cass-hacks.com/articles/discussion/js_php_cookies/
    //
    // RETURNS
    //      o   If func == 'read'
    //          - - - - - - - - -
    //          cookie value = Cookie read OK!
    //          null         = Read ERROR (NO error message issued)!
    //      o   Otherwise
    //          - - - - -
    //          true  = Cookie killed, cleared or set OK!
    //          false = ERROR (NO error message issued)!
    // ===========================================================================

    var content_type = processCookie(
                            'general'                                           ,   //  cookieName
                            'read'                                              ,   //  func
                            COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE       //  name
                            ) ;

    // -----------------------------------------------------------------------

    if ( content_type ) {
        return content_type ;
        }

    // -----------------------------------------------------------------------

    return default_value ;

    // -----------------------------------------------------------------------

    }

/*
// ===========================================================================
// SCCC_change_content_type
// ===========================================================================

function SCCC_change_content_type(
    new_content_type_name
    ) {

    // -----------------------------------------------------------------------
    // SCCC_change_content_type(
    //      new_content_type_name
    //      ) {
    // - - - - - - - - - - - - -
    // Called to handle things when an item on the top row of the 'standard
    // center column content picker':-
    //
    //      ISSUES  forums  polls  elected bodies  service organisations  laws  candidates  <--+
    //        Table of Contents       first  last    previous  next       Documentation        |
    //                                                                                         |
    // is clicked.                                                                             |
    //                                                                                         |
    // In other words, this routine is called when one the these items is clicked -------------+
    //
    // 'new_content_type_name' is the 'standard center column content type'
    // name of the item that was clicked on.
    //
    // This routine then:-
    //
    // 1.   De-highlights the currently highlit item on the 'content picker'.
    //
    // 2.   Highlights the new currently selected content type (on the
    //      'content picker').
    //
    // 3.   Switches the page content to the new content type.
    // -----------------------------------------------------------------------

    // -----------------------------------------------------------------------
    // Get the currently selected content type...
    // -----------------------------------------------------------------------

    // -----------------------------------------------------------------------
    // SCCC_get_currently_selected_content_type_name()
    // - - - - - - - - - - - - - - - - - - - - - - - -
    // Returns the name of the currently selected 'standard center column
    // content type'.  Unless there's NO currently selected 'standard center
    // column content type', in which case, the empty string ('') is
    // returned.
    //
    // NOTE!
    // -----
    // The currently selected 'standard center column content type' is
    // stored in the client browser's:-
    //      COOKIE_NAME__SCCC_CURRENTLY_SELECTED_CONTENT_TYPE
    // cookie.
    // -----------------------------------------------------------------------

    var old_content_type_name = SCCC_get_currently_selected_content_type_name__none2home() ;

    // -----------------------------------------------------------------------
    // Change the content type...
    // -----------------------------------------------------------------------

    CP_change_content_type(
        old_content_type_name           ,
        new_content_type_name           ,
        'SCCC_selection_list'           ,
        get_url__for_target( 'sccc' )
        ) ;

    // -----------------------------------------------------------------------
    // That's that!
    // -----------------------------------------------------------------------

    }
*/

