// Our first try works on Netscape 4 and up and most other non-IE browsers.  It
// may not account for the presence of scroll bars, so to be safe, we assume we have
// 30 fewer pixels to work with.
var inwidth = window.innerWidth ? window.innerWidth - 30 : 0;
// If that didn't work, this should do the job.  It works on IE4 and up, and most others, too.
if (inwidth == 0) inwidth = document.body.clientWidth ? document.body.clientWidth : 610;

// imagewidth:  number of images we can fit across one page.
//
// We assume a 100-pixel image takes 110 pixels, including table and padding.  We assume
// the table itself eats 50 pixels.  These should be conservative guesses.  If the
// window is unreasonably small, we will display 4 columns anyway, as they'll have little
// luck viewing the images unless they make the window at least that large.
var imagewidth = Math.max(4, Math.floor((inwidth - 50) / 110));

// columncounter:  how many columns we've displayed, not including the
// next image
var columncounter = 0;

// This function will be called after every image to break to a new table
// row if necessary
function rowbreak () {
   // Time to start a new row?
   if (++columncounter >= imagewidth) {
      document.writeln ("</tr><tr>");
      columncounter = 0;
   }
}
