﻿
var g_commentvuid = "0";
var g_commentouid = "0";
var g_commenttype = "0";
var g_commentid = "0";
var g_recentcomment = "";
var g_commenttypetext = "评论";
var g_commenttitle = "";
var g_is_privacy_pwd = "0";
var g_delrefresh = "0";

var g_homedir = "home.aspx";

var e_bold = false;
var e_italic = false;
var e_underline = false;
var e_font = false;
var e_fontsize = false;
var e_color = false;
var e_img = false;
var e_link = false;
var e_media = false;

function initComment(vuid, ouid, type, id)
{
    //lw initComment("10397740", "10397740", "0", "10397740");
    //wj initComment("10397740", "2092436", "0", "2092436");
    
	g_commentvuid = vuid; //登陆留言者       
	g_commentouid = ouid; //接收留言者
	g_commenttype = type; 
	g_commentid = id;  //
	
	if (g_commenttype == "0")
	{
		g_commenttypetext = "留言";
	}
}

function getCommentList()
{
	var url = "../comment/list.aspx";
	g_commentouid=document.getElementById("ucguestbook1_fid").value;
	var pars = "type="+g_commenttype+"&id="+g_commentid+"&uid="+g_commentouid;
	var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { getCommentListShow(req); } });
}

function _getCommentReplyHtml(ouid, rdata, vuid, owneruid, v_tag)
{
	var html = '';
	if (vuid == owneruid
		|| vuid == rdata.uid
		|| (vuid == ouid && rdata.uid != owneruid))
	{
		html += '<div class="hy_of" id=replytitle_'+rdata.cid+' onmouseover="this.className=\'hy_on\';s(\'hy2_2_'+rdata.cid+'\');" onmouseout="this.className=\'hy_of\';h(\'hy2_2_'+rdata.cid+'\');">';
	}
	else
	{
		html += '<div class="hy_of" id=replytitle_'+rdata.cid+'>';
	}
	if (vuid == rdata.uid)
	{
		html += '<div class="czhy_tx2" style="width:180px;">我的回复：</div>';
	}
	else
	{
		html += '<div class="czhy_tx2" style="width:180px;"><a href="'+g_homedir+'?uid='+rdata.uid+'" class="funclink sl" title="'+rdata.real_name+'">'+rdata.real_name+'</a>的回复：</div>';
	}
	html += '<div class="gw13" style="float:left;">'+rdata.ctime+'</div>';
	if (ouid == vuid)
	{
		html += '<div class="r dn" id="hy2_2_'+rdata.cid+'"><a href="javascript:' + v_tag + 'delComment(\''+rdata.cid+'\', \''+owneruid+'\', \''+owneruid+'\')" class="ql2"><b>×</b></a></div>';
	}
	else
	{
		html += '<div class="r dn" id="hy2_2_'+rdata.cid+'"><a href="javascript:' + v_tag + 'delComment(\''+rdata.cid+'\', \''+ouid+'\', \''+owneruid+'\')" class="ql2"><b>×</b></a></div>';
	}
	html += '<div class="c"></div>';
	html += '</div>';
	rdata.content = rdata.content.replace(/<img/g , "<img onload='_commentImageResize(this,350);'");
	if (vuid == rdata.uid)
	{
		html += '<div class="hy_wd" id=replycomment_'+rdata.cid+'>'+rdata.content+'</div>';
	}
	else
	{
		html += '<div  class="hy_br" id=replycomment_'+rdata.cid+'>'+rdata.content+'</div>';
	}
	return html;
}

function getCommentReplyHtml(ouid, rdata)
{
	return _getCommentReplyHtml(ouid, rdata, g_commentvuid, g_commentouid, "");
}

function commentFilter(v_str)
{
	
	v_tag = v_str.toLowerCase();
	if (v_str.substr(0, 4) == "<img")
	{
		return v_str;
	}
	if (v_str.substr(0, 3) == "<br")
	{
		return v_str;
	}
	if (v_str.substr(0, 2) == "<p")
	{
		return v_str;
	}
	if (v_str.substr(0, 3) == "</p")
	{
		return v_str;
	}
	if (v_str.substr(0, 2) == "<a")
	{
		return v_str;
	}
	if (v_str.substr(0, 3) == "</a")
	{
		return v_str;
	}
	
	return " ";
}

