// Groups List Display Setting
var _devicetype;
var timer,timertx;
var videoswitchingNum=0,videoswitchingNumtx=0;
var eventnum;

current_page="analog_audio";

$('body').on('click',function(){
	switch(eventnum){
		case 'Group':
			if (videoswitchingNum==1) {						
				eventnum = '';
				videoswitchingNum=0;
				console.log('display data1');
				clearInterval(timer);
			}
			if (videoswitchingNumtx==1) {						
				eventnum = '';
				videoswitchingNumtx=0;
				console.log('display data1');
				clearInterval(timertx);
			}
			break;
	}
	if (checkmouseover!=1) {
		setTimeout(function(){
			$('.listCont li').each(function(){
				if ($(this).hasClass('listContListLiHover')) {
					if (document.getElementById('CommonList')) {
						document.getElementById('CommonList').parentNode.removeChild(document.getElementById('CommonList'));
						$('.listContList:eq(0) li').removeClass('listContListLiHover');
						$('.listContList:eq(1) li').removeClass('listContListLiHover');
						//$('.listHeadRightCont li').removeClass('listContListLiHover');
					}
					if (document.getElementById('GroupSettingBox')) {
						document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));
						//$('.listContList:eq(0) li').removeClass('listContListLiHover');
					}
				}
				
			});
		},150);
			
	}
		
});
$('body').on('click',function(){
	setTimeout(function(){
		if (document.getElementById('CommonList')) {
			document.getElementById('CommonList').parentNode.removeChild(document.getElementById('CommonList'));
			$('.listContList:eq(0) li').removeClass('listContListLiHover');
			$('.listContList:eq(1) li').removeClass('listContListLiHover');
			$('.listHeadRightCont li').removeClass('listContListLiHover');
		}
		if (document.getElementById('GroupSettingBox')) {
			document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));
		}
	},150);
		
});

addListenEvent();
addDisplayListenEvent(0);
addDisplayListenEvent(1);

