
function NwdrSysInfo(
    nCamTotalNum,
    n360MicNum,
    nCamNumH265_1,
    nCamNumH265_2,
    nCamNumH265_3,
    nCamNumH265_4,
    nCamNumH265Vbr_1,
    nCamNumH265Vbr_2,
    nCamNumH265Vbr_3,
    nCamNumH264Vbr_1,
    nCamNumH264Vbr_2,
    nCamNumH264Vbr_3,
    nCamNumH264_1,
    nCamNumH264_2,
    nCamNumH264_3,
    nCamNumH264_4,
    nCamNumJpeg_1,
    nCamNumJpeg_2,
    nCamNumJpeg_3,
    nCamNumJpeg_4,
    nCamNumFace_1,
    sysRecDataTB,
    sysCalcMbps,
    sysDispMbps,
    sysTotalIps,
    extUnitNum,
    mainHddNum,
    intHDDq,
    sysLicNum_nxe40,
    sysLicNum_nxe41,
    c_nDispLic,
    nwdrModelName,
    lngLastHDDCapa,
    pankflg) {
    this.nCamTotalNum = nCamTotalNum; 
    this.n360MicNum = n360MicNum; 
    this.nCamNumH265_1 = nCamNumH265_1; 
    this.nCamNumH265_2 = nCamNumH265_2; 
    this.nCamNumH265_3 = nCamNumH265_3; 
    this.nCamNumH265_4 = nCamNumH265_4; 
    this.nCamNumH265Vbr_1 = nCamNumH265Vbr_1; 
    this.nCamNumH265Vbr_2 = nCamNumH265Vbr_2; 
    this.nCamNumH265Vbr_3 = nCamNumH265Vbr_3; 
    this.nCamNumH264Vbr_1 = nCamNumH264Vbr_1; 
    this.nCamNumH264Vbr_2 = nCamNumH264Vbr_2; 
    this.nCamNumH264Vbr_3 = nCamNumH264Vbr_3; 
    this.nCamNumH264_1 = nCamNumH264_1; 
    this.nCamNumH264_2 = nCamNumH264_2; 
    this.nCamNumH264_3 = nCamNumH264_3; 
    this.nCamNumH264_4 = nCamNumH264_4; 
    this.nCamNumJpeg_1 = nCamNumJpeg_1; 
    this.nCamNumJpeg_2 = nCamNumJpeg_2; 
    this.nCamNumJpeg_3 = nCamNumJpeg_3; 
    this.nCamNumJpeg_4 = nCamNumJpeg_4; 
    this.nCamNumFace_1 = nCamNumFace_1; 
    this.sysRecDataTB = sysRecDataTB; 
    this.sysCalcMbps = sysCalcMbps; 
    this.sysDispMbps = sysDispMbps; 
    this.sysTotalIps = sysTotalIps; 
    this.extUnitNum = extUnitNum; 
    this.mainHddNum = mainHddNum; 
    this.intHDDq = intHDDq; 
    this.sysLicNum_nxe40 = sysLicNum_nxe40; 
    this.sysLicNum_nxe41 = sysLicNum_nxe41; 
    this.c_nDispLic = c_nDispLic; 
    this.nwdrModelName = nwdrModelName; 
    this.lngLastHDDCapa = lngLastHDDCapa; 
    this.pankflg = pankflg; 
}

Array.prototype.clone = function() {
    return Array.apply(null, this);
};


function NWDRArrayInit(tmpRecNum) {
    gNwdrInfo.length = 0;
    for (var idx = 0; idx < tmpRecNum; idx++) {
        gNwdrInfo[idx] = new NwdrSysInfo(
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0);
    }
}

function CamSpecInfo(Mbps, typeCode, modelName) {
    this.Mbps = Mbps;
    this.typeCode = typeCode;
    this.modelName = modelName; 
}


