function openwin(url,w,h,scroll) {
  scrwidth=screen.width;scrheight=screen.height;
  leftmargin = (scrwidth - w)/2;topmargin = (scrheight - h)/2;
  props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
  var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",toolbar=no,location=no,status=yes,menubar=no,resizable=no,scrollbars="+ scroll;
  popup=window.open(url,'pop',windowprops);
  popup.focus();
}

function openwin2(url,w,h,scroll) {
  scrwidth=screen.width;scrheight=screen.height;
  leftmargin = (scrwidth - w)/2;topmargin = 50;
  props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
  var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",toolbar=no,location=no,status=yes,menubar=yes,resizable=no,scrollbars=yes";
  popup=window.open(url,'pop',windowprops);
  popup.focus();
}
function openwintop(url,w,h,scroll) {
  scrwidth=screen.width;scrheight=screen.height;
  leftmargin = (scrwidth - w)/2;topmargin = 0;
  props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
  var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",toolbar=no,location=no,status=yes,menubar=no,resizable=no,scrollbars="+ scroll;
  popup=window.open(url,'pop',windowprops);
  popup.focus();
}

function showWin2(FileName, titulo){
  foto1= new Image();
  foto1.src=FileName;
  ControlImg(FileName,titulo);
}

function ControlImg(FileName,titulo){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewPhoto(FileName,titulo);
  }
  else{
    funzione="ControlImg('"+FileName+"','"+titulo+")";
    intervallo=setTimeout(funzione,20);
  }
}

function viewPhoto(FileName, titulo)
{
 var nTop;
 var nLeft;
 var sAWin;
 
 
 wWidth=foto1.width + 6;
 wHeight=foto1.height + 4;
 
 nTop = (screen.height - wHeight) / 2
 nLeft = (screen.width - wWidth) / 2
 sAWin =  "width=" + wWidth + ",height=" + wHeight + 
          ",top=" + nTop + ",left=" + nLeft

 if (window.ventana && !(window.ventana.closed))
  window.ventana.close();
 
 ventana=window.open("", "ImageWindow", sAWin);
 ventana.document.write('<html><head><title>'+ titulo +'</title></head>');
 ventana.document.write('<BODY BGCOLOR=#ffffff TEXT=#FFFFCC LINK=#33CCFF VLINK=#FF6666 leftmargin=0 topmargin=0 onBlur=self.close()>');
 ventana.document.write('<table width="100%" height="100%"><tr><td with="100%" height="100%" align="center" valign="middle"><img src="' + FileName + '"></td></tr><table></body></html>');
 ventana.document.close();
}
