// copyright 2000 greggman
function mainbody_onresize()
{
      var scrnWidth  = defPicWidth;
      var scrnHeight = defPicHeight;

      var newWidth  = picWidth;
      var newHeight = picHeight;

      var mode = 0;

      if (document.body)
      {
         scrnWidth  = document.body.clientWidth;
         scrnHeight = document.body.clientHeight;
         mode = 1;
      }
      else if (window.innerWidth)
      {
         scrnWidth  = window.innerWidth;
         scrnHeight = window.innerHeight;
         mode = 2;
      }

      // this is incase there is a border
      scrnWidth  += widthAdjust;
      scrnHeight += heightAdjust;

      if (newWidth > scrnWidth)
      {
         newHeight = (newHeight * scrnWidth) / newWidth;
         newWidth  = scrnWidth;
      }

      if (newHeight > scrnHeight)
      {
         newWidth  = (newWidth * scrnHeight) / newHeight;
         newHeight = scrnHeight;
      }

      newWidth  = Math.floor(newWidth);
      newHeight = Math.floor(newHeight);

      if (mode == 1)
      {
         thepicture.width = newWidth;
         thepicture.height = newHeight;
      }

      return true;
}
