function openPopup (imageURL, caption) {
  var windowTop = 50;                // Top position of popup
  var windowLeft = 100;                // Left position of popup
  var defaultWidth = 660;             // Default width (for browsers that cannot resize)
  var defaultHeight = 580;            // Default height (for browsers that cannot resize)
  var onLoseFocusExit = false;         // Set if window to exit when it loses focus
  var undefined;
  var Options = "width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ",resizable" + ",status=1"
  

  var myScript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
    "<html>\n" + 
    "<head>\n" + 
    "<meta http-equiv=imagetoolbar content=no><title>" + caption + "\</title>\n" +




"<SCRIPT language=JavaScript type=text/javascript>\n" + 
"if (window.Event)\n" + 
"document.captureEvents(Event.MOUSEUP);\n" +
"function nocontextmenu(){ \n" + 
"event.cancelBubble = true \n" + 
"event.returnValue = false;\n" +
"return false;}\n" +
"function norightclick(e){ \n" +
"if (window.Event){ \n" +
"if (e.which == 2 || e.which == 3) \n" +
"return false; } \n"  +
"else \n" +
"if (event.button == 2 || event.button == 3){ \n" +
"event.cancelBubble = true \n" +
"event.returnValue = false; \n"  +
"return false; } } \n"  +
"document.oncontextmenu = nocontextmenu; \n" +
"document.onmousedown = norightclick; \n" +
" </SCRIPT> \n" +






    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1250\">\n" +
    "<meta http-equiv=\"Content-Language\" content=\"pl\">\n" +
    "<script language=\"JavaScript\" type=\"text/javascript\">\n" +
    "function resizewindow () {\n" +

    "  var width = document.myimage.width;\n" + 
    "  var height = document.myimage.height+20;\n";


   "  var wwww = document.myimage.width; \n" + 
    "  var hhhh = document.myimage.height;\n";



  // Netscape  
  if (navigator.appName.indexOf("Netscape") != -1) {  
    myScript = myScript +  "  window.innerHeight = height-20;\n  window.innerWidth = width;\n"
  }
   
  // Opera 
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+20, height+35);\n"
  }
  
  // Microsoft 
  else if (navigator.userAgent.indexOf("MSIE 6.0") != -1) { 
    myScript = myScript + "  window.resizeTo (width+12, height+31);\n" 

  }
    // Microsoft 
  else if (navigator.userAgent.indexOf("MSIE 8.0") != -1) { 
    myScript = myScript + "  window.resizeTo (width+24, height+74);\n" 

  }
  // Microsoft 
  else if (navigator.userAgent.indexOf("MSIE 9.0") != -1) { 
    myScript = myScript + "  window.resizeTo (width+24, height+74);\n" 

  }
  // Microsoft 
  else if (navigator.userAgent.indexOf("MSIE 7.0") != -1) { 
    myScript = myScript + "  window.resizeTo (width+24, height+74);\n" 

  }
  // Assume a frig factor for any other browsers
  else {
    myScript = myScript + "  window.resizeTo (width+14, height+34);\n"

  }
      
  myScript = myScript + "window.status='" + caption + "'" +  "}\n" + "window.onload = resizewindow\n" + 
    "</script>\n</head>\n" + "<body  bgcolor=black  ";
    
  // If the window is required to close when it loses focus.
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"self.close()\" ";}
    
  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n" +
    "<img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\" style=\"background-image:url(ladowanie.gif);background-repeat:no-repeat;background-position:199px 180px \"  onmousedown=window.close() ><center><font size=1 face=verdana color=yellow><B>\n" + 
    "</body>\n" +  "</html>\n";
        
  // Diagnostic - uncomment the next line if you wish to see the script generated.   
  //alert (myScript);
  
  // Create the popup window
  var imageWindow = window.open ("","imageWin",Options);
  imageWindow.document.write (myScript)
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  return false;
}
