var popupWindow;

function popUpImage(imagePath)
{
   // Get the default screen height and screen width
   // in case the user doesn't have a window up already

   var defaultWidth = screen.width/2
   var defaultHeight = screen.height/2

   // Here, the check for null is required because the 
   // .closed attribute will not be present for a null
   // window and if the user closes the popup window, the
   // value will not be null, and the open function will
   // crash
 
   if (popupWindow != null)
   {
      if (!popupWindow.closed)
      {
         // Open window in existing frame and then give it 
         // the focus to make it come to the forefront to 
         // prevent the main window covering the subwindow.

         popupWindow.focus()
         popupWindow = window.open(imagePath, "IMG",
            "status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
      }
      else
      {
         // If the user closed their window, open them up a 
         // fresh new window. (uses same call as below...)

         popupWindow = window.open(imagePath, "IMG",
            "status=no,toolbar=no,location=no" +
            "scrollbars=yes,resizable=yes,width=" + defaultWidth +
            ",height=" + defaultHeight);
      }
   }
   else
   {
      // If this is the first window that they've opened,
      // Give it the default height and width to fit 
      // comfortably on a 800x600 screen.

      popupWindow = window.open(imagePath, "IMG",
         "status=no,toolbar=no,location=no" +
         "scrollbars=yes,resizable=yes,width=" + defaultWidth +
         ",height=" + defaultHeight);

   }
}

