 // v_general.js
 //             {StylesDebugMisc.js}  {MultimediaPhotos_queryJpgJpegFile.rex}  {zz_writeSingletonSkeletons.html} {Html_checkMyHtmlGroup.rex}  {Net_updateMperspectivesWebSite.rex}

var  _v_debug_amLocalTf = window.location.protocol=='file:';
var  _v_cc_cookie_name = "v_Single_ColorNumber";

 // --------------------------------------------------------------------------------------------------------------------
 // :h- Defining paintings

function _v_paintingObj( maxNCm, width, height, fn, title, location, medium) {                  // :h- ctor

        var  debug_scale = 1.00;                                                                // Used to play with sizes

        this.m_maxNCm = debug_scale * maxNCm;                                                   // Desired length of the longer size
        this.m_width = width;
        this.m_height = height;
        this.m_fn = fn;
        this.m_title = title;                                                                   // Title
        this.m_location = location;                                                             // E.g., "Taos, New Mexico"
        this.m_medium = medium;                                                                 // E.g., "Collage and watercolor"
        // No return
}

 // Use:  MultimediaPhotos_queryJpgJpegFile /showSize fid
if( v_group == "two") {
  var  _xx_painting_infos =
    [ new _v_paintingObj(  8.0, 230,360 , "two_A_Well_Lighted_Place_Antelope_Canyon"   , "A Well Lighted Place, Antelope Canyon"  , "Arizona"                  , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 233,360 , "two_Rain_Coming_This_Way_Grand_Canyon"      , "Rain Coming this Way, Grand Canyon"     , "Arizona"                  , "Watercolor on handmade paper"     )
    , new _v_paintingObj(  8.0, 256,360 , "two_Fulling_Mill_of_the_Mission_Santa_Ines" , "Fulling Mill of the Mission Santa Ines" , "Solvang, California"      , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 264,365 , "two_Hiking_into_the_Narrows_Zion"           , "Hiking into the Narrows"                , "Zion National Park, Utah" , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 265,360 , "two_Madame_Rosinka_Palm_Reader"             , "Madame Rosinka - Palm Reader"           , "Santa Barbara"            , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 270,360 , "two_Cactus_Blooms_in_Zion"                  , "Cactus Blooms in Zion"                  , "Utah"                     , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 270,360 , "two_Showing_Their_Colors_Lotusland"         , "Showing Their Colors, Lotusland"        , "Santa Barbara"            , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 272,360 , "two_Tower_on_the_Presidio_Building"         , "Tower on the Presidio Building"         , "Santa Barbara"            , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 248,360 , "Fantasy_on_Canyon_Road_Santa_Fe"            , "Fantasy on Canyon Road, Santa Fe"       , "New Mexico"               , "Watercolor"                       )
/** , new _v_paintingObj(  8.0, 381,504 , "Tower_on_the_Presidio_Building"             , "Tower on the Presidio Building"         , "Santa Barbara"            , "Watercolor"                       ) dup **/
    , new _v_paintingObj(  8.0, 268,360 , "Vedanta_Path"                               , "Vedanta Path"                           , "Montecito"                , "Watercolor with gouache"          )
   /* Wide ... */
    , new _v_paintingObj(  8.0, 360,129 , "two_Desert_Mist_Arizona"                    , "Desert Mist"                            , "Arizona"                  , "Watercolor with gouache"          )
    , new _v_paintingObj(  8.0, 360,245 , "two_John_Fords_Point_Monument_Valley"       , "John Ford's Point, Monument Valley"     , "Utah"                     , "Watercolor and gouache"           )
    , new _v_paintingObj(  8.0, 360,262 , "two_Morning_Glow_on_Rock_Creek_Bay"         , "Morning Glow on Rock Creek Bay"         , "Lake Powell, Utah"        , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,265 , "two_No_38_Abiquiu"                          , "#38, Abiquiu"                           , "New Mexico"               , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,265 , "two_Pots_at_the_Mercado_Santa_Fe"           , "Pots at the Mercado, Santa Fe"          , "New Mexico"               , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,267 , "two_Backstreet_Textures_Jerome"             , "Backstreet Textures, Jerome"            , "Arizona"                  , "Watercolor with gouache"          )
    , new _v_paintingObj( 10.0, 360,270 , "two_Standing_Strong_Lake_Powell"            , "Standing Strong, Lake Powell"           , "Utah"                     , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 489,360 , "two_On_the_High_Road_to_Taos"               , "On the High Road to Taos"               , "New Mexico"               , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,261 , "Havasu_River_Grand_Canyon"                  , "Havasu River, Grand Canyon"             , "Arizona"                  , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,268 , "Sunrise_Flight_Monument_Valley"             , "Sunrise Flight, Monument Valley"        , "Utah"                     , "Watercolor"                       )
    , new _v_paintingObj(  8.0, 360,238 , "Valley_View_Santa_Ynez"                     , "Valley View, Santa Ynez"                , "Santa Ynez Valley"        , "Watercolor"                       )
    ];
}
if( v_group == "one") {
  var  _xx_painting_infos =
    [ new _v_paintingObj( 12.0,  85,120 , "one_Ah_I_Remember_Venice"                   , "Ah, I Remember Venice"                  , ""                         , "Watercolor"                       )
    , new _v_paintingObj(  8.0,  57, 80 , "one_Stone_Patterns_at_Palatki"              , "Stone Patterns at Palatki"              , ""                         , "Watercolor, gouache, gesso, sand" )
    , new _v_paintingObj(  8.0,  58, 80 , "one_Sedona_Wall_Pattern"                    , "Sedona Wall Pattern"                    , ""                         , "Watercolor and gouache"           )
    , new _v_paintingObj(  8.0,  59, 80 , "one_Ancient_Wood_and_Stone_Karnak"          , "Ancient Wood and Stone, Karnak"         , ""                         , "Watercolor"                       )
    , new _v_paintingObj(  8.0,  59, 80 , "one_Numero_Diacisette_Roma"                 , "Numero Diacisette, Roma"                , ""                         , "Watercolor and gouache"           )
    , new _v_paintingObj(  8.0,  60, 80 , "one_Rooms_with_an_Ocean_View_Sorrento"      , "Rooms with an Ocean View, Sorrento"     , ""                         , "Pen &amp; Wash"                   )
   /* Square */
    , new _v_paintingObj(  3.5,  10, 10 , "one_Sundown"                                , "Sundown"                                , ""                         , "Collage and watercolor"           )
   /* Wide */
    , new _v_paintingObj(  8.0,  80, 27 , "one_Cod_Fishing_Cabins_on_Lofoten_Island"   , "Cod Fishing Cabins on Lofoten Island"   , ""                         , "Watercolor"                       )
    , new _v_paintingObj(  8.0,  80, 56 , "one_Golden_Fields_Sicily"                   , "Golden Fields, Sicily"                  , ""                         , "Watercolor and gouache"           )
    , new _v_paintingObj(  8.0,  80, 56 , "one_Textures_on_the_Mission_Fountain"       , "Textures on the Mission Fountain"       , ""                         , "Watercolor"                       )
    , new _v_paintingObj(  8.0,  80, 59 , "one_Morning_Silhouette_Prague"              , "Morning Silhouette, Prague"             , ""                         , "Watercolor"                       )
    , new _v_paintingObj(  8.8,  80, 60 , "one_Irish_Farm"                             , "Irish Farm"                             , ""                         , "Collage and watercolor"           )
    ];
}

 // --------------------------------------------------------------------------------------------------------------------
 // :h- Support routines