function getCommentThreadHtml(tid, tdata)
{
  // debugger;
    
	var html = '<div class="gw1" id=threaddiv_'+tid;
	if((g_commenttype == "0")
		&& (g_commentvuid == g_commentouid))
	{
		if(tdata[0].friend=="0")
		{
			html += ' onmouseover="javascript:showfrdiv('+tid+');" onmouseout="javascript:hidefrdiv('+tid+');" >';
		}
		else
		{
			html += '>';
		}
	}
	else
	{
		html += '>';
	}
	html += '<div class="q_cygl2"><div class="l50_s"><a href="'+g_homedir+'?uid='+tdata[0].uid+'" title="'+tdata[0].real_name+'"><img src="'+tdata[0].icon+'" width="50" height="50" /></a></div>';
	html += '</div><div class="gw12">';
	if (tdata[0].hidden && parseInt(tdata[0].hidden))
	{
		html += '<p><b><font color=red>【悄悄话】</font></b></p>';
	}
	
	if (g_commentvuid == tdata[0].uid)
	{
		html += '<p class="gw_p1">我说道：</p>';
	}
	else
	{
		if (parseInt(tdata[0].online))
		{
			html += '<p class="gw_p1"><img src="images/u_zx1.gif" width="18" height="15" align="absmiddle" title="在线" /><a class="funclink sl" href="'+g_homedir+'?uid='+tdata[0].uid+'" title="'+tdata[0].real_name+'">'+tdata[0].real_name+'</a>说道：</p>';
		}
		else
		{
			html += '<p class="gw_p1"><a class="funclink sl" href="'+g_homedir+'?uid='+tdata[0].uid+'" title="'+tdata[0].real_name+'">'+tdata[0].real_name+'</a>说道：</p>';
		}
	}
	var str = tdata[0].content;	
	str = str.replace(/<\/?[^>]+>/gi, commentFilter);
	str = str.replace(/<img[^>]+(src=\"[^\"]+\"|src=\'[^\']+\')[^>]+>/gi, '<img $1>');
	
	html += '<p  style="font-size:12px;text-indent:0em;">'+str.replace(/<img/g , "<img onload='_commentImageResize(this,350);'")+'</p>';
	if (tdata.length > 1)
	{
		html += '<div id=commentdiv_'+tid+' class="hy_n">';
		for (i=1; i<tdata.length; i++)
		{
			html += getCommentReplyHtml(tdata[0].uid, tdata[i]);
		}
		html += '</div>';
	}
	else
	{
		html += '<div id=commentdiv_'+tid+' class="hy_n" style="display:none;">';
		html += '</div>';
	}
	html += '<p class="gw_p2">';
	if (g_commentvuid == tdata[0].uid)
	{
	    //html+='<a class="otherlink sl-gray" href=/msg/write.php?uids='+g_commentouid+'>短消息</a> ┊';
		html += '   <a class="otherlink sl-gray" href="javascript:delguest(\''+tid+'\');">删除</a>';
	}
	else if (g_commentvuid == g_commentouid)
	{
	    var ul="../guest/ReGuest.aspx?CID="+tid+"&REVID="+tdata[0].uid;        
        html +='<a  href=\"#\"  onclick=\"javascript:window.open(\''+ul+'\',\'newwindow\',\'height=320,width=400,top=250,left=280,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no\');\" class=\"lan\">回复┊</a>';
        
         var ul2="../guest/AddShortMess.aspx?revid="+tdata[0].uid;        
         html +='<a  href=\"#\"  onclick=\"javascript:window.open(\''+ul2+'\',\'newwindow\',\'height=320,width=400,top=250,left=280,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no\');\" class=\"lan\">短消息┊</a>';
         //<a class="otherlink sl-gray" href="javascript:replyComment(\''+tid+'\',\''+tdata[0].uid+'\')"></a>  <a class="otherlink sl-gray" href=/msg/write.php?uids='+tdata[0].uid+'>短消息</a>
		 html += '  <a class="otherlink sl-gray" href="javascript:delguest(\''+tid+'\');">删除</a>';
	}
	else if (g_commentouid == tdata[0].uid)
	{
		html += '<a class="otherlink sl-gray" href="javascript:replyComment(\''+tid+'\',\'0\')"></a>';
	}
	else
	{
		html += '<a class="otherlink sl-gray" href="javascript:replyComment(\''+tid+'\',\''+tdata[0].uid+'\')"></a>';
	}
	html += '</p><p><div id=replydiv_'+tid+'></div></p></div>';
	if((g_commenttype == "0")
		&& (g_commentvuid == g_commentouid))
	{
		if(tdata[0].friend=="0")
		{
			html += '<div class="l" title="举报陌生人骚扰留言" style="margin-left:-24px;margin-top:3px;"><img id="frimg_'+tid+'" onclick="javascript:reportFR('+tid+', '+tdata[0].uid+');" style="cursor: pointer;" width="14" height="14" alt="举报陌生人骚扰留言" align="absmiddle" src="/i2/tanhao.gif"/></div>';
		}
	}
	html += '<div class="gw13" style="width:48px;clear:left;">'+tdata[0].ctime+'</div>';
	html += '<div class="c"></div>';
	html += '</div>';
	
	return html;
}

function getCommentListShow(req)
{
	var r = req.responseText;
	
	
	//debugger;
	if(r == "0")
	{
		return;
	}
	else
	{
		eval("r="+r);
	}
	
	if (r.total >= 100)
	{
		if ($("limitCommentPrompt"))
		{
			s($("limitCommentPrompt"));
		}
	}
	
	var html = "";
	for (tid in r.data)
	{
		try
		{
			html += getCommentThreadHtml(tid, r.data[tid]);
		}
		catch(e)
		{
		}
	}
	if ($("commenttotal"))
	{
		$("commenttotal").innerHTML = r.total;
	}
	
	$("comment").innerHTML = html + $("comment").innerHTML;
}

function _delCommentThread(v_tid, v_ouid, v_type, v_tag)
{
	if (confirm("你确认要删除这条" + v_type + "和它的所有回复吗？"))
	{
		var url = "../comment/del.aspx";
		var pars = "thread_cid="+v_tid+"&ouid="+v_ouid;
		var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { eval(v_tag + "delCommentThreadShow(req)"); } });
	}
}

