function ccode(){
var _ccode=document.getElementById("ccode");
var _str="<strong>验证码 </strong> <img src=\"http://"+commentdomain+"/checkcode.php\" onclick='this.src = \"http://"+commentdomain+"/checkcode.php?time=\"+new Date().getTime();' /> <input type=\"text\" name=\"checkcode\" id=\"checkcode\" value=\"\" size=\"8\" />";
_ccode.innerHTML=_str;
}

function comment_quote(replyid,lock)
{
  if(lock==1){
    alert("对不起该文章已锁定,不能进行回复.");
    return;

  }	
  document.getElementById("replybody").focus();
  document.getElementById("replybody").value += "[quote]"+replyid+"[/quote]\n";
  document.getElementById("replybody").focus();
}



function comment_submit_form(lock)
{
  if(lock==1){
    alert("对不起该文章已锁定,不能发表留言.");
    return false;
  }else if(document.getElementById("replybody").value.match(/[\S]/ig)==null){
    alert("请输入要发表的留言.");
    document.getElementById("replybody").value="";
    document.getElementById("replybody").focus();   
    return false;	
  }else{
    var content=document.getElementById("replybody").value;
    content=content.substring(content.lastIndexOf("]")+1,content.length);
    if(content.match(/[\S]/ig)==null){
       alert("请输入要回复的内容.");
       return false;	
    }
  }
  var checkcode=document.getElementById("checkcode").value;
  checkcode=checkcode.replace(/\s*/ig,"");
  if(checkcode.length!=4||checkcode.match(/[^\w]/ig)!=null){
    alert("请输入正确的验证码!");
    return false;
  }
  document.getElementById("checkcode").value=checkcode;
  return true;
}


function comment_upvote(channelid,threadid)
{
  var f=document.createElement("form");
      f.action="http://"+commentdomain+"/do_comment.php";
      f.method="post";
      var i=document.createElement("input");
      i.type= "hidden";
      i.value=channelid;
      i.name= "cid";
      f.appendChild(i);
      var i2=document.createElement("input");
      i2.type= "hidden";
      i2.value=threadid;
      i2.name= "threadid";
      f.appendChild(i2);
      document.body.appendChild(f);
      var i3=document.createElement("input");
      i3.type= "hidden";
      i3.value=document.getElementById("url").value;
      i3.name= "url";
      f.appendChild(i3);
      document.body.appendChild(f);


      f.target="_self";
      f.submit();
}

function comment_quote(replyid,lock)
{
  if(lock==1){
    alert("对不起该文章已锁定,不能进行回复.");
    return;

  }	
  document.getElementById("replybody").focus();
  document.getElementById("replybody").value += "[quote]"+replyid+"[/quote]\n";
  document.getElementById("replybody").focus();
}

