
function $(id){
	var obj=document.getElementById(id);
	return obj;
}
//AJAX
function AjaxRequest() {
var xmlObj = false;
var CBfunc,ObjSelf;
ObjSelf=this;
try { xmlObj=new XMLHttpRequest; }
catch(e) {
  try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
  catch(e2) {
   try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
   catch(e3) { xmlObj=false; }
  }
}
if (!xmlObj) return false;
this.method="POST";
this.url;
this.async=true;
this.content="";
this.callback=function(cbobj) {return;}
this.send=function() {
  if(!this.method||!this.url||!this.async) return false;
  xmlObj.open (this.method, this.url, this.async);
  if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  xmlObj.onreadystatechange=function() {
   if(xmlObj.readyState==4) {
    if(xmlObj.status==200) {
     ObjSelf.callback(xmlObj);
    }
   }
  }
  if(this.method=="POST") xmlObj.send(this.content);
  else xmlObj.send(null);
}
}
//get x site
function GetX(e)
{
	var l=e.offsetLeft;
	while(e=e.offsetParent){				
		l+=e.offsetLeft;
	}
	return l;
}
//get y site
function GetY(e)
{
	var t=e.offsetTop;
	while(e=e.offsetParent){
		t+=e.offsetTop;
	}
	return t;
}