function delCommentThread(v_tid, v_ouid)
{
	return _delCommentThread(v_tid, v_ouid, g_commenttypetext, "")
}

function delCommentThreadShow(req)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	
	h('threaddiv_'+r);
}

function _delComment(v_cid, v_ouid, v_owner, v_tag)
{
	if (confirm("你确认要删除这条回复吗？"))
	{
		var url = "../comment/del.php";
		var pars = "cid="+v_cid+"&ouid="+v_ouid+"&owner="+v_owner;
		var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { eval(v_tag + "delCommentShow(req)"); } });
	}
}

function delComment(v_cid, v_ouid, v_owner)
{
	return _delComment(v_cid, v_ouid, v_owner, "");
}

function delCommentShow(req)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	
	h('replycomment_'+r);
	h('replytitle_'+r);
}

function _replyComment(v_tid, v_ouid, v_tag)
{
	var html = '<div class="mb5 mt5">'
	html += '<div class="l" style="width:300px;">';
//	html += '<span class="it_s"><textarea id="commentcontent__THREAD_CID_" cols="40" rows="2" class="it1" onfocus="this.className=\'it2\';" onblur="this.className=\'it1\';"></textarea></span>';
	html += '<div id="commentcontent__THREAD_CID_" name="commentcontent__THREAD_CID_"></div>';
	html += '</div>';
	html += '<div class="c" style="margin-top:0px;*margin-top:0px;"></div>';
	html += '</div>';
	html += '<div><div class="l" style="width:177px;*width:163px;">&nbsp;</div>';
	html += '<div class="rbs1"><input type="button" id="commentbtn__THREAD_CID_" value="回复" title="回复" class="rb1-12" onmouseover="this.className=\'rb2-12\';" onmouseout="this.className=\'rb1-12\';" onclick="' + v_tag + 'replyCommentSubmit(_THREAD_CID_,_OTHER_UID_)" /></div>';
	html += '<div class="flw5" >&nbsp;</div>';
	html += '<div class="gbs1"><input type="button" id="btn_fb" value="取消" title="取消" class="gb1-12" onmouseover="this.className=\'gb2-12\';" onmouseout="this.className=\'gb1-12\';" onclick="' + v_tag + 'cancelReply(_THREAD_CID_)" /></div>';
	html += '<div class="flw5">&nbsp;</div><div id="commentprompt__THREAD_CID_" style="display:none;" class="c6 p010">提交中...</div>';
	html += '<div class="c"></div>';
	html += '</div>';
	html = html.replace(/_THREAD_CID_/g , v_tid);
	html = html.replace(/_OTHER_UID_/g , v_ouid);
	$("replydiv_"+v_tid).innerHTML = html;
//	$("commentcontent_"+v_tid).focus();
	eval('comment_editor_'+v_tid+' = new webEditor("comment_editor_'+v_tid+'" , $("commentcontent_'+v_tid+'") , 268, 80, "");');
	eval('comment_editor_'+v_tid+'.init("");');
	setTimeout(v_tag + "setReplyEditorFocus('"+v_tid+"')", 1000);
	//alert(html);
}

