
childWindow = new Object ; childWindow.closed = true

function showViewer(pageparams) {

/* FUNCTION TO OPEN/UPDATE THE SEPARATE LARGE-IMAGE VIEWER WINDOW

This functions builds a string containing the name of the standard viewer document
(ppview.htm) plus ? and a parameter string supplied via the function call (see <IMG> tags
below for the contents of the parameter string). It then uses this string to open or update
a separate large-image viewer window.

This is a slightly different version of the showViewer function to the one shown
in Web Workshop, PC Plus issue 156. It doesn't always open the viewer window, but
instead checks to see if it's already open. If it is, the function reloads the standard viewer
page into the window with a new parameter string, by updating its location.href property.

*/

// Put viewer document name and ? in front of supplied parameter string
var pagestring = "_ppview.htm?"+pageparams

if (childWindow.closed) {
   // Window isn't open, so open it with new document.
   openChildWindow(pagestring) 
   } else {
   // If window is already open, just change its document, then give it focus (i.e. bring it to the front of the screen)
   childWindow.window.location.href = pagestring
   focusChild()
   }

}

function openChildWindow (pagestring) {
// Close child window if currently open
// Note that the declaration of "childWindow" as an object (above) allows this test
// to be performed before the window has first been created, without causing a JavaScript error.

if (!childWindow.closed) {
  closeChild()}

childWindow = window.open(pagestring, "viewer", "scrollbars=yes")
}

function closeChild () {
if (! childWindow.closed) {
  childWindow.close()}
}

function focusChild() {
if (! childWindow.closed) {
  childWindow.focus()}
}

function blurChild() {
if (! childWindow.closed) {
  childWindow.blur()}
}


function closepage() {
closeChild()
}