// JavaScript Document
var t = new Ext.Template([
	'<div class="s_list_Comment_LI" id="s_list_Comment_LI_{comment_id}">',
	'<div class="s_list_Comment_img"><img src="/content/jj0595com/199/images/loginImg.gif"></div>',
	'<div class="s_list_Comment_from">{comment_from}</a></div>',
	'<div class="s_list_Comment_content">{comment_content}</div>',
	'<div class="s_list_Comment_time">{comment_time}</div>',
	'<div class="s_list_Comment_fun"><span style="display:none;">支持({comment_support}) 反对({comment_opposed}) | </span><span class="s_list_Comment_replyBtn" onclick="s_list_Comment_LI_reply_showreplayformFun({comment_id},\'{comment_path}\')" style="cursor:pointer;">回复</span></div>',
	'<div class="s_list_Comment_replyA" id="s_list_Comment_reply_{comment_id}"></div>',
	'</div>'
]);
var tboy = new Ext.Template([
	'<div class="s_list_Comment_LI_Boy ca_5 s_list_Comment_LI_Boy_{comment_mod2}" id="s_list_Comment_LI_{comment_id}">',
	'<div class="s_list_Comment_img"><img src="/content/jj0595com/199/images/loginImg.gif"></div>',
	'<div class="s_list_Comment_from">{comment_from}</a></div>',
	'<div class="s_list_Comment_content">{comment_content}</div>',
	'<div class="s_list_Comment_time">{comment_time}</div>',
	'<div class="s_list_Comment_fun"><span style="display:none;">支持({comment_support}) 反对({comment_opposed}) | </span><span class="s_list_Comment_replyBtn" onclick="s_list_Comment_LI_reply_showreplayformFun({comment_id},\'{comment_path}\')" style="cursor:pointer;">回复</span></div>',
	'<div class="s_list_Comment_reply" id="s_list_Comment_reply_{comment_id}"></div>',
	'</div>'
]);

var tReply = new Ext.Template([
'<form action="/" method="post" id="asdaRpForm">',
'<input type="hidden" value="commentPage_COMMENT_POSTREPLY" name="action" />',
'<input type="hidden" value="" name="comment_path" id="comment_path" />',
'<input type="hidden" value="" name="comment_fid" id="comment_fid" />',
'<input type="hidden" value="" name="comment_target" id="comment_target" />',
'<input type="hidden" value="" name="cid" id="cid" />',
'<input type="hidden" value="您的评论提交成功." name="alert" />',
'<input type="hidden" value="" name="Redirect" id="Redirect" />',
'<input type="hidden" value="comment_posterName:您的姓名,comment_content:留言内容" name="must" />',
'<div style="position:relative; left:70px; top:0;" class="s_list_Comment_LI_replyContent" id="s_list_Comment_LI_replyContent_{comment_id}">',
'	<table width="100%" border="0" cellspacing="4" cellpadding="0">',
'	  <tr>',
'		<td width="80" height="20" align="right" valign="middle">称　　呼:</td>',
'		<td><input type="textfield" class="XD-inputText" id="comment_posterName" name="comment_posterName" /></td>',
'		<td>&nbsp;</td>',
'	  </tr>',
'	  <tr>',
'		<td height="20" align="right" valign="middle">联系方式:</td>',
'		<td><input type="textfield" class="XD-inputText" id="comment_posterTel" name="comment_posterTel" /></td>',
'		<td>&nbsp;</td>',
'	  </tr>',
'	  <tr>',
'		<td height="20" align="right" valign="top">内容:</td>',
'		<td><textarea class="XD-inputText" style="width:70%; height:100px;" id="comment_content" name="comment_content"></textarea></td>',
'		<td>&nbsp;</td>',
'	  </tr>',
'	  <tr>',
'		<td height="20" align="right" valign="middle">&nbsp;</td>',
'		<td><input type="button" value="发表" id="S_CommentForm_LI_submitBtn" class="XD-inputText" /><input type="button" value="取消" id="S_CommentForm_submitBtn" class="XD-inputText" onclick="s_list_Comment_LI_reply_cancelFun({comment_id})" /></td>',
'		<td>&nbsp;</td>',
'	  </tr>',
'	  <tr>',
'		<td height="20" align="right" valign="middle">&nbsp;</td>',
'		<td>&nbsp;</td>',
'		<td>&nbsp;</td>',
'	  </tr>',
'	</table>',
'</div></form>'
]);

