var ysmode = ['color', 'intelligent', 'variableinfraredlight', 'variablewhitelight', 'common', 'normal white'];
var txmode = ['normal', 'facenoexposure', 'licenseplate'];
var qwmode = ['0', '30', '60', '90'];
var ksmode = ['50HZ', '60HZ', 'close'];
var bgmode = ["auto", "1/3", "1/25", "1/30", "1/50", "1/60", "1/100", "1/120", "1/240", "1/480", "1/960", "1/1000", "1/2000", "1/4000", "1/8000", "1/10000", "1/100000"];
var zymode = ["auto", "6dB", "12dB", "18dB", "24dB", "30dB", "36dB", "42dB"];
var bphmode = ["incandescent", "warm", "fluorescent", "natural", "manual", "auto", "locked"];
var tdmode = ["automatic", "weak", "normal", "strong", "close"];
var jzmode = ["close", "weak", "normal", "strong"];
var tjmode = ["close", "leftright", "updown", "center"];
var lmd = ['high', 'middle', 'low'];
var hour = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"];
var minute = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"];
var gs_xml_doc, get_xml_doc;
var colorxml = "";
var Intelligentxml = "";
var checkboxvalue;
var intelligentLightCap = {},
    colorLightCap = {},
    normalWhiteLight = {},
    rebootObj = {};
var currentchannel = 0;
var g_bIsIE = !(/(msie\s|trident.*rv:)([\w.]+)/.exec(navigator.userAgent.toLowerCase()) == null);
var rangInitIamges = false,
    rangInitDraw = false,
    rangInitWhiteBalance = false;
