﻿function $message(msg, width, filter) {
    if (msg != undefined) {
        var iWidth = document.documentElement.clientWidth;
        var iHeight = document.documentElement.clientHeight
        width = width > 0 ? width : 180;
        var left = (iWidth - width) / 2;
        $("#msgbox") ? $("#msgbox").remove() : function() { };
        var elem = $("<div id='msgbox'>" + msg + "</div>");
        $("body").append(elem);
        //var top = document.documentElement.scrollTop + "px";
        var top = (iHeight / 2) - 50 + document.documentElement.scrollTop;
        if (filter == undefined) {
            filter = 80;
        }
        //alert(filter);
        $("#msgbox").css("position", "absolute").css("z-index", "9999").css("top", top).css("right", left + "px")
                    .css("width", width + "px").css("margin", "1px")
                    .css("filter", "Alpha(Opacity=" + filter + ")").css("-moz-opacity", filter / 100).css("opacity", filter / 100);

        $(window).scroll(function() {
            try {
                //var top = document.documentElement.scrollTop + "px";
                var top = (iHeight / 2) - 50 + document.documentElement.scrollTop;
                $("#msgbox").css("position", "absolute").css("z-index", "9999").css("top", top).css("right", left + "px")
                            .css("width", width + "px").css("margin", "1px")
                            .css("filter", "Alpha(Opacity=" + filter + ")").css("-moz-opacity", filter / 100).css("opacity", filter / 100);
            }
            catch (e) {
                alert(e.Message);
            }
        });

        //setTimeout("$message()", 3000);
    }
    else {
        $("#msgbox") ? $("#msgbox").remove() : function() { };
    }
}

function ShowTip(message, title) {
    var h = "";
    if (title == undefined) {
        title = "系统提示";
    }

    h += '<div class="TipTop"><div>' + title + '</div></div>';
    h += '<div class="TipBody">' + message + '</div>';
    h += '<div class="TipBtn"><input type="button" class="btn1" value="关闭" onclick="$message()" /></div>';
    $message(h, 300, 100);
}