Ext.select('.s_list_Comment_LII').each(function(i,c,idx){
	eval("var o = "+i.getValue())
	if(o.length == 0){
		i.parent("div").remove()
	}
	
	for(var j = 0;j<o.length;j++){
		try{
		var OJ =o[j]
		//OJ.comment_content = OJ.comment_content.split('"content\": \"')[1].split('\"}]')[0]
		if(OJ.comment_pathLen % 2 == 0){
			OJ.comment_mod2 = "mod2"
		}else{
			OJ.comment_mod2 = ""
		}
		if(OJ.comment_from == ""){
			OJ.comment_from = "<b>晋江房产网网友</b> (ip:"+OJ.comment_ip+")"
		}else{
			if(OJ.comment_posterID == 0 ){
				OJ.comment_from = "<b>"+OJ.comment_from+"</b> (ip:"+OJ.comment_ip+")"
			}else{
				OJ.comment_from = '<a href="/?uid='+OJ.comment_posterID+'" target="_blank"><b>'+OJ.comment_from+'</b></a> (ip:'+OJ.comment_ip+')'
			}
		}
		if(j==0){
			o[j].comment_content = o[j].comment_content.replace(/\r\n/gi,"<br />")
			t.overwrite(i.parent("div"),o[j])
		}else{
			try{
			if(OJ.comment_content == null)OJ.comment_content="该信息存储错误或已被删除";
			OJ.comment_content = OJ.comment_content.replace(/\r\n/gi,"<br />")
			tboy.append(Ext.fly("s_list_Comment_reply_"+OJ.comment_fid),OJ)
			}catch(e){
				//comment_fid 错误的话可能会有问题,直接忽略错误
			}
		}
		}catch(e){
			
		}
	}

	
})
function s_list_Comment_LI_reply_showreplayformFun(id,path){
	Ext.select('.s_list_Comment_LI_replyContent').each(function(i,c,idx){
		Ext.fly('s_list_Comment_LI_'+i.id.replace("s_list_Comment_LI_replyContent_","")).removeClass('s_list_Comment_LI_Light')
		i.remove()
	})
	tReply.insertFirst(Ext.fly("s_list_Comment_reply_"+id),{comment_id:id})
	Ext.fly('s_list_Comment_LI_'+id).addClass('s_list_Comment_LI_Light')
	if(session_user_realName != ''){
		Ext.get('comment_posterName').set({value:session_user_realName})
	}
	if(session_user_tel != ''){
		Ext.get('comment_posterTel').set({value:session_user_tel})
	}
	var S_CommentForm_LI_submitBtn = Ext.fly('S_CommentForm_LI_submitBtn')
	S_CommentForm_LI_submitBtn.on("click",S_CommentForm_LI_submitBtnSubmit)
	S_CommentForm_LI_submitBtn.set({'path':path,"fid":id})
	//结束回复
}
function S_CommentForm_LI_submitBtnSubmit(){
	var owner =this;
	if(Ext.get('comment_content').getValue().length <5){
		alert("您的回复太短了");
		return
	}
	if(Ext.get('comment_posterName').getValue().length <=0){
		alert("请填写您的称呼");
		return
	}
	Ext.get('comment_path').set({value:this.getAttribute("path")})
	Ext.get('comment_fid').set({value:this.getAttribute("fid")})
	Ext.get('comment_target').set({value:requestQueryString_tid})
	Ext.get('cid').set({value:requestQueryString_cid})
	Ext.get('Redirect').set({value:"/read.asp?cid="+requestQueryString_cid+"&tid="+requestQueryString_tid})
	document.getElementById("asdaRpForm").submit()
	//发表
	/*var postObject = {}
	postObject.comment_path = this.getAttribute("path");
	postObject.comment_fid = this.getAttribute("fid");
	postObject.cid = requestQueryString_cid;
	postObject.comment_target = requestQueryString_tid;
	postObject.comment_content = f_CommentForm_LI_contentValue;
	postObject.comment_posterName = f_CommentForm_LI_LoginNameValue;
	postObject.comment_posterTel = f_CommentForm_LI_posterTelValue;
	this.set({value:"正在发送,请稍候"})
	this.un("click",S_CommentForm_LI_submitBtnSubmit)
	Ext.Ajax.request({
		params:postObject,
		url:'/?action=commentPage_COMMENT_POSTREPLY',
		success:function(r){
			if(r.responseText=="true"){
				window.location.reload()
			}else{
				owner.set({value:"发表"})
				owner.on("click",S_CommentForm_LI_submitBtnSubmit)
			}
		}
	})*/
}
	
function s_list_Comment_LI_reply_cancelFun(id){
	Ext.fly('s_list_Comment_LI_'+id).removeClass('s_list_Comment_LI_Light')
	Ext.fly("s_list_Comment_LI_replyContent_"+id).remove()
}