function calcdata(nKeyCode) {
    g_strmsg = ''; 
    gTotalCamNum = 0; 
    gTotalMicNum = 0; 

    if (app_dst != 'ja') {
        var objParts = new Array();
        for (var i = 1; i < 4; i++) {
            var no = String(i);
            uiGetH265VbrObject(no, objParts);
            if (objParts[uiIndexMaxKbpsH265Vbr].classList[1] == 'outputNumStyleAlert') {
                uiMsgDialogPopup(CAMUPPERBITRATEOVER, ALARTMSGMODE);
                uiAllResultGrayOut();
                return;
            }
        }
        for (var i = 1; i < 4; i++) {
            var no = String(i);
            uiGetH264VbrObject(no, objParts);
            if (objParts[uiIndexMaxKbpsH264Vbr].classList[1] == 'outputNumStyleAlert') {
                uiMsgDialogPopup(CAMUPPERBITRATEOVER, ALARTMSGMODE);
                uiAllResultGrayOut();
                return;
            }
        }
    }

    if ( CALC_AUDIOAACLDSELECTED == true) {
        CALC_AUDIOAACLDSELECTED = false;
    }

    gRecDay = Number(frmNWDR.txtRecDays.value);
    gRecHour = Number(frmNWDR.selRecHour.options[frmNWDR.selRecHour.selectedIndex].value);
    gSelHddUnitGB = Number(frmNWDR.sel_HDD.options[frmNWDR.sel_HDD.selectedIndex].value);
    gSelRaidMode = Number(frmNWDR.sel_RAID.options[frmNWDR.sel_RAID.selectedIndex].value);

    if (nKeyCode == 37 || nKeyCode == 39) {
        return;
    }

    if (gRecDay == 0) {
        uiAllResultGrayOut();
        return;
    }

    gCamModelNameUI[H265VBR_1] = Number(frmNWDR.selModelH265Vbr_1.selectedIndex); 
    gCamModelNameUI[H265VBR_2] = Number(frmNWDR.selModelH265Vbr_2.selectedIndex); 
    gCamModelNameUI[H265VBR_3] = Number(frmNWDR.selModelH265Vbr_3.selectedIndex); 
    gCamModelNameUI[H264VBR_1] = Number(frmNWDR.selModelH264Vbr_1.selectedIndex); 
    gCamModelNameUI[H264VBR_2] = Number(frmNWDR.selModelH264Vbr_2.selectedIndex); 
    gCamModelNameUI[H264VBR_3] = Number(frmNWDR.selModelH264Vbr_3.selectedIndex); 
    gCamModelNameUI[H265_1] = Number(frmNWDR.selModelH265_1.selectedIndex); 
    gCamModelNameUI[H265_2] = Number(frmNWDR.selModelH265_2.selectedIndex); 
    gCamModelNameUI[H265_3] = Number(frmNWDR.selModelH265_3.selectedIndex); 
    gCamModelNameUI[H265_4] = Number(frmNWDR.selModelH265_4.selectedIndex); 
    gCamModelNameUI[H264_1] = Number(frmNWDR.selModelH264_1.selectedIndex); 
    gCamModelNameUI[H264_2] = Number(frmNWDR.selModelH264_2.selectedIndex); 
    gCamModelNameUI[H264_3] = Number(frmNWDR.selModelH264_3.selectedIndex); 
    gCamModelNameUI[H264_4] = Number(frmNWDR.selModelH264_4.selectedIndex); 
    gCamModelNameUI[JPEG_1] = Number(frmNWDR.selModelJpeg_1.selectedIndex); 
    gCamModelNameUI[JPEG_2] = Number(frmNWDR.selModelJpeg_2.selectedIndex); 
    gCamModelNameUI[JPEG_3] = Number(frmNWDR.selModelJpeg_3.selectedIndex); 
    gCamModelNameUI[JPEG_4] = Number(frmNWDR.selModelJpeg_4.selectedIndex); 

    gCamNumberUI[H265VBR_1] = Number(frmNWDR.txtCamNumH265Vbr_1.value); 
    gCamNumberUI[H265VBR_2] = Number(frmNWDR.txtCamNumH265Vbr_2.value); 
    gCamNumberUI[H265VBR_3] = Number(frmNWDR.txtCamNumH265Vbr_3.value); 
    gCamNumberUI[H264VBR_1] = Number(frmNWDR.txtCamNumH264Vbr_1.value); 
    gCamNumberUI[H264VBR_2] = Number(frmNWDR.txtCamNumH264Vbr_2.value); 
    gCamNumberUI[H264VBR_3] = Number(frmNWDR.txtCamNumH264Vbr_3.value); 
    gCamNumberUI[H265_1] = Number(frmNWDR.txtCamNumH265_1.value); 
    gCamNumberUI[H265_2] = Number(frmNWDR.txtCamNumH265_2.value); 
    gCamNumberUI[H265_3] = Number(frmNWDR.txtCamNumH265_3.value); 
    gCamNumberUI[H265_4] = Number(frmNWDR.txtCamNumH265_4.value); 
    gCamNumberUI[H264_1] = Number(frmNWDR.txtCamNumH264_1.value); 
    gCamNumberUI[H264_2] = Number(frmNWDR.txtCamNumH264_2.value); 
    gCamNumberUI[H264_3] = Number(frmNWDR.txtCamNumH264_3.value); 
    gCamNumberUI[H264_4] = Number(frmNWDR.txtCamNumH264_4.value); 
    gCamNumberUI[JPEG_1] = Number(frmNWDR.txtCamNumJpeg_1.value); 
    gCamNumberUI[JPEG_2] = Number(frmNWDR.txtCamNumJpeg_2.value); 
    gCamNumberUI[JPEG_3] = Number(frmNWDR.txtCamNumJpeg_3.value); 
    gCamNumberUI[JPEG_4] = Number(frmNWDR.txtCamNumJpeg_4.value); 

    gCamScanUI[H265_1] = frmNWDR.selScanH265_1.options[frmNWDR.selScanH265_1.selectedIndex].text; 
    gCamScanUI[H265_2] = frmNWDR.selScanH265_2.options[frmNWDR.selScanH265_2.selectedIndex].text; 
    gCamScanUI[H265_3] = frmNWDR.selScanH265_3.options[frmNWDR.selScanH265_3.selectedIndex].text; 
    gCamScanUI[H265_4] = frmNWDR.selScanH265_4.options[frmNWDR.selScanH265_4.selectedIndex].text; 
    gCamScanUI[H264_1] = frmNWDR.selScanH264_1.options[frmNWDR.selScanH264_1.selectedIndex].text; 
    gCamScanUI[H264_2] = frmNWDR.selScanH264_2.options[frmNWDR.selScanH264_2.selectedIndex].text; 
    gCamScanUI[H264_3] = frmNWDR.selScanH264_3.options[frmNWDR.selScanH264_3.selectedIndex].text; 
    gCamScanUI[H264_4] = frmNWDR.selScanH264_4.options[frmNWDR.selScanH264_4.selectedIndex].text; 

    for (var i = 0; i < CAM_TYPENUM_ALL; i++) { 
        if (gCamNumberUI[i] == '') { 
            gCamNumberUI[i] = 0;     
        }

        gTotalCamNum = gTotalCamNum + Number(gCamNumberUI[i]); 
        if (H264_1 <= i && i <= H264_4) {
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (gCamModelNameUI[i] + 3) || camKind_H264_9MSMR == (gCamModelNameUI[i] + 3)) {
                    gTotalMicNum += Number(gCamNumberUI[i]);
                }
            } else {
                if (camKind_H264_360SMR == gCamModelNameUI[i] || camKind_H264_9MSMR == gCamModelNameUI[i]) {
                    gTotalMicNum += Number(gCamNumberUI[i]);
                }
            }
        }
    }
    if (gTotalCamNum == 0) {
        uiAllResultGrayOut();
        return;
    }
    if ((gTotalCamNum + gTotalMicNum) > 1000) {
        uiMsgDialogPopup(CAMNUMOVER, ALARTMSGMODE);
        uiAllResultGrayOut();
        return;
    }

    uiAllResultGrayOut();
    uiAllResultInit();

    gBitRateUI[H265VBR_1] = (isNaN(Number(frmNWDR.selAvgKbpsH265Vbr_1.value))) ? 0 : Number(frmNWDR.selAvgKbpsH265Vbr_1.value); 
    gBitRateUI[H265VBR_2] = (isNaN(Number(frmNWDR.selAvgKbpsH265Vbr_2.value))) ? 0 : Number(frmNWDR.selAvgKbpsH265Vbr_2.value); 
    gBitRateUI[H265VBR_3] = (isNaN(Number(frmNWDR.selAvgKbpsH265Vbr_3.value))) ? 0 : Number(frmNWDR.selAvgKbpsH265Vbr_3.value); 
    gBitRateUI[H264VBR_1] = (isNaN(Number(frmNWDR.selAvgKbpsH264Vbr_1.value))) ? 0 : Number(frmNWDR.selAvgKbpsH264Vbr_1.value); 
    gBitRateUI[H264VBR_2] = (isNaN(Number(frmNWDR.selAvgKbpsH264Vbr_2.value))) ? 0 : Number(frmNWDR.selAvgKbpsH264Vbr_2.value); 
    gBitRateUI[H264VBR_3] = (isNaN(Number(frmNWDR.selAvgKbpsH264Vbr_3.value))) ? 0 : Number(frmNWDR.selAvgKbpsH264Vbr_3.value); 

    gBitRateUI[H265_1] = Number(frmNWDR.selKbpsH265_1.value); 
    gBitRateUI[H265_2] = Number(frmNWDR.selKbpsH265_2.value); 
    gBitRateUI[H265_3] = Number(frmNWDR.selKbpsH265_3.value); 
    gBitRateUI[H265_4] = Number(frmNWDR.selKbpsH265_4.value); 
    gBitRateUI[H264_1] = Number(frmNWDR.selKbpsH264_1.value); 
    gBitRateUI[H264_2] = Number(frmNWDR.selKbpsH264_2.value); 
    gBitRateUI[H264_3] = Number(frmNWDR.selKbpsH264_3.value); 
    gBitRateUI[H264_4] = Number(frmNWDR.selKbpsH264_4.value); 

    gFrameRateUI[H265VBR_1] = fpsInfo_H265Vbr[Number(frmNWDR.selModelH265Vbr_1.selectedIndex)][Number(frmNWDR.selFpsH265Vbr_1.value) + 1]; 
    gFrameRateUI[H265VBR_2] = fpsInfo_H265Vbr[Number(frmNWDR.selModelH265Vbr_2.selectedIndex)][Number(frmNWDR.selFpsH265Vbr_2.value) + 1]; 
    gFrameRateUI[H265VBR_3] = fpsInfo_H265Vbr[Number(frmNWDR.selModelH265Vbr_3.selectedIndex)][Number(frmNWDR.selFpsH265Vbr_3.value) + 1]; 
    gFrameRateUI[H264VBR_1] = fpsInfo_H264Vbr[Number(frmNWDR.selModelH264Vbr_1.selectedIndex)][Number(frmNWDR.selFpsH264Vbr_1.value) + 1]; 
    gFrameRateUI[H264VBR_2] = fpsInfo_H264Vbr[Number(frmNWDR.selModelH264Vbr_2.selectedIndex)][Number(frmNWDR.selFpsH264Vbr_2.value) + 1]; 
    gFrameRateUI[H264VBR_3] = fpsInfo_H264Vbr[Number(frmNWDR.selModelH264Vbr_3.selectedIndex)][Number(frmNWDR.selFpsH264Vbr_3.value) + 1]; 
    gFrameRateUI[H265_1] = Number(Framerate[1]); 
    gFrameRateUI[H265_2] = Number(Framerate[2]); 
    gFrameRateUI[H265_3] = Number(Framerate[3]); 
    gFrameRateUI[H265_4] = Number(Framerate[4]); 
    gFrameRateUI[H264_1] = Number(Framerate[5]); 
    gFrameRateUI[H264_2] = Number(Framerate[6]); 
    gFrameRateUI[H264_3] = Number(Framerate[7]); 
    gFrameRateUI[H264_4] = Number(Framerate[8]); 

    var coefAVBR_1 = Number(frmNWDR.selPrioH264_1.value);
    var coefAVBR_2 = Number(frmNWDR.selPrioH264_2.value);
    var coefAVBR_3 = Number(frmNWDR.selPrioH264_3.value);
    var coefAVBR_4 = Number(frmNWDR.selPrioH264_4.value);

    coefAVBR_1 = ((coefAVBR_1) > 1 ? (6 - coefAVBR_1) : 1);
    coefAVBR_2 = ((coefAVBR_2) > 1 ? (6 - coefAVBR_2) : 1);
    coefAVBR_3 = ((coefAVBR_3) > 1 ? (6 - coefAVBR_3) : 1);
    coefAVBR_4 = ((coefAVBR_4) > 1 ? (6 - coefAVBR_4) : 1);

    var h265vbr_max_1 = (isNaN(Number(frmNWDR.selMaxKbpsH265Vbr_1.value))) ? 0 : Number(frmNWDR.selMaxKbpsH265Vbr_1.value);
    var h265vbr_max_2 = (isNaN(Number(frmNWDR.selMaxKbpsH265Vbr_2.value))) ? 0 : Number(frmNWDR.selMaxKbpsH265Vbr_2.value);
    var h265vbr_max_3 = (isNaN(Number(frmNWDR.selMaxKbpsH265Vbr_3.value))) ? 0 : Number(frmNWDR.selMaxKbpsH265Vbr_3.value);

    if (
        (0 < gCamNumberUI[H265VBR_1] && true == isNaN(gBitRateUI[H265VBR_1])) ||
        (0 < gCamNumberUI[H265VBR_2] && true == isNaN(gBitRateUI[H265VBR_2])) ||
        (0 < gCamNumberUI[H265VBR_3] && true == isNaN(gBitRateUI[H265VBR_3]))
    ) {
        uiAllResultGrayOut();
        return;
    }

    var h264vbr_max_1 = (isNaN(Number(frmNWDR.selMaxKbpsH264Vbr_1.value))) ? 0 : Number(frmNWDR.selMaxKbpsH264Vbr_1.value);
    var h264vbr_max_2 = (isNaN(Number(frmNWDR.selMaxKbpsH264Vbr_2.value))) ? 0 : Number(frmNWDR.selMaxKbpsH264Vbr_2.value);
    var h264vbr_max_3 = (isNaN(Number(frmNWDR.selMaxKbpsH264Vbr_3.value))) ? 0 : Number(frmNWDR.selMaxKbpsH264Vbr_3.value);

    if (
        (0 < gCamNumberUI[H264VBR_1] && true == isNaN(gBitRateUI[H264VBR_1])) ||
        (0 < gCamNumberUI[H264VBR_2] && true == isNaN(gBitRateUI[H264VBR_2])) ||
        (0 < gCamNumberUI[H264VBR_3] && true == isNaN(gBitRateUI[H264VBR_3]))
    ) {
        uiAllResultGrayOut();
        return;
    }

    gDispMbps[H265VBR_1] = h265vbr_max_1 / 1024; 
    gDispVideoMbps[H265VBR_1] = gDispMbps[H265VBR_1];
    gDispMbps[H265VBR_2] = h265vbr_max_2 / 1024; 
    gDispVideoMbps[H265VBR_2] = gDispMbps[H265VBR_2];
    gDispMbps[H265VBR_3] = h265vbr_max_3 / 1024; 
    gDispVideoMbps[H265VBR_3] = gDispMbps[H265VBR_3];
    gDispMbps[H264VBR_1] = h264vbr_max_1 / 1024; 
    gDispVideoMbps[H264VBR_1] = gDispMbps[H264VBR_1];
    gDispMbps[H264VBR_2] = h264vbr_max_2 / 1024; 
    gDispVideoMbps[H264VBR_2] = gDispMbps[H264VBR_2];
    gDispMbps[H264VBR_3] = h264vbr_max_3 / 1024; 
    gDispVideoMbps[H264VBR_3] = gDispMbps[H264VBR_3];
    gDispMbps[H265_1] = gBitRateUI[H265_1] * coefAVBR_1 / 1024; 
    gDispVideoMbps[H265_1] = gDispMbps[H265_1];
    gDispMbps[H265_2] = gBitRateUI[H265_2] * coefAVBR_2 / 1024; 
    gDispVideoMbps[H265_2] = gDispMbps[H265_2];
    gDispMbps[H265_3] = gBitRateUI[H265_3] * coefAVBR_3 / 1024; 
    gDispVideoMbps[H265_3] = gDispMbps[H265_3];
    gDispMbps[H265_4] = gBitRateUI[H265_4] * coefAVBR_4 / 1024; 
    gDispVideoMbps[H265_4] = gDispMbps[H265_4];
    gDispMbps[H264_1] = gBitRateUI[H264_1] * coefAVBR_1 / 1024; 
    gDispVideoMbps[H264_1] = gDispMbps[H264_1];
    gDispMbps[H264_2] = gBitRateUI[H264_2] * coefAVBR_2 / 1024; 
    gDispVideoMbps[H264_2] = gDispMbps[H264_2];
    gDispMbps[H264_3] = gBitRateUI[H264_3] * coefAVBR_3 / 1024; 
    gDispVideoMbps[H264_3] = gDispMbps[H264_3];
    gDispMbps[H264_4] = gBitRateUI[H264_4] * coefAVBR_4 / 1024; 
    gDispVideoMbps[H264_4] = gDispMbps[H264_4];
    gDispMbps[JPEG_1] = gDispBandJpegMbps[0];    
    gDispVideoMbps[JPEG_1] = gDispMbps[JPEG_1];
    gDispMbps[JPEG_2] = gDispBandJpegMbps[1];    
    gDispVideoMbps[JPEG_2] = gDispMbps[JPEG_2];
    gDispMbps[JPEG_3] = gDispBandJpegMbps[2];    
    gDispVideoMbps[JPEG_3] = gDispMbps[JPEG_3];
    gDispMbps[JPEG_4] = gDispBandJpegMbps[3];    
    gDispVideoMbps[JPEG_4] = gDispMbps[JPEG_4];

    gCalcMbps[H265VBR_1] = gBitRateUI[H265VBR_1] / 1000; 
    gCalcMbps[H265VBR_2] = gBitRateUI[H265VBR_2] / 1000; 
    gCalcMbps[H265VBR_3] = gBitRateUI[H265VBR_3] / 1000; 
    gCalcMbps[H264VBR_1] = gBitRateUI[H264VBR_1] / 1000; 
    gCalcMbps[H264VBR_2] = gBitRateUI[H264VBR_2] / 1000; 
    gCalcMbps[H264VBR_3] = gBitRateUI[H264VBR_3] / 1000; 
    gCalcMbps[H265_1] = gBitRateUI[H265_1] / 1000; 
    gCalcMbps[H265_2] = gBitRateUI[H265_2] / 1000; 
    gCalcMbps[H265_3] = gBitRateUI[H265_3] / 1000; 
    gCalcMbps[H265_4] = gBitRateUI[H265_4] / 1000; 
    gCalcMbps[H264_1] = gBitRateUI[H264_1] / 1000; 
    gCalcMbps[H264_2] = gBitRateUI[H264_2] / 1000; 
    gCalcMbps[H264_3] = gBitRateUI[H264_3] / 1000; 
    gCalcMbps[H264_4] = gBitRateUI[H264_4] / 1000; 
    gCalcMbps[JPEG_1] = gCalcBandJpegMbps[0];      
    gCalcMbps[JPEG_2] = gCalcBandJpegMbps[1];      
    gCalcMbps[JPEG_3] = gCalcBandJpegMbps[2];      
    gCalcMbps[JPEG_4] = gCalcBandJpegMbps[3];      

    gCalcJpegMbps[0] = gCalcRecJpegMbps[0]; 
    gCalcJpegMbps[1] = gCalcRecJpegMbps[1]; 
    gCalcJpegMbps[2] = gCalcRecJpegMbps[2]; 
    gCalcJpegMbps[3] = gCalcRecJpegMbps[3]; 

    gVideoMbps[H265VBR_1] = h265vbr_max_1 / 1000; 
    gVideoMbps[H265VBR_2] = h265vbr_max_2 / 1000; 
    gVideoMbps[H265VBR_3] = h265vbr_max_3 / 1000; 
    gVideoMbps[H264VBR_1] = h264vbr_max_1 / 1000; 
    gVideoMbps[H264VBR_2] = h264vbr_max_2 / 1000; 
    gVideoMbps[H264VBR_3] = h264vbr_max_3 / 1000; 
    gVideoMbps[H265_1] = gCalcMbps[H265_1] * coefAVBR_1; 
    gVideoMbps[H265_2] = gCalcMbps[H265_2] * coefAVBR_2; 
    gVideoMbps[H265_3] = gCalcMbps[H265_3] * coefAVBR_3; 
    gVideoMbps[H265_4] = gCalcMbps[H265_4] * coefAVBR_4; 
    gVideoMbps[H264_1] = gCalcMbps[H264_1] * coefAVBR_1; 
    gVideoMbps[H264_2] = gCalcMbps[H264_2] * coefAVBR_2; 
    gVideoMbps[H264_3] = gCalcMbps[H264_3] * coefAVBR_3; 
    gVideoMbps[H264_4] = gCalcMbps[H264_4] * coefAVBR_4; 
    gVideoMbps[JPEG_1] = gCalcJpegMbps[0]; 
    gVideoMbps[JPEG_2] = gCalcJpegMbps[1]; 
    gVideoMbps[JPEG_3] = gCalcJpegMbps[2]; 
    gVideoMbps[JPEG_4] = gCalcJpegMbps[3]; 

    gJpegIps[H265VBR_1] = 0; 
    gJpegIps[H265VBR_2] = 0; 
    gJpegIps[H265VBR_3] = 0; 
    gJpegIps[H264VBR_1] = 0; 
    gJpegIps[H264VBR_2] = 0; 
    gJpegIps[H264VBR_3] = 0; 
    gJpegIps[H265_1] = 0; 
    gJpegIps[H265_2] = 0; 
    gJpegIps[H265_3] = 0; 
    gJpegIps[H265_4] = 0; 
    gJpegIps[H264_1] = 0; 
    gJpegIps[H264_2] = 0; 
    gJpegIps[H264_3] = 0; 
    gJpegIps[H264_4] = 0; 
    gJpegIps[JPEG_1] = Number(frmNWDR.selFpsJpeg_1.value); 
    gJpegIps[JPEG_2] = Number(frmNWDR.selFpsJpeg_2.value); 
    gJpegIps[JPEG_3] = Number(frmNWDR.selFpsJpeg_3.value); 
    gJpegIps[JPEG_4] = Number(frmNWDR.selFpsJpeg_4.value); 

    if (app_dst != 'zh') {
        if (frmNWDR.chkencdata.checked == true) {
            AddEncdataBitrate(nNwdrNX400); 
        }
    }

    g_DynaConnect[nNwdrNX400] = defMaxConAddInfo[nNwdrNX400];   

    AddVmdBitrate(); 

    Add360MicAudioBitrate();

    if (frmNWDR.chkaudio.checked == true) {
        if (document.getElementById('camRecAudio_AACLC').checked == true) {
            AddAudioBitrate(CALC_AUDIOSELECT_AACLC); 
        } else {
            AddAudioBitrate(CALC_AUDIOSELECT_G726); 
        }
    }

    if (frmNWDR.chksubstream.checked == true) {
        AddSubStreamBitrate(); 
        g_DynaConnect[nNwdrNX400] = defMaxConAddInfoSS[nNwdrNX400]; 
    }

    if (app_dst != 'zh') {
        if (frmNWDR.chkhttps.checked == true) {
            AddHttpsBitrate(); 
        }
    }

    var totalDispMbps = 0;
    for (var idx = 0; idx < CAM_TYPENUM_ALL; idx++) {
        totalDispMbps += (gCamNumberUI[idx] * gDispMbps[idx]);
    }

    frmNWDR.txttotalbit.value = NumberToFixed(totalDispMbps, 3);

    gCalcMbps[JPEG_1] = gCalcJpegMbps[0]; 
    gCalcMbps[JPEG_2] = gCalcJpegMbps[1]; 
    gCalcMbps[JPEG_3] = gCalcJpegMbps[2]; 
    gCalcMbps[JPEG_4] = gCalcJpegMbps[3]; 

    gCamModelParamInfo.length = 0;
    for (var idx = 0; idx < CAM_TYPENUM_ALL; idx++) {
        var each_size =
            ((gCalcMbps[idx] / 8) * 60 * 60 * (gRecHour * gRecDay)) / 1000 / 1000;

        gCamModelParamInfo.push({
            'camType': [idx],
            'camNum': gCamNumberUI[idx],
            'camCalcBR': gCalcMbps[idx],
            'camJpgIps': gJpegIps[idx],
            'camRecTB': GetMarumCapa2(each_size),
            'camDispBR': gDispMbps[idx],
            'camModel': gCamModelNameUI[idx],
            'camDispVBR': gDispVideoMbps[idx]
        });
    }

    var totalCalcMbps = 0; 
    for (var idx = 0; idx < CAM_TYPENUM_ALL; idx++) {
        totalCalcMbps += (gCamNumberUI[idx] * gCalcMbps[idx]); 
    }

    var totalRecDataTB =
        ((totalCalcMbps / 8) * 60 * 60 * (gRecHour * gRecDay)) / 1000 / 1000;

    frmNWDR.txttotalcap.value = GetMarumCapa(totalRecDataTB);

    SetDisplayResultFlag_InputParam();

    if (1 == g_DsplayResultFlag[nNwdrNX400]) {

        var buf = -1;
        buf = basicNwdrCalc(nNwdrNX400);

        if (buf < 0) {
            dataNX400out(); 
        } else {
            NX400_output(nNwdrNX400);
            if (frmNWDR.chkdetail.checked == true) {
                DetailOutput(gNwdrInfo, nNwdrNX400, '');
            } else {
                NoteOutput(gNwdrInfo);
            }
        }
    }
    frmNWDR.txttotalbit.value = Number(frmNWDR.txttotalbit.value).toLocaleString();
    frmNWDR.txttotalcap.value = Number(frmNWDR.txttotalcap.value).toLocaleString();
}

