//遮罩提示层
function blockUiInfo() {
    this.message = "";
    this.width = 130;
    this.height = 20;
    this.top = 0;
    this.left = 0;
    this.right = 0;
    this.textAlign = "left";
    this.color = "#000";
    this.border = "1px #ccc solid";
    this.padding = 3;
    this.margin = 0;
    this.backgroundColor = "#eee";
    this.obackgroundColor = "#eee";
    this.oopacity = 0.5;
    this.cursor = "default";
    this.centerX = true;
    this.centerY = true;
    this.autoTimeOut = 0;
    this.centerYN = true;
    this.closeIconYN = true;
}

//浮动提示层
function posInfo() {
    this.message = "";
    this.left = 0;
    this.top = 0;
    this.width = 100;
    this.height = 20;
    this.autoHideTime = 0;
    this.closeIconYN = true;
    this.successYN = false;
    this.overFlow = "auto";
}
//AJAX的加载-----------------------------------------------
function Loading() {
    var info = new blockUiInfo();
    info.message = '<img src="/Resources/Images/ajaxLoading/loading_width.gif" >';
    info.border = "0px";
    info.width = 118;
    info.height = 13;
    info.centerX = true;
    info.centerY = true;
    info.centerYN = false;
    info.top = 0;
    info.left = '';
    info.right = 0;
    info.padding = 0;
    info.border = "1px #ccc solid";
    info.backgroundColor = "#fff";
    info.obackgroundColor = "#fff";
    info.closeIconYN = false;
    BlockUiBodyAlert(info);
}
function LoadingClose() {
    $.unblockUI;
}
function objLoading(obj) {
    var info = new blockUiInfo();
    info.message = '<img src="/Resources/images/ajaxLoading/loading_1.gif" />';
    info.border = "0px";
    info.width = 16;
    info.height = 16;
    info.centerX = true;
    info.centerY = true;
    info.backgroundColor = "#fff";
    info.obackgroundColor = "#fff";
    info.closeIconYN = false;
    BlockUiObjAlert(obj, info);
}
function objLoadingClose(obj) {
    $(obj).unblock();
}

//遮罩的提示层---------------------------------------------------------------
function BlockUiAlertBodyCenter(successYN, msg, width, height, autoTimeOut) {
    var info = new blockUiInfo();
    if (successYN) {
        info.message = msg;
        info.border = "1px #063 solid";
        info.color = "#063";
        info.backgroundColor = "#B5F7C1";
        info.obackgroundColor = "#B5F7C1";
    }
    else {
        info.message = msg;
        info.border = "1px #ff6600 solid";
        info.color = "#f30";
        info.backgroundColor = "#fffeee";
        info.obackgroundColor = "#fff";
    }
    info.left = 0;
    info.width = width;
    info.height = height;
    info.autoTimeOut = autoTimeOut;
    BlockUiBodyAlert(info);
}

function BlockUiAlertObjCenter(obj, successYN, msg, width, height, autoTimeOut) {
    var info = new blockUiInfo();
    if (successYN) {
        info.message = msg;
        info.border = "1px #063 solid";
        info.color = "#063";
        info.backgroundColor = "#B5F7C1";
        info.obackgroundColor = "#fff";
    }
    else {
        info.message = msg;
        info.border = "1px #ff6600 solid";
        info.color = "#f30";
        info.backgroundColor = "#fffeee";
        info.obackgroundColor = "#fff";
    }
    info.width = width;
    info.height = height;
    info.autoTimeOut = autoTimeOut;
    BlockUiObjAlert(obj, info);
}


