var g_curcommentpagesize = 100;
//var oSize = document.getElementById("pagesize");
//if(oSize){g_curcommentpagesize = oSize.value;}

comment = {
	pagesize : 20,
	
	hiddeninput : function(rid){
		var o = document.getElementById('firstcomment'+rid);
		var obj = document.getElementById('commentdiv'+rid);
			o.style.display =  '';
			obj.style.display = 'none';
	},
	//获取全部列表//
	getlist : function(pageid, bloading, rid, commentid)
	{
		var loadid = "";
		if (bloading)
			loadid = "commentall"+rid;
		var sUrl="/comment.php";
		
		var paras = comment.makegetparam(pageid,rid);
		var univAjax = new Ajax.Request(
	    sUrl,
	    {    
	        method: 	'get',
	        //onCreate:   commentpublic.loading(loadid),
	        parameters: paras,
	        onComplete: function(originalRequest){comment.setlist(originalRequest,pageid,bloading,rid, commentid)}
			}
		);
	},

	//获取最新两条//
	gettwo : function(pageid,bloading,rid)
	{
		var loadid = "";
		if (bloading)
		{
			loadid = "commentall"+rid;
		}
		var sUrl="/yqfeed/index.php";
		var paras = comment.makegetparam(pageid,rid);
		
		var univAjax = new Ajax.Request(sUrl,
                                	    {
                                	        method:	'get',
                                	        //onCreate:   commentpublic.loading(loadid),
                                	        parameters: paras,
                                	        onComplete: function(originalRequest){comment.setlist(originalRequest,pageid,bloading,rid)}
                                		}
                                       );
	},
	setlist : function(originalRequest,pageid,bloading,rid,commentid)
	{
		//commentpublic.destroyWnd(); //补丁
		var sHtml = originalRequest.responseText;
		document.getElementById("commentall"+rid).innerHTML = sHtml;
		//翻页
		var nTotal = document.getElementById("commenttotalcnt"+rid).value;
		sHtml = commentpublic.writeTurnPageHtml(pageid,nTotal,g_curcommentpagesize,rid);
		var oPagecontent=document.getElementById("pagecontent"+rid);
		if(oPagecontent)
		{
			oPagecontent.innerHTML = sHtml;
			oPagecontent.style.display = "";
		}
		
		var nRTotal = document.getElementById("commentrealtotalcnt"+rid).value;		
		var oRTotal=document.getElementById("realtotalcnt"+rid);
		nRTotal = nRTotal ==""?0:nRTotal;
		if(oRTotal) oRTotal.innerHTML = nRTotal;
		//当前页
		document.getElementById("commentpageid"+rid).value = pageid;
		if(bloading){
			var surl = window.location.hash;
			if(surl.length > 0){
				var id = surl.replace("#","");
				var oId = document.getElementById(id);
				if(oId){
					var oInfo = commentpublic.getInfo(oId);
					window.scrollTo(oInfo.left,oInfo.top);
				}
			}
		}
		if(commentid)
		{
			var oId = document.getElementById(commentid);
			if(oId){				
				var oParent = document.getElementById("commentall");
				var oInfo 	= commentpublic.getInfo(oId, oParent);	
				oParent.scrollTop = oInfo.top - 66*4;
				var nParentTop = oParent.scrollTop;
			}
		}
		//滚动条高度
		if($('idslider'))
		{
			var nHeight = parseInt($('commentall'+rid).style.height)-30;
			$('idslider').style.height = nHeight + "px";
			if(yqread.sld == null)
			{
				yqread.initSlider();
			}	
			else
			{
				yqread.changeSliderHeight();
				var nSliderHieght = $("commentall").scrollHeight - $("commentall").clientHeight;
				if(typeof(commentid) != 'undefined')
					yqread.sld.SetPercent(nParentTop/nSliderHieght);
			}
		}
	},
	makegetparam : function(pageid,rid)
	{
		var aParam = new Array();
		var aValue = new Array();
		if(rid!=""){
			aParam.push("rid");aValue.push(document.getElementById("commentprimaryid"+rid).value);
		}
		var tplName = document.getElementById("commenttplname");
		if(tplName){
			aParam.push("commenttplname");aValue.push(document.getElementById("commenttplname").value);	
		}
		aParam.push("tab");aValue.push("getcomment");
		aParam.push("cpv");aValue.push(document.getElementById("commentprimaryid"+rid).value);
		aParam.push("curl");aValue.push(document.getElementById("commenturl"+rid).value);
		aParam.push("ctype");aValue.push(document.getElementById("commentType"+rid).value);
		aParam.push("commentprimaryuid");aValue.push(document.getElementById("commentprimaryuid"+rid).value);
		aParam.push("pg");aValue.push(pageid);
		aParam.push("candel");aValue.push(document.getElementById("candel"+rid).value);
		aParam.push("canpublish");aValue.push(document.getElementById("canpublish"+rid).value);
		aParam.push("pagesize");aValue.push(g_curcommentpagesize);
		return commentpublic.makeSendData(aParam,aValue);
	},
	
	//发表
	//is_all_comment 新加用于判断调哪一个刷新函数
	insert : function(rid,nType,shareWord)
	{
		if(typeof(rid) == "undefined")
			rid = ""; //留言
		if(typeof(nType) == "undefined")
			nType = 0; //留言
		var is_all_comment;
		is_all_comment=document.getElementById("is_all_comment"+rid).value

		var sValue = "";
		if(nType == 2 && document.getElementById("commentType"+rid).value > 9){
			sValue = document.getElementById("commentcontentreply"+rid).value;
		}
		else{
			
			if( nType == 1)
			{
				document.getElementById('commenbyreplayuserid'+rid).value="";
				document.getElementById('commenbyreplayusername'+rid).value="";
				document.getElementById('commenbyreplayuserheadurl'+rid).value="";
				document.getElementById('commentid'+rid).value = "";
			}
			if(shareWord && shareWord != '')
				sValue = shareWord;
			else
				sValue = document.getElementById("commentcontent"+rid).value;
		}
		if(commentpublic.trim(sValue).length <= 0)
		{
			comment.createtip("请您输入内容！");
			return false;
		}
			
		var pageid = document.getElementById("commentpageid"+rid).value;
		var sUrl="/comment.php";
		var paras = comment.makeinsertparam(rid,nType,sValue);
		var univAjax = new Ajax.Request(
	    sUrl,
	    {    
	        method: 	'post',
	        onCreate:   comment.createtip(),
	        parameters: paras,
	        onComplete: function(originalRequest){comment.setinsert(originalRequest,pageid,rid,is_all_comment)}
			}
		);
	},
	makeinsertparam : function(rid,nType,sValue)
	{
		var aParam = new Array();
		var aValue = new Array();
		aParam.push("tab");aValue.push("publishcomment");
		aParam.push("commentType");aValue.push(document.getElementById("commentType"+rid).value);
		aParam.push("commentprimaryid");aValue.push(document.getElementById("commentprimaryid"+rid).value);
		aParam.push("commentprimaryuid");aValue.push(document.getElementById("commentprimaryuid"+rid).value);
		aParam.push("commentprimaryuname");aValue.push(document.getElementById("commentprimaryuname"+rid).value);
		
		if(rid!=""){
			aParam.push("homeid");aValue.push(document.getElementById("homeid"+rid).value);
			aParam.push("homename");aValue.push(document.getElementById("homename"+rid).value);
		}
		aParam.push("commenbyreplayuserid");aValue.push(document.getElementById("commenbyreplayuserid"+rid).value);
		aParam.push("commenbyreplayusername");aValue.push(document.getElementById("commenbyreplayusername"+rid).value);
		aParam.push("commenbyreplayuserheadurl");aValue.push(document.getElementById("commenbyreplayuserheadurl"+rid).value);
		if(document.getElementById('commenbyreplayuseremail'+rid))
		{
			aParam.push("commenbyreplayuseremail");
			aValue.push(document.getElementById('commenbyreplayuseremail'+rid).value);
		}
		
		aParam.push("gid");aValue.push(document.getElementById("gid"+rid).value);
		aParam.push("gname");aValue.push(document.getElementById("gname"+rid).value);
		aParam.push("gpid");aValue.push(document.getElementById("gpid"+rid).value);
		
		aParam.push("eid");aValue.push(document.getElementById("eid"+rid).value);
		aParam.push("ename");aValue.push(document.getElementById("ename"+rid).value);
		aParam.push("epid");aValue.push(document.getElementById("epid"+rid).value);
		
		aParam.push("repastelid");aValue.push(document.getElementById("repastelid"+rid).value);
		
		aParam.push("commenturl");aValue.push(document.getElementById("commenturl"+rid).value);
		aParam.push("commentid");aValue.push(document.getElementById("commentid"+rid).value);
		
		if(document.getElementById("barid") && document.getElementById("bname"+rid))
		{
			aParam.push("barid");aValue.push(document.getElementById("barid"+rid).value);
			aParam.push("bname");aValue.push(document.getElementById("bname"+rid).value);
		}
		
		if(nType == 2 && document.getElementById("commentType"+rid).value > 9){
			aParam.push("commentcontent");
			aValue.push(document.getElementById("commentcontentreply"+rid).value);
			//匿名评论的名字
			var oName = document.getElementById("anonymity_uname_reply");
			if(oName)
			{
				aParam.push("anonymity_uname");
				aValue.push(oName.value);
			}
		}
		else{
			aParam.push("commentcontent");
			if(sValue && sValue !="")
				aValue.push(sValue);	
			else
				aValue.push(document.getElementById("commentcontent"+rid).value);
			//匿名评论的名字
			var oName = document.getElementById("anonymity_uname");
			if(oName)
			{
				aParam.push("anonymity_uname");
				aValue.push(oName.value);
			}
		}
		
		var oEmail = document.getElementById("anonymity_uemail");
		if(oEmail)
		{
			aParam.push("anonymity_uemail");
			aValue.push(oEmail.value);
		}
		return commentpublic.makeSendData(aParam,aValue);
	},
	setinsert : function(originalRequest,pageid,rid,is_all_comment)
	{
		var ret  = parseInt(originalRequest.responseText);
		var stip = "发表成功！";
		if(ret == -100){
			stip = "您还未登录！";
		}
		else if(ret < 0){
			stip = "抱歉，出错了！";
		}
		else
		{
			if(rid==""){
				var orealcnt = document.getElementById("realtotalcnt");
				if(orealcnt)
					orealcnt.innerHTML = parseInt(orealcnt.innerHTML) + 1;
			}
			else{
				var commenttotal = document.getElementById("commenttotal"+rid);
				var totals=parseInt(commenttotal.innerHTML) +1;
				commenttotal.innerHTML = totals;
				comment.hiddeninput(rid);
			}
			document.getElementById("commentcontent"+rid).value = "";
			if(is_all_comment=='no')
				comment.gettwo(1,true,rid);
			else
				comment.getlist(1,true,rid, originalRequest.responseText);
			//iframe 页面评论单独加的
			if(document.getElementById('yqreadcomment'))
			{
				document.getElementById('yqreadcomment').style.display = "none";
				var oFrame = $('rightframe');
				oFrame.style.display = 'none';
			}
		}
		comment.createtip(stip);
	},
	//删除
	del : function(commentid, replyid, breply,rid,is_all_comment, ev)
	{
		ev = ev || window.event;
		if(ev)		
			ev.cancelBubble = true;
		var selid = window.confirm("确定要删除该条数据吗？");
		if(!selid)
		{
			return;
		}
		document.getElementById('commentid'+rid).value=commentid;
		if(breply)
			document.getElementById('replyid'+rid).value=replyid;
		var pageid = document.getElementById("commentpageid"+rid).value;
		var sUrl="/comment.php";
		var paras = comment.makedelparam(rid);
		var univAjax = new Ajax.Request(
	    sUrl,
	    {    
	        method: 'get',
	        onCreate:   comment.createtip(),
	        parameters: paras,
	        onComplete: function(originalRequest){comment.setdel(originalRequest,commentid, replyid, breply,rid,is_all_comment)}
			}
		);
	},
	makedelparam : function(rid)
	{	
		var aParam = new Array();
		var aValue = new Array();
		aParam.push("tab");aValue.push("delcomment");
		aParam.push("commentType");aValue.push(document.getElementById("commentType"+rid).value);
		aParam.push("commentprimaryid");aValue.push(document.getElementById("commentprimaryid"+rid).value);
		aParam.push("commentprimaryuid");aValue.push(document.getElementById("commentprimaryuid"+rid).value);
		
		aParam.push("commenturl");aValue.push(document.getElementById("commenturl"+rid).value);
		aParam.push("commentid");aValue.push(document.getElementById("commentid"+rid).value);
		aParam.push("replyid");aValue.push(document.getElementById("replyid"+rid).value);
		
		return commentpublic.makeSendData(aParam,aValue);
	},
	setdel : function(originalRequest,commentid, replyid, breply,rid,is_all_comment)
	{
		var pageid = document.getElementById("commentpageid"+rid).value;
		var nTotal = parseInt(document.getElementById("commenttotalcnt"+rid).value) -1;
		var pagecnt = parseInt(nTotal/g_curcommentpagesize);
		if(nTotal%g_curcommentpagesize > 0)
			pagecnt ++;
		if(pagecnt < pageid)
		{
			pageid = pagecnt;
			document.getElementById("commentpageid"+rid).value = pageid;
		}
		var ret  = originalRequest.responseText;
		var stip = "删除成功！";
		if(parseInt(ret) < 0){
			stip = "抱歉，出错了！";
		}
		else{	
			if(rid==""){	
				var orealcnt = document.getElementById("realtotalcnt");
				if(orealcnt) orealcnt.innerHTML = parseInt(orealcnt.innerHTML) + 1;
			}else{
				var commenttotal = document.getElementById("commenttotal"+rid);
				 	commenttotal.innerHTML=parseInt(commenttotal.innerHTML) - 1
			}
		}
		//tip
		comment.createtip(stip);
		if(is_all_comment=="no")
			comment.gettwo(pageid,true,rid);	
		else
			comment.getlist(pageid,true,rid);
		comment.hiddenViewComment();	
	},
	//回复
	//
	gettextarea : function(obj)
	{
		var oArea = obj.firstChild;
		while(oArea)
		{
			if(oArea.nodeName == "TEXTAREA")
				break;
			else
				oArea = oArea.nextSibling;
		}
		return oArea;
	},
	makepublishobj : function(rid)
	{
		var oTmpReply = null;
		var oReply=document.getElementById("commentreplydivbak"+rid);
		if(oReply)
		{
			oTmpReply = document.getElementById("commentreplydiv"+rid);
			if(oTmpReply == null)
			{//无，则新创建一个
				oTmpReply = document.createElement("div");
				if(oTmpReply)
				{
					oTmpReply.id = "commentreplydiv"+rid;
					oTmpReply.innerHTML = oReply.innerHTML;
					var oArea = comment.gettextarea(oTmpReply);
					oArea.id   =  "commentcontentreply"+rid;
					oArea.name =  "commentcontent";
				}
			}
		}
		return oTmpReply;
	},
	setleaveword : function(pid,username,userid,userheadurl,rid)
	{
		document.getElementById('commentdiv'+rid).style.display='';
		var oComment = document.getElementById('commentcontent'+rid);
		oComment.focus();
		oComment.value='回复'+username + '：';
		
		//被回复的数据id
		document.getElementById('commentid'+rid).value=pid;
		//被回复的用户
		document.getElementById('commenbyreplayuserid'+rid).value=userid;
		document.getElementById('commenbyreplayusername'+rid).value=username;
		document.getElementById('commenbyreplayuserheadurl'+rid).value=userheadurl;
	},
	setreply : function(commentid, pid, username,userid,userheadurl,rid,useremail)
	{
		var parentid = "parent_" + commentid;
		var type = document.getElementById("commentType"+rid).value;
		if(type > 9)
		{
			var oParent=document.getElementById(parentid);
			if(oParent)
			{
				var oTmpReply = comment.makepublishobj(rid);
				if(oTmpReply)
				{
					//被回复的数据id
					document.getElementById('commentid'+rid).value=pid;
					//被回复的用户
					document.getElementById('commenbyreplayuserid'+rid).value=userid;
					document.getElementById('commenbyreplayuserid'+rid).value=userid;
					document.getElementById('commenbyreplayusername'+rid).value=username;
					document.getElementById('commenbyreplayuserheadurl'+rid).value=userheadurl;
					if(document.getElementById('commenbyreplayuseremail'+rid))
						document.getElementById('commenbyreplayuseremail'+rid).value=useremail;
					var obj = document.getElementById('replyarea');	
					if(type == 27 && obj)
					{
						obj.appendChild(oTmpReply);
						comment.setViewComment(commentid);
					}
					else
						oParent.appendChild(oTmpReply);
					var oBtn= document.getElementById('btninert'+rid);
					if(oBtn){
						oBtn.onclick = function(){comment.insert(rid,2)};
					}
					oTmpReply.style.display = "";
					document.getElementById('commentcontentreply'+rid).focus();
					document.getElementById('commentcontentreply'+rid).value = '回复'+username+"：";
					
				}
			}
		}
		else
		{
			comment.setleaveword(pid,username,userid,userheadurl,rid);
		}
	},
	cancelreply : function(rid)
	{
		if(typeof(rid) == "undefined") rid = ""; 
		document.getElementById('commentreplydiv'+rid).style.display='none';
		document.getElementById('commentcontentreply'+rid).value='';
		document.getElementById('commentid'+rid).value = '';
		document.getElementById('commentcontentreply'+rid).value='';
		document.getElementById('commenbyreplayuserid'+rid).value="";
		document.getElementById('commenbyreplayusername'+rid).value="";
		document.getElementById('commenbyreplayuserheadurl'+rid).value="";
		
		if(document.all) window.event.cancelBubble=true; 
	},
	//编辑
	seteditarea : function(commentid,rid)
	{
		var parentid = "parent_" + commentid;
		var editid   = "content_" + commentid; 
		var oParent=document.getElementById(parentid);
		if(oParent)
		{
			var oTmpReply = comment.makepublishobj(rid);
			if(oTmpReply)
			{
				var type = document.getElementById("commentType"+rid).value;
				var obj = document.getElementById('replyarea');
				if(type == 27 && obj)
				{
					obj.appendChild(oTmpReply);
					comment.setViewComment(commentid);
					editid   = "bak_content_" + commentid; 
				}
				else
				{
					oParent.appendChild(oTmpReply);
				}
		
				oTmpReply.style.display = "";
				var oEdit = document.getElementById(editid);
				if(oEdit)
				{//编辑
					var sText = oEdit.innerHTML;
					sText = unBar_rsm(sText);
					var objcomment = document.getElementById('commentcontentreply'+rid) ;
					objcomment.value = sText;
					if(type != 27)
						comment.fixup_textarea_row(objcomment);
					//被编辑的数据id
					if(typeof(commentid)!='undefined')
						document.getElementById('commentid'+rid).value=commentid;
					var oBtn= document.getElementById('btninert'+rid);
					if(oBtn)
					{
						oBtn.onclick = function(){comment.edit(rid,commentid)};
					}
				}
			}
		}
	},
	edit: function(rid,commentid)
	{
		var sValue = document.getElementById("commentcontentreply"+rid).value;
		if(commentpublic.trim(sValue).length <= 0)
		{
			comment.createtip("请您输入内容！");
			return false;
		}
		var sUrl="/comment.php";
		var paras = comment.makeeditparam(rid,commentid);
		
		var univAjax = new Ajax.Request(
	    sUrl,
	    {
	        method: 'post',
	        onCreate:    comment.createtip(),
	        parameters: paras,
	        onComplete: function(originalRequest){comment.setedit(originalRequest,rid,commentid)}
			}
		);
	},
	makeeditparam:function(rid,commentid)
	{
		var aParam = new Array();
		var aValue = new Array();
		aParam.push("tab");aValue.push("editcomment");
		aParam.push("commentType");aValue.push(document.getElementById("commentType"+rid).value);
		aParam.push("commentprimaryid");aValue.push(document.getElementById("commentprimaryid"+rid).value);
		aParam.push("commentprimaryuid");aValue.push(document.getElementById("commentprimaryuid"+rid).value);
		
		aParam.push("commenturl");aValue.push(document.getElementById("commenturl"+rid).value);
		aParam.push("commentid");aValue.push(commentid);
		aParam.push("replyid");aValue.push(document.getElementById("replyid"+rid).value);
		aParam.push("commentcontent");aValue.push(document.getElementById("commentcontentreply"+rid).value);
		
		return commentpublic.makeSendData(aParam,aValue);
	},
	setedit: function(originalRequest,rid,commentid)
	{
		var ret  = originalRequest.responseText;
		var stip = "编辑成功！";
		if(parseInt(ret) < 0){
			stip = "抱歉，出错了！";
		}
		else{
			var oContent = document.getElementById('commentcontentreply'+rid);
			if(oContent)
			{
				var oEdit = document.getElementById('content_'+commentid);
				var oBakEdit = document.getElementById('bak_content_'+commentid);
				var extText = saveCall(oContent.value);
					oEdit.innerHTML = extText ;
				if(oBakEdit)
					oBakEdit.innerHTML = extText;
				oContent.value = "";
				var oArea = document.getElementById('commentreplydiv'+rid);
				if(oArea)
					oArea.style.display = "none";
				//iframe 页面评论单独加的
				if(document.getElementById('yqreadcomment'))
				{
					document.getElementById('yqreadcomment').style.display = "none";
					var oFrame = $('rightframe');
					oFrame.style.display = 'none';
				}
			}
		}
		document.getElementById("commentid"+rid).value = "";
		//tip
		comment.createtip(stip);
	},
	createtip : function(sHtml)
	{
		commentpublic.destroyWnd();
		if(typeof(sHtml) == 'undefined')
			sHtml = "loading...";
		var oTip = document.getElementById("commenttip");
		var oTipInfo = document.getElementById("commenttipinfo");
		if(oTip && oTipInfo)
		{
			oTipInfo.innerHTML = sHtml;
			var aRe = new Array(150, 50);
			commentpublic.showWnd("commenttip",aRe);
			comment.destroytip();
		}
	},
	destroytip : function()
	{
		setTimeout(commentpublic.destroyWnd, 1000);
	},
	fixup_textarea_row :function(obj) {
	
	        var setHeight = obj.scrollHeight >30 ? obj.scrollHeight : 30 ;
	        obj.style.height=setHeight+'px';
	},
	setViewComment : function (commentid)
	{
		//姓名
		var oUnameView = document.getElementById('uname_view');
		var oUname = document.getElementById('uname_' + commentid);
		if(oUnameView && oUname)
		{
			oUnameView.innerHTML = oUname.innerHTML;
		}
		//头像
		var oUheadurlView = document.getElementById('uheadurl_view');
		var oUheadurl = document.getElementById('uheadurl_' + commentid);
		if(oUheadurlView && oUheadurl)
		{
			oUheadurlView.innerHTML = oUheadurl.innerHTML;
		}
		//内容
		var oContentView = document.getElementById('content_view');
		var oContent = document.getElementById('bak_content_' + commentid);
		if(oContentView && oContent)
		{
			oContentView.innerHTML = oContent.innerHTML;
		}
		var oView = document.getElementById('yqreadcomment');
		if(oView)
		{
			oView.style.display = '';
			var oFrame = $('rightframe');
			oFrame.style.width   = oView.offsetWidth + "px";
			oFrame.style.height  = (oView.offsetHeight-50) + "px";
			oFrame.style.top     = (oView.offsetTop+4) + "px";
			oFrame.style.right   = oView.style.right;
			oFrame.style.zIndex  = oView.style.zIndex - 1;
			oFrame.style.display = "block";
			oFrame.style.position = "absolute";
			oFrame.style.display = '';
		}
	},
	hiddenViewComment : function ()
	{
		var oYqRead = document.getElementById('yqreadcomment');
		if(oYqRead)
		{
			oYqRead.style.display = 'none';
			var oFrame = $('rightframe');
			oFrame.style.display = 'none';
		}
	}
};
commentpublic = {
	loading : function(id)
	{
		var oId = document.getElementById(id);
		if(oId)
		{
			oId.innerHTML= "<table width='100%'><tr><td align='center'>正在加载中......</td></tr></table>";
		}
	},
	getInfo : function(o, oParent)
	{
		oParent = oParent ||  document.body;
        var to = new Object();
        to.left = to.right = to.top = to.bottom = 0;
        var twidth  = o.offsetWidth;
        var theight = o.offsetHeight;
        while(o && o!=oParent){
                to.left+=o.offsetLeft;
                to.top+=o.offsetTop;
                o=o.offsetParent;
        }
        to.right=to.left+twidth;
        to.bottom=to.top+theight;
        return to;
	},
	makeSendData : function (aParam,aValue)
	{
	    var sendData = "";
	    var nLen = aParam.length;
	    for(var i = 0; i < nLen - 1; i++)
	    {
	        sendData += aParam[i] + "=" + encodeURIComponent(aValue[i]) + "&";
	    }
	    sendData += aParam[nLen -1] + "=" + encodeURIComponent(aValue[nLen -1]);
	    return sendData;
	},
	//数据翻页
	writeTurnPageHtml: function (nPageId, nTotalSize, nPageSize,rid)
	{
		nPageId = parseInt(nPageId);
		nTotalSize = parseInt(nTotalSize);
		nPageSize = parseInt(nPageSize);
		var sPage = "";
		if(nTotalSize <= 1 || nTotalSize<= nPageSize){
	        return sPage;
		}
	    var nPageCnt = parseInt(nTotalSize/nPageSize + 0.999999);
		if(nPageId > 1)
		{
			sPage += "&nbsp;<a href=\"javascript:void(0);\" onclick=\"comment.getlist("+ (nPageId -1)+ ",true,'"+rid+"')\">上一页</a>&nbsp;";
		}
		else
		{
			sPage += "<a>上一页</a>&nbsp;";
		}
		var nSpan = 5;
		var nOffset = 0;
		var nLeft = nPageId - nSpan;
		if(nLeft < 0)
		{
			nOffset = (-1) * nLeft;
			nLeft = 0;
		}
		var nRight = nPageId + nSpan + nOffset;
		if(nRight > nPageCnt)
		{
			nOffset = nRight - nPageCnt;
			nRight = nPageCnt;
		}
		nLeft -= nOffset;
		if(nLeft < 0)
			nLeft = 0;
		for(var i = nLeft; i < nRight; i++)
		{
			if(nPageId == i+1)
			{
				sPage += "&nbsp;" + (i+1) + "&nbsp;";
			}
			else
			{
				sPage += "&nbsp;<a href=\"javascript:void(0);\" onclick=\"comment.getlist("+(i+1)+",true,'"+rid+"')\">" + (i+1) + "</a>&nbsp;";
			}
		}
		if(nPageId < nPageCnt)
		{
			sPage += "&nbsp;<a href=\"javascript:void(0);\" onclick=\"comment.getlist("+ (nPageId +1)+ ",true,'"+rid+"')\">下一页</a>&nbsp;";
		}
		else
		{
			sPage += "&nbsp;<a>下一页</a>&nbsp;";
		}
		
		return sPage;
	},
	destroyWnd : function()
	{
		var oWnd = document.getElementById("setWin");
		if(oWnd)
		{
			oWnd.parentNode.removeChild(oWnd);
		}
		var oId = document.getElementById("yqreadcommentarea");
		if(oId)
		{
			oId.style.position = '';
		}
	},
	showWnd : function(id,aRegion)
	{
		var oId = document.getElementById("yqreadcommentarea");
		if(oId)
			this.createWndById(aRegion, oId);
		else
			this.createWnd(aRegion);
		if(id.length > 0)
		{
			var oDiv = document.getElementById(id);
			var oWnd = document.getElementById("setWin");
			if(oDiv && oWnd)
			{
				oWnd.innerHTML = oDiv.innerHTML;
			}
		}
		else
		{
			var oWnd = document.getElementById("setWin");
			if(oWnd)
				oWnd.innerHTML = "<table align=\"center\"><tr><td>loading</td></tr></table>";
		}
	},
	
	createWndById : function (aRegion, objBody)
	{
		var objSetWin = document.getElementById("setWin");
		if(objSetWin == null)
		{
		    objSetWin = document.createElement("div");
		    objSetWin.setAttribute('id','setWin');
		    objBody.insertBefore(objSetWin, objBody.firstChild);
		}
		objBody.style.position = 'relative';
		objSetWin.style.display = '';
		objSetWin.style.position = 'absolute';
		objSetWin.style.zIndex = '100';
		var nWndWidth = aRegion ? aRegion[0] : 600;
		var nWndHeight = aRegion ? aRegion[1] : arrayPageSize[3];
		
		objSetWin.style.top = (objBody.offsetHeight/2 - 50)+"px";
		objSetWin.style.left = objBody.offsetWidth/2+"px";
		objSetWin.style.height = (nWndHeight-20)+"px";
		objSetWin.style.width = (nWndWidth -2)+"px";
	},
	//private:
	createWnd : function (aRegion)
	{
		var arrayPageSize = this.getPageSize();
		var arrayPageScroll = this.getPageScroll();
		var lightboxTop = arrayPageScroll[1]+10;
		var lightboxLeft =(arrayPageSize[0]-20)/2;
		var objBody = document.getElementsByTagName("body").item(0);
		var objSetWin = document.getElementById("setWin");
		if(objSetWin == null)
		{
		    objSetWin = document.createElement("div");
		    objSetWin.setAttribute('id','setWin');
		    objBody.insertBefore(objSetWin, objBody.firstChild);
		}
		objSetWin.style.display = '';
		objSetWin.style.position = 'absolute';
		objSetWin.style.zIndex = '100';		
		var nWndWidth = aRegion ? aRegion[0] : 600;
		var nWndHeight = aRegion ? aRegion[1] : arrayPageSize[3];
		
		objSetWin.style.top = (lightboxTop+(arrayPageSize[3]-nWndHeight)/2)+"px";
		objSetWin.style.left = (lightboxLeft-nWndWidth/2)+"px";
		objSetWin.style.height = (nWndHeight-20)+"px";
		objSetWin.style.width = (nWndWidth -2)+"px";
	},
	getPageScroll : function() {
		var yScroll;
		if(self.pageYOffset) {
			yScroll = self.pageYOffset;
		}	else if(document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		}	else if(document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
		arrayPageScroll = new Array('',yScroll);
		return arrayPageScroll;
	},
	getPageSize : function() {
		var xScroll, yScroll;
		if(window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if(document.body.scrollHeight > document.body.offsetHeight){// all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if(self.innerHeight) {	// all except Explorer
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if(document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if(document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		// for small pages with total height less then height of the viewport
		pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
		// for small pages with total width less then width of the viewport
		pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	},
	isFF : function()
	{
		return navigator.userAgent.indexOf("Firefox") != -1;
	},
	isOpera : function()
	{
		return navigator.userAgent.indexOf("Opera") != -1;
	},
	trim : function(s)
	{
		return s.replace(/(^\s*)|(\s*$)/g,"");
	}
};