PWin = null;

PWinHeight = 500;
PWinWidth = 500;
//make sure this one is kept synchronised with the page margins in showmap.php
PWinMargin = 5;

function windowOpen(purl,pwidth,pheight,pscroll)
{
  if (PWin)
    PWin.close();

  PWin = window.open(purl,'PWin','width='+pwidth+',height='+pheight+',scrollbars='+pscroll+',toolbars=0,resizable=1');
//  PWin.moveTo(0,0);
  PWin.focus();
  return false;
}

function pictureOpen(pname)
{
//  windowOpen('showmap.php?n='+pname+'&resize=true',PWinWidth,PWinHeight,0);
//  windowOpen('showmap.php?n='+pname+'&resize=true',800,600,1);
  windowOpen('images/figures/'+pname,800,600,1);
  PWin.moveTo(0,0);
  PWin.focus();
  return false;
}

function FitPic() {
//iWidth and iHeight are window height and width specified in windows.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();
};
