//通过ID或Name得到元素
function $F(id) {
    var obj;
    obj = document.getElementById(id);
    if (obj != null)
        return obj;
    return document.getElementsByName(id);
}

function AlertOK(msg) {
    asyncbox.success(msg, '提示', function (buttonResult) {
    });
}
function AlertNO(msg) {
    asyncbox.error(msg, '提示', function (buttonResult) {
    });
}
function AlertConfirm(msg) {
    asyncbox.confirm(msg, '提示', function (action) {
        if (action == 'ok') {
            return true;
        }
        if (action == 'close') {
            return false;
        }
    });
}
//显示等待
function ShowLoadingMask() {
    asyncbox.html({
        id: 'win_mask',
        content: "<br/><img src='../../Images/UI/loading.gif'/><br/><br/>",
        modal: true,
        ctrlbar: { close: false },
        title: '系统正在处理中...'
    });
}
//关闭等待
function HideLoadingMask() {
    asyncbox.close('win_mask');
}
//定义模块格式
function DesignModuleFormat(module) {
    var url = "../../System/ModuleFormat/ModuleFormat_List.aspx?module=" + module;
    asyncbox.open({
        id: 'win_module_format',
        url: url,
        modal: true,
        width:480,
        height:380,
        title: '定义界面格式'
    });
}
//全屏弹出新窗口
function OpenNewWinMax(url) {
    var win_style = 'width=' + (screen.availWidth - 12) + ',height=' + (screen.availHeight - 60) 
                  + ',top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=yes';
    window.open(url, '_blank', win_style);
}
//关闭弹出层窗口
function CloseDivWin(){
  //定时关闭才不会出错
  //setTimeout(function() {
    var dialog = frameElement.api;
    try{
        dialog.close();
    } catch (err) {
        //alert(err.message);
    }
  //},1500); 
}
//调用日历控件(统一函统名方便日后更换控件)
function ShowDateControl() {
    WdatePicker();
}

//为select控件增加option
function AddOption(obj, name, value) {
    var op = document.createElement("OPTION");
    op.text = name;
    op.value = value;
    obj.add(op);
}
//保留小数位
function JSRound(value, digit) {
    var obj = new Number(value);
    return parseFloat(obj.toFixed(digit));
}
//判断字符串是否为空或非数值
function IsSpaceOrNaN(value) {
    if (value == "" || isNaN(value))
        return true;
    return false;
}
//判断字符串是否为空或非数值或零
function IsSpaceOrNaNOrZero(value) {
    if (value == "" || isNaN(value) || value == 0)
        return true;
    return false;
}
//禁止所有文本框进行输入
function disable_all_input() {
    var ele = document.getElementsByTagName("input");
    for (var i = 0; i < ele.length; i++) {
        ele[i].readOnly = true;
        //ele[i].disabled = true;
    }
}
//选择打印模板
function choice_print_template(module, sql_print_main_session_id, sql_print_detail_session_id) {
    var url = '../../System/GrfPrinter/PrintTemplate.aspx?module=' + module
            + '&sql_print_main_session_id=' + sql_print_main_session_id 
            + "&sql_print_detail_session_id=" + sql_print_detail_session_id;
    asyncbox.open({
        id: 'win_print',
        url: url,
        modal: true,
        title: '打印'
    });
}
 