  <!--
// ===================================================================================
//
// This software is a production of ZofX Systems (www.zofxsystems.com).
//
// Please keep this and related components in tact with these headers.
//
// If you wish to incorporate, modify, or adapt parts of this software,
// please include a courtesy acknowledgement such as "Portions of this software
// were developed by ZofX systems (www.zofxsystem.com).".
//
//===================================================================================
  function OpenZofXPictureViewer1(argJSNodeNumber, argPictureFile, argPictureTitle, argPictureWidthMax, argPictureHeightMax, argInitialWindowSize, argPictureFileFull, argPictureWidthFull, argPictureHeightFull, argInitialWindowSizeFull, argMinHMargins, argMinVMargins, argMarginsColor, argBorderWidth, argBorderColor, argCaption, argCaptionLines, argCaptionLineHeight, argCaptionFontFamily) {
    var qJSNodeNumber;
    var qPictureFile;
    var qPictureTitle;
    var qPictureWidthMax;
    var qPictureHeighthMax;
    var qInitialWindowSize;
    var qPictureFileFull;
    var qPictureWidthFull;
    var qPictureHeighthFull;
    var qInitialWindowSizeFull;
    var qMinHMargins;
    var qMinVMargins;
    var qMarginsColor;
    var qBorderWidth;
    var qBorderColor;
    var qCaption;
    var qCaptionLines;
    var qCaptionLineHeight;
    var qCaptionFontFamily;

    qJSNodeNumber = convertArgumentToQueryItem(argJSNodeNumber, "&n=", false);
    qPictureFile = convertArgumentToQueryItem(argPictureFile, "&f=", true);
    qPictureTitle = convertArgumentToQueryItem(argPictureTitle, "&t=", true);
    qPictureWidthMax = convertArgumentToQueryItem(argPictureWidthMax, "&pw=", false);
    qPictureHeightMax = convertArgumentToQueryItem(argPictureHeightMax, "&ph=", false);
    qPictureFileFull = convertArgumentToQueryItem(argPictureFileFull, "&ff=", true);
    qPictureWidthFull = convertArgumentToQueryItem(argPictureWidthFull, "&pwf=", false);
    qPictureHeightFull = convertArgumentToQueryItem(argPictureHeightFull, "&phf=", false);
    qInitialWindowSizeFull = convertArgumentToQueryItem(argInitialWindowSizeFull, "&sf=", false);
    qMinHMargins = convertArgumentToQueryItem(argMinHMargins, "&p=", false);
    qMinVMargins = convertArgumentToQueryItem(argMinVMargins, "&q=", false);
    qMarginsColor = convertArgumentToQueryItem(argMarginsColor, "&k=", false);
    qBorderWidth = convertArgumentToQueryItem(argBorderWidth, "&e=", false);
    qBorderColor = convertArgumentToQueryItem(argBorderColor, "&d=", false);
    qCaption = convertArgumentToQueryItem(argCaption, "&c=", true);
    qCaptionLines = convertArgumentToQueryItem(argCaptionLines, "&cl=", false);
    qCaptionLineHeight = convertArgumentToQueryItem(argCaptionLineHeight, "&ch=", false);
    qCaptionFontFamily = convertArgumentToQueryItem(argCaptionFontFamily, "&cf=", false);

    if (qJSNodeNumber == "") {argJSNodeNumber = 0; qJSNodeNumber = "&n=0"}
    if (qPictureWidthMax == "") {argPictureWidthMax = 300; qPictureWidthMax = "&pw=300"}
    if (qPictureHeightMax == "") {argPictureHeightMax = 300; qPictureHeightMax = "&ph=300"}
    var pictureHWRatio = Math.round((argPictureHeightMax / argPictureWidthMax) * 1000.0) / 1000.0;
    var qPictureHWRatio = "&r=" + pictureHWRatio;
    if (convertArgumentToQueryItem(argInitialWindowSize, "", false) == "") {
      if ((dInitialWindowSize[argJSNodeNumber] != "undefined") && (dInitialWindowSize[argJSNodeNumber] != null)) {
        argInitialWindowSize = dInitialWindowSize[argJSNodeNumber];
      }
      else {
        argInitialWindowSize = dInitialWindowSize[0];
      }
    }

    var reqWidthWindow;
    var reqHeightWindow;
    var estWidthBody;
    var estHeightBody;
    //some documentation says that window.open features width and height are the window size
    //in practice, width and height appear to be of the client or document body area
    if (pictureHWRatio > 1.0) {
      reqHeightWindow = Math.min(Math.round(screen.availWidth * argInitialWindowSize), screen.availHeight * 0.95);
      reqWidthWindow = Math.round(reqHeightWindow / pictureHWRatio);
    }
    else {
      reqWidthWindow = Math.round(screen.availWidth * argInitialWindowSize);
      reqHeightWindow = Math.min(Math.round(reqWidthWindow * pictureHWRatio), screen.availHeight * 0.95);
    }
    //estimate initial size of body in new window
    estWidthBody = reqWidthWindow;
    estHeightBody = reqHeightWindow;

    //var leftWindow;
    //var topWindow;
    //leftWindow = Math.round(screen.availWidth / 10);
    //topWindow = Math.round(screen.availHeight / 10);
    // + ' left=' + leftWindow + ' top=' + topWindow

    var features = 'width=' + reqWidthWindow + ', height=' + reqHeightWindow + ', resizable';	  //doesn't handle this properly in-line
    window.open("ZofXPictureViewer1.html?u=w" + qJSNodeNumber + qPictureFile + qPictureTitle + qPictureHWRatio + qPictureWidthMax + qPictureHeightMax + qMinHMargins + qMinVMargins + qMarginsColor + qBorderColor + qBorderWidth + qCaption + qCaptionLines + qCaptionLineHeight + qCaptionFontFamily + "&w=" + estWidthBody + "&h=" + estHeightBody + qPictureFileFull + qPictureWidthFull + qPictureHeightFull + qInitialWindowSizeFull, "", features);
  }
  function convertArgumentToQueryItem(arg, argQueryTag, argURLEncode) {
    if ((arg == "undefined") || (arg == null)) {
      return "";
    }
    else {
      if (!argURLEncode) {
        return argQueryTag + arg;
      }
      else {
        return argQueryTag + URLEncode(arg);
      }
    }
  }
  function URLEncode(argString) {
    //alert(argString);
    var newStr = argString;
    //do % first
    newStr = newStr.replace(/%/g, "%25");
    newStr = newStr.replace(/\//g, "%2F");
    newStr = newStr.replace(/ /g, "%20");
    newStr = newStr.replace(/"/g, "%22");
    newStr = newStr.replace(/#/g, "%23");
    newStr = newStr.replace(/&/g, "%24");
    newStr = newStr.replace(/'/g, "%27");
    newStr = newStr.replace(/,/g, "%2C");
    newStr = newStr.replace(/:/g, "%3A");
    newStr = newStr.replace(/;/g, "%3B");
    newStr = newStr.replace(/</g, "%3C");
    newStr = newStr.replace(/=/g, "%3D");
    newStr = newStr.replace(/>/g, "%3E");
    newStr = newStr.replace(/\?/g, "%3F");
    newStr = newStr.replace(/\[/g, "%5B");
    newStr = newStr.replace(/\\/g, "%5C");
    newStr = newStr.replace(/\]/g, "%5D");
    newStr = newStr.replace(/\^/g, "%5E");
    newStr = newStr.replace(/`/g, "%60");
    newStr = newStr.replace(/\{/g, "%7B");
    newStr = newStr.replace(/\|/g, "%7C");
    newStr = newStr.replace(/\}/g, "%7D");
    newStr = newStr.replace(/~/g, "%7E");
    return newStr;
  }
  // -->