function  BrowserCookies_getCookieVal(wantCookieName) {                                         // :h- From OurInitial.js
                              //alert('is: document.cookie: ' + document.cookie);
        var  wCNE = wantCookieName + "=";
        var  wCNENC = wCNE.length;
        var  gotCookiesNc = document.cookie.length;
        var  gotCookieNameIc = 0;
        while( gotCookieNameIc < gotCookiesNc) {                                                // Per crumb (a name=val pair)
          var  possGotCookieValIc = gotCookieNameIc + wCNENC;
                              //alert( "Checking: " + document.cookie.substring(gotCookieNameIc, possGotCookieValIc));
          if( document.cookie.substring(gotCookieNameIc, possGotCookieValIc) == wCNE) {         // Found
            var  gotCookieValEic = document.cookie.indexOf( "; ", possGotCookieValIc);
            if( gotCookieValEic == -1)
              gotCookieValEic = document.cookie.length;
            return unescape(document.cookie.substring(possGotCookieValIc, gotCookieValEic));    // <=========
          }
          var  gotCookieValEic = document.cookie.indexOf( "; ", gotCookieNameIc);               // (Not from possGotCookieValIc)
          if( gotCookieValEic == -1)                                                            // No more crumbs
            return null;                                                                        // <=========
          gotCookieNameIc = gotCookieValEic + 2;                                                // 2 == length('; ')
        }
}

function BrowserCookies_setCookieVal( wantCookieName, value, /*optional:*/ expDate, path, domain, secure ) {  // :h- From OurInitial.js
        if( secure!=undefined && secure!=true && secure!=false)
          alarm('*** BrowserCookies_setCookieVal -- secure='+secure);

        var  pref = wantCookieName + "=" + escape(value)
        var  suf =
          ((expDate == undefined) ? ""         : ("; expires=" + expDate.toGMTString())) +
          ((path    == undefined) ? ""         : ("; path=" + path)) +
          ((domain  == undefined) ? ""         : ("; domain=" + domain)) +
          ((secure  == true     ) ? "; secure" : "");
                              //alert( pref);
                              //alert( suf);
                              //alert('was: document.cookie: ' + document.cookie);
        document.cookie = pref+suf;                                                             // Add or update _one_ of the cookies
                              //alert('now: document.cookie: ' + document.cookie);
                              //alert("document.cookie ...");
                              //alert(document.cookie);
        var  newValue = BrowserCookies_getCookieVal(wantCookieName);
        if( newValue != value)                                                                  // If oops
          alert( "*** BrowserCookies_setCookieVal = " + newValue + " !=" + value);
}

