<!--
function loadComments() {
    var topicid = jQuery('#topicid').val();
    var page = jQuery('#compage').val();
    var param = "topicid="+topicid+"&page="+page;
    var url = "interface/comList.php";
    new AjaxRequest('POST',url,param,getCommentInfo);
}

function getCommentInfo(jsonStr) {
	if (null != jsonStr && "" != jsonStr) {
		var myJSON = eval("(" + jsonStr +")");
		if(0 == myJSON.exitcode){
			// topicDetailInfo.js
			displayComments(myJSON);
		} else {
			//showStatus('loading');
		}
	}
}


function showStatus(status){
	switch(status){
		case 'loading':
			jQuery('#commentLoading').show();
			jQuery('#commentNone').hide();
			break;
		case 'success':
			jQuery('#commentLoading').hide();
			jQuery('#commentNone').hide();
			break;
		case 'none':
			jQuery('#commentLoading').hide();
			jQuery('#commentNone').show();
			break;
		case 'faile':
		default:
			jQuery('#commentLoading').hide();
			jQuery('#commentNone').hide();
			break;
	}
}

function displayComments(myJSON) {
	if(null != myJSON && 0 == myJSON.detail.length){
		showStatus('none');
	}else{
		if(0 == myJSON.detail.length){
			showStatus('none');
		}else{
			showStatus('success');
			cleanComments();
			var myCommentDiv = jQuery("#commentListTable");
			var mycommentbody = jQuery("<div></div>");
			mycommentbody.attr('id','commentBody');
			for (var index = 0; index < myJSON.detail.length; index++) {
				var content = myJSON.detail[index].content;
				var date = myJSON.detail[index].date;
				var author = myJSON.detail[index].author;		
				//create comment list
				var comCell = jQuery("<div></div>");
				comCell.attr('className','commentCell');
				
				var comAuthor = jQuery("<div></div>");
				comAuthor.attr('className','commentAuthor');
				comAuthor.append(author + "(" + date + "):").appendTo(comCell);

				var comContent = jQuery("<div></div>");
				comContent.attr('className','commentContent');
				comContent.append(jQuery("<pre></pre>").append(content)).appendTo(comCell);	
								 
				mycommentbody.append(comCell);
			}
			myCommentDiv.append(mycommentbody);
			//addScrollBar('commentListTable');
			pagination(myJSON.totalcount);
		}
	}
}

function cleanComments() {
	jQuery('#commentListTable').empty();
}

function pagination(listCount){
	var pagesize = 25;
	var totalpage = Math.ceil(listCount/pagesize);
	var maxpageObj = jQuery('#maxpage');
	maxpageObj.val(totalpage);
	if(1<maxpageObj.val()){
		jQuery("#commentListBtn").show();
	}
}

function prePage() {
	var compageObj = jQuery('#compage');
	var currenPage = compageObj.val();
	if (parseInt(currenPage) > 1) {
		compageObj.val(parseInt(currenPage) - 1);	
		loadComments();
		jQuery('#nextCommentBtn').attr('src','image/nextPage.gif');
		jQuery('#nextCommentBtn').css('cursor','pointer');
	}
	if (parseInt(currenPage) == 1) {
		jQuery('#preCommentBtn').attr('src','image/previousPage_d.gif');
		jQuery('#preCommentBtn').css('cursor','auto');
	}	
}

function nextPage() {
	var compageObj = $('compage');
	var currenPage = compageObj.value;
	var maxPage = $('maxpage').value;
	if ( parseInt(currenPage) < parseInt(maxPage)) {
		compageObj.val(parseInt(currenPage) + 1);	
		loadComments();
		jQuery('#preCommentBtn').attr('src','image/previousPage.giff');
		jQuery('#preCommentBtn').css('cursor','pointer');
	}
	if (parseInt(currenPage) == (parseInt(maxPage) - 1)) {
		jQuery('#nextCommentBtn').attr('src','image/nextPage_d.gif');
		jQuery('#nextCommentBtn').css('cursor','auto');
	}
}
//-->