$(document).ready(function() {
    if (config.isSupportMultiChannel) {
        $(".isShowMultiChannel").show();
        // 初始化通道数
        $("#channel").empty();
        if (config.deviceInfo.VideoInputChannels > 1 && config.deviceInfo.VideoInputChannels <= 2) {
            $("#channel").append('<option class="option" value="1">' + $.i18n.prop("i18n-tracking") + '</option>');
            $("#channel").append('<option class="option" value="2">' + $.i18n.prop("i18n-panoramic") + '</option>');
            $("#coppyInds").append('<option class="option" value="1">' + $.i18n.prop("i18n-tracking") + '</option>');
            $("#coppyInds").append('<option class="option" value="2">' + $.i18n.prop("i18n-panoramic") + '</option>');
        } else {
            for (var i = 1; i <= config.deviceInfo.VideoInputChannels; i++) {
                $("#channel").append('<option class="option" value="' + i + '">' + i + '</option>');
                if (i != 1) {
                    $("#coppyInds").append('<option class="option" value="' + i + '">' + i + '</option>');
                }
            }

        }
        // 默认第一个通道
        $("#channel").val("1").trigger('change.select2');
        $("#channel").change(function() {
            currentchannel = $(this).val() - 1;
            var chid = $(this).val() * 1;
            $("#coppyInds").empty();
            $("#coppyInds").append('<option class="option" value="00">' + $.i18n.prop("i18n-video-all") + '</option>');

            if (config.deviceInfo.VideoInputChannels > 1 && config.deviceInfo.VideoInputChannels <= 2) {
                $("#coppyInds").append('<option class="option" value="1">' + $.i18n.prop("i18n-tracking") + '</option>');
                $("#coppyInds").append('<option class="option" value="2">' + $.i18n.prop("i18n-panoramic") + '</option>');
            } else {
                for (var i = 1; i <= config.deviceInfo.VideoInputChannels; i++) {
                    if (i != chid) {
                        $("#coppyInds").append('<option class="option" value="' + i + '">' + i + '</option>');
                    }
                }
            }
            if (g_bIsIE) {
                if (sessionStorage.getItem("playstyle") == 'MJPEG') {
                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 2, '', chid);
                } else {
                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 2, '', chid - 1);
                }

            } else {
                if (sessionStorage.getItem("playstyle") == 'EasyVideo') {
                    easyldspecialvideos(true);
                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 2, '', chid - 1);
                } else {
                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 2, '', chid);

                }
            }
            selectVale();
            getColor(chid);
            getWhiteBalance(chid);
            getImageBasic(chid);
            getExposure(chid);
            getScene(chid);
            getIrCutFilter(chid);
            getImageSens(chid);

        });
        // 复制到
        $("#copyTo").click(function() {
            if ($("#coppyInds").val() == "00") {
                for (var i = 1; i <= config.deviceInfo.VideoInputChannels; i++) {
                    if ("admin" == config.user || "super_admin" == config.user) {
                        setIrCutFilter(i);
                        setColor(i);
                        setImageBasic(i);
                        setWhiteBalance(i);
                        setExposure(i);
                        setScene(i);
                        setImageSens(i);

                    } else {
                        $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
                    }
                }
            } else {
                if ("admin" == config.user || "super_admin" == config.user) {
                    setIrCutFilter($("#channel").val() - 0);
                    setColor($("#channel").val() - 0);
                    setImageBasic($("#channel").val() - 0);
                    setWhiteBalance($("#channel").val() - 0);
                    setExposure($("#channel").val() - 0);
                    setScene($("#channel").val() - 0);
                    setImageSens($("#channel").val() - 0);
                    setIrCutFilter($("#coppyInds").val() - 0);
                    setColor($("#coppyInds").val() - 0);
                    setImageBasic($("#coppyInds").val() - 0);
                    setWhiteBalance($("#coppyInds").val() - 0);
                    setExposure($("#coppyInds").val() - 0);
                    setScene($("#coppyInds").val() - 0);
                    setImageSens($("#coppyInds").val() - 0);
                } else {
                    $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
                }
            }
        })
    } else {
        $(".isShowMultiChannel").hide();
    }


    var bls = getRatio();
    var newHs = 420 * 100 / bls;
    var newWs = 560 * 100 / bls;
    var divds = document.getElementById("box-border");
    if (divds) {
        divds.style.height = newHs + "px";
        divds.style.width = newWs + "px";
    }
    if (config.deviceCap[currentchannel].Defrog == 'true') {
        $("#fog").show();
    } else {
        $("#fog").hide();
    }
    // 曝光时间
    if (config.deviceCap[currentchannel].ExposureTime == 'true') {
        $(".sureTime").show();
    } else {
        $(".sureTime").hide();
    }
    if (config.deviceCap[currentchannel].PowerLineFrequency == 'true') {
        $("#powerLineFrequency").show();
    } else {
        $("#powerLineFrequency").hide();
    }
    if (config.deviceCap[currentchannel].AntiFlicker == 'true' || config.deviceCap[currentchannel].AntiFlicker == "") {
        $("#AntiFlicker").show();
    } else { //只有存在此能力且为false才隐藏，做反向逻辑处理
        $("#AntiFlicker").hide();
    }

    // 监听滚动条滚动改变easyvideo位置
    $(".image-gun").scroll(function() {
        if (sessionStorage.getItem("xystyle") == "p6s" || sessionStorage.getItem("xystyle") == "p2p") {
            if (sessionStorage.getItem("playstyle") == "EasyVideo" && window.location.hash.indexOf("#ipc/pages/image/imageParameter.html")!==-1 && sessionStorage.getItem('dpiRadio') != null) {
                var pt = GetAbsoluteLocationEx($("#axdiv")[0]);
                if (pt.Top > 80 && pt.Left > 250 * getRatio() / 100) {
                    preHiddenDisplaywindow(5, $("#channel").val() - 1);
                    preWindowfollowing(true, '', $("#channel").val() - 1);
                } else {
                    preHiddenDisplaywindow(4, $("#channel").val() - 1);
                }
            }
        } else {
            if (sessionStorage.getItem("playstyle") == "EasyVideo" && window.location.hash == "#ipc/pages/image/imageParameter.html") {
                var pt = GetAbsoluteLocationEx($("#axdiv")[0]);
                if (pt.Top > 127 && pt.Left > 250 * getRatio() / 100) {
                    preHiddenDisplaywindow(5, $("#channel").val() - 1);
                    preWindowfollowing(true, '', $("#channel").val() - 1);
                } else {
                    preHiddenDisplaywindow(4, $("#channel").val() - 1);
                }
            }
        }
    });
    if (config.devicelose) {
        addEventListener("resize", function(event) {});
    }
    $(window).resize(function() {
        if (sessionStorage.getItem("xystyle") == "p6s" || sessionStorage.getItem("xystyle") == "p2p") {
            if (window.location.hash.indexOf("#ipc/pages/image/imageParameter.html")!==-1 && sessionStorage.getItem('dpiRadio') != null) {
                var bl = getRatio();
                var newH = 420 * 100 / bl;
                var newW = 560 * 100 / bl;
                var divd = document.getElementById("box-border");
                if (divd) {
                    divd.style.height = newH + "px";
                    divd.style.width = newW + "px";
                }
                preWindowfollowing(true, '', $("#channel").val() - 1);
            }
        } else {
            if (sessionStorage.getItem("playstyle") == "EasyVideo" && window.location.hash == "#ipc/pages/image/imageParameter.html") {
                var bl = getRatio();
                var newH = 420 * 100 / bl;
                var newW = 560 * 100 / bl;
                var divd = document.getElementById("box-border");
                if (divd) {
                    divd.style.height = newH + "px";
                    divd.style.width = newW + "px";
                }
                preWindowfollowing(true, '', $("#channel").val() - 1);
            } else if (window.location.hash == "#ipc/pages/image/imageParameter.html") {
                var bl = getRatio();
                var newH = 420 * 100 / bl;
                var newW = 560 * 100 / bl;
                var divd = document.getElementById("box-border");
                if (divd) {
                    divd.style.height = newH + "px";
                    divd.style.width = newW + "px";
                }

            }
        }
    });
    if (g_bIsIE&&!config.forceEV) {
        if (sessionStorage.getItem("playstyle") == "ActiveX") {
            $("#playCanvas").hide();
            $("#axdiv").show();
            clearInterval(config.gs_interval);
        } else if (sessionStorage.getItem("playstyle") == "MJPEG") {
            $("#playCanvas").hide();
            $("#axdiv").show();
            $("#axdiv").empty();
            clearInterval(config.gs_interval);
        }
        getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true);
        SetActiveXMode(1);
    } else {
        if (sessionStorage.getItem("xystyle") == "p6s" || sessionStorage.getItem("xystyle") == "p2p") {
            config.refreshplayvideo = true;
            $("#playCanvas").hide();
            $("#axdiv").show();
            getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 3);
        } else {
            if (sessionStorage.getItem("playstyle") == "EasyVideo") {
                $("#playCanvas").hide();
                $("#axdiv").show();
            } else if (sessionStorage.getItem("playstyle") == "WebPlayer") {
                $("#playCanvas").show();
                $("#axdiv").hide();
                if (self.player) {
                    if (sessionStorage.getItem("stream") == "codestream1") {
                        self.player.stop("sub1");
                    } else {
                        self.player.stop("sub2");
                    }
                }

            } else if (sessionStorage.getItem("playstyle") == "MJPEG") {
                $("#playCanvas").hide();
                $("#axdiv").show();
                $("#axdiv").empty();
                clearInterval(config.gs_interval);
            }
            if (config.refreshplayvideo) {
                getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true, 3);
            } else {
                if (sessionStorage.getItem("playstyle") == "WebPlayer") {
                    $("#downloadeasyplay").hide();
                    if (config.playMode.indexOf("WebPlayer")!==-1) {
                        $.getScript("js/webPlayer/player.js", function() { //请求成功后的回调函数
                            $.getScript("js/webPlayer/webgl.js", function() { //请求成功后的回调函数
                                $.getScript("js/webPlayer/pcm-player.js", function() {
                                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true);
                                });
                            });
                        });
                    }
                } else if (sessionStorage.getItem("playstyle") == "EasyVideo") {
                    refershPlayer("");
                } else if (sessionStorage.getItem("playstyle") == "MJPEG") {
                    getVideoPlugin(sessionStorage.getItem("playstyle"), 1, "", true);
                }

            }
        }
    }
    if (!$('.select2').hasClass('select2-offscreen')) {
        $(".select2").select2({
            minimumResultsForSearch: -1,
        });
    }
    $("#de-fogging,#AntiflashMode,#FlashoverResis,#ApertureType,#ExposureTime,#ControlMode,#Controldirection,#IR-CUT-mode").select2({
        minimumResultsForSearch: -1,
    });
    $("#ImageSensity").select2({
        minimumResultsForSearch: -1,
        width: 200,
    });
    $("#gain,#WhiteBalance,#noisereduction,#Widedynamic,#ImageMirroring,#NightvisionMode,#ImageMode,#workingModeRed,#im_workmodewrite").select2({
        minimumResultsForSearch: -1,
    });
    initTimesmf();
    selectVale();
    getColor(1);
    getWhiteBalance(1);
    getImageBasic(1);
    getExposure(1);
    getScene(1);
    getIrCutFilter(1);
    getImageSens(1);
    $("#moren").click(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            setImgDefault();

        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 夜视模式
    $("#NightvisionMode").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            changeNightMode();
            setIrCutFilter($("#channel").val() - 0);

        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 控制模式
    $("#ControlMode").change(function() {
        if ($(this).select2('val') == 'custom') {
            $("#timeflows").show();
            $("#color_threshold").hide();
        } else {
            $("#timeflows").hide();
            if (colorLightCap.isColorThreshold == 'true') {
                $("#color_threshold").show()
            } else {
                $("#color_threshold").hide()
            }
        }
        setIrCutFilter($("#channel").val() - 0);

    });
    // 反向
    $("#cutOpen").click(function() {
        checkboxvalue = true;
        if ("admin" == config.user || "super_admin" == config.user) {
            setIrCutFilter($("#channel").val() - 0);
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    $("#cutClose").click(function() {
        checkboxvalue = false;
        if ("admin" == config.user || "super_admin" == config.user) {
            setIrCutFilter($("#channel").val() - 0);
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }

    });

    // 点击全彩白定时,普通红外定时的保存
    $("#whitetime,#phtime,#wjbtime").click(function(e) {
        e.preventDefault();
        if ("admin" == config.user || "super_admin" == config.user) {
            setIrCutFilter($("#channel").val() - 0);
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 工作模式
    $("#WorkingMode").change(function() {
        if ($(this).val() == "custom") { //手动
            if ($("#NightvisionMode").val() == 'variableinfraredlight') { //无极红
                $("#Infrared").show();
                $("#wjbtimeflows").hide(); //隐藏定时
            }
            if ($("#NightvisionMode").val() == 'variablewhitelight') { //无极白
                $("#conrection").show();
                $("#Effective").hide();
                //无极白 手动模式显示白光亮度
                $("#whitelight").show();
                if ($("#Controldirection").select2("val") == "timing") { //控制方向 是定时
                    $("#wjbtimeflows").show();
                    $("#Threshold").hide();
                    $("#offthreshold").hide();
                } else {
                    $("#wjbtimeflows").hide();
                    $("#Threshold").show();
                    $("#offthreshold").show();
                }
            }

        } else { //自动
            $("#Infrared").hide();
            $("#conrection").hide();
            $("#Threshold").hide();
            $("#offthreshold").hide();
            $("#whitelight").hide();
            $("#wjbtimeflows").hide();
            $("#Effective").show();
        }
        setIrCutFilter($("#channel").val() - 0);
    });

    $("#im_workmodewrite,#workingModeRed").change(function() {
        var mode = $(this).attr('id');
        if ($(this).val() == "custom") { //手动
            if (mode == 'workingModeRed') { //无极红
                $("#Infrared").show();
                $("#wjbtimeflows").hide(); //隐藏定时
            }
            if (mode == 'im_workmodewrite') { //无极白
                $("#conrection").show();
                $("#imageModeValue-2").hide();
                //无极白 手动模式显示白光亮度
                $("#whitelight").show();
                if ($("#Controldirection").select2("val") == "timing") { //控制方向 是定时
                    $("#wjbtimeflows").show();
                    $("#Threshold").hide();
                    $("#offthreshold").hide();
                } else {
                    $("#wjbtimeflows").hide();
                    $("#Threshold").show();
                    $("#offthreshold").show();
                }
            }

        } else { //自动
            $("#Infrared").hide();
            $("#conrection").hide();
            $("#Threshold").hide();
            $("#offthreshold").hide();
            $("#whitelight").hide();
            $("#wjbtimeflows").hide();
            // $("#Effective").show();
            if ($(this).attr('id') == 'workingModeRed') {
                $("#imageModeValue-1").show();
            } else {
                $("#imageModeValue-2").show();
            }

        }
        setIrCutFilter($("#channel").val() - 0);
    });
    // 控制方向
    $("#Controldirection").change(function(v) {
        if (v.val == 'timing') {
            $("#wjbtimeflows").show();
            $("#Threshold").hide();
            $("#offthreshold").hide();
            $("#whitelight").show();
        } else {
            $("#wjbtimeflows").hide();
            $("#Threshold").show();
            $("#offthreshold").show();
            $("#whitelight").show();
        }
        setIrCutFilter($("#channel").val() - 0);
    });
    // 普通红外ircut-模式change
    $("#IR-CUT-mode").change(function(v) {
        changeIRcutMode();
        if ("admin" == config.user || "super_admin" == config.user) {
            setIrCutFilter($("#channel").val() - 0);
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger")
        }
    });
    // 白平衡改变
    $("#WhiteBalance").change(function() {
        changeb();
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setWhiteBalance($("#channel").val() - 0);
            } else {
                setWhiteBalance();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    $('#boff').click(function() {
        document.getElementById('boff').classList.toggle('active');
        document.getElementById('bclos').classList.remove('active');
    });
    $('#bclos').click(function() {
        document.getElementById('boff').classList.remove('active');
        document.getElementById('bclos').classList.add('active');
    });
    // 光圈类型 曝光时间 增益改变后立即保存
    $("#ApertureType").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setExposure($("#channel").val() - 0);
            } else {
                setExposure();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    $("#ExposureTime").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setExposure($("#channel").val() - 0);
            } else {
                setExposure();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    $("#gain").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setExposure($("#channel").val() - 0);
            } else {
                setExposure();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 图像改变后立即保存
    $("#ImageMode").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            setIrCutFilter($("#channel").val() - 0);
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });

    // 去雾改变后立即保存
    $("#de-fogging").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setScene($("#channel").val() - 0);
            } else {
                setScene();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 宽动态改变后立即保存
    $("#Widedynamic").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            var param = '';
            if (["automatic", "weak", "normal", "strong"].indexOf(this.value) != -1) {
                param = '56';
            } else {
                param = '57';
            }
            if (config.deviceCap[currentchannel].WDRFlag == "true") {
                rebootObj = needReboot(param);
                if (rebootObj.isReBoot == 'true') {
                    var isUpplementary = rebootObj.hasOwnProperty('isUpplementary') ? rebootObj.isUpplementary : 0;
                    $.RestartModel.mask(setImageBasic, isUpplementary);
                    return;
                }
            }
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 图像镜像改变后立即保存
    $("#ImageMirroring").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 背光补偿改变后立即保存
    $("#boff").click(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    $("#bclos").click(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });

    // 降噪改变后立即保存
    $("#noisereduction").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 抗闪模式改变后立即保存
    $("#AntiflashMode").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 抗闪强度改变后立即保存
    $("#FlashoverResis").change(function() {
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageBasic($("#channel").val() - 0);
            } else {
                setImageBasic();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }
    });
    // 点击灵敏度设置
    $("#lmdsave").click(function(e) {
        e.preventDefault(); //阻止默认提交事件
        if ("admin" == config.user || "super_admin" == config.user) {
            if (config.isSupportMultiChannel) {
                setImageSens($("#channel").val() - 0);
            } else {
                setImageSens();
            }
        } else {
            $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
        }

    });
});
// 点击默认
function setImgDefault() {
    var cyXmlirc = "<?xml version='1.0' encoding='UTF-8' ?><IrCutFillter Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><Mode>initiative</Mode><DayStartTime>07:00:00</DayStartTime><DayEndTime>19:00:00</DayEndTime><Sensitivity>50</Sensitivity><SwitchTime>3</SwitchTime></IrCutFillter>";
    var cyURL;
    var num = $("#channel").val() ? $("#channel").val() : 1; //默认通道1
    cyURL = window.config.baseUrl + "/Images/" + num + "/Restore";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: cyXmlirc,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            if (200 == xhr.status) {
                checkboxvalue = false;
                //特殊情况 把IR-CUT模式值给自动 致为默认
                $("#IR-CUT-mode").select2('val', 'passivity');
                getColor(num);
                getWhiteBalance(num);
                getImageBasic(num);
                getExposure(num);
                getScene(num);
                getIrCutFilter(num);
                getImageSens(num);
                document.getElementById('boff').classList.remove('active');
                document.getElementById('bclos').classList.remove('active');
                document.getElementById('cutOpen').classList.remove('active');
                document.getElementById('cutClose').classList.remove('active');

                $("#brightness").jRange('setValue', $("#brightness").val()); //亮度
                $("#contrastRatio").jRange('setValue', $("#contrastRatio").val()); //对比度
                $("#saturation").jRange('setValue', $("#saturation").val()); //饱和度
                $("#tone").jRange('setValue', $("#tone").val()); //色度
                $("#Sharpness").jRange('setValue', $("#Sharpness").val()); //锐度
                $("#whitelightness").jRange('setValue', $("#whitelightness").val()); //白光亮度
                $("#imintelligentthreshold").jRange('setValue', $("#imintelligentthreshold").val());
                $("#imcolorthreshold").jRange('setValue', $("#imcolorthreshold").val());
                $("#imImage-1").jRange('setValue', $("#imImage-1").val());
                $("#imImage-2").jRange('setValue', $("#imImage-2").val());
                $("#Switchingtimeness").jRange('setValue', $("#Switchingtimeness").val());
                $("#CUTsensitivity").jRange('setValue', $("#CUTsensitivity").val());
                $("#imturnlight").jRange('setValue', $("#imturnlight").val());
                $("#imturnofflight").jRange('setValue', $("#imturnofflight").val());
                $("#Infraredness").jRange('setValue', $("#Infraredness").val()); //亮度

            } else {
                SaveState(xhr);
            }
        }
    });

}

// 初始化时分秒
function initTimesmf() {
    for (var i = 0; i < hour.length; i++) {
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#st_con_hour");
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#en_ic_hour1");
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#en_ic_hour2");
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#st_con_hour1");
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#en_ic_hour3");
        $("<option value='" + hour[i] + "'>" + hour[i] + "</option>").appendTo("#st_con_hour2");
    }
    for (var i = 0; i < minute.length; i++) {
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_minute");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_second");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_minute1");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_second1");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_minute1");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_second1");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_minute2");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_second2");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_minute2");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#st_con_second2");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_minute3");
        $("<option value='" + minute[i] + "'>" + minute[i] + "</option>").appendTo("#en_ic_second3");

    }


}
// 改变夜视模式
function changeNightMode() {
    var data = $("#NightvisionMode").val();
    if (data == 'intelligent') { //智能双光
        $("#turnlight,#turnofflight").hide();
        $("#workModeWrite").hide();
        $("#workModeRed").hide();
        $("#imageModeValue-2").hide();
        $("#imageModeValue-1").hide();
        $("#color_threshold").hide();
        if (intelligentLightCap.isIntelligentThreshold == 'true') {
            $("#intelligent_threshold").show();
        } else {
            $("#intelligent_threshold").hide();
        }
        if (intelligentLightCap.intelligentSensitivity == 'true') {
            $("#lmd").show();
        } else {
            $("#lmd").hide();
        }
        if (intelligentLightCap.intelligentDelayTime == 'true') {
            $("#imtime").show();
        } else {
            $("#imtime").hide();
        }
        $("#controlModeBox").hide();
        $("#workmode").hide();
        $("#Infrared").hide();
        $("#conrection").hide();
        $("#Threshold").hide();
        $("#offthreshold").hide();
        $("#whitelight").hide();
        $("#CUTmode").hide();
        $("#CUTtime").hide();
        $("#phtimeflows").hide();
        $("#CUTsensitiv").hide();
        $("#timeflows").hide();
        $("#wjbtimeflows").hide();
    } else if (data == 'color') { //全彩
        $("#turnlight,#turnofflight").hide();
        $("#workModeWrite").hide();
        $("#workModeRed").hide();
        $("#imageModeValue-2").hide();
        $("#imageModeValue-1").hide();
        $("#color_threshold").show()
        $("#intelligent_threshold").hide();
        $("#lmd").hide();
        $("#imtime").hide();
        $("#workmode").hide();
        // 因为配置项细节在灯板里面所以没有灯板就没有细节
        if (config.deviceCap[currentchannel].isSupportLightCapability !== 'true') {
            $("#controlModeBox").hide();
        } else {
            selectVale();
        }
        $("#Infrared").hide();
        $("#conrection").hide();
        $("#Threshold").hide();
        $("#offthreshold").hide();
        $("#whitelight").hide();
        $("#CUTmode").hide();
        $("#CUTtime").hide();
        $("#wjbtimeflows").hide();
        $("#phtimeflows").hide();
        $("#CUTsensitiv").hide();
        //控制模式
        if ($("#ControlMode").select2('val') == 'custom') { //定时
            $("#timeflows").show();
            $("#color_threshold").hide();
        } else { //自动
            $("#timeflows").hide();
            $("#color_threshold").show();
            if (colorLightCap.isColorThreshold == 'true') {
                $("#color_threshold").show()
            } else {
                $("#color_threshold").hide()
            }
        }
    } else if (data == 'variableinfraredlight') { //无极红外变光
        $("#turnlight,#turnofflight").hide();
        $("#workModeWrite").hide();
        $("#workModeRed").show();
        $("#imageModeValue-2").hide();
        $("#imageModeValue-1").show();
        $("#color_threshold").hide();
        $("#intelligent_threshold").hide();
        $("#timeflows").hide();
        $("#lmd").hide();
        $("#imtime").hide();
        $("#controlModeBox").hide();
        $("#workmode").show();
        $("#conrection").hide();
        $("#Threshold").hide();
        $("#offthreshold").hide();
        $("#whitelight").hide();
        $("#CUTmode").hide();
        $("#CUTtime").hide();
        $("#wjbtimeflows").hide();
        $("#phtimeflows").hide();
        $("#CUTsensitiv").hide();
        if ($("#workingModeRed").select2('val') == 'custom') {
            $("#Infrared").show();
        } else {
            $("#Infrared").hide();
        }

    } else if (data == 'variablewhitelight') { //无极白
        $("#turnlight,#turnofflight").hide();
        $("#workModeWrite").show();
        $("#workModeRed").hide();
        $("#imageModeValue-2").show();
        $("#imageModeValue-1").hide();
        $("#color_threshold").hide();
        $("#intelligent_threshold").hide();
        $("#timeflows").hide();
        $("#lmd").hide();
        $("#imtime").hide();
        $("#controlModeBox").hide();
        $("#workmode").show();
        $("#CUTmode").hide();
        $("#CUTtime").hide();
        $("#Infrared").hide();
        $("#CUTsensitiv").hide();
        if ($("#im_workmodewrite").select2('val') == "auto") { //工作模式 只显示起效亮度
            $("#conrection").hide();
            $("#Threshold").hide();
            $("#offthreshold").hide();
            $("#whitelight").hide();
            $("#wjbtimeflows").hide();
            $("#imageModeValue-2").show();
        } else { //工作模式-手动模式  一定有 控制方向 白光亮度 切不显示起效亮度
            $("#conrection").show();
            $("#whitelight").show();
            $("#imageModeValue-2").hide();
            // $("#Threshold").show();
            // $("#offthreshold").show();
            if ($("#Controldirection").val() == "timing") { //控制方向 定时--显示定时与白光亮度
                $("#Threshold").hide();
                $("#offthreshold").hide();
                $("#wjbtimeflows").show();
            } else { //控制方向 手动
                $("#Threshold").show();
                $("#offthreshold").show();
                $("#wjbtimeflows").hide();
            }
        }
        $("#phtimeflows").hide();

    } else if (data == 'normal white') { //普白
        if (normalWhiteLight.OpenLight == 'true') {
            $("#turnlight").show();
        } else {
            $("#turnlight").hide();
        }
        if (normalWhiteLight.CloseLight == 'true') {
            $("#turnofflight").show();
        } else {
            $("#turnofflight").hide();
        }
        // $("#turnlight,#turnofflight").show();
        $("#workModeWrite").hide();
        $("#workModeRed").hide();
        $("#imageModeValue-2").hide();
        $("#imageModeValue-1").hide();
        $("#color_threshold").hide();
        $("#intelligent_threshold").hide();
        $("#timeflows").hide();
        $("#lmd").hide();
        $("#imtime").hide();
        $("#controlModeBox").hide();
        $("#workmode").hide();
        $("#Infrared").hide();
        $("#conrection").hide();
        $("#Threshold").hide();
        $("#offthreshold").hide();
        $("#whitelight").hide();
        $("#wjbtimeflows").hide();
        $("#CUTmode").hide();
        $("#CUTtime").hide();
        $("#CUTsensitiv").hide();
        $("#phtimeflows").hide();
    } else { //common 普通红外夜视
        $("#turnlight,#turnofflight").hide();
        $("#workModeWrite").hide();
        $("#workModeRed").hide();
        $("#imageModeValue-2").hide();
        $("#imageModeValue-1").hide();
        $("#color_threshold").hide();
        $("#intelligent_threshold").hide();
        $("#lmd").hide();
        $("#imtime").hide();
        $("#controlModeBox").hide();
        $("#workmode").hide();
        $("#Infrared").hide();
        $("#conrection").hide();
        $("#Threshold").hide();
        $("#offthreshold").hide();
        $("#whitelight").hide();
        $("#CUTmode").show();
        $("#CUTtime").show();
        $("#timeflows").hide();
        $("#wjbtimeflows").hide();
        $("#phtimeflows").hide();

        changeIRcutMode();


    }
}

