/***************
 * image popup *
 ***************/

PWin = null;

PWinHeight = 550;
PWinWidth = 750;
//make sure this one is kept synchronised with the page margins in view.php
PWinMargin = 0;

function pictureOpen(pname)
{
  pictureClose();

  PWin = window.open('view.php?n='+pname+'&resize=true','PWin','width='+PWinWidth+',height='+PWinHeight+',scrollbars=0,toolbars=0,resizable=1');
  PWin.moveTo(0,0);
  PWin.focus();
  return false;
}

function pictureClose()
{
  if (PWin)
    PWin.close();
}

function FitPic() {
//iWidth and iHeight are window height and width specified in gallery.js, minus page margins
  iWidth = PWinWidth - (2 * PWinMargin);
  iHeight = PWinHeight - (2 * PWinMargin);
  iWidth = document.images[0].width - iWidth;
  iHeight = document.images[0].height - iHeight;
  window.resizeBy(iWidth, iHeight);
  self.focus();
}
