/*

 $Name  : iviewer.js, 20060221 © 1996-2007 pf;
 $Date  : Tue, 21 Feb 2006 10:00:00 GMT;
 $Exp   : Mon, 31 Dec 2007 23:59:59 GMT;
 $Lang  : javascript;
 $Target: none;
 $Type  : text/javascript;
 $Desc  : Pictures Displayer.

 Programming and graphics by pf - All rights Unreserved.

------------------------------------------------------------------------------
Inserire queste due righe con la path relativa appropriata prima della
 fine della sezione HEAD nel file che lo deve utilizzare.

<script language="javascript" type="text/javascript"
 src="path-to/scripts/iviewer.js"></script>

------------------------------------------------------------------------------
Sempre nella stessa pagina html un link sarą:

<script language="javascript" type="text/javascript"><!-- //

document.write('<a href="javascript:ShwImg' +
  '(\'path-to\/images\/nomefile.ext\',' +
  ' \'image width in px\', \'image height in px\',' +
  ' \'didas\',' +
  ' \'0|1\');"');
document.writeln('');
document.writeln(' onMouseOver="self.status=\'Apri il Visualizzatore\';' +
  ' return true;"');
document.writeln(' onMouseOut="self.status=\' \'; return true;"');
document.writeln('');
document.write(' title="Nome_del_file">Nome_del_file<\/a>');

// --></script><noscript><a href="nomefile.ext" target="_blank"
 title="Nome_del_file">Nome_del_file</a></noscript>

------------------------------------------------------------------------------

*/

// ShwImg - Image 
// img      image
// iw       image width
// ih       image height
// didas    didascalia
// cls      clear screen [0|1]
function ShwImg(img, iw, ih, didas, cls)
{ var ww = 768, wh = 556;

  re = /<b>|<\/b>/gi;
  tit = didas.replace(re, "");
  re = /<i>|<\/i>/gi;
  tit = tit.replace(re, "");
  re = / <a href='\w*\W*\s*\S*\d*\D*\w*|'>\w*\W*\s*\S*\d*\D*\w*<\/a>/gi;
  tit = tit.replace(re, "<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a\w*\W*\s*\S*\d*\D*\w*\W*\s*\S*\d*\D*\w*<a/gi;
  tit = tit.replace(re, "<a<a");
  re = /<a/gi;
  tit = tit.replace(re, "");

  if (iw < (parseInt(screen.width) - 33 - 40))
    ww = (parseInt(iw) + 32 + 40)
  else
  { if (parseInt(screen.width) < 800 || parseInt(screen.width) > 2048)
      ww = 608
    else ww = 768;
  }

  if (ih < (parseInt(screen.height) - 31 - 100))
    wh = (parseInt(ih) + 30 + 100)
  else
  { if (parseInt(screen.height) < 600 || parseInt(screen.height) > 1536)
      wh = 386
    else wh = 556;
  }

  cnfg = 'width=' + ww + ',height=' + wh + ',scrollbars=yes,resizable=yes,' +
    'screenX=' + parseInt((screen.width-ww) / 2 * 2 - 10) + ',screenY=24';

  dsplyr = window.open('', 'dsplyrwin', cnfg);
  if (cls == 1) dsplyr.document.close();

  if (navigator.appName == 'Microsoft Internet Explorer')
  { dsplyr.moveTo(parseInt((screen.width-ww) / 2 * 2), 24);
    dsplyr.resizeTo(ww, wh);
  }

/*
  alert('Width: ' + ww + '\nHeight: ' + wh + '\n\nWin Inner Width: ' +
        dsplyr.innerWidth + '\nWin Inner Height: ' + dsplyr.innerHeight +
        '\n\nImage Width: ' + iw + '\nImage Height: ' + ih + '\n');
*/

  dsplyr.document.writeln('<html>');
  dsplyr.document.writeln('<head>');
  dsplyr.document.writeln('<meta http-equiv="Content-Type"' +
    ' content="text\/html; charset=iso-8859-1" \/>');
  dsplyr.document.writeln('<title>heriz.it -' +
    ' Visualizzatore Immagini: ' + tit + '<\/title>');
  dsplyr.document.writeln('<link href="http:\/\/www.heriz.it\/css\/sb.css"' +
    ' rel="stylesheet" type="text\/css" \/>');
  dsplyr.document.writeln('<style type="text\/css">');
  dsplyr.document.writeln('body { text-align: center; margin: 0; padding: 0' +
    ' }');
  dsplyr.document.writeln('<\/style>');
  dsplyr.document.writeln('<\/head>');
  dsplyr.document.writeln('<body bgcolor="#000000" text="#ffffff"' +
    ' link="#ffff00" vlink="#ffd700" alink="#00ffff">');
  dsplyr.document.writeln('<center><img src="' + img + '" width="' + iw +
    '" height="' + ih + '"');
  dsplyr.document.writeln(' onmousedown="alert(\'Image: ' + img +
    '\\nWidth: ' + iw + '\\nHeight: ' + ih + '\\n' + tit + '\')"' +
    ' border="0" style="margin-top: 20px" \/><br \/>');
  dsplyr.document.writeln('<br \/>');
  dsplyr.document.writeln('<font size="1"><i>' + didas +
    '<\/i><\/font><br \/>');
  dsplyr.document.writeln('<br \/>');
  dsplyr.document.writeln('<font size="1"><a' +
    ' href="javascript:window.close();"' +
    ' title="Chiudi">Chiudi la finestra<\/a><\/font><\/center>');
  dsplyr.document.writeln('<\/body>');
  dsplyr.document.writeln('<\/html>');

  dsplyr.focus();
}

//  End of ShwImg.