function changeIRcutMode() {
    $("#CUTsensitiv").hide();
    $("#phtimeflows").hide();
    $("#CUTtime").hide();
    switch ($('#IR-CUT-mode').select2('val')) {
        case 'passivity':
            $("#CUTtime").show();
            break;
        case 'initiative':
            $("#CUTsensitiv").show();
            $("#CUTtime").show();
            break;
        case 'time':
            $("#phtimeflows").show();
            break;
        default:
            break;
    }
}
// 初始化选择框
function selectVale() {
    // 夜视模式['color', 'intelligent', 'variableinfraredlight', 'variablewhitelight', 'common', 'normal white']
    var ni = $.i18n.prop("i18n-NightvisionMode-vale").split(",");
    var ysmoden = [];
    var niss = [];
    var isRedloghe = false;
    if (config.deviceCap[currentchannel].colorMode == 'true' && config.deviceCap[currentchannel].intelligentMode == 'true') {
        isRedloghe = true; //app是智能红外，所以为了兼容这里也要加，他们所谓的智能红外就是网页的普红
    }
    if (config.deviceCap[currentchannel].isSupportLightCapability == 'true') { //新灯板能力
        getLightCap(ysmoden, niss, ni);
    } else {
        if (config.deviceCap[currentchannel].normalWhite == 'true') { //普白
            ysmoden.push("normal white");
            niss.push(ni[ni.length - 1]);
        }
        if (config.deviceCap[currentchannel].NormalInfrared == 'true' || isRedloghe == true) { //普通夜视
            ysmoden.push("common");
            niss.push(ni[ni.length - 2]);
        }
        if (config.deviceCap[currentchannel].colorMode == 'true') { //全彩
            ysmoden.push("color");
            niss.push(ni[0]);
        }
        if (config.deviceCap[currentchannel].intelligentMode == 'true') { //智能双光
            ysmoden.push("intelligent");
            niss.push(ni[1]);
        }
        if (config.deviceCap[currentchannel].variableInfrared == 'true') { //无极红
            ysmoden.push("variableinfraredlight");
            niss.push(ni[2]);
        }
        if (config.deviceCap[currentchannel].variableWhite == 'true') { //无极白
            ysmoden.push("variablewhitelight");
            niss.push(ni[3]);
        }
    }
    $("#NightvisionMode").empty();
    for (var i = 0; i < niss.length; i++) {
        $("<option value='" + ysmoden[i] + "'>" + niss[i] + "</option>").appendTo("#NightvisionMode");
    }
    // 图像模式
    var tx = $.i18n.prop("i18n-iamgeModel-value").split(",");
    $("#ImageMode").empty();
    for (var i = 0; i < tx.length; i++) {
        if (txmode[i] == 'normal') {
            if (config.deviceCap[currentchannel].normalMode === 'true') {
                $("<option value='" + txmode[i] + "'>" + tx[i] + "</option>").appendTo("#ImageMode");
            }
        }
        if (txmode[i] == 'facenoexposure') {
            if (config.deviceCap[currentchannel].faceMode === 'true') {
                $("<option value='" + txmode[i] + "'>" + tx[i] + "</option>").appendTo("#ImageMode");
            }
        }
        if (txmode[i] == 'licenseplate') {
            if (config.deviceCap[currentchannel].licenseMode === 'true') {
                $("<option value='" + txmode[i] + "'>" + tx[i] + "</option>").appendTo("#ImageMode");
            }
        }
        //$("<option value='" + txmode[i] + "'>" + tx[i] + "</option>").appendTo("#ImageMode");
    }
    // 去雾和3d降噪
    $("#de-fogging,#noisereduction").empty();
    var qw = $.i18n.prop("i18n-de-foggingValue").split(",");
    for (var i = 0; i < qw.length; i++) {
        $("<option value='" + qwmode[i] + "'>" + qw[i] + "</option>").appendTo("#de-fogging");
        $("<option value='" + jzmode[i] + "'>" + qw[i] + "</option>").appendTo("#noisereduction");
    }
    // 抗闪模式
    $("#AntiflashMode").empty();
    var ks = $.i18n.prop("i18n-AntiflashMode-value").split(",");
    for (var i = 0; i < ks.length; i++) {
        $("<option value='" + ksmode[i] + "'>" + ks[i] + "</option>").appendTo("#AntiflashMode");
    }
    // 曝光时间
    $("#ExposureTime").empty();
    var bg = $.i18n.prop("i18n-ExposureTime-value").split(",");
    var powerbg = config.deviceCap[currentchannel].ExposureTimeList.split(",");
    for (var i = 0; i < powerbg.length; i++) {
        if (powerbg[i] == '0') {
            $("<option value='" + bgmode[0] + "'>" + bg[0] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '3') {
            $("<option value='" + bgmode[1] + "'>" + bg[1] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '25') {
            $("<option value='" + bgmode[2] + "'>" + bg[2] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '30') {
            $("<option value='" + bgmode[3] + "'>" + bg[3] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '50') {
            $("<option value='" + bgmode[4] + "'>" + bg[4] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '60') {
            $("<option value='" + bgmode[5] + "'>" + bg[5] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '100') {
            $("<option value='" + bgmode[6] + "'>" + bg[6] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '120') {
            $("<option value='" + bgmode[7] + "'>" + bg[7] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '240') {
            $("<option value='" + bgmode[8] + "'>" + bg[8] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '480') {
            $("<option value='" + bgmode[9] + "'>" + bg[9] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '960') {
            $("<option value='" + bgmode[10] + "'>" + bg[10] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '1000') {
            $("<option value='" + bgmode[11] + "'>" + bg[11] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '2000') {
            $("<option value='" + bgmode[12] + "'>" + bg[12] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '4000') {
            $("<option value='" + bgmode[13] + "'>" + bg[13] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '8000') {
            $("<option value='" + bgmode[14] + "'>" + bg[14] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '10000') {
            $("<option value='" + bgmode[15] + "'>" + bg[15] + "</option>").appendTo("#ExposureTime");
        } else if (powerbg[i] == '100000') {
            $("<option value='" + bgmode[16] + "'>" + bg[16] + "</option>").appendTo("#ExposureTime");
        }
    }
    // 增益
    $("#gain").empty();
    var zy = $.i18n.prop("i18n-gainValue").split(",");
    for (var i = 0; i < zy.length; i++) {
        $("<option value='" + zymode[i] + "'>" + zy[i] + "</option>").appendTo("#gain");
    }
    // 白平衡
    $("#WhiteBalance").empty();
    var bph = $.i18n.prop("i18n-White-balanceValue").split(",");
    for (var i = 0; i < bph.length; i++) {
        $("<option value='" + bphmode[i] + "'>" + bph[i] + "</option>").appendTo("#WhiteBalance");
    }
    // 宽动态
    $("#Widedynamic").empty();
    var kdt = $.i18n.prop("i18n-Wide-dynamicValue").split(",");
    for (var i = 0; i < kdt.length; i++) {
        $("<option value='" + tdmode[i] + "'>" + kdt[i] + "</option>").appendTo("#Widedynamic");
    }
    // 图像镜像
    $("#ImageMirroring").empty();
    var txj = $.i18n.prop("i18n-ImageMirroring-value").split(",");
    for (var i = 0; i < txj.length; i++) {
        $("<option value='" + tjmode[i] + "'>" + txj[i] + "</option>").appendTo("#ImageMirroring");
    }
    // 灵敏度
    $("#ImageSensity").empty();
    var lmds = $.i18n.prop("i18n-sensitivity-value").split(",");
    for (var i = 0; i < lmds.length; i++) {
        $("<option value='" + lmd[i] + "'>" + lmds[i] + "</option>").appendTo("#ImageSensity");
    }

}
// 初始化进度条
function iamges() {
    rangInitIamges = true;
    // 亮度
    $('#brightness').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#brightnessvalues").text($("#brightness").val());
            throttle(setColor);
        },
        onSetPosition: function() {
            $("#brightnessvalues").text($("#brightness").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    // 饱和度
    $('#saturation').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#saturationValue").text($("#saturation").val());
            throttle(setColor);
        },
        onSetPosition: function() {
            $("#saturationValue").text($("#saturation").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    // 对比度
    $('#contrastRatio').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#contrastRatioValue").text($("#contrastRatio").val());
            throttle(setColor);
        },
        onSetPosition: function() {
            $("#contrastRatioValue").text($("#contrastRatio").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    // 色度
    $('#tone').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#toneValue").text($("#tone").val());
            throttle(setColor);
        },
        onSetPosition: function() {
            $("#toneValue").text($("#tone").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    // 锐度
    $('#Sharpness').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#SharpnessValue").text($("#Sharpness").val());
            throttle(setColor);
        },
        onSetPosition: function() {
            $("#SharpnessValue").text($("#Sharpness").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
}

// function initLightRange() {
//     rangInitDraw = true;
//     //白光亮度
//     $('#whitelightness').jRange({
//         from: 0,
//         to: 100,
//         // step: 1,
//         scale: 1,
//         format: '%s',
//         width: 240,
//         showLabels: false,
//         showScale: false,
//         onstatechange: function() {
//             $("#whitelightnessValue").text($("#whitelightness").val());
//             throttle(setIrCutFilter);
//         },
//         onSetPosition: function() {
//             $("#whitelightnessValue").text($("#whitelightness").val());
//         },
//         onMouseDown: function() {},
//         onMouseUp: function() {

//         }
//     });
//     //无极白光--手动阈值-开灯阈值
//     $('#Thresholdness').jRange({
//         from: 0,
//         to: 100,
//         // step: 1,
//         scale: 1,
//         format: '%s',
//         width: 240,
//         showLabels: false,
//         showScale: false,
//         onstatechange: function() {
//             $("#ThresholdnessValue").text($("#Thresholdness").val());
//             throttle(setIrCutFilter);
//         },
//         onSetPosition: function() {
//             $("#ThresholdnessValue").text($("#Thresholdness").val());
//         },
//         onMouseDown: function() {},
//         onMouseUp: function() {

//         }
//     });
//     //无极白光--手动阈值-关灯阈值
//     $('#offthresholdness').jRange({
//         from: 0,
//         to: 100,
//         // step: 1,
//         scale: 1,
//         format: '%s',
//         width: 240,
//         showLabels: false,
//         showScale: false,
//         onstatechange: function() {
//             $("#offthresholdnessValue").text($("#offthresholdness").val());
//             throttle(setIrCutFilter);
//         },
//         onSetPosition: function() {
//             $("#offthresholdnessValue").text($("#offthresholdness").val());
//         },
//         onMouseDown: function() {},
//         onMouseUp: function() {

//         }
//     });
// }
// 全彩白光下的定时时间
function setTimed() {
    var startime = $(get_xml_doc).find("IrCutFillter").eq(0).find("CustomStartTime").eq(0).text();
    var endtime = $(get_xml_doc).find("IrCutFillter").eq(0).find("CustomStopTime").eq(0).text();
    var stime = startime.split('T')[1];
    var etime = endtime.split('T')[1];
    if (startime == "" && endtime == "") {
        $("#st_con_hour").val("18");
        $("#st_con_minute").val("00");
        $("#st_con_second").val("00");
        $("#en_ic_hour1").val("06");
        $("#en_ic_minute1").val("00");
        $("#en_ic_second1").val("00");
    } else {
        $("#st_con_hour").val(stime.substring(0, 2));
        $("#st_con_minute").val(stime.substring(2, 4));
        $("#st_con_second").val(stime.substring(4, 6));
        $("#en_ic_hour1").val(etime.substring(0, 2));
        $("#en_ic_minute1").val(etime.substring(2, 4));
        $("#en_ic_second1").val(etime.substring(4, 6));
    }
}
// 无极白下的定时时间
function setWJBtimed() {
    var startime = $(get_xml_doc).find("IrCutFillter").eq(0).find("VarWhiteModeStartTime").eq(0).text();
    var endtime = $(get_xml_doc).find("IrCutFillter").eq(0).find("VarWhiteModeStopTime").eq(0).text();
    var stime = startime.split('T')[1];
    var etime = endtime.split('T')[1];
    if (startime == "" && endtime == "") {
        $("#st_con_hour1").val("18");
        $("#st_con_minute1").val("00");
        $("#st_con_second1").val("00");
        $("#en_ic_hour2").val("06");
        $("#en_ic_minute2").val("00");
        $("#en_ic_second2").val("00");
    } else {
        $("#st_con_hour1").val(stime.substring(0, 2));
        $("#st_con_minute1").val(stime.substring(2, 4));
        $("#st_con_second1").val(stime.substring(4, 6));
        $("#en_ic_hour2").val(etime.substring(0, 2));
        $("#en_ic_minute2").val(etime.substring(2, 4));
        $("#en_ic_second2").val(etime.substring(4, 6));
    }

}


// 获取基本图像信息
function getIrCutFilter(ch) {
    var url;
    url = window.config.baseUrl + "/Images/" + ch + "/IrCutFilter";
    $.ajax({
        url: url,
        type: "GET",
        async: false,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            get_xml_doc = xmlDoc;
            var nightMode = $(xmlDoc).find('IrCutFillter').eq(0).find('Mode').eq(0).text();
            if (nightMode === "normal white" || nightMode === "color" || nightMode === "intelligent" || nightMode === "variableinfraredlight" || nightMode === "variablewhitelight") {
                $("#NightvisionMode").select2('val', nightMode);
                $("#IR-CUT-mode").select2('val', im_irmode ? im_irmode : 'passivity');
                if (im_irmode == "initiative") { //主
                    //IR-CUT切换时间 Switchingtimeness
                    $("#Switchingtimeness").val($(get_xml_doc).find("IrCutFillter").eq(0).find("InitiveSwitchTime").eq(0).text());
                    $("#SwitchingtimenessValue").text($(get_xml_doc).find("IrCutFillter").eq(0).find("InitiveSwitchTime").eq(0).text());
                } else {
                    $("#Switchingtimeness").val($(get_xml_doc).find("IrCutFillter").eq(0).find("PassivitySwitchTime").eq(0).text());
                    $("#SwitchingtimenessValue").text($(get_xml_doc).find("IrCutFillter").eq(0).find("PassivitySwitchTime").eq(0).text());
                };
            } else {
                $("#IR-CUT-mode").select2('val', nightMode); //IR-CUT模式
                if (nightMode == "initiative") { //主
                    $("#Switchingtimeness").val($(get_xml_doc).find("IrCutFillter").eq(0).find("InitiveSwitchTime").eq(0).text());
                    $("#SwitchingtimenessValue").text($(get_xml_doc).find("IrCutFillter").eq(0).find("InitiveSwitchTime").eq(0).text());
                } else { //被动
                    $("#Switchingtimeness").val($(get_xml_doc).find("IrCutFillter").eq(0).find("PassivitySwitchTime").eq(0).text());
                    $("#SwitchingtimenessValue").text($(get_xml_doc).find("IrCutFillter").eq(0).find("PassivitySwitchTime").eq(0).text());
                };
                $("#NightvisionMode").select2('val', 'common');
            }
            //初始化全彩白光
            initColors(xmlDoc);
            initIntelligent(xmlDoc);
            initWhitelight(xmlDoc);
            initRedlight(xmlDoc);
            initNormalWhite(xmlDoc);
            // if (!rangInitDraw) {
            //     initLightRange() //初始化不复用的滑块 必须放在后面
            // } 


            //智能双光----延时时间
            $("#interval").val($(xmlDoc).find('IrCutFillter').eq(0).find('ColorLastTime').eq(0).text());
            //IR-CUT反向 所有模式下都存在
            var IrCutReverse = $(xmlDoc).find('IrCutFillter').eq(0).find('IrCutReverse').eq(0).text();
            if ("notsupport" == IrCutReverse) {
                $(".ircutResev").hide();
            } else {
                $(".ircutResev").show();
                if (IrCutReverse == "reverse" || IrCutReverse == "true") {
                    $('#cutOpen').addClass('active');
                    checkboxvalue = true;
                } else {
                    $('#cutClose').addClass('active');
                    checkboxvalue = false;
                }
            };
            //普通红外下的 定时
            initCommonRed(xmlDoc);
            changeNightMode();
            // 图像模式
            $("#ImageMode").select2('val', $(xmlDoc).find('IrCutFillter').eq(0).find('ImageMode').eq(0).text());
            if (!rangInitDraw) {
                drawIRCutLevel(); //绘画IRCutlevel信息
            }

        },
        error: function(xhr, textStatus, errorThrown) {}
    });
}
var im_irmode;
// 保存基本图像信息
function setIrCutFilter(num) {
    if (config.isSupportMultiChannel) {
        num = num || $("#channel").select2('val');
    } else {
        num = 1;
    }
    var nightMode = $("#NightvisionMode").select2('val');
    var icMode = "";
    if ($("#NightvisionMode").val() != "common") {
        icMode = $("#NightvisionMode").select2('val');
        im_irmode = $("#IR-CUT-mode").select2('val'); //保存ircut模式值
    } else {
        icMode = $("#IR-CUT-mode").select2('val'); //保存ircut模式值
    }
    if (parseInt($("#offthresholdness").val()) > parseInt($("#Thresholdness").val())) {
        $.optionBootoast($.i18n.prop('i18n-trunlightmsg'), "danger");
        if (config.isSupportMultiChannel) {
            getIrCutFilter(num);
        } else {
            getIrCutFilter();
        }

        return;
    }
    //全彩白下的定时
    var colorTimeS = $("#st_con_hour").val() + ":" + $("#st_con_minute").val() + ":" + $("#st_con_second").val();
    var colorTimeE = $("#en_ic_hour1").val() + ":" + $("#en_ic_minute1").val() + ":" + $("#en_ic_second1").val();
    if (!validateTime(colorTimeS, colorTimeE)) {
        if (config.isSupportMultiChannel) {
            getIrCutFilter(num);
        } else {
            getIrCutFilter();
        }
        return;
    }
    //无极白下的定时
    var whihtTimeS = $("#st_con_hour1").val() + ":" + $("#st_con_minute1").val() + ":" + $("#st_con_second1").val();
    var whihtTimeE = $("#en_ic_hour2").val() + ":" + $("#en_ic_minute2").val() + ":" + $("#en_ic_second2").val();
    if (!validateTime(whihtTimeS, whihtTimeE)) {
        if (config.isSupportMultiChannel) {
            getIrCutFilter(num);
        } else {
            getIrCutFilter();
        }
        return;
    }
    //普通红外下的定时
    var commonRedTimeS = $("#st_con_hour2").val() + ":" + $("#st_con_minute2").val() + ":" + $("#st_con_second2").val();
    var commonRedTimeE = $("#en_ic_hour3").val() + ":" + $("#en_ic_minute3").val() + ":" + $("#en_ic_second3").val();
    if (!validateTime(commonRedTimeS, commonRedTimeE)) {
        if (config.isSupportMultiChannel) {
            getIrCutFilter(num);
        } else {
            getIrCutFilter();
        }
        return;
    }
    if (colorLightCap.isColorThreshold == 'true') {
        colorxml = "<ColorNightThreshold>" + $("#imcolorthreshold").val() + "</ColorNightThreshold>";
    };
    if (intelligentLightCap.isIntelligentThreshold == 'true') {
        Intelligentxml = "<IntelligentThreshold>" + $("#imintelligentthreshold").val() + "</IntelligentThreshold>";
    };
    var fxvalue;
    if (checkboxvalue) {
        fxvalue = "reverse";
    } else {
        fxvalue = "positive";
    }
    var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><IrCutFillter Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'>" +
        "<Mode>" + icMode + "</Mode>" +
        "<DayStartTime>" + commonRedTimeS + "</DayStartTime>" +
        "<DayEndTime>" + commonRedTimeE + "</DayEndTime>" +
        "<Sensitivity>" + $("#CUTsensitivity").val() + "</Sensitivity>" +
        "<SwitchTime>" + $("#Switchingtimeness").val() + "</SwitchTime>" +
        "<IrCutReverse>" + fxvalue + "</IrCutReverse>" +
        "<ColorLastTime>" + $("#interval").val() + "</ColorLastTime>" +
        "<ImageMode>" + $("#ImageMode").val() + "</ImageMode>" +
        "<VariableInfraredThreshold>" + $("#imImage-1").val() + "</VariableInfraredThreshold>" +
        "<VariableWhiteThreshold>" + $("#imImage-2").val() + "</VariableWhiteThreshold>" +
        "<VarWhiteWorkMode>" + $("#Controldirection").val() + "</VarWhiteWorkMode>" + //控制方向
        "<VarWhiteModeStartTime>00000000T" + $("#st_con_hour1").val() + $("#st_con_minute1").val() + $("#st_con_second1").val() + "</VarWhiteModeStartTime>" + //无极白开始时间
        "<VarWhiteModeStopTime>00000000T" + $("#en_ic_hour2").val() + $("#en_ic_minute2").val() + $("#en_ic_second2").val() + "</VarWhiteModeStopTime>" + //无极白结束时间
        "<NormalWhiteLightOffLimit>" + $("#imturnofflight").val() + "</NormalWhiteLightOffLimit><NormalWhiteLightOnLimit>" + $("#imturnlight").val() + "</NormalWhiteLightOnLimit>" +
        "<VarWhiteLightOnThreshold>" + $("#Thresholdness").val() + "</VarWhiteLightOnThreshold>" +
        "<VarWhiteLightOffThreshold>" + $("#offthresholdness").val() + "</VarWhiteLightOffThreshold>" +
        "<ColorWorkmode>" + $("#ControlMode").val() + "</ColorWorkmode>" + //全彩白的控制模式
        "<CustomStartTime>00000000T" + $("#st_con_hour").val() + $("#st_con_minute").val() + $("#st_con_second").val() + "</CustomStartTime>" + //全彩开始时间
        "<CustomStopTime>00000000T" + $("#en_ic_hour1").val() + $("#en_ic_minute1").val() + $("#en_ic_second1").val() + "</CustomStopTime>" + //全彩结束时间
        "<VarInfraredWorkMode>" + $("#workingModeRed").select2('val') + "</VarInfraredWorkMode>" +
        "<VarInfraredBrightness>" + $("#Infraredness").val() + "</VarInfraredBrightness>" + //红外亮度
        "<VarWhiteControlMode>" + $("#im_workmodewrite").select2('val') + "</VarWhiteControlMode>" + //无极白 工作模式
        "<VarWhiteBrightness>" + $("#whitelightness").val() + "</VarWhiteBrightness>" + colorxml + Intelligentxml +
        "</IrCutFillter>";
    var cyURL;
    if (num) {
        cyURL = window.config.baseUrl + "/Images/" + num + "/IrCutFilter";
    } else {
        cyURL = window.config.baseUrl + "/Images/1/IrCutFilter";
    }
    $.ajax({
        type: "PUT",
        url: cyURL,
        async: false,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
            // if (config.isSupportMultiChannel) {
            //     getIrCutFilter(num);
            // } else {
            //     getIrCutFilter();
            // }
        }
    });
    // }
}

function validateTime(startTime, endTime) {
    if (startTime == endTime) {
        $.optionBootoast($.i18n.prop('i18n-storage_time_msg'), "danger");
        return false;
    }
    return true;
}

function initIntelligent(xmlDoc) {
    if (intelligentLightCap.isIntelligentThreshold == 'true') {
        $("#imintelligentthreshold").val($(xmlDoc).find('IrCutFillter').eq(0).find('IntelligentThreshold').eq(0).text());
        $("#imintelligentthresholdvalue").text($(xmlDoc).find('IrCutFillter').eq(0).find('IntelligentThreshold').eq(0).text());
        if (rangInitDraw) {
            $("#imintelligentthreshold").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('IntelligentThreshold').eq(0).text());
        }
    };
}
//初始化全彩白光
function initColors(xmlDoc) {
    //全彩白-控制模式(只存在于全彩白下)
    $("#ControlMode").select2('val', $(xmlDoc).find("IrCutFillter").eq(0).find("ColorWorkmode").eq(0).text());
    if (colorLightCap.isColorThreshold == 'true') { //全彩白光起效
        $("#imcolorthreshold").val($(xmlDoc).find('IrCutFillter').eq(0).find('ColorNightThreshold').eq(0).text());
        $("#imcolorthresholdvalue").text($(xmlDoc).find('IrCutFillter').eq(0).find('ColorNightThreshold').eq(0).text());
        if (rangInitDraw) { //初始化过可以直接设置值
            $("#imcolorthreshold").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('ColorNightThreshold').eq(0).text());
        }
    };
    setTimed(); //全彩白下的定时时间
}
//初始化无极白
function initWhitelight(xmlDoc) {
    $("#im_workmodewrite").select2('val', $(xmlDoc).find('IrCutFillter').eq(0).find('VarWhiteControlMode').eq(0).text());
    $("#Controldirection").select2('val', $(xmlDoc).find('IrCutFillter').eq(0).find('VarWhiteWorkMode').eq(0).text());
    $("#whitelightness").val($(xmlDoc).find('IrCutFillter').eq(0).find('VarWhiteBrightness').eq(0).text()); //白光亮度
    $("#whitelightnessValue").text($(xmlDoc).find('IrCutFillter').eq(0).find('VarWhiteBrightness').eq(0).text());
    $("#Thresholdness").val($(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOnThreshold").text()); //开灯阈值
    $("#ThresholdnessValue").text($(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOnThreshold").text());
    $("#offthresholdness").val($(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOffThreshold").text()); //关灯阈值
    $("#offthresholdnessValue").text($(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOffThreshold").text());
    //起效亮度
    $("#imImage-2").val($(xmlDoc).find('IrCutFillter').eq(0).find('VariableWhiteThreshold').eq(0).text());
    $("#imImagevalue-2").text($(xmlDoc).find('IrCutFillter').eq(0).find('VariableWhiteThreshold').eq(0).text());
    if (rangInitDraw) {
        $("#whitelightness").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('VarWhiteBrightness').eq(0).text());
        $("#offthresholdness").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOffThreshold").text());
        $("#imImage-2").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('VariableWhiteThreshold').eq(0).text());
        $("#Thresholdness").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find("VarWhiteLightOnThreshold").text());
    }
    setWJBtimed();
}
//初始化 红外数据
function initRedlight(xmlDoc) {
    //工作模式
    $("#workingModeRed").select2('val', $(xmlDoc).find('IrCutFillter').eq(0).find('VarInfraredWorkMode').eq(0).text());
    //红外亮度
    $("#Infraredness").val($(xmlDoc).find('IrCutFillter').eq(0).find('VarInfraredBrightness').eq(0).text());
    $("#InfrarednessValue").text($(xmlDoc).find('IrCutFillter').eq(0).find('VarInfraredBrightness').eq(0).text());
    //起效亮度
    $("#imImage-1").val($(xmlDoc).find('IrCutFillter').eq(0).find('VariableInfraredThreshold').eq(0).text());
    $("#imImagevalue-1").text($(xmlDoc).find('IrCutFillter').eq(0).find('VariableInfraredThreshold').eq(0).text());
    if (rangInitDraw) {
        $("#Infraredness").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('VarInfraredBrightness').eq(0).text());
        $("#imImage-1").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('VariableInfraredThreshold').eq(0).text());
    }
}

function initNormalWhite(xmlDoc) {
    $("#imturnlight").val($(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOnLimit").text());
    $("#imturnlightvalue").text($(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOnLimit").text());
    $("#imturnofflight").val($(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOffLimit").text());
    $("#imturnofflightvalue").text($(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOffLimit").text());
    if (rangInitDraw) {
        $("#imturnlight").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOnLimit").text());
        $("#imturnofflight").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find("NormalWhiteLightOffLimit").text());
    }
}

function initCommonRed(xmlDoc) {
    //普通红外--自动模式---ircut灵敏度
    $("#CUTsensitivity").val($(xmlDoc).find('IrCutFillter').eq(0).find('Sensitivity').eq(0).text());
    $("#CUTsensitivityValue").text($(xmlDoc).find('IrCutFillter').eq(0).find('Sensitivity').eq(0).text());
    if (rangInitDraw) {
        $("#CUTsensitivity").jRange("setValue", $(xmlDoc).find('IrCutFillter').eq(0).find('Sensitivity').eq(0).text());
    }
    //普通红外-定时---时间
    var startTime = $(xmlDoc).find('IrCutFillter').eq(0).find('DayStartTime').eq(0).text();
    var endTime = $(xmlDoc).find('IrCutFillter').eq(0).find('DayEndTime').eq(0).text();
    var startHour = startTime.toString().substring(0, 2);
    var startMin = startTime.toString().substring(3, 5);
    var startSec = startTime.toString().substring(6, 8);
    var endHour = endTime.toString().substring(0, 2);
    var endMin = endTime.toString().substring(3, 5);
    var endSec = endTime.toString().substring(6, 8);
    $("#st_con_hour2").val(startHour);
    $("#st_con_minute2").val(startMin);
    $("#st_con_second2").val(startSec);
    $("#en_ic_hour3").val(endHour);
    $("#en_ic_minute3").val(endMin);
    $("#en_ic_second3").val(endSec);
}
//初始化所有基本配置进度条
function drawIRCutLevel() {
    rangInitDraw = true;
    //白光亮度
    $('#whitelightness').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#whitelightnessValue").text($("#whitelightness").val());
            throttle(setIrCutFilter);
        },
        onSetPosition: function() {
            $("#whitelightnessValue").text($("#whitelightness").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    //无极白光--手动阈值-开灯阈值
    $('#Thresholdness').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#ThresholdnessValue").text($("#Thresholdness").val());
            throttle(setIrCutFilter);
        },
        onSetPosition: function() {
            $("#ThresholdnessValue").text($("#Thresholdness").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    //无极白光--手动阈值-关灯阈值
    $('#offthresholdness').jRange({
        from: 0,
        to: 100,
        // step: 1,
        scale: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#offthresholdnessValue").text($("#offthresholdness").val());
            throttle(setIrCutFilter);
        },
        onSetPosition: function() {
            $("#offthresholdnessValue").text($("#offthresholdness").val());
        },
        onMouseDown: function() {},
        onMouseUp: function() {

        }
    });
    $('#imturnlight').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imturnlightvalue").text($("#imturnlight").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imturnlightvalue").text($("#iimturnlight").val());
        },
    });
    $('#imturnofflight').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imturnofflightvalue").text($("#imturnofflight").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imturnofflightvalue").text($("#imturnofflight").val());
        },
    });
    $('#imImage-2').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imImagevalue-2").text($("#imImage-2").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imImagevalue-2").text($("#imImage-2").val());
        },
    });
    $('#imImage-1').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imImagevalue-1").text($("#imImage-1").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imImagevalue-1").text($("#imImage-1").val());
        },
    });
    $('#imcolorthreshold').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imcolorthresholdvalue").text($("#imcolorthreshold").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imcolorthresholdvalue").text($("#imcolorthreshold").val());
        },
    });
    $('#imintelligentthreshold').jRange({ //智能双关下的起效亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#imintelligentthresholdvalue").text($("#imintelligentthreshold").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#imintelligentthresholdvalue").text($("#imintelligentthreshold").val());
        },
    });
    $('#Infraredness').jRange({ //红外亮度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#InfrarednessValue").text($("#Infraredness").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#InfrarednessValue").text($("#Infraredness").val());
        },
    });
    $('#Thresholdness').jRange({ //开灯阈值
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#ThresholdnessValue").text($("#Thresholdness").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#ThresholdnessValue").text($("#Thresholdness").val());
        },
    });
    $('#offthresholdness').jRange({ //关灯阈值
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#offthresholdnessValue").text($("#offthresholdness").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#offthresholdnessValue").text($("#offthresholdness").val());
        },
    });
    $('#CUTsensitivity').jRange({ //ir-cut灵敏度
        from: 0,
        to: 100,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#CUTsensitivityValue").text($("#CUTsensitivity").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            $("#CUTsensitivityValue").text($("#CUTsensitivity").val());
        },
    });
    $('#Switchingtimeness').jRange({ //ir-cut切换时间
        from: 3,
        to: 15,
        step: 1,
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#SwitchingtimenessValue").text($("#Switchingtimeness").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                throttle(setIrCutFilter);
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            // if (gs_flag == 0 && gs_imred_flag != 0) {
            $("#SwitchingtimenessValue").text($("#Switchingtimeness").val());
            // }
            // gs_imred_flag = 1;
        },
    });

}
// 获取部分主要进度条数值
function getColor(ch) {
    var url;
    url = window.config.baseUrl + "/Images/" + ch + "/Color";
    $.ajax({
        url: url,
        type: "GET",
        async: false,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            $("#brightness").val($(xmlDoc).find('Color').eq(0).find('Brightness').eq(0).text()); //亮度
            $("#brightnessvalues").text($(xmlDoc).find('Color').eq(0).find('Brightness').eq(0).text());
            $("#contrastRatio").val($(xmlDoc).find('Color').eq(0).find('Contrast').eq(0).text()); //对比度
            $("#contrastRatioValue").text($(xmlDoc).find('Color').eq(0).find('Contrast').eq(0).text());
            $("#saturation").val($(xmlDoc).find('Color').eq(0).find('Saturation').eq(0).text()); //饱和度
            $("#saturationValue").text($(xmlDoc).find('Color').eq(0).find('Saturation').eq(0).text());
            $("#tone").val($(xmlDoc).find('Color').eq(0).find('Hue').eq(0).text()); //色度
            $("#toneValue").text($(xmlDoc).find('Color').eq(0).find('Hue').eq(0).text());
            $("#Sharpness").val($(xmlDoc).find('Color').eq(0).find('Sharpness').eq(0).text()); //锐度
            $("#SharpnessValue").text($(xmlDoc).find('Color').eq(0).find('Sharpness').eq(0).text());
            if (!rangInitIamges) { //首次初始化
                iamges();
            } else {
                $("#brightness").jRange("setValue", $(xmlDoc).find('Color').eq(0).find('Brightness').eq(0).text());
                $("#contrastRatio").jRange("setValue", $(xmlDoc).find('Color').eq(0).find('Contrast').eq(0).text());
                $("#saturation").jRange("setValue", $(xmlDoc).find('Color').eq(0).find('Saturation').eq(0).text());
                $("#tone").jRange("setValue", $(xmlDoc).find('Color').eq(0).find('Hue').eq(0).text());
                $("#Sharpness").jRange("setValue", $(xmlDoc).find('Color').eq(0).find('Sharpness').eq(0).text());
            }

        }
    });
}
// 节流操作解决多次提示保存
function throttle(method, context) {
    clearTimeout(method.tId);
    method.tId = setTimeout(function() {
        method.call(context);
    }, 1000);
}
// 保存部分主要进度条数值
function setColor(num) {
    if (config.isSupportMultiChannel) {
        num = num || $("#channel").select2("val");
    } else {
        num = 1;
    }
    if ("admin" == config.user || "super_admin" == config.user) {
        var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><Color Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><Mode>manual</Mode><Brightness>" + $("#brightness").val() + "</Brightness><Contrast>" + $("#contrastRatio").val() + "</Contrast><Saturation>" + $("#saturation").val() + "</Saturation><Hue>" + $("#tone").val() + "</Hue><Sharpness>" + $("#Sharpness").val() + "</Sharpness></Color>";
        var cyURL;
        num = num || 1;
        cyURL = window.config.baseUrl + "/Images/" + num + "/Color";
        $.ajax({
            type: "PUT",
            url: cyURL,
            processData: false,
            data: cyXml,
            beforeSend: function(xhr) {
                xhr.setRequestHeader("If-Modified-Since", "0");
            },
            complete: function(xhr, textStatus) {
                SaveState(xhr);
            }
        });
    } else {
        $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
    }
}
// 获取部分图像配置（3D降噪，背光补偿，宽动态，图像镜像，抗闪模式，抗闪强度）
function getImageBasic(ch) {
    var url;
    url = window.config.baseUrl + "/Images/" + ch + "/Basic";
    $.ajax({
        url: url,
        type: "GET",
        async: true,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            $("#noisereduction").val($(xmlDoc).find('Basic').eq(0).find('NoiseReduce').eq(0).text()).trigger('change.select2'); //3D降噪
            // $("#BacklightCompensation").val($(xmlDoc).find('Basic').eq(0).find('BLC').eq(0).text()).trigger('change.select2'); //背光补偿
            var chek = $(xmlDoc).find('Basic').eq(0).find('BLC').eq(0).text();
            if (chek == "open") {
                $('#boff').addClass('active');
            } else {
                $("#bclos").addClass('active');
            }
            $("#Widedynamic").val($(xmlDoc).find('Basic').eq(0).find('WDR').eq(0).text()).trigger('change.select2'); //宽动态
            if ('notsupport' == $(xmlDoc).find('Basic').eq(0).find('FlipMode').eq(0).text()) { //图像镜像
                $("#sufile").hide();
            } else {
                $("#ImageMirroring").val($(xmlDoc).find('Basic').eq(0).find('FlipMode').eq(0).text()).trigger('change.select2');
            }
            $("#AntiflashMode").val($(xmlDoc).find('Basic').eq(0).find('powerLineFrequencyMode').eq(0).text()).trigger('change.select2'); //抗闪模式
            $("#FlashoverResis").val($(xmlDoc).find('Basic').eq(0).find('powerLineFrequencyStrength').eq(0).text()).trigger('change.select2'); //抗闪强度
        },
        error: function(xhr, textStatus, errorThrown) {}
    });
}
// 保存部分图像配置（3D降噪，背光补偿，宽动态，图像镜像，抗闪模式，抗闪强度）
function setImageBasic(num) {
    var bgvalue;
    var bo = document.getElementById("boff");
    var arr = []
    for (var a = 0; a < bo.classList.length; a++) {
        arr.push(bo.classList[a])
    }
    if (arr.indexOf('active') != -1) {
        bgvalue = "open";
    } else {
        bgvalue = "close";
    }
    var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><Basic Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><powerLineFrequencyMode>" + $("#AntiflashMode").val() + "</powerLineFrequencyMode><NoiseReduce>" + $("#noisereduction").val() + "</NoiseReduce><BLC>" + bgvalue + "</BLC><WDR>" + $("#Widedynamic").val() + "</WDR><FlipMode>" + $("#ImageMirroring").val() + "</FlipMode>" +
        "<powerLineFrequencyStrength>" + $("#FlashoverResis").val() + "</powerLineFrequencyStrength></Basic>";

    var cyURL;
    num = num || 1;
    cyURL = window.config.baseUrl + "/Images/" + num + "/Basic";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
        }
    });
}
// 白平衡改变
function changeb() {
    if ($("#WhiteBalance").val() == 'manual') {
        $(".gain").show();
    } else {
        $(".gain").hide();
    }

}
// 获取白平衡条件（白平衡以及红蓝增益）
function getWhiteBalance(ch) {
    url = window.config.baseUrl + "/Images/" + ch + "/WhiteBalance";
    $.ajax({
        url: url,
        type: "GET",
        async: true,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            $("#WhiteBalance").val($(xmlDoc).find('WhiteBlance').eq(0).find('Mode').eq(0).text()).trigger('change.select2'); //白平衡
            changeb();
            $("#Redgain").val($(xmlDoc).find('WhiteBlance').eq(0).find('GainRed').eq(0).text()); //红增益
            $("#RedgainValue").text($(xmlDoc).find('WhiteBlance').eq(0).find('GainRed').eq(0).text());
            $("#Bluegain").val($(xmlDoc).find('WhiteBlance').eq(0).find('GainBlue').eq(0).text()); //蓝增益
            $("#BluegainValue").text($(xmlDoc).find('WhiteBlance').eq(0).find('GainBlue').eq(0).text());
            if (!rangInitWhiteBalance) {
                drawWhiteBalance();
            }

        }
    });
}
// 保存白平衡条件（白平衡以及红蓝增益）
function setWhiteBalance(num) {
    if ("admin" == config.user || "super_admin" == config.user) {
        var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><WhiteBlance Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><Mode>" + $("#WhiteBalance").val() + "</Mode><GainRed>" + $("#Redgain").val() + "</GainRed><GainBlue>" + $("#Bluegain").val() + "</GainBlue></WhiteBlance>";
        var cyURL;
        num = num || 1;
        cyURL = window.config.baseUrl + "/Images/" + num + "/WhiteBalance";
        $.ajax({
            type: "PUT",
            url: cyURL,
            processData: false,
            data: cyXml,
            beforeSend: function(xhr) {
                xhr.setRequestHeader("If-Modified-Since", "0");
            },
            complete: function(xhr, textStatus) {
                SaveState(xhr);
            }
        });
    } else {
        $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
    }
}
// 初始化增益进度条
function drawWhiteBalance() {
    rangInitWhiteBalance = true;
    $('#Redgain').jRange({ //红增益
        from: 0,
        to: 100,
        step: 1,
        //scale: [0,25,50,75,100],
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#RedgainValue").text($("#Redgain").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            // if (gs_flag == 0 && gs_imred_flag != 0) {
            $("#RedgainValue").text($("#Redgain").val());
            // }
            // gs_imred_flag = 1;
        },
        onMouseDown: function() {
            $("#RedgainValue").text($("#Redgain").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
            // gs_flag = 1;
        },
        onMouseUp: function() {
            $("#RedgainValue").text($("#imRedgainred").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
            // gs_flag = 0;
        }
    });
    $('#Bluegain').jRange({ //蓝增益
        from: 0,
        to: 100,
        step: 1,
        //scale: [3,5,10,15],
        format: '%s',
        width: 240,
        showLabels: false,
        showScale: false,
        onstatechange: function() {
            $("#BluegainValue").text($("#Bluegain").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
        },
        onSetPosition: function() {
            // if (gs_flag == 0 && gs_iimblue_flag != 0) {
            $("#BluegainValue").text($("#Bluegain").val());
            // }
            // gs_iimblue_flag = 1;
        },
        onMouseDown: function() {
            $("#BluegainValue").text($("#Bluegain").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
            // gs_flag = 1;
        },
        onMouseUp: function() {
            $("#BluegainValue").text($("#Bluegain").val());
            if ("admin" == config.user || "super_admin" == config.user) {
                setWhiteBalance();
            } else {
                $.optionBootoast($.i18n.prop('i18n-propoe'), "danger");
            }
            // gs_flag = 0;
        }
    });
}
//获取（光圈类型 曝光时间 增益）
function getExposure(ch) {
    var url;
    if (config.isSupportMultiChannel) {
        url = window.config.baseUrl + "/Images/" + ch + "/Exposure";
    } else {
        url = window.config.baseUrl + "/Images/1/Exposure";
    }
    $.ajax({
        url: url,
        type: "GET",
        async: true,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            $("#ApertureType").val($(xmlDoc).find('Exposure').eq(0).find('IrisType').eq(0).text()).trigger('change.select2'); //光圈类型
            $("#ExposureTime").val($(xmlDoc).find('Exposure').eq(0).find('shutter').eq(0).text()).trigger('change.select2'); //曝光时间
            $("#gain").val($(xmlDoc).find('Exposure').eq(0).find('Gain').eq(0).text()).trigger('change.select2'); //增益

        },
        error: function(xhr, textStatus, errorThrown) {}
    });
}
// 保存（光圈类型 曝光时间 增益）
function setExposure(num) {
    var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><Exposure Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><IrisType>" + $("#ApertureType").val() + "</IrisType><shutter>" + $("#ExposureTime").val() + "</shutter><Gain>" + $("#gain").val() + "</Gain><Shuttermode></Shuttermode></Exposure>";
    var cyURL;
    num = num || 1;
    cyURL = window.config.baseUrl + "/Images/" + num + "/Exposure";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
        }
    });
}
// 获取去雾
function getScene(ch) {
    var url;
    url = window.config.baseUrl + "/Images/" + ch + "/Scene";
    $.ajax({
        url: url,
        type: "GET",
        async: true,
        timeout: 15000,

        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            $("#imdefog").val($(xmlDoc).find('Scene').eq(0).find('FogValue').eq(0).text());
            $("#imedefogvalue").text($(xmlDoc).find('Scene').eq(0).find('FogValue').eq(0).text());
            var delopval = parseInt($(xmlDoc).find('Scene').eq(0).find('FogValue').eq(0).text());
            if ([0, 30, 60, 90].indexOf(delopval) == -1) {
                $("#de-fogging").val("0").trigger('change.select2');
            } else {
                $("#de-fogging").val($(xmlDoc).find('Scene').eq(0).find('FogValue').eq(0).text()).trigger('change.select2');
            }
        }
    });
}
// 保存去雾
function setScene(num) {
    var cyXml = "<?xml version='1.0' encoding='UTF-8' ?><Scene Version='1.0' xmlns='http://www.zwcloud.wang/ver10/XMLSchema'><Support></Support><Mode></Mode><LDC></LDC><Fog></Fog><FogValue>" + $("#de-fogging").val() + "</FogValue><Gamma></Gamma></Scene>";
    var cyURL;
    num = num || 1;
    cyURL = window.config.baseUrl + "/Images/" + num + "/Scene";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
        }
    });
}
// 获取灵敏度
function getImageSens(ch) {
    var url;
    url = window.config.baseUrl + "/Pictures/" + ch + "/Motion";
    $.ajax({
        url: url,
        type: "GET",
        async: false,
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            gs_xml_doc = xmlDoc;
            $("#ImageSensity").val($(xmlDoc).find('Motion').eq(0).find('Senstive').eq(0).text()).trigger('change.select2');
        }
    });
}
// 保存灵敏度
function setImageSens(num) {
    $(gs_xml_doc).find('Motion').eq(0).find('Senstive').eq(0).text($("#ImageSensity").val());
    var cyXml = gs_xml_doc;
    var cyURL;
    num = num || 1;
    cyURL = window.config.baseUrl + "/Pictures/" + num + "/Motion";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
        }
    });
}
//新灯板能力
function getLightCap(d, s, n) {
    $.ajax({
        url: window.config.baseUrl + "/System/LightCap",
        type: "GET",
        async: false,
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            var ch = ($("#channel").val() ? $("#channel").val() - 1 : 0);
            var $xml = $(xmlDoc);
            $xml.find("Channel").each(function() {
                var channelID = $(this).attr("ChannelID");
                if (channelID == ch) {
                    var colorMode = $(this).find("LightMode")
                        .eq(0)
                        .find("ColorNight")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    if (colorMode === "true") {
                        d.push("color");
                        s.push(n[0]);
                    }
                    //智能双关
                    var intelligentMode = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text(); //智能双光
                    if (intelligentMode === "true") {
                        d.push("intelligent");
                        s.push(n[1]);
                    }
                    //无极红外
                    var variableInfrared = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("VariableInfrared")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text(); //无极红外
                    if (variableInfrared === "true") {
                        d.push("variableinfraredlight");
                        s.push(n[2]);
                    }
                    //无极白光变光
                    var variableWhite = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("VariableWhite")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text(); //无极白光变光
                    if (variableWhite === "true") {
                        d.push("variablewhitelight");
                        s.push(n[3]);
                    }
                    //普通红外夜视
                    var NormalInfrared = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("NormalInfrared")
                        .find("Support")
                        .eq(0)
                        .text();
                    if (NormalInfrared == "true") {
                        d.push("common");
                        s.push(n[n.length - 2]);
                    }
                    //普通白光
                    var normalWhite = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("NormalWhite")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text(); //普通白光
                    if (normalWhite === "true") {
                        d.push("normal white");
                        s.push(n[n.length - 1]);
                    }

                    //智能双关
                    intelligentLightCap.isIntelligentThreshold = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("Threshold")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text(); //智能双光起效
                    if (intelligentLightCap.isIntelligentThreshold == "true") {
                        intelligentLightCap.intelligentThresholdmin = parseInt(
                            $(this)
                            .find("LightMode")
                            .eq(0)
                            .find("IntelligentNight")
                            .eq(0)
                            .find("Threshold")
                            .eq(0)
                            .find("Min")
                            .eq(0)
                            .text()
                        );
                        intelligentLightCap.intelligentThresholdmax = parseInt(
                            $(this)
                            .find("LightMode")
                            .eq(0)
                            .find("IntelligentNight")
                            .eq(0)
                            .find("Threshold")
                            .eq(0)
                            .find("Max")
                            .eq(0)
                            .text()
                        );
                    }
                    intelligentLightCap.intelligentSensitivity = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("Sensitivity")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    //灵敏度范围-----暂时不做
                    intelligentLightCap.intelligentSensitivityMinLevel = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("Sensitivity")
                        .eq(0)
                        .find("MinLevel")
                        .eq(0)
                        .text();
                    intelligentLightCap.intelligentSensitivityMaxLevel = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("Sensitivity")
                        .eq(0)
                        .find("MaxLevel")
                        .eq(0)
                        .text();
                    //智能---延时时间
                    intelligentLightCap.intelligentDelayTime = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("DelayTime")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    //延时时间范围
                    intelligentLightCap.intelligentMinDelay = parseInt(
                        $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("DelayTime")
                        .eq(0)
                        .find("MinDelay")
                        .eq(0)
                        .text()
                    );
                    intelligentLightCap.intelligentMaxDelay = parseInt(
                        $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("IntelligentNight")
                        .eq(0)
                        .find("DelayTime")
                        .eq(0)
                        .find("MaxDelay")
                        .eq(0)
                        .text()
                    );
                    $("#delayTimeRange").html(
                        $.i18n.prop("i18n-range") +
                        intelligentLightCap.intelligentMinDelay +
                        "~" +
                        intelligentLightCap.intelligentMaxDelay +
                        "s"
                    );

                    //全彩白光
                    colorLightCap.isColorThreshold = $(this)
                        .find("LightMode")
                        .find("ColorNight")
                        .eq(0)
                        .find("Auto")
                        .eq(0)
                        .find("Threshold")
                        .eq(0)
                        .find("Support")
                        .text(); //全彩白光下的起效亮度
                    var isSupportcolorPlan = $(this)
                        .find("LightMode")
                        .find("ColorNight")
                        .eq(0)
                        .find("Plan")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    var isSupportcolorauto = $(this)
                        .find("LightMode")
                        .find("ColorNight")
                        .eq(0)
                        .find("Auto")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    isSupportcolorauto == "false" &&
                        $("#ControlMode").find("option").eq(0).remove();
                    isSupportcolorPlan == "false" &&
                        $("#ControlMode").find("option").eq(1).remove();
                    if (
                        isSupportcolorauto == "false" &&
                        isSupportcolorPlan == "false"
                    ) {
                        $("#controlModeBox").hide();
                    } else {
                        $("#controlModeBox").show();
                    }

                    //无极红外
                    var variableInfraredauto = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("VariableInfrared")
                        .eq(0)
                        .find("Auto")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    var variableInfraredManual = $(this)
                        .find("LightMode")
                        .eq(0)
                        .find("VariableInfrared")
                        .eq(0)
                        .find("Manual")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    variableInfraredauto == "false" &&
                        $("#workingModeRed").find("option").eq(0).remove();
                    variableInfraredManual == "false" &&
                        $("#workingModeRed").find("option").eq(1).remove();

                    //无极白
                    var isSupportManual = $(this)
                        .find("LightMode")
                        .find("VariableWhite")
                        .eq(0)
                        .find("Manual")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    var isSupportAuto = $(this)
                        .find("LightMode")
                        .find("VariableWhite")
                        .eq(0)
                        .find("Auto")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    isSupportAuto == "false" &&
                        $("#im_workmodewrite").find("option").eq(0).remove();
                    isSupportManual == "false" &&
                        $("#im_workmodewrite").find("option").eq(1).remove();
                    var isSupporttiming = $(this)
                        .find("LightMode")
                        .find("VariableWhite")
                        .eq(0)
                        .find("Manual")
                        .eq(0)
                        .find("Plan")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    var isSupportthreshold = $(this)
                        .find("LightMode")
                        .find("VariableWhite")
                        .eq(0)
                        .find("Manual")
                        .eq(0)
                        .find("Manual")
                        .eq(0)
                        .find("Support")
                        .eq(0)
                        .text();
                    isSupporttiming == "false" &&
                        $("#Controldirection").find("option").eq(0).remove();
                    isSupportthreshold == "false" &&
                        $("#Controldirection").find("option").eq(1).remove();
                    // 普通白光
            normalWhiteLight.OpenLight = $(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("OpenLight").eq(0).find('Support').text();
            normalWhiteLight.OpenMinThreshold = parseInt($(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("OpenLight").eq(0).find('MinThreshold').text());
            normalWhiteLight.OpenMaxThreshold = parseInt($(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("OpenLight").eq(0).find('MaxThreshold').text());
            normalWhiteLight.CloseLight = $(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("CloseLight").eq(0).find('Support').text();
            normalWhiteLight.CloseLightMinThreshold = parseInt($(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("CloseLight").eq(0).find('MinThreshold').text());
            normalWhiteLight.CloseLightMaxThreshold = parseInt($(xmlDoc).find('LightMode').eq(0).find('NormalWhite').eq(0).find("CloseLight").eq(0).find('MaxThreshold').text());
            //无极白
            //无极白光下的工作模式
            var isSupportManual = $(xmlDoc).find('LightMode').find('VariableWhite').eq(0).find('Manual').eq(0).find('Support').eq(0).text();
            var isSupportAuto = $(xmlDoc).find('LightMode').find('VariableWhite').eq(0).find('Auto').eq(0).find('Support').eq(0).text();
            //普通红外ir-cut 模式
            var isSupportAutoPassive = $(xmlDoc).find('NormalInfrared').find('AutoPassive').eq(0).find('Support').eq(0).text();
            var isSupportAutoActive = $(xmlDoc).find('NormalInfrared').find('AutoActive').eq(0).find('Support').eq(0).text();
            var isSupportDay = $(xmlDoc).find('NormalInfrared').find('Day').eq(0).find('Support').eq(0).text();
            var isSupportNight = $(xmlDoc).find('NormalInfrared').find('Night').eq(0).find('Support').eq(0).text();
            var isSupportPlan = $(xmlDoc).find('NormalInfrared').find('Plan').eq(0).find('Support').eq(0).text();
            $("#IR-CUT-mode").empty();
            if (isSupportAutoPassive == 'true') {
                $("<option value='passivity'>" + $.i18n.prop('i18n-automode') + "</option>").appendTo("#IR-CUT-mode");
            }
            if (isSupportAutoActive == 'true') {
                $("<option value='initiative'>" + $.i18n.prop('i18n-custommode') + "</option>").appendTo("#IR-CUT-mode");
            }
            if (isSupportDay == 'true') {
                $("<option value='day'>" + $.i18n.prop('i18n-day') + "</option>").appendTo("#IR-CUT-mode");
            }
            if (isSupportNight == 'true') {
                $("<option value='night'>" + $.i18n.prop('i18n-night') + "</option>").appendTo("#IR-CUT-mode");
            }
            if (isSupportPlan == 'true') {
                $("<option value='time'>" + $.i18n.prop('i18n-timingout') + "</option>").appendTo("#IR-CUT-mode");
            }
        },
        error: function(xhr, textStatus, errorThrown) {
            if (xhr.status == 404) {

            };
        }
    });
}

function delayTimeSet() {
    if ("admin" == config.user || "super_admin" == config.user) {
        var interval = $("#interval").val();
        var reg = /^([3-9]|[1-9]\d|[1-5]\d{2}|600)$/;
        if (!reg.test(interval)) {
            $.optionBootoast($.i18n.prop('i18n-time-swith'), "danger");
            return false;
        }
        setIrCutFilter($("#channel").val() - 0);
    } else {
        $.optionBootoast($.i18n.prop('i18n-propoe'), "danger")
    }


}