// Posição de abertura da janela (popup)
var PositionX = 0;
var PositionY = 0;

// Exclusivo p/ Netscape: ajustar cerca de 20px acima do máximo a ser visualizado
var defaultWidth  = 1000;		
var defaultHeight = 750;		

// Parâmetro AutoClose: 'true' = para abrir sequência de fotos na mesma janela e 'false' = para múltiplas janelas
var AutoClose = true;

// Determinar versão do navegador
if (parseInt(navigator.appVersion.charAt(0))>=4){
    var isNN=(navigator.appName=="Netscape")?1:0;
    var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}

function popImage(imageURL){
  var barra = 'yes'; // default
  if (document.images[0].width < document.body.clientWidth)	{ barra = 'no';}
  if (document.images[0].height < document.body.clientHeight)	{ barra = 'no';}
  var optNN = 'scrollbars='+barra+',width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
  // var optIE = 'scrollbars=no,width=100,height=100,left='+PositionX+',top='+PositionY;
  var optIE = 'scrollbars='+barra+',width=100,height=100,left='+PositionX+',top='+PositionY;
		
  if (isNN){imgWin=window.open('about:blank','',optNN);}
  if (isIE){imgWin=window.open('about:blank','',optIE);}

  with (imgWin.document){
    writeln('<html><head><title>Carregando...</title><style>body{margin:0px;}</style>');
    writeln('<script>');
    writeln('var isNN,isIE;');
    writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');
    writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');
    writeln('if (isIE){');
    writeln('width=(document.images[0].width)+70;');
    writeln('height=(document.images[0].height)+140;');
    writeln('window.resizeTo(width,height);}');
    writeln('if (isNN){');       
    writeln('window.innerWidth=document.images[0].width;');
    writeln('window.innerHeight=document.images[0].height;}}');
    writeln('function doTitle(){document.title="HQNet - Sistema WebImóvel";}');
    writeln('</script>');

    if (!AutoClose)
      writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
    else
      writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');

    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();		
  }
}


function popImage2(imageRef,image,imageDesc,imageNo){
  var barra = 'yes'; // default
  if (document.images[2].width < document.body.clientWidth)	{ barra = 'no';}		// é a terceira imagem sequencial do documento. Começa com [0].
  if (document.images[2].height < document.body.clientHeight)	{ barra = 'no';}	// é a terceira imagem sequencial do documento. Começa com [0].
  var optNN = 'scrollbars='+barra+',width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
  // var optIE = 'scrollbars=no,width=100,height=100,left='+PositionX+',top='+PositionY;
  var optIE = 'scrollbars='+barra+',width=100,height=100,left='+PositionX+',top='+PositionY;
		
  if (isNN){imgWin=window.open('about:blank','',optNN);}
  if (isIE){imgWin=window.open('about:blank','',optIE);}

  with (imgWin.document){
    writeln('<html><head><title>Carregando...</title><style>body{margin:0px;}</style>');
    writeln('<script>');
    writeln('var isNN,isIE;');
    writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');
    writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');
    writeln('if (isIE){');
    writeln('width=(document.images[2].width)+70;');    // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('height=(document.images[2].height)+178;'); // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('window.resizeTo(width,height);}');
    writeln('if (isNN){');       
    writeln('window.innerWidth=document.images[2].width;');		  // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('window.innerHeight=document.images[2].height;}}');	  // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('function doTitle(){document.title="HQNet - Sistema WebImóvel";}');
    writeln('</script>');

    writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');

    writeln('<table width="100%" height="100%" border="1" bgcolor="#D7D1C5" bordercolor="purple" cellpadding="3">');
    writeln('  <tr style="font-family: verdana; font-size: 13px; color: navy; font-weight: bold">');
    writeln('    <td align="center" width="100%" height="35">');
    writeln('      <table border="0" width="100%" height="100%">');
    writeln('        <tr style="font-family: verdana; font-size: 13px; color: navy; font-weight: bold">');
    writeln('          <td align="center" width="50">');
    writeln('            <a href="ShowImage_aux.mvc?ref='+imageRef+'&fotoAnt='+imageNo+'">');
    writeln('            <img src="seta_esquerda.gif" border="0" title="anterior"></a>');
    writeln('          </td>');
    writeln('          <td align="center">');
    writeln(             imageDesc);
    writeln('          </td>');
    writeln('          <td align="center" width="50">');
    writeln('            <a href="ShowImage_aux.mvc?ref='+imageRef+'&fotoProx='+imageNo+'">');
    writeln('            <img src="seta_direita.gif" border="0" title="próxima"></a>');
    writeln('          </td>');
    writeln('        </tr>');
    writeln('      </table>');
    writeln('    </td>');
    writeln('  </tr>');
    writeln('  <tr style="font-family: verdana; font-size: 1px">');
    writeln('    <td align="center" valign="middle">');
    writeln('      <img src=fotos/'+imageRef+'/'+image+' style="display:block" border="1">');
    writeln('    </td>');
    writeln('  </tr>');
    writeln('</table>');
	
    writeln('</body></html>');
    close();		
  }
}


