var settings = {
	commentURI:SiteDir+"/action.php?do=comment&action=",
	diggURI:SiteDir+"/action.php?do=digg&action=do"
}
function digg(act,aid,cid){
	if(act=='up'||act=='against'){
		var pars = {'id':aid,'cid':cid,'ajax':'1',t: Math.random()};
		$.getJSON(settings.commentURI+act,pars, function(json){
		 	if(json.state=='1'){
			 	var Num=parseInt($("#"+act+"_"+cid).text());
			 	$("#"+act+"_"+cid).text(Num+1); 
		 	}
		 	if(json.state=='0'){
		 	 	alert(json.text);
		 	 }
		});
		return;
	}
	if(act=='digg'){
		var pars = {'id':aid,'t': Math.random()};
		$.getJSON(settings.diggURI,pars, function(json){
		 	if(json.state=='1'){
			 	var Num=parseInt($("#"+act+"_"+aid).text());
			 	$("#"+act+"_"+aid).text(Num+1); 
		 	}
		 	if(json.state=='0'){
		 	 	alert(json.text);
		 	 }
		});
		return;
	}
}
function quote(cid){
	addHTML('<div style="border:1px solid #999999; padding: 3px; background-color: #FFFFEE;margin-bottom: 12px; text-align:left;"><span style="color: #990000;font-weight:bold">----- 以下引用 <STRONG><EM>' + $("#comment_username_" + cid).text() + '</EM></STRONG> 于 ' + $("#comment_time_" + cid).text() + ' 的发言 -----</span><p style="margin: 9px 3px; line-height: 20px; text-align: left; color:#000000;">' + $("#comment_contents_" + cid).html() + '</p></div>');
}
function reply(cid){
	addHTML('<span style="padding-bottom:3px;color:#999999;">---<I>回复</I> ' + $("#lou_" + cid).text() + ' [' + $("#comment_username_" + cid).text() + '] 时间:[' + $("#comment_time_" + cid).text() + ']---</span><br />');
}
function addHTML(html){
	var oEditor = FCKeditorAPI.GetInstance('commentext');
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ){
		oEditor.InsertHtml(html);
	}else{
		alert("评论框不支持此功能！");
	}
}
function textareasize(obj) {
	if(obj.scrollHeight > 70) {
		obj.style.height = obj.scrollHeight + 'px';
	}
}