var lvid = getParameter("lvid");
var sign = getParameter("sign");
var category = getParameter("category");
if (!category) {
	category = 0;
}
$(function() {
	$(".mengCeng").show();
	$("#backTitle").val("");
	$("#Textarea").blur();
	//标题输入
	$(".backTit").focusin(function() {
		$("#backInput").hide();
		$("#backTitle").css({
			"background": "#fff"
		});
	});
	$(".backTit").focusout(function() {
		if ($("#backTitle").val() == "" || $("#backTitle").val() == null) {
			$("#backInput").show();
			$("#backTitle").css({
				"background": "#ececec"
			});
		} else {
			$("#backTitle").css({
				"background": "#ececec"
			});
		}
	});
	//单选按钮使用图片代替				
	$('.radio span').click(function() {
		$(this).parent().addClass('radio_on').removeClass('radio_off');
		$(this).parent().siblings('.radio').removeClass('radio_on').addClass('radio_off');
		$(this).siblings('input[type=radio]').attr("checked", "checked");
		$(this).parent().siblings('.radio').find('input[type=radio]').removeAttr("checked");
	});
	$('input[name="backType"]').each(function() {
		if ($(this).val() == category) {
			$(this).next().click();
		}
	});
});

function submitFb() {
	var type = $('input[name="backType"]:checked').val();
	var isUpload = $('#isUploadLog').is(':checked') ? 1 : 0;
	var content = $("#Textarea").val();
	if (content.match(/^\s+$/g)) {
		var paramStr = "{title:'内容限制',cat:0,content:'内容请输入5到200个字！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		sendCommand(params);
		return;
	}
	if (content == null || content == '' || content.length < 5 || content.length > 200) {
		var paramStr = "{title:'内容限制', cat:0, content:'内容请输入5到200个字！'}";
		var params = "{command:9006, params:" + paramStr + "}";
		sendCommand(params);
		return;
	}
	$(".loading-popup").show();
	var params = {
		'lvid': lvid,
		'sign': sign,
		'type': type,
		'isUpload':isUpload,
		'title': "问题反馈",
		'content': content
	};
	$.getJSON(requestUrlMap['reportUser']['url'], params, function(data) {
		$(".loading-popup").hide();
		if (data.errorid != 0) {
			var paramStr = "{title:'提交失败', cat:2, content:'提交失败，请稍后重试！'}";
			var params = "{command:9006, params:" + paramStr + "}";
			sendCommand(params);
			return;
		}
		if ($('#isUploadLog').is(':checked')) {
			sendCommand("{command:9029, params:{fid:" + data['fid'] + ", ftype:" + type + "}}");
		}
		var paramStr = "{title:'提交成功', cat:0, content:'提交成功！'}";
		var params = "{command:9006, params:" + paramStr + "}";
		sendCommand(params);
		sendCommand("{command:9001, params:{}}");
	});
}

function closeAlert() {
	$(".PopupQueding").hide();
}

$(document).ready(function() {
	$(".PopupQueding").hide();
	$("#alertnewlyClose").click(function() {
		$(".PopupQueding").hide();
	});
	$("#alertpopupSureBut").click(function() {
		$(".PopupQueding").hide();
	});
	lvAlertInit("annWarp");
});
//回车
document.onkeydown = function(event) {
	//网页内按下回车触发
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if (e && e.keyCode == 27) { // 按 Esc                 //要做的事情         
	}
	if (e && e.keyCode == 113) { // 按 F2                  //要做的事情         
	}
	if (e && e.keyCode == 13) { // enter 键                 //要做的事情      
		if ($(".PopupQueding").is(":hidden") == false) {
			$(".PopupQueding").hide();
		}
	}
	if (e && e.keyCode != 13) {
		if ($("#Textarea").val() != "" || $("#Textarea").text() != null) {
			$("#TextareaSpan").css({
				"display": "none"
			});
		} else {
			$("#TextareaSpan").css({
				"display": "block"
			});
			$("#Textarea").focus();
		}
	}
}