// Posição de abertura da janela (popup)
var PositionX = 0;
var PositionY = 0;

// Parâmetro AutoClose: 'true' = para abrir sequência de fotos na mesma janela e 'false' = para múltiplas janelas
var AutoClose = true;

function popImage(imageURL,imageTitle){
  var barra = 'yes'; // default
  if ( (document.images[0].width < document.body.clientWidth) & (document.images[0].height < document.body.clientHeight) )	{ barra = 'no';}
  
  var opt = 'scrollbars='+barra+',resizable=yes,width=100,height=100,left='+PositionX+',top='+PositionY;	
  if (opt){imgWin=window.open('about:blank','',opt);}
  
  with (imgWin.document){
    writeln('<html><head><title>Carregando...</title><style>body{margin:0px;}</style>');
    writeln('<script>');
    writeln('function reSizeToImage(){');
    writeln('width=(document.images[0].width)+70;');
    writeln('height=(document.images[0].height)+140;');
    writeln('window.resizeTo(width,height);}');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');
    writeln('</script>');
    writeln('</head>');

    if (!AutoClose)
      writeln('<body bgcolor=000000 scroll="'+barra+'" onload="reSizeToImage();doTitle();self.focus()">')
    else
      writeln('<body bgcolor=000000 scroll="'+barra+'" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');

    writeln('<img src='+imageURL+' style="display:block">');
/*	
    writeln('<table width="100%" height="100%" border="1" bgcolor="#D7D1C5" bordercolor="purple" cellpadding="3">');
    writeln('  <tr style="font-family: verdana; font-size: 1px">');
    writeln('    <td align="center" valign="middle">');
    writeln('      <img src='+imageURL+' style="display:block" border="1">');
    writeln('    </td>');
    writeln('  </tr>');
    writeln('</table>');
*/	
    writeln('</body></html>');
    close();		
  }
}