function SetDisplayResultFlag_InputParam() {
    var tblBitratePerOne = new Array();
    g_DsplayResultFlag[nNwdrNX400] = 1;

    var kindidx = 0;
    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        var objParts = new Array();
        uiGetH265Object((kindidx - minidx + 1).toString(), objParts);

        if (objParts[0].selectedIndex == camKind_H265_U11301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U11301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U11501 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U11501SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U15301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U15301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U15501 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U15501SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U15750 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U15750SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U11350 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U11350SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U11550 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U11550SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S15301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S15301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S15501 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S15501SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S15701 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S15701SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S61602 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S61602SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S61702 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S61702SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X67300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X67300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X67700 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X67700SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S32300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S32300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S32400 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S32400SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S66300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S66300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S66600 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S66600SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S66700 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S66700SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U31301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U31301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U31401 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U31401SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X15300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X15300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X15500 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X15500SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X15600 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X15600SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X15700 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X15700SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X25580 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X25580SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_B51300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_B51300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S61301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S61301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S61501 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S61501SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S85402 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S85402SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S85702 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S85702SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X86530 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X86530SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X86530PTZ && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X86530PTZSC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U61301 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U61301SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S2116 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S2116SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S2236 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S2236SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1130 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1130SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1110 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1110SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1552 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1552SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1550 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1550SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1572 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1572SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S1570 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S1570SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S3130 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S3130SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S3110 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S3110SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X8571 && objParts[3].selectedIndex == 1) {
          var model = camKind_H265_X8571SC;
          var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S8531 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S8531SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X8570 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X8570SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S8530 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S8530SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S6530 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S6530SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S6510 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S6510SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S4176 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S4176SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S4156 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S4156SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X4170 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X4170SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S4150 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S4150SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U1130 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U1130SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U11300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U11300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_U1140 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_U1140SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X1534 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X1534SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_X1571 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_X1571SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S25700 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S25700SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S25600 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S25600SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S25500 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S25500SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S71300 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S71300SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S8570 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S8570;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S8560 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S8560SC;
            var prio = 0;
        } else if (objParts[0].selectedIndex == camKind_H265_S8540 && objParts[3].selectedIndex == 1) {
            var model = camKind_H265_S8540SC;
            var prio = 0;
        } else {
            var model = objParts[0].selectedIndex;
            var prio = objParts[3].selectedIndex;
        }

        var tblBitrate =
            camBitrate_H265[
                model][                         
                objParts[2].selectedIndex][     
                prio][                          
                objParts[1].selectedIndex][     
                objParts[4].selectedIndex][     
                objParts[5].selectedIndex + 1]; 
        tblBitratePerOne[kindidx] = tblBitrate[2];

        if (0 < gCamNumberUI[kindidx]) {
            g_DsplayResultFlag[nNwdrNX400] &= tblBitrate[4]; 
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        var objParts = new Array();
        uiGetH264Object((kindidx - minidx + 1).toString(), objParts);

        if (app_dst == 'ja' && objParts[0].selectedIndex > (H265Num_h264 - 1)) {
            var tblBitrate =
                camBitrate_H264[
                    objParts[0].selectedIndex + 3][ 
                    objParts[2].selectedIndex][     
                    objParts[3].selectedIndex][     
                    objParts[1].selectedIndex][     
                    objParts[4].selectedIndex][     
                    objParts[5].selectedIndex + 1]; 
        } else {
            var tblBitrate =
                camBitrate_H264[
                    objParts[0].selectedIndex][     
                    objParts[2].selectedIndex][     
                    objParts[3].selectedIndex][     
                    objParts[1].selectedIndex][     
                    objParts[4].selectedIndex][     
                    objParts[5].selectedIndex + 1]; 
        }
        tblBitratePerOne[kindidx] = tblBitrate[2];

        if (0 < gCamNumberUI[kindidx]) {
            g_DsplayResultFlag[nNwdrNX400] &= tblBitrate[4]; 
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        var objParts = new Array();
        uiGetJpegObject((kindidx - minidx + 1).toString(), objParts);

        if (app_dst == 'ja' && objParts[0].selectedIndex > (H265Num_jpeg - 1)) {
            var tblQuality =
                camQuality_Jpeg[
                    objParts[0].selectedIndex + 3][
                    objParts[2].selectedIndex][
                    objParts[1].selectedIndex][
                    objParts[3].selectedIndex + 1];
        } else {
            var model = Number(objParts[0].options[objParts[0].selectedIndex].value);
            if (model == camKind_Jpeg_V23 || model == camKind_Jpeg_V63 ||
                model == camKind_Jpeg_V17) {
                var reso = objParts[1].selectedIndex * 7;
                switch (Number(objParts[4].options[objParts[4].selectedIndex].value)) {
                case 2:
                    reso = reso + 1;
                    break;
                case 3:
                    reso = reso + 2;
                    break;
                case 5:
                    reso = reso + 3;
                    break;
                case 10:
                    reso = reso + 4;
                    break;
                case 15:
                    reso = reso + 5;
                    break;
                case 30:
                    reso = reso + 6;
                    break;
                default:
                    break;
                }
                var tblQuality =
                    camQuality_Jpeg[
                        objParts[0].selectedIndex][
                        objParts[2].selectedIndex][
                        reso][
                        objParts[3].selectedIndex + 1];
            } else {
                var tblQuality =
                    camQuality_Jpeg[
                        objParts[0].selectedIndex][
                        objParts[2].selectedIndex][
                        objParts[1].selectedIndex][
                        objParts[3].selectedIndex + 1];
            }
        }

        if (0 < gCamNumberUI[kindidx]) {
            g_DsplayResultFlag[nNwdrNX400] &= tblQuality[4];  

            var recfps = Number(
                objParts[4].options[objParts[4].selectedIndex].value);
            var recfps_text =
                objParts[4].options[objParts[4].selectedIndex].text;

        }
    }

    switch (gSelHddUnitGB) {
        case 500:
        case 1500:
        case 1000:
        case 2000:
        case 3000:
        case 4000:
        case 5000:
        case 6000:
        case 8000:
            break;

        default: 
            g_DsplayResultFlag[nNwdrNX400] = 0;
            break;
    }

    switch (gSelRaidMode) {
        case 0: 
        case 1 : 
        case 5 : 
        case 6 : 
            break; 

        default: 
            g_DsplayResultFlag[nNwdrNX400] = 0;
            break;
    }





    SetDsplayResultByVseries(tblBitratePerOne);

    for (var idx = 0; idx < g_DynaConnect.length; idx++) {
        if (0 == g_DynaConnect[idx]) {
            g_DsplayResultFlag[idx] = 0;
        }
    }
}

function AddVmdBitrate() {
    var kindidx = 0;
    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        gCalcMbps[kindidx] += Number(CALC_VMDINFO); 
        gDispMbps[kindidx] += Number(DISP_VMDINFO); 
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (camKind_H264_Hcm7 != (gCamModelNameUI[kindidx] + 3)) {
                gCalcMbps[kindidx] += Number(CALC_VMDINFO); 
                gDispMbps[kindidx] += Number(DISP_VMDINFO); 
            }
        } else {
            if (camKind_H264_Hcm7 != gCamModelNameUI[kindidx]) {
                gCalcMbps[kindidx] += Number(CALC_VMDINFO); 
                gDispMbps[kindidx] += Number(DISP_VMDINFO); 
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (camKind_Jpeg_Hcm7 != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Hcm5 != (gCamModelNameUI[kindidx] + 3)) {
                gCalcMbps[kindidx] += Number(CALC_VMDINFO);
                gCalcJpegMbps[kindidx - minidx] += Number(CALC_VMDINFO);
                gDispMbps[kindidx] += Number(DISP_VMDINFO);
            }
        } else {
            if (camKind_Jpeg_Hcm7 != gCamModelNameUI[kindidx] && camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                gCalcMbps[kindidx] += Number(CALC_VMDINFO);
                gCalcJpegMbps[kindidx - minidx] += Number(CALC_VMDINFO);
                gDispMbps[kindidx] += Number(DISP_VMDINFO);
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H265VBR;
    for (; kindidx < maxidx; kindidx++) {
        gCalcMbps[kindidx] += Number(CALC_VMDINFO); 
        gDispMbps[kindidx] += Number(DISP_VMDINFO); 
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264VBR;
    for (; kindidx < maxidx; kindidx++) {
        gCalcMbps[kindidx] += Number(CALC_VMDINFO); 
        gDispMbps[kindidx] += Number(DISP_VMDINFO); 
    }

}

function SetDsplayResultByCamAudio() {
    var kindidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
    }

    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
    }

    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (0 < gCamNumberUI[kindidx]) {
            if (app_dst == 'ja') {
                if (camKind_Jpeg_Hcm5 == (gCamModelNameUI[kindidx] + 3)) {
                    g_DsplayResultFlag[nNwdrND400] = 0;
                    g_DsplayResultFlag[nNwdrNV300] = 0;
                }
            } else {
                if (camKind_Jpeg_Hcm5 == gCamModelNameUI[kindidx]) {
                    g_DsplayResultFlag[nNwdrND400] = 0;
                    g_DsplayResultFlag[nNwdrNV300] = 0;
                }
            }
        }
    }
}

function Add360MicAudioBitrate() {
    var maxidx = CAM_TYPENUM_H264 + CAM_TYPENUM_H265;
    for (var kindidx = CAM_TYPENUM_H265; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3) || camKind_H264_9MSMR == (gCamModelNameUI[kindidx] + 3)) { 
                gCalcMbps[kindidx] += Number(CALC_AUDIO_360);
                gDispMbps[kindidx] += Number(DISP_AUDIO_360);
                gVideoMbps[kindidx] += Number(DISP_AUDIO_360); 
            }
        } else {
            if (camKind_H264_360SMR == gCamModelNameUI[kindidx] || camKind_H264_9MSMR == gCamModelNameUI[kindidx]) { 
                gCalcMbps[kindidx] += Number(CALC_AUDIO_360);
                gDispMbps[kindidx] += Number(DISP_AUDIO_360);
                gVideoMbps[kindidx] += Number(DISP_AUDIO_360); 
            }
        }
    }
}