function popImage3(imageURL,imageDesc,imageNo){
  var barra = 'yes'; // default
  if (document.images[0].width < document.body.clientWidth)	{ barra = 'no';}		// é a terceira imagem sequencial do documento. Começa com [0].
  if (document.images[0].height < document.body.clientHeight)	{ barra = 'no';}	// é a terceira imagem sequencial do documento. Começa com [0].
  var optNN = 'scrollbars='+barra+',width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
  // var optIE = 'scrollbars=no,width=100,height=100,left='+PositionX+',top='+PositionY;
  var optIE = 'scrollbars='+barra+',width=100,height=100,left='+PositionX+',top='+PositionY;
		
  if (isNN){imgWin=window.open('about:blank','',optNN);}
  if (isIE){imgWin=window.open('about:blank','',optIE);}

  with (imgWin.document){
    writeln('<html><head><title>Carregando...</title><style>body{margin:0px;}</style>');
    writeln('<script>');
    writeln('var isNN,isIE;');
    writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');
    writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');
    writeln('if (isIE){');
    writeln('width=(document.images[0].width)+70;');    // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('height=(document.images[0].height)+178;'); // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('window.resizeTo(width,height);}');
    writeln('if (isNN){');       
    writeln('window.innerWidth=document.images[0].width;');		  // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('window.innerHeight=document.images[0].height;}}');	  // é a terceira imagem sequencial do documento. Começa com [0].
    writeln('function doTitle(){document.title="HQNet - Sistema WebImóvel";}');
    writeln('</script>');

    writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');

    writeln('<table width="100%" height="100%" border="1" bgcolor="#D7D1C5" bordercolor="purple" cellpadding="3">');
    writeln('  <tr style="font-family: verdana; font-size: 13px; color: navy; font-weight: bold">');
    writeln('    <td align="center" width="100%" height="35">');
    writeln('      <table border="0" width="100%" height="100%">');
    writeln('        <tr style="font-family: verdana; font-size: 13px; color: navy; font-weight: bold">');
    writeln('          <td align="center" width="50">');
    writeln('            <a href="ShowImage_aux.mvc?url='+imageURL+'&fotoAnt='+imageNo+'">');
    writeln('            [ anterior ]</a>');
    writeln('          </td>');
    writeln('          <td align="center">');
    writeln(             imageDesc);
    writeln('          </td>');
    writeln('          <td align="center" width="50">');
    writeln('            <a href="ShowImage_aux.mvc?url='+imageURL+'&fotoProx='+imageNo+'">');
    writeln('            [ próxima ]</a>');
    writeln('          </td>');
    writeln('        </tr>');
    writeln('      </table>');
    writeln('    </td>');
    writeln('  </tr>');
    writeln('  <tr style="font-family: verdana; font-size: 1px">');
    writeln('    <td align="center" valign="middle">');
    writeln('      <img src=fotos/'+imageURL+' style="display:block" border="1">');
    writeln('    </td>');
    writeln('  </tr>');
    writeln('</table>');
	
    writeln('</body></html>');
    close();		
  }
}