function replyComment(v_tid, v_ouid)
{
	return _replyComment(v_tid, v_ouid, "");
}

function setReplyEditorFocus(v_tid)
{
	eval('comment_editor_'+v_tid+'.getFocus();');
}

function cancelReply(thread_cid)
{
	$("replydiv_"+thread_cid).innerHTML = "";
}

function _replyCommentSubmit(thread_cid, other_uid, ouid, type, id, v_tag)
{
//thread_cid 信息ID
//ouid 接收留言者
  //alert(ouid);
//	var content = $("commentcontent_"+thread_cid).value;
	var content = eval('comment_editor_'+thread_cid+'.getHtml();');
	
	if (content.length == 0)
	{
		alert("请输入回复内容。");
//		$("commentcontent_"+thread_cid).focus();
		eval('comment_editor_'+thread_cid+'.getFocus();');
		return;
	}
	
	$("commentbtn_" + thread_cid).disabled = true;
	s("commentprompt_" + thread_cid);
	
    
	var url = "../comment/reply.aspx";
//	var pars = "owner="+ouid+"&thread_cid="+thread_cid+"&type="+type+"&id="+id+"&ouid="+other_uid+"&texttype=plain&content="+encodeURIComponent(content);
	var pars = "owner="+ouid+"&thread_cid="+thread_cid+"&type="+type+"&id="+id+"&ouid="+other_uid+"&texttype="+eval('comment_editor_'+thread_cid+'.getTextType();')+"&content="+encodeURIComponent(content);
	//alert(pars);
	var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { eval(v_tag + "addCommentReplyShow(req, '"+other_uid+"', '"+thread_cid+"')"); } });
}

function replyCommentSubmit(thread_cid, other_uid)
{
	return _replyCommentSubmit(thread_cid, other_uid, g_commentouid, g_commenttype, g_commentid, "");
}

function _addCommentReplyShow(req, v_ouid, v_tag, thread_cid)
{
	$("commentbtn_" + thread_cid).disabled = false;
	h("commentprompt_" + thread_cid);
	
	var r = req.responseText;
	if(r == "0")
	{
		alert("回复失败");
		return;
	}
	else
	{
		eval("r="+r);
	}

	var html = eval(v_tag + "getCommentReplyHtml('"+v_ouid+"', r)");
	$("commentdiv_"+r.thread_cid).innerHTML += html;
	s("commentdiv_"+r.thread_cid);
	
//	$("commentcontent_"+r.thread_cid).value="";
	eval('comment_editor_'+r.thread_cid+'.setContent();');
	$("replydiv_"+r.thread_cid).innerHTML = "";
}

function addCommentReplyShow(req, v_ouid, thread_cid)
{
	return _addCommentReplyShow(req, v_ouid, "", thread_cid);
}

function addCommentSubmit(v_btn, v_prompt,vck)
{
//	if (!parseInt(g_commentvuid))
//	{
//		alert("请先登录然后留言" + g_commenttypetext + "。");
//		return;
//	}
   
	if(vck=="1")
	{
	  alert("只有好友才能留言！");
	  return;
	}
	else if(vck=="2")
	{
	   alert("请先登录，才能留言！");
	   return;
	}
	var content = comment_editor.getHtml();
	if (content.length == 0)
	{
		alert("请输入" + g_commenttypetext + "内容。");
		comment_editor.getFocus();
		return;
	}
	if (content == g_recentcomment)
	{
		return;
	}
	g_recentcomment = content;

	if (v_btn) v_btn.disabled = true;
	if ($(v_prompt)) s(v_prompt);
	
	var hidden = 0;
	if ($('comment_hiddenmsg')
		&& $('comment_hiddenmsg').checked)
	{
		hidden = 1;
	}
	g_commentouid=document.getElementById("ucguestbook1_fid").value;
	
	var url = "comment/post.aspx";
	
	var pars = "type="+g_commenttype+"&id="+g_commentid+"&ofriend="+g_commentouid+"&texttype="+comment_editor.getTextType()+"&content="+encodeURIComponent(content)+"&title="+encodeURIComponent(g_commenttitle)+"&hidden="+hidden+"&ispwd="+g_is_privacy_pwd;
	
	var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) {addCommentShow(req, v_btn, v_prompt); } });
}