function AddAudioBitrate(nAudioKind) {
    var kindidx = 0;

    if (nAudioKind == CALC_AUDIOSELECT_AACLC) {
        var minidx = 0;
        var maxidx = CAM_TYPENUM_H265;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_H265_U1130 == gCamModelNameUI[kindidx] || camKind_H265_U1140 == gCamModelNameUI[kindidx] || camKind_H265_U15301 == gCamModelNameUI[kindidx] || camKind_H265_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            if (app_dst == 'ja') {
                gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
            } else {
                if (camKind_H265_V23 != gCamModelNameUI[kindidx] && camKind_H265_V63 != gCamModelNameUI[kindidx] &&
                    camKind_H265_V17 != gCamModelNameUI[kindidx]) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
                } else {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            }
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H264;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_H264_U15301 == gCamModelNameUI[kindidx] || camKind_H264_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            if (app_dst == 'ja') {
                if (camKind_H264_9MSMR == (gCamModelNameUI[kindidx] + 3) || camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3)) {
                } else if (camKind_H264_360 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_360SMR != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_FullHd != (gCamModelNameUI[kindidx] + 3) && camKind_H264_Hd != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_502 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_Gxe5 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_Gxe1 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_Hcm7 != (gCamModelNameUI[kindidx] + 3)) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
                } else {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            } else {
                if (camKind_H264_9MSMR == gCamModelNameUI[kindidx] || camKind_H264_360SMR == gCamModelNameUI[kindidx]) {
                } else if (camKind_H264_V23 != gCamModelNameUI[kindidx] && camKind_H264_V63 != gCamModelNameUI[kindidx] &&
                    camKind_H264_V17 != gCamModelNameUI[kindidx] &&
                    camKind_H264_360 != gCamModelNameUI[kindidx] && camKind_H264_360SMR != gCamModelNameUI[kindidx] &&
                    camKind_H264_FullHd != gCamModelNameUI[kindidx] && camKind_H264_Hd != gCamModelNameUI[kindidx] &&
                    camKind_H264_502 != gCamModelNameUI[kindidx] && camKind_H264_Gxe5 != gCamModelNameUI[kindidx] &&
                    camKind_H264_Gxe1 != gCamModelNameUI[kindidx] && camKind_H264_Hcm7 != gCamModelNameUI[kindidx]) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
                } else {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            }
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_JPEG;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx] || camKind_Jpeg_U15301 == gCamModelNameUI[kindidx] || camKind_Jpeg_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            if (app_dst == 'ja') {
                if (camKind_Jpeg_360 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_FullHd != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Hd != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_502 != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Gxe != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_Other != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Hcm7 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_Hcm5 != (gCamModelNameUI[kindidx] + 3)) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gCalcJpegMbps[kindidx - minidx] +=
                        Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
                } else {
                    if (camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                        gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                        gCalcJpegMbps[kindidx - minidx] +=
                            Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                        gDispMbps[kindidx] += Number(DISP_AUDIO);
                    }
                }
            } else {
                if (camKind_Jpeg_V23 != gCamModelNameUI[kindidx] && camKind_Jpeg_V63 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_V17 != gCamModelNameUI[kindidx] && camKind_Jpeg_360 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_FullHd != gCamModelNameUI[kindidx] && camKind_Jpeg_Hd != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_502 != gCamModelNameUI[kindidx] && camKind_Jpeg_Gxe != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_Other != gCamModelNameUI[kindidx] && camKind_Jpeg_Hcm7 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gCalcJpegMbps[kindidx - minidx] +=
                        Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
                } else {
                    if (camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                        gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                        gCalcJpegMbps[kindidx - minidx] +=
                            Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                        gDispMbps[kindidx] += Number(DISP_AUDIO);
                    }
                }
            }
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H265VBR;
        for (; kindidx < maxidx; kindidx++) {
            if ((camKind_H265Vbr_EX_U == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_2M_U4 == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_5M_U3 == gCamModelNameUI[kindidx])) {
                continue; 
            }
            gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
            gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H264VBR;
        for (; kindidx < maxidx; kindidx++) {
            if ((camKind_H264Vbr_EX_Next_2M_U4 == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_5M_U3 == gCamModelNameUI[kindidx])) {
                continue; 
            }
            gCalcMbps[kindidx] += Number(CALC_AUDIO_AACLC) + Number(AUDIOADDDATA);
            gDispMbps[kindidx] += Number(DISP_AUDIO_AACLC);
        }
    } else {
        var minidx = 0;
        var maxidx = CAM_TYPENUM_H265;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_H265_U1130 == gCamModelNameUI[kindidx] || camKind_H265_U1140 == gCamModelNameUI[kindidx] || camKind_H265_U15301 == gCamModelNameUI[kindidx] || camKind_H265_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
            gDispMbps[kindidx] += Number(DISP_AUDIO);
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H264;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_H264_U15301 == gCamModelNameUI[kindidx] || camKind_H264_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3) || camKind_H264_9MSMR == (gCamModelNameUI[kindidx] + 3)) { 
                } else {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            } else {
                if (camKind_H264_360SMR == gCamModelNameUI[kindidx] || camKind_H264_9MSMR == gCamModelNameUI[kindidx]) { 
                } else {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            }
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_JPEG;
        for (; kindidx < maxidx; kindidx++) {
            if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx] || camKind_Jpeg_U15301 == gCamModelNameUI[kindidx] || camKind_Jpeg_U15501 == gCamModelNameUI[kindidx]) {
                continue; 
            }
            if (app_dst == 'ja') {
                if (camKind_Jpeg_Hcm5 != (gCamModelNameUI[kindidx] + 3)) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gCalcJpegMbps[kindidx - minidx] +=
                        Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            } else {
                if (camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                    gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gCalcJpegMbps[kindidx - minidx] +=
                        Number(CALC_AUDIO) + Number(AUDIOADDDATA);
                    gDispMbps[kindidx] += Number(DISP_AUDIO);
                }
            }
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H265VBR;
        for (; kindidx < maxidx; kindidx++) {
            if ((camKind_H265Vbr_EX_U == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_2M_U4 == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_5M_U3 == gCamModelNameUI[kindidx])) {
                continue; 
            }
            gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
            gDispMbps[kindidx] += Number(DISP_AUDIO);
        }

        minidx = maxidx;
        maxidx += CAM_TYPENUM_H264VBR;
        for (; kindidx < maxidx; kindidx++) {
            if ((camKind_H264Vbr_EX_Next_2M_U4 == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_Next_5M_U3 == gCamModelNameUI[kindidx])) {
                continue; 
            }
            gCalcMbps[kindidx] += Number(CALC_AUDIO) + Number(AUDIOADDDATA);
            gDispMbps[kindidx] += Number(DISP_AUDIO);
        }
    }
}

function AddSubStreamBitrate() {
    var kindidx = 0;

    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        if (((camKind_H265_X4170 == gCamModelNameUI[kindidx]) || (camKind_H265_S4150 == gCamModelNameUI[kindidx]) ||
             (camKind_H265_S4176 == gCamModelNameUI[kindidx]) || (camKind_H265_S4156 == gCamModelNameUI[kindidx])) && 
            (s_camscan_h264_16 == gCamScanUI[kindidx])) {
        } else {
            gCalcMbps[kindidx] += Number(CALC_SUBSTREAM_H265);
            gDispMbps[kindidx] += Number(DISP_SUBSTREAM_H265);
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if ((camKind_H264_Hcm7 == (gCamModelNameUI[kindidx] + 3)) || (camKind_H264_Gxe5 == (gCamModelNameUI[kindidx] + 3)) ||
               (((camKind_H264_X4170 == gCamModelNameUI[kindidx]) || (camKind_H264_S4150 == gCamModelNameUI[kindidx])) &&
                (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               (((camKind_H264_S4176 == gCamModelNameUI[kindidx]) || (camKind_H264_S4156 == gCamModelNameUI[kindidx])) &&
                (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_9M == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_9MSMR == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_360 == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_06 == gCamScanUI[kindidx])) ||
               ((camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_06 == gCamScanUI[kindidx]))) {
            } else {
                gCalcMbps[kindidx] += Number(CALC_SUBSTREAM_H264);
                gDispMbps[kindidx] += Number(DISP_SUBSTREAM_H264);
            }
        } else {
            if ((camKind_H264_Hcm7 == gCamModelNameUI[kindidx]) || (camKind_H264_Gxe5 == gCamModelNameUI[kindidx]) ||
               (((camKind_H264_X4170 == gCamModelNameUI[kindidx]) || (camKind_H264_S4150 == gCamModelNameUI[kindidx])) &&
                (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               (((camKind_H264_S4176 == gCamModelNameUI[kindidx]) || (camKind_H264_S4156 == gCamModelNameUI[kindidx])) &&
                (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_9M == gCamModelNameUI[kindidx]) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_9MSMR == gCamModelNameUI[kindidx]) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
               ((camKind_H264_360 == gCamModelNameUI[kindidx]) && (s_camscan_h264_06 == gCamScanUI[kindidx])) ||
               ((camKind_H264_360SMR == gCamModelNameUI[kindidx]) && (s_camscan_h264_06 == gCamScanUI[kindidx]))) {
            } else {
                gCalcMbps[kindidx] += Number(CALC_SUBSTREAM_H264);
                gDispMbps[kindidx] += Number(DISP_SUBSTREAM_H264);
            }
        }
    }

    minidx = maxidx + CAM_TYPENUM_JPEG;
    kindidx = minidx;
    maxidx += (CAM_TYPENUM_H265VBR + CAM_TYPENUM_JPEG);
    for (; kindidx < maxidx; kindidx++) {
        gCalcMbps[kindidx] += Number(CALC_SUBSTREAM_H265);
        gDispMbps[kindidx] += Number(DISP_SUBSTREAM_H265);
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264VBR;
    for (; kindidx < maxidx; kindidx++) {
        gCalcMbps[kindidx] += Number(CALC_SUBSTREAM_H264);
        gDispMbps[kindidx] += Number(DISP_SUBSTREAM_H264);
    }
}

function SetDsplayResultBySubStream() {
    var kindidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
    }

    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if ((camKind_H264_Hcm7 == (gCamModelNameUI[kindidx] + 3)) || (camKind_H264_Gxe5 == (gCamModelNameUI[kindidx] + 3)) ||
                   ((camKind_H264_9M == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_9MSMR == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_360 == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_06 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3)) && (s_camscan_h264_06 == gCamScanUI[kindidx]))) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if ((camKind_H264_Hcm7 == gCamModelNameUI[kindidx]) || (camKind_H264_Gxe5 == gCamModelNameUI[kindidx]) ||
                   ((camKind_H264_9M == gCamModelNameUI[kindidx]) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_9MSMR == gCamModelNameUI[kindidx]) && (s_camscan_h264_16 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_360 == gCamModelNameUI[kindidx]) && (s_camscan_h264_06 == gCamScanUI[kindidx])) ||
                   ((camKind_H264_360SMR == gCamModelNameUI[kindidx]) && (s_camscan_h264_06 == gCamScanUI[kindidx]))) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }

    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (0 < gCamNumberUI[kindidx]) {
            g_DsplayResultFlag[nNwdrNX400] = 0;
        }
    }
}

function AddHttpsBitrate() {
    var kindidx = 0;
    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H265_V23 != gCamModelNameUI[kindidx] && camKind_H265_V63 != gCamModelNameUI[kindidx] &&
                    camKind_H265_V17 != gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                } else if (camKind_H265_U1130 == gCamModelNameUI[kindidx] || camKind_H265_U1140 == gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                }
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;

    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_360 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_FullHd != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_Hd != (gCamModelNameUI[kindidx] + 3) && camKind_H264_502 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_Gxe5 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_Gxe1 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_H264_Hcm7 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_360SMR != (gCamModelNameUI[kindidx] + 3)) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_V23 != gCamModelNameUI[kindidx] && camKind_H264_V63 != gCamModelNameUI[kindidx] &&
                    camKind_H264_V17 != gCamModelNameUI[kindidx] &&
                    camKind_H264_360 != gCamModelNameUI[kindidx] && camKind_H264_FullHd != gCamModelNameUI[kindidx] &&
                    camKind_H264_Hd != gCamModelNameUI[kindidx] && camKind_H264_502 != gCamModelNameUI[kindidx] &&
                    camKind_H264_Gxe5 != gCamModelNameUI[kindidx] && camKind_H264_Gxe1 != gCamModelNameUI[kindidx] &&
                    camKind_H264_Hcm7 != gCamModelNameUI[kindidx] && camKind_H264_360SMR != gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                }
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_JPEG;

    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_360 != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_FullHd != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_Hd != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_502 != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_Gxe != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Other != (gCamModelNameUI[kindidx] + 3) &&
                    camKind_Jpeg_Hcm7 != (gCamModelNameUI[kindidx] + 3) && camKind_Jpeg_Hcm5 != (gCamModelNameUI[kindidx] + 3)) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                } else if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_V23 != gCamModelNameUI[kindidx] && camKind_Jpeg_V63 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_V17 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_360 != gCamModelNameUI[kindidx] && camKind_Jpeg_FullHd != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_Hd != gCamModelNameUI[kindidx] && camKind_Jpeg_502 != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_Gxe != gCamModelNameUI[kindidx] && camKind_Jpeg_Other != gCamModelNameUI[kindidx] &&
                    camKind_Jpeg_Hcm7 != gCamModelNameUI[kindidx] && camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                } else if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx]) {
                    gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
                }
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H265VBR;
    for (; kindidx < maxidx; kindidx++) {
        if (0 < gCamNumberUI[kindidx]) {
            gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264VBR;
    for (; kindidx < maxidx; kindidx++) {
        if (0 < gCamNumberUI[kindidx]) {
            gDispMbps[kindidx] = gDispMbps[kindidx] * Number(DISP_HTTPS);
        }
    }

}

function SetDsplayResultByHttps() {
    var kindidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
    }

    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_360 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_FullHd == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Hd == (gCamModelNameUI[kindidx] + 3) || camKind_H264_502 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Gxe5 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_Gxe1 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Hcm7 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3)) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_360 == gCamModelNameUI[kindidx] || camKind_H264_FullHd == gCamModelNameUI[kindidx] ||
                    camKind_H264_Hd == gCamModelNameUI[kindidx] || camKind_H264_502 == gCamModelNameUI[kindidx] ||
                    camKind_H264_Gxe5 == gCamModelNameUI[kindidx] || camKind_H264_Gxe1 == gCamModelNameUI[kindidx] ||
                    camKind_H264_Hcm7 == gCamModelNameUI[kindidx] || camKind_H264_360SMR == gCamModelNameUI[kindidx]) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }

    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_360 == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_FullHd == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Hd == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_502 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Gxe == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_Other == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Hcm7 == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_Hcm5 == (gCamModelNameUI[kindidx] + 3)) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_360 == gCamModelNameUI[kindidx] || camKind_Jpeg_FullHd == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Hd == gCamModelNameUI[kindidx] || camKind_Jpeg_502 == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Gxe == gCamModelNameUI[kindidx] || camKind_Jpeg_Other == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Hcm7 == gCamModelNameUI[kindidx] || camKind_Jpeg_Hcm5 == gCamModelNameUI[kindidx]) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }
}

