$(document).ready(function(){
	$('.IPAV1100ContentBottomLeft li').each(function(e){
		$(this).on('mouseover',function(){
			$(this).css('background-color','#90dae5');
			$('.IPAV1100ContentBottomLeft li:eq('+e+') .IPAV1100ContentBottomLeftNavSecL').css('background-color','#22aabe');
		});
		$(this).on('mouseleave',function(){
			$(this).css('background-color','#c9e6eb');
			$('.IPAV1100ContentBottomLeft li:eq('+e+') .IPAV1100ContentBottomLeftNavSecL').css('background-color','#c9e6eb');
		});
	});
	$('.IPAV1100ContentBottomLeft .IPAV1100ContentBottomLeftNavTitle').each(function(e){
		$(this).on('mousedown',function(){
			if ($('.IPAV1100ContentBottomLeft ul:eq('+e+')').hasClass('IPAV1100ContentBottomLeftUlHide')){
				$('.IPAV1100ContentBottomLeft ul:eq('+e+')').removeClass('IPAV1100ContentBottomLeftUlHide');
				$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','0px');
				$('.IPAV1100ContentBottomLeft .IPAV1100ContentBottomLeftNavTitle:eq('+e+') img').removeClass('IPAV1100ContentBottomLeftNavTitleImg');
			}
			else{
				$('.IPAV1100ContentBottomLeft ul:eq('+e+')').addClass('IPAV1100ContentBottomLeftUlHide');
				$('.IPAV1100ContentBottomLeft .IPAV1100ContentBottomLeftNavTitle:eq('+e+') img').addClass('IPAV1100ContentBottomLeftNavTitleImg');
				switch(e){
				case 0:
					$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','49px');
				break;
				case 1:
					$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','49px');
				break;
				case 2:
					$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','50px');//当IR页面存在时 52 单个RS232 26
				break;
				case 3:
					$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','97px');
				break;
				case 4:
					$('.IPAV1100ContentBottomLeft ul:eq('+e+')').css('height','121px');
				break;
				}
			}			
		});
	});
	// connect function
	$('.connectionToServerBtn').on('click',function(){
		ConnectToServer();
	});
	NavTitleGoToPage();
	
});
var _ip;
var _port;
var GetDataTimer;
function ConnectToServer() {   
	_ip = $('.connectionIP').val();
	_port = $('.connectionPort').val();
	var data;
    if ($('.connectionToServerBtn').html()=='CONNECT') {
        $('.IPAV1100ContentBottomLeftConnectIpBox input').attr('disabled',true);
        $('.connectionPort').attr('disabled',true);
        $('.connectionToServerBtn').html('DISCONNECT');
        data = 'ip='+_ip + '&port=' + _port;
    }
    else if ($('.connectionToServerBtn').html()=='DISCONNECT') {
    	clearInterval(GetDataTimer);
        $('.IPAV1100ContentBottomLeftConnectIpBox input').attr('disabled',false);
        $('.connectionPort').attr('disabled',false);
        $('.connectionToServerBtn').html('CONNECT');
        data = 'data=CloseSocket';
    }

	$.ajax({
        type: "POST",
        url: "common/TcpCommon.php",//"common/TcpCommon.php","db/Socket_Connect.php"
        data: data,
        datatype: "json",
        async:true,
        success: function(rst) {
        // console.log(rst);
            if (rst.indexOf('TcpConnectErr')>0) {
                $('#MessageDisplay').show();
                $('#MessageDisplay .DeviceSendReceiveInfraredContText').html('Unable to connect to Server!');
                $('.IPAV1100ContentBottomLeftConnectIpBox input').attr('disabled',false);
                $('.connectionPort').attr('disabled',false);
                $('.connectionToServerBtn').html('CONNECT');
                CleanArr();
                return;
            }
            else {
            	if (rst=='') {
            		$('#IPA1100VideoWallParameterContTxDrop').html('');
    				$('#IPA1100VideoWallParameterContRxDrop').html('');
            		var videowallX = parseInt($('#VideoWallSizeX').val());
					var videowallY = parseInt($('#VideoWallSizeY').val());
					if (0>=videowallX||videowallX>5) {
						$('#DisplayErrorContent .DeviceSendReceiveInfraredContText').html('Must be a number between 1 and 5');
						$('#DisplayErrorContent').show();
						return;
					}
					$('#IPA1100VideoWallParameterContWallUl').html('');
					$('#IPA1100VideoWallParameterContWallUl').css('width',(videowallX*40-2)+'px');
					for (var j = 0; j < videowallY; j++) {
						PresetDataDetail[j]=[];
						for (var i = 0; i < videowallX; i++) {
							$('#IPA1100VideoWallParameterContWallUl').append('<li>\
																					<div class="IPA1100VideoWallParameterContWallULLIFlag"></div>\
																				</li>');
							PresetDataDetail[j][i]='';
						}
						$('#IPA1100VideoWallParameterContWallUl li:eq('+(videowallY*videowallX+videowallX-1)+')').css('border-right','none');
					}
					VideoWallEventListen(1);
            		CleanArr();
            		GetDeviceData='';

            		return;
            	}
            	GetDeviceData = rst;

            	if (current_page==1||current_page==11) {
            		VideoGetAllJson(rst);
		            AddEventListen(1);
		            AddEventListen(2);
		            var _dataTmp='';
					for (var i = 0; i <DecodeVideoDataArr.length; i++) {
						if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
							_dataTmp+="Video:Decode:"+DecodeVideoDataArr[i][1]+":Default:"
				                +DecodeDetaileDataArr[i][0]+":"
				                +DecodeDetaileDataArr[i][1]+":"
				                +DecodeDetaileDataArr[i][3]+":"
				                +DecodeDetaileDataArr[i][4]+":"
				                +DecodeDetaileDataArr[i][5]+":"
				                +DecodeDetaileDataArr[i][6]+":"
				                +DecodeDetaileDataArr[i][7]+":"
				                +DecodeDetaileDataArr[i][8]+":"
				                +DecodeDetaileDataArr[i][9]+":"
				                +DecodeDetaileDataArr[i][10]+":"
				                +DecodeDetaileDataArr[i][11]+',';
						}
					}
					_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
					GroupAddingDeviceSaveSetting('VideoDecode_Default',_dataTmp);
					_dataTmp=''
					for (var i = 0; i <EncodeVideoDataArr.length; i++) {
						if (EncodeVideoDataArr[i]!=''&&typeof(EncodeVideoDataArr[i])!='undefined') {
							var _connectedDevice='';
							for (var j = 0; j < DecodeVideoDataArr.length; j++) {
								if (DecodeVideoDataArr[j]!=''&&typeof(DecodeVideoDataArr[j])!='undefined') {
									if (DecodeVideoDataArr[j][5]==EncodeVideoDataArr[i][4]) {
										_connectedDevice += DecodeVideoDataArr[j][1]+'|';
									}
									else if ('255.255.255.255'==DecodeVideoDataArr[j][5]){
										_connectedDevice += DecodeVideoDataArr[j][1]+'|';
									}
								}
							}
							if (_connectedDevice!='') 
								_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
							else
								_connectedDevice = 'none';
							_dataTmp+="Video:Encode:"+EncodeVideoDataArr[i][1]+":Default:"
				                +EncodeDetaileDataArr[i][0]+":"
				                +EncodeDetaileDataArr[i][1]+":"
				                +EncodeDetaileDataArr[i][3]+":"
				                +EncodeDetaileDataArr[i][4]+":"
				                +EncodeDetaileDataArr[i][5]+":"
				                +EncodeDetaileDataArr[i][6]+":"
				                +EncodeDetaileDataArr[i][7]+":"
				                +EncodeDetaileDataArr[i][8]+":"
				                +EncodeDetaileDataArr[i][9]+":"
				                +EncodeDetaileDataArr[i][10]+":"
				                +EncodeDetaileDataArr[i][11]+':'+_connectedDevice+',';
						}
					}
					_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
					GroupAddingDeviceSaveSetting('VideoEncode_Default',_dataTmp);
            	}
            	else if (current_page==2) {
            		ReadDataFromFile('firstRecallFromFile=1','PresetRecall');
            		VideoWallGetAllJson(rst);
		            AddEventListen(3);
		            AddEventListen(4);
            	}
		        else if (current_page==3||current_page==12) {
            		HdmiAudioGetAllJson(rst);
	            	AddEventListen(5);
		            AddEventListen(6);
            	}
            	else if (current_page==4||current_page==13) {
            		AnalogAudioGetAllJson(rst);
		            AddEventListen(7);
		            AddEventListen(8);
            	}
            	else if (current_page==5||current_page==14) {
            		Rs232GetAllJson(rst);
		            AddEventListen(9);
		            AddEventListen(10);
            	}
            	else if (current_page==6||current_page==15) {
            		InfraredGetAllJson(rst);
		            AddEventListen(22);
		            AddEventListen(23);
            	}
            	
            	// 备份还原所需 
	            if (firmwareUpdateJsonDataArr!=rst||current_page==8) {
	            	firmwareUpdateJsonDataArr = rst;
	            }
	            
	            GetDataTimer = setInterval(function(){
	            	GetJsonDataInterval();
	            },1000);
            }
        },
        error: function() {
            //alert('Error!');
        }
    });
}
function GetJsonDataInterval(){
	var data = 'ip='+_ip + '&port=' + _port;
	$.ajax({
        type: "POST",
        url: "common/TcpCommon.php",//"common/TcpCommon.php","db/Socket_Connect.php"
        data: data,
        datatype: "json",
        async:true,
        success: function(rst) { 
        // console.log(rst);           
            if (rst.indexOf('TcpConnectErr')>0) {
                $('#MessageDisplay').show();
                $('#MessageDisplay .DeviceSendReceiveInfraredContText').html('Blueriver Server not alive or Invalid Value!');
                $('.IPAV1100ContentBottomLeftConnectIpBox input').attr('disabled',false);
                $('.connectionPort').attr('disabled',false);
                $('.connectionToServerBtn').html('CONNECT');
                clearInterval(GetDataTimer);
                return;
            }
            else {
            	GetDeviceData = rst;
            	if (receiveDataToCheck!=rst) {
	        		receiveDataToCheck = rst;
	        	}
            	if (current_page==1||current_page==11) {
            		VideoGetAllJson(rst);
		            //AddEventListen(1);
		            //AddEventListen(2);
            	}
            	else if (current_page==2) {
            		VideoWallGetAllJson(rst);
		            //AddEventListen(3);
		           // AddEventListen(4);
            	}
		        else if (current_page==3||current_page==12) {
            		HdmiAudioGetAllJson(rst);
	            	//AddEventListen(5);
		            //AddEventListen(6);
            	}
            	else if (current_page==4||current_page==13) {
            		AnalogAudioGetAllJson(rst);
		            //AddEventListen(7);
		            //AddEventListen(8);
            	}
            	else if (current_page==5||current_page==14) {
            		Rs232GetAllJson(rst);
		            //AddEventListen(9);
		            //AddEventListen(10);
            	}
            	else if (current_page==6||current_page==15) {
            		InfraredGetAllJson(rst);
		            //AddEventListen(22);
		            //AddEventListen(23);
            	}
            	else if(current_page==7){
            		firmwareUpdate(rst);
		            AddEventListen(21);
            	}
		        // 备份还原所需 
	            if (firmwareUpdateJsonDataArr!=rst||current_page==8) {
	            	firmwareUpdateJsonDataArr = rst;
	            }
            }
        },
        error: function() {
            //alert('Error!');
        }
    });
}
function ClickToShowOrHide(num) {
	if(_ClickToShowOrHideNum[num] == '0'||_ClickToShowOrHideNum[num] == 'undifine'||_ClickToShowOrHideNum[num] == ''){
		$('.main_left ul:eq(' + num + ')').show();	
		$('.main_left_nav a:eq(' + num + ')').html('-');
		_ClickToShowOrHideNum[num] = '1';
	}
	else if(_ClickToShowOrHideNum[num] == '1'){
		$('.main_left ul:eq(' + num + ')').hide();
		$('.main_left_nav a:eq(' + num + ')').html('+');
		_ClickToShowOrHideNum[num] = '0';
	}
}
function CleanArr(){
	_data.videoswitching_decode_arr = '';
	_data.videoswitching_encode_arr = '';
	_data.Rs232_De_En_arr = '';
	_data.Rs232_En_De_arr = '';
	DecodeVideoWallDataArr=[];
	DecodeDetaileDataArr=[];
	EncodeDetaileDataArr=[];
	EncodeVideoWallDataArr=[];
	DecodeVideoDataArr=[];
	EncodeVideoDataArr=[];
	Decode_HdmiAudio_DataArr=[];
	Encode_HdmiAudio_DataArr=[];
	Decode_AnalogAudio_DataArr=[];
	Encode_AnalogAudio_DataArr=[];
	Decode_Rs232_DataArr=[];
	Encode_Rs232_DataArr=[];
	Decode_Infrared_DataArr=[];
	Encode_Infrared_DataArr=[];
	Rs232IrReceiverDataDetaileDataArr=[];
	Rs232IrSenderDataDetaileDataArr=[];
	// 切换页面需删除已在的设备信息
	// video --------------------------------
	$('.IPAV1100RxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100VideoWallRxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100HdmiAudioRxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100AnalogAudioRxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100Rs232RxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100InfraredRxCont li').each(function(e){
        if (e!=0) {
            $(this).html('');
            $(this).removeClass('deviceBoxHasDevice');
        }
    });
    $('.IPAV1100FirmwareTxCont li').each(function(e){        
        $(this).html('');
        $(this).removeClass('deviceBoxHasDevice');        
    });
    

    

    $('.IPAV1100TxCont li').html('');
    $('.IPAV1100TxCont li').removeClass('deviceBoxHasDevice');

    $('.IPAV1100VideoWallTxCont li').html('');
    $('.IPAV1100VideoWallTxCont li').removeClass('deviceBoxHasDevice');

    $('.IPAV1100HdmiAudioTxCont li').html('');
    $('.IPAV1100HdmiAudioTxCont li').removeClass('deviceBoxHasDevice');

    $('.IPAV1100AnalogAudioTxCont li').html('');
    $('.IPAV1100AnalogAudioTxCont li').removeClass('deviceBoxHasDevice');

    $('.IPAV1100Rs232TxCont li').html('');
    $('.IPAV1100Rs232TxCont li').removeClass('deviceBoxHasDevice');

    $('.IPAV1100InfraredTxCont li').html('');
    $('.IPAV1100InfraredTxCont li').removeClass('deviceBoxHasDevice');
}
// 导航栏点击跳转事件
var _checkVideoWallNum=0;
var _CheckNavClick=0;
function NavTitleGoToPage(){	
	// video -------------------------------	
	$('#VideoSwitchingPage').on('click',function(){
		current_page = 1;
		CleanArr();
		CleanLeftNavStatu(0);
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		ReadDataFromFile('PositionInfoFromFile=1');
		ReadDataFromFile('PositionInfoFromFile=2');
		// $('#VideoGroupSelectRx span').html('Default');
		// $('#VideoGroupSelectTx span').html('Default');
		DeviceGroupRxSelectNum = 1;
		_CheckNavClick=1;
		PageAddGroup('type=11&pagetype=videoswitching&devicetype=rx');
		setTimeout(function(){
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightVideo').show();
			PageLoadingVideoDevice();

			VideoGetAllJson(GetDeviceData);	
			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <DecodeVideoDataArr.length; i++) {
					if (DecodeVideoDataArr[i]!=''&&typeof(DecodeVideoDataArr[i])!='undefined') {
						_dataTmp+="Video:Decode:"+DecodeVideoDataArr[i][1]+":Default:"
			                +DecodeDetaileDataArr[i][0]+":"
			                +DecodeDetaileDataArr[i][1]+":"
			                +DecodeDetaileDataArr[i][3]+":"
			                +DecodeDetaileDataArr[i][4]+":"
			                +DecodeDetaileDataArr[i][5]+":"
			                +DecodeDetaileDataArr[i][6]+":"
			                +DecodeDetaileDataArr[i][7]+":"
			                +DecodeDetaileDataArr[i][8]+":"
			                +DecodeDetaileDataArr[i][9]+":"
			                +DecodeDetaileDataArr[i][10]+":"
			                +DecodeDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#VideoGroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('VideoDecode_Default',_dataTmp);
				_dataTmp=''
				for (var i = 0; i <EncodeVideoDataArr.length; i++) {
					if (EncodeVideoDataArr[i]!=''&&typeof(EncodeVideoDataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < DecodeVideoDataArr.length; j++) {
							if (DecodeVideoDataArr[j]!=''&&typeof(DecodeVideoDataArr[j])!='undefined') {
								if (DecodeVideoDataArr[j][5]==EncodeVideoDataArr[i][4]) {
									_connectedDevice += DecodeVideoDataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==DecodeVideoDataArr[j][5]){
									_connectedDevice += DecodeVideoDataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+EncodeVideoDataArr[i][1]+":Default:"
				               +EncodeDetaileDataArr[i][0]+":"
				               +EncodeDetaileDataArr[i][1]+":"
				               +EncodeDetaileDataArr[i][3]+":"
				               +EncodeDetaileDataArr[i][4]+":"
				               +EncodeDetaileDataArr[i][5]+":"
				               +EncodeDetaileDataArr[i][6]+":"
				               +EncodeDetaileDataArr[i][7]+":"
				               +EncodeDetaileDataArr[i][8]+":"
				               +EncodeDetaileDataArr[i][9]+":"
				               +EncodeDetaileDataArr[i][10]+":"
				               +EncodeDetaileDataArr[i][11]+':'+_connectedDevice+',';						
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#VideoGroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('VideoEncode_Default',_dataTmp);
			},50);
				
		},50);
		$('body').click();
		
	});
	$('#VideoWallPage').on('click',function(){
		DeviceGroupRxSelectNum = 1;
		current_page = 2;
		CleanArr();
		CleanLeftNavStatu(1);
		ReadDataFromFile('PositionInfoFromFile=1');
		ReadDataFromFile('PositionInfoFromFile=2');
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		// $('#VideoWallGroupSelectRx span').html('Default');
		// $('#VideoWallGroupSelectTx span').html('Default');
		setTimeout(function(){
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightVideoWall').show();
			PageLoadingVideoWallDevice();
			
			VideoWallGetAllJson(GetDeviceData);
			
			_checkVideoWallNum=1;
			ReadDataFromFile('firstRecallFromFile=1','PresetRecall');

			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <DecodeVideoWallDataArr.length; i++) {
					if (DecodeVideoWallDataArr[i]!=''&&typeof(DecodeVideoWallDataArr[i])!='undefined') {
						_dataTmp+="VideoWall:Decode:"+DecodeVideoWallDataArr[i][1]+":Default:"
			                +DecodeDetaileDataArr[i][0]+":"
			                +DecodeDetaileDataArr[i][1]+":"
			                +DecodeDetaileDataArr[i][3]+":"
			                +DecodeDetaileDataArr[i][4]+":"
			                +DecodeDetaileDataArr[i][5]+":"
			                +DecodeDetaileDataArr[i][6]+":"
			                +DecodeDetaileDataArr[i][7]+":"
			                +DecodeDetaileDataArr[i][8]+":"
			                +DecodeDetaileDataArr[i][9]+":"
			                +DecodeDetaileDataArr[i][10]+":"
			                +DecodeDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#VideoWallGroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('VideoWallDecode_Default',_dataTmp);
				_dataTmp='';
				for (var i = 0; i <EncodeVideoWallDataArr.length; i++) {
					if (EncodeVideoWallDataArr[i]!=''&&typeof(EncodeVideoWallDataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < DecodeVideoWallDataArr.length; j++) {
							if (DecodeVideoWallDataArr[j]!=''&&typeof(DecodeVideoWallDataArr[j])!='undefined') {
								if (DecodeVideoWallDataArr[j][5]==EncodeVideoWallDataArr[i][4]) {
									_connectedDevice += DecodeVideoWallDataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==DecodeVideoWallDataArr[j][5]){
									_connectedDevice += DecodeVideoWallDataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+EncodeVideoWallDataArr[i][1]+":Default:"
				               +EncodeDetaileDataArr[i][0]+":"
				               +EncodeDetaileDataArr[i][1]+":"
				               +EncodeDetaileDataArr[i][3]+":"
				               +EncodeDetaileDataArr[i][4]+":"
				               +EncodeDetaileDataArr[i][5]+":"
				               +EncodeDetaileDataArr[i][6]+":"
				               +EncodeDetaileDataArr[i][7]+":"
				               +EncodeDetaileDataArr[i][8]+":"
				               +EncodeDetaileDataArr[i][9]+":"
				               +EncodeDetaileDataArr[i][10]+":"
				               +EncodeDetaileDataArr[i][11]+':'+_connectedDevice+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#VideoWallGroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('VideoWallEncode_Default',_dataTmp);
			},50);
				
			
		},50);
		$('body').click();
	});
	// audio --------------------------------
	$('#HdmiAudioRoutingPage').on('click',function(){
		DeviceGroupRxSelectNum = 1;
		current_page = 3;
		CleanArr();
		CleanLeftNavStatu(2);
		ReadDataFromFile('PositionInfoFromFile=3');
		ReadDataFromFile('PositionInfoFromFile=4');
		_CheckNavClick=1;
		PageAddGroup('type=11&pagetype=hdmi_audio&devicetype=rx');
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		// $('#HdmiAudioGroupSelectRx span').html('Default');
		// $('#HdmiAudioGroupSelectTx span').html('Default');
		setTimeout(function(){
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightHdmiAudio').show();
			PageLoadingHdmiAudioDevice();
			
			HdmiAudioGetAllJson(GetDeviceData);

			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <Decode_HdmiAudio_DataArr.length; i++) {
					if (Decode_HdmiAudio_DataArr[i]!=''&&typeof(Decode_HdmiAudio_DataArr[i])!='undefined') {
						_dataTmp+="HdmiAudio:Decode:"+Decode_HdmiAudio_DataArr[i][1]+":Default:"
			                +DecodeDetaileDataArr[i][0]+":"
			                +DecodeDetaileDataArr[i][1]+":"
			                +DecodeDetaileDataArr[i][3]+":"
			                +DecodeDetaileDataArr[i][4]+":"
			                +DecodeDetaileDataArr[i][5]+":"
			                +DecodeDetaileDataArr[i][6]+":"
			                +DecodeDetaileDataArr[i][7]+":"
			                +DecodeDetaileDataArr[i][8]+":"
			                +DecodeDetaileDataArr[i][9]+":"
			                +DecodeDetaileDataArr[i][10]+":"
			                +DecodeDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#HdmiAudioGroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('HdmiAudioDecode_Default',_dataTmp);
				_dataTmp=''
				for (var i = 0; i <Encode_HdmiAudio_DataArr.length; i++) {
					if (Encode_HdmiAudio_DataArr[i]!=''&&typeof(Encode_HdmiAudio_DataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < Decode_HdmiAudio_DataArr.length; j++) {
							if (Decode_HdmiAudio_DataArr[j]!=''&&typeof(Decode_HdmiAudio_DataArr[j])!='undefined') {
								if (Decode_HdmiAudio_DataArr[j][5]==Encode_HdmiAudio_DataArr[i][4]) {
									_connectedDevice += Decode_HdmiAudio_DataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==Decode_HdmiAudio_DataArr[j][5]){
									_connectedDevice += Decode_HdmiAudio_DataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+Encode_HdmiAudio_DataArr[i][1]+":Default:"
				               +EncodeDetaileDataArr[i][0]+":"
				               +EncodeDetaileDataArr[i][1]+":"
				               +EncodeDetaileDataArr[i][3]+":"
				               +EncodeDetaileDataArr[i][4]+":"
				               +EncodeDetaileDataArr[i][5]+":"
				               +EncodeDetaileDataArr[i][6]+":"
				               +EncodeDetaileDataArr[i][7]+":"
				               +EncodeDetaileDataArr[i][8]+":"
				               +EncodeDetaileDataArr[i][9]+":"
				               +EncodeDetaileDataArr[i][10]+":"
				               +EncodeDetaileDataArr[i][11]+':'+_connectedDevice+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#HdmiAudioGroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('HdmiAudioEncode_Default',_dataTmp);
			},50);
				
		},50);
		$('body').click();
	});
	$('#AnalogAudioRoutingPage').on('click',function(){
		DeviceGroupRxSelectNum = 1;
		current_page = 4;
		CleanArr();
		CleanLeftNavStatu(3);
		ReadDataFromFile('PositionInfoFromFile=5');
		ReadDataFromFile('PositionInfoFromFile=6');
		_CheckNavClick=1;
		PageAddGroup('type=11&pagetype=analog_audio&devicetype=rx');
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		// $('#AnalogAudioGroupSelectRx span').html('Default');
		// $('#AnalogAudioGroupSelectTx span').html('Default');
		setTimeout(function(){
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightAnalogAudio').show();
			PageLoadingAnalogAudioDevice();
			
			AnalogAudioGetAllJson(GetDeviceData);

			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <Decode_AnalogAudio_DataArr.length; i++) {
					if (Decode_AnalogAudio_DataArr[i]!=''&&typeof(Decode_AnalogAudio_DataArr[i])!='undefined') {
						_dataTmp+="AnalogAudio:Decode:"+Decode_AnalogAudio_DataArr[i][1]+":Default:"
			                +DecodeDetaileDataArr[i][0]+":"
			                +DecodeDetaileDataArr[i][1]+":"
			                +DecodeDetaileDataArr[i][3]+":"
			                +DecodeDetaileDataArr[i][4]+":"
			                +DecodeDetaileDataArr[i][5]+":"
			                +DecodeDetaileDataArr[i][6]+":"
			                +DecodeDetaileDataArr[i][7]+":"
			                +DecodeDetaileDataArr[i][8]+":"
			                +DecodeDetaileDataArr[i][9]+":"
			                +DecodeDetaileDataArr[i][10]+":"
			                +DecodeDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#AnalogAudioGroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('AnalogAudioDecode_Default',_dataTmp);
				_dataTmp=''
				for (var i = 0; i <Encode_AnalogAudio_DataArr.length; i++) {
					if (Encode_AnalogAudio_DataArr[i]!=''&&typeof(Encode_AnalogAudio_DataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < Decode_AnalogAudio_DataArr.length; j++) {
							if (Decode_AnalogAudio_DataArr[j]!=''&&typeof(Decode_AnalogAudio_DataArr[j])!='undefined') {
								if (Decode_AnalogAudio_DataArr[j][5]==Encode_AnalogAudio_DataArr[i][4]) {
									_connectedDevice += Decode_AnalogAudio_DataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==Decode_AnalogAudio_DataArr[j][5]){
									_connectedDevice += Decode_AnalogAudio_DataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+Encode_AnalogAudio_DataArr[i][1]+":Default:"
				               +EncodeDetaileDataArr[i][0]+":"
				               +EncodeDetaileDataArr[i][1]+":"
				               +EncodeDetaileDataArr[i][3]+":"
				               +EncodeDetaileDataArr[i][4]+":"
				               +EncodeDetaileDataArr[i][5]+":"
				               +EncodeDetaileDataArr[i][6]+":"
				               +EncodeDetaileDataArr[i][7]+":"
				               +EncodeDetaileDataArr[i][8]+":"
				               +EncodeDetaileDataArr[i][9]+":"
				               +EncodeDetaileDataArr[i][10]+":"
				               +EncodeDetaileDataArr[i][11]+':'+_connectedDevice+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#AnalogAudioGroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('AnalogAudioEncode_Default',_dataTmp);
			},50);
				
		},50);
		$('body').click();
	});
	// infrared & rs232 --------------------------
	$('#Rs232RoutingPage').on('click',function(){
		DeviceGroupRxSelectNum = 1;
		current_page = 5;
		CleanArr();
		CleanLeftNavStatu(4);
		ReadDataFromFile('PositionInfoFromFile=9');
		ReadDataFromFile('PositionInfoFromFile=10');
		_CheckNavClick=1;
		PageAddGroup('type=11&pagetype=rs232&devicetype=rx');
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		// $('#Rs232GroupSelectRx span').html('Default');
		// $('#Rs232GroupSelectTx span').html('Default');
		setTimeout(function(){
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightRs232').show();
			PageLoadingRs232Device();			
			Rs232GetAllJson(GetDeviceData);

			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <Decode_Rs232_DataArr.length; i++) {
					if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
						_dataTmp+="Rs232:Decode:"+Decode_Rs232_DataArr[i][1]+":Default:"
			                +Rs232IrReceiverDataDetaileDataArr[i][0]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][1]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][3]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][4]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][5]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][6]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][7]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][8]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][9]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][10]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#Rs232GroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('Rs232Decode_Default',_dataTmp);
				_dataTmp=''
				for (var i = 0; i <Encode_Rs232_DataArr.length; i++) {
					if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < Decode_Rs232_DataArr.length; j++) {
							if (Decode_Rs232_DataArr[j]!=''&&typeof(Decode_Rs232_DataArr[j])!='undefined') {
								if (Decode_Rs232_DataArr[j][2]==Encode_Rs232_DataArr[i][4]) {
									_connectedDevice += Decode_Rs232_DataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==Encode_Rs232_DataArr[j][4]){
									_connectedDevice += Decode_Rs232_DataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+Encode_Rs232_DataArr[i][1]+":Default:"
				               +Rs232IrSenderDataDetaileDataArr[i][0]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][1]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][3]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][4]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][5]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][6]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][7]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][8]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][9]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][10]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][11]+':'+_connectedDevice+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#Rs232GroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('Rs232Encode_Default',_dataTmp);
			},50);
				
		},50);
		$('body').click();
	});
	$('#InfraredRoutingPage').on('click',function(){
		DeviceGroupRxSelectNum = 1;
		current_page = 6;
		CleanArr();
		CleanLeftNavStatu(5);
		ReadDataFromFile('PositionInfoFromFile=7');
		ReadDataFromFile('PositionInfoFromFile=8');
		_CheckNavClick=1;
		PageAddGroup('type=11&pagetype=infrared&devicetype=rx');
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		// $('#InfraredGroupSelectRx span').html('Default');
		// $('#InfraredGroupSelectTx span').html('Default');
		setTimeout(function(){			
			$('.IPAV1100ContentBottomRight').hide();
			$('#BottomRightInfrared').show();
			PageLoadingInfraredDevice();			
			InfraredGetAllJson(GetDeviceData);

			setTimeout(function(){
				var _dataTmp='';
				for (var i = 0; i <Decode_Infrared_DataArr.length; i++) {
					if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
						_dataTmp+="Infrared:Decode:"+Decode_Infrared_DataArr[i][1]+":Default:"
			                +Rs232IrReceiverDataDetaileDataArr[i][0]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][1]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][3]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][4]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][5]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][6]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][7]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][8]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][9]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][10]+":"
			                +Rs232IrReceiverDataDetaileDataArr[i][11]+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#InfraredGroupSelectRx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('InfraredDecode_Default',_dataTmp);
				_dataTmp=''
				for (var i = 0; i <Encode_Infrared_DataArr.length; i++) {
					if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
						var _connectedDevice='';
						for (var j = 0; j < Decode_Infrared_DataArr.length; j++) {
							if (Decode_Infrared_DataArr[j]!=''&&typeof(Decode_Infrared_DataArr[j])!='undefined') {
								if (Decode_Infrared_DataArr[j][2]==Encode_Infrared_DataArr[i][4]) {
									_connectedDevice += Decode_Infrared_DataArr[j][1]+'|';
								}
								else if ('255.255.255.255'==Encode_Infrared_DataArr[j][4]){
									_connectedDevice += Decode_Infrared_DataArr[j][1]+'|';
								}
							}
						}
						if (_connectedDevice!='') 
							_connectedDevice = _connectedDevice.substr(0,_connectedDevice.length-1);
						else
							_connectedDevice = 'none';
						_dataTmp+="Video:Encode:"+Encode_Infrared_DataArr[i][1]+":Default:"
				               +Rs232IrSenderDataDetaileDataArr[i][0]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][1]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][3]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][4]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][5]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][6]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][7]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][8]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][9]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][10]+":"
				               +Rs232IrSenderDataDetaileDataArr[i][11]+':'+_connectedDevice+',';
					}
				}
				_dataTmp = _dataTmp.substr(0,_dataTmp.length-1);
				if ($('#InfraredGroupSelectTx span').html()=='Default') 
					GroupAddingDeviceSaveSetting('InfraredEncode_Default',_dataTmp);
			},50);
				
		},50);
		$('body').click();
	});
	// system management --------------------------------------
	$('#FirmwareUpdatePage').on('click',function(){
		current_page = 7;
		//CleanArr();		
		CleanLeftNavStatu(6);

		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightFirmwareUpdate').show();
		// PageLoadingRs232Device();
		firmwareUpdate(GetDeviceData);
		FirmwareVersionReflesh();
		PageLoadingFirmwareUpdateDevice();
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('body').click();
		// Rs232GetAllJson(GetDeviceData);
	});
	$('#BackupAndRestorePage').on('click',function(){
		current_page = 8;
		CleanArr();		
		CleanLeftNavStatu(7);
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightBackupAndRestore').show();
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('body').click();
	});
	$('#SecurityPage').on('click',function(){
		current_page = 9;
		CleanArr();		
		CleanLeftNavStatu(8);
		$('.IPAV1100ContentBottomRight').hide();
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('#BottomRightSecurity').show();
		$('body').click();
	});
	$('#SystemLogsPage').on('click',function(){
		current_page = 10;
		CleanArr();
		CleanLeftNavStatu(9);
		$('.systemlogTitle').html('');
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightSystemLog').show();
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		ReadDataFromFile('readdata=1');
		readfileTimer = setInterval(function(){
			if (AckDataReadSystemlog!='') {
				clearInterval(readfileTimer);				
				GetSystemLogData(AckDataReadSystemlog);
				AckDataReadSystemlog = '';
				SystemLogPageReload();
			}
		},500);
		$('body').click();
		
	});
	// routing table ---------------------------- 
	$('#VideoRoutingTablePage').on('click',function(){
		current_page = 11;
		CleanArr();	
		CleanLeftNavStatu(10);
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightVideoRouting').show();
		VideoGetAllJson(GetDeviceData);		
		GetVideoRouting(videoRoutingTitleSelect);
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('body').click();
	});
	$('#HdmiAudioRoutingTablePage').on('click',function(){
		current_page = 12;
		CleanArr();	
		CleanLeftNavStatu(11);
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightHdmiAudioRouting').show();
		HdmiAudioGetAllJson(GetDeviceData);
		GetHdmiAudioRouting(HdmiAudioRoutingTitleSelect);
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('body').click();
	});
	$('#AnalogAudioRoutingTablePage').on('click',function(){
		current_page = 13;
		CleanArr();	
		CleanLeftNavStatu(12);
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightAnalogAudioRouting').show();
		AnalogAudioGetAllJson(GetDeviceData);
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		GetAnalogAudioRouting(AnalogAudioRoutingTitleSelect);
		$('body').click();
	});
	$('#Rs232RoutingTablePage').on('click',function(){
		current_page = 14;
		CleanArr();	
		CleanLeftNavStatu(13);
		$('.IPAV1100ContentBottomRight').hide();
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		$('#BottomRightRs232Routing').show();
		Rs232GetAllJson(GetDeviceData);
		GetRs232Routing(Rs232RoutingTitleSelect);
		$('body').click();
	});
	$('#InfraredRoutingTablePage').on('click',function(){
		current_page = 15;
		CleanArr();	
		CleanLeftNavStatu(14);
		$('.IPAV1100ContentBottomRight').hide();
		$('#BottomRightInfraredRouting').show();
		InfraredGetAllJson(GetDeviceData);
		$('#VideoRoutingSelectOption').hide();
		$('#HdmiAudioRoutingSelectOption').hide();
		$('#AnalogAudioRoutingSelectOption').hide();
		$('#Rs232RoutingSelectOption').hide();
		$('#InfraredRoutingSelectOption').hide();
		GetInfraredRouting(Rs232RoutingTitleSelect);
		$('body').click();
	});
}
// 清楚左侧菜单状态显示
function CleanLeftNavStatu(num){
	$('.IPAV1100ContentBottomLeft li').removeClass('LeftClickHoverStatu');
	$('.IPAV1100ContentBottomLeft li .IPAV1100ContentBottomLeftNavSecL').removeClass('LeftTextClickHoverStatu');

	$('.IPAV1100ContentBottomLeft li:eq('+num+')').addClass('LeftClickHoverStatu');
	$('.IPAV1100ContentBottomLeft li:eq('+num+') .IPAV1100ContentBottomLeftNavSecL').addClass('LeftTextClickHoverStatu');
}
// 注册事件
var VideoDecoderToChangePosition=0;
var VideoEncoderToChangePosition=0;
var DecoderToChangePositionAfterNum;
var DecoderToChangePositionNowNum;
var _DeviceTxFirmwareSettingClick = 0;
// 升级页面参数
var _firmwareUpdateClickCheck=0;
function AddEventListen(num){
	// $('.DeviceBoxNavTopSetting').unbind('mouseover');
	// $('.DeviceBoxNavTopSetting').unbind('mouseleave');
	// $('.DeviceBoxNavTopSetting').on('mouseover',function(){
	// 	_DeviceRxSetting = 1;
	// });
	// $('.DeviceBoxNavTopSetting').on('mouseleave',function(){
	// 	_DeviceRxSetting = 0;
	// }); 
	switch(num){
		case 1:// video decoder 			
			$('.IPAV1100RxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100RxCont li .DeviceBoxNavTopStop').unbind('mousedown');
			$('.IPAV1100RxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100RxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100RxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100RxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100RxCont li').unbind('mousedown');
			$('.IPAV1100RxCont li').unbind('mouseup');
			$('.IPAV1100RxCont li').unbind('mouseleave');
			$('.IPAV1100RxCont li').unbind('mouseover');
			$('.IPAV1100RxCont li').each(function(e){
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){					
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');						
						var switchType;
			            if (DecodeVideoDataArr[_deviceNumBer-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(DecodeVideoDataArr[_deviceNumBer-1][4]=='FAST_SWITCHED'||DecodeVideoDataArr[_deviceNumBer-1][4]=='FAST_SWITCHED_CROP'||DecodeVideoDataArr[_deviceNumBer-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(DecodeVideoDataArr[_deviceNumBer-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(DecodeVideoDataArr[_deviceNumBer-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(DecodeVideoDataArr[_deviceNumBer-1][2]+'-'+switchType);
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100RxCont = $('.IPAV1100RxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#VideoConfigurationTxDevice').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').hide();

					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#VideoConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');							
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').addClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').addClass('RxDeviceSetting');
						}
						else {
							$('#VideoConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
							// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').removeClass('RxDeviceSetting');
							$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').removeClass('RxDeviceSetting');
						}

						$('#VideoConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						CheckBoxIsOverflow(1,1);
						// -----------------------
						
						// -----------------------
						$('#VideoConfigurationRxDevice').show();
						_DeviceRxSettingClick=1;
						DecoderConfigurationDeviceNumb = e;
						MouseoverRxToHide = 1;
						DecoderSettingConfigurationGetJsonData(e);
						DecoderConfigurationSettingBox();
						if ($('#VideoGroupSelectRx span').html()=='Default') {
							$('#VideoRemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=videoswitching&devicetype=rx');
						}
						else {
							$('#VideoRemoveFromGroupRx').html('Remove from Group');
						}						
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#VideoConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');							
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').addClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').addClass('RxDeviceSetting');
							}
							else {
								$('#VideoConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
								// $('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').removeClass('RxDeviceSetting');
								$('#VideoConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').removeClass('RxDeviceSetting');
							}
							$('#VideoConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							$('#VideoConfigurationRxDevice').show();
							_DeviceRxSettingClick=0;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							DecoderConfigurationSettingBox();
							return;
						}
						$('#VideoConfigurationRxDevice').hide();
						
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){
					if (e!=0) {						
						if ($('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
							var _arrRx = _data.videoswitching_decode_arr.split(',');
							sendCommand('data=leave '+_arrRx[e-1]+':HDMI:0');
						}
					}
				});
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#VideoRxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){	
					if (e==0) return;
					if ($('.IPAV1100RxCont li:eq('+e+')').html()!='') {
						backMouseUpOrDown = 1;
						$('.DeviceClickToMove').html($('.IPAV1100RxCont li:eq('+e+')').html());
						VideoDecoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;	
						CheckDeviceRouting(DecodeVideoDataArr[e-1][5],'video_switching');
					}
				});
				$(this).on('mouseup',function(){	
					if (e==0) return;
					if ($('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;				
					//if ($('#VideoGroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {						
							
							DecoderToChangePositionNowNum = e;
							if (DecodeVideoDataArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeVideoDataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								DecodeVideoDataArr[DecoderToChangePositionNowNum-1] = DecodeVideoDataArr[DecoderToChangePositionAfterNum-1];
								DecodeVideoDataArr[DecoderToChangePositionAfterNum-1] = '';
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = DecodeVideoDataArr[DecoderToChangePositionAfterNum-1];
								DecodeVideoDataArr[DecoderToChangePositionAfterNum-1] = DecodeVideoDataArr[DecoderToChangePositionNowNum-1];
								DecodeVideoDataArr[DecoderToChangePositionNowNum-1] = b;
								var c = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								c = $('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;


					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100RxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}							
					// }	
					AddEventListen(1);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0&&_DeviceTxSettingClick==1){
						$('#VideoConfigurationRxDevice').hide();
						_DeviceRxSettingClick = 0;
					}
					
				});
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
				});
				$('.IPAV1100RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;
					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						
						DecoderChannelNum = e;
					}			
				});
			});				
		break;
		case 2:// video encoder
			
			$('.IPAV1100TxCont li .DeviceBoxNavTopSetting').unbind('mousedown');	
			$('.IPAV1100TxCont li .DeviceBoxNavTopStop').unbind('mousedown');	
			$('.IPAV1100TxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100TxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100TxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100TxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100TxCont li').unbind('mousedown');
			$('.IPAV1100TxCont li').unbind('mouseup');
			$('.IPAV1100TxCont li').unbind('mouseover');
			$('.IPAV1100TxCont li').unbind('mouseleave');
			$('.IPAV1100TxCont li').each(function(e){
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(EncodeVideoDataArr[_deviceNumBer][2]);
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100TxCont = $('.IPAV1100TxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#VideoConfigurationRxDevice').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').hide();
					$('#VideoConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').hide();
					_DeviceRxSettingClick=0;
					
					var _IPAV1100TxCont = parseInt($('.IPAV1100TxContScrool').height())+12;
					var _y = parseInt(_IPAV1100TxCont/120);
					//console.log(e,_IPAV1100TxContX,_y);
					if (_DeviceTxSettingClick==0) {
						$('#VideoConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#VideoConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#VideoConfigurationTxDevice').show();
						CheckBoxIsOverflow(2,1);//
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						EncoderConfigurationSettingBox();
						if ($('#VideoGroupSelectTx span').html()=='Default') {
							$('#VideoRemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=videoswitching&devicetype=tx');
						}
						else {
							$('#VideoRemoveFromGroupTx').html('Remove from Group');
						}
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#VideoConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#VideoConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#VideoConfigurationTxDevice').show();
							CheckBoxIsOverflow(2,1);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							EncoderConfigurationSettingBox();
							return;
						}
						$('#VideoConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.videoswitching_encode_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':HDMI:0');
					}
					else {
						var _arrRx = _data.videoswitching_encode_arr.split(',');		
						sendCommand('data=start '+_arrRx[e]+':HDMI:0');
					}
					return;
				});
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#VideoTxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($('.IPAV1100TxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100TxCont li:eq('+e+')').html());
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(EncodeVideoDataArr[e][4],'video_switching');		
						MouseUpOrDown = 1;			
					}						
				});
				$(this).on('mouseup',function(){
					if ($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#VideoGroupSelectTx span').html()=='Default') {						
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							if ($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
							DecoderToChangePositionNowNum = e;
							if (EncodeVideoDataArr[DecoderToChangePositionNowNum]==''||typeof(EncodeVideoDataArr[DecoderToChangePositionNowNum])=='undefined') {
								EncodeVideoDataArr[DecoderToChangePositionNowNum] = EncodeVideoDataArr[DecoderToChangePositionAfterNum];
								EncodeVideoDataArr[DecoderToChangePositionAfterNum] = '';
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = EncodeVideoDataArr[DecoderToChangePositionAfterNum];
								EncodeVideoDataArr[DecoderToChangePositionAfterNum] = EncodeVideoDataArr[DecoderToChangePositionNowNum];
								EncodeVideoDataArr[DecoderToChangePositionNowNum] = b;
								var c = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(2);	
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#VideoConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {						
						backMouseoverRx = 1;
						EncoderChannelNum = e;
					}			
				});
				
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
			});
			
		break;
		case 3:// video wall decoder 
			
			$('.IPAV1100VideoWallRxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100VideoWallRxCont li .DeviceBoxNavTopStop').unbind('mousedown');	
			$('.IPAV1100VideoWallRxCont li .DeviceBoxBottom').unbind('mousedown');	
			$('.IPAV1100VideoWallRxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100VideoWallRxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100VideoWallRxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100VideoWallRxCont li').unbind('mousedown');
			$('.IPAV1100VideoWallRxCont li').unbind('mouseup');
			$('.IPAV1100VideoWallRxCont li').unbind('mouseover');
			$('.IPAV1100VideoWallRxCont li').unbind('mouseleave');
			$('.IPAV1100VideoWallRxCont li').each(function(e){
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						var switchType;
			            if (DecodeVideoWallDataArr[e-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(DecodeVideoWallDataArr[e-1][4]=='FAST_SWITCHED'||DecodeVideoWallDataArr[e-1][4]=='FAST_SWITCHED_CROP'||DecodeVideoWallDataArr[e-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(DecodeVideoWallDataArr[e-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(DecodeVideoWallDataArr[e-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(DecodeVideoWallDataArr[e-1][2]+'-'+switchType);
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					$('#VideoWallRemoveFromWall').hide();
					var _IPAV1100RxCont = $('.IPAV1100VideoWallRxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#VideoWallConfigurationTxDevice').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').hide();

					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#VideoWallConfigurationTxDevice').hide();
					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#VideoWallConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').addClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').addClass('RxDeviceSetting');
						}
						else {
							$('#VideoWallConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
							// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').removeClass('RxDeviceSetting');
							$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').removeClass('RxDeviceSetting');
						}
						
						$('#VideoWallConfigurationRxDevice').css('top',317+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						CheckBoxIsOverflow(3,3);
						$('#VideoWallConfigurationRxDevice').show();
						_DeviceRxSettingClick=1;
						MouseoverRxToHide = 1;
						DecoderConfigurationDeviceNumb = e;
						DecoderSettingConfigurationGetJsonData(e);
						DecoderConfigurationSettingBox();
						if ($('#VideoWallGroupSelectRx span').html()=='Default') {
							$('#VideoWallRemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=videoswitching&devicetype=rx');
						}
						else {
							$('#VideoWallRemoveFromGroupRx').html('Remove from Group');
						}
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#VideoWallConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').addClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').addClass('RxDeviceSetting');
							}
							else {
								$('#VideoWallConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(5)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
								// $('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(11)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(12)').removeClass('RxDeviceSetting');
								$('#VideoWallConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(13)').removeClass('RxDeviceSetting');
							}
						
							$('#VideoWallConfigurationRxDevice').css('top',317+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							CheckBoxIsOverflow(3,3);
							$('#VideoWallConfigurationRxDevice').show();
							_DeviceRxSettingClick=1;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							DecoderConfigurationSettingBox();
							return;
						}
						$('#VideoWallConfigurationRxDevice').hide();
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){
					if (e!=0) {						
						if ($('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
							var _arrRx = _data.videoswitching_decode_arr.split(',');
							sendCommand('data=leave '+_arrRx[e-1]+':HDMI:0');
						}
					}
				});
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#VideoWallRxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){		
					if (e==0) return;					
					if ($('.IPAV1100VideoWallRxCont li:eq('+e+')').html()!='') {
						backMouseUpOrDown = 1;	
						VideoWallDecoderDrop = 1;
						DecoderChannelNum = e;
						$('.DeviceClickToMove').html($('.IPAV1100VideoWallRxCont li:eq('+e+')').html());
						VideoDecoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(DecodeVideoWallDataArr[e-1][5],'video_wall');
					}
						
				});
				$(this).on('mouseup',function(){
					VideoWallDecoderDrop = 0;
					if (e==0) return;
					if ($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#VideoWallGroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {
							
							DecoderToChangePositionNowNum = e;
							if (DecodeVideoWallDataArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeVideoWallDataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								DecodeVideoWallDataArr[DecoderToChangePositionNowNum-1] = DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1];
								DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1] = '';
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1];
								DecodeVideoWallDataArr[DecoderToChangePositionAfterNum-1] = DecodeVideoWallDataArr[DecoderToChangePositionNowNum-1];
								DecodeVideoWallDataArr[DecoderToChangePositionNowNum-1] = b;
								var c = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								c = $('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		if ($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			b = $('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100VideoWallRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(3);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0&&_DeviceRxSettingClick==1){
						$('#VideoWallConfigurationRxDevice').hide();
						console.log(11);
						_DeviceRxSettingClick = 0;
					}

				});
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide = 0;
				});
				$('.IPAV1100VideoWallRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
					console.log(123);
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						DecoderChannelNum = e;
					}
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;

					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();
					}
				});
			});			
		break;
		case 4:// video wall encoder
			
			$('.IPAV1100VideoWallTxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100VideoWallTxCont li .DeviceBoxNavTopStop').unbind('mousedown');	
			$('.IPAV1100VideoWallTxCont li .DeviceBoxBottom').unbind('mousedown');	
			$('.IPAV1100VideoWallTxCont li .DeviceBoxNavTopLocked').unbind('mousedown');	
			$('.IPAV1100VideoWallTxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100VideoWallTxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100VideoWallTxCont li').unbind('mousedown');
			$('.IPAV1100VideoWallTxCont li').unbind('mouseup');
			$('.IPAV1100VideoWallTxCont li').unbind('mouseleave');	
			$('.IPAV1100VideoWallTxCont li').unbind('mouseover');	
			$('.IPAV1100VideoWallTxCont li').each(function(e){
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(EncodeVideoWallDataArr[e][2]);
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100TxCont = $('.IPAV1100VideoWallTxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					$('#VideoWallConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#VideoWallConfigurationRxDevice').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGenlockScaling').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitch').hide();
					$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightFastSwitchNav').hide();
					_IPAV1100TxCont = parseInt($('.IPAV1100VideoWallTxContScrool').height())+12;
					var _y = parseInt(_IPAV1100TxCont/120);
					$('#VideoWallConfigurationRxDevice').hide();
					_DeviceRxSettingClick=0;
					if (_DeviceTxSettingClick==0) {
						$('#VideoWallConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#VideoWallConfigurationTxDevice').css('top',523+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#VideoWallConfigurationTxDevice').show();
						CheckBoxIsOverflow(4,3);
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						EncoderConfigurationSettingBox();
						if ($('#VideoWallGroupSelectTx span').html()=='Default') {
							$('#VideoWallRemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=videoswitching&devicetype=tx');
						}
						else {
							$('#VideoWallRemoveFromGroupTx').html('Remove from Group');
						}
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#VideoWallConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#VideoWallConfigurationTxDevice').css('top',523+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#VideoWallConfigurationTxDevice').show();
							CheckBoxIsOverflow(4,3);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							EncoderConfigurationSettingBox();
							return;
						}
						$('#VideoWallConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.videoswitching_encode_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':HDMI:0');
					}
					else {
						var _arrRx = _data.videoswitching_encode_arr.split(',');		
						sendCommand('data=start '+_arrRx[e]+':HDMI:0');
					}
					return;
				});
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#VideoWallTxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($('.IPAV1100VideoWallTxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100VideoWallTxCont li:eq('+e+')').html());
						MouseUpOrDown = 1;
						EncoderChannelNum = e;
						// VideoWallTxDeviceID = e;
						VideoWallEncoderDrop = 1;
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(EncodeVideoWallDataArr[e][4],'video_wall');	
					}
						
				});
				$(this).on('mouseup',function(){
					VideoWallEncoderDrop = 0;
					if ($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#VideoWallGroupSelectTx span').html()=='Default') {
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							
							DecoderToChangePositionNowNum = e;
							if (EncodeVideoWallDataArr[DecoderToChangePositionNowNum]==''||typeof(EncodeVideoWallDataArr[DecoderToChangePositionNowNum])=='undefined') {
								
								EncodeVideoWallDataArr[DecoderToChangePositionNowNum] = EncodeVideoWallDataArr[DecoderToChangePositionAfterNum];
								EncodeVideoWallDataArr[DecoderToChangePositionAfterNum] = '';
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = EncodeVideoWallDataArr[DecoderToChangePositionAfterNum];
								EncodeVideoWallDataArr[DecoderToChangePositionAfterNum] = EncodeVideoWallDataArr[DecoderToChangePositionNowNum];
								EncodeVideoWallDataArr[DecoderToChangePositionNowNum] = b;
								var c = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			b = $('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100VideoWallTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(4);	
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#VideoWallConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100VideoWallTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						backMouseoverRx = 1;
						
						EncoderChannelNum = e;
					}
				});
			});
			
		break;
		case 5:// hdmi audio decoder
			
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTopStop').unbind('mousedown');		
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100HdmiAudioRxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100HdmiAudioRxCont li').unbind('mousedown');
			$('.IPAV1100HdmiAudioRxCont li').unbind('mouseup');
			$('.IPAV1100HdmiAudioRxCont li').unbind('mouseover');
			$('.IPAV1100HdmiAudioRxCont li').unbind('mouseleave');
			$('.IPAV1100HdmiAudioRxCont li').each(function(e){
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						var switchType;
			            if (Decode_HdmiAudio_DataArr[e-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(Decode_HdmiAudio_DataArr[e-1][4]=='FAST_SWITCHED'||Decode_HdmiAudio_DataArr[e-1][4]=='FAST_SWITCHED_CROP'||Decode_HdmiAudio_DataArr[e-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(Decode_HdmiAudio_DataArr[e-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(Decode_HdmiAudio_DataArr[e-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Decode_HdmiAudio_DataArr[e-1][2]+'-'+switchType);
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100RxCont = $('.IPAV1100HdmiAudioRxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#HdmiAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#HdmiAudioConfigurationTxDevice').hide();
					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#HdmiAudioConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							
							// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
							
						}
						else {
							$('#HdmiAudioConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							
							// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
							$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
						}
						$('#HdmiAudioConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						$('#HdmiAudioConfigurationRxDevice').show();
						CheckBoxIsOverflow(5,0);
						_DeviceRxSettingClick=1;
						MouseoverRxToHide = 1;
						DecoderConfigurationDeviceNumb = e;
						DecoderSettingConfigurationGetJsonData(e);
						DecoderConfigurationSettingBox();
						if ($('#HdmiAudioGroupSelectRx span').html()=='Default') {
							$('#HdmiAudioRemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=hdmi_audio&devicetype=rx');
						}
						else {
							$('#HdmiAudioRemoveFromGroupRx').html('Remove from Group');
						}
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#HdmiAudioConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								
								// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
								
							}
							else {
								$('#HdmiAudioConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								
								// $('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
								$('#HdmiAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
							}
							$('#HdmiAudioConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							$('#HdmiAudioConfigurationRxDevice').show();
							CheckBoxIsOverflow(5,0);
							_DeviceRxSettingClick=1;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							DecoderConfigurationSettingBox();
							return;
						}
						$('#HdmiAudioConfigurationRxDevice').hide();
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){
					if (e!=0) {						
						if ($('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
							var _arrRx = _data.videoswitching_decode_arr.split(',');
							sendCommand('data=leave '+_arrRx[e-1]+':HDMI_AUDIO:0');
						}
					}
				});
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#HdmiAudioRxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if (e==0) return;
					if ($('.IPAV1100HdmiAudioRxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100HdmiAudioRxCont li:eq('+e+')').html());
						backMouseUpOrDown = 1;	
						VideoDecoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Decode_HdmiAudio_DataArr[e-1][5],'hdmi_audio');
					}
						
				});
				$(this).on('mouseup',function(){
					if (e==0) return;
					if ($('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#HdmiAudioGroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {
							
							DecoderToChangePositionNowNum = e;
							if (Decode_HdmiAudio_DataArr[DecoderToChangePositionNowNum-1]==''||typeof(Decode_HdmiAudio_DataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								Decode_HdmiAudio_DataArr[DecoderToChangePositionNowNum-1] = Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1] = '';
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum-1] = Decode_HdmiAudio_DataArr[DecoderToChangePositionNowNum-1];
								Decode_HdmiAudio_DataArr[DecoderToChangePositionNowNum-1] = b;
								var c = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								c = $('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;


					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100HdmiAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}	
					// }
					AddEventListen(5);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0){
						$('#HdmiAudioConfigurationRxDevice').hide();
						_DeviceRxSettingClick = 0;
					}						
				});
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
				});
				$('.IPAV1100HdmiAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide = 0;
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						//backMouseUpOrDown = 1;
						DecoderChannelNum = e;
					}
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;
					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});
			});
				
		break;
		case 6:// hdmi audio encoder
			
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTopStop').unbind('mousedown');		
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100HdmiAudioTxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100HdmiAudioTxCont li').unbind('mousedown');
			$('.IPAV1100HdmiAudioTxCont li').unbind('mouseup');
			$('.IPAV1100HdmiAudioTxCont li').unbind('mouseleave');
			$('.IPAV1100HdmiAudioTxCont li').unbind('mouseover');
			$('.IPAV1100HdmiAudioTxCont li').each(function(e){
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Encode_HdmiAudio_DataArr[e][2]);
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100TxCont = $('.IPAV1100HdmiAudioTxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					_IPAV1100TxCont = parseInt($('.IPAV1100TxContScrool').height())+12;
					var _y = parseInt(_IPAV1100TxCont/120);
					$('#HdmiAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#HdmiAudioConfigurationRxDevice').hide();
					_DeviceRxSettingClick=0;
					if (_DeviceTxSettingClick==0) {
						$('#HdmiAudioConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#HdmiAudioConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#HdmiAudioConfigurationTxDevice').show();
						CheckBoxIsOverflow(6,0);
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						EncoderConfigurationSettingBox();
						if ($('#HdmiAudioGroupSelectTx span').html()=='Default') {
							$('#HdmiAudioRemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=hdmi_audio&devicetype=tx');
						}
						else {
							$('#HdmiAudioRemoveFromGroupTx').html('Remove from Group');
						}
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#HdmiAudioConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#HdmiAudioConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#HdmiAudioConfigurationTxDevice').show();
							CheckBoxIsOverflow(6,0);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							EncoderConfigurationSettingBox();
							return;
						}
						$('#HdmiAudioConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.videoswitching_encode_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':HDMI_AUDIO:0');
					}
					else {
						var _arrRx = _data.videoswitching_encode_arr.split(',');		
						sendCommand('data=start '+_arrRx[e]+':HDMI_AUDIO:0');
					}
					return;
				});
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#HdmiAudioTxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($(this).html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100HdmiAudioTxCont li:eq('+e+')').html());
						MouseUpOrDown = 1;
						EncoderChannelNum = e;
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Encode_HdmiAudio_DataArr[e][4],'hdmi_audio');
					}
				});						
				$(this).on('mouseup',function(){
					if ($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;		
					//if ($('#HdmiAudioGroupSelectTx span').html()=='Default') {
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							
							DecoderToChangePositionNowNum = e;
							if (Encode_HdmiAudio_DataArr[DecoderToChangePositionNowNum]==''||typeof(Encode_HdmiAudio_DataArr[DecoderToChangePositionNowNum])=='undefined') {
								
								Encode_HdmiAudio_DataArr[DecoderToChangePositionNowNum] = Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum];
								Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum] = '';
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum];
								Encode_HdmiAudio_DataArr[DecoderToChangePositionAfterNum] = Encode_HdmiAudio_DataArr[DecoderToChangePositionNowNum];
								Encode_HdmiAudio_DataArr[DecoderToChangePositionNowNum] = b;
								var c = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100HdmiAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }			
					AddEventListen(6);
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#HdmiAudioConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100HdmiAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						backMouseoverRx = 1;
						EncoderChannelNum = e;
					}
				});
			});
		break;
		case 7:// analog audio decoder
			
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTopSetting').unbind('mousedown');	
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTopStop').unbind('mousedown');
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTopLocked').unbind('mousedown');	
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTopSetting').unbind('mouseover');	
			$('.IPAV1100AnalogAudioRxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');	
			$('.IPAV1100AnalogAudioRxCont li').unbind('mousedown');
			$('.IPAV1100AnalogAudioRxCont li').unbind('mouseup');
			$('.IPAV1100AnalogAudioRxCont li').unbind('mouseover');
			$('.IPAV1100AnalogAudioRxCont li').unbind('mouseleave');
			$('.IPAV1100AnalogAudioRxCont li').each(function(e){
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						var switchType;
			            if (Decode_AnalogAudio_DataArr[e-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(Decode_AnalogAudio_DataArr[e-1][4]=='FAST_SWITCHED'||Decode_AnalogAudio_DataArr[e-1][4]=='FAST_SWITCHED_CROP'||Decode_AnalogAudio_DataArr[e-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(Decode_AnalogAudio_DataArr[e-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(Decode_AnalogAudio_DataArr[e-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Decode_AnalogAudio_DataArr[e-1][2]+'-'+switchType);
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100RxCont = $('.IPAV1100AnalogAudioRxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#AnalogAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#AnalogAudioConfigurationTxDevice').hide();
					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#AnalogAudioConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							
							// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
						}
						else {
							$('#AnalogAudioConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
							// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							
							// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
							$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
						}
						$('#AnalogAudioConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						$('#AnalogAudioConfigurationRxDevice').show();
						CheckBoxIsOverflow(7,0);
						_DeviceRxSettingClick=1;
						MouseoverRxToHide = 1;
						DecoderConfigurationDeviceNumb = e;
						DecoderSettingConfigurationGetJsonData(e);
						DecoderConfigurationSettingBox();
						if ($('#AnalogAudioGroupSelectRx span').html()=='Default') {
							$('#AnalogAudioRemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=analog_audio&devicetype=rx');
						}
						else {
							$('#AnalogAudioRemoveFromGroupRx').html('Remove from Group');
						}
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#AnalogAudioConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								
								// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').addClass('RxDeviceSetting');
							}
							else {
								$('#AnalogAudioConfigurationRxDevice').css('left',200+parseInt(e%_IPAV1100RxContX)*210+'px');
								// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								
								// $('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(4)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
								$('#AnalogAudioConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(10)').removeClass('RxDeviceSetting');
							}
							$('#AnalogAudioConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							$('#AnalogAudioConfigurationRxDevice').show();
							CheckBoxIsOverflow(7,0);
							_DeviceRxSettingClick=1;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							DecoderConfigurationSettingBox();
							return;
						}
						$('#AnalogAudioConfigurationRxDevice').hide();
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){
					if (e!=0) {						
						if ($('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
							var _arrRx = _data.videoswitching_decode_arr.split(',');
							sendCommand('data=leave '+_arrRx[e-1]+':AUDIO:0');
						}
					}
				});
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#AnalogAudioRxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if (e==0) return;
					if ($('.IPAV1100AnalogAudioRxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100AnalogAudioRxCont li:eq('+e+')').html());
						VideoDecoderToChangePosition = 1;						
						backMouseUpOrDown = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Decode_AnalogAudio_DataArr[e-1][5],'analog_audio');
					}
						
				});
				$(this).on('mouseup',function(){
					if (e==0) return;
					if ($('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#AnalogAudioGroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {
							
							DecoderToChangePositionNowNum = e;
							if (Decode_AnalogAudio_DataArr[DecoderToChangePositionNowNum-1]==''||typeof(Decode_AnalogAudio_DataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								Decode_AnalogAudio_DataArr[DecoderToChangePositionNowNum-1] = Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1] = '';
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum-1] = Decode_AnalogAudio_DataArr[DecoderToChangePositionNowNum-1];
								Decode_AnalogAudio_DataArr[DecoderToChangePositionNowNum-1] = b;
								var c = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionNowNum-1] = DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1];
								DecodeDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								_data.videoswitching_decode_arr = changeDeviceIDArrPosition(_data.videoswitching_decode_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								c = $('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;


					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100AnalogAudioRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}	
					// }
					AddEventListen(7);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0){
						$('#AnalogAudioConfigurationRxDevice').hide();
						_DeviceRxSettingClick = 0;
					}
						
				});
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
				});
				$('.IPAV1100AnalogAudioRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide = 0;
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						DecoderChannelNum = e;
					}
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;
					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});
			});						
		break;
		case 8:// analog audio encoder
			
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTopSetting').unbind('mousedown');		
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTopStop').unbind('mousedown');
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxBottom').unbind('mousedown');
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTopSetting').unbind('mouseover');	
			$('.IPAV1100AnalogAudioTxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100AnalogAudioTxCont li').unbind('mousedown');
			$('.IPAV1100AnalogAudioTxCont li').unbind('mouseup');
			$('.IPAV1100AnalogAudioTxCont li').unbind('mouseleave');
			$('.IPAV1100AnalogAudioTxCont li').unbind('mouseover');
			$('.IPAV1100AnalogAudioTxCont li').each(function(e){
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Encode_AnalogAudio_DataArr[e][2]);
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100TxCont = $('.IPAV1100AnalogAudioTxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					_IPAV1100TxCont = parseInt($('.IPAV1100TxContScrool').height())+12;
					$('#AnalogAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					var _y = parseInt(_IPAV1100TxCont/120);
					$('#AnalogAudioConfigurationRxDevice').hide();
					_DeviceRxSettingClick=0;
					if (_DeviceTxSettingClick==0) {
						$('#AnalogAudioConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#AnalogAudioConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#AnalogAudioConfigurationTxDevice').show();
						CheckBoxIsOverflow(8,0);
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						EncoderConfigurationSettingBox();
						if ($('#AnalogAudioGroupSelectTx span').html()=='Default') {
							$('#AnalogAudioRemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=analog_audio&devicetype=tx');
						}
						else {
							$('#AnalogAudioRemoveFromGroupTx').html('Remove from Group');
						}
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#AnalogAudioConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#AnalogiAudioConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#AnalogAudioConfigurationTxDevice').show();
							CheckBoxIsOverflow(8,0);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							EncoderConfigurationSettingBox();
							return;
						}
						$('#AnalogAudioConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.videoswitching_encode_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':AUDIO:0');
					}
					else {
						var _arrRx = _data.videoswitching_encode_arr.split(',');		
						sendCommand('data=start '+_arrRx[e]+':AUDIO:0');
					}
					return;
				});
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#AnalogAudioTxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($('.IPAV1100AnalogAudioTxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100AnalogAudioTxCont li:eq('+e+')').html());
						MouseUpOrDown = 1;
						EncoderChannelNum = e;
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Encode_AnalogAudio_DataArr[e][4],'analog_audio');
					}
						
				});
				$(this).on('mouseup',function(){
					if ($('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#AnalogAudioGroupSelectTx span').html()=='Default') {
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							
							DecoderToChangePositionNowNum = e;
							if (Encode_AnalogAudio_DataArr[DecoderToChangePositionNowNum]==''||typeof(Encode_AnalogAudio_DataArr[DecoderToChangePositionNowNum])=='undefined') {
								
								Encode_AnalogAudio_DataArr[DecoderToChangePositionNowNum] = Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum];
								Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum] = '';
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum];
								Encode_AnalogAudio_DataArr[DecoderToChangePositionAfterNum] = Encode_AnalogAudio_DataArr[DecoderToChangePositionNowNum];
								Encode_AnalogAudio_DataArr[DecoderToChangePositionNowNum] = b;
								var c = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionNowNum] = EncodeDetaileDataArr[DecoderToChangePositionAfterNum];
								EncodeDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.videoswitching_encode_arr = changeDeviceIDArrPosition(_data.videoswitching_encode_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100AnalogAudioTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(8);
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#AnalogAudioConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100AnalogAudioTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						backMouseoverRx = 1;
						EncoderChannelNum = e;
					}
				});
			});		
		break;
		case 9:// rs232 decoder
			
			$('.IPAV1100Rs232RxCont li .DeviceBoxNavTopSetting').unbind('mousedown');	
			$('.IPAV1100Rs232RxCont li .DeviceBoxBottom').unbind('mousedown');	
			$('.IPAV1100Rs232RxCont li .DeviceBoxNavTopLocked').unbind('mousedown');	
			$('.IPAV1100Rs232RxCont li .DeviceBoxNavTopSetting').unbind('mouseover');	
			$('.IPAV1100Rs232RxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100Rs232RxCont li').unbind('mousedown');
			$('.IPAV1100Rs232RxCont li').unbind('mouseup');
			$('.IPAV1100Rs232RxCont li').unbind('mouseover');
			$('.IPAV1100Rs232RxCont li').unbind('mouseleave');
			$('.IPAV1100Rs232RxCont li').each(function(e){
				$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						var switchType;
			            if (Decode_Rs232_DataArr[e-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(Decode_Rs232_DataArr[e-1][4]=='FAST_SWITCHED'||Decode_Rs232_DataArr[e-1][4]=='FAST_SWITCHED_CROP'||Decode_Rs232_DataArr[e-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(Decode_Rs232_DataArr[e-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(Decode_Rs232_DataArr[e-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Decode_Rs232_DataArr[e-1][2]+'-'+switchType);
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					$('#VideoWallRemoveFromWall').hide();
					var _IPAV1100RxCont = $('.IPAV1100Rs232RxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#Rs232ConfigurationTxDevice').hide();
					$('#Rs232ConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#Rs232ConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							
							// $('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
						}
						else {
							$('#Rs232ConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							
							// $('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
							$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
						}
						$('#Rs232ConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						$('#Rs232ConfigurationRxDevice').show();
						CheckBoxIsOverflow(9,0);
						_DeviceRxSettingClick=1;
						MouseoverRxToHide = 1;
						DecoderConfigurationDeviceNumb = e;
						DecoderSettingConfigurationGetJsonData(e);
						if (Decode_Rs232_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
							Rs232DecoderConfigurationSettingBox();	
						}
						else {
							for (var i = 0; i < Encode_Rs232_DataArr.length; i++) {
								if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
									if (Encode_Rs232_DataArr[i][1]==Decode_Rs232_DataArr[e-1][1]) {
										EncoderConfigurationDeviceNumb = i;
									}
								}
							}
							Rs232EncoderConfigurationSettingBox();	
						}
						if ($('#Rs232GroupSelectRx span').html()=='Default') {
							$('#Rs232RemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=rs232&devicetype=rx');
						}
						else {
							$('#Rs232RemoveFromGroupRx').html('Remove from Group');
						}
						// Rs232DecoderConfigurationSettingBox();						
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#Rs232ConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								
								// $('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
							}
							else {
								$('#Rs232ConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								
								// $('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
								$('#Rs232ConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
							}
							$('#Rs232ConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							$('#Rs232ConfigurationRxDevice').show();
							CheckBoxIsOverflow(9,0);
							_DeviceRxSettingClick=1;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							if (Decode_Rs232_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
								Rs232DecoderConfigurationSettingBox();	
							}
							else {
								for (var i = 0; i < Encode_Rs232_DataArr.length; i++) {
								if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
									if (Encode_Rs232_DataArr[i][1]==Decode_Rs232_DataArr[e-1][1]) {
										EncoderConfigurationDeviceNumb = i;
									}
								}
							}
								Rs232EncoderConfigurationSettingBox();	
							}
							return;
						}
						$('#Rs232ConfigurationRxDevice').hide();
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#Rs232RxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if (e==0) return;
					if ($('.IPAV1100Rs232RxCont li:eq('+e+')').html()!='') {
						if (e!=0) {
							$('.IPAV1100Rs232RxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
							$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						}
							
						$('.DeviceClickToMove').html($('.IPAV1100Rs232RxCont li:eq('+e+')').html());
						VideoDecoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						backMouseUpOrDown = 1;		
						CheckDeviceRouting(Decode_Rs232_DataArr[e-1][2],'rs232Receiver');
					}
						
				});
				$(this).on('mouseup',function(){
					if (e==0) return;
					if ($('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#Rs232GroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {
							
							DecoderToChangePositionNowNum = e;
							if (Decode_Rs232_DataArr[DecoderToChangePositionNowNum-1]==''||typeof(Decode_Rs232_DataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								Decode_Rs232_DataArr[DecoderToChangePositionNowNum-1] = Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1] = '';
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionNowNum-1] = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.Rs232_De_En_arr = changeDeviceIDArrPosition(_data.Rs232_De_En_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_Rs232_DataArr[DecoderToChangePositionAfterNum-1] = Decode_Rs232_DataArr[DecoderToChangePositionNowNum-1];
								Decode_Rs232_DataArr[DecoderToChangePositionNowNum-1] = b;
								_data.Rs232_De_En_arr = changeDeviceIDArrPosition(_data.Rs232_De_En_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								var c = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionNowNum-1] = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								c = $('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;


					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100Rs232RxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}	
					// }
					AddEventListen(9);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0){
						$('#Rs232ConfigurationRxDevice').hide();
						_DeviceRxSettingClick = 0;
					}
						
				});
				$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
				});
				$('.IPAV1100Rs232RxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide= 0;
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						DecoderChannelNum = e;
					}
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;
					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});
			});					
		break;
		case 10:// rs232 encoder  
			
			$('.IPAV1100Rs232TxCont li .DeviceBoxNavTopSetting').unbind('click');
			$('.IPAV1100Rs232TxCont li .DeviceBoxBottom').unbind('click');
			$('.IPAV1100Rs232TxCont li .DeviceBoxNavTopStop').unbind('mousedown');
			$('.IPAV1100Rs232TxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100Rs232TxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100Rs232TxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100Rs232TxCont li').unbind('mousedown');
			$('.IPAV1100Rs232TxCont li').unbind('mouseup');
			$('.IPAV1100Rs232TxCont li').unbind('mouseleave');
			$('.IPAV1100Rs232TxCont li').unbind('mouseover');
			$('.IPAV1100Rs232TxCont li').each(function(e){
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottom').on('click',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Encode_Rs232_DataArr[e][2]);
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('click',function(){
					var _IPAV1100TxCont = $('.IPAV1100Rs232TxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					$('#Rs232ConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#Rs232ConfigurationRxDevice').hide();
					_IPAV1100TxCont = parseInt($('.IPAV1100TxContScrool').height())+12;
					var _y = parseInt(_IPAV1100TxCont/120);
					_DeviceRxSettingClick=0;
					if (_DeviceTxSettingClick==0) {
						$('#Rs232ConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#Rs232ConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#Rs232ConfigurationTxDevice').show();
						CheckBoxIsOverflow(10,0);
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						if (Encode_Rs232_DataArr[EncoderConfigurationDeviceNumb][12]) {
							for (var i = 0; i < Decode_Rs232_DataArr.length; i++) {
									if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
										if (Decode_Rs232_DataArr[i][1]==Encode_Rs232_DataArr[e][1]) {
											DecoderConfigurationDeviceNumb = i+1;
										}
									}
								}
							Rs232DecoderConfigurationSettingBox();	
						}
						else {							
							Rs232EncoderConfigurationSettingBox();	
						}
						if ($('#Rs232GroupSelectTx span').html()=='Default') {
							$('#Rs232RemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=rs232&devicetype=tx');
						}
						else {
							$('#Rs232RemoveFromGroupTx').html('Remove from Group');
						}					
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#Rs232ConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#Rs232ConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#Rs232ConfigurationTxDevice').show();
							CheckBoxIsOverflow(10,0);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							if (Encode_Rs232_DataArr[EncoderConfigurationDeviceNumb][12]) {
								for (var i = 0; i < Decode_Rs232_DataArr.length; i++) {
									if (Decode_Rs232_DataArr[i]!=''&&typeof(Decode_Rs232_DataArr[i])!='undefined') {
										if (Decode_Rs232_DataArr[i][1]==Encode_Rs232_DataArr[e][1]) {
											DecoderConfigurationDeviceNumb = i+1;
										}
									}
								}
								Rs232DecoderConfigurationSettingBox();	
							}
							else {							
								Rs232EncoderConfigurationSettingBox();	
							}	
							return;
						}
						$('#Rs232ConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.Rs232_De_En_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':RS232:0');
					}
					return;
				});
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#Rs232TxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($('.IPAV1100Rs232TxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100Rs232TxCont li:eq('+e+')').html());
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Encode_Rs232_DataArr[e][4],'rs232Sender');
						MouseUpOrDown = 1;
						EncoderChannelNum = e;
					}
						
				});
				$(this).on('mouseup',function(){
					if ($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#Rs232GroupSelectTx span').html()=='Default') {
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							
							DecoderToChangePositionNowNum = e;
							if (Encode_Rs232_DataArr[DecoderToChangePositionNowNum]==''||typeof(Encode_Rs232_DataArr[DecoderToChangePositionNowNum])=='undefined') {
								console.log(DecoderToChangePositionAfterNum+':'+DecoderToChangePositionNowNum);
								Encode_Rs232_DataArr[DecoderToChangePositionNowNum] = Encode_Rs232_DataArr[DecoderToChangePositionAfterNum];
								Encode_Rs232_DataArr[DecoderToChangePositionAfterNum] = '';
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionNowNum] = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.Rs232_En_De_arr = changeDeviceIDArrPosition(_data.Rs232_En_De_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Encode_Rs232_DataArr[DecoderToChangePositionAfterNum];
								Encode_Rs232_DataArr[DecoderToChangePositionAfterNum] = Encode_Rs232_DataArr[DecoderToChangePositionNowNum-1];
								Encode_Rs232_DataArr[DecoderToChangePositionNowNum] = b;

								var c = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionNowNum] = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.Rs232_En_De_arr = changeDeviceIDArrPosition(_data.Rs232_En_De_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100Rs232TxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(10);
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#Rs232ConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100Rs232TxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						backMouseoverRx = 1;
						EncoderChannelNum = e;
					}
				});
			});
						
		break;
		case 11:// video rx device add to group
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'rxAddToGroup',_id,$('#VideoConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Video Decoder','Device Add to Group');

				});
			});
		break;
		case 12:// video tx device add to group
			$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#VideoConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());

				});
			});
		break;
		case 13:// video wall rx device add to group
			$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'rxAddToGroup',_id,$('#VideoWallConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Video Wall Decoder','Device Add to Group');
				});
			});
		break;
		case 14:// video wall tx device add to group
			$('#VideoWallConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#VideoWallConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#VideoWallConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#VideoWallConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
				});
			});
		break;
		case 15:// hdmi audio rx device add to group
			$('#HdmiAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#HdmiAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#HdmiAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'rxAddToGroup',_id,$('#HdmiAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('HDMI Audio Decoder','Device Add to Group');
				});
			});
		break;
		case 16:// hdmi audio tx device add to group
			$('#HdmiAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#HdmiAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#HdmiAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#HdmiAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('HDMI Audio Encoder','Device Add to Group');
				});
			});
		break;
		case 17:// analog audio rx device add to group
			$('#AnalogAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#AnalogAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#AnalogAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'rxAddToGroup',_id,$('#AnalogAudioConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Analog Audio Decoder','Device Add to Group');
				});
			});
		break;
		case 18:// analog audio tx device add to group
			$('#AnalogAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#AnalogAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#AnalogAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#AnalogAudioConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Analog Audio Encoder','Device Add to Group');
				});
			});
		break;
		case 19:// rs232 rx device add to group
			$('#Rs232ConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#Rs232ConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#Rs232ConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'rxAddToGroup',_id,$('#Rs232ConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Rs232 Decoder','Device Add to Group');
				});
			});
		break;
		case 20:// rs232 tx device add to group
			$('#Rs232ConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#Rs232ConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#Rs232ConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#Rs232ConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Rs232 Encoder','Device Add to Group');
				});
			});
		break;
		case 21:// firmware update
			$('.IPAV1100FirmwareTxCont li .DeviceBoxNavTopSetting').unbind('mousedown');
			$('.IPAV1100FirmwareTxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100FirmwareTxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100FirmwareTxCont li').each(function(e){
				$('.IPAV1100FirmwareTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100TxCont = $('.IPAV1100FirmwareTxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;	
								
					if (_DeviceTxFirmwareSettingClick==0) {
						if (e==0) 
							$('#FirmwareUpdateSettingCont').css('left',229+parseInt(e%_IPAV1100TxContX)*210+'px');						
						else
							$('#FirmwareUpdateSettingCont').css('left',210+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#FirmwareUpdateSettingCont').css('top',24+parseInt(e/_IPAV1100TxContX)*143+'px');
						$('#FirmwareUpdateSettingCont').show();
						CheckBoxIsOverflow(13,0);
						_DeviceTxFirmwareSettingClick=1;
						EncoderConfigurationDeviceNumb = e;						
					}
					else if (_DeviceTxFirmwareSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							if (e==0) 
								$('#FirmwareUpdateSettingCont').css('left',229+parseInt(e%_IPAV1100TxContX)*210+'px');						
							else
								$('#FirmwareUpdateSettingCont').css('left',210+parseInt(e%_IPAV1100TxContX)*210+'px');
							//$('#FirmwareUpdateSettingCont').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#FirmwareUpdateSettingCont').css('top',24+parseInt(e/_IPAV1100TxContX)*143+'px');
							$('#FirmwareUpdateSettingCont').show();
							CheckBoxIsOverflow(13,0);
							_DeviceTxFirmwareSettingClick=0;
							EncoderConfigurationDeviceNumb = e;
							return;
						}
						$('#FirmwareUpdateSettingCont').hide();
						_DeviceTxFirmwareSettingClick=0;
					}
				});
				$('.IPAV1100FirmwareTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					_firmwareUpdateClickCheck = 1;
					//console.log(_firmwareUpdateClickCheck);	
				});
				$('.IPAV1100FirmwareTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					_firmwareUpdateClickCheck = 0;
					//console.log(_firmwareUpdateClickCheck);	
				});
			});
		break;
		case 22:// infrared decoder			
			$('.IPAV1100InfraredRxCont li .DeviceBoxNavTopSetting').unbind('mousedown');	
			$('.IPAV1100InfraredRxCont li .DeviceBoxBottom').unbind('mousedown');	
			$('.IPAV1100InfraredRxCont li .DeviceBoxNavTopLocked').unbind('mousedown');	
			$('.IPAV1100InfraredRxCont li .DeviceBoxNavTopSetting').unbind('mouseover');	
			$('.IPAV1100InfraredRxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100InfraredRxCont li').unbind('mousedown');
			$('.IPAV1100InfraredRxCont li').unbind('mouseup');
			$('.IPAV1100InfraredRxCont li').unbind('mouseover');
			$('.IPAV1100InfraredRxCont li').unbind('mouseleave');
			$('.IPAV1100InfraredRxCont li').each(function(e){
				$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottom').on('mousedown',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						var switchType;
			            if (Decode_Infrared_DataArr[e-1][4]==0) {		
							switchType = 'Genlock';
						}
						else if(Decode_Infrared_DataArr[e-1][4]=='FAST_SWITCHED'||Decode_Infrared_DataArr[e-1][4]=='FAST_SWITCHED_CROP'||Decode_Infrared_DataArr[e-1][4]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
							switchType = 'Fast Switch';
						}
						else if(Decode_Infrared_DataArr[e-1][4]=='GENLOCK_SCALING'){//genlock scaling
							switchType = 'Genlock Scaling';
						}
						else if(Decode_Infrared_DataArr[e-1][4]=='WALL_GENLOCKED'){
							switchType = 'Wall Genlock';
						}
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Decode_Infrared_DataArr[e-1][2]+'-'+switchType);
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mousedown',function(){
					var _IPAV1100RxCont = $('.IPAV1100InfraredRxCont').width();
					var _IPAV1100RxContX = parseInt((_IPAV1100RxCont-197)/209)+1;
					$('#InfraredConfigurationTxDevice').hide();
					$('#InfraredConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					_DeviceTxSettingClick=0;
					if (_DeviceRxSettingClick==0) {
						if (e==0){
							$('#InfraredConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
							
							// $('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
						}
						else {
							$('#InfraredConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
							
							// $('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
							$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
						}
						$('#InfraredConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
						$('#InfraredConfigurationRxDevice').show();
						CheckBoxIsOverflow(11,0);
						_DeviceRxSettingClick=1;
						MouseoverRxToHide = 1;
						DecoderConfigurationDeviceNumb = e;
						DecoderSettingConfigurationGetJsonData(e);
						if (Decode_Infrared_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
							Rs232DecoderConfigurationSettingBox();	
						}
						else {
							for (var i = 0; i < Encode_Infrared_DataArr.length; i++) {
								if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
									if (Encode_Infrared_DataArr[i][1]==Decode_Infrared_DataArr[e-1][1]) {
										EncoderConfigurationDeviceNumb = i;
									}
								}
							}
							
							Rs232EncoderConfigurationSettingBox();	
						}
						if ($('#InfraredGroupSelectRx span').html()=='Default') {
							$('#InfraredRemoveFromGroupRx').html('Add to Group');
							PageAddGroup('type=11&pagetype=infrared&devicetype=rx');
						}
						else {
							$('#InfraredRemoveFromGroupRx').html('Remove from Group');
						}
						// Rs232DecoderConfigurationSettingBox();						
					}
					else if (_DeviceRxSettingClick==1){
						if (DecoderConfigurationDeviceNumb!=e) {
							if (e==0){
								$('#InfraredConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').addClass('RxDeviceSetting');
								
								// $('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').addClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').addClass('RxDeviceSetting');
							}
							else {
								$('#InfraredConfigurationRxDevice').css('left',217+parseInt(e%_IPAV1100RxContX)*210+'px');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(0)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(1)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(2)').removeClass('RxDeviceSetting');
								
								// $('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(3)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(6)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(7)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(8)').removeClass('RxDeviceSetting');
								$('#InfraredConfigurationRxDevice .IPAV1100RxDeviceOptionsNavSec:eq(9)').removeClass('RxDeviceSetting');
							}
							$('#InfraredConfigurationRxDevice').css('top',76+parseInt(e/_IPAV1100RxContX%2)*120+'px');
							$('#InfraredConfigurationRxDevice').show();
							CheckBoxIsOverflow(11,0);
							_DeviceRxSettingClick=1;
							DecoderConfigurationDeviceNumb = e;
							DecoderSettingConfigurationGetJsonData(e);
							if (Decode_Infrared_DataArr[DecoderConfigurationDeviceNumb-1][13]) {
								Rs232DecoderConfigurationSettingBox();	
							}
							else {
								for (var i = 0; i < Encode_Infrared_DataArr.length; i++) {
									if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
										if (Encode_Infrared_DataArr[i][1]==Decode_Infrared_DataArr[e-1][1]) {
											EncoderConfigurationDeviceNumb = i;
										}
									}
								}
								Rs232EncoderConfigurationSettingBox();	
							}
							return;
						}
						$('#InfraredConfigurationRxDevice').hide();
						_DeviceRxSettingClick=0;
					}
				});
				$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					DecoderConfigurationDeviceNumb = e;
					$('#InfraredRxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if (e==0) return;
					if ($('.IPAV1100InfraredRxCont li:eq('+e+')').html()!='') {
						if (e!=0) {
							$('.IPAV1100InfraredRxCont li .DeviceBoxNavTop').removeClass('DeviceCheckRouting');
							$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxNavTop').addClass('DeviceCheckRouting');
						}
							
						$('.DeviceClickToMove').html($('.IPAV1100InfraredRxCont li:eq('+e+')').html());
						VideoDecoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						backMouseUpOrDown = 1;		
						CheckDeviceRouting(Decode_Infrared_DataArr[e-1][2],'infraredReceiver');
					}
						
				});
				$(this).on('mouseup',function(){
					if (e==0) return;
					if ($('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#InfraredGroupSelectRx span').html()=='Default') {
						if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&DecoderToChangePositionAfterNum!=0) {
							DecoderToChangePositionNowNum = e;
							if (Decode_Infrared_DataArr[DecoderToChangePositionNowNum-1]==''||typeof(Decode_Infrared_DataArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
								Decode_Infrared_DataArr[DecoderToChangePositionNowNum-1] = Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1] = '';
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionNowNum-1] = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1] = '';
								_data.Rs232_De_En_arr = changeDeviceIDArrPosition(_data.Rs232_De_En_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,0);
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1];
								Decode_Infrared_DataArr[DecoderToChangePositionAfterNum-1] = Decode_Infrared_DataArr[DecoderToChangePositionNowNum-1];
								Decode_Infrared_DataArr[DecoderToChangePositionNowNum-1] = b;
								_data.Rs232_De_En_arr = changeDeviceIDArrPosition(_data.Rs232_De_En_arr,DecoderToChangePositionAfterNum-1,DecoderToChangePositionNowNum-1,1);
								var c = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionNowNum-1] = Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1];
								Rs232IrReceiverDataDetaileDataArr[DecoderToChangePositionAfterNum-1] = c;
								c = $('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoDecoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e&&e!=0) {
					// 		DecoderToChangePositionNowNum = e;
					// 		if (DecodeGroupDataListArr[DecoderToChangePositionNowNum-1]==''||typeof(DecodeGroupDataListArr[DecoderToChangePositionNowNum-1])=='undefined') {
								
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = '';
					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = b;


					// 			var _arr = DecodeGroupDataListArr[DecoderToChangePositionNowNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionNowNum-1] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1].split(':');
					// 			DecodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100InfraredRxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}	
					// }
					AddEventListen(22);
					VideoDecoderToChangePosition = 0;
					if (MouseoverRx==0){
						$('#InfraredConfigurationRxDevice').hide();
						_DeviceRxSettingClick = 0;
					}
						
				});
				$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					MouseoverRxToHide = 1;
				});
				$('.IPAV1100InfraredRxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					MouseoverRxToHide= 0;
				});
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						MouseoverRx = 1;
						DecoderChannelNum = e;
					}
				});
				$(this).on('mouseleave',function(){
					MouseoverRx = 0;
					if (VideoDecoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});
			});					
		break;
		case 23:// infrared encoder
			$('.IPAV1100InfraredTxCont li .DeviceBoxNavTopSetting').unbind('click');
			$('.IPAV1100InfraredTxCont li .DeviceBoxBottom').unbind('click');
			$('.IPAV1100InfraredTxCont li .DeviceBoxNavTopStop').unbind('mousedown');
			$('.IPAV1100InfraredTxCont li .DeviceBoxNavTopLocked').unbind('mousedown');
			$('.IPAV1100InfraredTxCont li .DeviceBoxNavTopSetting').unbind('mouseover');
			$('.IPAV1100InfraredTxCont li .DeviceBoxNavTopSetting').unbind('mouseleave');
			$('.IPAV1100InfraredTxCont li').unbind('mousedown');
			$('.IPAV1100InfraredTxCont li').unbind('mouseup');
			$('.IPAV1100InfraredTxCont li').unbind('mouseleave');
			$('.IPAV1100InfraredTxCont li').unbind('mouseover');
			$('.IPAV1100InfraredTxCont li').each(function(e){
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottom').on('click',function(){
					var _deviceNumBer = e;
					
					if ($(this).height()==80) {
						$(this).css('height','13px');
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html(Encode_Infrared_DataArr[e][2]);
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(0deg)');
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').hide();
					}
					else {
						$(this).css('height','80px');
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataScroll span').html('');
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataScroll img').css('transform','rotate(180deg)');
						$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxBottomDataDetail').show();
					}
				});
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('click',function(){
					var _IPAV1100TxCont = $('.IPAV1100InfraredTxCont').width();
					var _IPAV1100TxContX = parseInt((_IPAV1100TxCont-197)/209)+1;
					$('#InfraredConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay').hide();
					$('#InfraredConfigurationRxDevice').hide();
					_IPAV1100TxCont = parseInt($('.IPAV1100TxContScrool').height())+12;
					var _y = parseInt(_IPAV1100TxCont/120);
					_DeviceRxSettingClick=0;
					if (_DeviceTxSettingClick==0) {
						$('#InfraredConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
						$('#InfraredConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
						$('#InfraredConfigurationTxDevice').show();
						CheckBoxIsOverflow(12,0);
						_DeviceTxSettingClick=1;
						backMouseoverRxToHide = 1;
						EncoderConfigurationDeviceNumb = e;
						if (Encode_Infrared_DataArr[EncoderConfigurationDeviceNumb][12]) {							
							for (var i = 0; i < Decode_Infrared_DataArr.length; i++) {
								if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
									if (Decode_Infrared_DataArr[i][1]==Encode_Infrared_DataArr[e][1]) {
										DecoderConfigurationDeviceNumb = i+1;
									}
								}
							}
							Rs232DecoderConfigurationSettingBox();	
						}
						else {							
							Rs232EncoderConfigurationSettingBox();	
						}
						if ($('#InfraredGroupSelectTx span').html()=='Default') {
							$('#InfraredRemoveFromGroupTx').html('Add to Group');
							PageAddGroup('type=11&pagetype=infrared&devicetype=tx');
						}
						else {
							$('#InfraredRemoveFromGroupTx').html('Remove from Group');
						}					
					}
					else if (_DeviceTxSettingClick==1){
						if (EncoderConfigurationDeviceNumb!=e) {
							$('#InfraredConfigurationTxDevice').css('left',200+parseInt(e%_IPAV1100TxContX)*210+'px');
							$('#InfraredConfigurationTxDevice').css('top',405+parseInt(e/_IPAV1100TxContX%_y)*120+'px');
							$('#InfraredConfigurationTxDevice').show();
							CheckBoxIsOverflow(12,0);
							_DeviceTxSettingClick=1;
							EncoderConfigurationDeviceNumb = e;
							if (Encode_Infrared_DataArr[EncoderConfigurationDeviceNumb][12]) {
								for (var i = 0; i < Decode_Infrared_DataArr.length; i++) {
									if (Decode_Infrared_DataArr[i]!=''&&typeof(Decode_Infrared_DataArr[i])!='undefined') {
										if (Decode_Infrared_DataArr[i][1]==Encode_Infrared_DataArr[e][1]) {
											DecoderConfigurationDeviceNumb = i+1;
										}
									}
								}
								Rs232DecoderConfigurationSettingBox();	
							}
							else {							
								Rs232EncoderConfigurationSettingBox();	
							}	
							return;
						}
						$('#InfraredConfigurationTxDevice').hide();
						_DeviceTxSettingClick=0;
					}
				});
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopStop').on('mousedown',function(){											
					if ($('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopStop').hasClass('DeviceBoxNavTopStreaming')) {
						var _arrRx = _data.Rs232_En_De_arr.split(',');
						sendCommand('data=stop '+_arrRx[e]+':RS232:0');
					}
					return;
				});
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopLocked').on('mousedown',function(){
					EncoderConfigurationDeviceNumb = e;
					$('#InfraredTxPinToThisPosition').click();
				});
				$(this).on('mousedown',function(){
					if ($('.IPAV1100InfraredTxCont li:eq('+e+')').html()!='') {
						$('.DeviceClickToMove').html($('.IPAV1100InfraredTxCont li:eq('+e+')').html());
						VideoEncoderToChangePosition = 1;
						DecoderToChangePositionAfterNum = e;
						CheckDeviceRouting(Encode_Infrared_DataArr[e][4],'infraredSender');
						MouseUpOrDown = 1;
						EncoderChannelNum = e;
					}
						
				});
				$(this).on('mouseup',function(){
					if ($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					//if ($('#InfraredGroupSelectTx span').html()=='Default') {
						if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
							
							DecoderToChangePositionNowNum = e;
							if (Encode_Infrared_DataArr[DecoderToChangePositionNowNum]==''||typeof(Encode_Infrared_DataArr[DecoderToChangePositionNowNum])=='undefined') {
								//console.log(DecoderToChangePositionAfterNum+':'+DecoderToChangePositionNowNum);
								Encode_Infrared_DataArr[DecoderToChangePositionNowNum] = Encode_Infrared_DataArr[DecoderToChangePositionAfterNum];
								Encode_Infrared_DataArr[DecoderToChangePositionAfterNum] = '';
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionNowNum] = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum] = '';
								_data.Rs232_En_De_arr = changeDeviceIDArrPosition(_data.Rs232_En_De_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,0);
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
							}
							else {
								var b = Encode_Infrared_DataArr[DecoderToChangePositionAfterNum];
								Encode_Infrared_DataArr[DecoderToChangePositionAfterNum] = Encode_Infrared_DataArr[DecoderToChangePositionNowNum-1];
								Encode_Infrared_DataArr[DecoderToChangePositionNowNum] = b;

								var c = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionNowNum] = Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum];
								Rs232IrSenderDataDetaileDataArr[DecoderToChangePositionAfterNum] = c;
								_data.Rs232_En_De_arr = changeDeviceIDArrPosition(_data.Rs232_En_De_arr,DecoderToChangePositionAfterNum,DecoderToChangePositionNowNum,1);
								c = $('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
								$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
							}
						}
					// }
					// else {
					// 	if (VideoEncoderToChangePosition==1&&DecoderToChangePositionAfterNum!=e) {
					// 		if ($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+') .DeviceBoxNavTopLocked').hasClass('DeviceBoxPositionLocked')) return;
					// 		DecoderToChangePositionNowNum = e;
					// 		if (EncodeGroupDataListArr[DecoderToChangePositionNowNum]==''||typeof(EncodeGroupDataListArr[DecoderToChangePositionNowNum])=='undefined') {
								
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = '';
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html('');
								
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').addClass('deviceBoxHasDevice');
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').removeClass('deviceBoxHasDevice');
					// 		}
					// 		else {
					// 			var b = EncodeGroupDataListArr[DecoderToChangePositionAfterNum];
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum] = EncodeGroupDataListArr[DecoderToChangePositionNowNum-1];
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = b;
					// 			var _arr = EncodeGroupDataListArr[DecoderToChangePositionNowNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionNowNum] = _arr[0]+':'+DecoderToChangePositionNowNum;
					// 			var _arr1 = EncodeGroupDataListArr[DecoderToChangePositionAfterNum].split(':');
					// 			EncodeGroupDataListArr[DecoderToChangePositionAfterNum-1] = _arr1[0]+':'+DecoderToChangePositionAfterNum;
					// 			var c = $('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html();
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionNowNum+')').html($('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html());
					// 			$('.IPAV1100InfraredTxCont li:eq('+DecoderToChangePositionAfterNum+')').html(c);
					// 		}
					// 	}
					// }
					AddEventListen(23);
					VideoEncoderToChangePosition = 0;
					if (backMouseoverRx==0) {
						$('#InfraredConfigurationTxDevice').hide();
						_DeviceTxSettingClick = 0;
					}
						
				});
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseover',function(){
					backMouseoverRxToHide = 1;
				});
				$('.IPAV1100InfraredTxCont li:eq('+e+') .DeviceBoxNavTopSetting').on('mouseleave',function(){
					backMouseoverRxToHide = 0;
				});
				$(this).on('mouseleave',function(){
					backMouseoverRx = 0;
					if (VideoEncoderToChangePosition==1){
						$('.DeviceClickToMove').show();	
					}
				});	
				$(this).on('mouseover',function(){
					if ($(this).html()!='') {
						backMouseoverRx = 1;
						EncoderChannelNum = e;
					}
				});
			});
		case 24:// infrared rx device add to group
			$('#InfraredConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#InfraredConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#InfraredConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'rxAddToGroup',_id,$('#InfraredConfigurationRxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Infrared Decoder','Device Add to Group');
				});
			});
		break;
		case 25:// infrared tx device add to group
			$('#InfraredConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').unbind('click');
			$('#InfraredConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li').each(function(e){
				$(this).on('click',function(){
					var _id = $('#InfraredConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;		
					PageAddGroup(data,'txAddToGroup',_id,$('#InfraredConfigurationTxDevice .RxDeviceOptionsRightGroupDisplay li:eq('+e+') div:eq(1)').html());
					SystemLogWriteToFileAnother('Infrared Encoder','Device Add to Group');
				});
			});
		break;
		break;
	}
}