function setCookieUntilTomorrow( name, value) {                                                 // :h- From OurInitial.js
        var  expTomorrow = new Date;
        expTomorrow.setDate( 1 + expTomorrow.getDate());                                        // (Handled ok by Javascript even in December) -- The 1st of the month
        expTomorrow.setHours(1);                                                                // A bit after midnight
        BrowserCookies_setCookieVal( name, value, expTomorrow);
}

 // E.g.,  _v_dumpObject(temp.currentStyle,'font')
function _v_dumpObject(id,testPref) {                                                           // :h- !!!! put in library
        var key;
      //lwrh('<span style="font-family:courier">')  // style layout-grid-type:fixed does not work
        var  keys = "";
        for( key in id) {
          if( key.substr(0,testPref.length) == testPref)
            if( typeof id[key] == "function")
              keys = keys + '  ' + key + '(...)..."';
            else
              keys = keys + '  ' + key + "(" + typeof id[key] + ")" + ': "' + id[key] + '"';
        }
        alert( "keys: " + keys);
      //lwrh('</span>')
}


 // :h- In v_general.js & \Ours\Webs\Here\BaseCss_msc.js
function BaseCss_getCssStyleValue( node, ieStylePropertyName, firefoxStylePropertyName) {       // :h-
        if (node.currentStyle)                                                                  // In Firefox
          var  value = node.currentStyle[ieStylePropertyName];
        else
          if (window.getComputedStyle)                                                          // In Internet Explorer
            var  value = document.defaultView.getComputedStyle(node,null).getPropertyValue(firefoxStylePropertyName);
          else
            var  value = '[none]';
        return value;
}


 // :h- In v_general.js & \Ours\Webs\Here\BaseCss_msc.js
function BaseCss_convertToPixels(_str, _context)                                                // :h- Converts "10cm" -> "50" -- !!!! put in library
{
        if (/px$/.test(_str)) { return parseInt(_str); }

        var  tmp = document.createElement('div');
        tmp.style.visbility = 'hidden';
        tmp.style.position = 'absolute';
        tmp.style.lineHeight = '0';

        if (/%$/.test(_str)) {                                                                  // Contains a "%", so cannot set borderTopWidth to it
          var  _context = _context.parentNode || _context;
          tmp.style.height = _str;
        }
        else {
          tmp.style.borderStyle = 'solid';
          tmp.style.borderBottomWidth = '0';
          tmp.style.borderTopWidth = _str;
        }

        if (!_context)
          _context = document.body;

        _context.appendChild(tmp);
        var px = tmp.offsetHeight;
        _context.removeChild(tmp);

                              //alert(px + " := BaseCss_convertToPixels(" + _str + ")")
        return px;
};