function addCommentShow(req, v_btn, v_prompt)
{
	if (v_btn) v_btn.disabled = false;
	if ($(v_prompt)) h(v_prompt);

	var r = req.responseText;
	
	if(r == "0")
	{
		g_recentcomment = "";
		alert(g_commenttypetext + "失败");
		return;
	}
	else
	{
		eval("r=["+r+"]");
	}
    

	var html = getCommentThreadHtml(r[0].thread_cid, r);
	
	$("comment").innerHTML = html + $("comment").innerHTML;
	
	comment_editor.setContent("");
}






//COMMENT2

function c2_replyComment(v_tid, v_ouid)
{
	return _replyComment(v_tid, v_ouid, "c2_");
}

function c2_setReplyEditorFocus(v_tid)
{
	return setReplyEditorFocus(v_tid);
}

function c2_cancelReply(thread_cid)
{
	return cancelReply(thread_cid);
}

function c2_replyCommentSubmit(thread_cid,other_uid)
{
	return _replyCommentSubmit(thread_cid, other_uid, c2_g_mainthreaddata[thread_cid].owner_uid, c2_g_mainthreaddata[thread_cid].type, c2_g_mainthreaddata[thread_cid].id, "c2_");
}

function c2_addCommentReplyShow(req, v_ouid, thread_cid)
{
	return _addCommentReplyShow(req, v_ouid, "c2_", thread_cid);
}

function c2_getCommentReplyHtml(ouid, rdata)
{
	return _getCommentReplyHtml(ouid, rdata, c2_g_commentvuid, c2_g_mainthreaddata[rdata.thread_cid].owner_uid, "c2_");
}

function c2_delComment(v_cid, v_ouid, v_owner)
{
	return _delComment(v_cid, v_ouid, v_owner, "c2_");
}

function c2_delCommentShow(req)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	
	if(g_delrefresh == "1")
	{
		var href = window.location.href;
		var re = /t=(\d+)/g;
		if(re.test(href))
		{
			href = href.replace(re , "t="+Math.ceil(Math.random()*100));
		}
		else
		{
			if(-1 == href.indexOf('?'))
			{
				href = href+"?t="+Math.ceil(Math.random()*100);
			}
			else
			{
				href = href+"&t="+Math.ceil(Math.random()*100);
			}
		}
		window.location.href = href;
		exit;
	}
	
	$('replycomment_'+r).innerHTML = "此回复已被我删除";
	$('replycomment_'+r).className = "hy_br";
	$('replycomment_'+r).style.color = "#8692A2";
	$('replytitle_'+r).className = 'hy_of';
	h('hy2_2_' + r);
	$('replytitle_'+r).onmouseover = function () {};
	$('replytitle_'+r).onmouseout = function () {};
}


function c2_delCommentThread(v_tid, v_ouid)
{
	return _delCommentThread(v_tid, v_ouid, c2_g_commenttypetext, "c2_")
}


function c2_delCommentThreadShow(req, v_ouid)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	
	if(g_delrefresh == "1")
	{
		var href = window.location.href;
		var re = /t=(\d+)/g;
		if(re.test(href))
		{
			href = href.replace(re , "t="+Math.ceil(Math.random()*100));
		}
		else
		{
			if(-1 == href.indexOf('?'))
			{
				href = href+"?t="+Math.ceil(Math.random()*100);
			}
			else
			{
				href = href+"&t="+Math.ceil(Math.random()*100);
			}
		}
		window.location.href = href;
		exit;
	}

	var html = "<div style='color:#8692A2;'>此"+c2_g_commenttypetext+"已被我删除</div>";
	html += '<div class="gw_p2"><a href="/msg/write.php?uids=' + v_ouid + '" class="otherlink sl" title="短消息" target="_blank">短消息</a></div>';
	$('rightdiv_'+r).innerHTML = html;
}



var g3_commentvuid = 0;
var g3_commentisadmin = 0;
var g3_commenttype = 0;
var g3_commentid = 0;
var g3_commentgid = 0;

var g3_recentcomment= "";

function c3_initComment(vuid, isadmin , gid, type, id)
{
	g3_commentvuid = vuid;
	g3_commentisadmin = isadmin;
	g3_commentgid = gid;
	g3_commenttype = type;
	g3_commentid = id;
}