//去掉两边的空格
function trim(s)   
{   
    try  
    {   
        return s.replace(/^\s+|\s+$/g,"");   
    }   
    catch(e)   
    {   
        return s;   
    }   
}  
//添加快速回复的
var xmlHttp;   
var content;
var topicid;
function createXmlHttp() {
    if (window.XMLHttpRequest) {
       xmlHttp = new XMLHttpRequest();               
    } else {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
}                      
var userNAME;
var userID;
var cateId;
function submitPost(){
    userID = document.getElementById("userId").value;
    userNAME = document.getElementById("username").value;
    content = trim(document.getElementById("post_content").value);
    topicid = document.getElementById("topicid").value;
    cateId = document.getElementById("cateId").value;
    var vailimages = document.getElementById("vailimages").value;
     bbslimit.getReplyPermission(userID,cateId,function (data){
      if(data==true){
       //回复表情的相对路径
		    var emotPath = document.getElementById("emotPath").value;
		    if (checkForm()) {
		        document.getElementById("submit").disabled="true";
		        displayStatus("正在提交...");                     
		        createXmlHttp();                                  
		        xmlHttp.onreadystatechange = submitPostCallBack;   
		        xmlHttp.open("POST", "mod/bbs_post.jsp", true);        
		        xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		        xmlHttp.send("topicid=" + encodeURI(topicid)+"&content=" + encodeURI(content)+"&userId=" + encodeURI(userID)+"&username=" + encodeURI(userNAME)+"&emotPath=" + encodeURI(emotPath)+"&vailimages=" + encodeURI(vailimages));              
		    }
      }else{
        alert("对不起，您没回复的权限！");
      }
      });
   
}
function submitPostCallBack() {
    if (xmlHttp.readyState == 4) {
        createNewPost(xmlHttp.responseText);
        hiddenStatus();
    }
}
function createNewPost(postId) {
    if(postId==-1){
        document.getElementById("vailimages").focus();
        document.getElementById("checkmsg").innerHTML="<font color='red'>验证码输入错误，请重新输入!</font>";
        document.getElementById("submit").disabled="";
    }else{
    	if(postId==0){
        	alert("回复成功!");
        	document.getElementById("submit").disabled="";
        	document.getElementById("post_content").value="";   
	    	window.location.reload();
        }else{
        	alert("回复成功，请耐心等候管理员审核！");
        	document.getElementById("submit").disabled="";
        	document.getElementById("post_content").value="";
        }

    }
}

function displayStatus(info) {
    var statusDiv = document.getElementById("statusDiv");
    statusDiv.innerHTML = info;
    statusDiv.style.display = "";
}
function hiddenStatus() {
    var statusDiv = document.getElementById("statusDiv");
    statusDiv.innerHTML = "";
    statusDiv.style.display = "none";
}
 function checkForm() {
    if(content=='') {
        alert("请填写回复内容!");
        document.getElementById("post_content").focus();
        return false;
    }else if(len(trimFullSpace(content))<=10){
         alert("对不起，回复内容过短(最少不能少于5个汉字)！");
         return false;
       }else if(len(trimFullSpace(content))>2000){
         alert("对不起，回复内容过长(最多不能多于1000个汉字)！");
         return false;
       }
    return true;
} 

//发表帖子js
    var userid;
    var username;
    var major;
    var itopictype;
	//var contentUbb;
	var contentubb;
	var contenthtml;
	var catid;
	
	var vote;
	var dCrDate;
	var dEndDate;
	var voteCentent;
	
    var filePathName;
    var fileExt;
    var fileSize;
    var voteContentObj;
	//发帖
function getEditorContents(){
    //用户ID,用户名,板块ID,主题,主题分类
     userid=document.getElementById("userid").value;
     username=document.getElementById("username").value;
     catid=document.getElementById("catid").value;
     major=trim(document.getElementById("major").value);
     itopictype = document.getElementById("itopictype").value;
     var vailimages = document.getElementById("vailimages").value;
     //获得上传文件的文件名，文件后缀名，文件大小
     filePathName = document.getElementsByName("filePathName");
     fileExt = document.getElementsByName("fileExt");
     fileSize = document.getElementsByName("fileSize");
     //获取UBB文本编辑器的值
     if(window.frames['Editor'].document.getElementById('posteditor_source').value=='ubb'){
			window.frames['Editor'].document.getElementById('posteditor_source').click();
		}
		//获得编辑器的UBB以及HTML值
		 contentubb=window.frames['Editor'].document.getElementById('posteditor_textarea').value;
		 contenthtml=""; 

	 //普通贴，投票贴，单选，多选
	 obj = document.getElementsByName("vote");
	  if(obj[0].checked){
        vote=0;
      }
      if(obj[1].checked){
        vote=1;
      }
      if(obj[2].checked){
        vote=2;
      }
	 //起始终止日期
	  if(document.getElementById("dCrDate").value==""){
	     dCrDate="";
	  }else{
	     dCrDate = document.getElementById("dCrDate").value;
	  }
	  if(document.getElementById("dEndDate").value==""){
	     dEndDate="";
	  }else{
	     dEndDate = document.getElementById("dEndDate").value;
	  }
	  
	  
	 //投票选项
	  voteContentObj = document.getElementsByName("voteCentent");
	  voteCentent="";
	 if(voteContentObj.length==0){
	   voteCentent="";
	 }else{
	   for(var i=0;i<voteContentObj.length;i++){
	     voteCentent += trim(voteContentObj[i].value)+"\n";
	   }
	 }
	 if (checkForms()) {
	    document.getElementById("submit").disabled="true";
//        displayStatus("正在提交...");      
        ShowModal('buy');               
        createXmlHttp();                                  
        xmlHttp.onreadystatechange = submitPostCallBacks;   
        xmlHttp.open("POST", "bbs/mod/bbs_read.jsp", true);        
        xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");	
        
        var filePathNameStr="";
        var fileExtStr="";
        var fileSizeStr="";
        for(var i=0;i<filePathName.length;i++){
         filePathNameStr+= filePathName[i].value+",";
         fileExtStr+= fileExt[i].value+",";
         fileSizeStr+= fileSize[i].value+",";
        }
        xmlHttp.send("userid=" + encodeURI(userid)+"&major=" + encodeURI(major)+"&itopictype=" + encodeURI(itopictype)+"&contentubb=" + encodeURI(contentubb)+"&contenthtml=" + encodeURI(contenthtml)+"&username=" + encodeURI(username)+"&vote=" + encodeURI(vote)+"&dCrDate=" + encodeURI(dCrDate)+"&dEndDate=" + encodeURI(dEndDate)+"&voteCentent=" + encodeURI(voteCentent)+"&catid=" + encodeURI(catid)+"&filePathNameStr=" + encodeURI(filePathNameStr)+"&fileExtStr=" + encodeURI(fileExtStr)+"&fileSizeStr=" + encodeURI(fileSizeStr)+"&vailimages=" + encodeURI(vailimages));              
    }
}
function submitPostCallBacks() {
    if (xmlHttp.readyState == 4) {
        createNewPosts(eval(xmlHttp.responseText));
    }
}
function createNewPosts(postsId) {
    if(postsId!=-1){
      bbslimit.assertPermission(catid,function(data){
      		if(data=="1"||data=="2"){
      			ShowModal('buy');
      			alert("发表成功，请耐心等待管理员或版主的审核！");
      			document.location.href="../bbs/topics.jsp?scategory="+catid+"&type=0";
      		}else if(data=="0"){
      			ShowModal('buy');
		        alert('发帖成功！');
		        //异步更新当天帖子+回复总数
		        bbslimit.updateTodayTopicNum(catid,function(data){
		        });
		        document.location.href="../bbs/bbs_read.jsp?topicid="+postsId;      		
		    }
      });
    }else{
      document.getElementById("vailimages").focus();
      document.getElementById("checkmsg").innerHTML="<font color='red'>验证码输入错误，请重新输入!</font>";
      document.getElementById("submit").disabled="";
    }
}
   var filePathName;
    var fileExt;
    var fileSize;
    //添加附件到数据库
function addFileMethod(postsId){
   filePathName = document.getElementsByName("filePathName");
    fileExt = document.getElementsByName("fileExt");
    fileSize = document.getElementsByName("fileSize");
    for(var i=0;i<filePathName.length;i++){
     bbslimit.addFile(userid,postsId,filePathName[i].value,fileExt[i].value,fileSize[i].value,function(data){
      if(data=="true"){
       alert('插入成功');
       }
      });
   }
}
 function checkForms(){
    if(major=='') {
        alert("请填写主题!");
        document.getElementById("major").focus();
        return false;
      }
      if(len(major)>100){
        document.getElementById("msg").innerHTML="<font color='red'>主题名称最多不能超过100个汉字!</font>";
        document.getElementById("major").focus();
        return false;
        } 
    if(itopictype==''){
        alert("请选择帖子分类!");
        return false;
      }
       if(trimFullSpace(contentubb)==''){
         alert("发帖内容不能为空！");
        return false;
       }else if(len(trimFullSpace(contentubb))<=10){
         alert("对不起，发表内容过短(最少不能少于5个汉字)！");
         return false;
       }else if(len(trimFullSpace(contentubb))>10000){
         alert("对不起，发表内容过长(最多不能多于5000个汉字)！");
         return false;
       }
      if(vote!=0){
        if(voteCentent==''){
          alert("请添加投票选项，如不需要请选择普通帖选项！");  
          document.getElementById("voteCentent").focus();
          return false;      
        }
      }
      var retbool = true;
      if(voteContentObj.length!=0){
        for(var i=0;i<voteContentObj.length;i++){
          if(trim(voteContentObj[i].value)==''){
            retbool = false;
          }
        }
      }
      if(retbool==false){
        alert("投票选项不能有空值，请认真填写！");
      }
    return retbool;
    } 
//发表帖子
function contentAlter(catid){
    var userId = document.getElementById("userId").value;
    var username = document.getElementById("username").value;
    if(userId=="0"){
      bbslimit.getBbsateExtendByid(catid,function (data){
      if(data.isAllowAnonymous==1){
         var limitbool = window.confirm("用户未登录不能发匿名帖！确定登陆吗？");
         if(limitbool){
            document.location.href="login/login.jsp";
         }
      }else if(data.isAllowAnonymous==0){
         var limitContor = window.confirm("确定发匿名帖吗？");
         if(limitContor){
         document.location.href="postsAdd.jsp?catid="+catid;
         }else{
           if(window.confirm("确定登录吗？")){
             document.location.href="login/login.jsp";
           }
         }
      }
      });
    }else{
       document.location.href="postsAdd.jsp?catid="+catid;
    }
  }
  //取消发表帖子并清空缓存
  function gohistory(){  
       bbslimit.clearSessionMap();
       history.go(-1);
  }
 //投票控制
 function changeVote(){
 var obj=document.getElementsByName("vote");
 if(obj[0].checked){
    document.getElementById("aa").style.display = "none";
    document.getElementById("bb").style.display = "none";
    document.getElementById("cc").style.display = "none";
    }
 if(obj[1].checked){
   document.getElementById("aa").style.display = "";
   document.getElementById("bb").style.display = "";
   document.getElementById("cc").style.display = "";
    }
  if(obj[2].checked){
   document.getElementById("aa").style.display = "";
   document.getElementById("bb").style.display = "";
   document.getElementById("cc").style.display = "";
    }
 }
 
 //编辑帖子
 
function getEditorContentsEdit(){
     userid=document.getElementById("userid").value;
     username=document.getElementById("username").value;
     catid=document.getElementById("catid").value;
     major=document.getElementById("major").value;
     itopictype = document.getElementById("itopictype").value;
     //验证码
     var vailimages = document.getElementById("vailimages").value;
      //所要编辑帖子的ID
     var postUpdateID =  document.getElementById("postUpdateID").value;
     var topicsid = document.getElementById("topicsid").value;
     //获取UBB文本编辑器的值
     
          //获得上传文件的文件名，文件后缀名，文件大小
     filePathName = document.getElementsByName("filePathName");
     fileExt = document.getElementsByName("fileExt");
     fileSize = document.getElementsByName("fileSize");
          //获取UBB文本编辑器的值
     if(window.frames['Editor'].document.getElementById('posteditor_source').value=='ubb'){
			window.frames['Editor'].document.getElementById('posteditor_source').click();
			window.frames['Editor'].document.getElementById('posteditor_source').click();
		}
     	contentubb=window.frames['Editor'].document.getElementById('posteditor_textarea').value;
		contenthtml=""; 
	 //普通贴，投票贴，单选，多选
	 obj = document.getElementsByName("vote");
	  if(obj[0].checked){
        vote=0;
      }
      if(obj[1].checked){
        vote=1;
      }
      if(obj[2].checked){
        vote=2;
      }
	 //起始终止日期
	  if(document.getElementById("dCrDate").value==""){
	     dCrDate="";
	  }else{
	     dCrDate = document.getElementById("dCrDate").value;
	  }
	  if(document.getElementById("dEndDate").value==""){
	     dEndDate="";
	  }else{
	     dEndDate = document.getElementById("dEndDate").value;
	  }
	 //投票选项
	 
	 voteContentObj = document.getElementsByName("voteCentent");
	 voteCentent="";
	 if(voteContentObj.length==0){
	   voteCentent="";
	 }else{
	   for(var i=0;i<voteContentObj.length;i++){
	     voteCentent += trim(voteContentObj[i].value)+"\n";
	   }
	 }
	 if (checkEditForms()) {
	    document.getElementById("submit").disabled="true";
		ShowModal('buy');                  
        createXmlHttp();                                  
        xmlHttp.onreadystatechange = editPostCallBacks;   
        xmlHttp.open("POST", "bbs/mod/bbs_edit.jsp", true);        
        xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        
        var filePathNameStr="";
        var fileExtStr="";
        var fileSizeStr="";
        for(var i=0;i<filePathName.length;i++){
         filePathNameStr+= filePathName[i].value+",";
         fileExtStr+= fileExt[i].value+",";
         fileSizeStr+= fileSize[i].value+",";
        }
        xmlHttp.send("userid=" + encodeURI(userid)+"&major=" + encodeURI(major)+"&itopictype=" + encodeURI(itopictype)+"&contentubb=" + encodeURI(contentubb)+"&contenthtml=" + encodeURI(contenthtml)+"&username=" + encodeURI(username)+"&vote=" + encodeURI(vote)+"&dCrDate=" + encodeURI(dCrDate)+"&dEndDate=" + encodeURI(dEndDate)+"&voteCentent=" + encodeURI(voteCentent)+"&catid=" + encodeURI(catid)+"&topicsid=" + encodeURI(topicsid)+"&postUpdateID=" + encodeURI(postUpdateID)+"&filePathNameStr=" + encodeURI(filePathNameStr)+"&fileExtStr=" + encodeURI(fileExtStr)+"&fileSizeStr=" + encodeURI(fileSizeStr)+"&vailimages=" + encodeURI(vailimages));              
    }
}
function editPostCallBacks() {
    if (xmlHttp.readyState == 4) {
        createEditPosts(xmlHttp.responseText);
          hiddenStatus();
    }
}
function createEditPosts(topicsId) {
    if(topicsId==-1){
     document.getElementById("checkmsg").innerHTML="<font color='red'>验证码输入错误，请重新输入!</font>";
     document.getElementById("vailimages").focus();
     document.getElementById("submit").disabled="";
    }else if(topicsId==0){
      ShowModal('buy');
      alert('编辑失败！');
      document.getElementById("submit").disabled="";
    }else{
      ShowModal('buy');
      alert('编辑成功！');
      document.location.href="../bbs/bbs_read.jsp?topicid="+topicsId;
    }
}
 function checkEditForms(){
    if(major=='') {
        alert("请填写主题!");
        return false;
      }else if(itopictype==''){
         alert("请选择帖子分类!");
        return false;
      }else if(contentubb==''){
         alert("内容不能为空！");
        return false;
      }else if(len(trimFullSpace(contentubb))<=10){
         alert("对不起，发表内容过短(最少不能少于5个汉字)！");
         return false;
       }else if(len(trimFullSpace(contentubb))>10000){
         alert("对不起，发表内容过长(最多不能多于5000个汉字)！");
         return false;
       }
       if(vote!=0){
        if(voteCentent==''){
          alert("请添加投票选项，如不需要请选择普通帖选项！");  
          document.getElementById("voteCentent").focus();
          return false;      
        }
      }
      var retbool = true;
      if(voteContentObj.length!=0){
        for(var i=0;i<voteContentObj.length;i++){
          if(trim(voteContentObj[i].value)==''){
            retbool = false;
          }
        }
      }
      if(retbool==false){
        alert("投票选项不能有空值，请认真填写！");
      }
    return retbool;
}

//回复帖子
function submitPostsReply(){
     userid=document.getElementById("userid").value;
     username=document.getElementById("username").value;
     catid=document.getElementById("catid").value;
     major=document.getElementById("major").value;
     var vailimages = document.getElementById("vailimages").value;
      //所要回复的帖子的ID
     var topicid =  document.getElementById("topicid").value;
          //获取UBB文本编辑器的值
     if(window.frames['Editor'].document.getElementById('posteditor_source').value=='ubb'){
			window.frames['Editor'].document.getElementById('posteditor_source').click();
			window.frames['Editor'].document.getElementById('posteditor_source').click();
		}
     	contentubb=window.frames['Editor'].document.getElementById('posteditor_textarea').value;
		contenthtml="";
	 if (checkPreplyForms()) {
	 	ShowModal('buy');
	    document.getElementById("submit").disabled="true";
        createXmlHttp();                                  
        xmlHttp.onreadystatechange = replyPostCallBacks;   
        xmlHttp.open("POST", "bbs/mod/bbs_reply.jsp", true);        
        xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlHttp.send("userid=" + encodeURI(userid)+"&major=" + encodeURI(major)+"&contentubb=" + encodeURI(contentubb)+"&contenthtml=" + encodeURI(contenthtml)+"&username=" + encodeURI(username)+"&catid=" + encodeURI(catid)+"&topicid=" + encodeURI(topicid)+"&vailimages=" + encodeURI(vailimages));              
    }
}
function replyPostCallBacks() {
    if (xmlHttp.readyState == 4) {
        createReplyPosts(xmlHttp.responseText);
    }
}
function createReplyPosts(topicsId) {
    if(topicsId==-1){
     document.getElementById("checkmsg").innerHTML="<font color='red'>验证码输入错误，请重新输入!</font>";
     document.getElementById("vailimages").focus();
     document.getElementById("submit").disabled="";
    }else if(topicsId==0){
      ShowModal('buy');
      alert('回复失败！');
      document.getElementById("submit").disabled="";
    }else{
      bbslimit.assertPermission(catid,function(data){
      	if(data=="2"){
      		ShowModal('buy');
      		alert('回复成功,请耐心等待版主或管理员的审核!');
      		document.location.href="../bbs/bbs_read.jsp?topicid="+topicsId;
      	}else{
      		ShowModal('buy');
      		alert('回复成功!');
      		bbslimit.updateTodayTopicNum(catid,function(data){
		    });
      		document.location.href="../bbs/bbs_read.jsp?topicid="+topicsId;
      	}
      });
    }
}
 function checkPreplyForms(){
    if(major=='') {
        alert("请填写主题!");
        document.getElementById("major").focus();
        return false;
      }else if(contentubb==''){
         alert("内容不能为空！");
        return false;
      }else if(len(trimFullSpace(contentubb))<=10){
         alert("对不起，回复内容过短(最少不能少于5个汉字)！");
         return false;
       }else if(len(trimFullSpace(contentubb))>10000){
         alert("对不起，回复内容过长(最多不能多于5000个汉字)！");
         return false;
       }
    return true;
}

//编辑回复
function editReplyPosts(){
	 var userId = document.getElementById("userId").value;
	 var username = document.getElementById("username").value;
	 var postId = document.getElementById("postId").value;
     var vailimages = document.getElementById("vailimages").value;
          //获取UBB文本编辑器的值
     if(window.frames['Editor'].document.getElementById('posteditor_source').value=='ubb'){
			window.frames['Editor'].document.getElementById('posteditor_source').click();
			window.frames['Editor'].document.getElementById('posteditor_source').click();
		}
     	contentubb=window.frames['Editor'].document.getElementById('posteditor_textarea').value;
		contenthtml="";
	 if (checkEditReplyForms()) {
	    document.getElementById("submit").disabled="true";
		ShowModal('buy');
        createXmlHttp();                                  
        xmlHttp.onreadystatechange = editReplyCallBacks;   
        xmlHttp.open("POST", "bbs/mod/bbs_replyEdit.jsp", true);        
        xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
         xmlHttp.send("postId="+encodeURI(postId)+"&userId="+encodeURI(userId)+"&username="+encodeURI(username)+"&contentubb=" + encodeURI(contentubb)+"&contenthtml=" + encodeURI(contenthtml)+"&vailimages=" + encodeURI(vailimages));              
    }
}
function editReplyCallBacks() {
    if (xmlHttp.readyState == 4) {
        editReplyResultPosts(xmlHttp.responseText);
    }
}
function editReplyResultPosts(topicsId) {
    if(topicsId==-1){
     ShowModal('buy');
     document.getElementById("checkmsg").innerHTML="<font color='red'>验证码输入错误，请重新输入!</font>";
     document.getElementById("vailimages").focus();
     document.getElementById("submit").disabled="";
    }else if(topicsId==0){
      ShowModal('buy');
      alert('编辑失败！');
      document.getElementById("submit").disabled="";
    }else{
      ShowModal('buy');
      alert('编辑成功！');
      document.location.href="../bbs/bbs_read.jsp?topicid="+topicsId;
    }
}
 function checkEditReplyForms(){
	  if(contentubb==''){
         alert("对不起,内容不能为空！");
        return false;
      }else if(len(trimFullSpace(contentubb))<=10){
         alert("对不起，回复内容过短(最少不能少于5个汉字)！");
         return false;
       }else if(len(trimFullSpace(contentubb))>10000){
         alert("对不起，回复内容过长(最多不能多于5000个汉字)！");
         return false;
       }
    return true;
}




//将上传的文件信息添加到myfileResult层里面
function addUploadFilesInfos(info){
       var ladd = document.getElementById("myfileResult").innerHTML;
       document.getElementById("myfileResult").innerHTML=ladd+info;
     }
//删除刚刚上传的文件信息
  function deleteFilesInfos(divId,filePathName){
      var realPath = document.getElementById("realPath").value+filePathName;
      if(confirm("确定删除？")){
       bbslimit.deleteUploadFile(divId,realPath,function (data){
        if(data=='1'){
          alert('删除成功');
          var objDiv = document.getElementById(divId);
          objDiv.parentNode.removeChild(objDiv);
        }else if(data=='0'){
          alert('删除失败');
        }
       })
     }
  }
//删除以前上传上去的文件（涉及到数据库的）
  function deleteUpGoFilesInfos(divId,filePathName,atachId){
      var realPath = document.getElementById("realPath").value+filePathName;
      if(confirm("确定删除？")){
       bbslimit.deleteUpGoFilesInfos(divId,realPath,atachId,function (data){
        if(data=='1'){
          alert('删除成功');
          var objDiv = document.getElementById(divId);
          objDiv.parentNode.removeChild(objDiv);
        }else if(data=='0'){
          alert('删除失败');
        }
       })
     }
  }
  
//初始化上传的文件信息
   function initPostsAdd(){
      var divStr="";
       bbslimit.getUploadSessionMap(
       function (data){
       for(var property in data){
         divStr+=data[property];
       }
       addUploadFilesInfos(divStr);
      });
  }
  
  
  //显示置顶span
 function displayTopDiv(){
 document.getElementById("toanothorspan").style.display = "none";
   document.getElementById("totop").style.display = "";
 }
  //隐藏显示置顶span
 function nodisplayTopDiv(){
   document.getElementById("totop").style.display = "none";
 }
 //提交置顶
 function toPostsTop(){
  if(window.confirm("确定设置吗？")){
    var userId = document.getElementById("postuserId").value;
    var temp = document.getElementById("temp").value;
    var toptime = document.getElementById("toptime").value;
    if(temp!=''){
    if(userId=="0"){
        var topicId = document.getElementById("topicid").value;
         bbslimit.toPostsTop(topicId,temp,toptime,function (data){
         if(data=="true"){
          alert("设置成功！");
          window.location.reload();
         }else if(data=="false"){
          alert("设置失败！");
         }else if(data=="0"){
          alert("对不起，该贴已是置顶帖或非置顶帖！");
         }
         });
    }else{
		    if(temp!='0'){
			      bbslimit.getScoreObject("TOPTOPIC","BBS",function(data){
			      if(data.id==0){
			        alert("无置顶项目，不能置顶！");
			      }else{
				        var score = "主题置顶将加"+data.scores+"积分！确定置顶吗？";
					        if(window.confirm(score)){
						        var topicId = document.getElementById("topicid").value;
						         bbslimit.toPostsTop(topicId,temp,toptime,function (data){
						         if(data=="true"){
						          alert("帖子置顶成功！");
						          window.location.reload();
						         }else if(data=="false"){
						          alert("置顶设置失败！");
						         }else if(data=="0"){
						          alert("对不起，该贴已是置顶帖！");
						         }
						         });
					           }        
				          }
				        });
			  }else if(temp=='0'){
			  		  var topicId = document.getElementById("topicid").value;
			  		  bbslimit.toPostsTop(topicId,temp,toptime,function (data){
						         if(data=="true"){
							          alert("取消置顶成功！");
							          window.location.reload();
						         }else if(data=="false"){
						     	      alert("取消置顶设置失败！");
						         }else if(data=="0"){
						          	  alert("对不起，该贴已是普通帖！");
						         }
						         });
			  
			  }
       }
      }else{
        alert('请选择操作类型！');
      }
     }
 }
 //前台版主删帖
 function deletePosts(topicId){
 if(window.confirm("确定删除吗？")){
 var delOpCauseValue = document.getElementById("delOpCauseValue").value;
 var userId = document.getElementById("postuserId").value;
 var opuserId = document.getElementById("userId").value;
 var topicAuthor = document.getElementById("topicAuthor");
 var notiseAuhor ="0";
 	if(topicAuthor.checked==true){
 		notiseAuhor="1";
 	}
   if(userId=="0"){
         bbslimit.deletePosts(topicId,opuserId,delOpCauseValue,notiseAuhor,function (data){
	         if(data=="true"){
	              alert("删除成功！");
	         }else if(data=="false"){
	              alert("删除失败！");
	         }else if(data=="0"){
	          	  alert("该贴子已经被移至回收站！");
	         }else{
		          alert("删除成功！");
		          document.location.href="topics.jsp?scategory="+data;
	         }
         });
  }else{
     bbslimit.getScoreObject("DELTOPIC","BBS",function(data){
      if(data.id==0){
        alert("没有删除项目，不能删除！");
      }else{
	        var score = "删除将扣"+data.scores+"积分！确定删除吗？";
	        if(window.confirm(score)){
	         bbslimit.deletePosts(topicId,opuserId,delOpCauseValue,notiseAuhor,function (data){
	         if(data=="true"){
	           	alert("删除成功！");
	         }else if(data=="false"){
	          	alert("删除失败！");
	         }else if(data=="0"){
	          	alert("该贴子已经被移至回收站！");
	         }else{
		        alert("删除成功！");
		        document.location.href="topics.jsp?scategory="+data;
	         }
	         });
	        }        
       }
      });
     }
    }
 }
 //管理员删除回复
 function deletePostsReply(postsId){
   if(window.confirm("确定永久删除吗？")){
   		bbslimit.deletePostsReply(postsId,function(data){
   		   if(data=="true"){
   		   		alert("删除成功！");
   		   		window.location.reload();
   		   }else if(data=="false"){
   		        alert("删除失败！");
   		   }
   		})
   }
}
 //前台版主置精华
 function toPostsBests(topicId){
 var postsBest = document.getElementById("postsBest").value;
 if(postsBest=='0'){
	 if(window.confirm("确定置精华吗？")){
	 var userId = document.getElementById("postuserId").value;
	   if(userId=="0"){
	         bbslimit.toPostsBests(topicId,function (data){
	         if(data=="true"){
	          alert("设置成功！");
	          window.location.reload();
	         }else if(data=="false"){
	          alert("设置失败！");
	         }else if(data=="0"){
	           alert("该帖子已经是精华帖！");
	         }
	         });
	  }else{
	     bbslimit.getScoreObject("FINTOPIC","BBS",function(data){
	      if(data.id==0){
	        alert("没有置精华项目，不能置精华！");
	      }else{
	        var score = "置精华将加"+data.scores+"积分！确定执行吗？";
	        if(window.confirm(score)){
	         bbslimit.toPostsBests(topicId,function (data){
	         if(data=="true"){
	           alert("置精华成功！");
	           window.location.reload();
	         }else if(data=="false"){
	          alert("置精华失败！");
	         }else if(data=="0"){
	           alert("该帖子已经是精华帖！");
	         }
	         });
	        }        
	       }
	      });
	     }
	    }
    }else if(postsBest=='1'){
    	bbslimit.toFreePostsBests(topicId,function(data){
    		 if(data=="true"){
	           alert("解除成功！");
	           window.location.reload();
	         }else if(data=="false"){
	           alert("解除失败！");
	         }else if(data=="0"){
	           alert("该帖子已经是普通帖！");
	         }
    	});
	 }
 }
 //前台版主置推荐
 function toPostsBestsT(topicId){
 var electValue = document.getElementById("electValue").value;
 if(electValue=='0'){
 if(window.confirm("确定置该帖为推荐贴吗？")){
 var userId = document.getElementById("postuserId").value;
   if(userId=="0"){
         bbslimit.toPostsRecommend(topicId,function (data){
         if(data=="true"){
          alert("设置成功！");
          window.location.reload();
         }else if(data=="false"){
          alert("设置失败！");
         }else if(data=="0"){
          alert("对不起，该帖已为推荐贴！");
         }
         });
  }else{
     bbslimit.getScoreObject("RECTOPIC","BBS",function(data){
      if(data.id==0){
        alert("没有置推荐贴项目，不能置为推荐贴！");
      }else{
        var score = "置为推荐贴将加"+data.scores+"积分！确定执行吗？";
        if(window.confirm(score)){
         bbslimit.toPostsRecommend(topicId,function (data){
         if(data=="true"){
           alert("置推荐贴成功！");
           window.location.reload();
         }else if(data=="false"){
          alert("设置失败！");
         }else if(data=="0"){
          alert("对不起，该帖已为推荐贴！");
         }
         });
        }        
       }
      });
      }
     }
    }else if(electValue=='1'){
     	bbslimit.toFreePostsRecommend(topicId,function(data){
     		if(data=="true"){
	           alert("解除成功！");
	           window.location.reload();
	        }else if(data=="false"){
	           alert("解除失败！");
	        }else if(data=="0"){
	           alert("对不起，该帖已不是推荐贴！");
	        }
     	});
    }
 }
   //显示转移span
 function displayAnothorDiv(){
    document.getElementById("toanothorspan").style.display = "";
     document.getElementById("totop").style.display = "none";
 }
  //隐藏转移span
 function nodisplayAnothorDiv(){
    document.getElementById("toanothorspan").style.display = "none";
 }
 //前台版主移动该贴至目标板块
 function toAthorCat(topicId){
  var catId = document.getElementById("toanothor").value; 
  var convertCause = document.getElementById("convertCause").value;
  var userId = document.getElementById("userId").value;
 if(catId!=''){
 if(window.confirm("确定移动该主题至目标板块吗？")){
         bbslimit.toAthorCat(topicId,catId,userId,convertCause,function (data){
         if(data=="true"){
          alert("移动成功！");
          window.location.reload();
         }else if(data=="false"){
           alert("移动失败！");
         }else if(data=="0"){
           alert("对不起，不能将帖子移至顶级版块下！");
         }else if(data=="1"){
           alert("对不起，帖子已经在本版块下！");
          }
         });
     }
   }else{
    alert("请选择目标板块！");
   }
 }
    //添加回复表情(支持火狐IE)
  function addEmot(obj) {     
    var ubb=document.getElementById("post_content"); 
    var ubbLength=ubb.value.length; 
    ubb.focus(); 
    if(typeof document.selection !="undefined") 
    { 
        document.selection.createRange().text="[emot]" + obj+ "[/emot]"; 
    } 
    else 
    { 
        ubb.value=ubb.value.substr(0,ubb.selectionStart)+"[emot]" + obj+ "[/emot]"+ubb.value.substring(ubb.selectionStart,ubbLength); 
    } 
  }
  //跳转到本页面的锚点位置
  function toReplyMao(){
    window.location.hash="reply";
  }   
  //跳转到回复的页面
  function toReplyPage(topicsId,catid){
   var userid=document.getElementById("userId").value;
    var replyBool;
     if(userid==0){
        replyBool=window.confirm("确定匿名回复吗？");
        if(!replyBool){
          if(window.confirm("确定现在登录吗？")){
            document.location.href="../login/login.jsp";
          }
        }
     }
   document.location.href="bbs_postsReply.jsp?topicsId="+topicsId+"&catid="+catid;
  }
  
//向编辑器添加表情
function addEmotToEdit(obj) {     
    var basePath = document.getElementById("basePath").value;
    var basePathurl = basePath+obj;
      var contentEdit = "";
   if(typeof(window.frames['Editor'].editdoc.body)=="undefined"){
        contentEdit = window.frames['Editor'].document.getElementById('posteditor_textarea');
        var ubbLength=contentEdit.value.length; 
        contentEdit.focus();
        if(typeof document.selection !="undefined") { 
           window.frames['Editor'].document.selection.createRange().text="[IMG]" +basePathurl+"[/IMG]";
        } 
        else{ 
           window.frames['Editor'].document.getElementById('posteditor_textarea').value=contentEdit.value.substr(0,contentEdit.selectionStart)+"[IMG]" +basePathurl+"[/IMG]"+contentEdit.value.substring(contentEdit.selectionStart,ubbLength); 
        } 
 	 }else{
 	 		 contentEdit = window.frames['Editor'].editdoc.body.innerHTML;
			 window.frames['Editor'].editdoc.body.innerHTML=contentEdit+"<img src="+basePathurl+ " />";
 	 //这块不能实现 
 	           //contentEdit = window.frames['Editor'].document.getElementById('posteditor_textarea');
		  //  contentEdit = window.frames['Editor'].editdoc.body;
		  //   var ubbLength=contentEdit.innerHTML.length; 
		  //   contentEdit.focus();
		     
		  //    if(typeof document.selection !="undefined") { 
		      
            //   window.frames['Editor'].editdoc.body.document.selection.createRange().innerHTML="[IMG]" +basePathurl+"[/IMG]";
            //  } 
            //   else{ 
           //    window.frames['Editor'].editdoc.body.innerHTML=contentEdit.innerHTML.substr(0,contentEdit.selectionStart)+"[IMG]" +basePathurl+"[/IMG]"+contentEdit.innerHTML.substring(contentEdit.selectionStart,ubbLength); 
           // }
     }
  }


function checkIsNull(obj,message,meg) {
	var reg = new RegExp("^[\u0391-\uFFE5]+$");
	if (trimFullSpace(obj.value).length <= 0) {
		obj.value = "";
		document.getElementById(meg).innerHTML = "<font color='red'>"+message+"</font>";
		return false;
	}else if(trimFullSpace(obj.value).length>40){
	   document.getElementById(meg).innerHTML="<font color='red'>投票选项最多只允许输入40个汉字！</font>";
	   obj.focus();
	}else{
	   document.getElementById(meg).innerHTML=""; 
	}
}
function trimFullSpace(strIn) {
	if (strIn == null) {
		return null;
	} else {
		var len = strIn.length;
		var start = 0;
		var end = strIn.length;
		for (var i = 0; i < len; i++) {
			if (strIn.charAt(i) == " " || strIn.charAt(i) == "\u3000") {
				start++;
			} else {
				break;
			}
		}
		for (var i = len - 1; i > -1; i--) {
			if (strIn.charAt(i) == " " || strIn.charAt(i) == " ") {
				end--;
			} else {
				break;
			}
		}
		if (start >= end) {
			return "";
		} else {
			return strIn.substring(start, end);
		}
	}
}
function checkSize(obj,message) {
	var reg = new RegExp("^[\u0391-\uFFE5]+$");
	if (trimFullSpace(obj.value).length <= 0) {
		obj.value = "";
		document.getElementById("msg").innerHTML = "<font color='red'>"+message+"</font>";
		return false;
	}else{
	  if(len(trimFullSpace(obj.value))>100){
	   document.getElementById("msg").innerHTML="<font color='red'>主题名称最多不能超过50个汉字!</font>";
	   obj.focus();
	  }else{
	    document.getElementById("msg").innerHTML="<font color='red'>*</font>";
	    return true;
	  }
	}  
  }
function len(s) {
 var l = 0;
 var a = s.split("");
 for (i=0;i<a.length;i++) {
  if (a[i].charCodeAt(0)<299) {
   l++;
  } else {
   l+=2;
  }
 }
 return l;
} 

//板块之间的跳转
function toTarge(){
     scategory=document.getElementById('scategory0').value;
     document.location.href="topics.jsp?scategory="+scategory+"&"+"type=0";
}

function memu(w,h,c,src,obj){
/*
w:width;
h:height;
x:left;
y:top;
c:0;从页面上获取;1:从本方法
*/
	var M="memu_div";
	var F="memu_ifr";
	var x = GetX(obj);
	var y = GetY(obj)+15;
    var newFrame = document.createElement("iframe");
    newFrame.id = F;
    newFrame.style.position = "absolute";
    newFrame.style.zIndex = "9999";
    newFrame.style.width = w + "px";
    newFrame.style.height = h + "px";
    newFrame.style.top = y+"px";
    newFrame.style.left = x+"px";
    newFrame.style.background = "FFFFFF";
    newFrame.style.filter = "alpha(opacity=0)";
    newFrame.style.opacity = "0.00";
    document.body.appendChild(newFrame);
    //mask遮罩层

    var newMask = document.createElement("div");
    newMask.id = M;
    newMask.style.position = "absolute";
    newMask.style.zIndex = "10000";
    newMask.style.width = w + "px";
    newMask.style.height = h + "px";
    newMask.style.top = y+"px";
    newMask.style.left = x+"px";
    newMask.style.background = "#FFFFFF";
    newMask.style.filter = "alpha(opacity=100)";
    newMask.style.opacity = "1";
    document.body.appendChild(newMask);
    newMask.innerHTML="<div><a href='#'>jjjjjjjjjjjjjjjjj</a></div>"
    //getCateList(newMask,src);
    if(c==0){
	    newMask.onmouseover=function(){
	    	memu(w,h,1,src,obj);
	    };
    }else{
    	newMask.onmouseout=function(){
    		c=0;
	    	closeMenu(1000);
	    			
	    };
    }
}
function closeMenu(time){
	setTimeout('removeMenu()',time);
}
function removeMenu(){
     document.body.removeChild($("memu_div"));
      document.body.removeChild($("memu_ifr"));
     return false;
}
function getCateList(obj,src){
	var ajax=new AjaxRequest();
	ajax.method="POST";
		ajax.url=src;
		ajax.callback=function(xmlobj){
			obj.innerHTML=xmlobj.responseText;
		}
		ajax.send();
}
//前台版主查看所有回复
    function viewAllReply(){
    	var postIds = document.getElementsByName("topicsID");
    	for(var i=0;i<postIds.length;i++){
    		if(document.getElementById("postsReply"+postIds[i].value).style.display=="none"){
    			document.getElementById("postsReply"+postIds[i].value).style.display="";
    		}else if(document.getElementById("postsReply"+postIds[i].value).style.display==""){
        		document.getElementById("postsReply"+postIds[i].value).style.display="none";
       		}
    	}
    }
//前台版主查看某一个回复
    function viewReply(divID){
        if(document.getElementById(divID).style.display=="none"){
        	document.getElementById(divID).style.display="";
        }else if(document.getElementById(divID).style.display==""){
        	document.getElementById(divID).style.display="none";
        }
    }
    
     //前台审核/回复全选
   function selectall(obj) { 
        var temp = document.getElementsByName("topicsID"); 
        for (var i =0; i<temp.length; i++) 
        { 
            temp[i].checked = obj.checked; 
        } 
    } 
    
          //前台版主还原帖子(回复)
   function auditTopicsPoststoGo(satoryId,type){
     var topicsIDs = document.getElementsByName("topicsID");
     var topicsStr = "";
     for(var i=0;i<topicsIDs.length;i++){
      if(topicsIDs[i].checked==true){
        topicsStr+=topicsIDs[i].value+",";
       }
     }
      if(window.confirm("确定还原吗？")){
       bbslimit.auditTopicsPoststoGo(topicsStr,type,function (data){
         if(data=="1"){
           alert("还原成功！");
           document.location.href="bbs_recycle.jsp?cateId="+satoryId+"&type="+type;
         }else if(data=="0"){
           alert("还原失败！");
         }
       });
     }
   }
         //前台版主彻底删除帖子(回复)
   function auditTPDelForever(satoryId,type){
     var topicsIDs = document.getElementsByName("topicsID");
     var topicsStr = "";
     for(var i=0;i<topicsIDs.length;i++){
      if(topicsIDs[i].checked==true){
        topicsStr+=topicsIDs[i].value+",";
       }
     }
      if(window.confirm("确定彻底删除吗？")){
       bbslimit.auditTPDelForever(topicsStr,type,function (data){
         if(data=="1"){
           alert("删除成功！");
           bbslimit.updateTodayTopicNum(satoryId,function(data){
		   });
           document.location.href="bbs_recycle.jsp?cateId="+satoryId+"&type="+type;
         }else if(data=="0"){
           alert("删除失败！");
         }
       });
     }
   }
   
     //前台版主批量审核帖子/回复
   function auditTopicsPosts(satoryId,type){
     var topicsIDs = document.getElementsByName("topicsID");
     var topicsStr = "";
     for(var i=0;i<topicsIDs.length;i++){
      if(topicsIDs[i].checked==true){
        topicsStr+=topicsIDs[i].value+",";
       }
     }
      if(window.confirm("确定批量审核吗？")){
       bbslimit.auditTopicsPosts(topicsStr,type,function (data){
         if(data=="1"){
           alert("批量审核成功！");
           document.location.href="bbs_audit.jsp?cateId="+satoryId+"&type="+type+"&typegc=0";
         }else if(data=="0"){
           alert("审核失败！");
         }
       });
     }
   }
      //前台版主批量删除帖子
   function delAuditTopicsPosts(satoryId,type){
     var topicsIDs = document.getElementsByName("topicsID");
     var opuserId = document.getElementById("userId").value;
     var delOpCauseValue = document.getElementById("delOpCauseValue").value;
   	 var topicAuthor = document.getElementById("topicAuthor");
	 var notiseAuhor ="0";
 	 if(topicAuthor.checked==true){
 	 	//通知
 		notiseAuhor="1";
 	 }
     var topicsStr = "";
     for(var i=0;i<topicsIDs.length;i++){
      if(topicsIDs[i].checked==true){
        topicsStr+=topicsIDs[i].value+",";
       }
     }
      if(window.confirm("确定批量删除吗？")){
       bbslimit.delAuditTopicsPosts(topicsStr,type,opuserId,delOpCauseValue,notiseAuhor,function (data){
        if(data=="1"){
           alert("批量删除成功！");
           document.location.href="bbs_audit.jsp?cateId="+satoryId;
         }else if(data=="0"){
           alert("删除失败！");
         }
       });
     }
   }
   
   
 //回复列表页面批量的删除和屏蔽方法
   function oprateReplyTopicsPosts(){
   	 var type ="";
   	 var postsIds = document.getElementsByName("replyPostsId");
   	 var postsIdStr = "";
     var delorsheild = document.getElementsByName("delorsheild");
     var opuserId = document.getElementById("userId").value;
     var delOpCauseValue = "";
     var postAuthor = "";
     var notiseAuhor ="0";
      for(var i=0;i<delorsheild.length;i++){
	      if(delorsheild[i].checked==true){
	        	type = delorsheild[i].value;
	       }
     }
     for(var j=0;j<postsIds.length;j++){
     	 if(postsIds[j].checked==true){
     	 	postsIdStr+=postsIds[j].value+",";
     	 }
     }
     delOpCauseValue = document.getElementById("delReplyOpCauseValue").value;
		var postAuthor = document.getElementById("postAuthor");
	 	 if(topicAuthor.checked==true){
	 	 	//通知
	 		notiseAuhor="1";
 	 	 }
     if(postsIdStr==""){
     	alert("请选择所要操作的回复！");
     	return false;
     }else if(type==""){
     	alert("请选择操作项！");
     	return false;
     }else if(type=="0"){
     	//0:表示屏蔽或打开
     	  var  resheildOpenTemp = document.getElementById("resheildOpenTemp").value;
     	  if(resheildOpenTemp==""){
     	  		alert("请选择屏蔽或打开选项！");
     	  		return false;
     	  }else{
     	  		bbslimit.setPostsSheildOpen(postsIdStr,resheildOpenTemp,opuserId,delOpCauseValue,notiseAuhor,function(data){
     	  			if(data=="true"){
     	  				alert("屏蔽或打开回复成功！")
     	  				window.location.reload();
     	  			}else if(data=="false"){
     	  				alert("屏蔽或打开回复失败！");
     	  			}
     	  		});
     	  }
     }else if(type=="1"){
    	 //1:表示对回复做删除操作
 	 	  if(window.confirm("确定批量删除吗？")){
	       bbslimit.delAuditTopicsPosts(postsIdStr,1,opuserId,delOpCauseValue,notiseAuhor,function (data){
	        if(data=="1"){
	           alert("批量删除成功！");
	           window.location.reload();
	         }else if(data=="0"){
	           alert("删除失败！");
	         }
	       });
	     }
      }
   }
   
   
     //批量转帖
    function toTopicsAthorCat(){
    	var topicstr = getCheckboxValue("topicsID");
    	var cateId = $("toanothorcate").value;
    	var convertCause = $("OpCauseValue").value;
    	var topicAuthor = $("topicAuthor");
        var userId = $("userId").value;
        var notiseAuhor ="0";
	 	if(topicAuthor.checked){
	 	 	//通知
	 		notiseAuhor="1";
	 	}
		if(topicstr==""){
      		 alert("请选择所要操作的主题!");
        	 return false;
        }else{
        	if(window.confirm("确定转移？")){
	        	 bbslimit.toTopicsAthorCat(topicstr,cateId,userId,convertCause,notiseAuhor,function(data){
	        	 	if(data=="true"){
	        	 		alert("转移成功！");
	        	 		window.location.reload();
	        	 	}else if(data=="false"){
	        	 		alert("转移失败!");
	        	 	}else if(data=="0"){
	        	 		alert("对不起，主题不能移至顶级版块下！");
	        	 	}
	        	 });
        	 }
        }
    }
    //批量删帖至回收站
    function deleteManyPosts(){
    	var topicstr = getCheckboxValue("topicsID");//form.js
    	var opuserId = $("userId").value;
    	var delOpCauseValue = $("OpCauseValue").value;
    	var topicAuthor = $("topicAuthor").value;
 		var notiseAuhor ="0";
	 	if(topicAuthor.checked){
	 	 	//通知
	 		notiseAuhor="1";
	 	}
	     if(topicstr==""){
     		 	alert("请选择所要删除的主题!");
       	 	return false;
       	 }else{
       	 	if(window.confirm("确定删除?")){
       	 		bbslimit.deleteManyPosts(topicstr,opuserId,delOpCauseValue,notiseAuhor,function(data){
       	 			if(data=="true"){
       	 				alert("删除成功！");
       	 				window.location.reload();
       	 			}else if(data=="false"){
       	 				alert("删除失败！");
       	 			}
       	 		});
       	 	}
       	 }
    }
    //批量置精华
    function toManyPostsBests(){
    		 var topicIds = document.getElementsByName("topicsID");
    	     var topicstr = "";
		     for(var i=0;i<topicIds.length;i++){
			      if(topicIds[i].checked==true){
			        topicstr+=topicIds[i].value+",";
			       }
		     }
    		var postsBest = document.getElementById("postsBest").value;
    		if(topicstr==""){
    			alert("请选择所要操作的主题！");
    		}else{
    		if(postsBest=='0'){ 
			    bbslimit.getScoreObject("FINTOPIC","BBS",function(data){
			      if(data.id==0){
			        alert("没有置精华贴项目，不能置为精华贴！");
			      }else{
			        var score = "置为精华贴将为用户加"+data.scores+"积分！确定执行吗？";
				        if(window.confirm(score)){
					         bbslimit.toManyPostsBests(topicstr,function (data){
						         if(data=="true"){
							           alert("置精华贴成功！");
							           window.location.reload();
						         }else if(data=="false"){
						         	   alert("设置失败！");
						         }
					         });
				        }        
			       }
			      });
		   }else if(postsBest=='1'){
		  		 if(window.confirm("确定解除精华贴吗?")){
		  		 	bbslimit.toFreeManyPostsBests(topicstr,function(data){
		  		 		if(data=="true"){
		  		 			alert("解除成功!");
		  		 			window.location.reload();
		  		 		}else if(data=="false"){
		  		 			alert("解除失败!")
		  		 		}
		  		 	});
		  		 }
		   }
		 }
      }
      //批量推荐
      function toManyPostsRecommend(){
      		 var topicIds = document.getElementsByName("topicsID");
      		 var electValue = document.getElementById("electValue").value;
    	     var topicstr = "";
		     for(var i=0;i<topicIds.length;i++){
			      if(topicIds[i].checked==true){
			        topicstr+=topicIds[i].value+",";
			       }
		     }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     }else{
			     if(electValue=="0"){
			     	     bbslimit.getScoreObject("RECTOPIC","BBS",function(data){
					      if(data.id==0){
					        alert("没有置推荐贴项目，不能置为推荐贴！");
					      }else{
					        var score = "置推荐贴将给用户加"+data.scores+"积分！确定执行吗？";
						        if(window.confirm(score)){
						        	 bbslimit.toManyPostsRecommend(topicstr,function (data){
							         if(data=="true"){
							           alert("置推荐贴成功！");
							           window.location.reload();
							         }else if(data=="false"){
							          alert("置推荐失败！");
							         }
						         });
					       		 }        
					       }
					      });
			     }else if(electValue=="1"){
			     	bbslimit.toFreeManyPostsRecommend(topicstr,function(data){
			     		if(data=="true"){
			     			alert("解除成功!");
			     			window.location.reload();
			     		}else if(data=="false"){
							alert("解除失败!");			     		
			     		}
			     	});
			     } 
		     }
      }
      //管理员置高亮(列表页面用到的)
      function setTopicHighLight(){
             var topicIds = document.getElementsByName("topicsID");
      		 var inputcolor = document.getElementById("inputcolor").value;
    	     var topicstr = "";
		     for(var i=0;i<topicIds.length;i++){
			      if(topicIds[i].checked==true){
			        topicstr+=topicIds[i].value+",";
			       }
		     }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicHighLight(topicstr,inputcolor,function(data){
							if(data=="true"){
								alert("置高亮成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("置高亮失败！");
							}
						});
					  }
				}
      }
      //批量置顶
    function  toManyPostsTop(){
      	     var topicIds = document.getElementsByName("topicsID");
      		 var toptime = document.getElementById("toptime").value;
      		 var temp = document.getElementById("temp").value
    	     var topicstr = "";
		     for(var i=0;i<topicIds.length;i++){
			      if(topicIds[i].checked==true){
			        topicstr+=topicIds[i].value+",";
			       }
		     }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else if(temp==""){
		     	alert("请选择置顶类型！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.toManyPostsTop(topicstr,temp,toptime,function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
            //批量关闭帖子
    function  setManyTopicsCloseOpen(){
      	     var topicstr = getCheckboxValue("topicsID");
      		 var opclosetime = $("toptime").value;
      		 var opclosetemp = getRadioValue("opclosetemp");
      		 var opCauseValue = $("OpCauseValue").value;
      		 var sendUser = $("userId").value;
			 var topicAuthor = $("topicAuthor");
			 var notiseAuhor ="0";
			 if(topicAuthor.checked){
			 	 //通知
			 	notiseAuhor="1";
			 }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else if(opclosetemp==""){
		     	alert("请选择关闭/打开！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicsCloseOpen(topicstr,opclosetemp,opclosetime,sendUser,opCauseValue,notiseAuhor,function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
                  //关闭帖子
    function  setTopicsCloseOpen(topicid){
      	     var topicId = topicid;
      		 var opclosetime = document.getElementById("opclosetime").value;
      		 var opclosetemp = document.getElementById("opclosetemp").value
             if(opclosetemp==""){
		     	alert("请选择关闭/打开！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicsCloseOpen(topicId,opclosetemp,opclosetime,"0","","0",function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
      		
      		
    //对帖子进行评分
    function setTopicsGrade(topicid){
    	var opUserId = document.getElementById("userId").value;
    	var notice = 0;
    	var opCause = document.getElementById("gradeOpCauseValue").value;
    	var grade = document.getElementById("gradevalue").value;
    	if(document.getElementById("gradeAuthor").checked==true){
    		notice=1;
    	}else{
    		notice=0;
    	}
    	if(grade==''||grade=='0'){
    		alert("对不起，评分分值不能为空或为0!");
    		return false;
    	}else if(!IsInt(trim(grade))){
    		alert("分值必须为整数!");
    		return false;
    	}else{
    		if(window.confirm("确定评分?")){
    			bbslimit.setTopicsGrade(opUserId,topicid,grade,opCause,notice,function(data){
    				if(data=="true"){
    					alert("评分成功，谢谢参与!");
    					window.location.reload();
    				}else if(data=="false"){
    					alert("对不起，评分失败!");
    				}else if(data=="0"){
    					alert("对不起，不能给自己发的帖子评分!");
    				}
    			});
    		}
    	}
    }
                  //屏蔽帖子
    function  setTopicsSheildOpen(topicid){
      	     var topicId = topicid;
      		 var sheildOpenTemp = document.getElementById("sheildOpenTemp").value
             if(sheildOpenTemp==""){
		     	alert("请选择屏蔽/打开！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicsSheildOpen(topicId,sheildOpenTemp,"0","","0",function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
      		            //批量屏蔽帖子
    function  setManyTopicsSheildOpen(){
	         var topicstr = getCheckboxValue("topicsID");//form.js
      		 var sheildOpenTemp = $("sheildOpenTemp").value
      		 var opuserId = $("userId").value;
		     var opCauseValue = $("OpCauseValue").value;
		     var topicAuthor = $("topicAuthor");
		      var notiseAuhor ="0";
			 if(topicAuthor.checked){
			 	 //通知
			 	notiseAuhor="1";
			 }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else if(sheildOpenTemp==""){
		     	alert("请选择屏蔽/打开！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicsSheildOpen(topicstr,sheildOpenTemp,opuserId,opCauseValue,notiseAuhor,function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
      		
         		            //批量提升或下沉主题
    function  setManyTopicsSheildOpen(){
	         var topicstr = getCheckboxValue("topicsID");//form.js
      		 var sheildOpenTemp = $("sheildOpenTemp").value
      		 var opuserId = $("userId").value;
		     var opCauseValue = $("OpCauseValue").value;
		     var topicAuthor = $("topicAuthor");
		      var notiseAuhor ="0";
			 if(topicAuthor.checked){
			 	 //通知
			 	notiseAuhor="1";
			 }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else if(sheildOpenTemp==""){
		     	alert("请选择屏蔽/打开！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicsSheildOpen(topicstr,sheildOpenTemp,opuserId,opCauseValue,notiseAuhor,function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
          		            //批量提升或下沉主题
    function  setManyTopicsUpDown(){
	         var topicstr = getCheckboxValue("topicsID");//form.js
	         var toptime = document.getElementById("toptime").value;
      		 var topicsupgrade = $("topicsupgrade").value
      		 var opuserId = $("userId").value;
		     var opCauseValue = $("OpCauseValue").value;
		     var topicAuthor = $("topicAuthor");
		      var notiseAuhor ="0";
			 if(topicAuthor.checked){
			 	 //通知
			 	notiseAuhor="1";
			 }
		     if(topicstr==""){
		     	alert("请选择所要操作的主题！");
		     	return false;
		     }else{
		     	if(window.confirm("确定设置？")){
						bbslimit.setManyTopicsUpDown(topicstr,topicsupgrade,opuserId,opCauseValue,notiseAuhor,toptime,function(data){
							if(data=="true"){
								alert("设置成功!");
					     		window.location.reload();
							}else if(data=="false"){
								alert("设置失败！");
							}
						});
					  }
				}
      		}
            //管理员置高亮(阅读页面用到的)
      function setTopicsHighLight(topicId){
      		 var style="";
      		 var inputcolor = document.getElementById("inputcolor").value;
      		 if(inputcolor!=''){
      		 	style+="color:"+inputcolor+";";
      		 }
      		 var italic = document.getElementById("italic");
      		 var bold = document.getElementById("bold");
      		 if(italic.checked==true){
      		 	style+=italic.value;
      		 }
      		 if(bold.checked==true){
      		 	style+=bold.value;
      		 }
		     	if(window.confirm("确定设置？")){
						bbslimit.setTopicHighLight(topicId,style,function(data){
							if(data=="true"){
								alert("置高亮成功!");
								window.location.reload();
							}else if(data=="false"){
								alert("置高亮失败！");
							}
						});
			    }
       }
   function rgb(red,green,blue) {
		var hexarray= new Array(256);
		hexarray[0]="00"; hexarray[1]="01"; hexarray[2]="02";
		hexarray[3]="03"; hexarray[4]="04"; hexarray[5]="05";
		hexarray[6]="06"; hexarray[7]="07"; hexarray[8]="08";
		hexarray[9]="09"; hexarray[10]="0A"; hexarray[11]="0B"; 
		hexarray[12]="0C"; hexarray[13]="0D"; hexarray[14]="0E";
		hexarray[15]="0F"; hexarray[16]="10"; hexarray[17]="11";
		hexarray[18]="12"; hexarray[19]="13"; hexarray[20]="14";
		hexarray[21]="15"; hexarray[22]="16"; hexarray[23]="17";
		hexarray[24]="18"; hexarray[25]="19"; hexarray[26]="1A";
		hexarray[27]="1B"; hexarray[28]="1C"; hexarray[29]="1D";
		hexarray[30]="1E"; hexarray[31]="1F"; hexarray[32]="20";
		hexarray[33]="21"; hexarray[34]="22"; hexarray[35]="23";
		hexarray[36]="24"; hexarray[37]="25"; hexarray[38]="26";
		hexarray[39]="27"; hexarray[40]="28"; hexarray[41]="29"; 
		hexarray[42]="2A"; hexarray[43]="2B"; hexarray[44]="2C";
		hexarray[45]="2D"; hexarray[46]="2E"; hexarray[47]="2F";
		hexarray[48]="30"; hexarray[49]="31"; hexarray[50]="32";
		hexarray[51]="33"; hexarray[52]="34"; hexarray[53]="35";
		hexarray[54]="36"; hexarray[55]="37"; hexarray[56]="38";
		hexarray[57]="39"; hexarray[58]="3A"; hexarray[59]="3B";
		hexarray[60]="3C"; hexarray[61]="3D"; hexarray[62]="3E";
		hexarray[63]="3F"; hexarray[64]="40"; hexarray[65]="41";
		hexarray[66]="42"; hexarray[67]="43"; hexarray[68]="44";
		hexarray[69]="45"; hexarray[70]="46"; hexarray[71]="47";
		hexarray[72]="48"; hexarray[73]="49"; hexarray[74]="4A";
		hexarray[75]="4B"; hexarray[76]="4C"; hexarray[77]="4D";
		hexarray[78]="4E"; hexarray[79]="4F"; hexarray[80]="50";
		hexarray[81]="51"; hexarray[82]="52"; hexarray[83]="53";
		hexarray[84]="54"; hexarray[85]="55"; hexarray[86]="56";
		hexarray[87]="57"; hexarray[88]="58"; hexarray[89]="59";
		hexarray[90]="5A"; hexarray[91]="5B"; hexarray[92]="5C";
		hexarray[93]="5D"; hexarray[94]="5E"; hexarray[95]="6F";
		hexarray[96]="60"; hexarray[97]="61"; hexarray[98]="62";
		hexarray[99]="63"; hexarray[100]="64"; hexarray[101]="65";
		hexarray[102]="66"; hexarray[103]="67"; hexarray[104]="68";
		hexarray[105]="69"; hexarray[106]="6A"; hexarray[107]="6B";
		hexarray[108]="6C"; hexarray[109]="6D"; hexarray[110]="6E";
		hexarray[111]="6F"; hexarray[112]="70"; hexarray[113]="71";
		hexarray[114]="72"; hexarray[115]="73"; hexarray[116]="74";
		hexarray[117]="75"; hexarray[118]="76"; hexarray[119]="77";
		hexarray[120]="78"; hexarray[121]="79"; hexarray[122]="7A";
		hexarray[123]="7B"; hexarray[124]="7C"; hexarray[125]="7D";
		hexarray[126]="7E"; hexarray[127]="7F"; hexarray[128]="80";
		hexarray[129]="81"; hexarray[130]="82"; hexarray[131]="83";
		hexarray[132]="84"; hexarray[133]="85"; hexarray[134]="86";
		hexarray[135]="87"; hexarray[136]="88"; hexarray[137]="89";
		hexarray[138]="8A"; hexarray[139]="8B"; hexarray[140]="8C";
		hexarray[141]="8D"; hexarray[142]="8E"; hexarray[143]="8F";
		hexarray[144]="90"; hexarray[145]="91"; hexarray[146]="92"; 
		hexarray[147]="93"; hexarray[148]="94"; hexarray[149]="95";
		hexarray[150]="96"; hexarray[151]="97"; hexarray[152]="98";
		hexarray[153]="99"; hexarray[154]="9A"; hexarray[155]="9B";
		hexarray[156]="9C"; hexarray[157]="9D"; hexarray[158]="9E";
		hexarray[159]="9F"; hexarray[160]="A0"; hexarray[161]="A1";
		hexarray[162]="A2"; hexarray[163]="A3"; hexarray[164]="A4";
		hexarray[165]="A5"; hexarray[166]="A6"; hexarray[167]="A7";
		hexarray[168]="A8"; hexarray[169]="A9"; hexarray[170]="AA";
		hexarray[171]="AB"; hexarray[172]="AC"; hexarray[173]="AD";
		hexarray[174]="AE"; hexarray[175]="AF"; hexarray[176]="B0";
		hexarray[177]="B1"; hexarray[178]="B2"; hexarray[179]="B3";
		hexarray[180]="B4"; hexarray[181]="B5"; hexarray[182]="B6";
		hexarray[183]="B7"; hexarray[184]="B8"; hexarray[185]="B9";
		hexarray[186]="BA"; hexarray[187]="BB"; hexarray[188]="BC";
		hexarray[189]="BD"; hexarray[190]="BE"; hexarray[191]="BF";
		hexarray[192]="C0"; hexarray[193]="C1"; hexarray[194]="C2";
		hexarray[195]="C3"; hexarray[196]="C4"; hexarray[197]="C5";
		hexarray[198]="C6"; hexarray[199]="C7"; hexarray[200]="C8";
		hexarray[201]="C9"; hexarray[202]="CA"; hexarray[203]="CB";
		hexarray[204]="CC"; hexarray[205]="CD"; hexarray[206]="CE";
		hexarray[207]="CF"; hexarray[208]="D0"; hexarray[209]="D1";
		hexarray[210]="D2"; hexarray[211]="D3"; hexarray[212]="D4";
		hexarray[213]="D5"; hexarray[214]="D6"; hexarray[215]="D7";
		hexarray[216]="D8"; hexarray[217]="D9"; hexarray[218]="DA";
		hexarray[219]="DB"; hexarray[220]="DC"; hexarray[221]="DD";
		hexarray[222]="DE"; hexarray[223]="DF"; hexarray[224]="E0";
		hexarray[225]="E1"; hexarray[226]="E2"; hexarray[227]="E3";
		hexarray[228]="E4"; hexarray[229]="E5"; hexarray[230]="E6";
		hexarray[231]="E7"; hexarray[232]="E8"; hexarray[233]="E9";
		hexarray[234]="EA"; hexarray[235]="EB"; hexarray[236]="EC";
		hexarray[237]="ED"; hexarray[238]="EE"; hexarray[239]="EF";
		hexarray[240]="F0"; hexarray[241]="F1"; hexarray[242]="F2";
		hexarray[243]="F3"; hexarray[244]="F4"; hexarray[245]="F5";
		hexarray[246]="F6"; hexarray[247]="F7"; hexarray[248]="F8";
		hexarray[249]="F9"; hexarray[250]="FA"; hexarray[251]="FB";
		hexarray[252]="FC"; hexarray[253]="FD"; hexarray[254]="FE"; 
		hexarray[255]="FF";
		hexcode = "#" + hexarray[red] + hexarray[green] + hexarray[blue];
		return hexcode;
}

var ColorHex=new Array('00','33','66','99','CC','FF') 
var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF') 
var current=null; 
function doclick(obj){ 
	var rgbcolor = "";
	if(obj.length>7){
		rgbcolor=rgb(trim(obj.substring(obj.indexOf('(')+1,obj.indexOf(')')).split(',')[0]),trim(obj.substring(obj.indexOf('(')+1,obj.indexOf(')')).split(',')[1]),trim(obj.substring(obj.indexOf('(')+1,obj.indexOf(')')).split(',')[2]));
		document.getElementById("inputcolor").value=rgbcolor;
		document.getElementById("inputcolor").style.backgroundColor=rgbcolor;
	}else{
		rgbcolor=obj;
		document.getElementById("inputcolor").value=rgbcolor;
		document.getElementById("inputcolor").style.backgroundColor=rgbcolor;
	}
}
function resetColor(){
	document.getElementById("inputcolor").value="";
	document.getElementById("inputcolor").style.backgroundColor="";
} 

//更具天数得到日期
function getTimeAddDay(datename,toptime){
	var DaysToAdd=document.getElementById(datename).value;
	if(DaysToAdd==""){
		document.getElementById(toptime).value="";
	}else{
		var now=new Date();
		var newdate=new Date();
		var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
		newdate.setTime(newtimems);
		var datetime = newdate.getFullYear()+"-"+(newdate.getMonth()+1)+"-"+newdate.getDate();
		document.getElementById(toptime).value=datetime;
	}
}
function changeCause(selID,selCause){
   var selconOpCause = document.getElementById(selID).value;
   document.getElementById(selCause).value=selconOpCause;
}
function ShowModal(dname)
{
   var buyDiv=document.getElementById(dname+'SelName');
   var objDiv=document.getElementById('objText');
   var disable=document.getElementById('disableDiv');
   if(buyDiv.style.display=='none')
   {
    buyDiv.style.display='block';
    disable.style.display='block';
    buyDiv.innerHTML=objDiv.innerHTML;
   }else{
    buyDiv.style.display='none';
    disable.style.display='none';
   }
}
function optManager(){
   	var topicstr = getCheckboxValue("topicsID");
   	var toptime="",top="",best="",rec="",hl="";
   	var fontstyle="";
   	if($("top").checked){
   		 toptime = $("toptime").value;
    	 top = $("temp").value;
	}
    if($("best").checked)
    	 best = $("postsBest").value;
    if($("heightlight").checked){
	        hl = $("inputcolor").value;
	    	if(hl!=''){
	    		fontstyle+="color:"+hl+";"
	    	}
	    	var italic = document.getElementById("italic");
	    	var bold = document.getElementById("bold");
	    	if(italic.checked==true){
	    		fontstyle+=italic.value;
	    	}
	    	if(bold.checked==true){
	    		fontstyle+=bold.value;
	    	}
    	}
    if($("rec").checked)
    	 rec = $("electValue").value;
   	var opCause = $("OpCauseValue").value;
   	var topicAuthor = $("topicAuthor");
    var userId = $("userId").value;
    var notiseAuhor ="0";
 	if(topicAuthor.checked){
 	 	//通知
 		notiseAuhor="1";
 	}
	if(topicstr==""){
     	 alert("请选择所要操作的主题!");
       	 return false;
       }else{
       	 bbslimit.optManager(topicstr,top,toptime,best,rec,fontstyle,userId,opCause,notiseAuhor,function(data){
       	 	if(data=="true"){
       	 		alert("操作成功！");
       	 		window.location.reload();
       	 	}else if(data=="false"){
       	 		alert("操作失败!");
       	 	}	
       	 });
       }
}


