﻿function alertWin(title, msg, w, h) {
    var s = document.getElementsByTagName("select"); //--------------把所有select标签捉住
    for (var j = 0; j < s.length; j++) { s[j].style.display = "none"; } //--------------设为不显示，再进行下面操作
    var titleheight = "22px"; // 提示窗口标题高度 
    var bordercolor = "#666699"; // 提示窗口的边框颜色 
    var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
    var titlebgcolor = "#666699"; // 提示窗口的标题背景色
    var bgcolor = "#FFFFFF"; // 提示内容的背景色

    var iWidth = document.documentElement.clientWidth;
    var iHeight = document.documentElement.clientHeight;
    var bgObj = document.createElement("div");
    bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:" + iWidth + "px;height:" + Math.max(document.body.clientHeight, iHeight) + "px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
    document.body.appendChild(bgObj);

    var msgObj = document.createElement("div");
    msgObj.style.cssText = "position:absolute;font:11px '宋体';top:" + (iHeight - h) / 2 + "px;left:" + (iWidth - w) / 2 + "px;width:" + w + "px;height:" + h + "px;text-align:center;border:1px solid " + bordercolor + ";background-color:" + bgcolor + ";padding:1px;line-height:22px;z-index:102;";
    document.body.appendChild(msgObj);

    var table = document.createElement("table");
    msgObj.appendChild(table);
    table.style.cssText = "margin:0px;border:0px;padding:0px;";
    table.cellSpacing = 0;
    var tr = table.insertRow(-1);
    var titleBar = tr.insertCell(-1);
    titleBar.style.cssText = "width:100%;height:" + titleheight + "px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:" + titlecolor + ";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
    titleBar.style.paddingLeft = "10px";
    titleBar.innerHTML = title;
    var moveX = 0;
    var moveY = 0;
    var moveTop = 0;
    var moveLeft = 0;
    var moveable = false;
    var docMouseMoveEvent = document.onmousemove;
    var docMouseUpEvent = document.onmouseup;
    titleBar.onmousedown = function() {
        var evt = getEvent();
        moveable = true;
        moveX = evt.clientX;
        moveY = evt.clientY;
        moveTop = parseInt(msgObj.style.top);
        moveLeft = parseInt(msgObj.style.left);

        document.onmousemove = function() {
            if (moveable) {
                var evt = getEvent();
                var x = moveLeft + evt.clientX - moveX;
                var y = moveTop + evt.clientY - moveY;
                if (x > 0 && (x + w < iWidth) && y > 0 && (y + h < iHeight)) {
                    msgObj.style.left = x + "px";
                    msgObj.style.top = y + "px";
                }
            }
        };
        document.onmouseup = function() {
            if (moveable) {
                document.onmousemove = docMouseMoveEvent;
                document.onmouseup = docMouseUpEvent;
                moveable = false;
                moveX = 0;
                moveY = 0;
                moveTop = 0;
                moveLeft = 0;
            }
        };
    }

    var closeBtn = tr.insertCell(-1);
    closeBtn.style.cssText = "cursor:pointer; padding:2px;background-color:" + titlebgcolor;
    closeBtn.innerHTML = "<span style='font-size:15pt; color:" + titlecolor + ";'>×</span>";
    closeBtn.onclick = function() {
        for (var j = 0; j < s.length; j++) { s[j].style.display = ""; } //--------------再给select显出来
        document.body.removeChild(bgObj);
        document.body.removeChild(msgObj);
    }
    var msgBox = table.insertRow(-1).insertCell(-1);
    msgBox.style.cssText = "font:10pt '宋体';";
    msgBox.colSpan = 2;
    msgBox.innerHTML = msg;

    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
        return window.event || arguments.callee.caller.arguments[0];
    }
}

var reflash = false, messageboxloadcomplete = false;
if (document.all) { window.attachEvent('onload', SetMessageboxLoadComplete); }
else { window.addEventListener('load', SetMessageboxLoadComplete, false); }

function SetMessageboxLoadComplete() { messageboxloadcomplete = true; }
var sctimer; var tempwidth = 0, tempheight = 0, temppate = 1, speedrate = 24, interval_id = 0;
var newdiv = document.createElement("div"); var sdiv = document.createElement("div");
var contentdiv = document.createElement("div"); var Globle_width = 0, Globle_height = 0, Globle_src = '', Globle_title = '', Globle_Str = '', Globle_width_p = 0, Globle_height_div1 = 0;
document.writeln('<style type="text/css">body{ margin:0px !ipmortant; padding:0px  !ipmortant; font-family:Arial;}#blackbg{position:fixed;_position:absolute;}'); 
document.writeln('#blackcontentOuter{zoom:1; position:fixed!important;position:absolute;left:50%;top:45%;_top:expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(50 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100));}</style>');

function GetCookieValue(name) { var arr = document.cookie.match(new RegExp(name + "=([^&;]+)")); if (arr != null) { return decodeURI(arr[1]); } return ""; }

