var lvid = getParameter("lvid");
var sign = getParameter("sign");
var reportType = getParameter("type");
var reportId = getParameter("reportid");
var name = getParameter("name");
var md5 = getParameter("md5");
var imgurl = getParameter("imgurl");
if(imgurl){
	imgurl = imgurl.slice(imgurl.lastIndexOf('\\') + 1,imgurl.length);
}
if(reportType == 3){
	$('.backCon i').text(name + '(' + reportId + ')');
	$('.reportPic .backTextarea img').attr('src',requestUrlMap['getChatImg']['url']+'?md5=' + imgurl).hide();
	$('#annWarp').hide().next().show();
}
$('img').load(function(){
	$('.backTextarea img').show();
	$('.reportPic .backTextarea').css('background','none');
	if($('.backTextarea img').height() > 110){
		$('.backTextarea img').attr('height','110px');
	}
})
$(function() {
	var tip = "您为什么要举报";
	switch (reportType) {
		case '1': //用户
			tip += "用户：";
			break;
		case '2': //云组
			tip += "云组：";
			break;
		default:
			tip += '：';
			break;
	}
	tip += name + '(' + reportId + ')';
	$("#reportId").html(tip);
	$(".mengCeng").show();
	$("#Textarea").blur();
});

function submitFb() {
	var title = "举报";
	var content = $("#Textarea").val();
	if (content.match(/^\s+$/g)) { 
		var paramStr = "{title:'内容限制',cat:0,content:'内容请输入5到200个字！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		var resultS = 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 + "}";
		var resultS = sendCommand(params);
		return;
	}
	var params = {
		'lvid': lvid,
		'sign': sign,
		'type': reportType,
		'tolvid':reportId,
		'title': title,
		'content': content
	};
	$.getJSON(requestUrlMap['reportUser']['url'], params, function(data) {
		if (data.errorid != 0) {
			var paramStr = "{title:'提交失败',cat:2,content:'提交失败，请稍后重试！'}";
			var params = "{command:9006,params:" + paramStr + "}";
			var resultS = sendCommand(params);
			return;
		}
		var paramStr = "{title:'提交成功',cat:0,content:'提交成功！'}";
		var params = "{command:9006,params:" + paramStr + "}";
		var resultS = sendCommand(params);
		$(".loading-popup").hide();
		sendCommand("{command:9001}");
	});
}

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();
		}
	}
}
$('.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");
});
function reportPic(){
	var type = $('input[name="backType"]:checked').val();
	var reportInfo = $('.reportInfo').val();
	var params = {
		'lvid': lvid,
		'sign': sign,
		'complainType': type,
		'tolvid':reportId,
		'title': '举报图片',
		'imageMD5':md5,
		'detail': reportInfo
	};
	$.ajax({
		url:requestUrlMap['reportPic']['url'],
		data:params,
		dataType:'jsonp',
		success:function(){
			var paramStr = "{title:'提交成功',cat:0,content:'提交成功！'}";
			var params = "{command:9006,params:" + paramStr + "}";
			var resultS = sendCommand(params);
			$(".loading-popup").hide();
			sendCommand("{command:9001}");
		},
		error:function(){
			var paramStr = "{title:'提交失败',cat:2,content:'提交失败，请稍后重试！'}";
			var params = "{command:9006,params:" + paramStr + "}";
			var resultS = sendCommand(params);
		}
	})
}