﻿var ffAlertTxt = '您的输入含有非法字符，请检查！';

function g(nodeId) {
    return document.getElementById(nodeId);
}
function setInnerHtml(objName, dcontent) {
    if (g(objName) != null)
    { g(objName).innerHTML = dcontent; }
}
function getPos(obj) {
    this.Left = 0;
    this.Top = 0;
    this.Height = obj.offsetHeight;
    this.Width = obj.offsetWidth;
    var tempObj = obj;
    while (tempObj.tagName.toLowerCase() != "body" && tempObj.tagName.toLowerCase() != "html") {
        this.Left += tempObj.offsetLeft;
        this.Top += tempObj.offsetTop;
        tempObj = tempObj.offsetParent;
    }
}
function getNullPos() {
    return { Left: 0, Top: 0 }
}
function getMousePos(ev) {
    if (ev.pageX || ev.pageY) {
        return { Left: ev.pageX, Top: ev.pageY };
    }
    return {
        Left: ev.clientX + document.documentElement.scrollLeft, Top: ev.clientY + document.documentElement.scrollTop
    };
}
function clearWaitInfo() {
    var newd = g("waitInfo");
    if (newd != null) {
        newd.parentNode.removeChild(newd);
    }
}
function setGrowHidden(obj, intAlphaStep, intTimeStep) {

    try {
        if (obj == null) { return; }
        if (isIe) {
            try {
                obj.filters.alpha.opacity -= intAlphaStep;
                if (obj.filters.alpha.opacity > 0) {
                    setTimeout(function () { setGrowHidden(obj, intAlphaStep, intTimeStep); }, intTimeStep);
                }
                else { closeWindow(); }
            } catch (e) { closeWindow(); }
        }
        else {
            var curOpacity = obj.style.opacity;
            curOpacity -= intAlphaStep / 100;
            if (curOpacity > 0) {
                obj.style.opacity = curOpacity;
                setTimeout(function () { setGrowHidden(obj, intAlphaStep, intTimeStep); }, intTimeStep);
            }
            else { closeWindow(); }
        }
    } catch (e) { }
}
function showMessageBoxBase(content, pos, wWidth, windowId) {
    closeWindowBase(windowId);
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight);
    var mesW = document.createElement("div");
    mesW.id = windowId;
    mesW.innerHTML = content;
    if (bWidth - pos.Left < wWidth) {
        styleStr = "left:" + (pos.Left - wWidth) + "px;";
    }
    else {
        styleStr = "left:" + (pos.Left) + "px;";
    }
    styleStr += "top:" + pos.Top + "px;position:absolute;width:" + wWidth + "px;";
    mesW.style.cssText = styleStr;
    document.body.appendChild(mesW);

}
function showMessageBox(content, pos, wWidth) {
    showMessageBoxBase(content, pos, wWidth, "mesWindow");
}
function closeWindowBase(windowId) {
    if (g(windowId) != null) {
        g(windowId).parentNode.removeChild(g(windowId));
    }
}
function closeWindow() {
    closeWindowBase("mesWindow")
}
//页面定位
function setScroll(objId) {
    if (g(objId)) {

        var objPos = new getPos(g(objId));
        scroll(0, objPos.Top);
    }
}

//提示相关///////////////////////////////////////////////////



//设置是否可显示
function setDisplay(nodeId, state) {
    if (g(nodeId) != null) { g(nodeId).style.display = state; }
}
//删除元素
function removeNode(nodeId) {
    if (g(nodeId) != null) { g(nodeId).parentNode.removeChild(g(nodeId)); }
}

//显示提示信息
function showAlert(info, obj, infoSign) {
    if (g(infoSign) != null) { return; }
    var newd = document.createElement("span");
    newd.id = infoSign;
    newd.className = 'alertInfo';
    newd.innerHTML = info;
    obj.appendChild(newd);
}
//删除提示信息
function removeAlert(infoSign) {
    if (g(infoSign) == null) { return; }
    g(infoSign).parentNode.removeChild(g(infoSign));
}
//显示等待信息
function showWaitInfo(info, obj) {
    try {
        if (obj == null) return;
        clearWaitInfo();
        var newd = document.createElement("span");
        newd.className = 'waitInfo';
        newd.id = 'waitInfo';
        newd.innerHTML = info;
        obj.parentNode.appendChild(newd);
    } catch (e) { }
}
function showWaitInfoOnInner(info, obj) {
    try {
        if (obj == null) return;
        clearWaitInfo();
        var newd = document.createElement("span");
        newd.className = 'waitInfo';
        newd.id = 'waitInfo';
        newd.innerHTML = info;
        obj.innerHTML = '';
        obj.appendChild(newd);
    } catch (e) { }
}
function clearWaitInfo() {
    try {
        if (g('waitInfo') != null) { g('waitInfo').parentNode.removeChild(g('waitInfo')); }
    } catch (e) { }
}



function checknumber(String) {
    if (trimTxt(String) == "") {
        return false;
    }
    var Letters = "1234567890";
    var i;
    var c;
    for (i = 0; i < String.length; i++) {
        c = String.charAt(i);

        if (Letters.indexOf(c) == -1) {
            return false;
        }
    }
    return true;
}
function trimTxt(txt) {
    return txt.toString().replace(/(^\s*)|(\s*$)/g, "");
}
//检查是否为空
function isEmpty(inputId) {
    if (trimTxt(g(inputId).value) == '') { return true }
    return false;
}
