﻿// JavaScript Document
tinyMCE.init({
            mode : "exact",
	    	elements : "replyEditor",
			theme_advanced_buttons1 : "",
			plugins : "media",
            theme : "advanced",
			height : editorHeight
});

function TransURL(funcID)
{
	document.location = "/bbs/list.asp?ID=" + funcID;	
}

function TransTopicURL(funcID)
{
	document.location = "/bbs/display.asp?ID=" + funcID;	
}

function closePanel(pID)
{
	$("div.u_ActiveDiv").addClass("hidden");
}

function showBBSUserInfor(PID,uID)
{
	closePanel(0);
	$("#userInfor" + PID).removeClass("hidden");
	$("#inforContent" + PID).text("数据下载中...");
	$.ajax({
		   type : "Get",
		   url : "/BBS/Inc/userInfor.asp",
		   async: true,
		   dataType : "html",
		   data : {"ID":escape(uID)
		  },
		  success : function(msg){
			  if(msg == "error")
			  {
				  showTips("false","对不起，参数错误，请稍候.");
				  return;
			  }
			  $("#userInfor" + PID).html(msg);
			  },
		  error : function(){
			  showTips("false","操作失败，请刷新后测试");
		  }
		  });
}

// JavaScript Document
function createReply(editorId,topicID)
{
	
	if(canReplyTime > 3)
	{
		canReplyTime = 0;	
	}
	else
	{
		showTips("tips","对不起，你操作的太快了，请稍候进行提交");
		return false;	
	}
	showTipsOnly("tips","数据提交中...");
	_TopicID = topicID;
	_Description = tinyMCE.getInstanceById(editorId).getContent();
	_RR = $("input[name='RR']").val();
	_BID = $("input[name='BID']").val();
	if(_TopicID == "")
	{
		showTips("false","参数错误,请复制好回复内容,重新登陆后回复.");
		return false;
	}
	if(RemoveHTML(_Description) == "")
	{
		showTips("false","回复不能为空");
		return false;
	}
	$.ajax({
		   type : "Post",
		   url : "/BBS/Inc/bbs.action.asp",
		   async: true,
		   dataType : "html",
		   data : {"Action":"createReply",
		   "TopicID":escape(_TopicID),
		   "RR":escape(_RR),
		   "BID":escape(_BID),
		   "Description":escape(_Description)
		  },
		  success : function(msg){
			  if(msg == "ban")
			  {
			  	showTips("false","对不起，你被禁止发言。");
				return;
			  }
			  if(msg == "timeout")
			  {
			  	showTips("false","对不起，操作失败,登陆超时，请复制好回复帖子内容重新登陆后发布。");
				return;
			  }
			  if(msg == "nopass")
			  {
			  	showTipsOnly("false","必须最少验证一种联系方式才可以发帖.");
				setTimeout("document.location='/my/infor/honor.asp';",1500)
				return;
			  }
			  if(msg == "err")
			  {
				  showTips("false","对不起，请稍候再进行发布");
				  return;
			  }
			  showTipsOnly("true","发布成功");
			  setTimeout("TransTopicURL(" + topicID + ")",500)
			  },
		  error : function(){
			  showTips("false","操作失败，请刷新后测试");
		  }
		  });	
}