function GroupAddEventListen(num){
	// switch(num){
	// case 1:
	// 	$('.GroupRxSelectBoxNav li').unbind('mouseover');
	// 	$('.GroupRxSelectBoxNav li').unbind('mouseleave');
	// 	$('.GroupRxSelectBoxNav li').each(function(e){
	// 		$('.GroupRxSelectBoxNav li .IPAV1100GroupOptionsNavSecL').css('background-color','#23272d');
	// 		$('.GroupRxSelectBoxNav li .IPAV1100GroupSelectNavIco').css('border-color','#44474c');
	// 		$(this).on('mouseover',function(){
	// 			$(this).css('background-color','#6797b8');
	// 			$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupOptionsNavSecL').css('background-color','#006eb8');
	// 			$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('border-color','#e1ebe2');
	// 			if ($('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('width')=='9px') {
	// 				$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('color','#e1ebe2');
	// 			}
				
	// 		});
	// 		$(this).on('mouseleave',function(){
	// 			$(this).css('background-color','#23272d');
	// 			$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupOptionsNavSecL').css('background-color','#23272d');
	// 			$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('border-color','#44474c');
	// 			if ($('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('width')=='9px') {
	// 				$('.GroupRxSelectBoxNav li:eq('+e+') .IPAV1100GroupSelectNavIco').css('color','#44474c');
	// 			}
	// 		});
	// 	});		
	// break;
	// }
}
var DeviceGroupRxSelectNum=1;
var DeviceGroupTxSelectNum=0;
// 分组列表的选择显示
function GroupAddDeviceEventListen(num){
	switch(num){
	case 1:
		$('#GroupRxSelectBox li').unbind('click');
		$('#GroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#VideoGroupSelectRx span').html($('#GroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('VideoPreset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#GroupRxSelectBox').hide();
				_GrouopRxSelect=0;
			});
		});
		$('#GroupTxSelectBox li').unbind('click');
		$('#GroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100TxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < EncodeVideoDataArr.length; i++) {
						if (EncodeVideoDataArr[i]!=''&&typeof(EncodeVideoDataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+EncodeVideoDataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='DeviceBoxContOnceDisplayTxImg'><span style='position:relative;top:-18px;'># "+(i+1)+"</span></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ EncodeVideoDataArr[i][6] + "x" + EncodeVideoDataArr[i][7] +"</span>\
			                                        <span>"+ EncodeVideoDataArr[i][8] +"Hz</span>\
			                                        <span>"+ EncodeVideoDataArr[i][9] + "," + EncodeVideoDataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ EncodeVideoDataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ EncodeVideoDataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+EncodeVideoDataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+EncodeVideoDataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+EncodeVideoDataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100TxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100TxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            if (EncodeVideoDataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
                            if (EncodeVideoDataArr[i][6]=='0'&&EncodeVideoDataArr[i][7]=='0') {
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxContOnceDisplayTxImg').addClass('DeviceBoxContOnceDisplayTxImgNoDevice');
				            }else{
				            	$('.IPAV1100TxCont li:eq(' + (i) + ') .DeviceBoxContOnceDisplayTxImg').removeClass('DeviceBoxContOnceDisplayTxImgNoDevice');
				            }
						}
					}
					$('#GroupTxSelectBox').hide();
					$('#VideoGroupSelectTx span').html('Default');
					_GrouopTxSelect=0;
					LoadGroupSettingFromFile('VideoEncode_Default','tx',0);
				}
				else if(e!=($('#GroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#VideoGroupSelectTx span').html($('#GroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#GroupTxSelectBox').hide();
					
					var _id = $('#GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_GrouopTxSelect=0;
					LoadGroupSettingFromFile('VideoEncode_'+_id,'tx',0);
				}
				
			});
		});
		$('#VideoRxAddGroup').on('click',function(){
			var listnum = $('#GroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('video','rx',name);
			
		});
		$('#VideoTxAddGroup').on('click',function(){
			var listnum = $('#GroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('video','tx',name);
			
		});
	break;
	case 2:		
		$('#VideoWallGroupRxSelectBox li').unbind('click');
		$('#VideoWallGroupTxSelectBox li').unbind('click');
		$('#VideoWallGroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#VideoWallGroupSelectRx span').html($('#VideoWallGroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('VideoPreset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#VideoWallGroupRxSelectBox').hide();
				_VideoWallGrouopRxSelect=0;
			});
		});
		$('#VideoWallGroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100VideoWallTxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < EncodeVideoWallDataArr.length; i++) {
						if (EncodeVideoWallDataArr[i]!=''&&typeof(EncodeVideoWallDataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+EncodeVideoWallDataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='DeviceBoxContOnceDisplayTxImg'><span style='position:relative;top:-18px;'># "+(i+1)+"</span></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ EncodeVideoWallDataArr[i][6] + "x" + EncodeVideoWallDataArr[i][7] +"</span>\
			                                        <span>"+ EncodeVideoWallDataArr[i][8] +"Hz</span>\
			                                        <span>"+ EncodeVideoWallDataArr[i][9] + "," + EncodeVideoWallDataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ EncodeVideoWallDataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ EncodeVideoWallDataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+EncodeVideoWallDataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+EncodeVideoWallDataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+EncodeVideoWallDataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100VideoWallTxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100VideoWallTxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            if (EncodeVideoWallDataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
                            if (EncodeVideoWallDataArr[i][6]=='0'&&EncodeVideoWallDataArr[i][7]=='0') {
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxContOnceDisplayTxImg').addClass('DeviceBoxContOnceDisplayTxImgNoDevice');
				            }else{
				            	$('.IPAV1100VideoWallTxCont li:eq(' + (i) + ') .DeviceBoxContOnceDisplayTxImg').removeClass('DeviceBoxContOnceDisplayTxImgNoDevice');
				            }
						}
					}
					$('#VideoWallGroupTxSelectBox').hide();
					$('#VideoWallGroupSelectTx span').html('Default');
					_VideoWallGrouopTxSelect=0;
					LoadGroupSettingFromFile('VideoWallEncode_Default','tx',0);
				}
				else if(e!=($('#VideoWallGroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#VideoWallGroupSelectTx span').html($('#VideoWallGroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#VideoWallGroupTxSelectBox').hide();
					
					var _id = $('#VideoWallGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_VideoWallGrouopTxSelect=0;
					LoadGroupSettingFromFile('VideoWallEncode_'+_id,'tx',0);
				}
				
			});
		});
		$('#VideoWallRxAddGroup').on('click',function(){
			var listnum = $('#VideoWallGroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('videowall','rx',name);
		});
		$('#VideoWallTxAddGroup').on('click',function(){
			var listnum = $('#VideoWallGroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('videowall','tx',name);			
		});
	break;
	case 3:		
		$('#HdmiAudioGroupRxSelectBox li').unbind('click');
		$('#HdmiAudioGroupTxSelectBox li').unbind('click');
		$('#HdmiAudioGroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#HdmiAudioGroupSelectRx span').html($('#HdmiAudioGroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('HdmiAudioPreset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#HdmiAudioGroupRxSelectBox').hide();
				_HdmiAudioGrouopRxSelect=0;
			});
		});
		$('#HdmiAudioGroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100HdmiAudioTxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < Encode_HdmiAudio_DataArr.length; i++) {
						if (Encode_HdmiAudio_DataArr[i]!=''&&typeof(Encode_HdmiAudio_DataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+Encode_HdmiAudio_DataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='HdmiAudioDeviceBoxContOnceDisplayImg'></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ Encode_HdmiAudio_DataArr[i][6] + "x" + Encode_HdmiAudio_DataArr[i][7] +"</span>\
			                                        <span>"+ Encode_HdmiAudio_DataArr[i][8] +"Hz</span>\
			                                        <span>"+ Encode_HdmiAudio_DataArr[i][9] + "," + Encode_HdmiAudio_DataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ Encode_HdmiAudio_DataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ Encode_HdmiAudio_DataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_HdmiAudio_DataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_HdmiAudio_DataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+Encode_HdmiAudio_DataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100HdmiAudioTxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100HdmiAudioTxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            if (Encode_HdmiAudio_DataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100HdmiAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100HdmiAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100HdmiAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100HdmiAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
                            
						}
					}
					$('#HdmiAudioGroupTxSelectBox').hide();
					$('#HdmiAudioGroupSelectTx span').html('Default');
					_HdmiAudioGrouopTxSelect=0;
					LoadGroupSettingFromFile('HdmiAudioEncode_Default','tx',0);
				}
				else if(e!=($('#HdmiAudioGroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#HdmiAudioGroupSelectTx span').html($('#HdmiAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#HdmiAudioGroupTxSelectBox').hide();
					
					var _id = $('#HdmiAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_HdmiAudioGrouopTxSelect=0;
					LoadGroupSettingFromFile('HdmiAudioEncode_'+_id,'tx',0);
					
				}
				
			});
		});
		$('#HdmiAudioRxAddGroup').on('click',function(){
			var listnum = $('#HdmiAudioGroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('hdmiaudio','rx',name);
			
		});
		$('#HdmiAudioTxAddGroup').on('click',function(){
			var listnum = $('#HdmiAudioGroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('hdmiaudio','tx',name);
		});
	break;
	case 4:		
		$('#AnalogAudioGroupRxSelectBox li').unbind('click');
		$('#AnalogAudioGroupTxSelectBox li').unbind('click');
		$('#AnalogAudioGroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#AnalogAudioGroupSelectRx span').html($('#AnalogAudioGroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('HdmiAudioPreset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#AnalogAudioGroupRxSelectBox').hide();
				_AnalogAudioGrouopRxSelect=0;
			});
		});
		$('#AnalogAudioGroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100AnalogAudioTxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < Encode_AnalogAudio_DataArr.length; i++) {
						if (Encode_AnalogAudio_DataArr[i]!=''&&typeof(Encode_AnalogAudio_DataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+Encode_AnalogAudio_DataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='AnalogAudioDeviceBoxContOnceDisplayImg'></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ Encode_AnalogAudio_DataArr[i][6] + "x" + Encode_AnalogAudio_DataArr[i][7] +"</span>\
			                                        <span>"+ Encode_AnalogAudio_DataArr[i][8] +"Hz</span>\
			                                        <span>"+ Encode_AnalogAudio_DataArr[i][9] + "," + Encode_AnalogAudio_DataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ Encode_AnalogAudio_DataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ Encode_AnalogAudio_DataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_AnalogAudio_DataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_AnalogAudio_DataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+Encode_AnalogAudio_DataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100AnalogAudioTxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100AnalogAudioTxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            if (Encode_AnalogAudio_DataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100AnalogAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100AnalogAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100AnalogAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100AnalogAudioTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
						}
					}
					$('#AnalogAudioGroupTxSelectBox').hide();
					$('#AnalogAudioGroupSelectTx span').html('Default');
					_AnalogAudioGrouopTxSelect=0;
					LoadGroupSettingFromFile('AnalogAudioEncode_Default','tx',0);
				}
				else if(e!=($('#AnalogAudioGroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#AnalogAudioGroupSelectTx span').html($('#AnalogAudioGroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#AnalogAudioGroupTxSelectBox').hide();
					
					var _id = $('#AnalogAudioGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_AnalogAudioGrouopTxSelect=0;
					LoadGroupSettingFromFile('AnalogAudioEncode_'+_id,'tx',0);
				}
				
			});
		});
		$('#AnalogAudioRxAddGroup').on('click',function(){
			var listnum = $('#AnalogAudioGroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('analogaudio','rx',name);
		});
		$('#AnalogAudioTxAddGroup').on('click',function(){
			var listnum = $('#AnalogAudioGroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('analogaudio','tx',name);
		});
	break;
	case 5:		
		$('#Rs232GroupRxSelectBox li').unbind('click');
		$('#Rs232GroupTxSelectBox li').unbind('click');
		$('#Rs232GroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#Rs232GroupSelectRx span').html($('#Rs232GroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('Rs232Preset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#Rs232GroupRxSelectBox').hide();
				_Rs232GrouopRxSelect=0;
			});
		});
		$('#Rs232GroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100Rs232TxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < Encode_Rs232_DataArr.length; i++) {
						if (Encode_Rs232_DataArr[i]!=''&&typeof(Encode_Rs232_DataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+Encode_Rs232_DataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='Rs232DeviceBoxContOnceDisplayImg'></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ Encode_Rs232_DataArr[i][6] + "x" + Encode_Rs232_DataArr[i][7] +"</span>\
			                                        <span>"+ Encode_Rs232_DataArr[i][8] +"Hz</span>\
			                                        <span>"+ Encode_Rs232_DataArr[i][9] + "," + Encode_Rs232_DataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ Encode_Rs232_DataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ Encode_Rs232_DataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_Rs232_DataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_Rs232_DataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+Encode_Rs232_DataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100Rs232TxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100Rs232TxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            var switchType='';
                            if (Encode_Rs232_DataArr[i][12]) {
                            	if (Encode_Rs232_DataArr[i][13]==0) {		
									switchType = '-Genlock';
								}
								else if(Encode_Rs232_DataArr[i][13]=='FAST_SWITCHED'||Encode_Rs232_DataArr[i][13]=='FAST_SWITCHED_CROP'||Encode_Rs232_DataArr[i][13]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
									switchType = '-Fast Switch';
								}
								else if(Encode_Rs232_DataArr[i][13]=='GENLOCK_SCALING'){//genlock scaling
									switchType = '-Genlock Scaling';
								}
								else if(Encode_Rs232_DataArr[i][13]=='WALL_GENLOCKED'){
									switchType = '-Wall Genlock';
								}
                            }
                            $('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxBottomDataScroll span').html(Encode_Rs232_DataArr[i][2]+switchType);
                            if (Encode_Rs232_DataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100Rs232TxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
						}
					}

					$('#Rs232GroupTxSelectBox').hide();
					$('#Rs232GroupSelectTx span').html('Default');
					_Rs232GrouopTxSelect=0;
					LoadGroupSettingFromFile('Rs232Encode_Default','tx',1);
				}
				else if(e!=($('#Rs232GroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#Rs232GroupSelectTx span').html($('#Rs232GroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#Rs232GroupTxSelectBox').hide();
					
					var _id = $('#Rs232GroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_Rs232GrouopTxSelect=0;
					LoadGroupSettingFromFile('Rs232Encode_'+_id,'tx',1);
				}
				
			});
		});
		$('#Rs232RxAddGroup').on('click',function(){			
			var listnum = $('#Rs232GroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('rs232','rx',name);
		});
		$('#Rs232TxAddGroup').on('click',function(){
			var listnum = $('#Rs232GroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('rs232','tx',name);
		});
	break;
	case 6:		
		$('#InfraredGroupRxSelectBox li').unbind('click');
		$('#InfraredGroupTxSelectBox li').unbind('click');
		$('#InfraredGroupRxSelectBox li').each(function(e){
			$(this).on('click',function(){
				DeviceGroupRxSelectNum = e+1;
				$('#InfraredGroupSelectRx span').html($('#InfraredGroupRxSelectBox li:eq('+e+') div:eq(1)').html());				
				LoadGroupSettingFromFile('InfraredPreset_'+DeviceGroupRxSelectNum,'rx',0);
				$('#InfraredGroupRxSelectBox').hide();
				_InfraredGrouopRxSelect=0;
			});
		});
		$('#InfraredGroupTxSelectBox li').each(function(e){
			$(this).on('click',function(){
				if (e==0) {
					$('.IPAV1100InfraredTxCont li').each(function(e){                        
                        $(this).html('');
                        $(this).removeClass('deviceBoxHasDevice');                        
                    });  
					for (var i = 0; i < Encode_Infrared_DataArr.length; i++) {
						if (Encode_Infrared_DataArr[i]!=''&&typeof(Encode_Infrared_DataArr[i])!='undefined') {
							var _list = "<div class='DeviceBoxNavTop'>\
		                                    <span>"+Encode_Infrared_DataArr[i][0]+"</span>\
		                                    <a class='DeviceBoxNavTopStatus'></a>\
		                                    <a class='DeviceBoxNavTopSetting'></a>\
		                                    <a class='DeviceBoxNavTopStop'></a>\
		                                    <a class='DeviceBoxNavTopLocked'></a>\
		                                </div>\
		                                <div class='DeviceBoxCont'>\
		                                    <div class='DeviceBoxContOnceDisplay'>\
			                                    <div class='InfraredDeviceBoxContOnceDisplayImg'></div>\
			                                    <div class='DeviceBoxContOnceDisplayInfo'>\
			                                        <span>"+ Encode_Infrared_DataArr[i][6] + "x" + Encode_Infrared_DataArr[i][7] +"</span>\
			                                        <span>"+ Encode_Infrared_DataArr[i][8] +"Hz</span>\
			                                        <span>"+ Encode_Infrared_DataArr[i][9] + "," + Encode_Infrared_DataArr[i][10] + "Bit</span>\
			                                    </div>\
			                                </div>\
                                		</div>\
                                        <div class='DeviceBoxBottom'>\
                                            <div class='DeviceBoxBottomDataScroll'>\
                                                <div><span>"+ Encode_Infrared_DataArr[i][2] +"</span></div>\
                                                <img src='images/deviceBoxBottomIco.png'>\
                                            </div>\
                                            <div class='DeviceBoxBottomDataDetail'>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Hostname:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+ Encode_Infrared_DataArr[i][0] +"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>IP:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_Infrared_DataArr[i][2]+"</span>\
                                                </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>MAC:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>"+Encode_Infrared_DataArr[i][1]+"</span>\
                                                    </div>\
                                                <div>\
                                                    <span class='DeviceBoxBottomDataDetailLeft'>Firmware:</span>\
                                                    <span class='DeviceBoxBottomDataDetailRifht'>v"+Encode_Infrared_DataArr[i][3]+"</span>\
                                                </div>\
                                            </div>\
                                        </div>";
                            $('.IPAV1100InfraredTxCont li:eq('+i+')').html(_list);
                            $('.IPAV1100InfraredTxCont li:eq('+i+')').addClass('deviceBoxHasDevice');
                            var switchType='';
                            if (Encode_Infrared_DataArr[i][12]) {
                            	if (Encode_Infrared_DataArr[i][13]==0) {		
									switchType = '-Genlock';
								}
								else if(Encode_Infrared_DataArr[i][13]=='FAST_SWITCHED'||Encode_Infrared_DataArr[i][13]=='FAST_SWITCHED_CROP'||Encode_Infrared_DataArr[i][13]=='FAST_SWITCHED_STRETCH'){//fast switch full screen 
									switchType = '-Fast Switch';
								}
								else if(Encode_Infrared_DataArr[i][13]=='GENLOCK_SCALING'){//genlock scaling
									switchType = '-Genlock Scaling';
								}
								else if(Encode_Infrared_DataArr[i][13]=='WALL_GENLOCKED'){
									switchType = '-Wall Genlock';
								}
                            }
                            $('.IPAV1100InfraredTxCont li:eq(' + (i) + ') .DeviceBoxBottomDataScroll span').html(Encode_Infrared_DataArr[i][2]+switchType);
                            if (Encode_Infrared_DataArr[i][5]=='STREAMING') {
				            	$('.IPAV1100InfraredTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').addClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100InfraredTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').addClass('DeviceBoxNavTopStatusStreaming');
				            }
				            else {
				            	$('.IPAV1100InfraredTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStop').removeClass('DeviceBoxNavTopStreaming');
				            	$('.IPAV1100InfraredTxCont li:eq(' + (i) + ') .DeviceBoxNavTopStatus').removeClass('DeviceBoxNavTopStatusStreaming');
				            }
						}
					}

					$('#InfraredGroupTxSelectBox').hide();
					$('#InfraredGroupSelectTx span').html('Default');
					_InfraredGrouopTxSelect=0;
					LoadGroupSettingFromFile('InfraredEncode_Default','tx',1);
				}
				else if(e!=($('#InfraredGroupTxSelectBox li').length-1)){
					DeviceGroupTxSelectNum = e;
					$('#InfraredGroupSelectTx span').html($('#InfraredGroupTxSelectBox li:eq('+e+') div:eq(1)').html());
					$('#InfraredGroupTxSelectBox').hide();
					
					var _id = $('#InfraredGroupTxSelectBox li:eq('+e+') span:eq(1)').html();
					var data = 'type=6&id='+_id;
					PageAddGroup(data,'txDisplayGroupDevice',_id);
					_InfraredGrouopTxSelect=0;
					LoadGroupSettingFromFile('InfraredEncode_'+_id,'tx',1);
				}
				
			});
		});
		$('#InfraredRxAddGroup').on('click',function(){			
			var listnum = $('#InfraredGroupRxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('infrared','rx',name);
		});
		$('#InfraredTxAddGroup').on('click',function(){
			var listnum = $('#InfraredGroupTxSelectBox li').length-1;
			if (listnum>=9) return;
			var name = 'Group #' + listnum;
			AddToGroupDisplayBox('infrared','tx',name);
		});
	break;
	}
}
/*****************************************
 *
 * 		改变设备数组数据的位置
 *		_arr:数据数组
 *		_nowPosition:改变前的位置
 *		_changePosition:改变后的位置
 *		type:1[有设备]、2[无设备]
 * 
 *****************************************/
function changeDeviceIDArrPosition(_arr,_nowPosition,_changePosition,type){
 	var _arrTmp = _arr.split(','),
		_nowPositionTmp = parseInt(_nowPosition),
		_changePositionTmp = parseInt(_changePosition),
		_type = type;
	var _arrToString='';
	if (_type == 0) {
		if (_nowPosition!=_changePosition) {
	 		_arrTmp[_changePosition] = _arrTmp[_nowPositionTmp];
			_arrTmp[_nowPositionTmp] = '';
	 	}		
	}
	else if(_type == 1){
		if (_nowPosition!=_changePosition) {
			var _a = _arrTmp[_nowPositionTmp];
			_arrTmp[_nowPositionTmp] = _arrTmp[_changePosition];
			_arrTmp[_changePosition] = _a;
		}		
	}
	for (var i = 0; i < _arrTmp.length; i++) {
		if (typeof(_arrTmp[i])=='undefined'||_arrTmp[i]=='') {
			_arrToString += ',';
		}
		else if (_arrTmp[i]!='') {
			_arrToString += _arrTmp[i] + ',';
		}		
	}
	//console.log(_nowPosition+":"+_changePosition);
	//console.log(_arrToString);
	return _arrToString;

}
// 
function LoadGroupSettingFromFile(name,type,mode){
	var SendData = 'ReadGroupSaveSettingName='+name;	
	if (type=='rx') {
		$.ajax({
	        type: 'POST',
	        url: 'common/GroupSaveSetting.php',
	        data: SendData,
	        datatype: 'json',
	        async: true,
	        success: function(rst) {
	        	if (rst=='') return;
	        	var _rst = rst.split(',');
	        	for (var i = 0; i < _rst.length; i++) {
	        		if (_rst[i]!='') {
	        			var _rstArr = _rst[i].split(':');
			        	if (current_page==1) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=join ' + _rstArr[2] + ':HDMI:0 ' + _DeviceArr[j] + ':HDMI:0';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=join ' + _rstArr[2] + ':HDMI:0 ' + _DeviceArr + ':HDMI:0';
			        			sendCommand(data);
			        		}				        		
			        	}
			        	else if (current_page==2) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=join ' + _rstArr[2] + ':HDMI:0 ' + _DeviceArr[j] + ':HDMI:0';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=join ' + _rstArr[2] + ':HDMI:0 ' + _DeviceArr + ':HDMI:0';
			        			sendCommand(data);
			        		}
				        		
			        	}
			        	else if (current_page==3) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=join ' + _rstArr[2] + ':HDMI_AUDIO:0 ' + _DeviceArr[j] + ':HDMI_AUDIO:0';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=join ' + _rstArr[2] + ':HDMI_AUDIO:0 ' + _DeviceArr + ':HDMI_AUDIO:0';
			        			sendCommand(data);
			        		}
				        		
			        	}
			        	else if (current_page==4) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=join ' + _rstArr[2] + ':AUDIO:0 ' + _DeviceArr[j] + ':AUDIO:0';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=join ' + _rstArr[2] + ':AUDIO:0 ' + _DeviceArr + ':AUDIO:0';
			        			sendCommand(data);
			        		}
				        		
			        	}
			        	else if (current_page==5) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=switch ' + _rstArr[2] + ':RS232:1 ' + _DeviceArr[j] + ':RS232:1';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=switch ' + _rstArr[2] + ':RS232:1 ' + _DeviceArr + ':RS232:1';
			        			sendCommand(data);
			        		}
				        		
			        	}
			        	else if (current_page==6) {
			        		if (_rstArr[15].indexOf('|')>=0){
			        			var _DeviceArr = _rstArr[15].split('|');
			        			for (var j = 0; j < _DeviceArr.length; j++) {
				        			if (_DeviceArr[j]!='') {
				        				data='data=switch ' + _rstArr[2] + ':INFRARED:0 ' + _DeviceArr[j] + ':INFRARED:0';
				        				sendCommand(data);
				        			}
				        		}
			        		}
			        		else {
			        			var _DeviceArr = _rstArr[15];
			        			data='data=switch ' + _rstArr[2] + ':INFRARED:0 ' + _DeviceArr + ':INFRARED:0';
			        			sendCommand(data);
			        		}
				        		
			        	}
			        	
	        		}
	        	}
	        } 
	    });
	}
	    
}
