﻿function PKTopicUp(ID,obj)
{
	$.ajax({
		   type : "get",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"PKTopicUp",
		   "ID":escape(ID)
		  },
		  success : function(msg){
			  if(msg == "ok")
			  {
				  $("div.PK_Tips").removeClass("hidden");
				  $("div.PK_Tips p").text($(obj).text() + "成功.");
				  $("li.PKsupport em").text(parseInt($("li.PKsupport em").text()) + 1);
			  }
			  else
			  {$("div.PK_Tips").removeClass("hidden");
			  $("div.PK_Tips p").text("你已经投过票了.");}
			  },
		  error : function(){
			  showTips("false","操作失败，请刷新后测试");
		  }
		  });
}

function PKTopicDown(ID,obj)
{
	$.ajax({
		   type : "get",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"PKTopicDown",
		   "ID":escape(ID)
		  },
		  success : function(msg){
			  if(msg == "ok")
			  {
				  $("div.PK_Tips").removeClass("hidden");
				  $("div.PK_Tips p").text($(obj).text() + "成功.");
				  $("li.PKopposite em").text(parseInt($("li.PKopposite em").text()) + 1);
			  }
			  else
			  {$("div.PK_Tips").removeClass("hidden");
			  $("div.PK_Tips p").text("你已经投过票了.");}
			  },
		  error : function(){
			  showTips("false","操作失败，请刷新后测试");
		  }
		  });
}

function trankModel(obj)
{
	tempobj = $(obj).parent().parent().find("ul");
	if($(tempobj).is(".ConciseModel"))
	{
		$(tempobj).removeClass("ConciseModel");
		$(obj).attr("title","切换到简洁模式");
	}
	else
	{
		$(tempobj).addClass("ConciseModel");
		$(obj).attr("title","切换到列表模式");
	}
}

function canUpdate(uID)
{
	if(isLogin && myNumber == uID)
	{
		return true;
	}
	{
		showTips("false","只能修改属于你自己的帖子.");
		return false;	
	}
}

function canManage(uID)
{
	if(!isManage)
	{showTips("false","没有管理的权限.");}
	return isManage;
}

function canList()
{
	return isCanList;	
}

function SendShortMessage(ID)
{
	if(isLogin)
	{
		$("#commonAjaxID").attr("value",ID);
		showCommonBg();
		showCommonSendShortMessage();
	}
}

function ShowAddFriend(ID)
{
	if(isLogin)
	{
		$("#commonAjaxID").attr("value",ID);
		showCommonBg();
		//showCommonAddFriend();
		ajaxCommonAddFriend();
	}
}

function checkManageT()
{
	$("#form3").submit();
}

function getTopicListPage(funcPageNum,funcAllNum)
{
	$.ajax({
		   type : "get",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"getTopicListPage",
		   "Num":escape(funcPageNum),
		   "Allnum":escape(funcAllNum)
		  },
		  success : function(msg){
			  $("#TopicListPage").html(msg);
			  },
		  error : function(){
			  //showTips("false","操作失败，请刷新后测试");
		  }
		  });
}

function getTopicListReplyUser(funcPageNum)
{
	$.ajax({
		   type : "get",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"getTopicListReplyUser",
		   "Num" : escape(funcPageNum),
		   "TID" : escape(TopicID)
		  },
		  success : function(msg){
			  $("#TopicListUserName").html(msg);
			  },
		  error : function(){
			  //showTips("false","操作失败，请刷新后测试");
		  }
		  });	
}

function getTopicListReply(funcPageNum)
{
	$.ajax({
		   type : "get",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"getTopicListReply",
		   "Num" : escape(funcPageNum),
		   "TID" : escape(TopicID)
		  },
		  success : function(msg){
			  $("#TopicDescription").html(msg);
			  },
		  error : function(){
			  //showTips("false","操作失败，请刷新后测试");
		  }
		  });	
}

function getTopicList(funcPageNum,funcAllNum)
{
	if(funcPageNum > funcAllNum)
	{
		funcPageNum = funcAllNum;
	}
	if(funcPageNum == 1 || funcPageNum == 0)
	{
		$("#TopicDescription").html($("#firstTopicListDescription").html());
		$("#TopicListUserName").html($("#firstTopicListUserName").html());
		getTopicListPage(1,funcAllNum);
	}
	else
	{
		getTopicListReplyUser(funcPageNum);
		getTopicListReply(funcPageNum);
		getTopicListPage(funcPageNum,funcAllNum);
	}
}