// 载入list弹出事件
function addDisplayListenEvent(num){
	if (num==0) {// decoder list event
		$('.listContList:eq(0) li').each(function(e){
			$(this).on('mousedown',function(){
				if (!$(this).hasClass('decodeencodeexist')&&$(this).html()=="<div class=\"DragToDropBtn\"></div>") {
                    return;
                }
                if (e==0&&$('#decodersGroup li:eq(0)').hasClass('listHover')) return;
				$('.listContList:eq(0) li').each(function (a) {
                    $('.listContList:eq(0) li:eq('+a+') div:eq(0)').removeClass('AudioDisplayStream');
                });
                $('.listContList:eq(1) li').each(function (a) {
                    $('.listContList:eq(1) li:eq('+a+') div:eq(0)').removeClass('AudioDisplayStream');
                });
				$('.listContList:eq(0) li').removeClass('listContListLiHover');
				$('.listContList:eq(1) li').removeClass('listContListLiHover');
				$(this).addClass('listContListLiHover');
				if (e!=0&&$('#decodersGroup li:eq(0)').hasClass('listHover')) {
                    $('.listContList:eq(0) li:eq('+e+') div:eq(0)').addClass('AudioDisplayStream');
                    CheckDeviceRouting(Decode_AnalogAudio_DataArr[e-1][5],'analog_audio');
                }
                else {
						for (var i = 0; i < Decode_AnalogAudio_DataArr.length; i++) {
							// for (var j = 0; j < EncodeGroupDataListArr.length; j++) {
								var _EncodeGroupDataListArr = DecodeGroupDataListArr[e].split(':');
								if (Decode_AnalogAudio_DataArr[i][1]==_EncodeGroupDataListArr[0]) {
									CheckDeviceRouting(Decode_AnalogAudio_DataArr[i][5],'analog_audio');
									$('.listContList:eq(0) li:eq('+e+') div:eq(0)').addClass('AudioDisplayStream');
								}
							// }
						}
						
					}
			});	
			$(this).on('mouseover',function(){
				if (!$(this).hasClass('decodeencodeexist')&&$(this).html()=="<div class=\"DragToDropBtn\"></div>") {
                    return;
                }
                if (e==0&&$('#decodersGroup li:eq(0)').hasClass('listHover')) return;
				checkmouseover = 1;
				checkMouseWherePosition = 'analogaudiodecode';
			});
			$(this).on('mouseleave',function(){
				checkmouseover = 2;
				checkMouseWherePosition = '';
			});	
		});
	}
	else if(num==1){// encoder list event
		$('.listContList:eq(1) li').each(function(e){
			$(this).on('mousedown',function(){
				if (!$(this).hasClass('decodeencodeexist')&&$(this).html()=="<div class=\"DragToDropBtn\"></div>") {
                    return;
                }
				$('.listContList:eq(0) li').each(function (a) {
                    $('.listContList:eq(0) li:eq('+a+') div:eq(0)').removeClass('AudioDisplayStream');
                });
                $('.listContList:eq(1) li').each(function (a) {
                    $('.listContList:eq(1) li:eq('+a+') div:eq(0)').removeClass('AudioDisplayStream');
                });
				$('.listContList:eq(0) li').removeClass('listContListLiHover');
				$('.listContList:eq(1) li').removeClass('listContListLiHover');
				$(this).addClass('listContListLiHover');
				$('.listContList:eq(1) li:eq('+e+') div:eq(0)').addClass('AudioDisplayStream');
				if ($('#encodersGroup li:eq(0)').hasClass('listHover')) {                    
	                CheckDeviceRouting(Encode_AnalogAudio_DataArr[e][5],'analog_audio');
                }  
				else {
					for (var i = 0; i < Encode_AnalogAudio_DataArr.length; i++) {
							// for (var j = 0; j < EncodeGroupDataListArr.length; j++) {
						var _EncodeGroupDataListArr = EncodeGroupDataListArr[e].split(':');
						if (Encode_AnalogAudio_DataArr[i][1]==_EncodeGroupDataListArr[0]) {
							CheckDeviceRouting(Encode_AnalogAudio_DataArr[i][5],'analog_audio');
						}
							// }
					}
				}
			});	
			$(this).on('mouseover',function(){
				if (!$(this).hasClass('decodeencodeexist')&&$(this).html()=="<div class=\"DragToDropBtn\"></div>") {
                    return;
                }
				checkmouseover = 1;
				checkMouseWherePosition = 'analogaudioencode';
			});
			$(this).on('mouseleave',function(){
				checkmouseover = 2;
				checkMouseWherePosition = '';
			});
		});
	} 
}
// 载入Group分组弹出BOX事件
function addListenEvent(){
	$('#decodersGroup li').each(function(e){
		$(this).on('mousedown',function(a){	
			_GroupNumber = e;		
		});
		$(this).on('click',function(){
			$('#decodersGroup li').removeClass();
            $(this).addClass('listHover');
			ReadDataFromFile('PositionInfoFromFile=5');
            ReadDataFromFile('PositionInfoFromFile=6');
			if (document.getElementById('GroupSettingBox')) {
				document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));			
			}
			videoswitchingNum=0;
			var titleinfoDecodeArr = stringToArray(titleinfoDecode,1);
			//console.log('display data');
			clearInterval(timer);
			if (e==0) {
				$('.listContList:eq(0) ul').html('');
                var _arr = _data.videoswitching_decode_arr.split(',');
                var _li_head = "<li ondragover='exp1(event)' ondrop='exp(event)'>\
									<span class='macaddress'>All Displayers</span>\
									<span>&nbsp;</span>\
									<span>All_Rx</span>\
									<span></span>\
									<span></span>\
									<span></span>\
									<span></span>\
									<span></span>\
									<span></span>\
									<div class='AudioAllRx'></div>\
									<div class='DragToDropBtn'></div>\
								</li>";
                $('.listContList:eq(0) ul').append(_li_head);
                for (var i = 0; i < _arr.length-1; i++) {
                	if (_arr[i]!='') {
                		var _list = "<li id='DeviceDecodePositionID"+(i+1)+"' class='decodeencodeexist' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)' draggable='true' ondragstart='DecodeExpstart(event)'>\
										<span class='macaddress' "+(titleinfoDecodeArr[0]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[i][0]+"</span>\
										<span class='macaddress' "+(titleinfoDecodeArr[1]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[i][1]+"</span>\
										<span class='macaddress' "+(titleinfoDecodeArr[2]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[i][2]+"</span>\
										<span class='macaddress' "+(titleinfoDecodeArr[3]=='0'?"style='display:none'":'') + ">V"+Decode_AnalogAudio_DataArr[i][3]+"</span>\
										<span class='macaddress'>"+(Decode_AnalogAudio_DataArr[i][4]==true?'Point-to-Point':'')+"</span>\
										<span class='macaddress' "+(titleinfoDecodeArr[5]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[i][5]+"</span>\
										<span class='macaddress'></span>\
										<span class='macaddress'></span>\
										<span class='macaddress'></span>\
										<div class='AudioDisplayType'></div>\
										<div class='DragToDropBtn'></div>\
									</li>";
	                    $('.listContList:eq(0) ul').append(_list);
	                    if (Decode_AnalogAudio_DataArr[i][7]=='0'&&Decode_AnalogAudio_DataArr[i][8]=='0') {
			            	$('.listCont:eq(0) .listContList ul li:eq(' + (i + 1) + ') div:eq(0)').removeClass('decodeDisplayStream');
			            	$('.listCont:eq(0) .listContList ul li:eq(' + (i + 1) + ') div:eq(0)').removeClass('decodeDisplayType');
			            }else{
			            	$('.listCont:eq(0) .listContList ul li:eq(' + (i + 1) + ') div:eq(0)').addClass('decodeDisplayType');
			            }
			            var _arr = decodePinPosition.split(',');
		        		for (var j = 0; j < _arr.length; j++) {
		        			var _arrTmp = _arr[j].split(':');
		        			if (_arrTmp[0]==Decode_AnalogAudio_DataArr[i][1]) {
		        				$('#DeviceDecodePositionID'+(i+1)).append("<div class='PositionPIN'></div>");
		        			}
		        		}
                	}
                	else{
                        $('.listCont:eq(0) .listContList ul').append("<li id='DeviceDecodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");
                    }
                    
				}
				if ($('.listCont:eq(0) .listContList ul li').length<12) {
	        		for (var i = $('.listCont:eq(0) .listContList ul li').length; i <12; i++) {
	        			if($('#decodersGroup li:eq(0)').hasClass('listHover')){
	        				$('.listCont:eq(0) .listContList ul').append("<li id='DeviceDecodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");
	        				DecodeDetaileDataArr[i-1] = '';
		        			Decode_AnalogAudio_DataArr[i-1] = '';
	        			}
	        		}
	        	}
				addDisplayListenEvent(0);
				return;
			}else{
				var data = 'type=6&id='+$('#decodersGroup li:eq('+e+') span').html();
				//console.log(data);
				PageAddGroup(data);
				setTimeout(function(){
					data = ajaxDataStream;
					if (data=='null') {
						$('.listContList:eq(0) ul').html('');
						return;
					}
					DecodeGroupDataListArr = data.split(',');
					//console.log(dataArr);
					$('.listContList:eq(0) ul').html('');				

					var _arr = _data.videoswitching_decode_arr.split(',');
					var _num;
					$('.listContList:eq(0) ul').append(_li_head);
					if ($('.listCont:eq(0) .listContList ul li').length<12) {
		        		for (var i = $('.listCont:eq(0) .listContList ul li').length; i <12; i++) {	        			
		        			$('.listCont:eq(0) .listContList ul').append("<li id='DeviceDecodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");
		        				
		        		}
		        	}
		        	// if ($('.listCont:eq(1) .listContList ul li').length<12) {
		        	// 	for (var i = $('.listCont:eq(1) .listContList ul li').length; i <12; i++) {
		        	// 		$('.listCont:eq(1) .listContList ul').append("<li id='DeviceEncodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>"); 			
		        	// 	}
		        	// }
		        	
					for (var i = 0; i < DecodeGroupDataListArr.length; i++) {
	                    (function(ii){
	                        if (DecodeGroupDataListArr[ii]!='') {
	                            var _DecodeGroupDataListArrID = DecodeGroupDataListArr[ii].split(':');
	                            var _checkOnLine=0;
	                            for (var j = 0; j < _arr.length-1; j++) {
	                                (function(jj){                                  
	                                    if (_DecodeGroupDataListArrID[0]==_arr[jj]) {
	                                        _num = jj;  
	                                        _checkOnLine=1;
	                                    }
	                                })(j);                              
	                            }
	                            if (_checkOnLine==0) {
	                                var _list = "<span class='macaddress' "+(titleinfoDecodeArr[0]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[1]=='0'?"style='display:none'":'') + ">"+_DecodeGroupDataListArrID[0]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[2]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[3]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[4]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[5]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[6]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[7]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[8]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <div class='AudioDisplayType'></div>\
	                                                <div class='DragToDropBtn'></div>";
	                                $('#DeviceDecodePositionID'+ii).html(_list);
	                                // $('#DeviceDecodePositionID'+ii).removeClass('decodeencodeexist');
	                                // $('#DeviceDecodePositionID'+ii).addClass('deviceDisconnectedType');
	                                $('#DeviceDecodePositionID'+ii).addClass('decodeencodeexist');
	                                $('#DeviceDecodePositionID'+ii).attr('draggable',true);
	                                $('#DeviceDecodePositionID'+ii).attr('ondragstart','DecodeExpstart(event)');
	                                var _DecodeGroupDataListArrID = DecodeGroupDataListArr[ii].split(':');
	                                if (parseInt(_DecodeGroupDataListArrID[1])>=0) {
	                                    $('#DeviceDecodePositionID'+ii).append("<div class='PositionPIN'></div>");
	                                }
	                            }
	                            else {
	                                if (typeof(Decode_AnalogAudio_DataArr[_num])=='undefined') {
	                                    Decode_AnalogAudio_DataArr[_num]=[];
	                                }
	                                //<li id='DeviceDecodePositionID"+(ii)+"' class='decodeencodeexist' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)' draggable='true' ondragstart='DecodeExpstart(event)'>
	                                var _list = "<span class='macaddress' "+(titleinfoDecodeArr[0]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[_num][0]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[1]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[_num][1]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[2]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[_num][2]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[3]=='0'?"style='display:none'":'') + ">V"+Decode_AnalogAudio_DataArr[_num][3]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[4]=='0'?"style='display:none'":'') + ">"+(Decode_AnalogAudio_DataArr[_num][4]=='FAST_SWITCHED'?'Genlock':Decode_AnalogAudio_DataArr[_num][4])+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[5]=='0'?"style='display:none'":'') + ">"+Decode_AnalogAudio_DataArr[_num][5]+"</span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[6]=='0'?"style='display:none'":'') + "></span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[7]=='0'?"style='display:none'":'') + "></span>\
	                                                <span class='macaddress' "+(titleinfoDecodeArr[8]=='0'?"style='display:none'":'') + "></span>\
	                                                <div class='AudioDisplayType'></div>\
	                                                <div class='DragToDropBtn'></div>";
	                                $('#DeviceDecodePositionID'+ii).html(_list);
	                                $('#DeviceDecodePositionID'+ii).addClass('decodeencodeexist');
	                                // $('#DeviceDecodePositionID'+ii).removeClass('deviceDisconnectedType');
	                                $('#DeviceDecodePositionID'+ii).attr('draggable',true);
	                                $('#DeviceDecodePositionID'+ii).attr('ondragstart','DecodeExpstart(event)');
	                                var _DecodeGroupDataListArrID = DecodeGroupDataListArr[ii].split(':');
	                                if (parseInt(_DecodeGroupDataListArrID[1])>=0) {
	                                    $('#DeviceDecodePositionID'+ii).append("<div class='PositionPIN'></div>");
	                                }
	                                // if (Decode_AnalogAudio_DataArr[ii][7]=='0'&&Decode_AnalogAudio_DataArr[ii][8]=='0') {
	                                //     $('.listCont:eq(0) .listContList ul li:eq(' + ii + ') div:eq(0)').removeClass('AudioDisplayType');
	                                //     $('.listCont:eq(0) .listContList ul li:eq(' + ii + ') div:eq(0)').removeClass('AudioDisplayType');
	                                // }else{
	                                //     $('.listCont:eq(0) .listContList ul li:eq(' + ii + ') div:eq(0)').addClass('AudioDisplayType');
	                                // }
	                            }                               
	                        }
	                    })(i);                                              
	                }
					
					addDisplayListenEvent(0);
				},100);
					
				// CheckGroupPosition(0,DecodeGroupDataListArr);
			}
		
		});
		$(this).on('mouseover',function(){
			if (e==0) return;
			checkMouseWherePosition = 'analogaudiodecodeGroup';
		});
		$(this).on('mouseleave',function(){
			if (e==0) return;
			checkMouseWherePosition = '';
		});
	});
	$('#encodersGroup li').each(function(e){
		$(this).on('mousedown',function(a){	
			_GroupNumber = e;			
		});
		$(this).on('click',function(){
			$('#encodersGroup li').removeClass();
            $(this).addClass('listHover');
			ReadDataFromFile('PositionInfoFromFile=5');
            ReadDataFromFile('PositionInfoFromFile=6');
			if (document.getElementById('GroupSettingBox')) {
				document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));			
			}
			videoswitchingNumtx=0;				
			clearInterval(timertx);		
			var titleinfoEncodeArr = stringToArray(titleinfoEncode,1);
			if (e==0) {
				$('.listContList:eq(1) ul').html('');
				var _arr = _data.videoswitching_encode_arr.split(',');

                for (var i = 0; i < _arr.length-1; i++) {
                	if (_arr[i]!='') {
                		var _list = "<li id='DeviceEncodePositionID"+i+"' class='decodeencodeexist' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)' draggable='true' ondragstart='expstart(event)'>\
										<span class='macaddress' "+(titleinfoEncodeArr[0]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[i][0]+"</span>\
										<span class='macaddress' "+(titleinfoEncodeArr[1]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[i][1]+"</span>\
										<span class='macaddress' "+(titleinfoEncodeArr[2]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[i][2]+"</span>\
										<span class='macaddress' "+(titleinfoEncodeArr[3]=='0'?"style='display:none'":'') + ">V"+Encode_AnalogAudio_DataArr[i][3]+"</span>\
										<span class='macaddress'>"+(Encode_AnalogAudio_DataArr[i][4]==true?'Point-to-Point':'')+"</span>\
										<span class='macaddress' "+(titleinfoEncodeArr[5]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[i][5]+"</span>\
										<span class='macaddress' "+(titleinfoEncodeArr[6]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[i][6]+"</span>\
										<span class='macaddress'></span>\
										<span class='macaddress'></span>\
										<div class='AudioDisplayType'></div>\
										<div class='DragToDropBtn'></div>\
									</li>";
						$('.listContList:eq(1) ul').append(_list);						
			            var _arr = encodePinPosition.split(',');
		        		for (var j = 0; j < _arr.length; j++) {
		        			var _arrTmp = _arr[j].split(':');
		        			if (_arrTmp[0]==Encode_AnalogAudio_DataArr[i][1]) {
		        				$('#DeviceEncodePositionID'+(i)).append("<div class='PositionPIN'></div>");
		        			}
		        		}
                	}	
                	else{
                        $('.listCont:eq(1) .listContList ul').append("<li id='DeviceEncodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");
                    }
                    
				}
				if ($('.listCont:eq(1) .listContList ul li').length<12) {
                    for (var i = $('.listCont:eq(1) .listContList ul li').length; i <12; i++) {
                        if($('#encodersGroup li:eq(0)').hasClass('listHover')){
                            $('.listCont:eq(1) .listContList ul').append("<li id='DeviceEncodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");
                            EncodeDetaileDataArr[i] = '';
                            Encode_AnalogAudio_DataArr[i] = '';
                        }                        
                    }
                }
				addDisplayListenEvent(1);
				return;
			}else{
				var data = 'type=6&id='+$('#encodersGroup li:eq('+e+') span').html();
				//console.log(data);
				PageAddGroup(data);
				setTimeout(function(){
					data = ajaxDataStream;
					if (data=='null') {
						$('.listContList:eq(1) ul').html('');
						return;
					}
	 				EncodeGroupDataListArr = data.split(',');
	                //console.log(dataArr);
	                $('.listContList:eq(1) ul').html('');
	                var _arr = _data.videoswitching_encode_arr.split(',');
	                var _num;
	                if ($('.listCont:eq(1) .listContList ul li').length<12) {
	                    for (var i = $('.listCont:eq(1) .listContList ul li').length; i <12; i++) {
	                        $('.listCont:eq(1) .listContList ul').append("<li id='DeviceEncodePositionID"+i+"' ondragover='exp1(event)' ondrop='deviceToChangePosition(event)'><div class='DragToDropBtn'></div></li>");            
	                    }
	                }
	                
	                for (var i = 0; i < EncodeGroupDataListArr.length; i++) {
	                    (function(ii){
	                        if (EncodeGroupDataListArr[ii]!='') {
	                        	var _checkOnLine=0;
	                        	var _EncodeGroupDataListArrID = EncodeGroupDataListArr[ii].split(':');   
	                            for (var j = 0; j < _arr.length-1; j++) {
	                                (function(jj){                                                                   
	                                    if (_EncodeGroupDataListArrID[0]==_arr[jj]) {
	                                        _num = jj;
	                                        _checkOnLine = 1;                                       
	                                    }
	                                })(j);
	                                
	                            }
	                            if (_checkOnLine==0) {
	                            	var _list = "<span class='macaddress' "+(titleinfoEncodeArr[0]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[1]=='0'?"style='display:none'":'') + ">"+_EncodeGroupDataListArrID[0]+"</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[2]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[3]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[4]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[5]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[6]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[7]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <span class='macaddress' "+(titleinfoEncodeArr[8]=='0'?"style='display:none'":'') + ">&nbsp;</span>\
	                                                <div class='AudioDisplayType'></div>\
	                                                <div class='DragToDropBtn'></div>";
	                                $('#DeviceEncodePositionID'+ii).html(_list);
	                                // $('#DeviceDecodePositionID'+ii).removeClass('decodeencodeexist');
	                                // $('#DeviceDecodePositionID'+ii).addClass('deviceDisconnectedType');
	                                $('#DeviceEncodePositionID'+ii).addClass('decodeencodeexist');
	                                $('#DeviceEncodePositionID'+ii).attr('draggable',true);
	                                $('#DeviceEncodePositionID'+ii).attr('ondragstart','expstart(event)');
	                                var _EncodeGroupDataListArrID = EncodeGroupDataListArr[ii].split(':');
	                                if (parseInt(_EncodeGroupDataListArrID[1])>=0) {
	                                    $('#DeviceEncodePositionID'+ii).append("<div class='PositionPIN'></div>");
	                                }
	                            }
	                            else {
	                            	if (typeof(Encode_AnalogAudio_DataArr[_num])=='undefined') {
		                                Encode_AnalogAudio_DataArr[_num]=[];
		                            }
		                            //<li class='decodeencodeexist' draggable='true' ondragstart='expstart(event)'>\
		                            var _list = "<span class='macaddress' "+(titleinfoEncodeArr[0]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[_num][0]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[1]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[_num][1]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[2]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[_num][2]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[3]=='0'?"style='display:none'":'') + ">V"+Encode_AnalogAudio_DataArr[_num][3]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[4]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[_num][4]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[5]=='0'?"style='display:none'":'') + ">"+Encode_AnalogAudio_DataArr[_num][5]+"</span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[6]=='0'?"style='display:none'":'') + "></span>\
		                                            <span class='macaddress' "+(titleinfoEncodeArr[7]=='0'?"style='display:none'":'') + "></span>\
		                                            <div class='AudioDisplayType'></div>\
		                                            <div class='DragToDropBtn'></div>";
		                            $('#DeviceEncodePositionID'+ii).html(_list);
		                            $('#DeviceEncodePositionID'+ii).addClass('decodeencodeexist');
		                            $('#DeviceEncodePositionID'+ii).attr('draggable',true);
		                            $('#DeviceEncodePositionID'+ii).attr('ondragstart','expstart(event)');
		                            var _EncodeGroupDataListArrID = EncodeGroupDataListArr[ii].split(':');
		                            if (parseInt(_EncodeGroupDataListArrID[1])>=0) {
		                                $('#DeviceEncodePositionID'+ii).append("<div class='PositionPIN'></div>");
		                            }   
	                            }
		                                                     
	                        }
	                    })(i);                                              
	                }
	                addDisplayListenEvent(1);
				},100);
					
			}
		});
		$(this).on('mouseover',function(){
			if (e==0) return;
			checkMouseWherePosition = 'analogaudioencodeGroup';
		});
		$(this).on('mouseleave',function(){
			if (e==0) return;
			checkMouseWherePosition = '';
		});
	});
}