var selectedRow = null;
//添加房型
function add() {
	$('#dialog')
		.find('.dlg-content').panel({ href: '/RoomType/Edit/', queryParams: { ID: 0} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', save).end()
		.dialog({
			title: lang.NewRoomType,
			width: 350,
			height: 260
		})
		.dialog('open');
}
//编辑房型
function edit(row) {
	var row = row || $('#dg').datagrid('getSelected');
	if (row) {
		$('#dialog')
			.find('.dlg-content').panel({ href: '/RoomType/Edit/', queryParams: { ID: row.ID} }).end()
			.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', save).end()
			.dialog({
			    title: lang.EditRoomType + '：' + row.Name,
				width: 350,
				height: 260
			})
			.dialog('open');
	} else {
		$.tools.alert(lang.PleaseSelectTheData);
	}
}
//删除房型
function delData(row) {
    var row = row || $('#dg').datagrid('getSelected');
    if (row) {
        $.tools.delPost({ id: row.ID }, '/RoomType/Delete/', function () {
            $('#dg').datagrid('clearSelections');
            $('#dg').datagrid('reload');
        }, this);
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//复制房型
function copy(row) {
    var row = row || $('#dg').datagrid('getSelected');
    if (row) {
        $.tools.confrimPost(lang.CopyRoomTypeFlag, { id: row.ID }, '/RoomType/Copy/', function () {
            $('#dg').datagrid('reload');
        }, this);
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//打开程序文件界面
function programFile(row) {
    var row = row || $('#dg').datagrid('getSelected');
    if (row) {
        $('#dgUpdateHost').datagrid({ url: '/RoomType/LoadRoomTypeProgramFiles/', queryParams: { roomTypeID: row.ID} });
        $('#updateHost').window({ title: lang.ProgramFile + "(" + row.Name + ")" }).window('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//下载程序文件
function downloadFile(val) {
    return '<a href="' + "../../" + val + '" download style="text-decoration:none;">' + lang.Download + '</a>';
}
//上传程序文件
function uploadFile() {
    $('#uploadForm').form('submit', {
        url: '/RoomType/UploadProgramFile/',
        onSubmit: function () {
            return true;
        },
        success: function (r) {
            r = $.parseJSON(r);
            if (r.IsSuccess) {
                $('#uploadFile').window('close');
                $('#dgUpdateHost').datagrid('reload');
            }
            $.tools.alert(r.Message);
        }
    });
}
//删除程序文件
function delProgramFile() {
    var rows = $('#dgUpdateHost').datagrid('getSelections');
    if (!rows || rows.length == 0) {
        $.tools.alert(lang.PleaseSelectTheData);
        return;
    }
    var param;
    $.each(rows, function (i, n) {
        if (i == 0) {
            param = 'idList=' + n.ID;
        } else {
            param += '&idList=' + n.ID;
        }
    });
    $.tools.delPost(param, '/RoomType/DeleteProgramFile/', function () {
        $('#dgUpdateHost').datagrid('clearSelections');
        $('#dgUpdateHost').datagrid('reload');
    }, this);
}
//保存房型
function save() {
	var form = $('#dialog').find('form');
	if (form.form('enableValidation').form('validate')) {
		var entry = form.serializeJson();
		var param = { jsonData: JSON.stringify(entry) };
		$.tools.post(param, '/RoomType/Save/', function () {
			$('#dg').datagrid('reload');
			$('#dialog').window('close');
		}, this);
	}
}
//导入配置文件
function importConfigFile() {
	var row = $('#dg').datagrid('getSelected');
	if (row) {
		$('#dialog')
			.find('.dlg-content').panel({ href: '/RoomType/ImportConfigFile/', queryParams: { ID: row.ID} }).end()
			.find('.dlg-footer .dlg-btn-save').linkbutton({ text: '上传' }).unbind('click').bind('click', uploadConfigFile).end()
			.dialog({
			    title: lang.ImportProfiles,
				width: 600,
				height: 150
			})
			.dialog('open');
	} else {
		$.tools.alert(lang.PleaseSelectTheData);
	}
}
//上传配置文件
function uploadConfigFile() {
	var form = $('#dialog').find('form');
	if (form.form('enableValidation').form('validate')) {
		var param = form.serializeJson();
		$.messager.confirm(lang.ImportProfileConfirm, lang.ConfirmThatOfRoomType + '【' + param.Name + '】' + lang.ImportConfigurationInformationIt, function (r) {
			if (r) {
				form.form('submit', {
					url: '/RoomType/ImportConfig/',
					onSubmit: function () {
						var file = $('#uf', form).filebox('getValue');
						var mime = file.toLowerCase().substr(file.lastIndexOf('.'));
						if (mime !== '.xml') {
						    $.tools.alert(lang.YouCanOnlyImportXmlFormatConfigurationFile);
							return false;
						}
						return true;
					},
					success: function (r) {
						r = $.parseJSON(r);
						if (r.IsSuccess) {
							$('#dialog').window('close');
							$('#dg').datagrid('reload');
						}
						$.tools.alert(r.Message);
					}
				});
			}
		});
	}
}
//打开回路管理界面
function roomTypeModal() {
	var row = $('#dg').datagrid('getSelected');
	if (row) {
		$('#dialog2')
			.find('.dlg-content').panel({ fit: true, border: false, href: '/RoomType/RoomTypeModal/', queryParams: { roomTypeID: row.ID} }).css({ margin: 0 }).end()
			.dialog({
			    title: lang.RoomType + '【' + row.HostName + '】' + lang.Loop,
				width: 990,
				height: 500
			})
			.dialog('open');
	} else {
		$.tools.alert(lang.PleaseSelectTheData);
	}
}
//选择设备类型切换回路
function cbxDeviceTypeOnSelect(r) {
    //原回路列表切换回路改为了新增编辑回路时，默认取回路地址前6位
    /*var queryParams = $('#dgRoomModal').datagrid('options').queryParams;
    queryParams.deviceType = r.value
    $('#dgRoomModal').datagrid('clearSelections');
    $("#dgRoomModal").datagrid('reload');*/
    var id = $('#txtRoomTypeModalID').val();
    if (id == "0") {
        $.tools.post({ deviceType: r.value }, '/RoomType/LoadDefaultRoomModal/', function (result) {
            $('#txtModalAddress').val(result.ModalAddress)
        }, this, true);
    }
}
//添加回路
function addRoomTypeModal(roomTypeID) {
	$('#dialog')
		.find('.dlg-content').panel({ height: 280, href: '/RoomType/RoomTypeModalEdit/', queryParams: { id: 0, roomTypeId: roomTypeID, deviceType: $('#dgRoomModal').datagrid('options').queryParams.deviceType} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeModal).end()
		.dialog({
		    title: lang.NewLoop,
			width: 400,
			height: 380
		})
		.dialog('open');
}
//编辑回路
function editRoomTypeModal(row) {
    row = row || $('#dgRoomModal').datagrid('getSelected');
    if (row) {
        $('#dialog')
			.find('.dlg-content').panel({ height: 280, href: '/RoomType/RoomTypeModalEdit/', 
            queryParams: { 
                            id: row.ID, 
                            roomTypeId: row.RoomTypeID, 
                            deviceType: row.Type, 
                            modalAddress: row.ModalAddress, 
                            outlet: row.Outlet, 
                            name: row.Name, 
                            color: row.Color, 
                            aliasName: row.AliasName,
                            multipleTCLName:row.MultipleTCLName,
                            multipleGroupID: row.MultipleGroupID
                          } }).end()
			.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeModal).end()
			.dialog({
			    title: lang.EditLoop + '【' + row.ID + '/' + row.Name + '】',
			    width: 400,
			    height: 380
			})
			.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//编辑回路（宝易）
function editRoomTypeModalBY(row) {
    row = row || $('#dgRoomModalBY').datagrid('getSelected');
    if (row) {
        $('#dialog')
			.find('.dlg-content').panel({ height: 280, href: '/RoomType/RoomTypeModalEdit/', queryParams: { id: row.ID, roomTypeId: row.RoomTypeID, deviceType: row.Type, modalAddress: row.ModalAddress, outlet: row.Outlet, name: row.Name, color: row.Color, aliasName: row.AliasName} }).end()
			.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeModal).end()
			.dialog({
			    title: lang.EditLoop + '【' + row.ID + '/' + row.Name + '】',
			    width: 400,
			    height: 380
			})
			.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//删除回路
function delRoomTypeModal() {
	var rows = $('#dgRoomModal').datagrid('getChecked');
	if (rows.length <= 0) {
		$.tools.alert(lang.PleaseSelectTheData);
		return;
	}
	var params = '';
	for (var i in rows) {
		/*if (rows[i].Default) {
		    $.tools.alert(lang.YouCanNotDeleteTheDefaultLoop);
			return;
		}*/
		params += '&IDs=' + rows[i].ID;
	}
	$.tools.delPost(params, '/RoomType/RemoveRoomModal/', function () {
		$('#dgRoomModal').datagrid('clearSelections');
		$('#dgRoomModal').datagrid('reload');
	}, this);
}
//保存回路
function saveRoomTypeModal() {
	var form = $('#dialog').find('form');
	if (form.form('enableValidation').form('validate')) {
		var param = form.serialize();
		$.tools.post(param, '/RoomType/SaveRoomTypeModal/', function () {
		    $('#dgRoomModal').datagrid('clearSelections');
			$('#dgRoomModal').datagrid('reload');
			$('#dialog').window('close');
		}, this);
	}
}
//打开场景
function sceneMgmt() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $('#dialog3')
			.find('.dlg-content').panel({ fit: true, border: false, href: '/RoomType/RoomTypeScene/', queryParams: { roomTypeID: row.ID} }).css({ margin: 0 }).end()
			.dialog({
			    title: lang.RoomType + '【' + row.HostName + '】' + lang.Scene,
			    width: 600,
			    height: 400
			})
			.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//添加场景
function addRoomTypeScene(roomTypeID) {
    $('#dialog')
		.find('.dlg-content').panel({ height: 400, href: '/RoomTypeScene/Edit/', queryParams: { id: 0, roomTypeID: roomTypeID} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeScene).end()
		.dialog({
		    title: lang.NewScene,
		    width: 680,
		    height: 490
		})
		.dialog('open');
}
//编辑场景
function editRoomTypeScene(row) {
    row = row || $('#dgScene').datagrid('getSelected');
    if (row) {
        $('#dialog')
		.find('.dlg-content').panel({ height: 400, href: '/RoomTypeScene/Edit/', queryParams: { id: row.ID, roomTypeID: row.RoomTypeID} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeScene).end()
		.dialog({
		    title: lang.EditScene,
		    width: 680,
		    height: 490
		})
		.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//保存场景
function saveRoomTypeScene() {
    if ($('#roomTypeSceneForm').form('enableValidation').form('validate')) {
        if ($.trim($('#txtName').val()) === '') {
            $.tools.alert(lang.PleaseEnterTheModeName);
            return;
        }
        var jsonRoomTypeScene = $('#roomTypeSceneForm').serializeJson();
        var modals = [];
        var rows = $('#dgDevice').datagrid('getRows');
        for (var i in rows) {
            modals.push({
                ID: rows[i].ID,
                Status: rows[i].Status,
                Brightness: rows[i].Brightness,
                CurrentTemp: rows[i].CurrentTemp,
                Mode: rows[i].Mode,
                FanSpeed: rows[i].FanSpeed,
                Valve: rows[i].Valve 
            });
        }
        $.extend(jsonRoomTypeScene, { Modals: modals });
        var params = { jsonData: JSON.stringify(jsonRoomTypeScene) };
        $.tools.post(params, '/RoomTypeScene/Save/', function () {
            $('#dgScene').datagrid('reload');
            $('#dialog').window('close');
        });
    }
}
//删除场景
function delRoomTypeScene() {
    var rows = $('#dgScene').datagrid('getSelections');
    if (!rows || rows.length == 0) {
        $.tools.alert(lang.PleaseSelectTheData);
        return;
    }
    var param;
    $.each(rows, function (i, n) {
        if (i == 0) {
            param = 'idList=' + n.ID;
        } else {
            param += '&idList=' + n.ID;
        }
    });
    $.tools.delPost(param, '/RoomTypeScene/Delete/', function () {
        $('#dgScene').datagrid('clearSelections');
        $('#dgScene').datagrid('reload');
    }, this);
}
//场景类型选择
function sceneTypeOnchange(target) {
    if ($(target).val() == 0) {
        enableComstomScene();
    } else if ($(target).val() == 1) {
        enableCommandScene();
    }
}
//自定义场景
function enableComstomScene() {
    $('#txtGroupAddress').prop('readonly', 'readonly');
    $('#btnAddDevice').linkbutton('enable');
    $('#btnRemoveDevice').linkbutton('enable')
}
//指令场景
function enableCommandScene() {
    $('#txtGroupAddress').removeProp('readonly');
    $('#btnAddDevice').linkbutton('disable');
    $('#btnRemoveDevice').linkbutton('disable');
}
//选择设备回路事件
function dgDeviceOnSelect(index, row) {
    switch (row.Type) {
        case "Dimmer"://LED调光
        case "Traic": //可控硅调光
        case "Strip": //灯带调光
        case "PWMDimmer": //PWM调光
        case "PWMExpand": //PWM扩展
        case "PBLED": //PB LED
            $('#txtBrightness').numberspinner('enable');
            break;
        default:
            $('#txtBrightness').numberspinner('disable');
            break;
    }
}
//场景里添加设备回路
function addDevice() {
    function findDataItem(data, id) {
        if (data) {
            for (var i in data) {
                if (data[i].ID == id) {
                    return data[i];
                }
            }
        }
        return null;
    }
    var row = $('#cbxDevice').combogrid('grid').datagrid('getSelected'); //选中设备
    if (!row) {
        $.tools.alert(lang.PleaseSelectADevice);
        return;
    }
    var data = $('#dgDevice').datagrid('getData');
    if (findDataItem(data.rows, row.ID) !== null) {
        $.tools.alert(lang.LightingHasBeenAdded + '【' + row.Name + '】');
        return;
    }
    var status = $('#cbxStatus').combobox('getValue'); //获取状态
    var brightness = 0;
    var currentTemp = 0;
    var mode = 0;
    var speed = 0;
    var valve = 0;
    switch (row.Type) {
        case "Dimmer": //LED调光
        case "Traic": //可控硅调光
        case "Strip": //灯带调光
        case "PWMDimmer": //PWM调光
        case "PWMExpand": //PWM扩展
        case "PBLED": //PB LED
            if (status != 0) {
                brightness = $('#txtBrightness').numberspinner('getValue'); //获取灯光亮度
            }
            break;
        case "Music":
            if (status == 1) {
                brightness = $('#txtVolume').numberspinner('getValue');
                mode = $('#txtPlayMode').combobox('getValue');
            }
            break;
        case "TV":
            if (status == 1) {
                mode = $('#txtTV').combobox('getValue');
            }
            break;
        case "AirConditioner":
            if (status == 1) {
                currentTemp = $('#txtTemp').numberspinner('getValue');
                mode = $('#txtAirmode').combobox('getValue');
                speed = $('#txtSpeed').combobox('getValue');
                valve = $('#txtValve').combobox('getValue');
            }
            break;
        default:
            break;
    }
    $.extend(row, { Status: status, Brightness: brightness, Mode: mode, CurrentTemp: currentTemp, FanSpeed: speed, Valve: valve });
    $('#dgDevice').datagrid('appendRow', row);

}
//选择下拉框显隐
function dgDeviceOnSelect(index, row) {
    switch (row.Type) {
        case "Dimmer": //LED调光
        case "Traic": //可控硅调光
        case "Strip": //灯带调光
        case "PWMDimmer": //PWM调光
        case "PWMExpand": //PWM扩展
        case "PBLED": //PB LED  
            $('#Brigh').show(); $('#playmode').hide(); $('#volume').hide(); $('#TVOptions').hide();
            $('#aicmode').hide(); $('#Airspeed').hide(); $('#AicTemp').hide(); $('#Valve').hide();
            break;
        case "Music":
            $('#Brigh').hide(); $('#playmode').show(); $('#volume').show(); $('#TVOptions').hide();
            $('#aicmode').hide(); $('#Airspeed').hide(); $('#AicTemp').hide(); $('#Valve').hide();
            break;
        case "AirConditioner":
            $('#Brigh').hide(); $('#playmode').hide(); $('#volume').hide(); $('#TVOptions').hide();
            $('#aicmode').show(); $('#Airspeed').show(); $('#AicTemp').show(); $('#Valve').show();
            break;
        case "TV":
            $('#Brigh').hide(); $('#playmode').hide(); $('#TVOptions').show(); $('#volume').hide();
            $('#aicmode').hide(); $('#Airspeed').hide(); $('#AicTemp').hide(); $('#Valve').hide();
            break;
        default:
            $('#Brigh').hide(); $('#playmode').hide(); $('#volume').hide(); $('#TVOptions').hide();
            $('#aicmode').hide(); $('#Airspeed').hide(); $('#AicTemp').hide(); $('#Valve').hide();
            break;
    }
}
//场景里删除设备回路
function delDevice() {
    var rows = $('#dgDevice').datagrid('getChecked');
    for (var i in rows) {
        var index = $('#dgDevice').datagrid('getRowIndex', rows[i]);
        $('#dgDevice').datagrid('deleteRow', index);
    }
}
//打开微信管理界面
function weiXinMgmt() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $('#dialog3')
			.find('.dlg-content').panel({ fit: true, border: false, href: '/RoomType/RoomTypeWeiXin/', queryParams: { roomTypeID: row.ID} }).css({ margin: 0 }).end()
			.dialog({
			    title: lang.RoomType + '【' + row.HostName + '】' + lang.WeiXin,
			    width: 600,
			    height: 400
			})
			.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//打开电视频道管理界面
function channelMgmt() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $('#dialog3')
			.find('.dlg-content').panel({ fit: true, border: false, href: '/RoomTypeChannels/Index/', queryParams: { roomTypeID: row.ID} }).css({ margin: 0 }).end()
			.dialog({
			    title: lang.RoomType + '【' + row.HostName + '】' + lang.TVChannel,
			    width: 600,
			    height: 400
			})
			.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//新增頻道
function addRoomTypeChannel(roomTypeID) {
    $('#dialog')
		.find('.dlg-content').panel({ height: 110, href: '/RoomTypeChannels/Edit/', queryParams: { id: 0, roomTypeID: roomTypeID} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeChannel).end()
		.dialog({
		    title: lang.NewTVChannel,
		    width: 300,
		    height: 200
		})
		.dialog('open');
}
//编辑频道
function editRoomTypeChannel(row) {
    row = row || $('#dgChannel').datagrid('getSelected');
    if (row) {
        $('#dialog')
		.find('.dlg-content').panel({ height: 110, href: '/RoomTypeChannels/Edit/', queryParams: { id: row.ID, roomTypeID: row.RoomTypeID} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeChannel).end()
		.dialog({
		    title: lang.EditTVChannel,
		    width: 300,
		    height: 200
		})
		.dialog('open');
    } else {
        $.tools.alert(lang.PleaseSelectTheData);
    }
}
//保存频道
function saveRoomTypeChannel() {
    if ($('#roomTypeChannelForm').form('enableValidation').form('validate')) {
        if ($.trim($('#txtName').val()) === '') {
            $.tools.alert(lang.PleaseEnterTheModeName);
            return;
        }
        var jsonRoomTypeChannel = $('#roomTypeChannelForm').serializeJson();

        var params = { jsonData: JSON.stringify(jsonRoomTypeChannel), roomTypeID: $('#hidRoomTypeID').val() };
        $.tools.post(params, '/RoomTypeChannels/Save/', function () {
            $('#dgChannel').datagrid('reload');
            $('#dialog').window('close');
        });
    }
}
//删除频道
function delRoomTypeChannel() {
    var rows = $('#dgChannel').datagrid('getSelections');
    if (!rows || rows.length == 0) {
        $.tools.alert(lang.PleaseSelectTheData);
        return;
    }
    var param;
    $.each(rows, function (i, n) {
        if (i == 0) {
            param = 'idList=' + n.ID;
        } else {
            param += '&idList=' + n.ID;
        }
    });
    $.tools.delPost(param, '/RoomTypeChannels/Delete/', function () {
        $('#dgChannel').datagrid('clearSelections');
        $('#dgChannel').datagrid('reload');
    }, this);
}

//打开空调界面
function airSetting() {
	var row = $('#dg').datagrid('getSelected');
	if (row) {
		$('#dialog2')
			.find('.dlg-content').panel({ fit: true, border: false, href: '/RoomType/RoomTypeAir/', queryParams: { ID: row.ID} }).css({ margin: 0 }).end()
			.dialog({
			    title: lang.AirCondition,
				width: 600,
				height: 400
			})
			.dialog('open');
	} else {
		$.tools.alert(lang.PleaseSelectTheData);
	}
}
// 新增空调
function addRoomTypeAir(roomTypeID) {
	$('#dialog')
		.find('.dlg-content').panel({ href: '/RoomType/RoomTypeAirEdit/', queryParams: { ID: 0, RoomTypeID: roomTypeID} }).end()
		.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeAir).end()
		.dialog({
		    title: lang.NewAirConditioning,
			width: 300,
			height: 250
		})
		.dialog('open');
}
// 编辑空调
function editRoomTypeAir(row) {
	row = row || $('#dgRoomTypeAir').datagrid('getSelected');
	if (row) {
		$('#dialog')
			.find('.dlg-content').panel({ href: '/RoomType/RoomTypeAirEdit/', queryParams: { ID: row.ID, RoomTypeID: row.RoomTypeID} }).end()
			.find('.dlg-footer .dlg-btn-save').unbind('click').bind('click', saveRoomTypeAir).end()
			.dialog({
				title: lang.EditAirConditioning+'【' + row.ModalTypeName + '】',
				width: 300,
				height: 250
			})
			.dialog('open');
	} else {
		$.tools.alert(lang.PleaseSelectTheData);
	}
}
//删除空调
function delRoomTypeAir() {
	var rows = $('#dgRoomTypeAir').datagrid('getChecked');

	if (rows.length <= 0) {
		$.tools.alert(lang.PleaseSelectTheData);
		return;
	}

	var params = '';
	for (var i in rows) {
		params += '&IDs=' + rows[i].ID;
	}

	$.tools.delPost(params, '/RoomType/RemoveRoomTypeAir/', function () {
		$('#dgRoomTypeAir').datagrid('clearSelections');
		$('#dgRoomTypeAir').datagrid('reload');
	}, this);
}
//保存空调
function saveRoomTypeAir() {
	var form = $('#dialog').find('form');
	if (form.form('enableValidation').form('validate')) {

		var param = form.serialize();

		$.tools.post(param, '/RoomType/SaveRoomTypeAir/', function () {
			$('#dgRoomTypeAir').datagrid('reload');
			$('#dialog').window('close');
		}, this);
	}
}
//模式选项
function formatterType(val, row, index) {
    switch (row.Type) {
        case "Music":
            switch (parseInt(val)) {
                case 1: return lang.Music_Play;
                case 2: return lang.Music_Pause;
                case 3: return lang.Music_PRE;
                case 4: return lang.Music_NEX;
                case 5: return lang.Volume_Up;
                case 6: return lang.Volume_Down;
                default: return '';
            }
            break;
        case "AirConditioner":
            switch (parseInt(val)) {
                case 1: return lang.Refrigeration;
                case 2: return lang.Heating;
                case 3: return lang.BlowingIn;
                default: return '';
            }
            break;
        case "TV":
            switch (parseInt(val)) {
                case 1: return lang.Mute;
                case 2: return lang.Suspend_Mode;
                case 3: return lang.Volume_Up;
                case 4: return lang.Volume_Down;
                case 5: return lang.Channel_Add;
                case 6: return lang.Channel_Reduce;
                case 7: return lang.Up;
                case 8: return lang.Down;
                case 9: return lang.Left;
                case 10: return lang.Right;
                case 11: return lang.OK;
                case 12: return lang.Homepage;
                case 13: return lang.Menu;
                case 14: return lang.Message_Source;
                case 15: return lang.LookBack;
                default: return '';
            }
            break;
    }
}