<!--
function submitComment() {
	if (0 == checkUserStatus()) {
		login();
	} else {
		var comment = trimCharacter(document.getElementById('commentInput').value);
	    var topicid = document.getElementById("topicid").value;
	    if("" == comment || "请填写留言" == comment) {
	    	alert("对不起！不能用空值或者默认内容进行留言。");
		    document.getElementById('commentInput').focus();
		    return;	   	
	    }
		if (comment.length > 2000) {
	    	alert("对不起！留言最多2000字。");
	    	document.getElementById('commentInput').focus();
	    	return;	
		}
		displayCommentStep('upload');
		comment = encodeURIComponent(comment);
		var param = "topicid="+topicid+"&content="+comment;
	    var url = "../interface/reply.php";
	    new AjaxRequest('POST',url,param,getCommentResult);	
	}
}

function getCommentResult(jsonStr) {
    if (null != jsonStr && "" != jsonStr) {
		var myJSON = eval("(" + jsonStr +")");
		if (0 == myJSON.exitcode) {						
			document.getElementById('comment_upload_word').style.background = '#50D2FF';
			document.getElementById('comment_upload_word').innerHTML = '留言成功，等待审核';			
		} else {
			document.getElementById('comment_upload_word').style.background = '#FFB400';
			document.getElementById('comment_upload_word').innerHTML = '系统错误，请重新留言';
		}
		window.setTimeout("displayCommentStep('result')", 3000);			
	}
}

function displayCommentStep(step) {
	if ( 'upload' == step) {
		document.getElementById('comment_upload_word').style.background = '#50D2FF';
		document.getElementById('comment_upload_word').innerHTML = '留言正在提交...';
		document.getElementById('comment_upload_img').style.display = 'none';
		document.getElementById('comment_upload_word').style.display = 'block';
	} else {
		document.getElementById('comment_upload_img').style.display = 'block';
		document.getElementById('comment_upload_word').style.display = 'none';
	}	
}

function comment() {
	var defaultTxt = "请先登录后再留言";
    var txt = "请填写留言";
    if (0 == checkUserStatus()) {
    	document.getElementById('commentInput').value = defaultTxt;
        document.getElementById('commentInput').disabled = true;
    } else {
    	document.getElementById('commentInput').value = txt;
    	document.getElementById('commentInput').disabled = false;
    }  
    document.getElementById('commentInput').onfocus = function(){
        if (this.value == defaultTxt || this.value == txt) {
    		this.value = '';
    	}
    }
    if (document.getElementById('preCommentBtn')) {
    	document.getElementById('preCommentBtn').src = '../image/previousPage_d.gif';
    }	
}

function openBlog(url) {
	window.open(url);
}

function prePageComment() {
	var compageObj = document.getElementById('compage');
	var currenPage = compageObj.value;
	if (parseInt(currenPage) > 1) {
		compageObj.value = parseInt(currenPage) - 1;	
		showCommentList();
		var nextCommentBtn = document.getElementById('nextCommentBtn');
		nextCommentBtn.src = '../image/nextPage.gif';
		nextCommentBtn.style.cursor = 'pointer';
		// first page
		if(1 == compageObj.value){
			var preCommentBtn = document.getElementById('preCommentBtn');
			preCommentBtn.src = '../image/previousPage_d.gif';
			preCommentBtn.style.cursor = 'auto';
		}
	}
}

function nextPageComment() {
	var compageObj = document.getElementById('compage');
	var currenPage = compageObj.value;
	var maxPage = document.getElementById('maxpage').value;
	if ( parseInt(currenPage) < parseInt(maxPage)) {
		compageObj.value = parseInt(currenPage) + 1;	
		showCommentList();
		var preCommentBtn = document.getElementById('preCommentBtn');
		preCommentBtn.src = '../image/previousPage.gif';
		preCommentBtn.style.cursor = 'pointer';
		if(parseInt(currenPage) == (parseInt(maxPage) - 1) ){
			var nextCommentBtn = document.getElementById('nextCommentBtn');
			nextCommentBtn.src = '../image/nextPage_d.gif';
			nextCommentBtn.style.cursor = 'auto';
		}
	}
}

function showCommentList() {
    var topicid = document.getElementById('topicid').value;
    var page = document.getElementById('compage').value;
    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){
			insertCommentInfo(myJSON);
		} else {
			alert(myJSON.desc);
		}
	}
}

function insertCommentInfo(myJSON) {
	var myCommentDiv = document.getElementById("commentListTable");
	var mycommentbody = document.createElement("DIV");
	mycommentbody.id = "commentBody";
	//delete old comment data
	deleteCommentList();
	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 = document.createElement("DIV"); 
		comCell.className = "commentCell"; 
		var comAuthor = document.createElement("DIV");
		comAuthor.className = "commentAuthor"; 
		var authorDateTxt = document.createTextNode(author + "(" + date + "):");
		comAuthor.appendChild(authorDateTxt);
		comCell.appendChild(comAuthor);
		
		var comContent = document.createElement("DIV");
		comContent.className = "commentContent";
		var preElem = document.createElement("PRE");
		var contentTxt = document.createTextNode(content);
		preElem.appendChild(contentTxt);
		comContent.appendChild(preElem); 
		comCell.appendChild(comContent);
		mycommentbody.appendChild(comCell);	
	}
	myCommentDiv.appendChild(mycommentbody);
	addScrollBar('commentListTable');
}

function deleteCommentList() {
	var commentDiv  = document.getElementById('commentListTable');
	var mybody = document.getElementById("commentBody");
	commentDiv.removeChild(mybody);
}

function judgePrePageBtn(state) {
	var currenPage = document.getElementById('compage').value;
	if ('over' == state) {
      	 if (parseInt(currenPage) > 1) {
      	 	document.getElementById('preCommentBtn').src='../image/previousPage_a.gif';
      	 }   	 
    } else {
        if (parseInt(currenPage) > 1) {
      	 	document.getElementById('preCommentBtn').src='../image/previousPage.gif';
      	 }
	}
}

function judgeNextPageBtn(state) {
	var currenPage = document.getElementById('compage').value;
	var maxPage = document.getElementById('maxpage').value;
	if ('over' == state) {
      	 if(parseInt(currenPage) < parseInt(maxPage)){
      	 	document.getElementById('nextCommentBtn').src='../image/nextPage_a.gif';
      	 }   	 
    } else {
        if(parseInt(currenPage) <  parseInt(maxPage)){
      	 	document.getElementById('nextCommentBtn').src='../image/nextPage.gif';
      	 }
	}
}
// 
function returnListPage(frmid,action) {
    var frm = document.getElementById(frmid);
    if(null != frm){
    	frm.action = action;
    	frm.submit();
    }
}
//-->