function c3_getCommentList()
{
	var url = "../group/commentlist.php";
	var pars = "type="+g3_commenttype+"&id="+g3_commentid+"&gid="+g3_commentgid;
	var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { c3_getCommentListShow(req); } });
}

function c3_getCommentListShow(req)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	else
	{
		eval("r="+r);
	}
	
	var html = "";
	for (var i=0 ; i<r.length ; i++)
	{
		html += c3_getCommentThreadHtml(r[i]);
	}
	$("comment").innerHTML = html + $("comment").innerHTML;
}



function c3_getCommentThreadHtml(tdata)
{
	var html = '<div class="gw1" id=threaddiv_'+tdata.cid+'>';
	html += '<div class="q_cygl2"><div class="l50_s"><a href="'+g_homedir+'?uid='+tdata.uid+'" title="'+tdata.real_name+'"><img src="'+tdata.icon+'" width="50" height="50" /></a></div>';
	html += '</div><div class="gw12">';
	if (g3_commentvuid == tdata.uid)
	{
		html += '<p class="gw_p1">我说道：</p>';
	}
	else
	{
		if (parseInt(tdata.online))
		{
			html += '<p class="gw_p1"><img src="/images/u_zx1.gif" width="18" height="15" align="absmiddle" title="在线" /><a class="funclink sl" href="'+g_homedir+'?uid='+tdata.uid+'" title="'+tdata.real_name+'">'+tdata.real_name+'</a>说道：</p>';
		}
		else
		{
			html += '<p class="gw_p1"><a class="funclink sl" href="'+g_homedir+'?uid='+tdata.uid+'" title="'+tdata.real_name+'">'+tdata.real_name+'</a>说道：</p>';
		}
	}
	var str = tdata.content;
	str = str.replace(/<\/?[^>]+>/gi, commentFilter);
	str = str.replace(/<img[^>]+(src=\"[^\"]+\"|src=\'[^\']+\')[^>]+>/gi, '<img $1>');
	
	html += '<p class="text" style="font-size:12px;">'+str.replace(/<img/g , "<img onload='_commentImageResize(this,350);'")+'</p>';
	html += '<p class="gw_p2">';
	html += '<a class="otherlink sl-gray" href=/msg/write.php?uids='+tdata.uid+'>短消息</a>';
	if(g3_commentisadmin
		|| g3_commentvuid == tdata.uid)
	{
		html += ' ┊ <a class="otherlink sl-gray" href="javascript:c3_delCommentThread(\''+tdata.cid+'\');">删除</a>';
	}
	html += '</p></div>';
	html += '<div class="gw13">'+tdata.ctime+'</div>';
	html += '<div class="c"></div>';
	html += '</div>';
	return html;
}


function c3_addCommentSubmit(v_btn, v_prompt)
{
	var content = comment_editor.getHtml();
	if (content.length == 0)
	{
		alert("请输入评论内容。");
		comment_editor.getFocus();
		return;
	}
	if (content == g3_recentcomment)
	{
		return;
	}
	g3_recentcomment = content;

	if (v_btn) v_btn.disabled = true;
	if ($(v_prompt)) s(v_prompt);

	var url = "/group/commentpost.php";
	var pars = "type="+g3_commenttype+"&id="+g3_commentid+"&gid="+g3_commentgid+"&texttype="+comment_editor.getTextType()+"&content="+encodeURIComponent(content);
	var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { c3_addCommentShow(req, v_btn, v_prompt); } });
}


function c3_addCommentShow(req, v_btn, v_prompt)
{
	if (v_btn) v_btn.disabled = false;
	if ($(v_prompt)) h(v_prompt);

	var r = req.responseText;
	if(r == "0")
	{
		g3_recentcomment = "";
		alert("评论失败");
		return;
	}
	else
	{
		eval("r="+r);
	}
	
	var html = c3_getCommentThreadHtml(r);
	$("comment").innerHTML = html + $("comment").innerHTML;
	comment_editor.setContent("");
}


function c3_delCommentThread(v_cid)
{
	if (confirm("你确认要删除这条评论吗？"))
	{
		var url = "/group/commentdel.php";
		var pars = "cid="+v_cid+"&gid="+g3_commentgid;
		var myAjax = new Ajax.Request(url, {method: "post", parameters: pars, onComplete: function (req) { c3_delCommentThreadShow(req); } });
	}
}

function c3_delCommentThreadShow(req)
{
	var r = req.responseText;
	if(r == "0")
	{
		return;
	}
	
	h('threaddiv_'+r);
}


