
saveCookies = function()
    {
    var save =  'textSize=' + encodeURIComponent(wlx.wlx_textSize) + '|'

    var translation = wlx.wlx_translation

    // Don't save WordLinks in cookie - not an automatic translation.
    // When returning to the lookup after having gone to WordLinks,
    // we don't want to select 'WordLinks' as the previous translation
    // for two reasons: (1) WordLinks replaced the top pane and will
    // initiate an automatic lookup causing us to return back to
    // WordLinks (when using index.htm) in an endless loop which frustrates
    // use of the back button; (2) WordLinks is meant to be a manual selection
    // to jump to full bible study--but a choice that is not remembered.
    // Thereafter (after [BACK]) we return to the specific translation just
    // like things worked before 'WordLinks' was manually chosen.
    if ( 'WordLinks' == translation )
        {
        translation = wlx.wlx_translationOld
        }

    if ( translation && ('WordLinks' != translation ))
        {
        save +=  'translation=' + encodeURIComponent(translation) + '|'
        }

    save += '; max-age=' + (60*60*24*365); // 1 year
    save += '; path=/'
    //save += '; domain=spiritandtruth.org'

    //alert( 'cookie save ' + save )
    document.cookie = save
    }

readCookie = function( tag )
   {
   var cookie= document.cookie;
   if ( cookie ) 
       {
       //alert( 'cookie read ' + cookie );
       var crumbs = cookie.split( ';' );
       //alert( 'crumbs ' + crumbs );
       var tagValue;
       for( var i = 0; i < crumbs.length ; i++ ) {
           var parts = crumbs[i].split( '|' );
           //alert( 'parts ' + parts );
           for ( var j = 0; j < parts.length ; j++ )
               {
                var pairs = parts[j].split( '=' );
                if( tag == pairs[0] ) 
                   {
                   // Save the last (rightmost) matching tag which
                   // represents the latest setting in cases where several
                   // copies of the tag are still around in an old cookie.
                   tagValue = decodeURIComponent(pairs[1]);
                   }
               }
           }
       return tagValue;
       }
   return undefined
   }


