﻿
function mousePosition(ev) {
    if (ev == null) {
        return { x: 0, y: 0 };
    }
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    return {
        x: ev.clientX + document.body.scrollLeft - document.body.clientLeft, y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}
//测试弹出
function testMessageBox(value, url) {
    // var objPos = mousePosition();
    messContent = "<div style='padding:20px 0 20px 0;text-align:center'>" + value + "</div><div style='padding:20px 0 20px 0;'>3秒后自动关闭！</div>";
    showMessageBox('温馨提示', messContent, '', 50, url);
}
function testMessageBox2(ev, value, url) {
    var objPos = mousePosition(ev);
    messContent = "<div style='padding:20px 0 20px 0;text-align:center'>" + value + "</div><div style='padding:20px 0 20px 0;'>3秒后自动关闭！</div>";
    showMessageBox('温馨提示', messContent, objPos, 350, url);
}
//弹出方法
function showMessageBox(wTitle, content, pos, wWidth, url) {
    closeWindow();
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight);

    var back = document.createElement("div");
    back.id = "back";
    var styleStr = "top:0px;left:0px;position:absolute;background:#666;width:" + bWidth + "px;height:" + bHeight + "px;";
    styleStr += "filter:alpha(opacity=0);";
    back.style.cssText = styleStr;
    document.body.appendChild(back);
    showBackground(back, 50);
    var mesW = document.createElement("div")
    mesW.id = "mesWindow";
    mesW.className = "mesWindow";
    mesW.innerHTML = "<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>" + wTitle + "</td><td style='width:1px;'><input type='button' onclick='closeWindow();' title='关闭窗口' class='close' value='关闭' /></td></tr></table></div><div class='mesWindowContent' id='mesWindowContent'>" + content + "</div><div class='mesWindowBottom'></div>";
    // var v_top = (document.body.clientHeight - mesW.clientHeight) / 2;
    // var v_top = window.screenTop;
    var v_top = window.screenTop + document.documentElement.scrollTop;
    //    v_top += document.documentElement.scrollTop;
    // v_top += document.documentElement.clientTop;
    //    if (pos == null || pos == '') {
    styleStr = "top:" + (v_top) + "px;left:" + (document.body.clientWidth / 2 - mesW.clientWidth / 2) + "px;position:absolute;width:600px;margin-left:-300px;left:50%;z-index:9999;";
    //    }
    //    else {
    //        alert(pos.x + " : " + pos.y);
    //        styleStr = "left:" + (((pos.x - wWidth) > 0) ? (pos.x - wWidth) : pos.x) + "px;top:" + (pos.y) + "px;position:absolute;width:" + wWidth + "px;";
    //    }
    mesW.style.cssText = styleStr;
    document.body.appendChild(mesW);
    setTimeout("closeWindow('" + url + "');", 3000)
}
//让背景渐渐变暗
var isBack = true;
function showBackground(obj, endInt) {
    if (isBack == true) {
        obj.filters.alpha.opacity += 5;
        if (obj.filters.alpha.opacity < endInt) {
            setTimeout(function() { showBackground(obj, endInt) }, 5);
        }
    }
    else {
        var al = parseFloat(obj.style.opacity); al += 0.05;
        obj.style.opacity = al;
        if (al < (endInt / 100))
        { setTimeout(function() { showBackground(obj, endInt) }, 5); }
    }
}
//关闭窗口
function closeWindow(url) {
    if (document.getElementById('back') != null) {
        document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
    }
    if (document.getElementById('mesWindow') != null) {
        document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }
    if (url != null) {
        if (url.length > 0) {
            window.location.href = url;
        }
    }
}
function closeSelfPage() {
    parent.window.opener = null; parent.window.open('', '_self'); parent.window.close();
}
function goWeb(url) {
    window.location.href = "../default.aspx"
}
function logout() {
    if (confirm("你确定要注销身份吗？是－选择确定，否-选择取消")) {
        window.location.href = "../default.aspx"
    }
}
  