function resize_image (imageref)
  {
    var winwidth = 0;
    var size_available = 500;

    if (self.innerWidth) winwidth = self.innerWidth;
      else if (document.documentElement && document.documentElement.clientWidth) winwidth = document.documentElement.clientWidth;
        else if (document.body) winwidth = document.body.clientWidth;

    size_available = winwidth - document.getElementById('leftbar').offsetWidth - 80;

    // if (navigator.platform.indexOf('FreeBSD') !=-1) alert (imageref.width + " " + size_available);
    if (imageref.width > size_available)
      {
        var pc = Math.round (size_available / imageref.width * 10000) / 100;
        // if (navigator.platform.indexOf('FreeBSD') !=-1) alert (imageref.width);
        imageref._original_width=imageref.width;
        imageref._shrunk_width=size_available;
        imageref._shrunk_pc=pc;
        imageref._shrunk_status=1;
        imageref.style.width=size_available + 'px';
        if (imageref.previousSibling)
          {
            imageref.previousSibling.style.width=size_available + 'px';
            imageref.previousSibling.firstChild.nodeValue="Image reduced to " + pc + "% of its original size. Click this bar to restore to full size.";
            imageref.previousSibling.style.display = 'block';
          }
      }
  }

function toggle_image_size (imageref)
  {
    if (imageref.nextSibling)
      {
        if (imageref.nextSibling._shrunk_status == 1)
          {
            imageref.firstChild.nodeValue="Image at full-size. Click this bar to fit to window.";
            imageref.style.width=imageref.nextSibling._original_width + 'px';
            imageref.nextSibling.style.width=imageref.nextSibling._original_width + 'px';
            imageref.nextSibling._shrunk_status=0;
            imageref.style.display = 'block';
          }
         else
          {
            imageref.firstChild.nodeValue="Image reduced to " + imageref.nextSibling._shrunk_pc + "% of its original size. Click this bar to restore to full size.";
            imageref.style.width=imageref.nextSibling._shrunk_width + 'px';
            imageref.nextSibling.style.width=imageref.nextSibling._shrunk_width + 'px';
            imageref.nextSibling._shrunk_status=1;
            imageref.style.display = 'block';
          }
      }
  }