function AddEncdataBitrate(nNwdrCode) {
    var kindidx = 0;
    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        if (camKind_H265_U11300 == gCamModelNameUI[kindidx] || camKind_H265_U1130 == gCamModelNameUI[kindidx] || camKind_H265_U1140 == gCamModelNameUI[kindidx] || camKind_H265Vbr_EX_MIC_U == gCamModelNameUI[kindidx]) {
            continue; 
        }
        if (app_dst == 'ja') {

            var PregCalcMbps = gCalcMbps[kindidx];
            gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H265);

            var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
            DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

            gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;

            if (document.getElementById('camRecAudio_AACLC').checked == true) {
                gCalcMbps[kindidx] += Number(CALC_AUDIOENC_AACLC);
                gDispMbps[kindidx] += Number(DISP_AUDIOENC_AACLC);
            }
        } else {
            if (camKind_H265_V23 != gCamModelNameUI[kindidx] && camKind_H265_V63 != gCamModelNameUI[kindidx] &&
                camKind_H265_V17 != gCamModelNameUI[kindidx]) {

                var PregCalcMbps = gCalcMbps[kindidx];
                gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H265);

                var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
                DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

                gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;

                if (document.frmNWDR.elements['chkaudio'].checked == true) {
                    if (document.getElementById('camRecAudio_AACLC').checked == true) {
                        gCalcMbps[kindidx] += Number(CALC_AUDIOENC_AACLC);
                        gDispMbps[kindidx] += Number(DISP_AUDIOENC_AACLC);
                    }
                }
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (camKind_H264_360 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_FullHd != (gCamModelNameUI[kindidx] + 3) &&
                camKind_H264_Hd != (gCamModelNameUI[kindidx] + 3) && camKind_H264_502 != (gCamModelNameUI[kindidx] + 3) &&
                camKind_H264_Gxe5 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_Gxe1 != (gCamModelNameUI[kindidx] + 3) &&
                camKind_H264_Hcm7 != (gCamModelNameUI[kindidx] + 3) && camKind_H264_360SMR != (gCamModelNameUI[kindidx] + 3) &&
                camKind_H264_U11300 != (gCamModelNameUI[kindidx] + 3)
                ) {

                var PregCalcMbps = gCalcMbps[kindidx];
                gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H264);

                var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
                DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

                gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;
            }
        } else {
            if (camKind_H264_V23 != gCamModelNameUI[kindidx] && camKind_H264_V63 != gCamModelNameUI[kindidx] &&
                camKind_H264_V17 != gCamModelNameUI[kindidx] &&
                camKind_H264_360 != gCamModelNameUI[kindidx] && camKind_H264_FullHd != gCamModelNameUI[kindidx] &&
                camKind_H264_Hd != gCamModelNameUI[kindidx] && camKind_H264_502 != gCamModelNameUI[kindidx] &&
                camKind_H264_Gxe5 != gCamModelNameUI[kindidx] && camKind_H264_Gxe1 != gCamModelNameUI[kindidx] &&
                camKind_H264_Hcm7 != gCamModelNameUI[kindidx] && camKind_H264_360SMR != gCamModelNameUI[kindidx] &&
                camKind_H264_U11300 != gCamModelNameUI[kindidx]
                ) {

                var PregCalcMbps = gCalcMbps[kindidx];
                gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H264);

                var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
                DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

                gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;
            }
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx]) {
            continue; 
        }
        if (camKind_Jpeg_S2116 == gCamModelNameUI[kindidx] || camKind_Jpeg_S2236 == gCamModelNameUI[kindidx] ||
            camKind_Jpeg_S1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_S1110 == gCamModelNameUI[kindidx] ||
            camKind_Jpeg_S4176 == gCamModelNameUI[kindidx] || camKind_Jpeg_S4156 == gCamModelNameUI[kindidx] ||
            camKind_Jpeg_X4170 == gCamModelNameUI[kindidx] || camKind_Jpeg_S4150 == gCamModelNameUI[kindidx] ||
			camKind_Jpeg_S1552 == gCamModelNameUI[kindidx] || camKind_Jpeg_S1550 == gCamModelNameUI[kindidx] || 
			camKind_Jpeg_S1572 == gCamModelNameUI[kindidx] || camKind_Jpeg_S3130 == gCamModelNameUI[kindidx] || 
			camKind_Jpeg_S3110 == gCamModelNameUI[kindidx] || camKind_Jpeg_X1534 == gCamModelNameUI[kindidx] || 
			camKind_Jpeg_X1571 == gCamModelNameUI[kindidx]) {
            PregCalcMbps = gCalcMbps[kindidx];
            gCalcMbps[kindidx] = SetEncData(gCalcMbps[kindidx] * 1000, gJpegIps[kindidx], CAM_JPEG);

            gCalcJpegMbps[kindidx - minidx] = SetEncData(gCalcJpegMbps[kindidx - minidx] * 1000, gJpegIps[kindidx], CAM_JPEG);

            var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
            DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

            gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H265VBR;
    for (; kindidx < maxidx; kindidx++) {
        if ((camKind_H265Vbr_EX_U == gCamModelNameUI[kindidx]) || (camKind_H265Vbr_EX_MIC_U == gCamModelNameUI[kindidx])) {
            continue; 
        }
        var PregCalcMbps = gCalcMbps[kindidx];
        gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H265);

        var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
        DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

        gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264VBR;
    for (; kindidx < maxidx; kindidx++) {
        if ((camKind_H264Vbr_EX_U == gCamModelNameUI[kindidx]) || (camKind_H264Vbr_EX_MIC_U == gCamModelNameUI[kindidx])) {
            continue; 
        }
        var PregCalcMbps = gCalcMbps[kindidx];
        gCalcMbps[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H264);

        var DispSumEncMbps = gCalcMbps[kindidx] - PregCalcMbps;
        DispSumEncMbps = DispSumEncMbps * 1000 / 1024;

        gDispMbps[kindidx] = gDispMbps[kindidx] + DispSumEncMbps;
    }
}

function AddEncdataBitrate_Video(nNwdrCode) {
    var kindidx = 0;
    var minidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        if (camKind_H265_U11300 == gCamModelNameUI[kindidx] || camKind_H265_U1130 == gCamModelNameUI[kindidx] || camKind_H265_U1140 == gCamModelNameUI[kindidx]) {
            continue; 
        }
        gVideoMbps_w[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H265);
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        gVideoMbps_w[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H264);
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (camKind_Jpeg_U1130 == gCamModelNameUI[kindidx] || camKind_Jpeg_U1140 == gCamModelNameUI[kindidx]) {
            continue; 
        }
        if (camKind_Jpeg_Hcm7 != gCamModelNameUI[kindidx] && camKind_Jpeg_Hcm5 != gCamModelNameUI[kindidx]) {
            gVideoMbps_w[kindidx] = SetEncData(gCalcMbps[kindidx] * 1000, gJpegIps[kindidx], CAM_JPEG);
        }
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H265VBR;
    for (; kindidx < maxidx; kindidx++) {
        if (camKind_H265Vbr_EX_U == gCamModelNameUI[kindidx]) {
            continue; 
        }
        gVideoMbps_w[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H265);
    }

    minidx = maxidx;
    maxidx += CAM_TYPENUM_H264VBR;
    for (; kindidx < maxidx; kindidx++) {
        gVideoMbps_w[kindidx] = SetEncData(gBitRateUI[kindidx], gFrameRateUI[kindidx], CAM_H264);
    }

}




function SetEncData(video_bitrate, fps, kindidx) {
    var SetEncBitrate = 0;

    if (0 < video_bitrate) {
        var vByteOfPerSec = video_bitrate / 8 * 1000;
        var vEncParam01 = Math.floor(vByteOfPerSec / 10240);
        if (kindidx == CAM_H265) {
            var vEncRate = (181 * fps + (vEncParam01 * 72) + (vEncParam01 * 8 + 15)) / vByteOfPerSec;
        } else {
            var vEncRate = (173 * fps + (vEncParam01 * 72) + (vEncParam01 * 8 + 15)) / vByteOfPerSec;
        }

        var vEncFactor = 1;
        vEncFactor = 1 + vEncRate;

        SetEncBitrate = (video_bitrate * vEncFactor) / 1000;
    }

    return SetEncBitrate;
}

function SetDsplayResultByEncdata() {
    var kindidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
    }

    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_360 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_FullHd == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Hd == (gCamModelNameUI[kindidx] + 3) || camKind_H264_502 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Gxe5 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_Gxe1 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_H264_Hcm7 == (gCamModelNameUI[kindidx] + 3) || camKind_H264_360SMR == (gCamModelNameUI[kindidx] + 3)) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_H264_360 == gCamModelNameUI[kindidx] || camKind_H264_FullHd == gCamModelNameUI[kindidx] ||
                    camKind_H264_Hd == gCamModelNameUI[kindidx] || camKind_H264_502 == gCamModelNameUI[kindidx] ||
                    camKind_H264_Gxe5 == gCamModelNameUI[kindidx] || camKind_H264_Gxe1 == gCamModelNameUI[kindidx] ||
                    camKind_H264_Hcm7 == gCamModelNameUI[kindidx] || camKind_H264_360SMR == gCamModelNameUI[kindidx]) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }

    maxidx += CAM_TYPENUM_JPEG;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst == 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_360 == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_FullHd == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Hd == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_502 == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Gxe == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_Other == (gCamModelNameUI[kindidx] + 3) ||
                    camKind_Jpeg_Hcm7 == (gCamModelNameUI[kindidx] + 3) || camKind_Jpeg_Hcm5 == (gCamModelNameUI[kindidx] + 3)) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        } else {
            if (0 < gCamNumberUI[kindidx]) {
                if (camKind_Jpeg_360 == gCamModelNameUI[kindidx] || camKind_Jpeg_FullHd == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Hd == gCamModelNameUI[kindidx] || camKind_Jpeg_502 == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Gxe == gCamModelNameUI[kindidx] || camKind_Jpeg_Other == gCamModelNameUI[kindidx] ||
                    camKind_Jpeg_Hcm7 == gCamModelNameUI[kindidx] || camKind_Jpeg_Hcm5 == gCamModelNameUI[kindidx]) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }
}

function SetDsplayResultByVseries(tblBitratePerOne) {
    var kindidx = 0;
    var maxidx = CAM_TYPENUM_H265;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst != 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if ((camKind_H265_V23 == gCamModelNameUI[kindidx] || camKind_H265_V63 == gCamModelNameUI[kindidx] ||
                     camKind_H265_V17 == gCamModelNameUI[kindidx]) &&
                    tblBitratePerOne[kindidx] == 60) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }

    maxidx += CAM_TYPENUM_H264;
    for (; kindidx < maxidx; kindidx++) {
        if (app_dst != 'ja') {
            if (0 < gCamNumberUI[kindidx]) {
                if ((camKind_H264_V23 == gCamModelNameUI[kindidx] || camKind_H264_V63 == gCamModelNameUI[kindidx] ||
                     camKind_H264_V17 == gCamModelNameUI[kindidx]) &&
                    tblBitratePerOne[kindidx] == 60) {
                    g_DsplayResultFlag[nNwdrNX400] = 0;
                }
            }
        }
    }
}


function uiGetH264VbrObject_module(no, partsObj) {
    switch (no) {
        case 1 :
            partsObj[uiIndexCamNumH264Vbr] = frmNWDR.txtCamNumH264Vbr_1;
            partsObj[uiIndexModelH264Vbr] = frmNWDR.selModelH264Vbr_1;
            partsObj[uiIndexResoH264Vbr] = frmNWDR.selResoH264Vbr_1;
            partsObj[uiIndexQualH264Vbr] = frmNWDR.selQualH264Vbr_1;
            partsObj[uiIndexFpsH264Vbr] = frmNWDR.selFpsH264Vbr_1;
            partsObj[uiIndexSceneLocationH264Vbr] = frmNWDR.selSceneLocationH264Vbr_1;
            partsObj[uiIndexSceneGopControlH264Vbr] = frmNWDR.selSceneGopControlH264Vbr_1;
            partsObj[uiIndexSceneSmartFacialCodingH264Vbr] = frmNWDR.selSceneSmartFacialCodingH264Vbr_1;
            partsObj[uiIndexSceneIllumNormalH264Vbr] = frmNWDR.selSceneIllumNormalH264Vbr_1;
            partsObj[uiIndexSceneIllumLowH264Vbr] = frmNWDR.selSceneIllumLowH264Vbr_1;
            partsObj[uiIndexSceneMotionNormalH264Vbr] = frmNWDR.selSceneMotionNormalH264Vbr_1;
            partsObj[uiIndexSceneMotionLowH264Vbr] = frmNWDR.selSceneMotionLowH264Vbr_1;
            partsObj[uiIndexSceneIllumNormalHourH264Vbr] = txt_s_scene_illum_h264_normal_hour_1;
            partsObj[uiIndexSceneMotionNormalHourH264Vbr] = txt_s_scene_motion_h264_normal_hour_1;
            partsObj[uiIndexSceneIllumLowHourH264Vbr] = txt_s_scene_illum_h264_low_hour_1;
            partsObj[uiIndexSceneMotionLowHourH264Vbr] = txt_s_scene_motion_h264_low_hour_1;
            partsObj[uiIndexSceneImageNormalH264Vbr] = frmNWDR.img_h264vbr_scene_normal_1;
            partsObj[uiIndexSceneImageLowH264Vbr] = frmNWDR.img_h264vbr_scene_low_1;
            partsObj[uiIndexMaxKbpsH264Vbr] = frmNWDR.selMaxKbpsH264Vbr_1;
            partsObj[uiIndexAvgKbpsH264Vbr] = frmNWDR.selAvgKbpsH264Vbr_1;
            partsObj[uiIndexCompkindH264Vbr] = frmNWDR.selCompkindVbr;
            break;

        case 2 :
            partsObj[uiIndexCamNumH264Vbr] = frmNWDR.txtCamNumH264Vbr_2;
            partsObj[uiIndexModelH264Vbr] = frmNWDR.selModelH264Vbr_2;
            partsObj[uiIndexResoH264Vbr] = frmNWDR.selResoH264Vbr_2;
            partsObj[uiIndexQualH264Vbr] = frmNWDR.selQualH264Vbr_2;
            partsObj[uiIndexFpsH264Vbr] = frmNWDR.selFpsH264Vbr_2;
            partsObj[uiIndexSceneLocationH264Vbr] = frmNWDR.selSceneLocationH264Vbr_2;
            partsObj[uiIndexSceneGopControlH264Vbr] = frmNWDR.selSceneGopControlH264Vbr_2;
            partsObj[uiIndexSceneSmartFacialCodingH264Vbr] = frmNWDR.selSceneSmartFacialCodingH264Vbr_2;
            partsObj[uiIndexSceneIllumNormalH264Vbr] = frmNWDR.selSceneIllumNormalH264Vbr_2;
            partsObj[uiIndexSceneIllumLowH264Vbr] = frmNWDR.selSceneIllumLowH264Vbr_2;
            partsObj[uiIndexSceneMotionNormalH264Vbr] = frmNWDR.selSceneMotionNormalH264Vbr_2;
            partsObj[uiIndexSceneMotionLowH264Vbr] = frmNWDR.selSceneMotionLowH264Vbr_2;
            partsObj[uiIndexSceneIllumNormalHourH264Vbr] = txt_s_scene_illum_h264_normal_hour_2;
            partsObj[uiIndexSceneMotionNormalHourH264Vbr] = txt_s_scene_motion_h264_normal_hour_2;
            partsObj[uiIndexSceneIllumLowHourH264Vbr] = txt_s_scene_illum_h264_low_hour_2;
            partsObj[uiIndexSceneMotionLowHourH264Vbr] = txt_s_scene_motion_h264_low_hour_2;
            partsObj[uiIndexSceneImageNormalH264Vbr] = frmNWDR.img_h264vbr_scene_normal_2;
            partsObj[uiIndexSceneImageLowH264Vbr] = frmNWDR.img_h264vbr_scene_low_2;
            partsObj[uiIndexMaxKbpsH264Vbr] = frmNWDR.selMaxKbpsH264Vbr_2;
            partsObj[uiIndexAvgKbpsH264Vbr] = frmNWDR.selAvgKbpsH264Vbr_2;
            break;

        case 3 :
            partsObj[uiIndexCamNumH264Vbr] = frmNWDR.txtCamNumH264Vbr_3;
            partsObj[uiIndexModelH264Vbr] = frmNWDR.selModelH264Vbr_3;
            partsObj[uiIndexResoH264Vbr] = frmNWDR.selResoH264Vbr_3;
            partsObj[uiIndexQualH264Vbr] = frmNWDR.selQualH264Vbr_3;
            partsObj[uiIndexFpsH264Vbr] = frmNWDR.selFpsH264Vbr_3;
            partsObj[uiIndexSceneLocationH264Vbr] = frmNWDR.selSceneLocationH264Vbr_3;
            partsObj[uiIndexSceneGopControlH264Vbr] = frmNWDR.selSceneGopControlH264Vbr_3;
            partsObj[uiIndexSceneSmartFacialCodingH264Vbr] = frmNWDR.selSceneSmartFacialCodingH264Vbr_3;
            partsObj[uiIndexSceneIllumNormalH264Vbr] = frmNWDR.selSceneIllumNormalH264Vbr_3;
            partsObj[uiIndexSceneIllumLowH264Vbr] = frmNWDR.selSceneIllumLowH264Vbr_3;
            partsObj[uiIndexSceneMotionNormalH264Vbr] = frmNWDR.selSceneMotionNormalH264Vbr_3;
            partsObj[uiIndexSceneMotionLowH264Vbr] = frmNWDR.selSceneMotionLowH264Vbr_3;
            partsObj[uiIndexSceneIllumNormalHourH264Vbr] = txt_s_scene_illum_h264_normal_hour_3;
            partsObj[uiIndexSceneMotionNormalHourH264Vbr] = txt_s_scene_motion_h264_normal_hour_3;
            partsObj[uiIndexSceneIllumLowHourH264Vbr] = txt_s_scene_illum_h264_low_hour_3;
            partsObj[uiIndexSceneMotionLowHourH264Vbr] = txt_s_scene_motion_h264_low_hour_3;
            partsObj[uiIndexSceneImageNormalH264Vbr] = frmNWDR.img_h264vbr_scene_normal_3;
            partsObj[uiIndexSceneImageLowH264Vbr] = frmNWDR.img_h264vbr_scene_low_3;
            partsObj[uiIndexMaxKbpsH264Vbr] = frmNWDR.selMaxKbpsH264Vbr_3;
            partsObj[uiIndexAvgKbpsH264Vbr] = frmNWDR.selAvgKbpsH264Vbr_3;
            break;
    }
}



