// resize to reload
PageLoadingVideoDevice();
AddEventListen(1);
AddEventListen(2);
ReadDataFromFile('PositionInfoFromFile=1');
ReadDataFromFile('PositionInfoFromFile=2');
WriteToSystemLogReset('CleanFileLocation=1');
var decoderConfigurationSlider = 0;
var decoderConfigurationSliderPageY;
var decoderConfigurationSliderTop;
var decoderConfigurationCont;
var decoderConfigurationContTop;

var MouseoverRx=0;//鼠标是否停留在decoder上--正向
var MouseoverRxToHide=0;
var MouseUpOrDown=0;//鼠标在encoder上是否释放--正向
var backMouseoverRx=0;//鼠标是否停留在decoder上--反向
var backMouseoverRxToHide=0;
var backMouseUpOrDown=0;//鼠标在encoder上是否释放--反向
var DecoderChannelNum;//拖动切换的放置设备
var EncoderChannelNum;
//同组拖动机构切换 
var DecodeDropToChangePosition=0;
var _VideoPageResolutionFormats = 0;
var _keyPressActive=0;
var _settimeoutResolution=0;
// encode EDID Dropdown select
var EDIDSelectFile='';
var EDIDSelectFileText='';

var _ReceiveCheckType=0;
var _SendingCheckType=0;
$(document).ready(function(){
	GroupAddDeviceEventListen(1);
	// 20190311==========================================================================
	$('#DisplayErrorContentClose').on('click',function(){
		$('#DisplayErrorContent').hide();
	});
	$('#DisplayErrorContentYesBtn').on('click',function(){
		$('#DisplayErrorContent').hide();
	});
	$('#DisplaySuccessContentClose').on('click',function(){
		$('#DisplaySuccessContent').hide();
	});
	$('#DisplaySuccessContentYesBtn').on('click',function(){
		$('#DisplaySuccessContent').hide();
	});
	// 2019-02-26 video save preset =====================================================
	$('#VideoGroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#VideoConfigurationRxDevice').hide();
		_DeviceRxSettingClick = 0;
	});
	$('#VideoGroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#VideoConfigurationRxDevice').hide();
		_DeviceRxSettingClick = 0;
	});
	$('#VideoWallGroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#VideoWallConfigurationRxDevice').hide();
		_VideoWallDeviceRxSettingClick = 0;
	});
	$('#VideoWallGroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#VideoWallConfigurationRxDevice').hide();
		_VideoWallDeviceRxSettingClick = 0;
	});
	$('#HdmiAudioGroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#HdmiAudioConfigurationRxDevice').hide();
		_HdmiAudioDeviceRxSettingClick = 0;
	});
	$('#HdmiAudioGroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#HdmiAudioConfigurationRxDevice').hide();
		_HdmiAudioDeviceRxSettingClick = 0;
	});
	$('#AnalogAudioGroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#AnalogAudioConfigurationRxDevice').hide();
		_AnalogAudioDeviceRxSettingClick = 0;
	});
	$('#AnalogAudioGroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#AnalogAudioConfigurationRxDevice').hide();
		_AnalogAudioDeviceRxSettingClick = 0;
	});
	$('#Rs232GroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#Rs232ConfigurationRxDevice').hide();
		_Rs232DeviceRxSettingClick = 0;
	});
	$('#Rs232GroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#Rs232ConfigurationRxDevice').hide();
		_Rs232DeviceRxSettingClick = 0;
	});
	$('#InfraredGroupOptionsRxSavePreset').on('click',function(){
		$('#SavePresetNeedComfirm').show();
		$('#InfraredConfigurationRxDevice').hide();
		_InfraredDeviceRxSettingClick = 0;
	});
	$('#InfraredGroupOptionsRxRecallPreset').on('click',function(){
		$('#RecallPresetNeedComfirm').show();
		$('#InfraredConfigurationRxDevice').hide();
		_InfraredDeviceRxSettingClick = 0;
	});
	// /////////////////////////////
	$('#SavePresetNeedComfirmNo').on('click',function(){
		$('#SavePresetNeedComfirm').hide();
	});
	$('#SavePresetNeedComfirmYes').on('click',function(){
		var _recv = '';
		var _fileName = '';
		
		switch(current_page){
		case 1:
			_recv = CheckRoutingAndMode(1);
			_fileName = 'VideoPreset_'+DeviceGroupRxSelectNum;
		break;
		case 2:
			_recv = CheckRoutingAndMode(1);
			_fileName = 'VideoPreset_'+DeviceGroupRxSelectNum;
		break;
		case 3:
			_fileName = 'HdmiAudioPreset_'+DeviceGroupRxSelectNum;
			_recv = CheckRoutingAndMode(2);
		break;
		case 4:
			_fileName = 'AnalogAudioPreset_'+DeviceGroupRxSelectNum;
			_recv = CheckRoutingAndMode(3);
		break;
		case 5:
			_fileName = 'Rs232Preset_'+DeviceGroupRxSelectNum;
			_recv = CheckRoutingAndMode(4);
		break;
		case 6:
			_fileName = 'InfraredPreset_'+DeviceGroupRxSelectNum;
			_recv = CheckRoutingAndMode(5);
		break;
		}
		console.log(_recv);
		$('#SavePresetNeedComfirm').hide();
		$.ajax({
	        type: 'POST',
	        url: 'common/GroupSaveSetting.php',
	        data: 'GroupSaveSettingName='+_fileName+'&FileData='+_recv,
	        datatype: 'json',
	        async: true,
	        cache:false,
	        success: function(rst) {
	        	
	        }
	    });
	});
	$('#SavePresetNeedComfirmClose').on('click',function(){
		$('#SavePresetNeedComfirm').hide();
	});
	// 2019-02-26 video recall preset =====================================================	
	$('#RecallPresetNeedComfirmNo').on('click',function(){
		$('#RecallPresetNeedComfirm').hide();
	});
	$('#RecallPresetNeedComfirmYes').on('click',function(){
		var _fileName = '';
		switch(current_page){ 
		case 1:
			_fileName = 'VideoPreset_'+DeviceGroupRxSelectNum;
		break;
		case 2:
			_fileName = 'VideoPreset_'+DeviceGroupRxSelectNum;
		break;
		case 3:
			_fileName = 'HdmiAudioPreset_'+DeviceGroupRxSelectNum;
		break;
		case 4:
			_fileName = 'AnalogAudioPreset_'+DeviceGroupRxSelectNum;
		break;
		case 5:
			_fileName = 'Rs232Preset_'+DeviceGroupRxSelectNum;
		break;
		case 6:
			_fileName = 'InfraredPreset_'+DeviceGroupRxSelectNum;
		break;
		}
		$.ajax({
	        type: 'POST',
	        url: 'common/GroupSaveSetting.php',
	        data: 'ReadGroupSaveSettingName='+_fileName,
	        datatype: 'json',
	        async: true,
	        cache:false,
	        success: function(rst) {
	        	if (rst!='NULL'||rst!='') {
	        		//0004a3eb5fa3:,=|=0004a3eb7348:genlock_scaling|1280|720|60,
	        		var _rstArr = rst.split('=|=');
	        		var _channelRouting = _rstArr[0].split(',');
	        		for (var i = 0; i < _channelRouting.length; i++) {
	        			if (_channelRouting[i]!='') {
	        				var _channelRoutingDevice = _channelRouting[i].split(':');
	        				if (_channelRoutingDevice[1]!='') {
	        					var _channelRoutingDeviceDecode = _channelRoutingDevice[1].split('|');
	        					for (var j = 0; j < _channelRoutingDeviceDecode.length; j++) {
	        						if (_channelRoutingDeviceDecode[j]!='') {
	        							if (current_page==1||current_page==2) {
	        								sendCommand('data=join ' + _channelRoutingDevice[0] + ':HDMI:0 ' 
		        										+ _channelRoutingDeviceDecode[j] + ':HDMI:0');
	        							}
	        							else if (current_page==3)
		        						{
		        							sendCommand('data=join ' + _channelRoutingDevice[0] + ':HDMI_AUDIO:0 ' 
		        										+ _channelRoutingDeviceDecode[j] + ':HDMI_AUDIO:0');
		        						}
		        						else if (current_page==4)
		        						{
		        							sendCommand('data=join ' + _channelRoutingDevice[0] + ':AUDIO:0 ' 
		        										+ _channelRoutingDeviceDecode[j] + ':AUDIO:0');
		        						}
		        						else if (current_page==5)
		        						{
		        							sendCommand('data=switch ' + _channelRoutingDevice[0] + ':RS232:1 ' 
		        										+ _channelRoutingDeviceDecode[j] + ':RS232:1');
		        						}
		        						else if (current_page==6)
		        						{
		        							sendCommand('data=switch ' + _channelRoutingDevice[0] + ':INFRARED:0 ' 
		        										+ _channelRoutingDeviceDecode[j] + ':INFRARED:0');
		        						}
	        						}
	        					}
	        				}
	        			}
	        		}
	        		if (_rstArr[1]!=''&&(current_page==1||current_page==2)) {
	        			var _VideoMode = _rstArr[1].split(',');
	        			for (var i = 0; i < _VideoMode.length; i++) {
	        				if (_VideoMode[i]!='') {
	        					var _VideoModeArr = _VideoMode[i].split(':');
	        					var _VideoModeRes = _VideoModeArr[1].split('|');
	        					if (_VideoModeRes[0]=='genlock') {
	        						sendCommand('data=set '+ _VideoModeArr[0] +' video genlock');
	        					}
	        					else {//size 1280 720 fps 60
	        						sendCommand('data=set '+ _VideoModeArr[0] +' video '+_VideoModeRes[0] + ' size '
	        									+_VideoModeRes[1]+' '+_VideoModeRes[2]+' fps '+_VideoModeRes[3]);
	        					}
	        				}
	        			}
	        		}
	        	}
	        }
	    });
	    $('#RecallPresetNeedComfirm').hide();
	});
	$('#RecallPresetNeedComfirmClose').on('click',function(){
		$('#RecallPresetNeedComfirm').hide();
	});
	// 2019-02-20 ===============================================================
	$('#DeviceStopandFreeMulticastaddressClose').on('click',function(){
		$('#DeviceStopandFreeMulticastaddress').hide();
	});
	$('#DeviceStopandFreeMulticastaddressNoBtn').on('click',function(){
		$('#DeviceStopandFreeMulticastaddress').hide();
	});
	$('#DeviceStopandFreeMulticastaddressYesBtn').on('click',function(){
		var _arrRx = _data.videoswitching_encode_arr.split(',');
		if (current_page==3)
			sendCommand('data=stop '+_arrRx[EncoderConfigurationDeviceNumb]+':HDMI_AUDIO:0 free');
		else if (current_page==4)
			sendCommand('data=stop '+_arrRx[EncoderConfigurationDeviceNumb]+':AUDIO:0 free');
		else 
			sendCommand('data=stop '+_arrRx[EncoderConfigurationDeviceNumb]+':HDMI:0 free');
		$('#DeviceStopandFreeMulticastaddress').hide();
	});
	$('.VideoRxSettingBackup').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0&&_DeviceRxSettingClick==1) return;
		var data = 'devicesettinginfo=1&devicesettinginfodata=';
		if (current_page==5||current_page==6) {
			if (_DeviceRxSettingClick==1) {
				data += Rs232IrReceiverDataDetaileDataArr[DecoderConfigurationDeviceNumb-1].toString();
			}
			if (_DeviceTxSettingClick==1) {
				data += Rs232IrSenderDataDetaileDataArr[EncoderConfigurationDeviceNumb].toString();
			}
		}
		else{ 
			if (_DeviceRxSettingClick==1) {
				data += DecodeDetaileDataArr[DecoderConfigurationDeviceNumb-1].toString();
			}
			if (_DeviceTxSettingClick==1) {
				data += EncodeDetaileDataArr[EncoderConfigurationDeviceNumb].toString();
			}
		}
		$.ajax({
	        type: 'POST',
	        url: 'common/readfile.php',
	        data: data,
	        datatype: 'json',
	        async: true,
	        success: function(rst) {
	        	var url = "http://"+window.location.hostname+"/info/DeviceSettingInfo.txt";
				new FileDownloader({
				    url: encodeURI(url),
				    filename: "Device Setting.txt"
				});
	        	// QtFileBackup();
	        }
	    });
	});	
	$('.VideoRxSettingRestore').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0&&_DeviceRxSettingClick==1) return;
		if (_DeviceRxSettingClick==1) {
			_RestoreSettingRxOrTx = 1;
		}
		if (_DeviceTxSettingClick==1) {
			_RestoreSettingRxOrTx = 2;
		}
		$('#DeviceSettingRestore').show();
	});
	$('#DeviceSettingRestoreClose').on('click',function(){
		$('#DeviceSettingRestore').hide();
	});
	$('#DeviceSettingRestoreNoBtn').on('click',function(){
		$('#DeviceSettingRestore').hide();
	});
	$('#DeviceSettingRestoreYesBtn').on('click',function(){
		var formData = new FormData();
		if(document.getElementById("DeviceSetting").files[0]==null){
			$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html("Invalid Value!");
			$('#DisplayErrorContent').show();
			return;
		}
	    
		formData.append("DeviceSetting", document.getElementById("DeviceSetting").files[0]);
    
    	$.ajax({
	        url: "common/BackupAndRestore.php",
	        type: "POST",
	        data: formData,
	        /**
	        *必须false才会自动加上正确的Content-Type
	        */
	        contentType: false,
	        /**
	        * 必须false才会避开jQuery对 formdata 的默认处理
	        * XMLHttpRequest会对 formdata 进行正确的处理
	        */
	        processData: false,
	        success: function (data) {
	        	var _DeviceID='';
	        	var dataArr = data.split(',');
	        	if (current_page==5||current_page==6) {
					if (_RestoreSettingRxOrTx==1) {
						if (typeof(dataArr[0])=='boolean'){
							$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('This Config not Decode!');
							$('#DisplayErrorContent').show();
							return;
						}
						var _arrRx = _data.Rs232_De_En_arr.split(',');
						_DeviceID = _arrRx[DecoderConfigurationDeviceNumb-1];
					}
					if (_RestoreSettingRxOrTx==2) {
						if (typeof(dataArr[0])=='number'){
							$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('This Config not Encode!');
							$('#DisplayErrorContent').show();
							return;
						}
						var _arrRx = _data.Rs232_En_De_arr.split(',');
						_DeviceID = _arrRx[EncoderConfigurationDeviceNumb];
					}
				}
				else{ 
					if (_RestoreSettingRxOrTx==1) {
						if (typeof(dataArr[0])=='boolean'){
							$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('This Config not Decode!');
							$('#DisplayErrorContent').show();
							return;
						}
						var _arrRx = _data.videoswitching_decode_arr.split(',');
						_DeviceID = _arrRx[DecoderConfigurationDeviceNumb-1];
					}
					if (_RestoreSettingRxOrTx==2) {
						if (typeof(dataArr[0])=='number'){
							$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('This Config not Encode!');
							$('#DisplayErrorContent').show();
							return;
						}
						var _arrRx = _data.videoswitching_encode_arr.split(',');
						_DeviceID = _arrRx[EncoderConfigurationDeviceNumb];
					}
				}
				
				if (dataArr[0]=='2'||dataArr[0]=='3')
	        		DeviceSettingRestoreDecode(_DeviceID,data);
	        	else
	        		DeviceSettingRestoreEncode(_DeviceID,data);
	        	$('#DeviceSettingRestore').hide();
	        },
	        error: function () {

	        }
      	}); 
	});
	// ===============================================================
	$('#DeviceDeviceCleanSettingClose').on('click',function(){
		$('#DeviceCleanSetting').hide();
	});
	$('#DeviceDeviceCleanSettingNoBtn').on('click',function(){
		$('#DeviceCleanSetting').hide();
	});
	$('#DeviceDeviceCleanSettingYesBtn').on('click',function(){		
		var _ClecnSettingVal = [0,0,0,0,0];
		if (_CleanSettingRxOrTx==1) {
			if ($('#RxAnalogAudioOutput').prop('checked'))
				_ClecnSettingVal[0] = 1;
			if ($('#RxHDMIAudioOutput').prop('checked'))
				_ClecnSettingVal[1] = 1;
			if ($('#RxNetworkSetting').prop('checked'))
				_ClecnSettingVal[2] = 1;
			if ($('#RxRs232').prop('checked'))
				_ClecnSettingVal[3] = 1;
			if ($('#RxSetVideoGenlock').prop('checked'))
				_ClecnSettingVal[4] = 1;
		}
		else if (_CleanSettingRxOrTx==2) {
			if ($('#TxHDCPSetting').prop('checked'))
				_ClecnSettingVal[0] = 1;
			if ($('#TxNetworkSetting').prop('checked'))
				_ClecnSettingVal[1] = 1;
			if ($('#TxRs232').prop('checked'))
				_ClecnSettingVal[2] = 1;
		}
		CleanSettingsFunction(current_page,_ClecnSettingVal);
		$('#DeviceCleanSetting').hide();
	});
	// 清除设备现有设置至出厂设置，只有Hostname不重置
	$('#VideoCleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#VideoCleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// ====================
	$('#VideoWallCleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#VideoWallCleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// ====================
	$('#HdmiAudioCleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#HdmiAudioCleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// ====================
	$('#AnalogAudioCleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#AnalogAudioCleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// ====================
	$('#Rs232CleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#Rs232CleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// ====================
	$('#InfraredCleanSettings').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').hide();
		_CleanSettingRxOrTx = 1;
		if ($('#RxAnalogAudioOutput').prop('checked'))
			$('#RxAnalogAudioOutput').click();
		if ($('#RxHDMIAudioOutput').prop('checked'))
			$('#RxHDMIAudioOutput').click();
		if ($('#RxNetworkSetting').prop('checked'))
			$('#RxNetworkSetting').click();
		if ($('#RxRs232').prop('checked'))
			$('#RxRs232').click();
		if ($('#RxSetVideoGenlock').prop('checked'))
			$('#RxSetVideoGenlock').click();
		$('#DeviceCleanSetting').show();
	});
	$('#InfraredCleanSettingsTx').on('click',function(){
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(1)').show();
		$('#DeviceCleanSetting .DeviceCleanSettingCont:eq(0)').hide();
		_CleanSettingRxOrTx = 2;
		if ($('#TxHDCPSetting').prop('checked'))
			$('#TxHDCPSetting').click();
		if ($('#TxNetworkSetting').prop('checked'))
			$('#TxNetworkSetting').click();
		if ($('#TxRs232').prop('checked'))
			$('#TxRs232').click();
		$('#DeviceCleanSetting').show();
	});
	// 读取本地EDID文件夹目录文件
	$('#DisplayEdidNavReflash').on('click',function(){
		$.ajax({
		    type: 'POST',
		    url: 'common/readDocumentEdidFile.php',
		    data: '1',
		    datatype: 'json',
		    async: true,
		    success: function(rst) {
		    	// for (item in rst) {
		    	// 	console.log(item);
		    	// }
		    	$('#DisplayEdidNav').html('');
		    	var _rst = rst.split(':');
		        for (var i = _rst.length-1; i >= 0 ; i--) {
		        	if (_rst[i]!='') {
		        		$('#DisplayEdidNav').append('<option value='+i+'>'+_rst[i]+'</option>');
		        	}		        	
		        }
		    }

		});
	});
	// 输入IP效果 --------------------------------------------------------------------------
	$('#HDCPSupport').on('change',function(){
		if ($('#HDCPSupport').val()=='0'&&EncodeDetaileDataArr[EncoderConfigurationDeviceNumb][0]) {
			$('#HDCP22Support').attr('disabled',false);		
			$('#HDCP22Support').removeClass('textDisabled');
		}else{
			$('#HDCP22Support').attr('disabled',true);
			$('#HDCP22Support').addClass('textDisabled');
		}
	});
	$('.IPAV1100ContentBottomLeftConnectIpBox input').each(function(e){
		$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+(e)+')').on('focus',function(){
			//console.log(123);
			this.selectionStart = 0;
			this.selectionEnd = 3;
		});	
		$(this).bind('input propertychange',function(){
			//console.log($('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val());
			// 当为输入符号"."时 进行光标移动
			if ($('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val().indexOf('.')>=0) {
				if (e==3) 
					$('.connectionPort').focus();
				else{										
					$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+(e+1)+')').focus();
				}

				$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val($('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val().replace(/[^\d]/g,''));
			}
			

			$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val($('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val().replace(/[^\d]/g,''));
			var _num = $('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val()==''?'':parseInt($('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val());
			if (e==0) {
				if (_num>223) {
					$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val('223');
					return;
				}
			}
			else{
				if (_num>255) {
					$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val('255');
					return;
				}
			}
			if (this.selectionStart==3&&this.selectionEnd==3) {
				if (e==3) 
					$('.connectionPort').focus();
				else
					$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+(e+1)+')').focus();
			}
			//console.log(_num);
			$('.IPAV1100ContentBottomLeftConnectIpBox input:eq('+e+')').val(_num);
			// keypress
			$('.connectionIP').val($('.IPAV1100ContentBottomLeftConnectIpBox input:eq(0)').val()+'.'
									+$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(1)').val()+'.'
									+$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(2)').val()+'.'
									+$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(3)').val());
		});	
		
	});
	
		
	// ---------------------------------------------------------------------------------
	$('#DeleteGroupNeedComfirmClose').on('click',function(){
		$('#DeleteGroupNeedComfirm').hide();
	});
	$('#DeleteGroupNeedComfirmNo').on('click',function(){
		$('#DeleteGroupNeedComfirm').hide();
	});
	$('#DeleteGroupNeedComfirmYes').on('click',function(){
		DeleteGroupFromThisPage(AddToGroupEditNamePage,AddToGroupEditNameType);
	});
	// ---------------------------------------------------------------------------------
	$('#AddToGroupEditNameClose').on('click',function(){
		$('#AddToGroupEditName').hide();
	});
	$('#AddToGroupEditNameNo').on('click',function(){
		$('#AddToGroupEditName').hide();
	});
	$('#AddToGroupEditNameYes').on('click',function(){
		var _name = $('#AddToGroupEditName .DeviceSendReceiveInfraredContText').val();
		AddToGroupThisArgument(_name);
	});
	// 左侧圆形按钮点击事件 -------------------------------------------------------------------------
	$('#VideoRxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#VideoRxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#VideoRxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#VideoTxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#VideoTxDeviceRenameBoxYes').click();
		});
	});
	$('#VideoTxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	//////////////////////////////////////////////////////////----------------------------------------
	$('#VideoWallRxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#VideoWallRxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#VideoWallRxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#VideoWallTxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#VideoWallTxDeviceRenameBoxYes').click();
		});
	});
	$('#VideoWallTxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	//////////////////////////////////////////////////////////----------------------------------------
	$('#HdmiAudioRxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#HdmiAudioRxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#HdmiAudioRxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#HdmiAudioTxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#HdmiAudioTxDeviceRenameBoxYes').click();
		});
	});
	$('#HdmiAudioTxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	//////////////////////////////////////////////////////////----------------------------------------
	$('#AnalogAudioRxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#AnalogAudioRxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#AnalogAudioRxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#AnalogAudioTxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#AnalogAudioTxDeviceRenameBoxYes').click();
		});
	});
	$('#AnalogAudioTxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	//////////////////////////////////////////////////////////----------------------------------------
	$('#Rs232RxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#Rs232RxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#Rs232RxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#Rs232TxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#Rs232TxDeviceRenameBoxYes').click();
		});
	});
	$('#Rs232TxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	//////////////////////////////////////////////////////////----------------------------------------
	$('#InfraredRxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#InfraredRxDeviceRenameBoxYes').click();	
				//console.log(1);		
		});
	});
	$('#InfraredRxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
		//console.log(2);	
	});
	$('#InfraredTxDeviceRenameBox input').on('focus',function(){
		$(this).keypress(function(e) {
			if (e.which == 13)
				$('#InfraredTxDeviceRenameBoxYes').click();
		});
	});
	$('#InfraredTxDeviceRenameBox input').on('blur',function(){
		$(this).unbind('keypress');
	});
	////////////////////////////////////////////////////////////------------------------------------------
	$('.VideoRxDeviceScrollContVideoDecoder li').each(function(e){
		$(this).on('click',function(){
			$('.VideoRxDeviceScrollContVideoDecoder li').removeClass('VideoScrollRxClick');
			$('.IPAV1100RxCont').css('top',-(240*e)+'px');
			$(this).addClass('VideoScrollRxClick');
		});
	});
	$('.VideoTxDeviceScrollContVideoEncoder li').each(function(e){
		$(this).on('click',function(){
			var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
			var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
			
			$('.VideoTxDeviceScrollContVideoEncoder li').removeClass('VideoScrollRxClick');
			$('.IPAV1100TxCont').css('top',-(_IPAV1100TxContDisplayH*e)+'px');
			$(this).addClass('VideoScrollRxClick');
		});
	});
	$.ajax({//0::123::listen::192.168.0.104::6970
        type: 'POST',
        url: 'common/readfile.php',
        data: 'readSocketdata=1',
        datatype: 'json',
        async: true,
        success: function(rst) {
        	console.log(rst);
        	var _rstArr = rst.split('::');
        	if (_rstArr[3]!=''&&typeof(_rstArr[3])!='undefined') {
        		$('.connectionIP').val(_rstArr[3]);
        		var _FenduanArr = _rstArr[3].split('.');
        		$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(0)').val(_FenduanArr[0]);
        		$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(1)').val(_FenduanArr[1]);
        		$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(2)').val(_FenduanArr[2]);
        		$('.IPAV1100ContentBottomLeftConnectIpBox input:eq(3)').val(_FenduanArr[3]);
        	}
        	if (_rstArr[4]!=''&&typeof(_rstArr[4])!='undefined') {
        		$('.connectionPort').val(_rstArr[4]);
        	}
        }
    });
	$('.DisplayErrorNav a').on('click',function(){
		$('.DisplayErrorNav').hide();
	});
	// save edid rx
	
	$('#DecoderSaveEDIDBtn').on('click',function(){
		var data = $('.DecoderEdidDataText').html();//_data.Rs232_De_En_arr _data.videoswitching_decode_arr
		if (current_page==5||current_page==6){
			var _deviceData = Rs232IrReceiverDataDetaileDataArr[DecoderConfigurationDeviceNumb-1];
		}
		else {
			var _deviceData = DecodeDetaileDataArr[DecoderConfigurationDeviceNumb-1];
		}
		var deviceid = _deviceData[2];
		ReadDataFromFile('saveedid='+data+'&deviceID='+deviceid);
		setTimeout(function(){
			var url = "http://"+window.location.hostname+"/edid/edid.edid";
			var _filename = "edid.edid";
			new FileDownloader({
			    url: encodeURI(url),
			    filename: _filename
			});
		},200);
		// if(typeof context == 'undefined')
	  //   {
	  //   	$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html("context error！");
			// $('#DisplayErrorContent').show();
	  //   }
	  //   else
	  //   {    	
	  //   	var data = $('.DecoderEdidDataText').val();
	  //   	//alert(context1.__propertyCache__[3]);  
	  //   	//alert(JSON.stringify(context));  	
	  //      // context.file_select();IPA100
	  //      	context.file_save();

	  //      	//alert(QtObjectName+'123');
	  //       //alert(JSON.stringify(context));
	  //       //alert(JSON.stringify(context));
	  //   }
	});
	// 
	$('#DisplayEdidToDevice').on('click',function(){
		if ($('.connectionToServerBtn').html()=='Connect') {
			return;
		}
		var _val = $('#DisplayEdidData').val();
		if (current_page==5||current_page==6) {
			var _arrRx = _data.Rs232_En_De_arr.split(',');
			var _id = _arrRx[EncoderConfigurationDeviceNumb];
		}
		else {
			var _arrRx = _data.videoswitching_encode_arr.split(',');
			var _id = _arrRx[EncoderConfigurationDeviceNumb];
		}
		// var _arr = _data.videoswitching_encode_arr.split(',');
		// var _id = _arr[EncoderConfigurationDeviceNumb];

		if (EDIDSelectFileText==_val) {
			var FileData = "filePath=../EDID File/"+$('#DisplayEdidNav').find('option:selected').text();
			$.ajax({
		        url: "common/readEdidFromSelectDocumentFile.php",
		        type: "POST",
		        data: FileData,
		        datatype: 'json',
		        async: false,
		        success: function (data) {
		        	if (data.length!=512&&data.length!=256) {
		        		console.log(data);
		        		$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('Invalid EDID!');
						$('#DisplayErrorContent').show();
		        		return;
		        	}
		        	if ($('.connectionToServerBtn').html()=='Connect') {
						return;
					}
					// console.log(data);
					sendCommand('data=set '+_id+' edid ' + data);
					$('#DisplayEdidData').val(data);
					$('#DisplaySuccessContent .DeviceSendReceiveInfraredContText').html('success!');
					$('#DisplaySuccessContent').show();
					EDIDSelectFileText = data;
		        },
		        error: function () {}
		    });
		}
		else {
			sendCommand('data=set '+_id+' edid ' + _val);
			EDIDSelectFileText = _val;
			$('#DisplaySuccessContent .DeviceSendReceiveInfraredContText').html('success!');
			$('#DisplaySuccessContent').show();

		}
	});
	$('#DisplayEdidFromFileToDevice').on('click',function(){
		$('#fileSelect').click();
	});
	$('#fileSelect').on('change',function(){
		var formData = new FormData();
		if(document.getElementById("fileSelect").files[0]==null){
			$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html("Invalid Value!");
			$('#DisplayErrorContent').show();
			return;
		}
		formData.append("myfile", document.getElementById("fileSelect").files[0]);
		
		$.ajax({
	        url: "common/readEdidFromFile.php",
	        type: "POST",
	        data: formData,
	        /**
	        *必须false才会自动加上正确的Content-Type
	        */
	        contentType: false,
	        /**
	        * 必须false才会避开jQuery对 formdata 的默认处理
	        * XMLHttpRequest会对 formdata 进行正确的处理
	        */
	        processData: false,
	        success: function (data) {
	        	if (data.length!=512&&data.length!=256) {
	        		$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('Invalid EDID!');
					$('#DisplayErrorContent').show();
	        		return;
	        	}
	        	if ($('.connectionToServerBtn').html()=='Connect') {
					 return;
				}
	        	var _arr = _data.videoswitching_encode_arr.split(',');
				var _id = _arr[deviceSelectID];

				// sendCommand('data=set '+_id+' edid ' + data);
				$('#DisplayEdidData').val(data);
				//alert('success!');
	        },
	        error: function () {}
	    });
	});
	// rx setting cancel change
	$('#DeviceRxConfigurationBoxCancelBtn').on('click',function(){
		DecoderConfigurationSettingBox();
	});
	$('#DeviceTxConfigurationBoxCancelBtn').on('click',function(){
		EncoderConfigurationSettingBox();
	});
	// setting network select change
	$('#DecoderIPMode').on('change',function(){
		if ($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='0') {
			$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',true);
			$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',true);
			$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',true);
			$('#DeviceRxConfigurationBox #DecoderIPAdress').addClass('textDisabled');
			$('#DeviceRxConfigurationBox #DecoderMask').addClass('textDisabled');
			$('#DeviceRxConfigurationBox #DecoderGateway').addClass('textDisabled');
		}else if($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='1'){
			$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',false);
			$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',false);
			$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',false);
			$('#DeviceRxConfigurationBox #DecoderIPAdress').removeClass('textDisabled');
			$('#DeviceRxConfigurationBox #DecoderMask').removeClass('textDisabled');
			$('#DeviceRxConfigurationBox #DecoderGateway').removeClass('textDisabled');
		}
	});
	$('#EncoderIPMode').on('change',function(){
		if ($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='0') {
			$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',true);
			$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',true);
			$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',true);
			$('#DeviceTxConfigurationBox #EncoderIPAdress').addClass('textDisabled');
			$('#DeviceTxConfigurationBox #EncoderMask').addClass('textDisabled');
			$('#DeviceTxConfigurationBox #EncoderGateway').addClass('textDisabled');
		}else if($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='1'){
			$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',false);
			$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',false);
			$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',false);
			$('#DeviceTxConfigurationBox #EncoderIPAdress').removeClass('textDisabled');
			$('#DeviceTxConfigurationBox #EncoderMask').removeClass('textDisabled');
			$('#DeviceTxConfigurationBox #EncoderGateway').removeClass('textDisabled');
		}
	});
	// setting滚轮事件
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRight').bind('mousewheel',function(e){
		var _top = -(parseInt($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightC').css('top')));
		var _Scrolltop = (parseInt($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationScrollSlider').css('top')));
        if (e.originalEvent.wheelDelta<0) {//true:正        	
        	if (_top<=265) {
        		_top = -((_top+30)>=265?265:(_top+30));
        		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightC').css('top',_top+'px');
        	}
        	if (_Scrolltop<=250) {
        		_Scrolltop = ((_Scrolltop+30)>=250?250:(_Scrolltop+30));
        		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationScrollSlider').css('top',_Scrolltop+'px');        		
        	}
        }                    
		else {
			if (_top>=0) {
        		_top = -((_top-30)>0?(_top-30):0);
        		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightC').css('top',_top+'px');
        	}
        	if (_Scrolltop>=0) {
        		_Scrolltop = ((_Scrolltop-30)>0?(_Scrolltop-30):0);
        		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationScrollSlider').css('top',_Scrolltop+'px');
        	}
		}
	});
	$('#DeviceTxConfigurationBox .DeviceEncoderConfigurationRightC').bind('mousewheel',function(e){
		var _top = -(parseInt($('#DeviceTxConfigurationBox .DeviceEncoderConfigurationRightC').css('top')));
		var _Scrolltop = (parseInt($('#DeviceTxConfigurationBox .DeviceEncoderConfigurationScrollSlider').css('top')));

        if (e.originalEvent.wheelDelta<0) {//true:正        	
        	if (_top<=119) {
        		_top = -((_top+30)>=119?119:(_top+30));
        		$('#DeviceTxConfigurationBox .DeviceEncoderConfigurationRightC').css('top',_top+'px');

        	}
        	if (_Scrolltop<=250) {
        		_Scrolltop = ((_Scrolltop+50)>=250?250:(_Scrolltop+50));
        		$('#DeviceTxConfigurationBox .DeviceEncoderConfigurationScrollSlider').css('top',_Scrolltop+'px');        		
        	}
        }                    
		else {
			if (_top>=0) {
        		_top = -((_top-30)>0?(_top-30):0);
        		$('#DeviceTxConfigurationBox .DeviceEncoderConfigurationRightC').css('top',_top+'px');
        	}
        	if (_Scrolltop>=0) {
        		_Scrolltop = ((_Scrolltop-50)>0?(_Scrolltop-50):0);
        		$('#DeviceTxConfigurationBox .DeviceEncoderConfigurationScrollSlider').css('top',_Scrolltop+'px');
        	}
		}
	});
	// 错误提示框
	$('#MessageDisplayBtn').on('click',function(){
		$('#MessageDisplay').hide();
	});
	$('#MessageDisplayClose').on('click',function(){
		$('#MessageDisplay').hide();
	});
	// video routing select box
	$('#VideoRoutingTypeSelect').on('click',function(){
		if ($('#VideoRoutingSelectOption').css('display').indexOf('block')<0) {
			$('#VideoRoutingSelectOption').show();
		}
		else 
			$('#VideoRoutingSelectOption').hide();
	});
	$('#HdmiAudioRoutingTypeSelect').on('click',function(){
		if ($('#HdmiAudioRoutingSelectOption').css('display').indexOf('block')<0) {
			$('#HdmiAudioRoutingSelectOption').show();
		}
		else 
			$('#HdmiAudioRoutingSelectOption').hide();
	});
	$('#AnalogAudioRoutingTypeSelect').on('click',function(){
		if ($('#AnalogAudioRoutingSelectOption').css('display').indexOf('block')<0) {
			$('#AnalogAudioRoutingSelectOption').show();
		}
		else 
			$('#AnalogAudioRoutingSelectOption').hide();
	});
	$('#Rs232RoutingTypeSelect').on('click',function(){
		if ($('#Rs232RoutingSelectOption').css('display').indexOf('block')<0) {
			$('#Rs232RoutingSelectOption').show();
		}
		else 
			$('#Rs232RoutingSelectOption').hide();
	});
	$('#InfraredRoutingTypeSelect').on('click',function(){
		if ($('#InfraredRoutingSelectOption').css('display').indexOf('block')<0) {
			$('#InfraredRoutingSelectOption').show();
		}
		else 
			$('#InfraredRoutingSelectOption').hide();
	});
	// drop event begin ---------------------------------------	
	// check video routing
	
	//video switch 切换功能模块 ----------------
	
	$(window).on('mouseup',function(){
		VideoDecoderToChangePosition = 0;
		VideoEncoderToChangePosition=0;
		var _rx,_tx;
		if (current_page==5||current_page==6) {
			var _arrRx = _data.Rs232_De_En_arr.split(',');
		}
		else {
			var _arrRx = _data.videoswitching_decode_arr.split(',');
		}
				
		$('.DeviceClickToMove').hide();
		if (MouseUpOrDown==1) {
			if (MouseoverRx==1) {	
				$('.IPAV1100RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    // $('.IPAV1100TxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100VideoWallRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    // $('.IPAV1100VideoWallTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    // $('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    // $('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    //$('.IPAV1100Rs232RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    // $('.IPAV1100Rs232TxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100Rs232RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    // $('.IPAV1100InfraredTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100InfraredRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
				var data;			
				
				var _id;
				var _linkDevice;
				if (current_page==1) {
					_tx = EncodeVideoDataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=join ' + _tx + ':HDMI:0 ' + DecodeVideoDataArr[DecoderChannelNum-1][1] + ':HDMI:0';			
						_rx = DecodeVideoDataArr[DecoderChannelNum-1][1];
						
						$('.IPAV1100RxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < DecodeVideoDataArr.length; i++) {
			                if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
			                    if (DecodeVideoDataArr[i][5]==EncodeVideoDataArr[DecoderToChangePositionAfterNum][4]) {
			                        $('.IPAV1100RxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            
						_id = 'Default';
						
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=VideoEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + DecodeVideoDataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(DecodeVideoDataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('VideoEncode_'+_id,_rst.toString());
			                } 
			            });
						
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':HDMI:0 all_rx:HDMI:0';
							_rx = 0;
							//_tx = EncodeVideoDataArr[DecoderToChangePositionAfterNum][1];
							
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
									$('.IPAV1100RxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#GroupTxSelectBox li').each(function(e){
									if ($('#VideoGroupSelectTx span').html()==$('#GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=VideoEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < DecodeVideoDataArr.length; j++) {
				                    				if (DecodeVideoDataArr[j]!=''&&typeof(DecodeVideoDataArr[j])!='undefined') {
				                    					_rstArr[15] += DecodeVideoDataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}else {
				                    			//_rstArr[15] = _rstArr[15].replace(DecodeVideoDataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('VideoEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==2) {
					_tx = EncodeVideoWallDataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=join ' + _tx + ':HDMI:0 ' + DecodeVideoWallDataArr[DecoderChannelNum-1][1] + ':HDMI:0';			
						_rx = DecodeVideoWallDataArr[DecoderChannelNum-1][1];
						//_tx = EncodeVideoWallDataArr[DecoderToChangePositionAfterNum][1];
						$('.IPAV1100VideoWallRxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < DecodeVideoWallDataArr.length; i++) {
			                if (DecodeVideoWallDataArr[i]!=''&&typeof(DecodeVideoWallDataArr[i])!='undefined') {
			                    if (DecodeVideoWallDataArr[i][5]==EncodeVideoWallDataArr[DecoderToChangePositionAfterNum][4]) {
			                        $('.IPAV1100VideoWallRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=VideoWallEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + DecodeVideoWallDataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}  else {
			                    			_rstArr[15] = _rstArr[15].replace(DecodeVideoWallDataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}                  		
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('VideoWallEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {							
						if (0) {
							data='data=join ' + _tx + ':HDMI:0 all_rx:HDMI:0';
							_rx = 0;
							//_tx = EncodeVideoWallDataArr[DecoderToChangePositionAfterNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (DecodeVideoWallDataArr[i]!=''&&typeof(DecodeVideoWallDataArr[i])!='undefined') {
									$('.IPAV1100VideoWallRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#VideoWallGroupTxSelectBox li').each(function(e){
									if ($('#VideoWallGroupSelectTx span').html()==$('#VideoWallGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#VideoWallGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=VideoWallEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < DecodeVideoWallDataArr.length; j++) {
				                    				if (DecodeVideoWallDataArr[j]!=''&&typeof(DecodeVideoWallDataArr[j])!='undefined') {
				                    					_rstArr[15] += DecodeVideoWallDataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}else {
				                    			//_rstArr[15] = _rstArr[15].replace(DecodeVideoWallDataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                     		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('VideoWallEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==3) {
					_tx = Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=join ' + _tx + ':HDMI_AUDIO:0 ' + Decode_HdmiAudio_DataArr[DecoderChannelNum-1][1] + ':HDMI_AUDIO:0';			
						_rx = Decode_HdmiAudio_DataArr[DecoderChannelNum-1][1];
						//_tx = Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum][1];
						$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < Decode_HdmiAudio_DataArr.length; i++) {
			                if (Decode_HdmiAudio_DataArr[i]!=''&&typeof(Decode_HdmiAudio_DataArr[i])!='undefined') {
			                    if (Decode_HdmiAudio_DataArr[i][5]==Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum][4]) {
			                        $('.IPAV1100HdmiAudioRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						else {				
							$('#HdmiAudioGroupTxSelectBox li').each(function(e){
								if ($('#HdmiAudioGroupSelectTx span').html()==$('#HdmiAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
									_id = $('#HdmiAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
								}
							});
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=HdmiAudioEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_HdmiAudio_DataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}  else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_HdmiAudio_DataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}  
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('HdmiAudioEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':HDMI_AUDIO:0 all_rx:HDMI_AUDIO:0';
							_rx = 0;
							//_tx = Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_HdmiAudio_DataArr[i]!=''&&typeof(Decode_HdmiAudio_DataArr[i])!='undefined') {
									$('.IPAV1100HdmiAudioRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#HdmiAudioGroupTxSelectBox li').each(function(e){
									if ($('#HdmiAudioGroupSelectTx span').html()==$('#HdmiAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#HdmiAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=HdmiAudioEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_HdmiAudio_DataArr.length; j++) {
				                    				if (Decode_HdmiAudio_DataArr[j]!=''&&typeof(Decode_HdmiAudio_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_HdmiAudio_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_HdmiAudio_DataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                   		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('HdmiAudioEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==4) {
					_tx = Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=join ' + _tx + ':AUDIO:0 ' + Decode_AnalogAudio_DataArr[DecoderChannelNum-1][1] + ':AUDIO:0';			
						_rx = Decode_AnalogAudio_DataArr[DecoderChannelNum-1][1];
						//_tx = Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum][1];
						$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < Decode_AnalogAudio_DataArr.length; i++) {
			                if (Decode_AnalogAudio_DataArr[i]!=''&&typeof(Decode_AnalogAudio_DataArr[i])!='undefined') {
			                    if (Decode_AnalogAudio_DataArr[i][5]==Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum][4]) {
			                        $('.IPAV1100AnalogAudioRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=AnalogAudioEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_AnalogAudio_DataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_AnalogAudio_DataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}  
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('AnalogAudioEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':AUDIO:0 all_rx:AUDIO:0';
							_rx = 0;
							//_tx = Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_AnalogAudio_DataArr[i]!=''&&typeof(Decode_AnalogAudio_DataArr[i])!='undefined') {
									$('.IPAV1100AnalogAudioRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#AnalogAudioGroupTxSelectBox li').each(function(e){
									if ($('#AnalogAudioGroupSelectTx span').html()==$('#AnalogAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#AnalogAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=AnalogAudioEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_AnalogAudio_DataArr.length; j++) {
				                    				if (Decode_AnalogAudio_DataArr[j]!=''&&typeof(Decode_AnalogAudio_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_AnalogAudio_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_AnalogAudio_DataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('AnalogAudioEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==5) {
					_tx = Encode_Rs232_DataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=switch ' + _tx + ':RS232:1 ' + Decode_Rs232_DataArr[DecoderChannelNum-1][1] + ':RS232:1';			
						_rx = Decode_Rs232_DataArr[DecoderChannelNum-1][1];
						//_tx = Encode_Rs232_DataArr[DecoderToChangePositionAfterNum][1];
						$('.IPAV1100Rs232RxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < Encode_Rs232_DataArr.length; i++) {
			                if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
			                    if (Decode_Rs232_DataArr[DecoderChannelNum-1][2]==Encode_Rs232_DataArr[i][4]) {
			                        $('.IPAV1100Rs232TxCont li:eq(' + i + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_Rs232_DataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_Rs232_DataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} 
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {							
						if (1) {
							data='data=switch ' + _tx + ':RS232:1 all:RS232:1';
							_rx = 0;
							//_tx = Encode_Rs232_DataArr[DecoderToChangePositionAfterNum][1];
							var _numArr = _data.Rs232_De_En_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
									$('.IPAV1100Rs232RxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#Rs232GroupTxSelectBox li').each(function(e){
									if ($('#Rs232GroupSelectTx span').html()==$('#Rs232GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#Rs232GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_Rs232_DataArr.length; j++) {
				                    				if (Decode_Rs232_DataArr[j]!=''&&typeof(Decode_Rs232_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_Rs232_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_Rs232_DataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}	
				else if (current_page==6) {
					_tx = Encode_Infrared_DataArr[DecoderToChangePositionAfterNum][1];
					if (DecoderChannelNum!=0) {
						data='data=switch ' + _tx + ':INFRARED:0 ' + Decode_Infrared_DataArr[DecoderChannelNum-1][1] + ':INFRARED:0';			
						_rx = Decode_Infrared_DataArr[DecoderChannelNum-1][1];
						//_tx = Encode_Infrared_DataArr[DecoderToChangePositionAfterNum][1];
						$('.IPAV1100InfraredRxCont li:eq('+DecoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						for (var i = 0; i < Encode_Infrared_DataArr.length; i++) {
			                if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
			                    if (Decode_Infrared_DataArr[DecoderChannelNum-1][2]==Encode_Infrared_DataArr[i][4]) {
			                        $('.IPAV1100InfraredTxCont li:eq(' + (i ) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_Infrared_DataArr[DecoderChannelNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_Infrared_DataArr[DecoderChannelNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}                   		
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {							
						if (1) {
							data='data=switch ' + _tx + ':INFRARED:0 all:INFRARED:0';
							_rx = 0;
							//_tx = Encode_Infrared_DataArr[DecoderToChangePositionAfterNum][1];
							var _numArr = _data.Rs232_De_En_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
									$('.IPAV1100InfraredRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#InfraredGroupTxSelectBox li').each(function(e){
									if ($('#InfraredGroupSelectTx span').html()==$('#InfraredGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#InfraredGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_Infrared_DataArr.length; j++) {
				                    				if (Decode_Infrared_DataArr[j]!=''&&typeof(Decode_Infrared_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_Infrared_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_Infrared_DataArr[DecoderChannelNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}		
				sendCommand(data);
				MouseUpOrDown=0;
				MouseoverRx=0;
				SystemLogWriteToFile(_rx,_tx);
			}
		}
		if (backMouseUpOrDown==1) {
			if (backMouseoverRx==1) {
				$('.IPAV1100RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100TxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100VideoWallRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100VideoWallTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    //$('.IPAV1100Rs232RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100Rs232TxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100Rs232RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');

			    $('.IPAV1100InfraredTxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
			    $('.IPAV1100InfraredRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
				var data;			
				
				var _id;
				var _linkDevice;
				if (current_page==1) {
					_tx = EncodeVideoDataArr[EncoderChannelNum][1];
					$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100TxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=join ' + _tx + ':HDMI:0 ' + DecodeVideoDataArr[DecoderToChangePositionAfterNum-1][1] + ':HDMI:0';			
						_rx = DecodeVideoDataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = EncodeVideoDataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < DecodeVideoDataArr.length; i++) {
			                if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
			                    if (DecodeVideoDataArr[i][5]==EncodeVideoDataArr[EncoderChannelNum][4]) {
			                        $('.IPAV1100RxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=VideoEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + DecodeVideoDataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} else {
			                    			_rstArr[15] = _rstArr[15].replace(DecodeVideoDataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}  
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('VideoEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':HDMI:0 all_rx:HDMI:0';
							_rx = 0;
							//_tx = EncodeVideoDataArr[EncoderChannelNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
									$('.IPAV1100RxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#GroupTxSelectBox li').each(function(e){
									if ($('#VideoGroupSelectTx span').html()==$('#GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=VideoEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < DecodeVideoDataArr.length; j++) {
				                    				if (DecodeVideoDataArr[j]!=''&&typeof(DecodeVideoDataArr[j])!='undefined') {
				                    					_rstArr[15] += DecodeVideoDataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}else {
				                    			//_rstArr[15] = _rstArr[15].replace(DecodeVideoDataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                     		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('VideoEncode_'+_id,_rst.toString());
				                } 
				            });
						}
							
					}
					
				}
				else if (current_page==2) {
					_tx = EncodeVideoWallDataArr[EncoderChannelNum][1];
					$('.IPAV1100VideoWallTxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=join ' + _tx + ':HDMI:0 ' + DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1][1] + ':HDMI:0';			
						_rx = DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = EncodeVideoWallDataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < DecodeVideoWallDataArr.length; i++) {
			                if (DecodeVideoWallDataArr[i]!=''&&typeof(DecodeVideoWallDataArr[i])!='undefined') {
			                    if (DecodeVideoWallDataArr[i][5]==EncodeVideoWallDataArr[EncoderChannelNum][4]) {
			                        $('.IPAV1100VideoWallRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=VideoWallEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} 
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('VideoWallEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (0) {
							data='data=join ' + _tx + ':HDMI:0 all_rx:HDMI:0';
							_rx = 0;
							//_tx = EncodeVideoWallDataArr[EncoderChannelNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (DecodeVideoWallDataArr[i]!=''&&typeof(DecodeVideoWallDataArr[i])!='undefined') {
									$('.IPAV1100VideoWallRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#VideoWallGroupTxSelectBox li').each(function(e){
									if ($('#VideoWallGroupSelectTx span').html()==$('#VideoWallGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#VideoWallGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=VideoWallEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < DecodeVideoWallDataArr.length; j++) {
				                    				if (DecodeVideoWallDataArr[j]!=''&&typeof(DecodeVideoWallDataArr[j])!='undefined') {
				                    					_rstArr[15] += DecodeVideoWallDataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('VideoWallEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==3) {
					_tx = Encode_HdmiAudio_DataArr[EncoderChannelNum][1];
					$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100HdmiAudioTxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=join ' + _tx + ':HDMI_AUDIO:0 ' + Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1][1] + ':HDMI_AUDIO:0';			
						_rx = Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = Encode_HdmiAudio_DataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < Decode_HdmiAudio_DataArr.length; i++) {
			                if (Decode_HdmiAudio_DataArr[i]!=''&&typeof(Decode_HdmiAudio_DataArr[i])!='undefined') {
			                    if (Decode_HdmiAudio_DataArr[i][5]==Encode_HdmiAudio_DataArr[EncoderChannelNum][4]) {
			                        $('.IPAV1100HdmiAudioRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=HdmiAudioEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} 
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('HdmiAudioEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':HDMI_AUDIO:0 all_rx:HDMI_AUDIO:0';
							_rx = 0;
							//_tx = Encode_HdmiAudio_DataArr[EncoderChannelNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_HdmiAudio_DataArr[i]!=''&&typeof(Decode_HdmiAudio_DataArr[i])!='undefined') {
									$('.IPAV1100HdmiAudioRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#HdmiAudioGroupTxSelectBox li').each(function(e){
									if ($('#HdmiAudioGroupSelectTx span').html()==$('#HdmiAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#HdmiAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=HdmiAudioEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_HdmiAudio_DataArr.length; j++) {
				                    				if (Decode_HdmiAudio_DataArr[j]!=''&&typeof(Decode_HdmiAudio_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_HdmiAudio_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			//_rstArr[15] = _rstArr[15].replace(Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('HdmiAudioEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==4) {
					_tx = Encode_AnalogAudio_DataArr[EncoderChannelNum][1];
					$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100AnalogAudioTxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=join ' + _tx + ':AUDIO:0 ' + Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1][1] + ':AUDIO:0';			
						_rx = Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = Encode_AnalogAudio_DataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < Decode_AnalogAudio_DataArr.length; i++) {
			                if (Decode_AnalogAudio_DataArr[i]!=''&&typeof(Decode_AnalogAudio_DataArr[i])!='undefined') {
			                    if (Decode_AnalogAudio_DataArr[i][5]==Encode_AnalogAudio_DataArr[EncoderChannelNum][4]) {
			                        $('.IPAV1100AnalogAudioRxCont li:eq(' + (i + 1) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=AnalogAudioEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} 
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('AnalogAudioEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=join ' + _tx + ':AUDIO:0 all_rx:AUDIO:0';
							_rx = 0;
							//_tx = Encode_AnalogAudio_DataArr[EncoderChannelNum][1];
							var _numArr = _data.videoswitching_decode_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_AnalogAudio_DataArr[i]!=''&&typeof(Decode_AnalogAudio_DataArr[i])!='undefined') {
									$('.IPAV1100AnalogAudioRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#AnalogAudioGroupTxSelectBox li').each(function(e){
									if ($('#AnalogAudioGroupSelectTx span').html()==$('#AnalogAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#AnalogAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=AnalogAudioEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_AnalogAudio_DataArr.length; j++) {
				                    				if (Decode_AnalogAudio_DataArr[j]!=''&&typeof(Decode_AnalogAudio_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_AnalogAudio_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}else {
				                    			//_rstArr[15] = _rstArr[15].replace(Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                     		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('AnalogAudioEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}
				else if (current_page==5) {
					_tx = Encode_Rs232_DataArr[EncoderChannelNum][1];
					$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100Rs232TxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=switch ' + _tx + ':RS232:1 ' + Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][1] + ':RS232:1';			
						_rx = Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = Encode_Rs232_DataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < Encode_Rs232_DataArr.length; i++) {
			                if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
			                    if (Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][2]==Encode_Rs232_DataArr[i][4]) {
			                        $('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}                    		
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=switch ' + _tx + ':RS232:1 all:RS232:1';
							_rx = 0;
							//_tx = Encode_Rs232_DataArr[EncoderChannelNum][1];
							var _numArr = _data.Rs232_De_En_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
									$('.IPAV1100Rs232RxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#Rs232GroupTxSelectBox li').each(function(e){
									if ($('#Rs232GroupSelectTx span').html()==$('#Rs232GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#Rs232GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_Rs232_DataArr.length; j++) {
				                    				if (Decode_Rs232_DataArr[j]!=''&&typeof(Decode_Rs232_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_Rs232_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                   		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
					
				}	
				else if (current_page==6) {
					_tx = Encode_Infrared_DataArr[EncoderChannelNum][1];
					$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					$('.IPAV1100InfraredTxCont li:eq('+EncoderChannelNum+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
					if (DecoderToChangePositionAfterNum!=0) {
						data='data=switch ' + _tx + ':INFRARED:0 ' + Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][1] + ':INFRARED:0';			
						_rx = Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][1];
						//_tx = Encode_Infrared_DataArr[EncoderChannelNum][1];
						
						for (var i = 0; i < Encode_Infrared_DataArr.length; i++) {
			                if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
			                    if (Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][2]==Encode_Infrared_DataArr[i][4]) {
			                        $('.IPAV1100InfraredTxCont li:eq(' + (i ) + ') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
			                    }                    
			                }
			            }
			            if (1) {
							_id = 'Default';
						}
						$.ajax({
			                type: 'POST',
			                url: 'common/GroupSaveSetting.php',
			                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
			                datatype: 'json',
			                async: true,
			                success: function(rst) {
			                    var _rst = rst.split(',');
			                    for (var i = 0; i < _rst.length; i++) {
			                    	if (_rst[i]!='') {
			                    		var _rstArr = _rst[i].split(':');
			                    		if (_tx==_rstArr[2]) {
			                    			_rstArr[15] += '|' + Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][1];
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		} else {
			                    			_rstArr[15] = _rstArr[15].replace(Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][1],'');
			                    			
			                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
			                    		}                    		
			                    	}
			                    }
			                    GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
			                } 
			            });
					}
					else {
						if (1) {
							data='data=switch ' + _tx + ':INFRARED:0 allINFRARED:0';
							_rx = 0;
							//_tx = Encode_Infrared_DataArr[EncoderChannelNum][1];
							var _numArr = _data.Rs232_De_En_arr.split(',');
							for (var i = 0; i < _numArr.length; i++) {
								if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
									$('.IPAV1100InfraredRxCont li:eq('+(i+1)+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
								}
							}
							if (1) {
								_id = 'Default';
							}
							else {				
								$('#InfraredGroupTxSelectBox li').each(function(e){
									if ($('#InfraredGroupSelectTx span').html()==$('#InfraredGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
										_id = $('#InfraredGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
									}
								});
							}
							$.ajax({
				                type: 'POST',
				                url: 'common/GroupSaveSetting.php',
				                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
				                datatype: 'json',
				                async: true,
				                success: function(rst) {
				                    var _rst = rst.split(',');
				                    for (var i = 0; i < _rst.length; i++) {
				                    	if (_rst[i]!='') {
				                    		var _rstArr = _rst[i].split(':');
				                    		if (_tx==_rstArr[2]) {
				                    			_rstArr[15] = '';
				                    			for (var j = 0; j < Decode_Infrared_DataArr.length; j++) {
				                    				if (Decode_Infrared_DataArr[j]!=''&&typeof(Decode_Infrared_DataArr[j])!='undefined') {
				                    					_rstArr[15] += Decode_Infrared_DataArr[j][1] + '|';
				                    				}
				                    			}
				                    			_rstArr[15] = _rstArr[15].substr(0,_rstArr[15].length-1);
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		} else {
				                    			// _rstArr[15] = _rstArr[15].replace(Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1][1],'');
				                    			_rstArr[15] = '';
				                    			_rst[i] = _rstArr.toString().replace(/,/g,':');
				                    		}                    		
				                    	}
				                    }
				                    GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
				                } 
				            });
						}
					}
				}		
				sendCommand(data);
				backMouseUpOrDown=0;
				backMouseoverRx=0;
				SystemLogWriteToFile(_rx,_tx);
			}
		}
		MouseUpOrDown = 0;
		backMouseUpOrDown = 0;
	});
	$('body').on('mousemove',function(e){
		if (VideoEncoderToChangePosition==1) {
			if (MouseUpOrDown==1){
				if (e.pageX<(parseInt($('.IPAV1100Content').width())-215)) {
					$('.DeviceClickToMove').css('left',(e.pageX)+'px');			
				}
				if (e.pageY<=(parseInt($('.IPAV1100Content').height())-130)) {
					$('.DeviceClickToMove').css('top',(e.pageY)+'px');					
				}
				else {
					$('.DeviceClickToMove').css('top',(parseInt($('.IPAV1100Content').height())-130)+'px');	
				}
			}
		}
		if (VideoDecoderToChangePosition==1) {
			if (backMouseUpOrDown==1){
				if (e.pageX<=(parseInt($('.IPAV1100Content').width())-215)) {
					$('.DeviceClickToMove').css('left',(e.pageX)+'px');				
				}
				if (e.pageY<=(parseInt($('.IPAV1100Content').height())-130)) {
					$('.DeviceClickToMove').css('top',(e.pageY)+'px');
					clearInterval(TxDeviceAutomateScroll);
					//console.log(1);
				}
				else {
					//console.log(2);
					$('.DeviceClickToMove').css('top',(parseInt($('.IPAV1100Content').height())-130)+'px');	
					clearInterval(TxDeviceAutomateScroll);
					TxDeviceAutomateScroll = setInterval(function(){
						if (current_page==1) {
							var _top = -(parseInt($('.IPAV1100TxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							//console.log(_IPAV1100TxContDisplayH);
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100TxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}
							_top = -(parseInt($('.IPAV1100TxCont').css('top')));
							$('.VideoTxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.VideoTxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.VideoTxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.VideoTxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
						else if (current_page==2) {
							var _top = -(parseInt($('.IPAV1100VideoWallTxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100VideoWallTxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100VideoWallTxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}		
							
							_top = -(parseInt($('.IPAV1100VideoWallTxCont').css('top')));
							$('.VideoWallTxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.VideoWallTxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.VideoWallTxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.VideoWallTxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
						else if (current_page==3) {
							var _top = -(parseInt($('.IPAV1100HdmiAudioTxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100HdmiAudioTxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}		
							
							
							_top = -(parseInt($('.IPAV1100HdmiAudioTxCont').css('top')));
							$('.HdmiAudioTxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.HdmiAudioTxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.HdmiAudioTxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.HdmiAudioTxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
						else if (current_page==4) {
							var _top = -(parseInt($('.IPAV1100AnalogAudioTxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100AnalogAudioTxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}		
							
							
							_top = -(parseInt($('.IPAV1100AnalogAudioTxCont').css('top')));
							$('.AnalogAudioTxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.AnalogAudioTxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.AnalogAudioTxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.AnalogAudioTxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
						else if (current_page==5) {
							var _top = -(parseInt($('.IPAV1100Rs232TxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100Rs232TxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}		
							
							
							_top = -(parseInt($('.IPAV1100Rs232TxCont').css('top')));
							$('.Rs232TxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.Rs232TxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.Rs232TxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.Rs232TxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
						else if (current_page==6) {
							var _top = -(parseInt($('.IPAV1100InfraredTxCont').css('top')));
							var _IPAV1100TxCont = $('.IPAV1100TxContScrool').height();
							var _IPAV1100TxContDisplayH = parseInt((_IPAV1100TxCont+12)/120)*120;
							
							if (_top<_IPAV1100TxContDisplayH*2) {			
								$('.IPAV1100InfraredTxCont').css('top',-(_top+_IPAV1100TxContDisplayH)+'px');
							}		
							
							
							_top = -(parseInt($('.IPAV1100InfraredTxCont').css('top')));
							$('.InfraredTxDeviceScrollCont li').removeClass('VideoScrollRxClick');
							if (_top==0) {
								$('.InfraredTxDeviceScrollCont li:eq(0)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH) {
								$('.InfraredTxDeviceScrollCont li:eq(1)').addClass('VideoScrollRxClick');
							}
							else if (_top==_IPAV1100TxContDisplayH*2) {
								$('.InfraredTxDeviceScrollCont li:eq(2)').addClass('VideoScrollRxClick');
							}
						}
					},2000);
				}
				
				
				if (backMouseoverRx==1){
					
				}
			}
		}
			
	});
	// drop event end -----------------------------------------
	$('.DeviceDecoderConfigurationLeft li').each(function(e){
		$(this).on('mouseover',function(){
			$(this).css('background-color','#6797b8');
			$('.DeviceDecoderConfigurationLeft li:eq('+e+') .DeviceDecoderConfigurationLeftFlag').css('background-color','#006eb8');
		});
		$(this).on('mouseleave',function(){
			$(this).css('background-color','#23272d');
			$('.DeviceDecoderConfigurationLeft li:eq('+e+') .DeviceDecoderConfigurationLeftFlag').css('background-color','#23272d');
			if (e>8) {
				$(this).css('background-color','#6797b8');
				$('#DeviceSendReceiveRs232 .DeviceDecoderConfigurationLeftFlag').css('background-color','#006eb8');	
			}						
		});
	});	
	$('#DeviceDecoderConfigurationClose').on('click',function(){
		$('#DeviceRxConfigurationBox').hide();
		_ReceiveCheckType = 0;
		_SendingCheckType=0;
	});
	$('#DeviceEncoderConfigurationClose').on('click',function(){
		$('#DeviceTxConfigurationBox').hide();
		_ReceiveCheckType = 0;
		_SendingCheckType=0;
	});
	$('#DeviceSendReceiveRs232Close').on('click',function(){
		$('#DeviceSendReceiveRs232').hide();
		$.ajax({
		    type: 'POST',
		    url: 'common/readfile.php',
		    data: "rs232CloseSocket=1",
		    datatype: 'json',
		    async: true,
		    success: function(rst) {
		      	
		    }
		});
		clearInterval(checkRs232GetDataTimer);
	});
	$('#DeviceSendReceiveInfraredClose').on('click',function(){
		$('#DeviceSendReceiveInfrared').hide();
		$.ajax({
		    type: 'POST',
		    url: 'common/readfile.php',
		    data: "infraredCloseSocket=1",
		    datatype: 'json',
		    async: true,
		    success: function(rst) {
		      	
		    }
		});		
		clearInterval(checkInfraredGetDataTimer);
	});
	$('#DeviceFactoryResetClose').on('click',function(){
		$('#DeviceFactoryReset').hide();
	});
	$('#DeviceFactoryResetNoBtn').on('click',function(){
		$('#DeviceFactoryReset').hide();
	});
	$('#DeviceRebootClose').on('click',function(){
		$('#DeviceReboot').hide();
	});
	$('#DeviceRebootNoBtn').on('click',function(){
		$('#DeviceReboot').hide();
	});
	$('.DeviceDecoderConfigurationScrollSlider').on('mousedown',function(e){
		$('.DeviceDecoderConfigurationBgZhezhao').css('z-index','20');
		decoderConfigurationSlider = 1;
		decoderConfigurationSliderPageY = e.pageY;
		decoderConfigurationSliderTop = parseInt($('.DeviceDecoderConfigurationScrollSlider').css('top'));
		decoderConfigurationContTop = parseInt($('.DeviceDecoderConfigurationRightC').css('top'));
	});
	$('.DeviceEncoderConfigurationScrollSlider').on('mousedown',function(e){
		$('.DeviceDecoderConfigurationBgZhezhao').css('z-index','20');
		decoderConfigurationSlider = 1;
		decoderConfigurationSliderPageY = e.pageY;
		decoderConfigurationSliderTop = parseInt($('.DeviceEncoderConfigurationScrollSlider').css('top'));
		decoderConfigurationContTop = parseInt($('.DeviceEncoderConfigurationRightC').css('top'));
	});
	$(window).on('mouseup',function(){
		$('.DeviceDecoderConfigurationBgZhezhao').css('z-index','0');
		decoderConfigurationSlider = 0;
		clearInterval(TxDeviceAutomateScroll);
	});
	$(window).on('mousemove',function(e){
		if (current_page==5||current_page==6) {
			if (_ReceiveCheckType!=1&&_SendingCheckType!=1) return;
		}else{
			if (DecoderOrEncoder!=1) return;
		}
		
		if (decoderConfigurationSlider==1&&parseInt($('.DeviceDecoderConfigurationScrollSlider').css('top'))<=250&&parseInt($('.DeviceDecoderConfigurationScrollSlider').css('top'))>=0) {
			document.getSelection ? document.getSelection().removeAllRanges() : window.selection.empty();
			if (e.pageY>decoderConfigurationSliderPageY) {
				var _top = e.pageY-decoderConfigurationSliderPageY;
				if (parseInt(_top+decoderConfigurationSliderTop)>250){
					$('.DeviceDecoderConfigurationScrollSlider').css('top','250px');	
					$('.DeviceDecoderConfigurationRightC').css('top',-($('.DeviceDecoderConfigurationRightC').height()-435)+'px');					
				}
				else{
					$('.DeviceDecoderConfigurationScrollSlider').css('top',(_top+decoderConfigurationSliderTop)+'px');
					var _configurationPos = parseInt(_top*($('.DeviceDecoderConfigurationRightC').height()-435)/250);
					$('.DeviceDecoderConfigurationRightC').css('top',(decoderConfigurationContTop-_configurationPos)+'px');
				}
			}
			if (e.pageY<decoderConfigurationSliderPageY) {
				var _top = decoderConfigurationSliderPageY-e.pageY;
				if (parseInt(decoderConfigurationSliderTop-_top)<0) {
					$('.DeviceDecoderConfigurationScrollSlider').css('top','0px');
					$('.DeviceDecoderConfigurationRightC').css('top','0px');
				}					
				else {
					$('.DeviceDecoderConfigurationScrollSlider').css('top',(decoderConfigurationSliderTop-_top)+'px');
					var _configurationPos = parseInt(_top*($('.DeviceDecoderConfigurationRightC').height()-435)/250);
					$('.DeviceDecoderConfigurationRightC').css('top',(decoderConfigurationContTop+_configurationPos)+'px');
				}
			}
		}
		
	});
	$(window).on('mousemove',function(e){
		if (current_page==5||current_page==6) {
			if (_ReceiveCheckType!=2&&_SendingCheckType!=2) return;
		}else{
			if (DecoderOrEncoder!=2) return;	
		}
			
		if (decoderConfigurationSlider==1&&parseInt($('.DeviceEncoderConfigurationScrollSlider').css('top'))<=250&&parseInt($('.DeviceEncoderConfigurationScrollSlider').css('top'))>=0) {
			document.getSelection ? document.getSelection().removeAllRanges() : window.selection.empty();
			if (e.pageY>decoderConfigurationSliderPageY) {
				var _top = e.pageY-decoderConfigurationSliderPageY;
				if (parseInt(_top+decoderConfigurationSliderTop)>250){
					$('.DeviceEncoderConfigurationScrollSlider').css('top','250px');	
					$('.DeviceEncoderConfigurationRightC').css('top',-($('.DeviceEncoderConfigurationRightC').height()-435)+'px');					
				}
				else{
					$('.DeviceEncoderConfigurationScrollSlider').css('top',(_top+decoderConfigurationSliderTop)+'px');
					var _configurationPos = parseInt(_top*($('.DeviceEncoderConfigurationRightC').height()-435)/250);
					$('.DeviceEncoderConfigurationRightC').css('top',(decoderConfigurationContTop-_configurationPos)+'px');
				}
			}
			if (e.pageY<decoderConfigurationSliderPageY) {
				var _top = decoderConfigurationSliderPageY-e.pageY;
				if (parseInt(decoderConfigurationSliderTop-_top)<0) {
					$('.DeviceEncoderConfigurationScrollSlider').css('top','0px');
					$('.DeviceEncoderConfigurationRightC').css('top','0px');
				}					
				else {
					$('.DeviceEncoderConfigurationScrollSlider').css('top',(decoderConfigurationSliderTop-_top)+'px');
					var _configurationPos = parseInt(_top*($('.DeviceEncoderConfigurationRightC').height()-435)/250);
					$('.DeviceEncoderConfigurationRightC').css('top',(decoderConfigurationContTop+_configurationPos)+'px');
				}
			}
		}

	});
	// device display  settingbox -------------------------------------------
	$('#VideoDecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceRxConfigurationBox').show();
	});
	$('#VideoEncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceTxConfigurationBox').show();
		$('#DisplayEdidNavReflash').click();
	});
	$('#VideoWallDecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceRxConfigurationBox').show();
	});
	$('#VideoWallEncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceTxConfigurationBox').show();
		$('#DisplayEdidNavReflash').click();
	});
	$('#HdmiAudioDecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceRxConfigurationBox').show();
	});
	$('#HdmiAudioEncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceTxConfigurationBox').show();
		$('#DisplayEdidNavReflash').click();
	});
	$('#AnalogAudioDecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceRxConfigurationBox').show();
	});
	$('#AnalogAudioEncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceTxConfigurationBox').show();
		$('#DisplayEdidNavReflash').click();
	});
	$('#Rs232DecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		if (Decode_Rs232_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
			$('#DeviceRxConfigurationBox').show();
			_ReceiveCheckType =1;
		}
		else {
			_ReceiveCheckType =2;
			$('#DeviceTxConfigurationBox').show();
			$('#DisplayEdidNavReflash').click();
		}
		
	});
	$('#Rs232EncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;		
		if (Encode_Rs232_DataArr[EncoderConfigurationDeviceNumb][12]) {
			$('#DeviceRxConfigurationBox').show();
			_SendingCheckType = 1;
		}
		else {
			 _SendingCheckType = 2;
			$('#DeviceTxConfigurationBox').show();
			$('#DisplayEdidNavReflash').click();
		}		
	});
	$('#InfraredDecoderSettingConfiguration').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		if (Decode_Infrared_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
			$('#DeviceRxConfigurationBox').show();
			_ReceiveCheckType =1;
		}
		else {
			_ReceiveCheckType =2;
			$('#DeviceTxConfigurationBox').show();
		}
		
	});
	$('#InfraredEncoderSettingConfiguration').on('click',function(){
		DecoderOrEncoder = 2;		
		if (Encode_Infrared_DataArr[EncoderConfigurationDeviceNumb][12]) {
			$('#DeviceRxConfigurationBox').show();
			_SendingCheckType = 1;
		}
		else {
			_SendingCheckType = 2;
			$('#DeviceTxConfigurationBox').show();
		}		
	});
	// decoder点击弹窗显示-------------------------------
	$('#VideoSendReceiveRS232').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceSendReceiveRs232').show();
		loadingDeviceIDRs232();
	});
	$('#VideoSendReceiveIR').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		DecoderOrEncoder = 1;
		$('#DeviceSendReceiveInfrared').show();
		loadingDeviceIDInfrared();
	});
	$('#VideoFactoryReset').on('click',function(){
		DecoderOrEncoder = 1;
		$('#DeviceFactoryReset').show();
	});
	$('#VideoReboot').on('click',function(){
		DecoderOrEncoder = 1;
		$('#DeviceReboot').show();
	});
	// encoder点击弹窗显示------------------------------
	$('#VideoSendReceiveRS232Tx').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceSendReceiveRs232').show();
		loadingDeviceIDRs232();
	});
	$('#VideoSendReceiveIRTx').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceSendReceiveInfrared').show();
		loadingDeviceIDInfrared();
	});
	$('#VideoFactoryResetTx').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceFactoryReset').show();
	});
	$('#VideoRebootTx').on('click',function(){
		DecoderOrEncoder = 2;
		$('#DeviceReboot').show();
	});
	// DecoderConfiguration navigation click 
	$('#DeviceDecoderConfigurationAnalogAudioOutput').on('click',function(){
		$('.DeviceDecoderConfigurationRightC').css('top','0px');
		$('.DeviceDecoderConfigurationScrollSlider').css('top','0px');
	});
	$('#DeviceDecoderConfigurationHDMIAudioOutput').on('click',function(){
		$('.DeviceDecoderConfigurationRightC').css('top','-77px');
		$('.DeviceDecoderConfigurationScrollSlider').css('top','74px');
	});
	$('#DeviceDecoderConfigurationDisplayEDID').on('click',function(){
		$('.DeviceDecoderConfigurationRightC').css('top','-206px');
		$('.DeviceDecoderConfigurationScrollSlider').css('top','195px');
	});
	$('#DeviceDecoderConfigurationNetworkSetting').on('click',function(){
		$('.DeviceDecoderConfigurationRightC').css('top','-265px');
		$('.DeviceDecoderConfigurationScrollSlider').css('top','250px');
	});
	$('#DeviceDecoderConfigurationRS232').on('click',function(){
		$('.DeviceDecoderConfigurationRightC').css('top','-265px');
		$('.DeviceDecoderConfigurationScrollSlider').css('top','250px');
	});
	// DecoderConfiguration navigation click 
	$('#DeviceEncoderConfigurationInput').on('click',function(){
		$('.DeviceEncoderConfigurationRightC').css('top','0px');
		$('.DeviceEncoderConfigurationScrollSlider').css('top','0px');
	});
	$('#DeviceEncoderConfigurationDisplayEDID').on('click',function(){
		$('.DeviceEncoderConfigurationRightC').css('top','-77px');
		$('.DeviceEncoderConfigurationScrollSlider').css('top','161px');
	});
	$('#DeviceEncoderConfigurationNetworkSetting').on('click',function(){
		$('.DeviceEncoderConfigurationRightC').css('top','-119px');
		$('.DeviceEncoderConfigurationScrollSlider').css('top','250px');
		
	});
	$('#DeviceEncoderConfigurationRS232').on('click',function(){
		$('.DeviceEncoderConfigurationRightC').css('top','-119px');
		$('.DeviceEncoderConfigurationScrollSlider').css('top','250px');
	});
	
	// decoder configuration setting ------------------------------
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco').each(function(e){
		$(this).on('click',function(){
			if (e<2) {
				for (var i = 0; i < 2; i++) {
					(function(ii){
						$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq('+ii+')').attr('src','images/SettingRadioOff.png');
					})(i);
				}
				$(this).attr('src','images/SettingRadioOn.png');
			}
			if (e>=2&&e<=5) {
				for (var i = 2; i < 6; i++) {
					(function(ii){
						$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq('+ii+')').attr('src','images/SettingRadioOff.png');
					})(i);
				}
				$(this).attr('src','images/SettingRadioOn.png');
			}
		});
	});
	// pin to this position
	$('#VideoRxPinToThisPosition').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) return;
		var _deviceNum=DecoderConfigurationDeviceNumb;
		var _jsonPositionData;
		
		$.ajax({
		    type: 'POST',
		    url: 'common/readfile.php',
		    data: 'PositionInfoFromFile=1',
		    datatype: 'json',
		    async: true,
		    success: function(rst) {
		    	var _arr = _data.videoswitching_decode_arr.split(',');
				_jsonPositionData = rst;
				var _jsonPositionDataArr = _jsonPositionData.split(',');
		    	if (1) {
		    		if ($('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) {
		    			$('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').removeClass('DeviceBoxPositionLocked');
		    			if (_jsonPositionData!='') {        		
				        	var _jsonPositionDataTmp='';
				        	if (_jsonPositionData.indexOf(_arr[_deviceNum-1])>=0) {
				        		for (var i = 0; i < _jsonPositionDataArr.length; i++) {
					        		var _jsonPositionDataArrTmp = _jsonPositionDataArr[i].split(':');
					        		if (_jsonPositionDataArrTmp[0]==_arr[_deviceNum-1]) {
					        			_jsonPositionDataArr[i] = _jsonPositionDataArrTmp[0]+':N';	        				
					        		}
					        	}
					        	_jsonPositionData='';
					        	for (var i = 0; i < _jsonPositionDataArr.length; i++) {
						        	_jsonPositionData += _jsonPositionDataArr[i] + ',';
						        }
						        _jsonPositionData = _jsonPositionData.substr(0,_jsonPositionData.length-1);
				        	}else{
				        		_jsonPositionData += ',' + _arr[_deviceNum-1]+':N';
				        	}
				        }else{
				        	_jsonPositionData = _arr[_deviceNum-1]+':N';
				        }
		    		}
		    		else {		
		    			$('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').addClass('DeviceBoxPositionLocked');		        
				        if (_jsonPositionData!='') {        		
				        	var _jsonPositionDataTmp='';
				        	if (_jsonPositionData.indexOf(_arr[_deviceNum-1])>=0) {
				        		for (var i = 0; i < _jsonPositionDataArr.length; i++) {
					        		var _jsonPositionDataArrTmp = _jsonPositionDataArr[i].split(':');
					        		if (_jsonPositionDataArrTmp[0]==_arr[_deviceNum-1]) {
					        			_jsonPositionDataArrTmp[1] = _deviceNum;
					        			_jsonPositionDataArr[i] = _jsonPositionDataArrTmp[0]+':'+_jsonPositionDataArrTmp[1];	        				
					        		}
					        	}
					        	_jsonPositionData='';
					        	for (var i = 0; i < _jsonPositionDataArr.length; i++) {
						        	_jsonPositionData += _jsonPositionDataArr[i] + ',';
						        }
						        _jsonPositionData = _jsonPositionData.substr(0,_jsonPositionData.length-1);
				        	}else{
				        		_jsonPositionData += ',' + _arr[_deviceNum-1]+':'+_deviceNum;
				        	}
				        }else{
				        	_jsonPositionData = _arr[_deviceNum-1]+':'+_deviceNum;
				        }
		    		}
			    	ReadDataFromFile('PositionInfoSetFile=1&PositionInfoData='+_jsonPositionData);
			    	// console.log(_jsonPositionData);
		    	}
			    else {
			    	//DecodeGroupDataListArr
			    	if ($('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) {
		    			$('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').removeClass('DeviceBoxPositionLocked');
		    			for (var i = 0; i < DecodeGroupDataListArr.length; i++) {
				    		if ((_deviceNum-1)==i) {
				    			var _DecodeGroupDataListArrTmp = DecodeGroupDataListArr[i].split(':');
				    			_DecodeGroupDataListArrTmp[1] = _deviceNum;
				    			DecodeGroupDataListArr[i] = _DecodeGroupDataListArrTmp[0]+':N';
				    			PinPositionSaveToFile(_DecodeGroupDataListArrTmp[0],DecodeGroupDataListArr[i].replace(/:/g,'_'),'VideoDecode_'+$('#GroupRxSelectBox li:eq('+DeviceGroupRxSelectNum+') span:eq(1)').html());
				    			break;
				    		}
				    	}
				    	var _temp='';
				    	for (var i = 0; i < DecodeGroupDataListArr.length; i++) {
				    		_temp+=DecodeGroupDataListArr[i]+',';
				    	}
				    	_temp = _temp.substr(0,_temp.length-1);
		    		}
		    		else {
		    			$('.IPAV1100RxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').addClass('DeviceBoxPositionLocked');
		    			for (var i = 0; i < DecodeGroupDataListArr.length; i++) {
				    		if ((_deviceNum-1)==i) {
				    			var _DecodeGroupDataListArrTmp = DecodeGroupDataListArr[i].split(':');
				    			_DecodeGroupDataListArrTmp[1] = _deviceNum;
				    			DecodeGroupDataListArr[i] = _DecodeGroupDataListArrTmp[0]+':'+_DecodeGroupDataListArrTmp[1];
				    			PinPositionSaveToFile(_DecodeGroupDataListArrTmp[0],DecodeGroupDataListArr[i].replace(/:/g,'_'),'VideoDecode_'+$('#GroupRxSelectBox li:eq('+DeviceGroupRxSelectNum+') span:eq(1)').html());
				    			break;
				    		}
				    	}
				    	var _temp='';
				    	for (var i = 0; i < DecodeGroupDataListArr.length; i++) {
				    		_temp+=DecodeGroupDataListArr[i]+',';
				    	}
				    	_temp = _temp.substr(0,_temp.length-1);
				    	
		    		}
				    PageAddGroup('type=9&id='+$('#GroupRxSelectBox li:eq('+DeviceGroupRxSelectNum+') span:eq(1)').html()+'&deviceMAC='+_temp);
				   	// console.log(_temp);
			    }
		    }
		});
	});
	$('#VideoTxPinToThisPosition').on('click',function(){
		var _deviceNum=EncoderConfigurationDeviceNumb;
		var _jsonPositionData;
		
		$.ajax({
		    type: 'POST',
		    url: 'common/readfile.php',
		    data: 'PositionInfoFromFile=2',
		    datatype: 'json',
		    async: true,
		    success: function(rst) {
		    	var _arr = _data.videoswitching_encode_arr.split(',');
				_jsonPositionData = rst;
				var _jsonPositionDataArr = _jsonPositionData.split(',');
		    	if (1) {
		    		if ($('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) {
		    			$('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').removeClass('DeviceBoxPositionLocked');
		    			if (_jsonPositionData!='') {        		
				        	var _jsonPositionDataTmp='';
				        	if (_jsonPositionData.indexOf(_arr[_deviceNum])>=0) {
				        		for (var i = 0; i < _jsonPositionDataArr.length; i++) {
					        		var _jsonPositionDataArrTmp = _jsonPositionDataArr[i].split(':');
					        		if (_jsonPositionDataArrTmp[0]==_arr[_deviceNum]) {
					        			_jsonPositionDataArr[i] = _jsonPositionDataArrTmp[0]+':N';	        				
					        		}
					        	}
					        	_jsonPositionData='';
					        	for (var i = 0; i < _jsonPositionDataArr.length; i++) {
						        	_jsonPositionData += _jsonPositionDataArr[i] + ',';
						        }
						        _jsonPositionData = _jsonPositionData.substr(0,_jsonPositionData.length-1);
				        	}else{
				        		_jsonPositionData += ',' + _arr[_deviceNum]+':N';
				        	}
				        }else{
				        	_jsonPositionData = _arr[_deviceNum]+':N';
				        }
		    		}
		    		else {		
		    			$('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').addClass('DeviceBoxPositionLocked');		        
				        if (_jsonPositionData!='') {        		
				        	var _jsonPositionDataTmp='';
				        	if (_jsonPositionData.indexOf(_arr[_deviceNum])>=0) {
				        		for (var i = 0; i < _jsonPositionDataArr.length; i++) {
					        		var _jsonPositionDataArrTmp = _jsonPositionDataArr[i].split(':');
					        		if (_jsonPositionDataArrTmp[0]==_arr[_deviceNum]) {
					        			_jsonPositionDataArrTmp[1] = _deviceNum;
					        			_jsonPositionDataArr[i] = _jsonPositionDataArrTmp[0]+':'+_jsonPositionDataArrTmp[1];	        				
					        		}
					        	}
					        	_jsonPositionData='';
					        	for (var i = 0; i < _jsonPositionDataArr.length; i++) {
						        	_jsonPositionData += _jsonPositionDataArr[i] + ',';
						        }
						        _jsonPositionData = _jsonPositionData.substr(0,_jsonPositionData.length-1);
				        	}else{
				        		_jsonPositionData += ',' + _arr[_deviceNum]+':'+_deviceNum;
				        	}
				        }else{
				        	_jsonPositionData = _arr[_deviceNum]+':'+_deviceNum;
				        }
		    		}
			    	ReadDataFromFile('PositionInfoSetFile=2&PositionInfoData='+_jsonPositionData);
			    	// console.log(_jsonPositionData);
		    	}
			    else {
			    	//DecodeGroupDataListArr
			    	if ($('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) {
		    			$('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').removeClass('DeviceBoxPositionLocked');
		    			for (var i = 0; i < EncodeGroupDataListArr.length; i++) {
				    		if (_deviceNum==i) {
				    			var _DecodeGroupDataListArrTmp = EncodeGroupDataListArr[i].split(':');
				    			_DecodeGroupDataListArrTmp[1] = _deviceNum;
				    			EncodeGroupDataListArr[i] = _DecodeGroupDataListArrTmp[0]+':N';
				    			PinPositionSaveToFile(_DecodeGroupDataListArrTmp[0],EncodeGroupDataListArr[i].replace(/:/g,'_'),'VideoEncode_'+$('#GroupTxSelectBox li:eq('+DeviceGroupTxSelectNum+') span:eq(1)').html());
				    			break;
				    		}
				    	}
				    	var _temp='';
				    	for (var i = 0; i < EncodeGroupDataListArr.length; i++) {
				    		_temp+=EncodeGroupDataListArr[i]+',';
				    	}
				    	_temp = _temp.substr(0,_temp.length-1);
		    		}
		    		else {
		    			$('.IPAV1100TxCont li:eq('+_deviceNum+') .DeviceBoxNavTopLocked').addClass('DeviceBoxPositionLocked');
		    			for (var i = 0; i < EncodeGroupDataListArr.length; i++) {
				    		if (_deviceNum==i) {
				    			var _DecodeGroupDataListArrTmp = EncodeGroupDataListArr[i].split(':');
				    			_DecodeGroupDataListArrTmp[1] = _deviceNum;
				    			EncodeGroupDataListArr[i] = _DecodeGroupDataListArrTmp[0]+':'+_DecodeGroupDataListArrTmp[1];
				    			PinPositionSaveToFile(_DecodeGroupDataListArrTmp[0],EncodeGroupDataListArr[i].replace(/:/g,'_'),'VideoEncode_'+$('#GroupTxSelectBox li:eq('+DeviceGroupTxSelectNum+') span:eq(1)').html());
				    			break;
				    		}
				    	}
				    	var _temp='';
				    	for (var i = 0; i < EncodeGroupDataListArr.length; i++) {
				    		_temp+=EncodeGroupDataListArr[i]+',';
				    	}
				    	_temp = _temp.substr(0,_temp.length-1);
				    	
		    		}
				    PageAddGroup('type=9&id='+$('#GroupTxSelectBox li:eq('+DeviceGroupTxSelectNum+') span:eq(1)').html()+'&deviceMAC='+_temp);
				   	// console.log(_temp);
			    }
		    }
		});
	});
	// video change resolution
	
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRight1 .RxDeviceOptionsRightNavList').each(function(e){
		$(this).on('mouseover',function(){
			//if (DecoderConfigurationDeviceNumb==0) return; //开放部分使用权限
			//clearTimeout(_settimeoutResolution);
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').hide();
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').hide();
			_settimeoutResolution=setTimeout(function(){
				if (_VideoPageResolutionFormats==0) {
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').hide();
				}
			},300);
			
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();


			if (e==1) {
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').show();
				CheckBoxIsOverflow(0,2);

			}
			if (e==2) {
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').show();
				CheckBoxIsOverflow(0,2);
			}
			if (1) {
				if (e==10) {
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').show();
				}
			}
			
		});		
		
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').on('mouseover',function(){
		_VideoPageResolutionFormats = 1;
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').on('mouseleave',function(){
		_VideoPageResolutionFormats = 0;
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').on('mouseover',function(){
		_VideoPageResolutionFormats = 1;
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').on('mouseleave',function(){
		$(this).hide();
		_VideoPageResolutionFormats = 0;
	});
	$('#VideoConfigurationTxDevice .RxDeviceOptionsRight .RxDeviceOptionsRightNavList').each(function(e){
		$(this).on('mouseover',function(){
			$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
			if (1) {
				if (e==9) {
					$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').show();
					CheckBoxIsOverflow(0,1);
				}
			}				
		});
		
	});
			
	var _videoFastSwitchMode;
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .RxDeviceOptionsRightNavList').each(function(e){
		$(this).on('mouseover',function(){
			//console.log(e);
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').show();
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
			if ($('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq('+e+')').hasClass('IPAV1100RxDeviceOptionsNavSecLHover')) {
				console.log(e);
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL:eq('+_DecoderFastSwitchFullScreen+')').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
			}
			_videoFastSwitchMode = e;
			if (e==0) {
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').css('top','91px');
			}
			if (e==1) {
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').css('top','112px');
			}
			if (e==2) {
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').css('top','133px');
			}
			CheckBoxIsOverflow(0,2);
		});
	});
	// decoder configuration click function  发送指令----------------------------------------------
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightNavList:eq(0)').on('click',function(){//genlock
		var _arrRx = _data.videoswitching_decode_arr.split(',');
		var _DecodeRx;
		if (DecoderConfigurationDeviceNumb==0)
			_DecodeRx = 'ALL_RX';
		else
			_DecodeRx = _arrRx[DecoderConfigurationDeviceNumb-1];
		
		sendCommand('data=set '+_DecodeRx+' video genlock');
		SystemLogWriteToFileAnother('Video Decoder','Genlock');
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling .RxDeviceOptionsRightNavList').each(function(e){// genlock scalling
		$(this).on('click',function(){
			var _arrRx = _data.videoswitching_decode_arr.split(',');
			var _DecodeRx;
			if (DecoderConfigurationDeviceNumb==0)
				_DecodeRx = 'ALL_RX';
			else
				_DecodeRx = _arrRx[DecoderConfigurationDeviceNumb-1];
			sendCommand('data=set '+_DecodeRx+' video genlock_scaling size '+_genlockscalling[e]);
			SystemLogWriteToFileAnother('Video Decoder','Genlock Scalling');
		});
	});
	$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .RxDeviceOptionsRightNavList').each(function(e){// fast switch
		$(this).on('click',function(){
			var _arrRx = _data.videoswitching_decode_arr.split(',');
			var _DecodeRx;
			if (DecoderConfigurationDeviceNumb==0)
				_DecodeRx = 'ALL_RX';
			else
				_DecodeRx = _arrRx[DecoderConfigurationDeviceNumb-1];
			if (_videoFastSwitchMode == 0) {
				sendCommand('data=set '+_DecodeRx+' video fastswitch size '+_fastswitch[e]);
			}
			else if(_videoFastSwitchMode == 1){
				sendCommand('data=set '+_DecodeRx+' video fastswitch stretch size '+_fastswitch[e]);
			}
			else if(_videoFastSwitchMode == 2){
				sendCommand('data=set '+_DecodeRx+' video fastswitch crop size '+_fastswitch[e]);
			}
			SystemLogWriteToFileAnother('Video Decoder','Fast Switch Full Screen');
		});
	});
	$('#VideoLeaveVideoChannel').on('click',function(){		
		var _arrRx = _data.videoswitching_decode_arr.split(',');
		var _DecodeRx;
		if (DecoderConfigurationDeviceNumb==0)
			_DecodeRx = 'ALL_RX';
		else
			_DecodeRx = _arrRx[DecoderConfigurationDeviceNumb-1];
		sendCommand('data=leave '+_DecodeRx+':HDMI:0');
		SystemLogWriteToFileAnother('Video Decoder','Leave Video Channel');
	});
	$('#DeviceFactoryResetYesBtn').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) {
			if (DecoderOrEncoder==1) {
				sendCommand('data=factory ALL_RX');
				$('#DeviceFactoryReset').hide();
				return;
			}
		}
		if (current_page==5||current_page==6) {
			if (DecoderOrEncoder==1) {
				var _arrRx = _data.Rs232_En_De_arr.split(',');
				sendCommand('data=factory '+_arrRx[DecoderConfigurationDeviceNumb-1]);
			}
			else if(DecoderOrEncoder==2){
				var _arrRx = _data.Rs232_De_En_arr.split(',');
				sendCommand('data=factory '+_arrRx[EncoderConfigurationDeviceNumb]);
			}	
		}
		else {
			if (DecoderOrEncoder==1) {
				var _arrRx = _data.videoswitching_decode_arr.split(',');
				sendCommand('data=factory '+_arrRx[DecoderConfigurationDeviceNumb-1]);
			}
			else if(DecoderOrEncoder==2){
				var _arrRx = _data.videoswitching_encode_arr.split(',');
				sendCommand('data=factory '+_arrRx[EncoderConfigurationDeviceNumb]);
			}	
		}		
		$('#DeviceFactoryReset').hide();	
		SystemLogWriteToFileAnother('Video Decoder','Factory Reset');		
	});
	$('#DeviceRebootYesBtn').on('click',function(){
		if (DecoderConfigurationDeviceNumb==0) {
			if (DecoderOrEncoder==1) {
				sendCommand('data=reboot ALL_RX');
				$('#DeviceReboot').hide();
				return;
			}				
		}
		if (current_page==5||current_page==6) {
			if (DecoderOrEncoder==1) {
				var _arrRx = _data.Rs232_En_De_arr.split(',');
				sendCommand('data=reboot '+_arrRx[DecoderConfigurationDeviceNumb-1]);
			}
			else if(DecoderOrEncoder==2){
				var _arrRx = _data.Rs232_De_En_arr.split(',');
				sendCommand('data=reboot '+_arrRx[EncoderConfigurationDeviceNumb]);
			}	
		}
		else {
			if (DecoderOrEncoder==1) {
				var _arrRx = _data.videoswitching_decode_arr.split(',');
				sendCommand('data=reboot '+_arrRx[DecoderConfigurationDeviceNumb-1]);
			}
			else if(DecoderOrEncoder==2){
				var _arrRx = _data.videoswitching_encode_arr.split(',');
				sendCommand('data=reboot '+_arrRx[EncoderConfigurationDeviceNumb]);
			}	
		}
		$('#DeviceReboot').hide();
		SystemLogWriteToFileAnother('Video Decoder','Device Reboot');
	});
	// encoder configuration click function  发送指令----------------------------------------------
	$('#VideoConfigurationStartVideo').on('click',function(){
		var _arrRx = _data.videoswitching_encode_arr.split(',');		
		sendCommand('data=start '+_arrRx[EncoderConfigurationDeviceNumb]+':HDMI:0');
	});
	$('#VideoConfigurationStopVideo').on('click',function(){
		var _arrRx = _data.videoswitching_encode_arr.split(',');		
		sendCommand('data=stop '+_arrRx[EncoderConfigurationDeviceNumb]+':HDMI:0');
	});
	$('#VideoConfigurationStopAndFreeChannel').on('click',function(){
		$('#DeviceStopandFreeMulticastaddress').show();
		
	});
	// decoder setting save begin ------------------------------------------------------------------------------------
	$('#DeviceRxConfigurationBoxSaveBtn').on('click',function(){
		var _arrRx = _data.videoswitching_decode_arr.split(',');
		var _DecoderConfigurationDeviceNumb = DecoderConfigurationDeviceNumb;
		var _analogAudio;
		//console.log(12341231);
		if ($('#EncoderIPMode').val()=='1'||$('#DecoderIPMode').val()=='1') {
			if (CheckNetworkIsOk(1,$('#DeviceRxConfigurationBox #DecoderIPAdress').val(),
				$('#DeviceRxConfigurationBox #DecoderMask').val(),
				$('#DeviceRxConfigurationBox #DecoderGateway').val())) {
				return;
			}
		}
			
		// Analog Audio *********************
		if ($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(0)').attr('src').indexOf('SettingRadioOn')>=0)
			_analogAudio = 2;
		else if($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(1)').attr('src').indexOf('SettingRadioOn')>=0)
			_analogAudio = 3;
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][0]!=_analogAudio) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[ANALOG_AUDIO_OUTPUT:0].inputs[main:0].configuration.source.value '+_analogAudio);
			SystemLogWriteToFileAnother('Decoder Configuration','Analog Audio Output Change');
		}
		// Hdmi Audio *********************
		var _hdmiAudio;
		if ($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(2)').attr('src').indexOf('SettingRadioOn')>=0)
			_hdmiAudio = 2;
		else if($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(3)').attr('src').indexOf('SettingRadioOn')>=0)
			_hdmiAudio = 3;
		else if($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(4)').attr('src').indexOf('SettingRadioOn')>=0)
			_hdmiAudio = 6;
		else if($('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(5)').attr('src').indexOf('SettingRadioOn')>=0)
			_hdmiAudio = 7;
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]!=_hdmiAudio) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[HDMI_ENCODER:0].inputs[audio:0].configuration.source.value '+_hdmiAudio);
			SystemLogWriteToFileAnother('Decoder Configuration','HDMI Audio Output Change');
		}
		// IP Adress *********************
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][3]!=$('#DecoderHostname').val()) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property configuration.device_name '+$('#DecoderHostname').val());
			SystemLogWriteToFileAnother('Decoder Configuration','Network Hostname Change');
		}
		if ((DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4]=='MANUAL'?'STATIC':DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4])!=$('#DecoderIPMode option:selected').text()&&$('#DecoderIPMode option:selected').text()=='DHCP') {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' ip mode DHCP');
			SystemLogWriteToFileAnother('Decoder Configuration','Network IP Mode Change');
		}
		if (((DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4]=='MANUAL'?'STATIC':DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4])!=$('#DecoderIPMode option:selected').text()&&$('#DecoderIPMode option:selected').text()=='STATIC')
			||DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][5]!=$('#DeviceRxConfigurationBox #DecoderIPAdress').val()
			||DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][6]!=$('#DeviceRxConfigurationBox #DecoderMask').val()
			||DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][7]!=$('#DeviceRxConfigurationBox #DecoderGateway').val()) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' ip mode MANUAL address '
				+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+' mask '+$('#DeviceRxConfigurationBox #DecoderMask').val()
				+' gateway '+$('#DeviceRxConfigurationBox #DecoderGateway').val());
			SystemLogWriteToFileAnother('Decoder Configuration','Network IP Change');
		}
		// Rs232 *********************
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]!=parseInt($('#DecoderRs232BaudRate option:selected').text())) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[UART:1].configuration.baud_rate '
				+$('#DecoderRs232BaudRate option:selected').text());
			SystemLogWriteToFileAnother('Decoder Configuration','RS232 BaudRate Change');
		}
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][9]!=parseInt($('#DecoderRs232DataBit option:selected').text())) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[UART:1].configuration.data_bits '
				+$('#DecoderRs232DataBit option:selected').text());
			SystemLogWriteToFileAnother('Decoder Configuration','RS232 DataBit Change');
		}
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][10]!=parseInt($('#DecoderRs232StopBit option:selected').text())) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[UART:1].configuration.stop_bits '
				+$('#DecoderRs232StopBit option:selected').text());
			SystemLogWriteToFileAnother('Decoder Configuration','RS232 StopBit Change');
		}
		if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]!=$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase()) {
			sendCommand('data=set '+_arrRx[DecoderConfigurationDeviceNumb-1]+' property nodes[UART:1].configuration.parity '
				+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase());
			SystemLogWriteToFileAnother('Decoder Configuration','RS232 Parity Change');
		}
		$('#DeviceRxConfigurationBox').hide();

		$('.DeviceDecoderConfigurationLeftText').removeClass('ErrorInputText');
		$('#DecoderIPAdress').removeClass('ErrorInputBoxRadius');
		$('#DeviceRxConfigurationBox .DisplayErrorNav').hide();
		$('#DecoderMask').removeClass('ErrorInputBoxRadius');
		$('#DecoderGateway').removeClass('ErrorInputBoxRadius');

		$('#EncoderIPAdress').removeClass('ErrorInputBoxRadius');
		$('#DeviceTxConfigurationBox .DisplayErrorNav').hide();
		$('#EncoderMask').removeClass('ErrorInputBoxRadius');
		$('#EncoderGateway').removeClass('ErrorInputBoxRadius');

		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').removeClass('ErrorInputText');
		$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').removeClass('ErrorInputText');

		// switch(current_page){
		// case 1:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#GroupRxSelectBox li').each(function(e){
		// 			if ($('#VideoGroupSelectRx span').html()==$('#GroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#GroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=VideoDecode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
  //                   			_rst[i] = 'Video:Decode:'
  //                   					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
  //                   					+_id+':'
  //                   					+_analogAudio+':'
  //                   					+_hdmiAudio+':'
  //                   					+$('#DecoderHostname').val()+':'
  //                   					+$('#DecoderIPMode option:selected').text()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#DecoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#DecoderRs232DataBit option:selected').text()+':'
  //                   					+$('#DecoderRs232StopBit option:selected').text()+':'
  //                   					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
  //                   		}                    		
  //                   	}
  //                   }
  //                   GroupAddingDeviceSaveSetting('VideoDecode_'+_id,_rst.toString());
  //               } 
  //           });
			
		// break;
		// case 2:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#VideoWallGroupRxSelectBox li').each(function(e){
		// 			if ($('#VideoWallGroupSelectRx span').html()==$('#VideoWallGroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#VideoWallGroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=VideoWallDecode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
  //                   			_rst[i] = 'VideoWall:Decode:'
  //                   					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
  //                   					+_id+':'
  //                   					+_analogAudio+':'
  //                   					+_hdmiAudio+':'
  //                   					+$('#DecoderHostname').val()+':'
  //                   					+$('#DecoderIPMode option:selected').text()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#DecoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#DecoderRs232DataBit option:selected').text()+':'
  //                   					+$('#DecoderRs232StopBit option:selected').text()+':'
  //                   					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
  //                   		}                    		
  //                   	}
  //                   }
  //                   GroupAddingDeviceSaveSetting('VideoWallDecode_'+_id,_rst.toString());
  //               } 
  //           });
			
		// break;
		// case 3:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#HdmiAudioGroupRxSelectBox li').each(function(e){
		// 			if ($('#HdmiAudioGroupSelectRx span').html()==$('#HdmiAudioGroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#HdmiAudioGroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=HdmiAudioDecode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
  //                   			_rst[i] = 'HdmiAudio:Decode:'
  //                   					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
  //                   					+_id+':'
  //                   					+_analogAudio+':'
  //                   					+_hdmiAudio+':'
  //                   					+$('#DecoderHostname').val()+':'
  //                   					+$('#DecoderIPMode option:selected').text()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#DecoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#DecoderRs232DataBit option:selected').text()+':'
  //                   					+$('#DecoderRs232StopBit option:selected').text()+':'
  //                   					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
  //                   		}                    		
  //                   	}
  //                   }
  //                   GroupAddingDeviceSaveSetting('HdmiAudioDecode_'+_id,_rst.toString());
  //               } 
  //           });
			
		// break;
		// case 4:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#AnalogAudioGroupRxSelectBox li').each(function(e){
		// 			if ($('#AnalogAudioGroupSelectRx span').html()==$('#AnalogAudioGroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#AnalogAudioGroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=AnalogAudioDecode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
  //                   			_rst[i] = 'AnalogAudio:Decode:'
  //                   					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
  //                   					+_id+':'
  //                   					+_analogAudio+':'
  //                   					+_hdmiAudio+':'
  //                   					+$('#DecoderHostname').val()+':'
  //                   					+$('#DecoderIPMode option:selected').text()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#DecoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#DecoderRs232DataBit option:selected').text()+':'
  //                   					+$('#DecoderRs232StopBit option:selected').text()+':'
  //                   					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
  //                   		}                    		
  //                   	}
  //                   }
  //                   GroupAddingDeviceSaveSetting('AnalogAudioDecode_'+_id,_rst.toString());
  //               } 
  //           });
			
		// break;
		// case 5:
		// 	if (DecoderOrEncoder==1) {
		// 		var _id;			
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#Rs232GroupRxSelectBox li').each(function(e){
		// 				if ($('#Rs232GroupSelectRx span').html()==$('#Rs232GroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#Rs232GroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
				
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=Rs232Decode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
	 //                    			_rst[i] = 'Rs232:Decode:'
	 //                    					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
	 //                    					+_id+':'
	 //                    					+_analogAudio+':'
	 //                    					+_hdmiAudio+':'
	 //                    					+$('#DecoderHostname').val()+':'
	 //                    					+$('#DecoderIPMode option:selected').text()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#DecoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#DecoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                    GroupAddingDeviceSaveSetting('Rs232Decode_'+_id,_rst.toString());
	 //                } 
	 //            });
				
		// 	}
		// 	else if (DecoderOrEncoder==2) {
		// 		var _id;			
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#Rs232GroupTxSelectBox li').each(function(e){
		// 				if ($('#Rs232GroupSelectTx span').html()==$('#Rs232GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#Rs232GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
				
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
	 //                    			_rst[i] = 'Rs232:Encode:'
	 //                    					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
	 //                    					+_id+':'
	 //                    					+_analogAudio+':'
	 //                    					+_hdmiAudio+':'
	 //                    					+$('#DecoderHostname').val()+':'
	 //                    					+$('#DecoderIPMode option:selected').text()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#DecoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#DecoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
	 //                    					+_rstArr[15];
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                    GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
	 //                } 
	 //            });
				
		// 	}
				
		// break;
		// case 6:
		// 	if (DecoderOrEncoder==1) {
		// 		var _id;
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#InfraredGroupRxSelectBox li').each(function(e){
		// 				if ($('#InfraredGroupSelectRx span').html()==$('#InfraredGroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#InfraredGroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=InfraredDecode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
	 //                    			_rst[i] = 'Infrared:Decode:'
	 //                    					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
	 //                    					+_id+':'
	 //                    					+_analogAudio+':'
	 //                    					+_hdmiAudio+':'
	 //                    					+$('#DecoderHostname').val()+':'
	 //                    					+$('#DecoderIPMode option:selected').text()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#DecoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#DecoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase();
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                    GroupAddingDeviceSaveSetting('InfraredDecode_'+_id,_rst.toString());
	 //                } 
	 //            });
				
		// 	}
		// 	else if (DecoderOrEncoder==2) {
		// 		var _id;
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#InfraredGroupTxSelectBox li').each(function(e){
		// 				if ($('#InfraredGroupSelectTx span').html()==$('#InfraredGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#InfraredGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[DecoderConfigurationDeviceNumb-1]==_rstArr[2]) {
	 //                    			_rst[i] = 'Infrared:Encode:'
	 //                    					+_arrRx[DecoderConfigurationDeviceNumb-1]+':'
	 //                    					+_id+':'
	 //                    					+_analogAudio+':'
	 //                    					+_hdmiAudio+':'
	 //                    					+$('#DecoderHostname').val()+':'
	 //                    					+$('#DecoderIPMode option:selected').text()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#DeviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#DecoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#DecoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#DecoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
	 //                    					+_rstArr[15];
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                    GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
	 //                } 
	 //            });
				
		// 	}				
		// break;
		// }
	});
	// decoder setting save end   ------------------------------------------------------------------------------------
	// encoder setting save begin ------------------------------------------------------------------------------------
	$('#DeviceTxConfigurationBoxSaveBtn').on('click',function(){
		if (current_page==5||current_page==6) {
			var _arrRx = _data.Rs232_En_De_arr.split(',');
			EncodeDetaileDataArr = Rs232IrSenderDataDetaileDataArr;
		}
		else {
			var _arrRx = _data.videoswitching_encode_arr.split(',');
		}
		var _DecoderConfigurationDeviceNumb = EncoderConfigurationDeviceNumb;
		var _analogAudio;
		var _EncodeHDCP,_EncodeHDCP22;
		if ($('#EncoderIPMode').val()=='1'||$('#DecoderIPMode').val()=='1') {
			if (CheckNetworkIsOk(2,$('#DeviceTxConfigurationBox #EncoderIPAdress').val(),
				$('#DeviceTxConfigurationBox #EncoderMask').val(),
				$('#DeviceTxConfigurationBox #EncoderGateway').val())) {
				return;
			}
		}
		
			
		// Input HDCP *********************
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][0]) {
			if ($('#HDCPSupport option:selected').text()=='Disable') {
				sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[HDMI_DECODER:0].configuration.Hdcp_support_enable DISABLE');
				SystemLogWriteToFileAnother('Encoder Configuration','HDCP Support Change');
				_EncodeHDCP = false;
			}			
		}
		else {
			if ($('#HDCPSupport option:selected').text()=='Enable') {
				sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[HDMI_DECODER:0].configuration.Hdcp_support_enable ENABLE');
				SystemLogWriteToFileAnother('Encoder Configuration','HDCP Support Change');
				_EncodeHDCP = true;
			}
		}
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][0]&&$('#HDCPSupport option:selected').text()=='Enable') {
			if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][1]) {
				if ($('#HDCP22Support option:selected').text()=='Enable') {
					sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable DISABLE');		
					SystemLogWriteToFileAnother('Encoder Configuration','HDCP 2.2 Support Change');
					_EncodeHDCP22 = false;
				}
					
			}
			else {			
				if ($('#HDCP22Support option:selected').text()=='Disable') {
					sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable ENABLE');
					SystemLogWriteToFileAnother('Encoder Configuration','HDCP 2.2 Support Change');
					_EncodeHDCP22 = true;
				}
					
			}
		}			
		// IP Adress *********************
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][3]!=$('#EncoderHostname').val()) {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property configuration.device_name '+$('#EncoderHostname').val());
			SystemLogWriteToFileAnother('Encoder Configuration','Network Hostname Change');
		}
		if ((EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][4]=='MANUAL'?'STATIC':EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][4])!=$('#EncoderIPMode option:selected').text()&&$('#EncoderIPMode option:selected').text()=='DHCP') {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' ip mode DHCP');
			SystemLogWriteToFileAnother('Encoder Configuration','Network IP Mode Change');
		}
		if ((EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][4]=='MANUAL'?'STATIC':EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][4])!=$('#EncoderIPMode option:selected').text()&&$('#EncoderIPMode option:selected').text()=='STATIC'
			||EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][5]!=$('#DeviceTxConfigurationBox #EncoderIPAdress').val()
			||EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][6]!=$('#DeviceTxConfigurationBox #EncoderMask').val()
			||EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][7]!=$('#DeviceTxConfigurationBox #EncoderGateway').val()) {

			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' ip mode MANUAL address '
				+$('#DeviceTxConfigurationBox #EncoderIPAdress').val()+' mask '+$('#DeviceTxConfigurationBox #EncoderMask').val()
				+' gateway '+$('#DeviceTxConfigurationBox #EncoderGateway').val());
			SystemLogWriteToFileAnother('Encoder Configuration','Network IP Change');
		}
		// Rs232 *********************
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][8]!=parseInt($('#EncoderRs232BaudRate option:selected').text())) {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[UART:1].configuration.baud_rate '
				+$('#EncoderRs232BaudRate option:selected').text());
			SystemLogWriteToFileAnother('Encoder Configuration','RS232 BaudRate Change');
		}
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][9]!=parseInt($('#EncoderRs232DataBit option:selected').text())) {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[UART:1].configuration.data_bits '
				+$('#EncoderRs232DataBit option:selected').text());
			SystemLogWriteToFileAnother('Encoder Configuration','RS232 DataBit Change');
		}
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][10]!=parseInt($('#EncoderRs232StopBit option:selected').text())) {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[UART:1].configuration.stop_bits '
				+$('#EncoderRs232StopBit option:selected').text());
			SystemLogWriteToFileAnother('Encoder Configuration','RS232 StopBit Change');
		}
		if (EncodeDetaileDataArr[_DecoderConfigurationDeviceNumb][11]!=$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()) {
			sendCommand('data=set '+_arrRx[_DecoderConfigurationDeviceNumb]+' property nodes[UART:1].configuration.parity '
				+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase());
			SystemLogWriteToFileAnother('Encoder Configuration','RS232 Parity Change');
		}
		$('#DeviceTxConfigurationBox').hide();
		_ReceiveCheckType = 0;
		_SendingCheckType=0;
		$('.DeviceDecoderConfigurationLeftText').removeClass('ErrorInputText');
		$('#DecoderIPAdress').removeClass('ErrorInputBoxRadius');
		$('#DeviceRxConfigurationBox .DisplayErrorNav').hide();
		$('#DecoderMask').removeClass('ErrorInputBoxRadius');
		$('#DecoderGateway').removeClass('ErrorInputBoxRadius');

		$('#EncoderIPAdress').removeClass('ErrorInputBoxRadius');
		$('#DeviceTxConfigurationBox .DisplayErrorNav').hide();
		$('#EncoderMask').removeClass('ErrorInputBoxRadius');
		$('#EncoderGateway').removeClass('ErrorInputBoxRadius');

		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').removeClass('ErrorInputText');
		$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').removeClass('ErrorInputText');
		// switch(current_page){
		// case 1:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#GroupTxSelectBox li').each(function(e){
		// 			if ($('#VideoGroupSelectTx div:eq(1)').html()==$('#GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=VideoEncode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = _rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
  //                   			_rst[i] = 'Video:Encode:'
  //                   					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
  //                   					+_id+':'
  //                   					+_EncodeHDCP+':'
  //                   					+_EncodeHDCP22+':'
  //                   					+$('#EncoderHostname').val()+':'
  //                   					+$('#EncoderIPMode option:selected').text()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#EncoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#EncoderRs232DataBit option:selected').text()+':'
  //                   					+$('#EncoderRs232StopBit option:selected').text()+':'
  //                   					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
  //                   					+_rstArr[15];
  //                   		}                    		
  //                   	}
  //                   }
  //               } 
  //           });
		// 	GroupAddingDeviceSaveSetting('VideoEncode_'+_id,_rst.toString());
		// break;
		// case 2:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#VideoWallGroupTxSelectBox li').each(function(e){
		// 			if ($('#VideoWallGroupSelectTx div:eq(1)').html()==$('#VideoWallGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#VideoWallGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=VideoWallEncode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = _rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
  //                   			_rst[i] = 'VideoWall:Encode:'
  //                   					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
  //                   					+_id+':'
  //                   					+_EncodeHDCP+':'
  //                   					+_EncodeHDCP22+':'
  //                   					+$('#EncoderHostname').val()+':'
  //                   					+$('#EncoderIPMode option:selected').text()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#EncoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#EncoderRs232DataBit option:selected').text()+':'
  //                   					+$('#EncoderRs232StopBit option:selected').text()+':'
  //                   					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
  //                   					+_rstArr[15];
  //                   		}                    		
  //                   	}
  //                   }
  //               } 
  //           });
		// 	GroupAddingDeviceSaveSetting('VideoWallEncode_'+_id,_rst.toString());
		// break;
		// case 3:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#HdmiAudioGroupTxSelectBox li').each(function(e){
		// 			if ($('#HdmiAudioGroupSelectTx div:eq(1)').html()==$('#HdmiAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#HdmiAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=HdmiAudioEncode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = _rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
  //                   			_rst[i] = 'HdmiAudio:Encode:'
  //                   					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
  //                   					+_id+':'
  //                   					+_EncodeHDCP+':'
  //                   					+_EncodeHDCP22+':'
  //                   					+$('#EncoderHostname').val()+':'
  //                   					+$('#EncoderIPMode option:selected').text()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#EncoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#EncoderRs232DataBit option:selected').text()+':'
  //                   					+$('#EncoderRs232StopBit option:selected').text()+':'
  //                   					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
  //                   					+_rstArr[15];
  //                   		}                    		
  //                   	}
  //                   }
  //               } 
  //           });
		// 	GroupAddingDeviceSaveSetting('HdmiAudioEncode_'+_id,_rst.toString());
		// break;
		// case 4:
		// 	var _id;
		// 	if (1) {
		// 		_id = 'Default';
		// 	}
		// 	else {				
		// 		$('#AnalogAudioGroupTxSelectBox li').each(function(e){
		// 			if ($('#AnalogAudioGroupSelectTx div:eq(1)').html()==$('#AnalogAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 				_id = $('#AnalogAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 			}
		// 		});
		// 	}
		// 	$.ajax({
  //               type: 'POST',
  //               url: 'common/GroupSaveSetting.php',
  //               data: 'ReadGroupSaveSettingName=AnalogAudioEncode_'+_id,
  //               datatype: 'json',
  //               async: true,
  //               success: function(rst) {
  //                   var _rst = _rst.split(',');
  //                   for (var i = 0; i < _rst.length; i++) {
  //                   	if (_rst[i]!='') {
  //                   		var _rstArr = _rst[i].split(':');
  //                   		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
  //                   			_rst[i] = 'AnalogAudio:Encode:'
  //                   					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
  //                   					+_id+':'
  //                   					+_EncodeHDCP+':'
  //                   					+_EncodeHDCP22+':'
  //                   					+$('#EncoderHostname').val()+':'
  //                   					+$('#EncoderIPMode option:selected').text()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
  //                   					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
  //                   					+$('#EncoderRs232BaudRate option:selected').text()+':'
  //                   					+$('#EncoderRs232DataBit option:selected').text()+':'
  //                   					+$('#EncoderRs232StopBit option:selected').text()+':'
  //                   					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
  //                   					+_rstArr[15];
  //                   		}                    		
  //                   	}
  //                   }
  //               } 
  //           });
		// 	GroupAddingDeviceSaveSetting('AnalogAudioEncode_'+_id,_rst.toString());
		// break;
		// case 5:
		// 	if (DecoderOrEncoder==1) {
		// 		var _id;			
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#Rs232GroupRxSelectBox li').each(function(e){
		// 				if ($('#Rs232GroupSelectRx div:eq(1)').html()==$('#Rs232GroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#Rs232GroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
				
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=Rs232Decode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = _rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
	 //                    			_rst[i] = 'Rs232:Decode:'
	 //                    					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
	 //                    					+_id+':'
	 //                    					+_EncodeHDCP+':'
	 //                    					+_EncodeHDCP22+':'
	 //                    					+$('#EncoderHostname').val()+':'
	 //                    					+$('#EncoderIPMode option:selected').text()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#EncoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#EncoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase();
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                } 
	 //            });
		// 		GroupAddingDeviceSaveSetting('Rs232Decode_'+_id,_rst.toString());
		// 	}
		// 	else if (DecoderOrEncoder==2) {
		// 		var _id;			
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#Rs232GroupTxSelectBox li').each(function(e){
		// 				if ($('#Rs232GroupSelectTx div:eq(1)').html()==$('#Rs232GroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#Rs232GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
				
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=Rs232Encode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = _rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
	 //                    			_rst[i] = 'Rs232:Encode:'
	 //                    					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
	 //                    					+_id+':'
	 //                    					+_EncodeHDCP+':'
	 //                    					+_EncodeHDCP22+':'
	 //                    					+$('#EncoderHostname').val()+':'
	 //                    					+$('#EncoderIPMode option:selected').text()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#EncoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#EncoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
	 //                    					+_rstArr[15];
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                } 
	 //            });
		// 		GroupAddingDeviceSaveSetting('Rs232Encode_'+_id,_rst.toString());
		// 	}
				
		// break;
		// case 6:
		// 	if (DecoderOrEncoder==1) {
		// 		var _id;
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#InfraredGroupRxSelectBox li').each(function(e){
		// 				if ($('#InfraredGroupSelectRx div:eq(1)').html()==$('#InfraredGroupRxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#InfraredGroupRxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=InfraredDecode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = _rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
	 //                    			_rst[i] = 'Infrared:Decode:'
	 //                    					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
	 //                    					+_id+':'
	 //                    					+_EncodeHDCP+':'
	 //                    					+_EncodeHDCP22+':'
	 //                    					+$('#EncoderHostname').val()+':'
	 //                    					+$('#EncoderIPMode option:selected').text()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#EncoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#EncoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase();
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                } 
	 //            });
		// 		GroupAddingDeviceSaveSetting('InfraredDecode_'+_id,_rst.toString());
		// 	}
		// 	else if (DecoderOrEncoder==2) {
		// 		var _id;
		// 		if (1) {
		// 			_id = 'Default';
		// 		}
		// 		else {				
		// 			$('#InfraredGroupTxSelectBox li').each(function(e){
		// 				if ($('#InfraredGroupSelectTx div:eq(1)').html()==$('#InfraredGroupTxSelectBox li:eq('+e+') div:eq(1)').html()) {
		// 					_id = $('#InfraredGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
		// 				}
		// 			});
		// 		}
		// 		$.ajax({
	 //                type: 'POST',
	 //                url: 'common/GroupSaveSetting.php',
	 //                data: 'ReadGroupSaveSettingName=InfraredEncode_'+_id,
	 //                datatype: 'json',
	 //                async: true,
	 //                success: function(rst) {
	 //                    var _rst = _rst.split(',');
	 //                    for (var i = 0; i < _rst.length; i++) {
	 //                    	if (_rst[i]!='') {
	 //                    		var _rstArr = _rst[i].split(':');
	 //                    		if (_arrRx[_DecoderConfigurationDeviceNumb]==_rstArr[2]) {
	 //                    			_rst[i] = 'Infrared:Encode:'
	 //                    					+_arrRx[_DecoderConfigurationDeviceNumb]+':'
	 //                    					+_id+':'
	 //                    					+_EncodeHDCP+':'
	 //                    					+_EncodeHDCP22+':'
	 //                    					+$('#EncoderHostname').val()+':'
	 //                    					+$('#EncoderIPMode option:selected').text()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderIPAdress').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderMask').val()+':'
	 //                    					+$('#EnviceRxConfigurationBox #DecoderGateway').val()+':'
	 //                    					+$('#EncoderRs232BaudRate option:selected').text()+':'
	 //                    					+$('#EncoderRs232DataBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232StopBit option:selected').text()+':'
	 //                    					+$('#EncoderRs232Parity option:selected').text().toLocaleUpperCase()+':'
	 //                    					+_rstArr[15];
	 //                    		}                    		
	 //                    	}
	 //                    }
	 //                } 
	 //            });
		// 		GroupAddingDeviceSaveSetting('InfraredEncode_'+_id,_rst.toString());
		// 	}
				
		// break;
		// }
	});
	// encoder setting save end   ------------------------------------------------------------------------------------
	// add to group	
	$('#VideoRemoveFromGroupRx').on('click',function(){
		if (1) return;
		var groupID = $('#GroupRxSelectBox li:eq('+DeviceGroupRxSelectNum+') span:eq(1)').html();
		var grouplist = DecodeGroupDataListArr;
		var  newgrouplist='';
		var _num;
		
		var GroupDataArr = '';
		$.ajax({
            type: 'POST',
            url: 'common/GroupSaveSetting.php',
            data: 'ReadGroupSaveSettingName=VideoDecode_'+groupID,
            datatype: 'json',
            async: true,
            success: function(rst) {
            	var _rst = rst.split(',');
            	for (var i = 0; i < _rst.length; i++) {
            		if (_rst[i]!='') {
            			var _rstArr = _rst[i].split(':');
            			var _grouplist = grouplist[DecoderConfigurationDeviceNumb-1].split(':');
            			if (_grouplist[0]==_rstArr[2]) {
            				_rst[i] = '';
            			}            			
            		}
            	}
            	var _rstTmp='';
            	for (var i = 0; i < _rst.length; i++) {//重新拼合数据    
            		if (_rst[i]!='') {
            			_rstTmp += _rst[i]+',';
            		}
				}
				_rstTmp = _rstTmp.substr(0,_rstTmp.length-1);
                GroupAddingDeviceSaveSetting('VideoDecode_'+groupID,_rstTmp);

                grouplist[DecoderConfigurationDeviceNumb-1]='';
				for (var i = 0; i < grouplist.length; i++) {//重新拼合数据      
					if (grouplist[i]!='') {
						GroupDataArr+= grouplist[i]+',';
					}   
				    
				}
				GroupDataArr = GroupDataArr.substr(0,GroupDataArr.length-1);
				var data = 'type=9&id='+groupID+'&deviceMAC='+GroupDataArr+'&devicetype=rx';
				//console.log(data);
				PageAddGroup(data);
				$('.IPAV1100RxCont:eq(0) li:eq('+DecoderConfigurationDeviceNumb+')').html('');
				$('.IPAV1100RxCont:eq(0) li:eq('+DecoderConfigurationDeviceNumb+')').removeClass('deviceBoxHasDevice');
				SystemLogWriteToFileAnother('Video Decoder','Remove Device From Group');
            } 
        });
				
	});
	$('#VideoRemoveFromGroupTx').on('click',function(){
		if (1) return;
		var groupID = $('#GroupTxSelectBox li:eq('+DeviceGroupTxSelectNum+') span:eq(1)').html();
		var grouplist = EncodeGroupDataListArr;
		var  newgrouplist='';
		var _num;
		
		var GroupDataArr = '';
		$.ajax({
            type: 'POST',
            url: 'common/GroupSaveSetting.php',
            data: 'ReadGroupSaveSettingName=VideoEncode_'+groupID,
            datatype: 'json',
            async: true,
            success: function(rst) {
            	var _rst = rst.split(',');
            	for (var i = 0; i < _rst.length; i++) {
            		if (_rst[i]!='') {
            			var _rstArr = _rst[i].split(':');
            			var _grouplist = grouplist[EncoderConfigurationDeviceNumb].split(':');
            			if (_grouplist[0]==_rstArr[2]) {
            				_rst[i] = '';
            			}
            		}
            	}
            	var _rstTmp='';
            	for (var i = 0; i < _rst.length; i++) {//重新拼合数据    
            		if (_rst[i]!='') {
            			_rstTmp += _rst[i]+',';
            		}
				}
				_rstTmp = _rstTmp.substr(0,_rstTmp.length-1);
                GroupAddingDeviceSaveSetting('VideoEncode_'+groupID,_rstTmp);

                grouplist[EncoderConfigurationDeviceNumb]='';    
				for (var i = 0; i < grouplist.length; i++) {//重新拼合数据      
					if (grouplist[i]!='') {
						GroupDataArr+= grouplist[i]+',';
					}   				    
				}
				GroupDataArr = GroupDataArr.substr(0,GroupDataArr.length-1);
				var data = 'type=9&id='+groupID+'&deviceMAC='+GroupDataArr+'&devicetype=tx';
				//console.log(data);
				PageAddGroup(data);
				$('.IPAV1100TxCont:eq(0) li:eq('+EncoderConfigurationDeviceNumb+')').html('');
				$('.IPAV1100TxCont:eq(0) li:eq('+EncoderConfigurationDeviceNumb+')').removeClass('deviceBoxHasDevice');
            } 
        });
				
	});
});

$(window).resize(function(){
	//$('.IPAV1100ContentBottomLeft').css('width','15%');
	//$('.IPAV1100ContentBottomLeft').css('width',(parseInt($('.IPAV1100ContentBottomLeft').width())-1)+'px');
	if (current_page != 1) {
		return;
	}
	PageLoadingVideoDevice();
	
	

});
// Group 
$('.GroupOptionsRight .GroupOptionsRightNavList').each(function(e){
	$(this).on('mouseover',function(){
		$(this).css('background-color','#6797b8');
		$('.GroupOptionsRight .GroupOptionsRightNavList .IPAV1100GroupOptionsNavSecL').css('background-color','#313d49');
		$('.GroupOptionsRight .GroupOptionsRightNavList:eq('+e+') .IPAV1100GroupOptionsNavSecL').css('background-color','#006eb8');
	});
	$(this).on('mouseleave',function(){
		$(this).css('background-color','#313d49');
		$('.GroupOptionsRight .GroupOptionsRightNavList:eq('+e+') .IPAV1100GroupOptionsNavSecL').css('background-color','#313d49');
	});
});

// 点击页面取消弹出框
$('body').on('click',function(){
	if (_GroupRxSettingOver==1) {
		if (_GroupTxSettingOver==0){
			$('#GroupOptionsTx').hide();
			$('#VideoTxDeviceRenameBox').css('left','165px');
			_GrouopTxSetting=0;
			$('#GroupTxSelectBox').hide();
			_GrouopTxSelect=0;
		}
		if (_DeviceRxSettingClick==1){
			if (MouseoverRxToHide==1) return;
			$('.GroupOptionsRxDevice').hide();
			_DeviceRxSettingClick=0;
		}
		if (_DeviceTxSettingClick==1){
			if (backMouseoverRxToHide==1) return;
			$('.GroupOptionsTxDevice').hide();
			_DeviceTxSettingClick=0;
			_DeviceTxFirmwareSettingClick = 0;
		}
		return;
	}
	if (_GroupTxSettingOver==1) {
		if (_GroupRxSettingOver==0){
			$('#GroupOptionsRx').hide();
			$('#VideoRxDeviceRenameBox').css('left','165px');
			_GrouopRxSetting=0;
			$('#GroupRxSelectBox').hide();
			_GrouopRxSelect=0;
		}
		if (_DeviceRxSettingClick==1){
			if (MouseoverRxToHide==1) return;
			$('.GroupOptionsRxDevice').hide();
			_DeviceRxSettingClick=0;
		}
		if (_DeviceTxSettingClick==1){
			if (backMouseoverRxToHide==1) return;
			$('.GroupOptionsTxDevice').hide();
			_DeviceTxSettingClick=0;
			_DeviceTxFirmwareSettingClick = 0;
		}
		return;
	}
	// if (_DeviceRxSetting==1) {
	// 	return;
	// }
	if (_GrouopTxSetting==1){
		$('#GroupOptionsTx').hide();
		$('#VideoTxDeviceRenameBox').css('left','165px');
		_GrouopTxSetting=0;
	}
	if (_GrouopRxSetting==1){
		$('#GroupOptionsRx').hide();
		$('#VideoRxDeviceRenameBox').css('left','165px');
		_GrouopRxSetting=0;
	}
	if (_GrouopTxSelect==1){
		$('#GroupTxSelectBox').hide();
		_GrouopTxSelect=0;
	}
	if (_GrouopRxSelect==1){
		$('#GroupRxSelectBox').hide();
		_GrouopRxSelect=0;
	}
	// device setting----------------------
	if (_DeviceRxSettingClick==1){
		if (MouseoverRxToHide==1) return;
		$('.GroupOptionsRxDevice').hide();
		_DeviceRxSettingClick=0;
	}
	if (_DeviceTxSettingClick==1){
		if (backMouseoverRxToHide==1) return;
		$('.GroupOptionsTxDevice').hide();
		_DeviceTxFirmwareSettingClick = 0;
		_DeviceTxSettingClick=0;
	}
});
var _GroupRxSettingOver = 0;
$('#VideoGroupOptionSettingRx').on('mouseover',function(){
	_GroupRxSettingOver = 1;
});
$('#VideoGroupOptionSettingRx').on('mouseleave',function(){
	_GroupRxSettingOver = 0;
});
$('#GroupOptionsRx').on('mouseover',function(){
	_GroupRxSettingOver = 1;
});
$('#GroupOptionsRx').on('mouseleave',function(){
	_GroupRxSettingOver = 0;
});
// ------------------------------
$('#VideoGroupSelectRx').on('mouseover',function(){
	_GroupRxSettingOver = 1;
});
$('#VideoGroupSelectRx').on('mouseleave',function(){
	_GroupRxSettingOver = 0;
});
$('#GroupRxSelectBox').on('mouseover',function(){
	_GroupRxSettingOver = 1;
});
$('#GroupRxSelectBox').on('mouseleave',function(){
	_GroupRxSettingOver = 0;
});
// ---------------------
$('#AddToGroupEditName').on('mouseover',function(){
	_GroupRxSettingOver = 1;
	_GroupTxSettingOver = 1;
	_VideoWallGroupRxSettingOver=1;
	_VideoWallGroupTxSettingOver=1;
	_HdmiAudioGroupRxSettingOver=1;
	_HdmiAudioGroupTxSettingOver=1;
	_AnalogAudioGroupRxSettingOver=1;
	_AnalogAudioGroupTxSettingOver=1;
	_Rs232GroupRxSettingOver=1;
	_Rs232GroupTxSettingOver=1;
	_InfraredGroupRxSettingOver=1;
	_InfraredGroupTxSettingOver=1;
});
$('#AddToGroupEditName').on('mouseleave',function(){
	_GroupRxSettingOver = 0;
	_GroupTxSettingOver = 0;
	_VideoWallGroupRxSettingOver=0;
	_VideoWallGroupTxSettingOver=0;
	_HdmiAudioGroupTxSettingOver=0;
	_AnalogAudioGroupRxSettingOver=0;
	_AnalogAudioGroupTxSettingOver=0;
	_Rs232GroupRxSettingOver=0;
	_Rs232GroupTxSettingOver=0;
	_InfraredGroupRxSettingOver=0;
	_InfraredGroupTxSettingOver=0;
});

var _GroupTxSettingOver = 0;
$('#VideoGroupOptionSettingTx').on('mouseover',function(){
	_GroupTxSettingOver = 1;
});
$('#VideoGroupOptionSettingTx').on('mouseleave',function(){
	_GroupTxSettingOver = 0;
});
$('#GroupOptionsTx').on('mouseover',function(){
	_GroupTxSettingOver = 1;
});
$('#GroupOptionsTx').on('mouseleave',function(){
	_GroupTxSettingOver = 0;
});
// ------------------------
$('#VideoGroupSelectTx').on('mouseover',function(){
	_GroupTxSettingOver = 1;
});
$('#VideoGroupSelectTx').on('mouseleave',function(){
	_GroupTxSettingOver = 0;
});
$('#GroupTxSelectBox').on('mouseover',function(){
	_GroupTxSettingOver = 1;
});
$('#GroupTxSelectBox').on('mouseleave',function(){
	_GroupTxSettingOver = 0;
});

// Group Rx Setting ---------------------------------
var _DeviceRxSetting = 0;

// Group Tx Setting
var _GrouopTxSetting = 0;
$('#VideoGroupOptionSettingTx').on('click',function(){
	if (_GrouopTxSetting==0) {
		$('#GroupOptionsTx').show();
		$('#GroupTxSelectBox').hide();
		_GrouopTxSetting=1;
		_GrouopTxSelect=0;
		_GrouopRxSelect=0;
	}
	else if (_GrouopTxSetting==1){
		$('#GroupOptionsTx').hide();
		$('#VideoTxDeviceRenameBox').css('left','165px');
		_GrouopTxSetting=0;
	}
});
var _GrouopRxSetting = 0;
$('#VideoGroupOptionSettingRx').on('click',function(){
	if (_GrouopRxSetting==0) {
		$('#GroupOptionsRx').show();
		$('#GroupRxSelectBox').hide();
		_GrouopRxSetting=1;
		_GrouopTxSelect=0;
		_GrouopRxSelect=0;
	}
	else if (_GrouopRxSetting==1){
		$('#GroupOptionsRx').hide();
		$('#VideoRxDeviceRenameBox').css('left','165px');
		_GrouopRxSetting=0;
	}
});
// Group select rx ---------------------------------
var _GrouopRxSelect = 0;
$('#VideoGroupSelectRx').on('click',function(){
	if (_GrouopRxSelect==0) {
		$('#GroupRxSelectBox').show();
		$('#GroupOptionsRx').hide();
		$('#VideoRxDeviceRenameBox').css('left','165px');
		_GrouopRxSelect=1;
		_GrouopRxSetting=0;
		_GrouopTxSetting=0;
		PageAddGroup('type=11&pagetype=videoswitching&devicetype=rx');
	}
	else if (_GrouopRxSelect==1){
		$('#GroupRxSelectBox').hide();
		_GrouopRxSelect=0;
	}
});
// Group select tx
var _GrouopTxSelect = 0;
$('#VideoGroupSelectTx').on('click',function(){
	if (_GrouopTxSelect==0) {
		$('#GroupTxSelectBox').show();
		$('#GroupOptionsTx').hide();
		$('#VideoTxDeviceRenameBox').css('left','165px');
		_GrouopTxSelect=1;
		_GrouopRxSetting=0;
		_GrouopTxSetting=0;
		PageAddGroup('type=11&pagetype=videoswitching&devicetype=tx');
	}
	else if (_GrouopTxSelect==1){
		$('#GroupTxSelectBox').hide();
		_GrouopTxSelect=0;
	}
});
// 分组功能模块rename//////////////////////////////////////////////////////////////////////////
$('#VideoGroupOptionsRxRename').on('click',function(){
	if ($('#VideoGroupSelectRx span').html()!='Default') {
		$('#VideoRxDeviceRenameBox input').val($('#VideoGroupSelectRx span').html());
		$('#VideoRxDeviceRenameBox').css('left','11px');
	}	
});
$('#VideoRxDeviceRenameBoxYes').on('click',function(){
	var groupID = $('#GroupRxSelectBox li:eq('+(DeviceGroupRxSelectNum-1)+') span:eq(1)').html();
	var name = $('#VideoRxDeviceRenameBox input').val();
	if (name=='') {
		$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('Invalid Value!');
		$('#DisplayErrorContent').show();
		return;
	}
	var data = 'type=2&id='+groupID+'&rename='+name+'&pagetype=videoswitching&devicetype=rx';
	//_GrouopRxSelect = 1;
	PageAddGroup(data);
	$('#VideoGroupSelectRx span').html(name);
	$('#VideoRxDeviceRenameBox').css('left','165px');
});
$('#VideoRxDeviceRenameBoxNo').on('click',function(){
	$('#VideoRxDeviceRenameBox').css('left','165px');
});
$('#VideoGroupOptionsTxRename').on('click',function(){
	if ($('#VideoGroupSelectTx span').html()!='Default') {
		$('#VideoTxDeviceRenameBox input').val($('#VideoGroupSelectTx span').html());
		$('#VideoTxDeviceRenameBox').css('left','11px');
	}	
});
$('#VideoTxDeviceRenameBoxYes').on('click',function(){	
	var groupID = $('#GroupTxSelectBox li:eq('+DeviceGroupTxSelectNum+') span:eq(1)').html();
	var name = $('#VideoTxDeviceRenameBox input').val();
	var data = 'type=2&id='+groupID+'&rename='+name+'&pagetype=videoswitching&devicetype=tx';
	_GrouopTxSelect = 1;
	PageAddGroup(data);
	$('#VideoTxDeviceRenameBox').css('left','165px');
});
$('#VideoTxDeviceRenameBoxNo').on('click',function(){
	$('#VideoTxDeviceRenameBox').css('left','165px');
});
// 删除分组选项功能
$('#VideoGroupOptionsRxDelectGroup').on('click',function(){
	if ($('#VideoGroupSelectRx span').html()=='Default') {
        $('#DeleteGroupNeedComfirm').hide();
        return;
    }
	DeleteGroupDisplayBox('video','rx');
});
$('#VideoGroupOptionsTxDelectGroup').on('click',function(){
	if ($('#VideoGroupSelectTx span').html()=='Default') {
        $('#DeleteGroupNeedComfirm').hide();
        return;
    }
	DeleteGroupDisplayBox('video','tx');
});
// device setting -----------------------------
var _DeviceRxSettingClick = 0;
var _DeviceTxSettingClick = 0;
// 
// pageloading device box
function PageLoadingVideoDevice(){
	// $('.IPAV1100ContentBottomLeft').css('width','15%');
	// $('.IPAV1100ContentBottomLeft').css('width',(parseInt($('.IPAV1100ContentBottomLeft').width())-1)+'px');
	if (current_page != 1) {
		return;
	}
	$('.IPAV1100RxCont').css('width','100%');
	$('.IPAV1100TxCont').css('width','100%');
	var Exp_boxHeight = $('#BottomRightVideo').height();
	var Exp_CurrentBoxHeight = Exp_boxHeight-381;
	$('.IPAV1100ContentBottomRightVideoSwitchingBottomCont').css('height',Exp_CurrentBoxHeight+'px');
	// $('.IPAV1100ContentBottomLeft').css('height',(parseInt($('.IPAV1100Content').height())-parseInt($('.IPAV1100ContentHead').height()))+'px');
	// rx device box reload -----------------------------
	var _EncoderDeviceBoxHeight = (parseInt((Exp_CurrentBoxHeight-42)/108)*120+108)<Exp_CurrentBoxHeight?(parseInt((Exp_CurrentBoxHeight-42)/108)*120+108):(parseInt((Exp_CurrentBoxHeight-42)/108-1)*120+108);
	$('.IPAV1100TxContScrool').css('height',_EncoderDeviceBoxHeight+'px');

	var _IPAV1100RxCont = $('.IPAV1100RxCont').width();
	var _IPAV1100TxCont = $('.IPAV1100TxCont').width();
	var _IPAV1100TxContDisplayH = parseInt((_EncoderDeviceBoxHeight+12)/120);
	var _IPAV1100TxContDisplayH = _IPAV1100TxContDisplayH*3;
	var _x = 6*(parseInt((_IPAV1100RxCont-197)/(209))+1);
	var _y = _IPAV1100TxContDisplayH*(parseInt((_IPAV1100TxCont-197)/(209))+1);
	
	if (_IPAV1100RxCont>(_x/6*209+197-12) ) {
		$('.IPAV1100RxCont').css('width','99%');
	}
	if (_IPAV1100TxCont>(_y/_IPAV1100TxContDisplayH*209+197-12) ) {
		$('.IPAV1100TxCont').css('width','99%');
	}

	$('.IPAV1100TxCont').css('height',($('.IPAV1100TxCont').height()-24)+'px');
	if ($('.IPAV1100RxCont li').length<_x) {
		var _qidian = $('.IPAV1100RxCont li').length;
		for (var i = _qidian; i <_x; i++) {
			$('.IPAV1100RxCont').append("<li></li>");
		}
		$('.IPAV1100RxCont li').each(function(){
			if ($(this).hasClass('IPAV1100RxContLiRepos')) {
				$(this).removeClass('IPAV1100RxContLiRepos');
			}			
		});
		for (var i = 1; i < 6; i++) {
			$('.IPAV1100RxCont li:eq('+((_x/6)*i)+')').addClass('IPAV1100RxContLiRepos');
		}
	}
	if ($('.IPAV1100RxCont li').length>_x) {
		$('.IPAV1100RxCont li').each(function(){
			if ($(this).hasClass('IPAV1100RxContLiRepos')) {
				$(this).removeClass('IPAV1100RxContLiRepos');
			}
		});
		for (var i = 1; i < 6; i++) {
			$('.IPAV1100RxCont li:eq('+((_x/6)*i)+')').addClass('IPAV1100RxContLiRepos');
		}
		
		var _length = $('.IPAV1100RxCont li').length;
		for (var i = _length-1; i >= _x; i--) {
			$('.IPAV1100RxCont li:eq('+i+')').remove();
		}
	}
	if ($('.IPAV1100TxCont li').length<_y) {
		var _qidian = $('.IPAV1100TxCont li').length;
		for (var i = _qidian; i <_y; i++) {
			$('.IPAV1100TxCont').append("<li></li>");
		}
		$('.IPAV1100TxCont li').each(function(){
			if ($(this).hasClass('IPAV1100RxContLiRepos')) {
				$(this).removeClass('IPAV1100RxContLiRepos');
			}
		});
		for (var i = 1; i < _IPAV1100TxContDisplayH; i++) {
			$('.IPAV1100TxCont li:eq('+(_y/_IPAV1100TxContDisplayH)*i+')').addClass('IPAV1100RxContLiRepos');
		}
		
	}
	if ($('.IPAV1100TxCont li').length>_y) {
		$('.IPAV1100TxCont li').each(function(){
			if ($(this).hasClass('IPAV1100RxContLiRepos')) {
				$(this).removeClass('IPAV1100RxContLiRepos');
			}
		});
		for (var i = 1; i < _IPAV1100TxContDisplayH; i++) {
			$('.IPAV1100TxCont li:eq('+(_y/_IPAV1100TxContDisplayH)*i+')').addClass('IPAV1100RxContLiRepos');
		}
		
		var _length = $('.IPAV1100TxCont li').length;
		for (var i = _length-1; i >= _y; i--) {
			$('.IPAV1100TxCont li:eq('+i+')').remove();
		}
	}
}
// decoder弹出菜单共用参数获取函数 
var _DecoderFastSwitchFullScreen=0;
function DecoderSettingConfigurationGetJsonData(numb){
	if (DecoderConfigurationDeviceNumb==0) {
		$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		return;
	}
	if (current_page==5||current_page==6) {
		var _arrRx = _data.Rs232_De_En_arr.split(',');
	}
	else {
		var _arrRx = _data.videoswitching_decode_arr.split(',');
	}
	var _deviceNumb = numb;
	
	
	if ($('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').hasClass('IPAV1100RxDeviceOptionsNavSecLHover')
		||$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').hasClass('IPAV1100RxDeviceOptionsNavSecLHover')) {
		$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
	}
	if (_deviceNumb==-1) return;
	if (1) {
		_deviceNumb = _deviceNumb-1;
	}
	if (current_page==1) {
		var _displayMode = DecodeVideoDataArr[_deviceNumb][4];
		var _width = DecodeVideoDataArr[_deviceNumb][7];
		var _height = DecodeVideoDataArr[_deviceNumb][8];
		var _fps = DecodeVideoDataArr[_deviceNumb][9];
	}
	else if (current_page==2){
		var _displayMode = DecodeVideoWallDataArr[_deviceNumb][4];
		var _width = DecodeVideoWallDataArr[_deviceNumb][7];
		var _height = DecodeVideoWallDataArr[_deviceNumb][8];
		var _fps = DecodeVideoWallDataArr[_deviceNumb][9];
	}

	if (_displayMode==0) {		
		$('#VideoConfigurationRxDeviceGenlock').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDeviceGenlock').addClass('IPAV1100RxDeviceOptionsNavSecLHover');		
	}
	else if(_displayMode=='FAST_SWITCHED'||_displayMode=='FAST_SWITCHED_CROP'||_displayMode=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
		$('#VideoConfigurationRxDeviceFastswitchFullScreen').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDeviceFastswitchFullScreen').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling .IPAV1100RxDeviceOptionsNavSecL').removeClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		switch(_displayMode){
		case 'FAST_SWITCHED':			
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(0)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
			$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(0)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		break;
		case 'FAST_SWITCHED_CROP':
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(2)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
			$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(2)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		break;
		case 'FAST_SWITCHED_STRETCH':
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(1)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
			$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch .IPAV1100RxDeviceOptionsNavSecL:eq(1)').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		break;
		}
		
		for (var i = 0; i < videoResolutionFastSwitchFull.length; i++) {
			if (videoResolutionFastSwitchFull[i][0]==_width&&
				videoResolutionFastSwitchFull[i][1]==_height&&
				videoResolutionFastSwitchFull[i][2]==_fps) {				
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL:eq('+i+')').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
				$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav .IPAV1100RxDeviceOptionsNavSecL:eq('+i+')').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
				_DecoderFastSwitchFullScreen = i;
			}
		}
	}
	else if(_displayMode=='GENLOCK_SCALING'){//genlock scaling
		$('#VideoConfigurationRxDeviceGenlockScaling').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		$('#VideoWallConfigurationRxDeviceGenlockScaling').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
		
		for (var i = 0; i < VideoWallResolutionArr.length; i++) {
			if (VideoWallResolutionArr[i][0]==_width&&
				VideoWallResolutionArr[i][1]==_height) {				
				$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling .IPAV1100RxDeviceOptionsNavSecL:eq('+i+')').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
				$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling .IPAV1100RxDeviceOptionsNavSecL:eq('+i+')').addClass('IPAV1100RxDeviceOptionsNavSecLHover');
			
			}
		}
	}
	else if(_displayMode=='WALL_GENLOCKED'){
		
	}
}
// decoder configuration setting
function DecoderConfigurationSettingBox(){
	var _DecoderConfigurationDeviceNumb = DecoderConfigurationDeviceNumb;	
	if (_DecoderConfigurationDeviceNumb==0) return;
	if (current_page==5||current_page==6) {
		var _arrRx = _data.Rs232_De_En_arr.split(',');
	}
	else {
		var _arrRx = _data.videoswitching_decode_arr.split(',');
	}
	
	

	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationNav span:eq(0)').html('Decoder '+ _arrRx[DecoderConfigurationDeviceNumb-1] +' Configuration');
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco').attr('src','images/SettingRadioOff.png');
	// Analog Audio Output
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][0]==2) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(0)').attr('src','images/SettingRadioOn.png');
	}else if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][0]==3) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(1)').attr('src','images/SettingRadioOn.png');
	}
	// HDMI Audio Output
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==2) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(2)').attr('src','images/SettingRadioOn.png');
	}else if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==3) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(3)').attr('src','images/SettingRadioOn.png');
	}else if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==6) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(4)').attr('src','images/SettingRadioOn.png');
	}else if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==7) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(5)').attr('src','images/SettingRadioOn.png');
	}
	// Display EDID
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCEDIDTxt').html(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][2]);
	//$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCEDIDTxt').html('ceshi~ceshi~');
	// Network Setting
	$('#DeviceRxConfigurationBox #DecoderHostname').val(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][3]);
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4]=='DHCP')
		$('#DeviceRxConfigurationBox #DecoderIPMode').val('0');
	else
		$('#DeviceRxConfigurationBox #DecoderIPMode').val('1');
	
	$('#DeviceRxConfigurationBox #DecoderIPAdress').val(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][5]);
	$('#DeviceRxConfigurationBox #DecoderMask').val(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][6]);
	$('#DeviceRxConfigurationBox #DecoderGateway').val(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][7]);
	if ($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='0') {
		$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderIPAdress').addClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderMask').addClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderGateway').addClass('textDisabled');
	}else if($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='1'){
		$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderIPAdress').removeClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderMask').removeClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderGateway').removeClass('textDisabled');
	}
	// RS232
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==2400) {
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('0');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==4800){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('1');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==9600){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('2');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==19200){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('3');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==38400){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('4');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==57600){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('5');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==115200){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('6');
	}
	if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][9]==7){
		$('#DeviceRxConfigurationBox #DecoderRs232DataBit').val('0');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][9]==8){
		$('#DeviceRxConfigurationBox #DecoderRs232DataBit').val('1');
	}
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][10]==1) {
		$('#DeviceRxConfigurationBox #DecoderRs232StopBit').val('0');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][10]==2){
		$('#DeviceRxConfigurationBox #DecoderRs232StopBit').val('1');
	}
	if (DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='NONE') {
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('0');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='ODD'){
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('1');
	}else if(DecodeDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='EVEN'){
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('2');
	}
}
// encoder configuration setting
function EncoderConfigurationSettingBox(){	
	if (current_page==5||current_page==6) {
		var _arrRx = _data.Rs232_En_De_arr.split(',');

		var _EncoderConfigurationDeviceNumb = EncoderConfigurationDeviceNumb;
	}
	else {
		var _arrRx = _data.videoswitching_encode_arr.split(',');
		var _EncoderConfigurationDeviceNumb = EncoderConfigurationDeviceNumb;
	}
	
	$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationNav span:eq(0)').html('Encoder '+ _arrRx[_EncoderConfigurationDeviceNumb] +' Configuration');
	
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][0]) {
		$('#HDCPSupport').val('0');
		$('#HDCP22Support').attr('disabled',false);		
		$('#HDCP22Support').removeClass('textDisabled');
	}else{
		$('#HDCPSupport').val('1');
		$('#HDCP22Support').attr('disabled',true);

		$('#HDCP22Support').addClass('textDisabled');
	}
	// HDCP 2.2 Support
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][1]) {
		$('#HDCP22Support').val('1');
	}else{
		$('#HDCP22Support').val('0');
	}
	// Display EDID
	$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationRightNavCEDIDTxt').val(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][2]);
	EDIDSelectFileText = EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][2];
	// Network Setting
	$('#DeviceTxConfigurationBox #EncoderHostname').val(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][3]);
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][4]=='DHCP')
		$('#DeviceTxConfigurationBox #EncoderIPMode').val('0');
	else
		$('#DeviceTxConfigurationBox #EncoderIPMode').val('1');
	
	$('#DeviceTxConfigurationBox #EncoderIPAdress').val(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][5]);
	$('#DeviceTxConfigurationBox #EncoderMask').val(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][6]);
	$('#DeviceTxConfigurationBox #EncoderGateway').val(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][7]);
	if ($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='0') {
		$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderIPAdress').addClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderMask').addClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderGateway').addClass('textDisabled');
	}else if($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='1'){
		$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderIPAdress').removeClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderMask').removeClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderGateway').removeClass('textDisabled');
	}
	// RS232
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==2400) {
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('0');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==4800){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('1');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==9600){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('2');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==19200){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('3');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==38400){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('4');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==57600){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('5');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==115200){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('6');
	}
	if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][9]==7){
		$('#DeviceTxConfigurationBox #EncoderRs232DataBit').val('0');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][9]==8){
		$('#DeviceTxConfigurationBox #EncoderRs232DataBit').val('1');
	}
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][10]==1) {
		$('#DeviceTxConfigurationBox #EncoderRs232StopBit').val('0');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][10]==2){
		$('#DeviceTxConfigurationBox #EncoderRs232StopBit').val('1');
	}
	if (EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='NONE') {
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('0');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='ODD'){
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('1');
	}else if(EncodeDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='EVEN'){
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('2');
	}
}
// Rs232--------------------------------------------------------
function Rs232DecoderConfigurationSettingBox(){
	var _DecoderConfigurationDeviceNumb = DecoderConfigurationDeviceNumb;
	if (_DecoderConfigurationDeviceNumb==0) return;
	if (current_page==5||current_page==6) {
		var _arrRx = _data.Rs232_De_En_arr.split(',');
	}
	else {
		var _arrRx = _data.videoswitching_decode_arr.split(',');
	}
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationNav span:eq(0)').html('Decoder '+ _arrRx[DecoderConfigurationDeviceNumb-1] +' Configuration');
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco').attr('src','images/SettingRadioOff.png');
	// Analog Audio Output
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][0]==2) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(0)').attr('src','images/SettingRadioOn.png');
	}else if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][0]==3) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(1)').attr('src','images/SettingRadioOn.png');
	}
	// HDMI Audio Output
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==2) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(2)').attr('src','images/SettingRadioOn.png');
	}else if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==3) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(3)').attr('src','images/SettingRadioOn.png');
	}else if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==6) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(4)').attr('src','images/SettingRadioOn.png');
	}else if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][1]==7) {
		$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCIco:eq(5)').attr('src','images/SettingRadioOn.png');
	}
	// Display EDID
	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationRightNavCEDIDTxt').html(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][2]);
	// Network Setting
	$('#DeviceRxConfigurationBox #DecoderHostname').val(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][3]);
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][4]=='DHCP')
		$('#DeviceRxConfigurationBox #DecoderIPMode').val('0');
	else
		$('#DeviceRxConfigurationBox #DecoderIPMode').val('1');
	
	$('#DeviceRxConfigurationBox #DecoderIPAdress').val(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][5]);
	$('#DeviceRxConfigurationBox #DecoderMask').val(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][6]);
	$('#DeviceRxConfigurationBox #DecoderGateway').val(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][7]);
	if ($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='0') {
		$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',true);
		$('#DeviceRxConfigurationBox #DecoderIPAdress').addClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderMask').addClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderGateway').addClass('textDisabled');
	}else if($('#DeviceRxConfigurationBox #DecoderIPMode').val()=='1'){
		$('#DeviceRxConfigurationBox #DecoderIPAdress').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderMask').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderGateway').attr('disabled',false);
		$('#DeviceRxConfigurationBox #DecoderIPAdress').removeClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderMask').removeClass('textDisabled');
		$('#DeviceRxConfigurationBox #DecoderGateway').removeClass('textDisabled');
	}
	// RS232
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==2400) {
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('0');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==4800){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('1');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==9600){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('2');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==19200){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('3');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==38400){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('4');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==57600){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('5');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][8]==115200){
		$('#DeviceRxConfigurationBox #DecoderRs232BaudRate').val('6');
	}
	if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][9]==7){
		$('#DeviceRxConfigurationBox #DecoderRs232DataBit').val('0');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][9]==8){
		$('#DeviceRxConfigurationBox #DecoderRs232DataBit').val('1');
	}
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][10]==1) {
		$('#DeviceRxConfigurationBox #DecoderRs232StopBit').val('0');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][10]==2){
		$('#DeviceRxConfigurationBox #DecoderRs232StopBit').val('1');
	}
	if (Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='NONE') {
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('0');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='ODD'){
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('1');
	}else if(Rs232IrReceiverDataDetaileDataArr[_DecoderConfigurationDeviceNumb-1][11]=='EVEN'){
		$('#DeviceRxConfigurationBox #DecoderRs232Parity').val('2');
	}
}
// encoder configuration setting
function Rs232EncoderConfigurationSettingBox(){	
	if (current_page==5||current_page==6) {
		var _arrRx = _data.Rs232_En_De_arr.split(',');
		var _EncoderConfigurationDeviceNumb = EncoderConfigurationDeviceNumb;
	}
	else {
		var _arrRx = _data.videoswitching_encode_arr.split(',');
		var _EncoderConfigurationDeviceNumb = EncoderConfigurationDeviceNumb;
	}
	$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationNav span:eq(0)').html('Encoder '+ _arrRx[_EncoderConfigurationDeviceNumb] +' Configuration');
	
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][0]) {
		$('#HDCPSupport').val('0');
		$('#HDCP22Support').attr('disabled',false);
		$('#HDCP22Support').removeClass('textDisabled');
	}else{
		$('#HDCPSupport').val('1');
		$('#HDCP22Support').attr('disabled',true);

		$('#HDCP22Support').addClass('textDisabled');
	}
	// HDCP 2.2 Support
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][1]) {
		$('#HDCP22Support').val('1');
	}else{
		$('#HDCP22Support').val('0');
	}
	// Display EDID
	$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationRightNavCEDIDTxt').val(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][2]);
	// Network Setting
	$('#DeviceTxConfigurationBox #EncoderHostname').val(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][3]);
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][4]=='DHCP')
		$('#DeviceTxConfigurationBox #EncoderIPMode').val('0');
	else
		$('#DeviceTxConfigurationBox #EncoderIPMode').val('1');
	
	$('#DeviceTxConfigurationBox #EncoderIPAdress').val(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][5]);
	$('#DeviceTxConfigurationBox #EncoderMask').val(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][6]);
	$('#DeviceTxConfigurationBox #EncoderGateway').val(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][7]);
	if ($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='0') {
		$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',true);
		$('#DeviceTxConfigurationBox #EncoderIPAdress').addClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderMask').addClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderGateway').addClass('textDisabled');
	}else if($('#DeviceTxConfigurationBox #EncoderIPMode').val()=='1'){
		$('#DeviceTxConfigurationBox #EncoderIPAdress').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderMask').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderGateway').attr('disabled',false);
		$('#DeviceTxConfigurationBox #EncoderIPAdress').removeClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderMask').removeClass('textDisabled');
		$('#DeviceTxConfigurationBox #EncoderGateway').removeClass('textDisabled');
	}
	// RS232
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==2400) {
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('0');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==4800){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('1');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==9600){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('2');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==19200){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('3');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==38400){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('4');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==57600){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('5');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][8]==115200){
		$('#DeviceTxConfigurationBox #EncoderRs232BaudRate').val('6');
	}
	if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][9]==7){
		$('#DeviceTxConfigurationBox #EncoderRs232DataBit').val('0');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][9]==8){
		$('#DeviceTxConfigurationBox #EncoderRs232DataBit').val('1');
	}
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][10]==1) {
		$('#DeviceTxConfigurationBox #EncoderRs232StopBit').val('0');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][10]==2){
		$('#DeviceTxConfigurationBox #EncoderRs232StopBit').val('1');
	}
	if (Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='NONE') {
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('0');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='ODD'){
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('1');
	}else if(Rs232IrSenderDataDetaileDataArr[_EncoderConfigurationDeviceNumb][11]=='EVEN'){
		$('#DeviceTxConfigurationBox #EncoderRs232Parity').val('2');
	}
}

