newWindow = null;
function powieksz(src, width, height, title, flash) {
  var screenWidth, screenHeight;

  if (window.screen) {
    screenWidth = window.screen.availWidth;
    screenHeight = window.screen.availHeight-30;
  } else {
    screenWidth = 640;
    screenHeight = 450;
  }

  var actualHeight = height;

  var scroll = false;
  if (height >= screenHeight)  {
    actualHeight = screenHeight;
    scroll = true;
  }

  if (newWindow != null && !newWindow.closed) newWindow.close();


  var settings =
    "left=" + (screenWidth - width)/2 + "," +
    "top=" + ((screenHeight - height)<0?0 : (screenHeight - height)/2) + "," +
    "screenX=" + (screenWidth - width)/2 + "," +
    "screenY=" + (screenHeight - height)/2 + "," +
    "width=" + (scroll ? (width + 19) : width) + "," +
    "height=" + actualHeight + "," +
    "innerWidth=" + width + "," +
    "innerHeight=" + actualHeight + "," +
    "toolbar=no,location=no,directories=no,status=no,menubar=no," +
    "scrollbars=" + (scroll ? "yes" : "no") + "," +
    "resizable=no";

  var outDocument =
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html40/loose.dtd\">\n" +
    "<html lang=\"pl\">\n" +
    "<head>\n" +
    "<title>"+title+"</title>\n" +
    "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n" +
    "<meta name=\"author\" content=\"InsERT.net\">\n" +
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"/.style/obrazek.css\">\n" +
    "</head>\n" +
    "<body>";

  if (flash != '') {
    outDocument +=
      "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" id=\"kobierzycka\" width=\""+width+"\" height=\""+height+"\">" +
      "<param name=\"movie\" value=\""+flash+"\">" +
      "<param name=\"quality\" value=\"high\">"+
      "<param name=\"menu\" value=\"false\">"+
      "<param name=\"bgcolor\" value=\"#ffffff\">"+
      "<noembed><img src=\""+src+"\" alt=\"Plan dojazdu\" width=\""+width+"\" height=\""+height+"\" border=\"1\"></noembed>"+
      "<embed src=\""+flash+"\" quality=\"high\" bgcolor=\"#ffffff\" width=\""+width+"\" height=\""+height+"\" border=\"1\" menu=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>"+
      "</object>";
  } else {
    outDocument +=
      "<a href=\"#obrazek\" onclick=\"window.close()\">" +
      "<img id=\"obrazek\" src=\"" + src + "\" alt=\"\" width=\"" + width + "\" height=\"" + height + "\" border=\"0\" hspace=\"0\" vspace=\"0\">" +
      "</a>";
  }

  outDocument += "</body>\n"+
    "</html>"
  newWindow = window.open('', 'picture', settings);
  newWindow.document.open();
  newWindow.document.clear();
  newWindow.document.write(outDocument);
  newWindow.document.close();
  newWindow.focus();
}

legendWindow = null;

function showLegend() {
  if (!(legendWindow != null && !legendWindow.closed)) {
    if (typeof(window.showModelessDialog) != "undefined") {
      var settings = "status:yes;unadorned:yes;help:no;edge:raised;dialogWidth:440px;dialogHeight:375px;dialogTop:0px;dialogLeft:0px;scroll:no";
      legendWindow = window.showModelessDialog("../legenda.html", "", settings);
    }
    else {
      var settings = "toolbar=no,location=no,directories=no,status=yes,menubar=no,width=440,height=320,top=0,left=0";
      legendWindow = window.open("../legenda.html", "", settings);
    }
    legendWindow.focus();
  }
}

function showScreenShot(src) {
  var screenWidth, screenHeight;
  var width, height;

  height = 550;
  width = 770;

  if (window.screen) {
    screenWidth = window.screen.availWidth;
    screenHeight = window.screen.availHeight-30;
  } else {
    screenWidth = 640;
    screenHeight = 450;
  }

  var actualHeight = height;

  if (height >= screenHeight)  {
    actualHeight = screenHeight;
  }

  if (newWindow != null && !newWindow.closed) newWindow.close();

  var settings =
    "left=" + (screenWidth - width)/2 + "," +
    "top=" + ((screenHeight - height)<0?0 : (screenHeight - height)/2) + "," +
    "screenX=" + (screenWidth - width)/2 + "," +
    "screenY=" + (screenHeight - height)/2 + "," +
    "width=" + width + "," +
    "height=" + actualHeight + "," +
    "innerWidth=" + width + "," +
    "innerHeight=" + actualHeight + "," +
    "toolbar=no,location=no,directories=no,status=no,menubar=no," +
    "scrollbars=no,resizable=no";

  newWindow = window.open(src, '',settings);
  newWindow.focus();
}