function SortEachModelInfo_Aorder(model1, model2) {
    var product_id1 = model1['camCalcBR'];
    var product_id2 = model2['camCalcBR'];

    return product_id1 - product_id2;
}



function SortEachModelInfo_Dorder(model1, model2) {

    var product_id1 = model1['camCalcBR'];
    var product_id2 = model2['camCalcBR'];

    return product_id2 - product_id1;
}


function basicNwdrCalc(nNwdrCode) {
    var tmpRecNum = getTempNwdrNum(nNwdrCode);

    if (tmpRecNum < 1) {
        return -1;
    }

    var plusRecNum = tmpRecNum;
    for (var idx = 0; idx < defPlusRecMax; idx++)
    {
        var orgNwdrInfo = gNwdrInfo.clone();
        NWDRArrayInit(plusRecNum);
        while (true) {
            var buf = AssignCam2Nwdr(nNwdrCode, plusRecNum);
            if (0 > buf) {
                return buf; 
            } else if (1 == buf) { 
                plusRecNum++; 
                NWDRArrayInit(plusRecNum);
            } else { 
                break;
            }
        }

        if (0 != idx) { 
            FunCompareOptimum(gNwdrInfo, orgNwdrInfo, nNwdrCode);
        }
        plusRecNum++; 
    }

    var copyNwdrInfo = gNwdrInfo.clone();

    gCamModelParamInfo.sort(SortEachModelInfo_Aorder);
    plusRecNum = tmpRecNum;
    for (var idx = 0; idx < defPlusRecMax; idx++)
    {    
        var orgNwdrInfo = gNwdrInfo.clone(); 
        NWDRArrayInit(plusRecNum);
        while (true) {
            var buf = AssignCam2Nwdr(nNwdrCode, plusRecNum);
            if (0 > buf) {
                return buf; 
            } else if (1 == buf) { 
                plusRecNum++; 
                NWDRArrayInit(plusRecNum);
            } else { 
                break;
            }
        }

        if (0 != idx) { 
            FunCompareOptimum(gNwdrInfo, orgNwdrInfo, nNwdrCode);
        }
        plusRecNum++; 
    }

    FunCompareOptimum(gNwdrInfo, copyNwdrInfo, nNwdrCode);

    return 1;
}



function FunCompareOptimum(NwdrInfo1, NwdrInfo2, nNwdrCode) {
    var NwdrIdx1 = 0; var NwdrIdx2 = 0;
    var ExtUnitNum1 = 0; var ExtUnitNum2 = 0;

    NwdrIdx1 = NwdrInfo1.length;
    NwdrIdx2 = NwdrInfo2.length;

    for (var i = 0; i < NwdrIdx1; i++) {
        ExtUnitNum1 = Number(ExtUnitNum1) + Number(NwdrInfo1[i].extUnitNum);
    }
    for (var i = 0; i < NwdrIdx2; i++) {
        ExtUnitNum2 = Number(ExtUnitNum2) + Number(NwdrInfo2[i].extUnitNum);
    }
    var lratio = Number(defValRatio[nNwdrCode]) * (NwdrIdx1 - NwdrIdx2);

    if ((ExtUnitNum2 - ExtUnitNum1) >= lratio) {
        return 1;
    }

    tempnum = NwdrInfo2.length;
    NWDRArrayInit(tempnum);
    gNwdrInfo = NwdrInfo2.clone();
    return 0;
}


function FunCheckOverData(nNwdrCode) {
    gMaxDataCapTotalTB = Number(gMaxDataCapExtGB) * Number(defLimitOfExtNum[nNwdrCode]) / 1000;
    gMaxDataCapTotalTB = Number(gMaxDataCapTotalTB) + (Number(gMaxDataCapMainGB) / 1000);

    for (var i = 0; i < gCamModelParamInfo.length; i++) {
        var buf = gCamModelParamInfo[i]; 
        if (buf['camNum'] != 0) { 
            if ((Number(buf['camRecTB']) / Number(defRecCoef[nNwdrCode])) > gMaxDataCapTotalTB) {
                return RET_NWDR_OVF;
            }
        }
    }
    return RET_NO_ERROR;
}


function AssignCam2Nwdr(nNwdrCode, tempnum) {

    var intNWDRq = 0; 

    var bCamHandled = new Array(gTotalCamNum + 1);
    for (var camno = 0; camno < gTotalCamNum + 1; camno++) {
        bCamHandled[camno] = false;
    }

    var bigcheck = FunCheckOverData(nNwdrCode);
    if (bigcheck < 0) {
        return -1;
    }

    var oneMainUnitCapaTB = Number(gMaxDataCapMainGB) / 1000;

    var bMainUnitFinishedFlag = false; 

    intNWDRq = 0; 
    for (var camno = 1; camno < gTotalCamNum + 1; camno++) {
        if (bCamHandled[camno] == true) continue; 

        targetcaminfo = GetSingleCamInfo(nNwdrCode, camno);

        if (targetcaminfo[CAM_RECTB] > oneMainUnitCapaTB) {
            break; 
        }

        for (var nwdrno = intNWDRq; nwdrno < tempnum; nwdrno++) {
            var ret = SubChangeNwdrChecklimit(nNwdrCode, targetcaminfo, nwdrno, 0); 
            if (0 > ret) {
                if (nwdrno == tempnum - 1) {
                    bMainUnitFinishedFlag = true; 
                    break;
                }
            }
            else {
                RegCam2Nwdr(nwdrno,            
                            targetcaminfo[CAM_CALCBR], 
                            targetcaminfo[CAM_TYPE],   
                            targetcaminfo[CAM_JPGIPS], 
                            targetcaminfo[CAM_RECTB],  
                            targetcaminfo[CAM_DISPBR], 
                            targetcaminfo[CAM_MODEL], 
                            targetcaminfo[CAM_DISPVBR]); 

                gNwdrInfo[nwdrno].lngLastHDDCapa =
                    Number(gNwdrInfo[nwdrno].lngLastHDDCapa) +
                    Number(targetcaminfo[CAM_RECTB]);

                intNWDRq++;
                if (intNWDRq >= tempnum) {
                    intNWDRq = 0;
                }
                bCamHandled[camno] = true;
                break;
            }
        }

        if (true == bMainUnitFinishedFlag) {
            break;
        }
    }

    intNWDRq = 0; 

    for (var camno = 1; camno < gTotalCamNum + 1; camno++) { 
        if (bCamHandled[camno] == true) continue; 

        targetcaminfo = GetSingleCamInfo(nNwdrCode, camno);

        intNWDRq = AddCamtoAnotherUnit(nNwdrCode, targetcaminfo, intNWDRq, 1); 
        if (intNWDRq < 0) {
            return 1;
        }
        RegCam2Nwdr(intNWDRq,                  
                    targetcaminfo[CAM_CALCBR], 
                    targetcaminfo[CAM_TYPE],   
                    targetcaminfo[CAM_JPGIPS], 
                    targetcaminfo[CAM_RECTB],  
                    targetcaminfo[CAM_DISPBR], 
                    targetcaminfo[CAM_MODEL], 
                    targetcaminfo[CAM_DISPVBR]); 
        bCamHandled[camno] = true; 
    }

    return RET_NO_ERROR;
}



function SubChangeNwdrChecklimit(nNwdrCode, targetcaminfo, intNWDRq, hdeflag) {

    if (1 < gNwdrInfo[intNWDRq].pankflg) { 
        return -1;
    }

    var camBitrate = 0;

    if (JPEG_1 <= targetcaminfo[CAM_TYPE][0] && targetcaminfo[CAM_TYPE][0] <= JPEG_3) {
        camBitrate = Number(targetcaminfo[CAM_CALCBR]) * Number(defGetaJpeg);
    } else { 
        camBitrate = Number(targetcaminfo[CAM_CALCBR]); 
    }

    var nextBitrateMbps =
        Number(gNwdrInfo[intNWDRq].nCamNumH265Vbr_1) * gVideoMbps[H265VBR_1] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265Vbr_2) * gVideoMbps[H265VBR_2] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265Vbr_3) * gVideoMbps[H265VBR_3] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264Vbr_1) * gVideoMbps[H264VBR_1] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264Vbr_2) * gVideoMbps[H264VBR_2] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264Vbr_3) * gVideoMbps[H264VBR_3] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265_1) * gVideoMbps[H265_1] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265_2) * gVideoMbps[H265_2] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265_3) * gVideoMbps[H265_3] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH265_4) * gVideoMbps[H265_4] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264_1) * gVideoMbps[H264_1] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264_2) * gVideoMbps[H264_2] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264_3) * gVideoMbps[H264_3] + 
        Number(gNwdrInfo[intNWDRq].nCamNumH264_4) * gVideoMbps[H264_4] + 
        Number(gNwdrInfo[intNWDRq].nCamNumJpeg_1) * gDispMbps[JPEG_1] / 1000 * 1024 + 
        Number(gNwdrInfo[intNWDRq].nCamNumJpeg_2) * gDispMbps[JPEG_2] / 1000 * 1024 + 
        Number(gNwdrInfo[intNWDRq].nCamNumJpeg_3) * gDispMbps[JPEG_3] / 1000 * 1024 + 
        Number(gNwdrInfo[intNWDRq].nCamNumJpeg_4) * gDispMbps[JPEG_4] / 1000 * 1024 + 
        gVideoMbps[targetcaminfo[CAM_TYPE][0]];

    if (app_dst != 'zh') {
        if (frmNWDR.chkhttps.checked == true) {
            nextBitrateMbps = Number(nextBitrateMbps) * Number(CALC_HTTPS);
        }
    }

    if (defLimitBandWidth[nNwdrCode] < nextBitrateMbps) {
        gNwdrInfo[intNWDRq].pankflg = 2; 
        return RET_NWDR_OVF;
    }

    if (app_dst == 'ja') {
        var nextMicNum = ((camKind_H264_360SMR == (Number(targetcaminfo[CAM_MODEL]) + 3)) || (camKind_H264_9MSMR == (Number(targetcaminfo[CAM_MODEL]) + 3)) ? 1 : 0);
    } else {
        var nextMicNum = ((camKind_H264_360SMR == Number(targetcaminfo[CAM_MODEL])) || (camKind_H264_9MSMR == Number(targetcaminfo[CAM_MODEL])) ? 1 : 0);
    }
    var nextCamNum = Number(gNwdrInfo[intNWDRq].nCamTotalNum);
    if (H264_1 <= targetcaminfo[CAM_TYPE][0] && targetcaminfo[CAM_TYPE][0] <= H264_4) {
        nextCamNum += Number(gNwdrInfo[intNWDRq].n360MicNum) + nextMicNum;
    }
    else
    {
        nextCamNum += Number(gNwdrInfo[intNWDRq].n360MicNum);
    }

    if (Number(g_DynaConnect[nNwdrCode]) <= nextCamNum) { 
        gNwdrInfo[intNWDRq].pankflg = 2;  
        return RET_NWDR_OVF;
    }

    if (Number(g_DynaConnect[nNwdrCode]) <= nextCamNum) { 
        gNwdrInfo[intNWDRq].pankflg = 2;  
        return RET_NWDR_OVF;
    }

    var nextJpegFps =
        Number(gNwdrInfo[intNWDRq].sysTotalIps) + Number(targetcaminfo[CAM_JPGIPS]);
    if (nextJpegFps > Number(defMaxJpegIps[nNwdrCode])) {
        gNwdrInfo[intNWDRq].pankflg = 2; 
        return RET_NWDR_OVF;
    }

    var nextRecCapa1 =
        Number(gNwdrInfo[intNWDRq].sysRecDataTB) + Number(targetcaminfo[CAM_RECTB]); 

    var nextRecCapa2 = 0;
    if (0 == Number(gNwdrInfo[intNWDRq].extUnitNum)) { 
        nextRecCapa2 =
            Number(gNwdrInfo[intNWDRq].lngLastHDDCapa) + Number(targetcaminfo[CAM_RECTB]); 
    } else {
        nextRecCapa2 =
            (gMaxDataCapMainGB / 1000) +     
            Number(gNwdrInfo[intNWDRq].extUnitNum - 1) * (gMaxDataCapExtGB / 1000) + 
            Number(gNwdrInfo[intNWDRq].lngLastHDDCapa) + 
            Number(targetcaminfo[CAM_RECTB]); 
    }

    var maxDataCapaTB = 0;
    switch (hdeflag) {
        case 0: 
        case 2: 
            maxDataCapaTB = gMaxDataCapMainGB / 1000;
            break;
        case 1: 
            maxDataCapaTB = gMaxDataCapTotalTB;
            break;
    }

    if (gSelRaidMode == 1 && hdeflag != 1) { 
        maxDataCapaTB = maxDataCapaTB / 2;
    }

    if (maxDataCapaTB < nextRecCapa1 || maxDataCapaTB < nextRecCapa2) {
        return ((hdeflag == 2) ? 1 : RET_NWDR_OVF); 
    }

    return RET_NO_ERROR; 
}