function SystemLogWriteToFile(deviceID,_txDeviceMAC){
	var myDate = new Date();
	var systemlogtype='';
	var _systemlogTime = myDate.toLocaleDateString() + ' ' + myDate.getHours() + ':' + myDate.getMinutes();
	var _arrRx = _data.Rs232_De_En_arr.split(',');
	var _arrTx = _data.Rs232_En_De_arr.split(',');
	var _arrRx1 = _data.videoswitching_decode_arr.split(',');
	var _arrTx1 = _data.videoswitching_encode_arr.split(',');
	var _numRx,_numTx,_numRx1,_numTx1;
	if (current_page==5||current_page==6) {		
		for (var i = 0; i <_arrTx.length; i++) {
			(function(ii){
				if (_arrTx[ii]==_txDeviceMAC) {
					_numTx=ii;//匹配设备ID,存储到相应序号设备数据			
				}
			})(i);		
		}
		for (var i = 0; i <_arrRx.length; i++) {
			(function(ii){
				if (_arrRx[ii]==deviceID) {
					_numRx=ii;//匹配设备ID,存储到相应序号设备数据
				}
			})(i);		
		}
	}
	else {
		for (var i = 0; i <_arrTx1.length; i++) {
			(function(ii){
				if (_arrTx1[ii]==_txDeviceMAC) {
					_numTx1=ii;//匹配设备ID,存储到相应序号设备数据			
				}
			})(i);		
		}
		for (var i = 0; i <_arrRx1.length; i++) {
			(function(ii){
				if (_arrRx1[ii]==deviceID) {
					_numRx1=ii;//匹配设备ID,存储到相应序号设备数据
				}
			})(i);		
		}
	}
		
	var _systemCommand;
	if (current_page==6) {		
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx)!='undefined') {
					_systemCommand = 'INFRARED Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_Infrared_DataArr[_numTx][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx)!='undefined') {
					_systemCommand = 'INFRARED Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Decode_Infrared_DataArr[_numRx][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'INFRARED Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_Infrared_DataArr[_numTx][2] + ' >> '+Decode_Infrared_DataArr[_numRx][2];
			}
				
			
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Encode_Infrared_DataArr[_numTx][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Decode_Infrared_DataArr[_numRx][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = 'INFRARED Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + Encode_Infrared_DataArr[_numTx][2] + ' >> ' + Decode_Infrared_DataArr[_numRx][2];
		}
			
	}
	else if(current_page==5){
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx)!='undefined') {
					_systemCommand = 'RS232 Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_Rs232_DataArr[_numTx][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx)!='undefined') {
					_systemCommand = 'RS232 Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Decode_Rs232_DataArr[_numRx][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'RS232 Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_Rs232_DataArr[_numTx][2] + ' >> '+Decode_Rs232_DataArr[_numRx][2];
			}
				
			
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Encode_Rs232_DataArr[_numTx][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Decode_Rs232_DataArr[_numRx][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = 'RS232 Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + Encode_Rs232_DataArr[_numTx][2] + ' >> ' + Decode_Rs232_DataArr[_numRx][2];
		}
	}
	else if(current_page==1){
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx1)!='undefined') {
					_systemCommand = 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoDataArr[_numTx1][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx1)!='undefined') {
					_systemCommand = 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + DecodeVideoDataArr[_numRx1][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoDataArr[_numTx1][2] + ' >> '+DecodeVideoDataArr[_numRx1][2];
			}
			
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx1)!='undefined') {
				_systemCommand = systemlogtype + 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoDataArr[_numTx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx1)!='undefined') {
				_systemCommand = systemlogtype + 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + DecodeVideoDataArr[_numRx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = systemlogtype + 'Video Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + EncodeVideoDataArr[_numTx1][2] + ' >> ' + DecodeVideoDataArr[_numRx1][2];
		}
	}		
	else if(current_page==2){
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx1)!='undefined') {
					_systemCommand = systemlogtype + 'Video Wall Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoWallDataArr[_numTx1][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx1)!='undefined') {
					_systemCommand = systemlogtype + 'Video Wall Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + DecodeVideoWallDataArr[_numRx1][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'Video Wall Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoWallDataArr[_numTx1][2] + ' >> '+DecodeVideoWallDataArr[_numRx1][2];
			}
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx1)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + EncodeVideoWallDataArr[_numTx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx1)!='undefined') {
				_systemCommand = systemlogtype + '|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + DecodeVideoWallDataArr[_numRx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = systemlogtype + 'Video Wall Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + EncodeVideoWallDataArr[_numTx1][2] + ' >> ' + DecodeVideoWallDataArr[_numRx1][2];
		}
	}
	else if(current_page==3){
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx1)!='undefined') {
					_systemCommand = systemlogtype + 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_HdmiAudio_DataArr[_numTx1][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx1)!='undefined') {
					_systemCommand = systemlogtype + 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Decode_HdmiAudio_DataArr[_numRx1][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_HdmiAudio_DataArr[_numTx1][2] + ' >> '+Decode_HdmiAudio_DataArr[_numRx1][2];
			}
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx1)!='undefined') {
				_systemCommand = systemlogtype + 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_HdmiAudio_DataArr[_numTx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx1)!='undefined') {
				_systemCommand = systemlogtype + 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Decode_HdmiAudio_DataArr[_numRx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = systemlogtype + 'HDMI Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + Encode_HdmiAudio_DataArr[_numTx1][2] + ' >> ' + Decode_HdmiAudio_DataArr[_numRx1][2];
		}
	}
	else if(current_page==4){
		if (DecoderChannelNum==0) {
			if (1) {
				if (typeof(_numTx1)!='undefined') {
					_systemCommand = systemlogtype + 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_AnalogAudio_DataArr[_numTx1][2] + ' >> All_Rx';
				}
				else if (typeof(_numRx1)!='undefined') {
					_systemCommand = systemlogtype + 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Decode_AnalogAudio_DataArr[_numRx1][2] + ' >> All_Rx';
				}
			}
			else {
				_systemCommand = 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_AnalogAudio_DataArr[_numTx1][2] + ' >> '+Decode_AnalogAudio_DataArr[_numRx1][2];
			}
		}
		else if (DecoderChannelNum<0) {
			if (typeof(_numTx1)!='undefined') {
				_systemCommand = systemlogtype + 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + Encode_AnalogAudio_DataArr[_numTx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			else if (typeof(_numRx1)!='undefined') {
				_systemCommand = systemlogtype + 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
				'|Admin|' + Decode_AnalogAudio_DataArr[_numRx1][2] + ' >> '+$('#box2 span:eq(1)').html();
			}
			
		}
		else{
			_systemCommand = systemlogtype + 'Analog Audio Routing|' + _systemlogTime + '|' + _systemlogTime + 
			'|Admin|' + Encode_AnalogAudio_DataArr[_numTx1][2] + ' >> ' + Decode_AnalogAudio_DataArr[_numRx1][2];
		}
	}
	
	WriteToSystemLog('data='+_systemCommand);
}
// 保存当前操作
function SystemLogWriteToFileAnother(type,detail){
	var myDate = new Date();
	var systemlogtype='';
	var _systemlogTime = myDate.toLocaleDateString() + ' ' + myDate.getHours() + ':' + myDate.getMinutes();
	var _arrRx = _data.Rs232_De_En_arr.split(',');
	var _arrTx = _data.Rs232_En_De_arr.split(',');
	var _arrRx1 = _data.videoswitching_decode_arr.split(',');
	var _arrTx1 = _data.videoswitching_encode_arr.split(',');
	var _numRx='',_numTx='',_numRx1='',_numTx1='';


	_systemCommand = type + '|' + _systemlogTime + '|' + _systemlogTime + 
					'|Admin|' + detail;
	WriteToSystemLog('data='+_systemCommand);
}
// 判断Network格式是否正确
function CheckNetworkIsOk(type,ip,mask,subnet){
	var reg = /\D/;
	var _ip = ip.split('.');
	var _mask = mask.split('.');
	var _subnet = subnet.split('.');
	$('.DeviceDecoderConfigurationLeftText').removeClass('ErrorInputText');
	$('#DecoderIPAdress').removeClass('ErrorInputBoxRadius');
	$('#DeviceRxConfigurationBox .DisplayErrorNav').hide();
	$('#DecoderMask').removeClass('ErrorInputBoxRadius');
	$('#DecoderGateway').removeClass('ErrorInputBoxRadius');

	$('#EncoderIPAdress').removeClass('ErrorInputBoxRadius');
	$('#DeviceTxConfigurationBox .DisplayErrorNav').hide();
	$('#EncoderMask').removeClass('ErrorInputBoxRadius');
	$('#EncoderGateway').removeClass('ErrorInputBoxRadius');

	$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').removeClass('ErrorInputText');
	$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').removeClass('ErrorInputText');
	console.log(_ip[0]);
	if (_ip.length!=4
		||(parseInt(_ip[0])>255)||((_ip[0])=='')
		||(parseInt(_ip[1])>255)||((_ip[1])=='')
		||(parseInt(_ip[2])>255)||((_ip[2])=='')
		||(parseInt(_ip[3])>255)||((_ip[3])=='')
		||ip==subnet
		||reg.test(_ip[0])
		||reg.test(_ip[1])
		||reg.test(_ip[2])
		||reg.test(_ip[3])) {
		if (type==1) {
			$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').addClass('ErrorInputText');
			$('#DeviceRxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid IP Address!');
			$('#DeviceRxConfigurationBox .DisplayErrorNav').show();
			$('#DecoderIPAdress').addClass('ErrorInputBoxRadius');
		}
		else if (type==2) {
			$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').addClass('ErrorInputText');
			$('#DeviceTxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid IP Address!');
			$('#DeviceTxConfigurationBox .DisplayErrorNav').show();
			$('#EncoderIPAdress').addClass('ErrorInputBoxRadius');
		}			
		
		return true;
		
	}
	if (_mask.length!=4
		||(parseInt(_mask[0])>255)||((_mask[0])=='')
		||(parseInt(_mask[1])>255)||((_mask[1])=='')
		||(parseInt(_mask[2])>255)||((_mask[2])=='')
		||(parseInt(_mask[3])>255)||((_mask[3])=='')
		||reg.test(_mask[0])
		||reg.test(_mask[1])
		||reg.test(_mask[2])
		||reg.test(_mask[3])) {
		if (type==1) {
			$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').addClass('ErrorInputText');
			$('#DeviceRxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid Subnet Mask!');
			$('#DeviceRxConfigurationBox .DisplayErrorNav').show();
			$('#DecoderMask').addClass('ErrorInputBoxRadius');
		}
		else if (type==2) {
			$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').addClass('ErrorInputText');
			$('#DeviceTxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid Subnet Mask!');
			$('#DeviceTxConfigurationBox .DisplayErrorNav').show();
			$('#EncoderMask').addClass('ErrorInputBoxRadius');
		}		
		return true;
	}
	if (_subnet.length!=4
		||(parseInt(_subnet[0])>255)||((_subnet[0])=='')
		||(parseInt(_subnet[1])>255)||((_subnet[1])=='')
		||(parseInt(_subnet[2])>255)||((_subnet[2])=='')
		||(parseInt(_subnet[3])>255)||((_subnet[3])=='')
		||reg.test(_subnet[0])
		||reg.test(_subnet[1])
		||reg.test(_subnet[2])
		||reg.test(_subnet[3])) {
		if (type==1) {
			$('#DeviceRxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(3)').addClass('ErrorInputText');
			$('#DeviceRxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid Default Gateway!');
			$('#DeviceRxConfigurationBox .DisplayErrorNav').show();
			$('#DecoderGateway').addClass('ErrorInputBoxRadius');
		}
		else if (type==2) {
			$('#DeviceTxConfigurationBox .DeviceDecoderConfigurationLeftText:eq(2)').addClass('ErrorInputText');
			$('#DeviceTxConfigurationBox .DisplayErrorNav span').html('Please Enter Valid Default Gateway!');
			$('#DeviceTxConfigurationBox .DisplayErrorNav').show();
			$('#EncoderGateway').addClass('ErrorInputBoxRadius');
		}		
		return true;
	}
}
// 
function CleanSettingsFunction(num,clecnSettingVal){
	var _DeviceMac;

	if (current_page==5||current_page==6) {
		if (_CleanSettingRxOrTx==1) {
			var _arrRx = _data.Rs232_De_En_arr.split(',');
			_DeviceMac = _arrRx[DecoderConfigurationDeviceNumb-1];
		}
		else if(_CleanSettingRxOrTx==2){
			var _arrRx = _data.Rs232_En_De_arr.split(',');
			_DeviceMac = _arrRx[EncoderConfigurationDeviceNumb];
		}	
	}
	else {
		if (_CleanSettingRxOrTx==1) {
			var _arrRx = _data.videoswitching_decode_arr.split(',');
			_DeviceMac = _arrRx[DecoderConfigurationDeviceNumb-1];
		}
		else if(_CleanSettingRxOrTx==2){
			var _arrRx = _data.videoswitching_encode_arr.split(',');
			_DeviceMac = _arrRx[EncoderConfigurationDeviceNumb];
		}
	}
	if (_CleanSettingRxOrTx==1) {
		if (DecoderConfigurationDeviceNumb==0)
			_DeviceMac = 'ALL_RX';

		if (clecnSettingVal[0]==1)
			sendCommand('data=set '+_DeviceMac+' property nodes[ANALOG_AUDIO_OUTPUT:0].inputs[main:0].configuration.source.value 3');
		
		if (clecnSettingVal[1]==1){
			sendCommand('data=set '+_DeviceMac+' property nodes[HDMI_ENCODER:0].inputs[audio:0].configuration.source.value 2');
		}
		
		if (clecnSettingVal[2]==1){
			if (current_page==5||current_page==6) {
				if (_CleanSettingRxOrTx==1) {
					var _arrRxTmp = _data.Rs232_De_En_arr.split(',');
				}	
			}
			else {
				if (_CleanSettingRxOrTx==1) {
					var _arrRxTmp = _data.videoswitching_decode_arr.split(',');
				}
			}
				
			for (var i = 0; i < _arrRxTmp.length; i++) {
				if (_arrRxTmp[i]!=''&&typeof(_arrRxTmp[i])!='undefined') {
					sendCommand('data=set '+_arrRxTmp[i]+' ip mode DHCP');
				}
			}
			
		}
		
		if (clecnSettingVal[3]==1){
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.baud_rate 57600');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.data_bits 8');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.stop_bits 1');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.parity NONE');
		}
		if (clecnSettingVal[4]==1){
			sendCommand('data=set '+_DeviceMac+' video genlock');			
		}
		if (clecnSettingVal.toString().indexOf('1')>=0) {
			switch(num){
			case 0:
				SystemLogWriteToFileAnother('Video Decoder','Clean Settings');
				break;
			case 1:
				SystemLogWriteToFileAnother('Video Wall Decoder','Clean Settings');
				break;
			case 2:
				SystemLogWriteToFileAnother('Hdmi Audio Decoder','Clean Settings');
				break;
			case 3:
				SystemLogWriteToFileAnother('Analog Audio Decoder','Clean Settings');
				break;
			case 4:
				SystemLogWriteToFileAnother('Rs232 Decoder','Clean Settings');
				break;
			case 5:
				SystemLogWriteToFileAnother('Infrared Decoder','Clean Settings');
				break;
			}
		}
			
	}
	else if(_CleanSettingRxOrTx==2){
		if (clecnSettingVal[0]==1){
			sendCommand('data=set '+_DeviceMac+' property nodes[HDMI_DECODER:0].configuration.Hdcp_support_enable ENABLE');
			setTimeout(function(){
				sendCommand('data=set '+_DeviceMac+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable DISABLE');
			},200);
			
		}
		
		if (clecnSettingVal[1]==1)
		sendCommand('data=set '+_DeviceMac+' ip mode DHCP');
		if (clecnSettingVal[2]==1){
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.baud_rate 57600');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.data_bits 8');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.stop_bits 1');
			sendCommand('data=set '+_DeviceMac+' property nodes[UART:1].configuration.parity NONE');
			
		}
			
		if (clecnSettingVal.toString().indexOf('1')>=0) {
			switch(num){
			case 0:
				SystemLogWriteToFileAnother('Video Encoder','Clean Settings');
				break;
			case 1:
				SystemLogWriteToFileAnother('Video Wall Encoder','Clean Settings');
				break;
			case 2:
				SystemLogWriteToFileAnother('Hdmi Audio Encoder','Clean Settings');
				break;
			case 3:
				SystemLogWriteToFileAnother('Analog Audio Encoder','Clean Settings');
				break;
			case 4:
				SystemLogWriteToFileAnother('Rs232 Encoder','Clean Settings');
				break;
			case 5:
				SystemLogWriteToFileAnother('Infrared Encoder','Clean Settings');
				break;
			}
		}
			
	}
}
function PinPositionSaveToFile(deviceID,data,filename){
	var SendData = 'ReadGroupSaveSettingName='+filename;
	var _filename = filename;
	var _deviceID = deviceID;
    $.ajax({
        type: 'POST',
        url: 'common/GroupSaveSetting.php',
        data: SendData,
        datatype: 'json',
        async: true,
        success: function(rst) {
        	if (rst.indexOf(',')>=0) {
        		var _rst = rst.split(',');
        		for (var i = 0; i < _rst.length; i++) {
        			if (_rst[i]!='') {
        				var _rstArr = _rst[i].split(':');
        				if (_rstArr[2]==_deviceID) {
        					_rstArr[5] = data;
        					_rst[i] = _rstArr.toString().replace(/,/g,':');
        					//var _zuhe = _rst.toString().replace(/,/g,':');
        					var _SendData = 'GroupSaveSettingName='+_filename+'&FileData='+_rst.toString();
						    $.ajax({
								type: 'POST',
								url: 'common/GroupSaveSetting.php',
								data: _SendData,
								datatype: 'json',
								async: true,
								success: function(rst) {} 
							});
        				}
        			}
        		}
			        		
        	}
        	else {
        		var _rst = rst.split(':');
        		_rst[5] = data;
        		var _SendData = 'GroupSaveSettingName='+_filename+'&FileData='+_rst.toString().replace(/,/g,':');
			    $.ajax({
			        type: 'POST',
			        url: 'common/GroupSaveSetting.php',
			        data: _SendData,
			        datatype: 'json',
			        async: true,
			        success: function(rst) {
			        } 
			    });
        	}
        } 
    });
}
// setting restore
function DeviceSettingRestoreDecode(deviceoID,_settingVal){
	var _settingValArr = _settingVal.split(',');
	sendCommand('data=set '+deviceoID+' property nodes[ANALOG_AUDIO_OUTPUT:0].inputs[main:0].configuration.source.value '+_settingValArr[0]);
	
	sendCommand('data=set '+deviceoID+' property nodes[HDMI_ENCODER:0].inputs[audio:0].configuration.source.value '+_settingValArr[1]);
	
	sendCommand('data=set '+deviceoID+' property configuration.device_name '+_settingValArr[3]);
	
	if (_settingValArr[4]=='DHCP') {
		sendCommand('data=set '+deviceoID+' ip mode DHCP');
	}
	else {
		sendCommand('data=set '+deviceoID+' ip mode MANUAL address '
				+_settingValArr[5]+' mask '+_settingValArr[6]
				+' gateway '+_settingValArr[7]);
	}

	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.baud_rate '
				+_settingValArr[8]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.data_bits '
				+_settingValArr[9]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.stop_bits '
				+_settingValArr[10]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.parity '
				+_settingValArr[11]);
	
}
function DeviceSettingRestoreEncode(deviceoID,_settingVal){
	var _settingValArr = _settingVal.split(',');
	if (_settingValArr[0]=='true') {
		sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_support_enable ENABLE');
				
	}
	else {
		sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_support_enable DISABLE');
		
	}
	if (_settingValArr[1]=='true') {
		setTimeout(function(){
			sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable ENABLE');
		},200);
		
		// if (_settingValArr[1]) {
			
		// 	if ($('#HDCP22Support option:selected').text()=='Enable') {
		// 		sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable DISABLE');		
		// 	}
					
		// }
		// else {			
		// 	if ($('#HDCP22Support option:selected').text()=='Disable') {
		// 		sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable ENABLE');
		// 	}
		// }
	}
	else {
		setTimeout(function(){
			sendCommand('data=set '+deviceoID+' property nodes[HDMI_DECODER:0].configuration.Hdcp_22_support_disable DISABLE');	
		},200);
		
	}

	sendCommand('data=set '+deviceoID+' property configuration.device_name '+_settingValArr[3]);
	
	if (_settingValArr[4]=='DHCP') {
		sendCommand('data=set '+deviceoID+' ip mode DHCP');
	}
	else {
		sendCommand('data=set '+deviceoID+' ip mode MANUAL address '
				+_settingValArr[5]+' mask '+_settingValArr[6]
				+' gateway '+_settingValArr[7]);
	}

	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.baud_rate '
				+_settingValArr[8]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.data_bits '
				+_settingValArr[9]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.stop_bits '
				+_settingValArr[10]);
	sendCommand('data=set '+deviceoID+' property nodes[UART:1].configuration.parity '
				+_settingValArr[11]);	
}
// 检测设备对应关系与genlock模式，并返回
function CheckRoutingAndMode(pagetype){
	var _pagetype = pagetype;
	switch(_pagetype){
	case 1://video
		var encode='',decode;
		var _recv='',_genlockMode='';
		if (EncodeVideoDataArr.length>0) {
			for (var i = 0; i < EncodeVideoDataArr.length; i++) {	
				if (EncodeVideoDataArr[i]!=''&&typeof(EncodeVideoDataArr[i])!='undefined') {
					encode = EncodeVideoDataArr[i][1];		
					if (DecodeVideoDataArr.length>0) {
						decode = '';				
						for (var j = 0; j < DecodeVideoDataArr.length; j++) {
							(function(ii,jj){
								if (EncodeVideoDataArr[ii]!=''&&typeof(EncodeVideoDataArr[ii])!='undefined'&&
									DecodeVideoDataArr[jj]!=''&&typeof(DecodeVideoDataArr[jj])!='undefined') {
									if (EncodeVideoDataArr[ii][4]==DecodeVideoDataArr[jj][5]) {
										decode += DecodeVideoDataArr[jj][1]+'|';
									}		
									if (EncodeVideoDataArr[ii][5]=='255.255.255.255'){
										decode = 'ALL_RX';								
									}
									if (DecodeVideoDataArr[jj][4]==0) {
										_genlockMode += DecodeVideoDataArr[jj][1] + ':genlock|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
									}
									else if (DecodeVideoDataArr[jj][4]=='GENLOCK_SCALING') {
										_genlockMode += DecodeVideoDataArr[jj][1] + ':genlock_scaling|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
									}
									else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED') {
										_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
									}
									else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED_STRETCH') {
										_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch stretch|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
									}
									else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED_CROP') {
										_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch crop|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
									}
									
								}												
							})(i,j);
						}	
						_recv += encode	+ ':' +	decode + ',';
					}
					else{
						_recv = 'NULL';
					}
				}					
			}
			_recv = _recv + '=|=' + _genlockMode;
		}
		else {
			for (var j = 0; j < DecodeVideoDataArr.length; j++) {
				(function(jj){
					if (DecodeVideoDataArr[jj]!=''&&typeof(DecodeVideoDataArr[jj])!='undefined') {
						if (DecodeVideoDataArr[jj][4]==0) {
							_genlockMode += DecodeVideoDataArr[jj][1] + ':genlock|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
						}
						else if (DecodeVideoDataArr[jj][4]=='GENLOCK_SCALING') {
							_genlockMode += DecodeVideoDataArr[jj][1] + ':genlock_scaling|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
						}
						else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED') {
							_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
						}
						else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED_STRETCH') {
							_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch stretch|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
						}
						else if (DecodeVideoDataArr[jj][4]=='FAST_SWITCHED_CROP') {
							_genlockMode += DecodeVideoDataArr[jj][1] + ':fastswitch crop|' 
														+ DecodeVideoDataArr[jj][7] + '|'
														+ DecodeVideoDataArr[jj][8] + '|'
														+ DecodeVideoDataArr[jj][9] + ',';
						}									
					}												
				})(j);
			}
			_recv = 'NULL=|=' + _genlockMode;
		}
	break;
	case 2:
		var encode='',decode;
		var _recv='';
		if (Encode_HdmiAudio_DataArr.length>0) {
			for (var i = 0; i < Encode_HdmiAudio_DataArr.length; i++) {
				if (Encode_HdmiAudio_DataArr[i]!=''&&typeof(Encode_HdmiAudio_DataArr[i])!='undefined') {
					encode = Encode_HdmiAudio_DataArr[i][1];	
					if (Decode_HdmiAudio_DataArr.length>0) {
						decode = '';
						for (var j = 0; j < Decode_HdmiAudio_DataArr.length; j++) {
							(function(ii,jj){
								if (Encode_HdmiAudio_DataArr[ii]!=''&&typeof(Encode_HdmiAudio_DataArr[ii])!='undefined'&&
									Decode_HdmiAudio_DataArr[jj]!=''&&typeof(Decode_HdmiAudio_DataArr[jj])!='undefined') {
									if (Encode_HdmiAudio_DataArr[ii][4]==Decode_HdmiAudio_DataArr[jj][5]) {
										decode += Decode_HdmiAudio_DataArr[jj][1]+'|';
									}
									if (Encode_HdmiAudio_DataArr[ii][4]=='255.255.255.255'){
										decode = 'ALL_RX';								
									}
								}									
							})(i,j);
						}
						_recv += encode	+ ':' +	decode + ',';			
					}
					else{
						_recv = 'NULL';
					}
				}				
			}
		}
	break;
	case 3:
		var encode='',decode;
		var _recv='';
		if (Encode_AnalogAudio_DataArr.length>0) {
			for (var i = 0; i < Encode_AnalogAudio_DataArr.length; i++) {
				if (Encode_AnalogAudio_DataArr[i]!=''&&typeof(Encode_AnalogAudio_DataArr[i])!='undefined') {
					encode = Encode_AnalogAudio_DataArr[i][1];	
					if (Decode_AnalogAudio_DataArr.length>0) {
						decode = '';
						for (var j = 0; j < Decode_AnalogAudio_DataArr.length; j++) {
							(function(ii,jj){
								if (Encode_AnalogAudio_DataArr[ii]!=''&&typeof(Encode_AnalogAudio_DataArr[ii])!='undefined'&&
									Decode_AnalogAudio_DataArr[jj]!=''&&typeof(Decode_AnalogAudio_DataArr[jj])!='undefined') {
									if (Encode_AnalogAudio_DataArr[ii][4]==Decode_AnalogAudio_DataArr[jj][5]) {
										decode += Decode_AnalogAudio_DataArr[jj][1]+'|';
									}
									if (Encode_AnalogAudio_DataArr[ii][4]=='255.255.255.255'){
										decode = 'ALL_RX';								
									}
								}									
							})(i,j);
						}
						_recv += encode	+ ':' +	decode + ',';			
					}
					else{
						_recv = 'NULL';
					}
				}				
			}
		}
	break;
	case 4:
		var encode='',decode;
		var _recv='';
		if (Decode_Rs232_DataArr.length>0) {
			for (var i = 0; i < Decode_Rs232_DataArr.length; i++) {	
				if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
					encode = Decode_Rs232_DataArr[i][1];		
					if (Decode_Rs232_DataArr.length>0) {
						decode = '';				
						for (var j = 0; j < Decode_Rs232_DataArr.length; j++) {
							(function(ii,jj){
								if (Decode_Rs232_DataArr[ii]!=''&&typeof(Decode_Rs232_DataArr[ii])!='undefined'&&
									Decode_Rs232_DataArr[jj]!=''&&typeof(Decode_Rs232_DataArr[jj])!='undefined') {
									if (Decode_Rs232_DataArr[ii][5]==Decode_Rs232_DataArr[jj][2]) {
										decode += Decode_Rs232_DataArr[jj][1]+'|';
									}	
									if (Decode_Rs232_DataArr[ii][5]=='255.255.255.255'){
										decode = 'all';								
									}
									if (Decode_Rs232_DataArr[ii][5]==$('.connectionIP').val()){
										decode = $('.connectionIP').val();								
									}
								}
														
							})(i,j);
						}		
						_recv += encode	+ ':' +	decode + ',';		
					}
					else{
						_recv = 'NULL';
					}
				}				
			}
		}
	break;
	case 5:
		var encode='',decode;
		var _recv='';
		if (Decode_Infrared_DataArr.length>0) {
			for (var i = 0; i < Decode_Infrared_DataArr.length; i++) {	
				if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
					encode = Decode_Infrared_DataArr[i][1];		
					if (Decode_Infrared_DataArr.length>0) {
						decode = '';				
						for (var j = 0; j < Decode_Infrared_DataArr.length; j++) {
							(function(ii,jj){
								if (Decode_Infrared_DataArr[ii]!=''&&typeof(Decode_Infrared_DataArr[ii])!='undefined'&&
									Decode_Infrared_DataArr[jj]!=''&&typeof(Decode_Infrared_DataArr[jj])!='undefined') {
									if (Decode_Infrared_DataArr[ii][5]==Decode_Infrared_DataArr[jj][2]) {
										decode += Decode_Infrared_DataArr[jj][1]+'|';
									}	
									if (Decode_Infrared_DataArr[ii][5]=='255.255.255.255'){
										decode = 'all';								
									}
									if (Decode_Infrared_DataArr[ii][5]==$('.connectionIP').val()){
										decode = $('.connectionIP').val();								
									}
								}
														
							})(i,j);
						}		
						_recv += encode	+ ':' +	decode + ',';	
					}
					else{
						_recv = 'NULL';
					}
				}				
			}
		}
	break;
	}
	return _recv;
}
