// Written by: Matthew Landseadel  07/05/00  landseadel@hotmail.com
// Updated by: Matthew Landseadel  08/29/00  landseadel@hotmail.com

   /* The ViewImage function opens a new browser window with the large image 
      and a button to close the window.  The window will be placed in the middle
      of the screen by calculating the position by using the screen properties.

      The function accepts the image filename, the size of the image, and the 
      title of the image as arguments.  Next, the height is increased.  Then, 
      the starting position for the new window is calculated based on the size
      of the screen and the size of the image window.  The function then opens
      the new window.
    */

   function ViewImage(ifile,ix,iy,ititle,idesc) { 
      ix = eval(ix + 8);
      // Calculates how many lines the idesc will need and adds that to the height of the window.
      iy = eval((Math.ceil(idesc.length/(ix/8.06))*20) + 60 + iy);

      // Centers the window starting coordinates in the center of the screen.
      var ixstart = Math.round((screen.availWidth - ix) / 2);
      var iystart = Math.round((screen.availHeight - iy) / 2);
      if (ixstart < 0){ ixstart = 0; }
      if (iystart < 0){ iystart = 0; }

      var win = window.open("","imageviewer","status,width=" + ix + ",height=" + iy + ",left=" + ixstart + ",top=" + iystart + ",scrolling=no,resizable=no,menubar=no,toolbar=no");

      win.document.open();
      win.document.writeln("<HTML><HEAD>");
      win.document.writeln("  <TITLE>" + ititle + "<\/TITLE>");
      win.document.writeln("<\/HEAD>");
      win.document.writeln("<BODY BGCOLOR='#FFFFFF' topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'>");
      win.document.writeln("<CENTER>");
      win.document.writeln("  <IMG SRC='" + ifile + "' BORDER='2' ALT='" + ititle + "'><BR>");
      win.document.writeln("  <TABLE BORDER='0' WIDTH='90%' CELLPADDING='0' CELLSPACING='0'>");
      win.document.writeln("     <TR><TD ALIGN='CENTER'>");
      win.document.writeln("     " + idesc);
      win.document.writeln("  <\/TD><\/TR><\/TABLE><BR>");
      win.document.writeln("  <A HREF='' ONCLICK='top.close();return false;'>");
      win.document.writeln("  <IMG SRC='images\/close.gif' BORDER='0' ALT='Close Window'><\/A>");
      win.document.writeln("<\/CENTER>");
      win.document.writeln("<\/BODY><\/HTML>");
      win.document.close();
   }
