<style>
#m___MODULE_ID___b li {list-style:none; }
</style>
<script type="text/javascript">
function showtree(topicid,ppp){
	var imgsrcCol = "${forumpath}space/skins/themes/${themepath}/images/item_collapsed.gif";
	var imgsrcExp = "${forumpath}space/skins/themes/${themepath}/images/item_extend.gif"
	var errimgColpath = "${forumpath}space/modules/builtin/forum/images/item_collapsed.gif";
	var errimgExppath = "${forumpath}space/modules/builtin/forum/images/item_extend.gif";
	var divTopic = _gel("divTopic" + topicid);
	if (divTopic.innerHTML =="")
	{	
		div = document.createElement("DIV");
		div.id = "divShowContext_" + topicid;
		div.className = "openlist";
		div.innerHTML = "<img src='${forumpath}space/Modules/builtin/forum/images/loading.gif' />载入中...";
		
		divTopic.appendChild(div);
		_sendx("${forumpath}tools/ajax.aspx?t=topictree&topicid=" + topicid, function(obj){writetree(obj,topicid,ppp)},true, null);
	}

	if (_gel("imgButton_" + topicid).src.indexOf(errimgExppath)!=-1 || _gel("imgButton_" + topicid).src.indexOf(errimgColpath)!=-1)
	{
		if (_gel("imgButton_" + topicid).src.indexOf(errimgColpath)!=-1){	
			_gel("imgButton_" + topicid).src = errimgExppath;
			_gel("imgButton_" + topicid).alt = "展开";
			_gel("imgButton_" + topicid).title = "展开";
			_gel("divTopic" + topicid).style.display = "none";
		}
		else{
			_gel("imgButton_" + topicid).src = errimgColpath;
			_gel("imgButton_" + topicid).alt = "关闭";
			_gel("imgButton_" + topicid).title = "关闭";
			if (_gel("divTopic" + topicid)){
				_gel("divTopic" + topicid).style.display = "";
			}
		}
	}
	else
	{
		if (_gel("imgButton_" + topicid).src.indexOf(imgsrcCol)!=-1){	
			_gel("imgButton_" + topicid).src = imgsrcExp;
			_gel("imgButton_" + topicid).alt = "展开";
			_gel("imgButton_" + topicid).title = "展开";
			_gel("divTopic" + topicid).style.display = "none";
		}
		else{
			_gel("imgButton_" + topicid).src = imgsrcCol;
			_gel("imgButton_" + topicid).alt = "关闭";
			_gel("imgButton_" + topicid).title = "关闭";
			if (_gel("divTopic" + topicid)){
				_gel("divTopic" + topicid).style.display = "";
			}
		}
	}
}