function AlertPosNobg(info) {
    AlertPosClose("#mesAlertPos");
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight);
    var mesW = document.createElement("div");

    mesW.id = "mesAlertPos";

    if (info.closeIconYN) {
        info.message += "<div style=\"height:13px;width:14px; position:absolute;right:5px;top:5px;\">"
            + " <a href=\"javascript:;\" onclick=\"AlertPosClose('#" + mesW.id + "');\"><img src=\"/resources/images/icon/icon_close.gif\" alt=\"close\"/></a>"
            + "</div>";
    }
    mesW.innerHTML = info.message;

    if (bWidth - info.Left < info.width) {
        styleStr = "left:" + (info.left - info.width) + "px;";
    }
    else {
        styleStr = "left:" + (info.left) + "px;";
    }
    styleStr += "top:" + info.top + "px;";
    styleStr += "padding-top:2px; padding-bottom:10px;line-height:18px;padding-left:10px;padding-right:10px;"
    styleStr += "position:absolute;";
    styleStr += "overflow:" + info.overFlow + ";";

    styleStr += "width:" + info.width + "px;"
    //styleStr += "height:" + info.height + "px;";

    if (info.successYN) {
        styleStr += "border:1px #ff3366 solid;";
        styleStr += "background-color: #fff;";
        styleStr += "color: #ff3366;";
    }
    else {
        styleStr += "border:1px #AA0605 solid;";
        styleStr += "background-color: #fff;";
        styleStr += "color: #AA0605;";
    }

    mesW.style.cssText = styleStr;

    document.body.appendChild(mesW);

    $("#" + mesW.id).fadeIn(500);

    if (info.autoHideTime > 0)
        setTimeout(function() { AlertPosClose("#" + mesW.id); }, info.autoHideTime);
}

//浮动的提示层
function AlertPos(info) {
    AlertPosClose("#mesAlertPos");
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight);
    var mesW = document.createElement("div");

    mesW.id = "mesAlertPos";

    if (info.closeIconYN) {
        info.message += "<div style=\"height:13px;width:14px; position:absolute;right:5px;top:5px;\">"
            + " <a href=\"javascript:;\" onclick=\"AlertPosClose('#" + mesW.id + "');\"><img src=\"/resources/images/icon/icon_close.gif\" alt=\"close\"/></a>"
            + "</div>";
    }
    mesW.innerHTML = info.message;

    if (bWidth - info.Left < info.width) {
        styleStr = "left:" + (info.left - info.width) + "px;";
    }
    else {
        styleStr = "left:" + (info.left) + "px;";
    }
    styleStr += "top:" + info.top + "px;";
    styleStr += "padding-top:2px; padding-bottom:5px;line-height:18px;padding-left:25px;padding-right:20px;"
    styleStr += "position:absolute;";
    styleStr += "overflow:" + info.overFlow + ";";

    styleStr += "width:" + info.width + "px;"
    //styleStr += "height:" + info.height + "px;";

    if (info.successYN) {
        styleStr += "border:1px #ff3366 solid;";
        styleStr += "background-color: #fff;";
        styleStr += "color: #ff3366;";
        styleStr += "background: url(/resources/images/icon/msga.gif) 5px -1430px no-repeat #fff;";
    }
    else {
        styleStr += "border:1px #AA0605 solid;";
        styleStr += "background-color: #fff;";
        styleStr += "color: #AA0605;";
        styleStr += "background: url(/resources/images/icon/msga.gif) 5px -1472px no-repeat #fff;";
    }

    mesW.style.cssText = styleStr;

    document.body.appendChild(mesW);

    $("#" + mesW.id).fadeIn(500);

    if (info.autoHideTime > 0)
        setTimeout(function() { AlertPosClose("#" + mesW.id); }, info.autoHideTime);
}

function AlertPosClose(obj) {
    if ($(obj) != null) {
        $(obj).hide();
        $(obj).remove();
    }
}

