/* 
--------------------------
boot.js 调用miniUI主入口
升级 miniUI 时不可替换此文件boot.js
升级 miniUI 时请直接替换miniUI文件夹
升级时请保留/miniui/themes下的自定义按钮图标文件夹user_icons和样式文件user_icons.css
创建：zhaoshunlu
维护：zhaoshunlu@163.com 2014-09-10 增加主界面布局样式，完善换肤功能
--------------------------
*/
var bootPATH = "/scripts/";
//debugger
mini_debugger = false;   
//miniui
document.write('<script type="text/javascript" src="/scripts/jquery-1.6.2.min.js"></script>');
document.write('<script type="text/javascript" src="/scripts/miniui/miniui.js"></script>');
document.write('<link type="text/css" rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css"/>');
document.write('<link type="text/css" rel="stylesheet" href="/scripts/miniui/themes/user_icons.css"/>');    //更改为自定义图标文件
//--skin
var skin = getCookie("miniuiSkin");
if (!skin) { skin = "blue"; } //默认皮肤 蓝色
document.write('<link type="text/css" rel="stylesheet" href="/scripts/miniui/themes/' + skin + '/skin.css"/>');
//设置主界面局部样式
document.write("<style type=\"text/css\" rel=\"stylesheet\">");
if (skin == "blue") {
    document.write(".mini-body{background:#023867;}.mini-layout-south{background:#023867;color:#077da1;}.mini-nav-page{background:#f9fcfe;}");
} else if (skin == "gray") {
    document.write(".mini-body{background:#8b8b8b;}.mini-layout-south{background:#636262;color:#a9a9a9;}.mini-nav-page{background:#f7f7f9;}");
} else if (skin == "olive2003") {
    document.write(".mini-body{background:#b7c691;}.mini-layout-south{background:#758d5e;color:#bdca87;}.mini-nav-page{background:#f8f9f0;}");
} else if (skin == "blue2003") {
    document.write(".mini-body{background:#002d96;}.mini-layout-south{background:#041f5e;color:#435fa2;}.mini-nav-page{background:#f9fcfe;}");
} else if (skin == "blue2010") {
    document.write(".mini-body{background:#8ba0bc;}.mini-layout-south{background:#718bad;color:#acbbd0;}.mini-nav-page{background:#f9fcfe;}");
} 
document.write("</style>");
//--
function getCookie(sName) {
    var aCookie = document.cookie.split("; ");
    var lastMatch = null;
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) {
            lastMatch = aCrumb;
        }
    }
    if (lastMatch) {
        var v = lastMatch[1];
        if (v === undefined) return v;
        return unescape(v);
    }
    return null;
}

// 以下是我新增加的属性与方法 zhaoshunlu
var Global_debugger = true; //启用开发帮助提示 显示页面路径、创建人、维护人及创建日期等信息
/*
* 设置 asLabel 文本、只读表单 样式（必须配合 miniui 及 themes/user_icons.css 使用）
* 创建： zhaoshunlu 2014-5-22
*/
function SetLabelModel(form) {
    var fields = form.getFields();
    for (var i = 0, l = fields.length; i < l; i++) {
        var c = fields[i];
        if (c.setDisable) c.setDisable(false);
        if (c.setReadOnly) c.setReadOnly(true);     //只读
        if (c.setIsValid) c.setIsValid(true);      //去除错误提示
        if (c.addCls) c.addCls("asLabel");          //增加asLabel外观
    }
}
/*
* 设置  表单为 输入框模式 （必须配合 miniui 使用）
* 创建： zhaoshunlu 2014-5-22
*/
function SetInputModel(form) {
    var fields = form.getFields();
    for (var i = 0, l = fields.length; i < l; i++) {
        var c = fields[i];
        if (c.setReadOnly) c.setReadOnly(false);
        if (c.removeCls) c.removeCls("asLabel");
    }
    mini.repaint(document.body);
}

/*
*	显示一个无模式能自己关闭的即时提示框
*  本mini版本低不支持showTips()
*  msg:消息文本
*  state:图标类型，取值四个:success,info,warning,danger
*  创建人zhaoshunlu 2014-2-28
*/
function mini_showTips(msg, _state) {
    //mini.showTips({ content:ferror.errorText, state:"warning", x:"center", y:"center", timeout:2000 });
    //state:success, info, warning, danger
    var icon = "";
    switch (_state) {
        case "success":
            icon = "msgbox_ok";
            break;
        case "info":
            icon = "msgbox_ok";
            break;
        case "warning":
            icon = "msgbox_err";
            break;
        case "danger":
            icon = "msgbox_ok";
            break;
        default:
            icon = "msgbox_err";
            break;
    }
    var showTipsId = mini.showMessageBox({
        showModal: false,
        showHeader: false,
        message: msg,
        iconCls: icon
        //timeout: 2000,
        //x: "center",
        //y: "center"
    });
    setTimeout(function () {
        mini.hideMessageBox(showTipsId);
    }, 2000);
}
/*
*  获取系统帮助
*  helpId:帮助ID，即帮助文档路径
*  帮助文件统一放到/OA/_help/userManual/目录下
*  为了更新帮助文档方便，可以统一放到官方网站如：http://your.com/YLLogin/_help/userManual/
*  创建人zhaoshunlu 2014-2-28
*/
function onSystemHelp(helpId,folder) {
    if (!helpId || helpId == "") {
        mini.alert("未指定帮助ID，无法链接帮助信息");
        return;
    }

    var surl = (folder) ? "/Admin/_help/userManual/doc/" + folder + "/" + helpId : "/Admin/_help/userManual/doc/" + helpId;
    var _options = {
        url: surl,            //页面地址
        title: "系统帮助",     //标题
        iconCls: "icon-help", //标题图标
        width:600,
        height: 500,
        allowResize: true,
        allowDrag: true,
        showCloseButton: true,
        showMaxButton: true,
        showModal: false,
        onload: function () {
            //var iframe = this.getIFrameEl(); 
            //var data = {};       
            //调用弹出页面方法进行初始化
            //iframe.contentWindow.SetData(data);                         
        },
        ondestroy: function (action) {
            //if (action == "ok") {     

            //}                        
        }
    };
    mini.open(_options);
}
 