var dialog = {
    /**
     * 弹出框
     * @param string title   弹出框标题
     * @param string content 弹出框内容
     * @param int    icon    弹出图标
     */
    alert: function(title, content, icon){
        var btn   = arguments[3];   // 按钮
        var func1 = arguments[4];   // 按钮一回调
        var func2 = arguments[5];   // 按钮二回调
        var func3 = arguments[6];   // 关闭按钮回调
        
        layer.open({
            title: title,
            content: content,
            area: '260px',
            icon: icon,
            btn: btn,
            yes: function(index){
                layer.close(index);
                if (typeof(func1) === 'function') func1();
            },
            btn2: function(index){
                layer.close(index);
                if (typeof(func2) === 'function') func2();
            },
            cancel: function(index){
                layer.close(index);
                if (typeof(func3) === 'function') func3();
            }
        })
    },
    /**
     * 成功提示框
     * @param string content 弹出框内容
     */
    success: function(content){
        if (isMobile()) {
            this.msg(content, arguments[1]);
        } else {
            this.alert(jsLang.SUCCESS, content, 1, [jsLang.CONFIRM_BTN_OK], arguments[1], '', arguments[1]);
        }
    },
    /**
     * 失败提示框
     * @param string content 弹出框内容
     */
    error: function(content){
        if (isMobile()) {
            this.msg(content, arguments[1]);
        } else {
            this.alert(jsLang.ERROR, content, 2, [jsLang.CONFIRM_BTN_OK], arguments[1], '', arguments[1]);
        }
    },
    /**
     * 询问框
     * @param string content 询问框内容
     */
    confirm: function(content){
        this.alert(jsLang.CONFIRM, content, 3, [jsLang.CONFIRM_BTN_OK, jsLang.CONFIRM_BTN_CANCEL], arguments[1], arguments[2], arguments[2]);
    },
    /**
     * 加载层
     */
    loading: function(){
        if (isMobile()) {
            return layer.open({
                type: 2,
                content: jsLang.LOADING
            });
        } else {
            return layer.load(1, {
                shade: [.6, '#000']     // 0.6 透明度的黑色背景
            });
        }
    },
    /**
     * 提示层
     */
    msg: function(message){
        var func = arguments[1];   // 按钮一回调
        if (isMobile()) {
            layer.open({
                content: message,
                skin: 'msg',
                time: 3000,
                end: function(){
                    if (typeof(func) === 'function') func();
                }
            });
        } else {
            return layer.msg(message, function(){
                if (typeof(func) === 'function') func();
            });
        }
    }
}
