
$('#GroupSettingBox li:eq(0)').on('click',function(){//rename
	
	$('.renameBox').show();
	if (document.getElementById('GroupSettingBox')) {//清除元素
		document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));
		//$('.listContList:eq(0) li').removeClass('listContListLiHover');
	}
});
	
$('#GroupSettingBox li:eq(1)').on('click',function(){//delete
	var groupID;
	
	if (_devicetype=='rx') {
		// $('#decodersGroup li').each(function(e){
		// 	if ($(this).hasClass('listHover')) {
		// 		groupID = parseInt($('#decodersGroup li:eq('+e+') span').html());
		// 	}
		// });
		groupID = parseInt($('#decodersGroup li:eq('+_GroupNumber+') span').html());
	}
	else if(_devicetype=='tx'){
		// $('#encodersGroup li').each(function(e){
		// 	if ($(this).hasClass('listHover')) {
		// 		groupID = parseInt($('#encodersGroup li:eq('+e+') span').html());
		// 	}
		// });
		groupID = parseInt($('#encodersGroup li:eq('+_GroupNumber+') span').html());
	}
	if (document.getElementById('GroupSettingBox')) {//清除元素
		document.getElementById('GroupSettingBox').parentNode.removeChild(document.getElementById('GroupSettingBox'));
		//$('.listContList:eq(0) li').removeClass('listContListLiHover');
	}
	
	var data = 'type=3&id='+groupID+'&pagetype=rs232&devicetype='+_devicetype;
	//console.log(data);
	PageAddGroup(data);
	setTimeout(function(){
		if (_devicetype=='rx') {
			$('#decodersGroup').html(ajaxDataStream);
		}
		else if(_devicetype=='tx'){
			$('#encodersGroup').html(ajaxDataStream);
		}
		
		addListenEvent();//重新添加监听事件
	},100);
		

});

$('.zhezhao').on('click',function(){
	$('.renameBox').hide();
});

$('#renameBoxBtn').on('click',function(){
	var groupID;
	var name = $('#GroupRename').val();
	if (_devicetype=='rx') {
		// $('#decodersGroup li').each(function(e){
		// 	if ($(this).hasClass('listHover')) {
		// 		groupID = parseInt($('#decodersGroup li:eq('+e+') span').html());
		// 	}
		// });
		groupID = parseInt($('#decodersGroup li:eq('+_GroupNumber+') span').html());
	}
	else if(_devicetype=='tx'){
		// $('#encodersGroup li').each(function(e){
		// 	if ($(this).hasClass('listHover')) {
		// 		groupID = parseInt($('#encodersGroup li:eq('+e+') span').html());
		// 	}
		// });
		groupID = parseInt($('#encodersGroup li:eq('+_GroupNumber+') span').html());
	}
	
	var data = 'type=2&id='+groupID+'&rename='+name+'&pagetype=rs232&devicetype='+_devicetype;
	//console.log(data);
	PageAddGroup(data);
	setTimeout(function(){
		if (_devicetype=='rx') {
			$('#decodersGroup').html(ajaxDataStream);
		}
		else if(_devicetype=='tx'){
			$('#encodersGroup').html(ajaxDataStream);
		}
		//$('#decodersGroup').html(ajaxDataStream);
		addListenEvent();//重新添加监听事件
		$('.renameBox').hide();
		$('.renameBoxBtn').unbind('click');	
	},100);
		
});