function autoresize(window, imagename) {
  if (window.document && window.document.images[imagename]) {
    var pNewWidth = eval('window.document.images[imagename].width');
    var pNewHeight = eval('window.document.images[imagename].height');
    //taken from a forum... but i don't remeber where
    if (window.window.innerWidth) { window.window.innerWidth = pNewWidth + 50; window.window.innerHeight = pNewHeight + 20; }
    // If IE, the delta is the "client" size minus the client size
    else if (window.document.body.clientWidth) {
      var dWidth = Number(pNewWidth) + Number(window.document.body.offsetWidth) - Number(window.document.body.clientWidth) + 30;
      var dHeight = Number(pNewHeight) + Number(window.document.body.offsetHeight) - Number(window.document.body.clientHeight) + 60;
      // Resize the window, accounting for the extra space
      window.window.resizeTo(dWidth, dHeight) ;
    }
  }
}
function showfoto(imagename, title) {
  fotowindow = window.open('', 'foto', 'location=no, toolbar=no, menubar=no, scrollbars=no', false);
  fotowindow.document.write('<'+'?xml version="1.0" ?'+'>\n');
  fotowindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n');
  fotowindow.document.write('<html xml:lang="it" xmlns="http://www.w3.org/1999/xhtml">\n');
  fotowindow.document.write('<head>\n');
  fotowindow.document.write('<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />\n');
  fotowindow.document.write('<title>'+title+'</title>\n');
  fotowindow.document.write('<style type="text/css">\n');
  fotowindow.document.write('body { background-image: url("images/bkgsite.gif"); text-align: center; }\n');
  fotowindow.document.write('</style>\n');
  fotowindow.document.write('</head>\n');
  fotowindow.document.write('<body>\n');
  fotowindow.document.write('<img name="'+imagename+'" id="'+imagename+'" src="images/'+imagename+'_big.jpg" alt="'+title+'" />\n');
  fotowindow.document.write('</body>\n');
  fotowindow.document.write('</html>\n');
  fotowindow.document.close();
  autoresint = setInterval("autoresize(fotowindow, '"+imagename+"');", 200);
  setTimeout("clearInterval(autoresint);", 30000);
}