function SubChangeNwdrCheck(nNwdrCode, targetcaminfo, intNWDRq, hdeflag) {

    var ret = SubChangeNwdrChecklimit(nNwdrCode, targetcaminfo, intNWDRq, hdeflag);
    if (0 == ret) { 
        return intNWDRq; 
    }

    for (var idx = 0; idx < gNwdrInfo.length; idx++) {
        ret = SubChangeNwdrChecklimit(nNwdrCode, targetcaminfo, idx, hdeflag);
        if (0 == ret) { 
            return idx; 
        }
    }

    return RET_NWDR_OVF; 
}



function AddCamtoAnotherUnit(nNwdrCode, targetcaminfo, intNWDRq, hdeflag) {
    var targetUnitMaxCapaGB;

    var ret = SubChangeNwdrCheck(nNwdrCode, targetcaminfo, intNWDRq, hdeflag);
    if (0 > ret) { 
        return RET_NWDR_OVF;
    }

    var nextRecCapa = Number(gNwdrInfo[ret].lngLastHDDCapa) + Number(targetcaminfo[CAM_RECTB]); 

    if (gSelRaidMode == 1) {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB / 2 : gMaxDataCapExtGB / 2);
    } else {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB : gMaxDataCapExtGB);
    }
    if (nextRecCapa > (targetUnitMaxCapaGB / 1000)) { 
        intNWDRq++;
        if (intNWDRq >= gNwdrInfo.length) {
            intNWDRq = 0;
        }
        ret = SubChangeNwdrCheck(nNwdrCode, targetcaminfo, intNWDRq, hdeflag);
        if (0 > ret) { 
            return RET_NWDR_OVF;
        }
    }

    nextRecCapa = Number(gNwdrInfo[ret].lngLastHDDCapa) + Number(targetcaminfo[CAM_RECTB]); 

    if (gSelRaidMode == 1) {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB / 2 : gMaxDataCapExtGB / 2);
    } else {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB : gMaxDataCapExtGB);
    }

    if (nextRecCapa > (targetUnitMaxCapaGB / 1000)) {
        if (gNwdrInfo[ret].extUnitNum >= defLimitOfExtNum[nNwdrCode]) { 
            return RET_EXT_OVF; 
        }

        gNwdrInfo[ret].lngLastHDDCapa = Number(gNwdrInfo[ret].lngLastHDDCapa) + Number(targetcaminfo[CAM_RECTB]); 
        var dobhanpadata = addExtUnit(ret);

        if (gSelRaidMode == 1) {
            targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB / 2 : gMaxDataCapExtGB / 2);
        } else {
            targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[ret].extUnitNum) ? gMaxDataCapMainGB : gMaxDataCapExtGB);
        }
        while (dobhanpadata > targetUnitMaxCapaGB / 1000) {
            if (gNwdrInfo[ret].extUnitNum >= defLimitOfExtNum[nNwdrCode]) { 
                return RET_EXT_OVF; 
            }

            dobhanpadata = addExtUnit(ret);
            gNwdrInfo[ret].lngLastHDDCapa = dobhanpadata; 
        }
    } else {
        gNwdrInfo[ret].lngLastHDDCapa = nextRecCapa; 
    }

    return ret;
}


function addExtUnit(intNWDRq) {
    var dobhanpadata = 0;

    var targetUnitMaxCapaGB; 
    if (gSelRaidMode == 1) {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[intNWDRq].extUnitNum) ? gMaxDataCapMainGB / 2 : gMaxDataCapExtGB / 2);
    } else {
        targetUnitMaxCapaGB = (0 == Number(gNwdrInfo[intNWDRq].extUnitNum) ? gMaxDataCapMainGB : gMaxDataCapExtGB);
    }

    dobhanpadata = Number(gNwdrInfo[intNWDRq].lngLastHDDCapa) - (targetUnitMaxCapaGB / 1000); 
    gNwdrInfo[intNWDRq].extUnitNum = Number(gNwdrInfo[intNWDRq].extUnitNum) + 1; 
    gNwdrInfo[intNWDRq].lngLastHDDCapa = dobhanpadata; 
    return dobhanpadata;
}


function RegCam2Nwdr(i, brCalcMbps, cType, ips, camDataTB, brDispMbps, modelname, brDispVMbps) {
    brCalcMbps = gVideoMbps[cType];

    switch (cType[0]) {
        case H265VBR_1:
            gNwdrInfo[i].nCamNumH265Vbr_1 = Number(gNwdrInfo[i].nCamNumH265Vbr_1) + 1;
            break;
        case H265VBR_2:
            gNwdrInfo[i].nCamNumH265Vbr_2 = Number(gNwdrInfo[i].nCamNumH265Vbr_2) + 1;
            break;
        case H265VBR_3:
            gNwdrInfo[i].nCamNumH265Vbr_3 = Number(gNwdrInfo[i].nCamNumH265Vbr_3) + 1;
            break;
        case H264VBR_1:
            gNwdrInfo[i].nCamNumH264Vbr_1 = Number(gNwdrInfo[i].nCamNumH264Vbr_1) + 1;
            break;
        case H264VBR_2:
            gNwdrInfo[i].nCamNumH264Vbr_2 = Number(gNwdrInfo[i].nCamNumH264Vbr_2) + 1;
            break;
        case H264VBR_3:
            gNwdrInfo[i].nCamNumH264Vbr_3 = Number(gNwdrInfo[i].nCamNumH264Vbr_3) + 1;
            break;
        case H265_1:
            gNwdrInfo[i].nCamNumH265_1 = Number(gNwdrInfo[i].nCamNumH265_1) + 1;
            break;
        case H265_2:
            gNwdrInfo[i].nCamNumH265_2 = Number(gNwdrInfo[i].nCamNumH265_2) + 1;
            break;
        case H265_3:
            gNwdrInfo[i].nCamNumH265_3 = Number(gNwdrInfo[i].nCamNumH265_3) + 1;
            break;
        case H265_4:
            gNwdrInfo[i].nCamNumH265_4 = Number(gNwdrInfo[i].nCamNumH265_4) + 1;
            break;
        case H264_1:
            gNwdrInfo[i].nCamNumH264_1 = Number(gNwdrInfo[i].nCamNumH264_1) + 1;
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (modelname + 3) || camKind_H264_9MSMR == (modelname + 3)) {
                    gNwdrInfo[i].n360MicNum++;
                }
            } else {
                if (camKind_H264_360SMR == modelname || camKind_H264_9MSMR == modelname) {
                    gNwdrInfo[i].n360MicNum++;
                }
            }
            break;
        case H264_2:
            gNwdrInfo[i].nCamNumH264_2 = Number(gNwdrInfo[i].nCamNumH264_2) + 1;
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (modelname + 3) || camKind_H264_9MSMR == (modelname + 3)) {
                    gNwdrInfo[i].n360MicNum++;
                }
            } else {
                if (camKind_H264_360SMR == modelname || camKind_H264_9MSMR == modelname) {
                    gNwdrInfo[i].n360MicNum++;
                }
            }
            break;
        case H264_3:
            gNwdrInfo[i].nCamNumH264_3 = Number(gNwdrInfo[i].nCamNumH264_3) + 1;
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (modelname + 3) || camKind_H264_9MSMR == (modelname + 3)) {
                    gNwdrInfo[i].n360MicNum++;
                }
            } else {
                if (camKind_H264_360SMR == modelname || camKind_H264_9MSMR == modelname) {
                    gNwdrInfo[i].n360MicNum++;
                }
            }
            break;
        case H264_4:
            gNwdrInfo[i].nCamNumH264_4 = Number(gNwdrInfo[i].nCamNumH264_4) + 1;
            if (app_dst == 'ja') {
                if (camKind_H264_360SMR == (modelname + 3) || camKind_H264_9MSMR == (modelname + 3)) {
                    gNwdrInfo[i].n360MicNum++;
                }
            } else {
                if (camKind_H264_360SMR == modelname || camKind_H264_9MSMR == modelname) {
                    gNwdrInfo[i].n360MicNum++;
                }
            }
            break;

        case JPEG_1:
            gNwdrInfo[i].nCamNumJpeg_1 = Number(gNwdrInfo[i].nCamNumJpeg_1) + 1;
            brCalcMbps = brCalcMbps * defGetaJpeg;
            break;
        case JPEG_2:
            gNwdrInfo[i].nCamNumJpeg_2 = Number(gNwdrInfo[i].nCamNumJpeg_2) + 1;
            brCalcMbps = brCalcMbps * defGetaJpeg;
            break;
        case JPEG_3:
            gNwdrInfo[i].nCamNumJpeg_3 = Number(gNwdrInfo[i].nCamNumJpeg_3) + 1;
            brCalcMbps = brCalcMbps * defGetaJpeg;
            break;
        case JPEG_4:
            gNwdrInfo[i].nCamNumJpeg_4 = Number(gNwdrInfo[i].nCamNumJpeg_4) + 1;
            brCalcMbps = brCalcMbps * defGetaJpeg;
            break;

    }

    if (app_dst != 'zh') {
        if (frmNWDR.chkencdata.checked == true) {
            var Encdata;
            if (cType >= H264VBR_1) {
                brCalcMbps = SetEncData(gBitRateUI[cType], gFrameRateUI[cType], CAM_H264);
            } else if (cType >= H265VBR_1) {
                brCalcMbps = SetEncData(gBitRateUI[cType], gFrameRateUI[cType], CAM_H265);
            } else if (cType >= JPEG_1) {
                brCalcMbps = SetEncData(gCalcMbps[cType] * 1000, gJpegIps[cType], CAM_JPEG);
            } else if (cType >= H264_1) {
                brCalcMbps = SetEncData(gBitRateUI[cType], gFrameRateUI[cType], CAM_H264);
            } else {
                brCalcMbps = SetEncData(gBitRateUI[cType], gFrameRateUI[cType], CAM_H265);
            }
        }
    }

    if (true == frmNWDR.chkaudio.checked) {
        if (document.getElementById('camRecAudio_AACLC').checked == true) {
            brCalcMbps = brCalcMbps + Number(CALC_AUDIO_AACLC);
        } else {
            brCalcMbps = brCalcMbps + Number(CALC_AUDIO);
        }
    }
    brCalcMbps = brCalcMbps + (Number(CALC_VMDINFO));

    var tempCamBps = 0;
    gNwdrInfo[i].nCamTotalNum =
        Number(gNwdrInfo[i].nCamNumH265Vbr_1) +
        Number(gNwdrInfo[i].nCamNumH265Vbr_2) +
        Number(gNwdrInfo[i].nCamNumH265Vbr_3) +
        Number(gNwdrInfo[i].nCamNumH264Vbr_1) +
        Number(gNwdrInfo[i].nCamNumH264Vbr_2) +
        Number(gNwdrInfo[i].nCamNumH264Vbr_3) +
        Number(gNwdrInfo[i].nCamNumH265_1) +
        Number(gNwdrInfo[i].nCamNumH265_2) +
        Number(gNwdrInfo[i].nCamNumH265_3) +
        Number(gNwdrInfo[i].nCamNumH265_4) +
        Number(gNwdrInfo[i].nCamNumH264_1) +
        Number(gNwdrInfo[i].nCamNumH264_2) +
        Number(gNwdrInfo[i].nCamNumH264_3) +
        Number(gNwdrInfo[i].nCamNumH264_4) +
        Number(gNwdrInfo[i].nCamNumJpeg_1) +
        Number(gNwdrInfo[i].nCamNumJpeg_2) +
        Number(gNwdrInfo[i].nCamNumJpeg_3) +
        Number(gNwdrInfo[i].nCamNumJpeg_4);

    gNwdrInfo[i].sysCalcMbps = Number(gNwdrInfo[i].sysCalcMbps) + Number(brCalcMbps);
    tempCamBps = gNwdrInfo[i].sysCalcMbps;
    tempCamBps = NumberToFixed2(tempCamBps, 3);
    gNwdrInfo[i].sysCalcMbps = tempCamBps;

    gNwdrInfo[i].sysDispMbps =
        Number(gNwdrInfo[i].sysDispMbps) + Number(brDispMbps); 

    gNwdrInfo[i].sysTotalIps = Number(gNwdrInfo[i].sysTotalIps) + Number(ips);

    camDataTB = GetMarumCapa2(camDataTB);
    gNwdrInfo[i].sysRecDataTB =
        Number(gNwdrInfo[i].sysRecDataTB) + Number(camDataTB); 
}


function GetSingleCamInfo(nNwdrCode, j) {
    var lmode;
    var inttempc = 0;

    for (var i = 0; i < gCamModelParamInfo.length; i++) {
        var buf = gCamModelParamInfo[i];

        var inttempc = Number(inttempc) + Number(buf['camNum']);
        if (j <= inttempc) {
            intarrayno = j;

            return [
                Number(buf['camRecTB']) / defRecCoef[nNwdrCode], 
                buf['camCalcBR'], 
                buf['camType'],   
                buf['camJpgIps'], 
                buf['camDispBR'], 
                buf['camModel'],   
                buf['camDispVBR']   
            ];
        }
    }
}