function AlertPosObjVI(obj, successYN, msg, autoHideTime, width, height, overFlow, left, top) {
    var pos = new getPos(obj);
    var info = new posInfo();
    info.left = pos.Left + left;
    info.top = pos.Top + top;
    info.message = msg;
    info.successYN = successYN;
    info.autoHideTime = autoHideTime;
    info.width = width;
    info.height = height;
    info.overFlow = overFlow;
    AlertPos(info);
}
function AlertPosObj(obj, successYN, msg, autoHideTime, width, height, position) {
    var pos = new getPos(obj);
    var info = new posInfo();
    if (position == "in") {
        info.left = pos.Left;
        info.top = pos.Top;
    }
    else if (position == "left") {
        info.left = pos.Left - width - 47;
        info.top = pos.Top;
    }
    else if (position == "right") {
        info.left = pos.Left + pos.Width;
        info.top = pos.Top;
    }
    else if (position == "top") {
        info.left = pos.Left + pos.Width - width - 47;
        info.top = pos.Top - pos.Height - height + 5;
    }
    else if (position == "bottom") {
        info.left = pos.Left + pos.Width - width - 47;
        info.top = pos.Top + pos.Height;
    }
    else if (position == "bottomleft") {
        info.left = pos.Left;
        info.top = pos.Top + pos.Height+5;
    }
    info.overFlow = "visible";
    info.message = msg;
    info.successYN = successYN;
    info.autoHideTime = autoHideTime;
    info.width = width;
    info.height = height;
    AlertPos(info);
}

function AlertPosObjNobg(obj, successYN, msg, autoHideTime, width, height, position) {
    var pos = new getPos(obj);
    var info = new posInfo();
    if (position == "in") {
        info.left = pos.Left;
        info.top = pos.Top;
    }
    else if (position == "left") {
        info.left = pos.Left - width - 47;
        info.top = pos.Top;
    }
    else if (position == "right") {
        info.left = pos.Left + pos.Width;
        info.top = pos.Top;
    }
    else if (position == "top") {
        info.left = pos.Left + pos.Width - width - 47;
        info.top = pos.Top - pos.Height - height + 5;
    }
    else if (position == "bottom") {
        info.left = pos.Left + pos.Width - width - 30;
        info.top = pos.Top + pos.Height;
    }
    info.overFlow = "visible";
    info.message = msg;
    info.successYN = successYN;
    info.autoHideTime = autoHideTime;
    info.width = width;
    info.height = height;
    AlertPosNobg(info);
}

//显示页面提示(页面里面操作div)
function AlertDiv(obj, successYN, msg, autoHideTime) {
    $(obj).empty();
    if (successYN) {
        $(obj).removeClass("Error");
        $(obj).addClass("Success");
    }
    else {
        $(obj).removeClass("Success");
        $(obj).addClass("Error");
    }
    $(obj).show();
    // $(obj).append(XmlToHtmlLi(msg + " <a href=\"javascript:;\" onclick=\"AlertDivClose('" + obj + "');\"><img align=\"absmiddle\" src=\"/resources/images/icon/icon_close.jpg\" alt=\"close\"/></a>"));
    $(obj).append(msg);
    if (parseInt(autoHideTime) > 0) {
        setTimeout(function() {
            $(obj).slideUp(700, function() { $(obj).empty(); });
        }, autoHideTime);
    }
}
//function AlertDivClose(obj) {
//    $(obj).empty();
//    $(obj).slideUp(700);
//}

//删除提示框
function delConfirm(obj, msg, width, height, left, top) {
    msg = msg + '<div><img id="Yes_Del" align="absmiddle" src=\"/Resources/images/icon/icon_yes.gif\" alt="yes" style="cursor:pointer;">   <img align="absmiddle" id="No_Del" src=\"/Resources/images/icon/icon_no.gif\" alt="no" style="cursor:pointer;"></div>';
    AlertPosObjVI(obj, false, msg, 0, width, height, 'visible', left, top);
}

function clearAlert() {
    $(".errorPageMsg").each(function() {
        $(this).hide();
    });
}

function clearObjAlert(obj) {
    $(obj).each(function() {
        $(this).hide();
    });
}