function photoClicked(itemVal) {
// Check to see if snapshot or slideshow viewer selected
// 1 = snapshot, 2 = slide show
  document.photoForm.item.value = itemVal;
  if (viewerTest() == 1)  {
    var sub = parseInt(itemVal,10) - 1;
    if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(3) != "")  {
      specWidth = document.photoSpecs[sub].value.slice(3,7);
      specHeight = document.photoSpecs[sub].value.slice(8,12);
    }
    else  {
      specWidth = "2500";
      specHeight = "2500";
    }
    openSnapshot(itemVal,specWidth,specHeight);
  }
  else  {
    poparray[popsub] = window.open("viewfrm.htm","viewFrame",
      "toolbar=no,location=no,directories=no,status=yes," +
      "menubar=no,scrollbars=yes,resizable=yes," +
      "dependent=no,left=1,top=1," +
      "width=" + (screen.availWidth - 13) + ",height=" + (screen.availHeight - 51));
    popsub++;
  }
}

function openSnapshot(photoNum,photoWidth,photoHeight) {
  var windowName = document.photoForm.prefix.value + photoNum;
  var bars = 'no';
  document.photoForm.item.value = photoNum;
  if (!numeric(photoWidth) || !numeric(photoHeight))  {
    photoWidth = screen.availWidth - 140;
    photoHeight = screen.availHeight - 170;
    bars = 'yes'
  } 
// increase height & width to allow for border browser leaves 
// between inner edge of window and outer edge of full width
// table. Also increase height even more to allow for caption
// and exit icon.
  photoWidth = parseInt(photoWidth,10) + 20;
  photoHeight = parseInt(photoHeight,10) + 80;
// add more depth for captions if the photo is narrow
  if (photoWidth < 380)  {
    photoHeight = photoHeight + 10;
  } 
  if (photoWidth < 350)  {
    photoHeight = photoHeight + 20;
  } 
// Now that we have determined the ideal height and 
// width for the new window, check the screen 
// resolution and reduce the window dimensions if 
// necessary.
  if (photoWidth > (screen.width - 80))  {
    photoWidth = screen.width - 80;
    bars = "yes";
  }
  if (photoHeight > (screen.height - 80))  {
    photoHeight = screen.height - 80;
    bars = "yes";
  }
  windowWidth = photoWidth.toString();
  windowHeight = photoHeight.toString();
  var left = "40";
  if (photoWidth < 400)  {
    left = "100"
  }
  poparray[popsub] = window.open("snapshot.htm",windowName,
     "toolbar=no,location=no,directories=no,status=no," +
     "menubar=no,scrollbars=" + bars + ",resizable=yes," +
     "dependent=no,left=" + left + ",top=20," +
     "width=" + windowWidth + ",height=" + windowHeight);
  popsub++;
}

//Default to snapshot style viewer unless slide
//show button is present and checked
function viewerTest ()  {
  if (document.photoForm.viewer_type[1] == null)  {
    return 1;
  }
  else  {
    if (document.photoForm.viewer_type[1].checked)  {
      return 2;
    }
    else  {
      return 1;
    }
  }
}