var  _v_browserDetect = {                                                                       // :hc- !!!! put in library
        init: function () {
                this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
                this.version = this.searchVersion(navigator.userAgent)
                        || this.searchVersion(navigator.appVersion)
                        || "an unknown version";
                this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function (data) {
                for (var i=0;i<data.length;i++) {
                        var dataString = data[i].string;
                        var dataProp = data[i].prop;
                        this.versionSearchString = data[i].versionSearch || data[i].identity;
                        if (dataString) {
                                if (dataString.indexOf(data[i].subString) != -1)
                                        return data[i].identity;
                        }
                        else if (dataProp)
                                return data[i].identity;
                }
        },
        searchVersion: function (dataString) {
                var index = dataString.indexOf(this.versionSearchString);
                if (index == -1) return;
                return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
        },
        dataBrowser: [
                {       string: navigator.userAgent,
                        subString: "OmniWeb",
                        versionSearch: "OmniWeb/",
                        identity: "OmniWeb"
                },
                {
                        string: navigator.vendor,
                        subString: "Apple",
                        identity: "Safari"
                },
                {
                        prop: window.opera,
                        identity: "Opera"
                },
                {
                        string: navigator.vendor,
                        subString: "iCab",
                        identity: "iCab"
                },
                {
                        string: navigator.vendor,
                        subString: "KDE",
                        identity: "Konqueror"
                },
                {
                        string: navigator.userAgent,
                        subString: "Firefox",
                        identity: "Firefox"
                },
                {
                        string: navigator.vendor,
                        subString: "Camino",
                        identity: "Camino"
                },
                {               // for newer Netscapes (6+)
                        string: navigator.userAgent,
                        subString: "Netscape",
                        identity: "Netscape"
                },
                {
                        string: navigator.userAgent,
                        subString: "MSIE",
                        identity: "Explorer",
                        versionSearch: "MSIE"
                },
                {
                        string: navigator.userAgent,
                        subString: "Gecko",
                        identity: "Mozilla",
                        versionSearch: "rv"
                },
                {               // for older Netscapes (4-)
                        string: navigator.userAgent,
                        subString: "Mozilla",
                        identity: "Netscape",
                        versionSearch: "Mozilla"
                }
        ],
        dataOS : [
                {
                        string: navigator.platform,
                        subString: "Win",
                        identity: "Windows"
                },
                {
                        string: navigator.platform,
                        subString: "Mac",
                        identity: "Mac"
                },
                {
                        string: navigator.platform,
                        subString: "Linux",
                        identity: "Linux"
                }
        ]

};

_v_browserDetect.init();

 // --------------------------------------------------------------------------------------------------------------------
 // :h- ----------------------------------------------------------------------------------------------------------------
 // :h- For zz_with_macros.html

var  v_ZZ_justImgs = false;                                                                     // :h- Initial value for external var

 // --------------------------------------------------------------------------------------------------------------------
 // :h- For zz_writeSingletonSkeletons.html

 // v_ZZ_writeSingletonSkeletons() generates single picture files.  Use it, then propagate into those files.
function  v_ZZ_writeSingletonSkeletons() {                                                      // :h- i: v_group -- For generating single picture files

          var  br = '<br>';
        document.write(  '<pre>' + br);

        for( var ii=0; ii!=_xx_painting_infos.length; ++ii) {                                   // Per painting
                              //alert( ii + " " + _xx_painting_infos[ii].m_fn);
          var  width = _xx_painting_infos[ii].m_width;
          var  height = _xx_painting_infos[ii].m_height;
          var  fn = _xx_painting_infos[ii].m_fn;
          var  title = _xx_painting_infos[ii].m_title;
                              //alert( ii + " title: " + title);
          var  paintingLocation = _xx_painting_infos[ii].m_location;
                              //alert( ii + " location: " + paintingLocation);
          var  medium = _xx_painting_infos[ii].m_medium;
                              //alert( ii + " medium: " + medium);

          document.write(  '-------------------------------------------------------'                                          +br);
          document.write(  'e .\\' + fn + '.html'                                                                             +br);
          document.write(  ''                                                                                                 +br);
          document.write(  ' &lt;!-- art\\' + fn + '.html --&gt;'                                                             +br);
          document.write(  ' &lt;!-- Copyright © 2008 Martha Inman Lorch --&gt;'                                              +br);
          document.write(  ''                                                                                                 +br);
          document.write(  ' &lt;!-- ........................... :h- XShared( Site-Top ................... --&gt;'            +br);
          document.write(  ' &lt;!-- ........................... :h- )XShared Site-Top ................... --&gt;'            +br);
          document.write(  ''                                                                                                 +br);
          document.write(  '&lt;title&gt;' + title + '&lt;/title&gt;'                                                         +br);
          document.write(  '&lt;meta name="description" content="Shows Martha Inman Lorch\'s painting \'' + title + '\'"&gt;' +br);
          document.write(  '&lt;meta name="keywords" content="Martha Inman Lorch,painting,' + title + '"&gt;'                 +br);
          document.write(  '&lt;script type="text/javascript"&gt;var v_group = "' + v_group + '";&lt;/script&gt;'             +br);
          document.write(  ''                                                                                                 +br);
          document.write(  ' &lt;!-- ........................... :h- XShared( Art-Singles-Top ............ --&gt;'            +br);
          document.write(  ' &lt;!-- ........................... :h- )XShared Art-Singles-Top ............ --&gt;'            +br);
          document.write(  '              ' + title                                                                           +br);
          document.write(  ' &lt;!-- ........................... :h- XShared( Art-Singles-Mid-1 ............ --&gt;'          +br);
          document.write(  ' &lt;!-- ........................... :h- )XShared Art-Singles-Mid-1 ............ --&gt;'          +br);
          document.write(  '              &lt;img id=_resize_img_id class=v_Single_img'                                       +br);
          document.write(  '                  src="images/' + fn + '.jpg" alt="painting" title="' + title + '" width="' + width + '" height="' + height + '"&gt;'  +br);
          document.write(  ' &lt;!-- ........................... :h- XShared( Art-Singles-Mid-2 ............ --&gt;'          +br);
          document.write(  ' &lt;!-- ........................... :h- )XShared Art-Singles-Mid-2 ............ --&gt;'          +br);
          var  cc_sep = ' -- ';
          var  xx = '';
          if( paintingLocation != "")
            xx = xx + cc_sep + 'Location: ' + paintingLocation;
          if( medium != "")
            xx = xx + cc_sep + 'Medium: ' + medium;
          if( xx != "")
          document.write(  '                ' + xx.substr(4)                                                                  +br);
          document.write(  ' &lt;!-- ........................... :h- XShared( Art-Singles-Bot ............ --&gt;'            +br);
          document.write(  ' &lt;!-- ........................... :h- )XShared Art-Singles-Bot ............ --&gt;'            +br);
          document.write(  ''                                                                                                 +br);
        }
        document.write(  '</pre>' + br);

}

 // --------------------------------------------------------------------------------------------------------------------
 // :h- For Single-Painting pages

var  _v_urlPref;                                                                                // :h-


function  _v_Single_getUrlFn(url) {                                                             // :h- o: _v_urlPref
        var  ic = url.lastIndexOf("/");
        _v_urlPref = window.location.href.substr(0,ic+1);
        var  neEtc = window.location.href.substr(ic+1) + "#";
        var  ic = neEtc.indexOf("#");
        var  nex = neEtc.substr(0,ic);
        var  ic = nex.indexOf(".html");
        var  fn = nex.substr(0,ic);
        return fn;
}

function  _v_Single_findPaintingFnDcl( wantFn) {                                                // :h-
                              //alert( "_v_Single_findPaintingFnDcl(" + wantFn + ")");
        for( var ii=0; ii!=_xx_painting_infos.length; ++ii) {                                   // Per painting
                              //alert( ii + " " + _xx_painting_infos[ii].m_fn);
          if( _xx_painting_infos[ii].m_fn.toUpperCase() == wantFn.toUpperCase())
            return ii;                                                                          // <=========
        }
        alert( " ** Painting fn not found: " + wantFn + " -- v_group: " + v_group);
}

function  v_Single_goToHome() {                                                                 // :h-
        if( v_group == "one") {
          window.location.href = 'index_01.html';                                               // !!! why doesn't this work?
        }
        else
          window.location.href = 'index.html';
        return false;
}


function  v_Single_goToNext() {                                                                 // :h-
        var  fn = _v_Single_getUrlFn(window.location.href);                                     // o: _v_urlPref
        var  ii = _v_Single_findPaintingFnDcl(fn);
        var  nextIx = ii+1;
        if( nextIx == _xx_painting_infos.length)                                                // Wrapping
          nextIx = 0;                                                                           // Go to beginning
        next_ne = _xx_painting_infos[nextIx].m_fn + ".html";
        var  nextUrl = _v_urlPref + next_ne;
                              //alert( "-> " + nextIx + " " + nextUrl);
        window.location.href = nextUrl;
                              //alert( '(' + window.location.href + ')');
        return false;                                                                           // false => browser shouldn't use target URL
}

function  v_Single_goToPrev() {                                                                 // :h-
        var  fn = _v_Single_getUrlFn(window.location.href);                                     // o: _v_urlPref
        var  ii = _v_Single_findPaintingFnDcl(fn);
                              //alert( ii + " " + _xx_painting_infos[ii].m_fn);
        if( ii == 0)                                                                            // Wrapping
          var  nextIx = _xx_painting_infos.length-1;                                            // Go to end
        else
          nextIx = ii-1;
        var  next_ne = _xx_painting_infos[nextIx].m_fn + ".html";
        var  nextUrl = _v_urlPref + next_ne;
                              //alert( "-> " + nextIx + " " + nextUrl);
        window.location.href = nextUrl;
                              //alert( '(' + window.location.href + ')');
        return false;                                                                           // false => browser shouldn't use target URL
}

 // ------------------------------------

var  xx_v_pendingTimeout = undefined;
var  _v_origYVsXRatio = undefined;                                                              // Avoids problems with compounded errors
                                var  xx_dev_was = '';

function  _v_Single_resizeImage() {                                                             // :h- i: _v_Single_scaleFactor _v_debug_Single_tdNode
                              //alert( "_v_Single_resizeImage -> _v_Single_scaleFactor: " + _v_Single_scaleFactor);
                                debugTrace = "";

        xx_v_pendingTimeout = undefined;
        if( _v_origYVsXRatio == undefined) {                                                    // First sizing
          _v_origImgYPx = _v_Single_imgNode.height;
          _v_origImgXPx = _v_Single_imgNode.width;
          _v_origYVsXRatio = _v_origImgYPx / _v_origImgXPx;
          _v_origUnchangeableUsedYNPx = _v_Single_tableNode.offsetHeight + _v_Single_headerNode.offsetHeight - _v_origImgYPx;
 //  __ 2008/ 6/17
 // |             _v_origUnchangeableUsedXNPx = _v_Single_tableNode.offsetWidth - _v_origImgXPx;
 //  ¯¯
          var  borderWidthNAny = BaseCss_getCssStyleValue(_v_Single_imgNode, 'borderLeftWidth', 'border-left-width');
                              //alert( borderWidthNAny);
                              //alert( ': ' + _v_Single_imgNode);
                              //alert( 's: ' + _v_Single_imgNode.borderLeftStyle);
                              //alert( 'ws: ' + _v_Single_imgNode.borderLeftWidthStyle);
                              //alert( 'w: ' + _v_Single_imgNode.borderLeftWidth);
 //  __ 2008/ 6/17
 // |             if( borderWidthNAny.substr(borderWidthNAny.length-2,2) == "px")
 // |               borderWidthNAny = borderWidthNAny.substr(0,borderWidthNAny.length-2);
 //  ¯¯
          var  borderWidthNPx = BaseCss_convertToPixels(borderWidthNAny);
                              //alert( borderWidthNAny);
          _v_origUnchangeableUsedXNPx = 2 * 2 * borderWidthNPx;                                 // Leave room for border + same width empty space on 2 sides
        }
                                var  debugTrace = debugTrace + " _v_origImgYPx: " + _v_origImgYPx + " _v_origImgXPx: " + _v_origImgXPx;

                              //dev_is = "doc.cw: " + window.document.body.clientWidth + "  tn.ow: " + _v_Single_tableNode.offsetWidth + " rnw: " + _v_origImgXPx;
                              //alert( "dev_is: " + dev_is + " <-- xx_dev_was: " + xx_dev_was);
                              //xx_dev_was = dev_is;
                              //alert( 'window.document.body.clientHeight: ' + window.document.body.clientHeight
                              //    + ' _v_Single_tableNode.offsetHeight: ' + _v_Single_tableNode.offsetHeight
                              //    + ' _v_Single_headerNode.offsetHeight: ' + _v_Single_headerNode.offsetHeight );

        var  availableImgYNPx = window.document.body.clientHeight - _v_origUnchangeableUsedYNPx;
        var  availableImgXNPx = window.document.body.clientWidth - _v_origUnchangeableUsedXNPx;

        var  useImgEitherNPx = Math.min( availableImgYNPx, availableImgXNPx);

        var  maxImgYNPx = Math.max( useImgEitherNPx, _v_minYNPx);
        var  maxImgXNPx = Math.max( useImgEitherNPx, _v_minXNPx);

        var  maxNewVsOldRatioY = maxImgYNPx / _v_origImgYPx;
        var  maxNewVsOldRatioX = maxImgXNPx / _v_origImgXPx;

        var  useNewOldRatio = Math.min( maxNewVsOldRatioY, maxNewVsOldRatioX);
        _v_Single_imgNode.width = Math.round( _v_Single_scaleFactor * useNewOldRatio * _v_origImgXPx - 0.5);
        _v_Single_imgNode.height = Math.round( _v_origYVsXRatio * _v_Single_imgNode.width - 0.5) - 1;  // The -1 is needed

                                debugTrace = debugTrace
                                    + " unchangeableUsed*NPx: "  + _v_origUnchangeableUsedYNPx + " " + _v_origUnchangeableUsedXNPx
                                    + " availableImg*NPx: "      + availableImgYNPx + " " + availableImgXNPx

                                    + " useImgEitherNPx: "    + useImgEitherNPx
                                    + " maxImg*NPx: "            + maxImgYNPx + " " + maxImgXNPx
                                    + " maxNewVsOldRatio*: "     + maxNewVsOldRatioY + " " + maxNewVsOldRatioX
                                    + " useNewOldRatio: "        + useNewOldRatio
                                    + " _v_Single_imgNode.width&.height: " + _v_Single_imgNode.width + " " + _v_Single_imgNode.height
                                    ;
                                if( _v_debug_amLocalTf) {
                              //  _v_debug_Single_tdNode.innerHTML = debugTrace;
                                }
}
function  _v_Single_schedResizeImage() {                                                        // :h- Only resize occasionally so errors don't compound much
        if( xx_v_pendingTimeout == undefined) {
          var  inv = '_v_Single_resizeImage();';
          xx_v_pendingTimeout = window.setTimeout(inv, 200);
        }
}

function  v_Single_handleResizedWindow() {                                                      // :h-
        _v_Single_schedResizeImage( 'resize_img_id', 'resize_table_id');

}
function  v_Single_handleOnInit() {                                                             // :h-
        _v_minYNPx = 100;
        _v_minXNPx = 100;
        _v_Single_scaleFactor = 1.0;

                                if( _v_debug_amLocalTf) {
                              //  _v_debug_Single_tdNode.innerHTML = "_v_Single_imgNode.height: " + _v_Single_imgNode.height + " _v_Single_imgNode.width: " + _v_Single_imgNode.width + " y/x: " + (_v_Single_imgNode.height/_v_Single_imgNode.width);
                                }

        _v_Single_resizeImage();                                                                // i: _v_Single_scaleFactor _v_debug_Single_tdNode
}

function  v_Single_makeLarger() {                                                               // :h-
        _v_Single_scaleFactor = 1.5 * _v_Single_scaleFactor;
        _v_Single_resizeImage();                                                                // i: _v_Single_scaleFactor _v_debug_Single_tdNode
        return false;                                                                           // false => browser shouldn't use target URL
}

function  v_Single_makeSmaller() {                                                              // :h-
        _v_Single_scaleFactor = _v_Single_scaleFactor / 1.5;
        _v_Single_resizeImage();                                                                // i: _v_Single_scaleFactor _v_debug_Single_tdNode
        return false;                                                                           // false => browser shouldn't use target URL
}

function  _v_Single_debug_setThisColor(colorName) {                                             // :h-
        if( ! _v_debug_Single_displayColorSelector)
          return;                                                                               // <=========

                              //alert( " -> _v_Single_debug_setThisColor -- colorName: " + colorName);
        try {
          if( _v_browserDetect.browser == "Firefox") {                                          // Firefox
                              //alert( "_v_Single_imgNode.style.currentStyle: " + _v_Single_imgNode.style.currentStyle);
                              //alert( "_v_Single_imgNode.style: " + _v_Single_imgNode.style);
                              //alert( "_v_Single_imgNode: " + _v_Single_imgNode);

                              //_v_dumpObject( _v_Single_imgNode.style, "");

            _v_Single_imgNode.style['borderColor'] = "#" + colorName;
          }
          else {                                                                                // IE?
                              //_v_dumpObject( _v_Single_imgNode.style, "");
            _v_Single_imgNode.style.borderColor = "#" + colorName;
          }
          setCookieUntilTomorrow( _v_cc_cookie_name, colorName);
          _v_debug_Single_colorNameNode.value = colorName;
        }
        catch(ex) {
                                alert( "Invalid hex color number: " + colorName + " -- Must be 3 hex digits -- Exception: " + ex);
        }
                              //_v_dumpObject( _v_debug_Single_colorNameNode, "");
}

function  v_Single_debug_setColor() {                                                           // :h-
        if( ! _v_debug_Single_displayColorSelector)
          return;                                                                               // <=========
                                var  colorName = _v_debug_Single_colorNameNode.value;
                              //alert( " -> v_Single_debug_setColor -- colorName: " + colorName);
                                _v_Single_debug_setThisColor(colorName);
}

 // --------------------------------------------------------------------------------------------------------------------
 // :h- For Summary pages

 // E.g., <script type='text/javascript'>v_Summary_table_showPainting('one_Sundown');</script>
 //
function  v_Summary_table_showPainting( paintingFn) {                                           // :h-
                              //alert( "_v_Single_resizeImage -> " + paintingFn);
        var  ii = _v_Single_findPaintingFnDcl(paintingFn);
        var  paintingLongerCM      = _xx_painting_infos[ii].m_maxNCm;                           // Desired length of the longer size
        var  paintingXVsY          = _xx_painting_infos[ii].m_width / _xx_painting_infos[ii].m_height;  // Ratio of the number of pixels on each side
        var  paintingTitle         = _xx_painting_infos[ii].m_title;                            // Title
        var  paintingLocation      = _xx_painting_infos[ii].m_location;
        var  paintingMedium        = _xx_painting_infos[ii].m_medium;                           // E.g., "Collage and watercolor"

        if( paintingXVsY >= 1.0) {                                                              // Wider than high
          var  paintingXCm = paintingLongerCM;
          var  paintingYCm = paintingLongerCM / paintingXVsY;
        }
        else {                                                                                  // Higher than wide
          var  paintingXCm = paintingLongerCM * paintingXVsY;
          var  paintingYCm = paintingLongerCM;
        }

        var  debug_showHTML = true;
        var  debug_showHTML = false;
        if( debug_showHTML)
          var  br = "<br>";
        else
          var  br = "";

        if( v_ZZ_justImgs)
          var  imgAttrs = 'margin:0.1cm ; ';
        else
          var  imgAttrs = '';

        if( ! v_ZZ_justImgs) {
          document.write(  "  <table style='display:inline ; position:relative ; clear:none ; width:10% ; margin:0cm 0cm 0cm 0cm'>"+br);
          document.write(  "    <tr>"+br);
          document.write(  "      <td style='width:50%'>&nbsp;</td>"+br);
          document.write(  "      <td class=v_Gallery_image_td>"+br);
          document.write(  "        <div class=v_Gallery_image_div>"+br);
          document.write(  "          <a class=v_Gallery_image_a  href='http://www.mperspectives.com/art/" + paintingFn + ".html'>"+br);  // !! add tabindex=4
        }

        document.write(    "            <img class=v_Gallery_image_img title='" + paintingTitle + "' style='" + imgAttrs + " width:" + paintingXCm + "cm ; height:" + paintingYCm + "cm' src='images/" + paintingFn + ".jpg'>"+br);

        if( ! v_ZZ_justImgs) {
          document.write(  "          </a>"+br);
          document.write(  "        </div>"+br);
          document.write(  "        <a class=v_Gallery_text_a  href='http://www.mperspectives.com/art/" + paintingFn + ".html'>"+br);  // !! add tabindex=4
          document.write(  "          <div class=v_Gallery_title_div>" + paintingTitle + "</div>"+br);
          document.write(  "        </a>"+br);
          if( paintingLocation != "")
            document.write("        <div class=v_Gallery_location_and_medium_div>" + paintingLocation + "</div>"+br);
          document.write(  "        <div class=v_Gallery_location_and_medium_div>" + paintingMedium + "</div>"+br);
          document.write(  "      </td>"+br);
          document.write(  "      <td style='width:50%'>&nbsp;</td>"+br);
          document.write(  "    </tr>"+br);
          document.write(  "  </table>"+br);
        }
}

 // --------------------------------------------------------------------------------------------------------------------
 // :h- Unused

function  _unused_v_td_painting(paintingFn) {                                                   // :h-
                              //alert( "_v_Single_resizeImage -> " + paintingFn);
        document.write("<td>");
        v_Summary_table_showPainting(paintingFn);
        document.write("</td>");
}

function  _unused_v_tr_painting(paintingFn) {                                                   // :h-
                              //alert( "_v_Single_resizeImage -> " + paintingFn);
        document.write('<tr align="center">');
        _unused_v_td_painting(paintingFn);
        document.write("</tr>");
}

 // --------------------------------------------------------------------------------------------------------------------
 // :h- Am-Local Stuff for Both

function  v_Summary_handleEndOfBody() {                                                         // :h-
                              //alert("browser: " + _v_browserDetect.browser);
        if( _v_debug_amLocalTf)
          MPG_localize(_v_browserDetect.browser);
}


function  v_Contact_handleEndOfBody() {                                                         // :h-
                              //alert("browser: " + _v_browserDetect.browser);
        if( _v_debug_amLocalTf)
          MPG_localize(_v_browserDetect.browser);
}


function  v_Single_handleEndOfBody(headerId,resizeTableId,resizeImgId, firefoxFormId,ieFormId) {  // :h-
                              //alert("browser: " + _v_browserDetect.browser);

                                _v_debug_Single_displayColorSelector = false && _v_debug_amLocalTf;
                                if( _v_debug_Single_displayColorSelector) {
                                  alert("Selecting");
                                  _v_debug_Single_tdNode = document.getElementById('v_debugTdId');
                                  _v_debug_Single_tdNode.innerHTML =
                                      ( '<form action="" onsubmit="v_Single_debug_setColor()">'
                                      +    '<input id=v_Single_debugColorNameId name="red" size="4" maxlength="3" >'
                                      +    '<input type="button" value="Color" accesskey="c" onclick="v_Single_debug_setColor()">'
                                      +  '</form>'
                                      );
                                  _v_debug_Single_colorNameNode = document.getElementById('v_Single_debugColorNameId');
                                //alert(_v_debug_Single_colorNameNode);
                                }

        _v_Single_headerNode = document.getElementById(headerId);                               // The only node before the table which contains the image
        _v_Single_tableNode = document.getElementById(resizeTableId)                            // The 2nd of two nodes in the body -- Contains the image which is to be resized
        _v_Single_imgNode = document.getElementById(resizeImgId)                                // The image (in the table)

                                if( _v_debug_Single_displayColorSelector) {
                                  var  prev_cookie_number = BrowserCookies_getCookieVal(_v_cc_cookie_name);
                                  if( typeof prev_cookie_number != 'string' || prev_cookie_number.length != 3)
                                    var  prev_cookie_number = 'f00';                            // Red!
                                  _v_Single_debug_setThisColor(prev_cookie_number);
                                }

        if( _v_browserDetect.browser == "Firefox") {                                            // Firefox
          document.getElementById(firefoxFormId).style.display = 'block';
          document.getElementById(ieFormId).style.display = 'none';
        }
        else {                                                                                  // A browser not successfully tried -- E.g., IE 7.0
          document.getElementById(firefoxFormId).style.display = 'none';
          document.getElementById(ieFormId).style.display = 'block';
        }


        if( _v_debug_amLocalTf)
          MPG_localize(_v_browserDetect.browser);
}
 // --------------------------------------------------------------------------------------------------------------------

if( _v_debug_amLocalTf)
  document.write("<script type='text/javascript' src='../../Here/MPG_local.js'></script>");

 // ------------------------------------
 // eof