
/* JS: new_window*/

function openwin(elm, isImage) {

    if (!isImage) {
      window.open(elm.getAttribute("href"), "_blank");
      return true;
    }


    var msgWindow = window.open(elm.getAttribute("href"), "_blank", "toolbar=no");
    msgWindow.document.write("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>");
    msgWindow.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>");
    msgWindow.document.write("<html>");
    msgWindow.document.write("<meta http-equiv='content-type' content='text/html; charset=utf-8'>");
    msgWindow.document.write("<head>");
    msgWindow.document.write("<title>Obrázek</title>");
    msgWindow.document.write("<style media='screen,tv,projection' type='text/css'> html, body {margin:0;padding:0} a, img {border: 0px solid #fff}</style>");
    msgWindow.document.write("<script type='text/javascript'>");
    msgWindow.document.writeln("    function getInnerHeight() { ");
    msgWindow.document.writeln("           if (window.innerHeight) {");
    msgWindow.document.writeln("             return window.innerHeight;");
    msgWindow.document.writeln("           } else {");
    msgWindow.document.writeln("             return document.documentElement.offsetHeight;"); // document.body.clientHeight;
    msgWindow.document.writeln("           }");
    msgWindow.document.writeln("    }");
    msgWindow.document.writeln("    function getInnerWidth() { ");
    msgWindow.document.writeln("           if (window.innerWidth) {");
    msgWindow.document.writeln("             return window.innerWidth;");
    msgWindow.document.writeln("           } else {");
    msgWindow.document.writeln("             return document.documentElement.offsetWidth;"); //document.body.clientWidth;
    msgWindow.document.writeln("           }");
    msgWindow.document.writeln("    }");
    msgWindow.document.writeln("    function imgSize(controlHeight,fotoMargin) {");
    msgWindow.document.writeln("      image=document.getElementById('image_elm');");
    msgWindow.document.writeln("      if (screen.height <= (image.height + 31)) {");
    msgWindow.document.writeln("        window.resizeTo(image.width + 12,screen.height - 100);");
    msgWindow.document.writeln("      } else {");
    msgWindow.document.writeln("        window.resizeTo(image.width+2*fotoMargin,image.height+controlHeight+fotoMargin);");
    msgWindow.document.writeln("        controlx = image.width+2*fotoMargin - getInnerWidth();");
    msgWindow.document.writeln("        controly = image.height+controlHeight+fotoMargin - getInnerHeight();");
    msgWindow.document.writeln("        window.resizeTo(image.width + controlx+2*fotoMargin, image.height + controly+controlHeight+fotoMargin);");
    msgWindow.document.writeln("      }");
    msgWindow.document.writeln("    }");
    msgWindow.document.write("</script>");
    msgWindow.document.write("</head>");
    msgWindow.document.write("<body style='margin:0;padding:0;background:#fff' onload='imgSize(0,0);'>");
    msgWindow.document.write("<a style='border:0px solid #fff;' href='#' onclick='window.close();'><img src='"+elm.getAttribute("href")+"' style='border:0px solid #fff;' id='image_elm' alt=''></a>");
    msgWindow.document.write("</body>");
    msgWindow.document.write("</html>");
    msgWindow.document.close();
    msgWindow.focus();
    return true;
}

function open_win_external(elm) {
    window.open(elm.getAttribute("href"), "_blank");
    return true;
}