function getTempNwdrNum(nNwdrCode) {
    var tempNwdrNum = 0;

    var sprio1 = frmNWDR.selPrioH264_1.options[
                frmNWDR.selPrioH264_1.selectedIndex
            ].text;
    var sprio2 = frmNWDR.selPrioH264_2.options[
                frmNWDR.selPrioH264_2.selectedIndex
            ].text;
    var sprio3 = frmNWDR.selPrioH264_3.options[
                frmNWDR.selPrioH264_3.selectedIndex
            ].text;
    var sprio4 = frmNWDR.selPrioH264_4.options[
                frmNWDR.selPrioH264_4.selectedIndex
            ].text;

    var modconnect = gTotalCamNum % g_DynaConnect[nNwdrCode];
    tempNwdrNum = (gTotalCamNum - modconnect) / g_DynaConnect[nNwdrCode];
    if (0 < modconnect) {
        tempNwdrNum += 1;
    }


    if ((app_dst != 'zh') && (frmNWDR.chkencdata.checked == true)) {
        AddEncdataBitrate_Video(nNwdrCode);
    } else {
        gVideoMbps_w[H265VBR_1] = gVideoMbps[H265VBR_1];
        gVideoMbps_w[H265VBR_2] = gVideoMbps[H265VBR_2];
        gVideoMbps_w[H265VBR_3] = gVideoMbps[H265VBR_3];
        gVideoMbps_w[H264VBR_1] = gVideoMbps[H264VBR_1];
        gVideoMbps_w[H264VBR_2] = gVideoMbps[H264VBR_2];
        gVideoMbps_w[H264VBR_3] = gVideoMbps[H264VBR_3];
        gVideoMbps_w[H265_1] = gVideoMbps[H265_1];
        gVideoMbps_w[H265_2] = gVideoMbps[H265_2];
        gVideoMbps_w[H265_3] = gVideoMbps[H265_3];
        gVideoMbps_w[H265_4] = gVideoMbps[H265_4];
        gVideoMbps_w[H264_1] = gVideoMbps[H264_1];
        gVideoMbps_w[H264_2] = gVideoMbps[H264_2];
        gVideoMbps_w[H264_3] = gVideoMbps[H264_3];
        gVideoMbps_w[H264_4] = gVideoMbps[H264_4];
        gVideoMbps_w[JPEG_1] = gDispMbps[JPEG_1];
        gVideoMbps_w[JPEG_2] = gDispMbps[JPEG_2];
        gVideoMbps_w[JPEG_3] = gDispMbps[JPEG_3];
        gVideoMbps_w[JPEG_4] = gDispMbps[JPEG_4];
    }

    var totalBitrateMbps =
        gCamNumberUI[H265VBR_1] * gVideoMbps_w[H265VBR_1] + 
        gCamNumberUI[H265VBR_2] * gVideoMbps_w[H265VBR_2] + 
        gCamNumberUI[H265VBR_3] * gVideoMbps_w[H265VBR_3] + 
        gCamNumberUI[H264VBR_1] * gVideoMbps_w[H264VBR_1] + 
        gCamNumberUI[H264VBR_2] * gVideoMbps_w[H264VBR_2] + 
        gCamNumberUI[H264VBR_3] * gVideoMbps_w[H264VBR_3] + 
        gCamNumberUI[H265_1] * gVideoMbps_w[H265_1] + 
        gCamNumberUI[H265_2] * gVideoMbps_w[H265_2] + 
        gCamNumberUI[H265_3] * gVideoMbps_w[H265_3] + 
        gCamNumberUI[H265_4] * gVideoMbps_w[H265_4] + 
        gCamNumberUI[H264_1] * gVideoMbps_w[H264_1] + 
        gCamNumberUI[H264_2] * gVideoMbps_w[H264_2] + 
        gCamNumberUI[H264_3] * gVideoMbps_w[H264_3] + 
        gCamNumberUI[H264_4] * gVideoMbps_w[H264_4] + 
        gCamNumberUI[JPEG_1] * gVideoMbps_w[JPEG_1] / 1000 * 1024 + 
        gCamNumberUI[JPEG_2] * gVideoMbps_w[JPEG_2] / 1000 * 1024 + 
        gCamNumberUI[JPEG_3] * gVideoMbps_w[JPEG_3] / 1000 * 1024 + 
        gCamNumberUI[JPEG_4] * gVideoMbps_w[JPEG_4] / 1000 * 1024;  

    if (app_dst != 'ja') {
        if (frmNWDR.chksubstream.checked == true) {
            totalBitrateMbps += ((gCamNumberUI[H265VBR_1] + gCamNumberUI[H265VBR_2] +
                                  gCamNumberUI[H265VBR_3] + gCamNumberUI[H265_1] +
                                  gCamNumberUI[H265_2] + gCamNumberUI[H265_3] +
                                  gCamNumberUI[H265_4]) * Number(CALC_SUBSTREAM_H265)) +
                                ((gCamNumberUI[H264VBR_1] + gCamNumberUI[H264VBR_2] +
                                  gCamNumberUI[H264VBR_3] + gCamNumberUI[H264_1] +
                                  gCamNumberUI[H264_2] + gCamNumberUI[H264_3] +
                                  gCamNumberUI[H264_4]) * Number(CALC_SUBSTREAM_H264));
        }
    }

    var calcNwdrNum = Math.ceil(totalBitrateMbps / defLimitBandWidth[nNwdrCode]); 

    if (calcNwdrNum > tempNwdrNum) {
        tempNwdrNum = calcNwdrNum;
    }

    var totalTargetRecDataGB = Number(frmNWDR.txttotalcap.value) / defRecCoef[nNwdrCode]; 
    totalTargetRecDataGB = NumberToFixed2(totalTargetRecDataGB, 4) * 1000;

    var hddCapaGB = gSelHddUnitGB;
    var maxTotalCapaGB;    

    switch (gSelRaidMode) {
        case 0: 
            gMaxDataCapMainGB = hddCapaGB * defMaxHddNum_Main_RAID0[nNwdrCode];
            gMaxDataCapExtGB = hddCapaGB * defMaxHddNum_Ext_RAID0[nNwdrCode];
            maxTotalCapaGB = gMaxDataCapMainGB +
                hddCapaGB * defLimitOfExtNum[nNwdrCode] * defMaxHddNum_Ext_RAID0[nNwdrCode];

            if (nNwdrCode == nNwdrNX400) {
                gMaxDataCapMainGB -= defMaxHddNum_Main_RAID0[nNwdrCode] * (defNXtimelineTB * 1000); 
                gMaxDataCapExtGB -= defMaxHddNum_Ext_RAID0[nNwdrCode] * (defNXtimelineTB * 1000); 
                maxTotalCapaGB -= defMaxHddNum_System_RAID0[nNwdrCode] * (defNXtimelineTB * 1000); 
            }
            break;

        case 1: 
            gMaxDataCapMainGB = hddCapaGB * defMaxHddNum_Main_RAID1[nNwdrCode];
            gMaxDataCapExtGB = hddCapaGB * defMaxHddNum_Ext_RAID1[nNwdrCode];
            maxTotalCapaGB = hddCapaGB * defMaxHddNum_System_RAID1[nNwdrCode];

            if (nNwdrCode == nNwdrNX400) {
                gMaxDataCapMainGB -= defMaxHddNum_Main_RAID1[nNwdrCode] * (defNXtimelineTB * 1000); 
                gMaxDataCapExtGB -= defMaxHddNum_Ext_RAID1[nNwdrCode] * (defNXtimelineTB * 1000); 
                maxTotalCapaGB -= defMaxHddNum_System_RAID1[nNwdrCode] * (defNXtimelineTB * 1000); 
            }
            break;

        case 5: 
            gMaxDataCapMainGB = hddCapaGB * defMaxHddNum_Main_RAID5[nNwdrCode];
            gMaxDataCapExtGB = hddCapaGB * defMaxHddNum_Ext_RAID5[nNwdrCode];
            maxTotalCapaGB = hddCapaGB * defMaxHddNum_System_RAID5[nNwdrCode];

            if (nNwdrCode == nNwdrNX400) {
                gMaxDataCapMainGB -= (defNXtimelineTB * 1000); 
                gMaxDataCapExtGB -= (defNXtimelineTB * 1000); 
                maxTotalCapaGB -= defLimitOfExtNum[nNwdrCode] * (defNXtimelineTB * 1000); 
            }
            break;

        case 6: 
            gMaxDataCapMainGB = hddCapaGB * defMaxHddNum_Main_RAID6[nNwdrCode];
            gMaxDataCapExtGB = hddCapaGB * defMaxHddNum_Ext_RAID6[nNwdrCode];
            maxTotalCapaGB = hddCapaGB * defMaxHddNum_System_RAID6[nNwdrCode];

            if (nNwdrCode == nNwdrNX400) {
                gMaxDataCapMainGB -= (defNXtimelineTB * 1000); 
                gMaxDataCapExtGB -= (defNXtimelineTB * 1000); 
                maxTotalCapaGB -= defLimitOfExtNum[nNwdrCode] * (defNXtimelineTB * 1000); 
            }

            break;
    } 
    calcNwdrNum = Math.ceil(totalTargetRecDataGB / maxTotalCapaGB);

    if (calcNwdrNum > tempNwdrNum) {
        tempNwdrNum = calcNwdrNum;
    }

    var totalJpegIps = 0;
    totalJpegIps += (gCamNumberUI[JPEG_1] * gJpegIps[JPEG_1]); 
    totalJpegIps += (gCamNumberUI[JPEG_2] * gJpegIps[JPEG_2]); 
    totalJpegIps += (gCamNumberUI[JPEG_3] * gJpegIps[JPEG_3]); 
    totalJpegIps += (gCamNumberUI[JPEG_4] * gJpegIps[JPEG_4]); 

    var modJpegIps = totalJpegIps % defMaxJpegIps[nNwdrCode];
    calcNwdrNum = (totalJpegIps - modJpegIps) / defMaxJpegIps[nNwdrCode];
    if (modJpegIps > 0) {
        calcNwdrNum += 1;
    }

    if (calcNwdrNum > tempNwdrNum) {
        tempNwdrNum = calcNwdrNum;
    }

    var oneDataGB = GetCamBitrateorder(nNwdrCode);
    if (oneDataGB > maxTotalCapaGB) {
        return RET_NWDR_OVF;
    }

    return tempNwdrNum;
}



function GetCamBitrateorder(nNwdrCode) {
    var tempbit = 0;
    for (var i = 0; i < CAM_TYPENUM_ALL; i++) {
        if (gCamNumberUI[i] > 0) {
            if (gCalcMbps[i] > tempbit) {
                tempbit = gCalcMbps[i];
            }
        }
    }

    var oneDataGB = 0;
    oneDataGB =
        Number(tempbit) / 8 * 3600 * gRecDay * gRecHour / 1000;
    oneDataGB = oneDataGB / Number(defRecCoef[nNwdrCode]);


    oneDataGB = Number(NumberToFixed2(oneDataGB, 4));

    gCamModelParamInfo.sort(SortEachModelInfo_Dorder);

    return oneDataGB;
}

function hikaku(a, b) {
    return (b.Mbps - a.Mbps);
}

function sort_kougo(cnt, camBitrate) {
    var cnt_l = 0; 
    var cnt_s = 0; 

    for (var i = 0; i < cnt; i++) {
        if (i % 2 == 0) {
            tmpcamBitrate[i] = camBitrate[cnt_s];
            cnt_s++;
        }
        else {
            tmpcamBitrate[i] = camBitrate[cnt - 1 - cnt_l];
            cnt_l++;
        }
    }
    for (var i = 0; i < cnt; i++) {
        camBitrate[i] = tmpcamBitrate[i];
    }
}


function camNum2LicNum(nCamNum, nNxLicCode) {
    var nRet = 0;
    switch (nNxLicCode) {
        case NXE40:
            if (nCamNum > 96) nRet++;
            if (nCamNum > 64) nRet++;
            break;

        case NXE41:
            if (nCamNum > 96) nRet++; 
            break;

    } 
    return nRet;
}


function getBrowserVersion() {
    return window.opera ?
        (opera.version().replace(/\d$/, '') - 0) :
        parseFloat((/(?:IE |fox\/|ome\/|ion\/)(\d+\.\d)/.
            exec(navigator.userAgent) || [, 0])[1]);
}


function numOnly2(nKeyCode) {

    if (nKeyCode == 46 || nKeyCode == 37 || nKeyCode == 39) {
         return true;
    }

    if (96 <= nKeyCode & nKeyCode <= 105) {
        return true;
    }

    var m = String.fromCharCode(nKeyCode);
    if ('0123456789\d\b\r\t'.indexOf(m, 0) < 0) {
         return false;
    }

    return true;

}


function GetMarumCapa(data) {

    if (data < 1) {
        if (data < 0.0001) {
            data = 0.0001;
        } else {
            data = Math.ceil(data * 100000) / 100000;
            data = NumberToFixed(data, 4);
        }
    } else {
        data = Math.ceil(data * 1000) / 1000;
        data = NumberToFixed(data, 2);
    }

    return data;
}


function GetMarumCapa2(data) {

    return data;
}

function NumberToFixed(dValue, iDigits) {
    if (isNaN(dValue)) {
        return dValue;
    }

    var dCoef = Math.pow(10, iDigits);
    var ret = dValue;

    if (dValue > 0) {
        ret = Math.floor((dValue * dCoef) + 0.5) / dCoef;
    }
    else {
        ret = Math.ceil((dValue * dCoef) - 0.5) / dCoef;
    }

    var retstr = ret.toString();
    var pos = retstr.lastIndexOf('.');
    if (0 < pos) {
        var keta = retstr.length - (pos + 1);
        for (var idx = keta; idx < iDigits; idx++) {
            retstr = retstr + '0';
        }
    }
    else {
        retstr = ret.toString();

        retstr = retstr + '.';
        for (var idx = 0; idx < iDigits; idx++) {
            retstr = retstr + '0';
        }
    }

    return retstr;
}

function NumberToFixed2(dValue, iDigits) {
    return dValue;
}

function isJpSingle() {
    if (gSelRaidMode == 0 && app_dst == 'ja') return true;
    return false;
}

function isJpMirror() {
    if (gSelRaidMode == 1 && app_dst == 'ja') return true;
    return false;
}


