﻿
function showDialog(title, width, height, url, canclose) {
    var backdiv = document.createElement("div");
    backdiv.innerHTML = ("<div id='backdiv' style='background-image:url(/Scripts/exh/opendialog/opacity_layer.png);background-repeat:repeat;z-index:9999;position:absolute;left:0px;top:0px;width:100%;height:" + document.body.scrollHeight + "px;'></div>");
    var centerdiv = document.createElement("div");
    var marl = (document.body.clientWidth - width) / 2;
    var mart = (window.screen.height - height) / 2 - 50;
    var closestr = "<img onclick='closedialog()' width='14px' height='14px' style='cursor:pointer' title='关闭' src='/Scripts/exh/opendialog/close-qr-code.png'></div>";
    if (canclose == false) {
        closestr = "";
    }
    centerdiv.innerHTML = "<div id='centerdiv' style='-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius:5px; padding:5px;width:" + width + "px;height:" + (height + 40) + "px;background-color:white;margin-left:" + marl + "px;margin-top:" + mart + "px;position:fixed;'><div  style='top: 10px; right: 10px; position: absolute;'>"
        + closestr
          + "<div style='clear:both;text-align:center;font-weight:700;font-size:18px;border-bottom:1px solid gray;ine-height:16px;padding-top:10px;padding-bottom:10px;'>" + title + "</div><iframe id='centeriframe' frameborder='0' scrolling='auto' style='width:" + (width) + "px;height:" + (height - 20) + "px;border:none;overflow:hidden;text-align:center;padding:0;' marginheight='0' marginwidth='0'  /></div>";

    document.body.appendChild(backdiv);
    document.getElementById("backdiv").appendChild(centerdiv);
    var id = "dlg" + randomChar(12);
    if (url.indexOf("?") > 0) {
        url += ("&did=" + id);
    }
    else {
        url += ("?did=" + id);
    }
    $("#centeriframe").attr("src", url);
}
function closedialog(closeType,data) {
    if (window.top.dialogClose1) {
        window.top.dialogClose1(closeType,data);
    }
    window.top.document.getElementById("backdiv").parentNode.removeChild(window.top.document.getElementById("backdiv"));
}