function setbg(boxtitle, pwidth, pheight, psrc, showclose) {
    var show = 'true'; if (showclose && showclose == 'false')
    { show = 'false' } if (!messageboxloadcomplete)
    { window.clearInterval(interval_id); interval_id = window.setInterval("setbg('" + boxtitle + "', " + pwidth + "," + pheight + ", '" + psrc + "','" + show + "')", 200); return; }
    ShowSelectAll(false, __MessageBox.HideIDs); window.clearInterval(interval_id); if (GetCookieValue("UserID11") == "") reflash = true; __MessageBox.InitMsgDivData();
    Globle_title = boxtitle; Globle_width = pwidth; Globle_height = pheight; Globle_src = psrc; Globle_width_p = Globle_width - 22; Globle_height_div1 = Globle_height + 38;
    Globle_Str = '<div style=" position:relative"><div id="messageboxframecontainer" style="display:none;width:' + Globle_width + 'px; height:38px ;padding:10px; background:#000;filter:alpha(opacity=40); -moz-opacity:0.4; -kHTML-opacity: 0.4; opacity: 0.4; position:absolute; top:0; left:0; z-index:1"></div><div id="__messageboxback" style=" width:' + Globle_width + 'px;position:absolute; top:10px; left:10px; background:#F6F9FF; z-index:1000;"><p id="messageboxclosebutton" style=" display:none; background:#06c; width:' + Globle_width_p + 'px; height:36px; line-height:40px; padding:0 10px; border:1px solid #7288c8; border-bottom:none; font-size:14px; font-weight:bold; color:#fff;margin:0;">' + (show == 'true' ? '<a style=" display:block; width:12px; height:12px; background:url(http://admin.aphrobridal.com/images/x.gif) no-repeat 0 0; line-height:100px; overflow:hidden; margin-top:12px; float:right" href="javascript:closeopendiv()">[关闭]</a>' : '') + Globle_title + '</p><iframe id="__MessageBoxFrame" onload="__MessageBox.ResizeIframe()" scrolling="no" src="' + Globle_src + '" frameborder="0" height="0" width="' + Globle_width + '"></iframe></div></div>';
    __MessageBox.scroolMsgeffect();
} function closeopendiv() {
    ShowSelectAll(true, __MessageBox.HideIDs);
    if (reflash == true && GetCookieValue("UserID") != "") { window.location.reload(); }
    else {
        contentdiv.style.width = '10px'; contentdiv.style.height = '10px'; contentdiv.innerHTML = ""; Globle_width = 0, Globle_height = 0, Globle_src = '',
Globle_title = '', Globle_Str = ''; tempwidth = 0, tempheight = 0, temppate = 1, contentdiv.style.display = "none"; newdiv.style.display = "none";
    }
} var __MessageBox = { HideIDs: '', ResizeIframe: function() {
    try {
        var _frame = document.getElementById("__MessageBoxFrame");
        var height = 0, width = 0; var f = document.getElementById("messageboxframecontainer");
        var closebutton = document.getElementById("messageboxclosebutton");
        try {
            _frame.height = 0; width = Math.max(_frame.contentWindow.document.documentElement.scrollWidth, _frame.contentWindow.document.body.scrollWidth); height = Math.max(_frame.contentWindow.document.documentElement.scrollHeight, _frame.contentWindow.document.body.scrollHeight);
        }
        catch (e) { }
        if (height > 0) { Globle_height = height; Globle_height_div1 = Globle_height + 38; Globle_width = width; Globle_width_p = Globle_width - 22; }
        contentdiv.style.width = Globle_width + "px"; contentdiv.style.height = Globle_height + "px"; contentdiv.style.margin = "-" + Globle_height / 2 + "px 0px 0px -" + Globle_width / 2 + "px"; _frame.width = Globle_width; _frame.height = Globle_height; closebutton.style.width = Globle_width_p + "px"; closebutton.style.display = "inline-block"; f.style.width = Globle_width + "px"; f.style.height = __MessageBox.setheightauto(Globle_height_div1) + "px"; f.style.display = "block"; document.getElementById('__messageboxback').style.width = Globle_width + "px"; document.getElementById("messageboxclosebutton").style.display = "inline-block";
    } catch (e1) { }
}, getMsgDivHeight: function() { var a = document.body.scrollHeight; var b = window.screen.height; return a > b ? a : b; }, InitMsgDivData: function() { newdiv.id = "blackbg"; newdiv.style.display = "none"; newdiv.style.zIndex = '99990'; newdiv.style.backgroundColor = "#000000"; newdiv.style.filter = "alpha(opacity=30)"; newdiv.style.opacity = 0.3; newdiv.style.display = "block"; newdiv.style.top = "0px"; newdiv.style.left = "0px"; newdiv.style.width = "100%"; newdiv.style.height = __MessageBox.getMsgDivHeight() + "px"; contentdiv.id = "blackcontentOuter"; contentdiv.style.display = "none"; contentdiv.style.zIndex = '99991'; contentdiv.style.width = '10px'; contentdiv.style.height = '10px'; contentdiv.style.margin = '-5px 0px 0px -5px'; contentdiv.style.backgroundColor = ""; document.body.appendChild(newdiv); document.body.appendChild(contentdiv); }, scroolMsgeffect: function() { contentdiv.style.display = "block"; __MessageBox.scroolMsgdiv(); }, getiecopy: function() { var bro = navigator.userAgent.toLowerCase(); if (/msie/.test(bro)) return bro.match(/msie ([\d.]*);/)[1]; }, setheightauto: function(input) { if (document.all) { if (__MessageBox.getiecopy() < 7.0) return input + 3; } return input; }, scroolMsgdiv: function() { tempwidth = Globle_width; tempheight = Globle_height; contentdiv.innerHTML = Globle_Str; contentdiv.style.width = tempwidth + "px"; contentdiv.style.height = tempheight + "px"; contentdiv.style.margin = "-" + tempheight / 2 + "px 0px 0px -" + tempwidth / 2 + "px"; }
};

function ShowSelectAll(show, sID) { var sList = document.getElementsByTagName("select"); if (sID && sID != '') { sID = "|" + sID + '|'; } if (sList && sList.length > 0) { for (var i = 0; i < sList.length; i++) { if (sID && sID != '') { if (sList[i].id && sList[i].id != '' && sID.indexOf('|' + sList[i].id + '|') >= 0) { continue; } } if (show) { sList[i].style.display = 'inline'; } else { sList[i].style.display = 'none'; } } } }
