

// 显示最新评论
function get_newcommentinfo(DivId, ListNum)
{
	if(nc_userList.length<=0 || nc_conList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();

	for (var i=0,j=0; i<nc_userList.length; i++)
	{
		if(i >= ListNum) break;
		temArray[j++] = "<div class=\"info\"><span>Time:" + nc_timeList[i] + "</span>Name: " + nc_userList[i] + "</div>";
		temArray[j++] = "<div class=\"text\">";
		temArray[j++] = " <p class=\"line\">" + nc_conList[i] + "</p>";
		temArray[j++] = "<p>Article: <a href=\"" + nc_urlList[i] + "\" target=\"_blank\" class=\"font_a\">" + nc_titleList[i] + "</a></p>";
		temArray[j++] = "</div>";

		//temArray[j++] = "<div class=\"userinfo\"> <span  class=\"menu12white\">Name:" + nc_userList[i] + " </span><span  class=\"menu12white paddingnone\">Time:" + nc_timeList[i] + "</span></div>";
		//temArray[j++] = "<div class=\"txt10tg\">" + nc_conList[i] + "</div>";
		//temArray[j++] = "<div class=\"commentinfo\"> <a href=\"" + nc_urlList[i] + "\" target=\"_blank\"  class=\"menu12type\">" + nc_titleList[i] + "</a> </div>";
	}
	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}


// 显示一周内的热门评论
function get_lastweekcommentinfo(DivId, ListNum)
{
	if(lwc_titleList.length<=0 || lwc_connumList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();
	var j = 0;
	var ImgNum = new Array();
         ImgNum[0] = '<img src=http://comment.91.com/images/no_1.gif />';
		 ImgNum[1] = '<img src=http://comment.91.com/images/no_2.gif />';
		 ImgNum[2] = '<img src=http://comment.91.com/images/no_3.gif />';
		 ImgNum[3] = '<img src=http://comment.91.com/images/no_4.gif />';
		 ImgNum[4] = '<img src=http://comment.91.com/images/no_5.gif />';
		 ImgNum[5] = '<img src=http://comment.91.com/images/no_6.gif />';
		 ImgNum[6] = '<img src=http://comment.91.com/images/no_7.gif />';
		 ImgNum[7] = '<img src=http://comment.91.com/images/no_8.gif />';
		 ImgNum[8] = '<img src=http://comment.91.com/images/no_9.gif />';
		 ImgNum[9] = '<img src=http://comment.91.com/images/no_10.gif />';

	var LastNum = new Array();
         LastNum[0] = '1';
		 LastNum[1] = '2';
		 LastNum[2] = '3';
		 LastNum[3] = '4';
		 LastNum[4] = '5';
		 LastNum[5] = '6';
		 LastNum[6] = '7';
		 LastNum[7] = '8';
		 LastNum[8] = '9';
		 LastNum[9] = '10';

	//temArray[j++] = "<table width=\"313\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
	temArray[j++] = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	for (var i=0; i<lwc_titleList.length; i++)
	{
		if(i >= ListNum) break;

		/*temArray[j++] = "  <tr>";
		temArray[j++] = "    <td class=\"comment_info\">" + ImgNum[i] + "<a href=\"" + lwc_urlList[i] + "\" class=\"comment_info\">" + lwc_titleList[i] + "</a> [" + lwc_newstimeList[i] + "]</td>";
		temArray[j++] = "  </tr>";
		temArray[j++] = "  <tr>";
		temArray[j++] = "    <td>coments: " + lwc_connumList[i] + " </td><td class=\"comment_name\"> <a href=\"" + lwc_conurlList[i] + "\" target=\"_blank\" >comment here</a></td>";
		temArray[j++] = "  </tr>";*/
		temArray[j++] = " <div class=\"cont\"  onmouseover=\"this.className='cont_on'\"  onmouseout=\"this.className='cont'\">";
		temArray[j++] = " <ul class=\"num\">"+ LastNum[i] +"</ul>";
		temArray[j++] = " <ul class=\"txt\">";
		temArray[j++] = " <h4>" + "<a href=\"" + lwc_urlList[i] + "\" target=\"_blank\" >" +  lwc_titleList[i] + "</a></h4>";
		temArray[j++] = " <p>Coments: " + lwc_connumList[i] + " </p></ul> ";
		temArray[j++] = " <ul class=\"join\"><a href=\"" + lwc_conurlList[i] + "\" target=\"_blank\" title=\"Join Discussion\"></a></ul> ";
		temArray[j++] = " <div class=\"clear\"></div></div>";


		//temArray[j++] = "  <tr>";
		//temArray[j++] = "    <td valign=\"top\">"+ ImgNum[i] +"</td>";
		//temArray[j++] = "    <td class=\"comment_info\">" + "<a href=\"" + lwc_urlList[i] + "\">" +  lwc_titleList[i] + "</a><br />";
		//temArray[j++] = "     coments: " + lwc_connumList[i] + "</td>";
		//temArray[j++] = "    <td class=\"comment_name\"><a href=\"" + lwc_conurlList[i] + "\" target=\"_blank\">Join&nbsp;comment</a> </td>";
		//temArray[j++] = "  </tr>";
	}
	temArray[j++] = "</table>";

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}


// 显示本周热门评论
function get_currweekcommentinfo(DivId, ListNum)
{
	if(lwc_titleList.length<=0 || lwc_connumList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();
	var j = 0;

	for (var i=0; i<lwc_titleList.length; i++)
	{
		if(i >= ListNum) break;


		temArray[j++] = "<li>";
		temArray[j++] = '<li><a class="title" href="'+ lwc_conurlList[i] +'">'+GetSubStr(lwc_titleList[i], 50, '..') +'</a>';
		temArray[j++] = '<a class="source" href="' + lwc_urlList[i] + '">[查看源文]</a>';
		temArray[j++] = '<span>'+lwc_connumList[i]+'</span></li>';
	}

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}

// 显示一个月内的热门评论
function get_lastmonthcommentinfo(DivId, ListNum)
{
	if(lmc_titleList.length<=0 || lmc_connumList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();
	var j = 0;

	temArray[j++] = "<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"cmsTable\">";
	for (var i=0; i<lmc_titleList.length; i++)
	{
		if(i >= ListNum) break;

		temArray[j++] = "  <tr>";
		temArray[j++] = "    <td class=\"r_rank\">" + (i+1) + "</td><td>&nbsp;<a title=\""+lmc_titleList[i]+"\" href=\"" + lmc_conurlList[i] + "\" target=\"_blank\" class=\"txt2\">" + GetSubStr(lmc_titleList[i], 30, '...') + "</a>[<a href=\"" + lmc_urlList[i] + "\" target=\"_blank\" class=\"txt2\">文</a>]</td>";
		temArray[j++] = "  </tr>";
	}
	temArray[j++] = "</table>";

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}

//显示精彩评论列表
function get_recommendReply(DivId, ListNum)
{
	if(infoid_arr.length<=0){
		return false;
	}
	if(ListNum == null || ListNum < 1){
		 ListNum = 10;
	}

	var str = "";
	var temArray = new Array();
	var j = 0;

	temArray[j++] = '<h3>精华评论</h3><ul class="m_spl">';
	for (var i=0; i<infoid_arr.length; i++)
	{
		if(i >= ListNum){
			break;
		}
		if(uc_uid_arr[i] != 0){
			temArray[j++] = '<li><div class="m_sinfo"><a href="http://i.81813.com/?controller=userinfo&uid='+uc_uid_arr[i]+'" class="m_name">'+nickname_arr[i]+'</a>';
		}else{
			temArray[j++] = '<li><div class="m_sinfo"><a href="#" class="m_name">'+nickname_arr[i]+'</a>';
		}

		if(ctype_arr[i] == 'zx'){
			temArray[j++] = '&nbsp;对咨询&lt;&lt;&nbsp;<a href="'+url_arr[i]+'">'+title_arr[i]+'</a>&gt;&gt;的评论</div>';
		}else{
			temArray[j++] = '&nbsp;对新闻&lt;&lt;&nbsp;<a href="'+url_arr[i]+'">'+title_arr[i]+'</a>&gt;&gt;的评论</div>';
		}

		temArray[j++] = '<div class="m_cinfo vspace10">'+content_arr[i]+'<span class="m_arr"></span></div></li>';
	}
	temArray[j++] = '</ul>';

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null){
		document.getElementById(DivId).innerHTML = str;
	}
}


// 显示一个周内的热门回复
function get_lastweekreplyinfo(DivId, ListNum)
{
	if(lwr_titleList.length<=0 || lwr_dbnumList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();
	var j = 0;

	temArray[j++] = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"table2\">";
	for (var i=0; i<lwr_titleList.length; i++)
	{
		if(i >= ListNum) break;

		temArray[j++] = "  <tr>";
		temArray[j++] = "    <td class=\"txt2\"><a href=\"" + lwr_urlList[i] + "\" target=\"_blank\" class=\"txt2\">" + GetSubStr(lwr_titleList[i], 36, '..') + "</a></td>";
		temArray[j++] = "  </tr>";
		//temArray[j++] = "  <tr>";
		//temArray[j++] = "    <td class=\"menu12t\"><p style=\"text-indent:2em;\">" + lwr_conList[i] + "</p></td>";
		//temArray[j++] = "  </tr>";

	}
	temArray[j++] = "</table>";

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}

// 显示一个月内的热门回复
function get_lastmonthreplyinfo(DivId, ListNum)
{
	if(lmr_titleList.length<=0 || lmr_dbnumList.length<=0) return;
	if(ListNum == null || ListNum < 1) ListNum = 10;

	var str = "";
	var temArray = new Array();
	var j = 0;

	temArray[j++] = "<table width=\"95%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"table2\">";
	for (var i=0; i<lmr_titleList.length; i++)
	{
		if(i >= ListNum) break;

		temArray[j++] = "  <tr>";
		temArray[j++] = "    <td class=\"txt2\"><a href=\"" + lmr_urlList[i] + "\" target=\"_blank\" class=\"txt2\">" + GetSubStr(lmr_titleList[i], 36, '..') + "</a></td>";
		temArray[j++] = "  </tr>";
		//temArray[j++] = "  <tr>";
		//temArray[j++] = "    <td class=\"menu12t\"><p style=\"text-indent:2em;\">" + lmr_conList[i] + "</p></td>";
		//temArray[j++] = "  </tr>";

	}
	temArray[j++] = "</table>";

	str = temArray.join("");
	temArray = null;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}

// 获取/显示评论内容
function getcommentinfo(DivId, ListNum, isReturn)
{
	if(userList.length<=0 || conList.length<=0) return;
	if(DivId == null) DivId = "commentinfoDiv";
	if(ListNum == null || ListNum < 1)
		ListNum = userList.length;
	else
		ListNum  = (ListNum > userList.length) ? userList.length : ListNum;
	if(isReturn == null) isReturn= false;

	var str = "";
	for(i=0; i<userList.length; i++)
	{
		str += "<TABLE cellSpacing=0 cellPadding=0 border=0 width=570><tr><td class=more1 style=padding:3px;>"+userList[i]+"  说：</td></tr><tr><td class=more2 style=padding:3px;> "+GetSubStr(conList[i])+" </td></tr><tr><td background=http://tp.91.com/images/01.gif><img src=http://tp.91.com/images/01.gif width=3 height=3></td></tr></table>";
	}

	if(isReturn) return str;

	if(document.getElementById(DivId) != null)
		document.getElementById(DivId).innerHTML = str;
}

//选择表情后
function switchStatus(){
	objComment.style.color = "#000";
	calLeft();
	firstLoad = false;
	var allFace = document.getElementById("all_face");
	allFace.style.display="none";
	objComment.focus();

}
//切换表情包
function change_face(a,b){
	for(i= 0 ;i<left_face.length;i++){
		right_face[i].style.display = "none";
		right_face[b].style.display = '';
		left_face[i].className = "";
		left_face[a].className = "on_face";
	}
}
//检查剩余字数
function calLeft(){
  objCleft.innerHTML = 400 - objComment.value.length;
if (objComment.value.length > 400 ){
  alert("评论不能超过400个字!");
  objComment.value=objComment.value.substring(0,400);
  }
}
//随机显示快速评论
function pickArr(num, array){
	var temp_array = new Array();
	temp_array = array.slice(0);//复制数组
	if (firstLoad){//页面载入后立即显示一条随机评论
		var arrIndex = Math.floor(Math.random()*temp_array.length);
		objComment.value = temp_array[arrIndex].replace(/　/g, "\r\n");
		objComment.style.color = "#888";
	}
	refreshArr(num, array);
}
//刷新快速评论
function refreshArr(num, array){
	var temp_array = new Array();
	objR_con.innerHTML = '';
	temp_array = array.slice(0);//复制数组
	for (var i = 0; i<num; i++) {
		if (temp_array.length>0) {
			var arrIndex = Math.floor(Math.random()*temp_array.length);
			var oLi = doc.createElement("li");
			var oA = doc.createElement("a");
			var oText = doc.createTextNode(temp_array[arrIndex]);
			oA.appendChild(oText);
			oA.href="javascript:;";
			oA.title=oA.innerHTML.replace(/　/g, "\r\n");
			oA.onclick = function (e){
				//if (firstLoad) objComment.value = this.innerHTML;
				//else objComment.value += this.innerHTML;
				objComment.value = this.innerHTML.replace(/　/g, "\r\n");
				objComment.style.color = "#000";
				calLeft();
				firstLoad = false;
				objComment.focus();
			}
			oLi.appendChild(oA);;
			objR_con.appendChild(oLi);
			temp_array.splice(arrIndex, 1);//将已输出的元素从数组里删除
		} else {break; }
	}

}

//生成一套表情代码
function genSmilies(source,sep,width){
	var sstr = "";
	end = source.length;
	tdLeft = end%sep;
	for (i=1; i<=end; i++){
		var tmpArr = new Array();
		tmpArr = source[i-1].split(".");
		if(i==1) {sstr+="<table width=\"100%\" border=\"0\" 	<tr>";	}
		sstr += "<td><img src=\"http://image.91.com/pz91/images/smile/"+tmpArr[0]+".gif\" title=\""+tmpArr[1]+"\" width=\""+width+"\" height=\""+width+"\" onClick=\"setFace(\'[f="+tmpArr[0]+"]\');switchStatus()\" /></td>";

		if(i%sep == 0 && i!=end){//如果达到行尾
			sstr+="</tr><tr>";
		}
	}
	if(tdLeft>0){
		sstr+="<td colspan="+tdLeft+"></td></tr></table>";
	}else{
		sstr+="</tr>";
	}
	return sstr;

}
//显示表情选择框
function showSmiliesCon(){
	var allFace = document.getElementById("all_face");
	allFace.style.display="";
	}
//鼠标点击任意处，隐藏表情框
document.onclick = function (event){
	var e = event || window.event;
	var elem = e.srcElement||e.target;
	while(elem)
	{
		if(elem.id == "all_face"||elem.id == "smilies")
		{
				return;
		}
		elem = elem.parentNode;
	}
	var allFace = document.getElementById("all_face");
	if(allFace) allFace.style.display="none";
}
//输出表情代码
function showSmilies(){
var o = "<div class=\"smilies\" id=\"smilies\">";
o += "    <a onclick=\"showSmiliesCon();\" style=\"cursor:pointer\"><img src=\"http://image.91.com/pz91/images/smile/insert_face.gif\"></a>";
o += "</div>";
o += "<div id=\"all_face\" class=\"all_face\" style=\"display:none\">";
o += "    <div class=\"title\">选择表情<a onclick=\"document.getElementById(\'all_face\').style.display=\'none\'\">关闭</a></div>";
o += "    <div class=\"category\">";
o += "        <ul id=\"left_allface\">";
o += "            <li onclick=\"change_face(0,0)\" class=\"on_face\">91游</li>";
o += "            <li onclick=\"change_face(1,1)\">土匪鸡</li>";
o += "            <li onclick=\"change_face(2,2)\">乌龟GG</li>";
o += "            <li onclick=\"change_face(3,3)\">小僵尸</li>";
o += "            <li onclick=\"change_face(4,4)\">乡村熊</li>";
o += "        </ul>";
o += "        <div class=\"fix_empty\"></div>";
o += "    </div>";
o += "    <div class=\"right_con\">";
o += "        <div id=\"right_face\" class=\"right_face\">";
o += "        	<div>";

var s_title1 = new Array("1.哈哈大笑","2.开心","3.鼓掌","4.无语","5.大心","6.汗","7.打哈欠","8.疑问","9.hoho","10.惊讶",
						"11.加油","12.激动","13.不同意","14.害羞","15.不是介个样子滴","16.同意","17.晕","18.寒","19.气愤","20.撒娇",
						"21.装酷","22.仰慕","23.头晕","24.大哭","25.大笑","26.偷笑","27.嗯嗯","28.幻想","29.悲伤","30.困惑")
o += genSmilies(s_title1,8,23);

o += "            </div>";
o += "            <div style=\"display:none\">";

var s_title2 = new Array("1072.翻脸","1073.吃惊","1074.晕倒","1075.没钱","1076.单挑","1077.不知道","1078.有的是钱","1079.来啊","1080.弹吉他","1081.真好吃",
						"1083.闪","1084.耍刀","1085.双截棍","1086.救命啊","1087.转晕了")
o += genSmilies(s_title2,4,50);

o += "            </div>";
o += "            <div style=\"display:none\">";

var s_title3 = new Array("1059.开心","1060.吃惊","1061.打劫啊","1062.可怕啊","1063.抄袭","1064.嘻嘻","1065.伤心","1066.累","1067.爬过","1068.上学",
						"1069.哇---","1070.猥亵","1071.吓---")
o += genSmilies(s_title3,4,50);

o += "            </div>";
o += "            <div style=\"display:none\">";

var s_title4 = new Array("1088.吹符","1089.发呆","1090.睡觉","1091.吐舌头","1092.乌云","1093.小僵尸闭嘴","1094.小僵尸发火","1095.小僵尸耍宝","1096.小僵尸炸弹","1097.一队路过",
						"1098.着火")
o += genSmilies(s_title4,4,50);

o += "            </div>";
o += "            <div style=\"display:none\">";

var s_title5 = new Array("1039.拜拜","1040.鄙视你","1041.变身","1042.吃玉米","1043.鬼脸","1044.奸笑","1045.呕吐","1046.飘过","1047.掐脸","1057.装酷");
o += genSmilies(s_title5,4,50);

o += "            </div>";
o += "        </div>";
o += "    </div>";
o += "</div>";
document.writeln(o);
}

var doc = window.document;
var firstLoad = true;
var comments = new Array('这就是传说中的沙发么',
					   '自插双目，扶墙而出',
					   '露珠湿沙壁，暮有晓寂寂',
					   '又是这种文章，我手欠',
					   '好文，必须顶！',
					   '我的心久久不能平静，好文啊',
					   '我一辈子都没有像今天这么开心',
					   '太恶心了，顶上去让大家跟我同恶心',
					   '小编功力不够就不要出来了',
					   '跪求下载地址~~~',
					   '鄙视标题党',
					   '哈哈，太搞笑了',
					   '友情支持',
					   '我是来打酱油的',
					   '又看见你在上网了，你怎么总在网上呀？你的学习任务完成了吗？你父母不为你着急吗？',
					   '此文带给我的震撼，犹如闪电瞬间通过全身，雷得外焦里嫩',
					   '本人过去、现在以及将来都不认识作者',
					   '哥回复 不代表小盆友你帅　哥回复 不代表小女女你水灵　哥回复 不代表您多有才华　哥回复 不代表您有多牛X　哥回复 不代表您值得哥在这浪费手劲　哥回复 不代表哥寂寞 只是哥想要包子了',
					   '看到此文，智商上的优越感油然而生',
					   '你就是那不落的太阳，照亮了大地，拯救了苍生，世界因你而美丽！',
					   '此评论来自91.com，可能是系统自动发送，与本人一点关系都没有，谢绝各种形式的跨省追捕。',
					   '雷就一个字，雷我很多次',
					   '此文真是一派胡言，真可谓：“两个黄鹂鸣翠柳，不知所云；一行白鹭上青天，不知所往”。',
					   '在逐行逐句地看完此文后，我的心久久不能压抑的喜悦，震动了整个生命！怎会有如此精妙绝伦的好文？'
					   );
