

  imgWinOpened = new Array();

  function imgWin(imgObj)
  {
    if (imgWinOpened[imgObj.src])
    {
      imgWinOpened[imgObj.src].close();
      imgWinOpened[imgObj.src] = null;
    }
    else
    {
      // try to determine width/height, if not specified on function call
      if (!imgObj.w || !imgObj.h)
      {
        var tmp = new Image();
        tmp.src = imgObj.src;
        imgObj.w = tmp.width;
        imgObj.h = tmp.height;
      }
      
      if (!imgObj.name)
      {
        imgObj.name = imgObj.src;
      }
  
      w = window.open(
        'about:blank',
        '_blank',
        'width='+imgObj.w+',height='+((imgObj.info?100:24)+parseInt(imgObj.h)));
      w.document.write(genImgBody(imgObj));
      w.document.title = imgObj.name;
      
      imgWinOpened[imgObj.src] = w;
    }
    
    return false;
  }
  
  

  /*
  **  genImgBody()
  **
  **    helper function for imgWin(), generates popup html
  **
  */

  function genImgBody(imgObj)
  {
    return '<html><body '
      + 'onkeypress="if(event.keyCode==27){if(opener && opener.imgWinOpened){opener.imgWinOpened[\''+imgObj.src+'\']=null;}self.close();}" '
      + 'style="margin:0px;background-color:#F5F5F5;font-family:sans-serif;overflow:hidden;'
      + (imgObj.bg ? 'background-image:url('+imgObj.bg+')' : '')
      + '" '
      + '>'
      + '<img '
      + (imgObj.alt ? 'alt="' + imgObj.alt + '" ' : '')
      + 'onmousedown="this.domove=1;this.curX=event.clientX;this.curY=event.clientY;" '
      + 'onmouseup="this.domove=0" '
      + 'onmousemove="if(this.domove){self.moveBy(event.clientX-this.curX, event.clientY-this.curY);}" '
      + 'ondragstart="window.event.returnValue=false" '
      + 'src='+(imgObj.bg?'/images/trans.gif':imgObj.src)+' '
      + (imgObj.w ? 'width='+imgObj.w+' '  : '')
      + (imgObj.h ? 'height='+imgObj.h+' ' : '')
      + 'style="border-bottom:1px solid black'
      + '" />'
      + '<div style="text-align:'+(imgObj.infoAlign?imgObj.infoAlign:'center')+';font-size:0.9em; border-bottom:0px solid red;height:80px;overflow-x:hidden;overflow-y:auto;" />'
      + (imgObj.info?imgObj.info:(imgObj.alt?imgObj.alt:''))
      + '</div>'
      + '<br />'
      + '<div style="position:absolute;left:0px;width:100%;bottom:0px;text-align:center;font-family:tahoma;font-size:12px;height:18px;cursor:hand;">'      + '<a onclick="if(opener && opener.imgWinOpened){opener.imgWinOpened[\''+imgObj.src+'\']=null;}self.close();">Sluit venster</a>'
      + '</div>'
      + '</body></html>';
  }



  /*
  **  fgResizeImg()
  **
  **    set width/height of imgtag (in correct proportions) to prevent
  **    ugly runtime resizing while imgs are loading
  **
  */
  
  function fgResizeImg(id, rW, rH, tW, tH)
  {
    var nW = tW;
    var nH = tH;
    if (rW > rH) { nH = rH / (rW/tW); }
    if (rH > rW) { nW = rW / (rH/tH); }
    if (document.getElementById)
    {
      if (document.getElementById(id))
      {
        with(document.getElementById(id).style)
        {
          width   = nW;
          height  = nH;
        }
      }
    }
    else if (document.all)
    {
      if (document.all[id])
      {
        with(document.all[id].style)
        {
          width   = nW;
          height  = nH;
        }
      }
    }
  }