function writetree(obj,topicid,ppp){
	var divTopic = _gel("divTopic" + topicid);

	var err = obj.getElementsByTagName('error');
	if (err[0] != null && err[0] != undefined)
	{
		var errdiv = document.createElement("DIV");
		errdiv.className='errcontext';

	    if (err[0].childNodes.length > 1) {
		    errdiv.innerHTML = '<div style="margin: 0px 15px 0px 40px;">' + err[0].childNodes[1].nodeValue + '</div>';
		} else {
		    errdiv.innerHTML = '<div style="margin: 0px 15px 0px 40px;">' + err[0].firstChild.nodeValue + '</div>';    		
		}

		divTopic.appendChild(errdiv);
		_gel("divTopic" + topicid).style.display = "";
		_gel("divShowContext_" + topicid).style.display = "none";
		return;
	}

	var dataArray = obj.getElementsByTagName('post');
	var dataArrayLen = dataArray.length;
	
		var page = 0;
		var divIsShow = "block";
		for(var i = 0; i < dataArrayLen; i++){
			page ++;
			div = document.createElement("DIV");
			div.className = "openlist";
			div.id = "divFollow_" + topicid + "_" + page;
			div.style.display = divIsShow;
			div.style.lineHeight = "180%";
			var list = "<ul class=\"listcontent\">";
			for (j=0;j<10;j++){
				list += "<li><a href=\"${forumpath}showtopic-";
				list += topicid;
				if (ppp>0){
					list += "-";
					list += Math.ceil((i+2)/ppp);
				}
				list += ".aspx#";
				list += dataArray[i].getAttribute("pid");
				list +="\">";
				list += dataArray[i].getAttribute("message").substring(0,50);
				list += "</a>&nbsp; --- &nbsp; (";
				if (dataArray[i].getAttribute("poster")!="游客")
				{
					list += "<a target=\"_blank\" href=\"${forumpath}userinfo.aspx?userid=";
					list += dataArray[i].getAttribute("posterid");
					list += "\">";
					list += dataArray[i].getAttribute("poster");
					list += "</a> 发表于 ";
				}
				else
				{
					list += "游客 发表于";
				}
				
				list += dataArray[i].getAttribute("postdatetime");
				list += ")</li>";
				i++;
				if (i>=dataArrayLen){
					break;
				}
			}
			list += "</ul>";
			if ( list != "<ul class=\"listcontent\"></ul>" )
			{
			
				i--;
				
			}

			div.innerHTML = list;
			
			divIsShow = "none";
			divTopic.appendChild(div);
		}
		
		divpage = document.createElement("DIV");
		divpage.id = "divFollow_page_" + topicid;
		divpage.className = "pagecontent";
		divpage.style.marginTop = "5px"
		divpage.innerHTML = "页数:<span id=\"div_curpage_" + topicid + "\">1</span>/<span id=\"div_Totalpage_" + topicid + "\">" + page + "</span>&nbsp;&nbsp;&nbsp;<span onclick=\"gotopage(" + topicid + ",1);\" style=\"cursor:pointer;\" title=\"上一页\"><img src=\"${forumpath}space/Modules/builtin/forum/images/prev.gif\" /></span>&nbsp;<input type=\"text\" id=\"divInput_pagenumber_" + topicid + "\" value=\"1\" size=\"3\" style=\"text-align:center\" class=\"colorblue\" onKeyDown=\"if(event.keyCode==13) { gotopage(" + topicid + ",3); return false; }\">&nbsp;<span onclick=\"gotopage(" + topicid + ",2);\" style=\"cursor:pointer;\" title=\"下一页\"><img src=\"${forumpath}space/Modules/builtin/forum/images/next.gif\" /></span>"
		divTopic.appendChild(divpage);
		divTopic.className = "pagediv";
		_gel("divTopic" + topicid).style.display = "";
		_gel("divShowContext_" + topicid).style.display = "none";
		
}

function gotopage(topicid,index){
	page = parseInt($("divInput_pagenumber_" + topicid).value);
	if (DragUtil.is_ie){
		curpage = parseInt($("div_curpage_" + topicid).innerText);
		total = parseInt($("div_Totalpage_" + topicid).innerText);
	}
	else{
		curpage = parseInt($("div_curpage_" + topicid).textContent);
		total = parseInt($("div_Totalpage_" + topicid).textContent);
	}
	if (!(parseInt(page)==page && page>0)){
		alert("页码无效");
		return false;
	}
	
	if (!(parseInt(curpage)==curpage && curpage>0)){
		curpage = page;
	}
	
	if (!(parseInt(total)==total && total>0)){
		alert("总页码无效");
		return false;
	}
	
	if (curpage>total || curpage < 1){
		alert("页码无效");
		return false;
	}
	
	
	switch (index){
		case 1:
			if (page-1<1){
				alert("已经是第一页");
				return false
			}
			$("divFollow_" + topicid + "_" + curpage).style.display="none";
			$("divFollow_" + topicid + "_" + (curpage-1)).style.display="block";
			$("divInput_pagenumber_" + topicid).value = curpage - 1;
			break;
		case 2:
			if (page+1>total){
				alert("已经到达最后一页");
				return false
			}
			$("divFollow_" + topicid + "_" + curpage).style.display="none";
			$("divFollow_" + topicid + "_" + (parseInt(curpage) +1)).style.display="block";
			$("divInput_pagenumber_" + topicid).value = parseInt(curpage) + 1;
			break;
		case 3:
			if (page>total || page<1){
				alert("页码应在 1-" + total + " 之间");
				return false
			}
			$("divFollow_" + topicid + "_" + curpage).style.display="none";
			$("divFollow_" + topicid + "_" + page).style.display="block";
			break;
	}
	if (DragUtil.is_ie){
		$("div_curpage_" + topicid).innerText = $("divInput_pagenumber_" + topicid).value;
	}
	else{
		$("div_curpage_" + topicid).textContent = $("divInput_pagenumber_" + topicid).value;
	}
}
</script>