// JavaScript Document
function check_msg()
{
	reply_nid_val = $("#reply_nid").val();
	reply_pid_val = $("#reply_pid").val();
	reply_info_val = $("#reply_info").val();
	userName_val = $("#userName").val();
	password_val = $("#password").val();
	if(!reply_info_val)
	{
		LD_alert('用户操作提示','请输入回复内容');
		return false;
	}
	/*
	if(!$("#gameUser").attr("checked") && (!userName_val || !password_val )) {
		LD_alert('用户操作提示','请输入用户名和密码');
			return false;
	}*/
	if($("#gameUser").attr("checked"))
	{
		$.post("/index.php/admin/reply/addReply",
			   {action:"gameUser",reply_uid:0,reply_uname:"游客", reply_nid:reply_nid_val, reply_pid: reply_pid_val,reply_info:reply_info_val},
			   function(data){
				  handle_msg(data);
			   } 
		); 
	}else{
		$.post("/index.php/admin/reply/addReply",
		  {action:"5y173User",userName:userName_val,password:password_val, reply_nid:reply_nid_val, reply_pid: reply_pid_val,reply_info:reply_info_val},
		   function(data){
				 handle_msg(data);
		   } 
		); 
	
	}
	
	return false;
}

function handle_msg(data)
{

	eval("var json = "+data+";");
	if(json.message == 'loginWrong')
	{
		LD_alert('网友操作提示','你所输入的账号或密码错误。请重新输出');
		return false;
	}
	if(json.message == 'success')
	{
		show_info('回复成功','感谢您的留言。。');
		reload_reply_list();
		load_user_login()
		$("#reply_info").val("");
	}
	if(json.message == 'successLogin')
	{
		show_info('回复成功','感谢您的留言。。');
		load_userLogin_info();
		reload_reply_list();
		load_user_login()
		$("#reply_info").val("");
	}
	
}

function reload_reply_list()
{
	reply_nid_val = $("#reply_nid").val();
	$.post("/index.php/admin/reply/reloadList",
		  {reply_nid:reply_nid_val},
		   function(data){
			$("#replyList").html(data);
			hid();
		   } 
	); 
}

function load_userLogin_info()
{
	$.post("/index.php/admin/reply/loadUserLoginInfo",
		 function(data){
				$("#user_bar").html(data);
		 } 
	); 
}

function load_userLogout_info()
{
	$.post("/index.php/admin/reply/loadUserLogoutInfo",
		 function(data){
		 		load_user_logout();
				$("#user_bar").html(data);
		 } 
	); 
}

function clearGamerUser()
{
	$("#gameUser").attr("checked",false);
}

