//验证评论内容
function checkContent(){
	var content = document.getElementById("comDto.content");
	if(content.value==""){
		alert("评论内容不能为空！");
		content.focus();
		return false;
	}
	if(content.value.length > 100){
	 	alert("评论内容不能超过100个字！");
	 	content.focus();
	 	return false;
	}
	var maskCode = document.getElementById("comment_mask");
	if(maskCode.value==""){
    	alert("验证码不能为空！");
   		maskCode.focus();
	   	return false;
	}
	var d=$j('#frmComment').serialize();
	var date=new Date();
	d=d+"&t="+getRandom(date.getSeconds());
	$j.ajax({
		type:"post",
		url:rootpath+"/newsCommentInForntAction.action",
		data:d,
		datatype:"html",
		success:function(msg){
			eval("var ds="+msg);
			if(ds.result=='true'){
				maskCode.value='';
				alert('评论成功！');
				content.value='';
				$j('#linkComment').html('查看评论内容');
				showCommentList();
			}else{
				eval(ds.strJs);
			}
			refresh($j('#commnet_yzm'));
	   	}
		});
	return true;
}
//下面两个方法为处理Ajax加载评论信息
function trunPage(pageNo){
	var d=pageNo;
	var perPage=10;
	var newsId=$j('#divNewsId').html();
	if(!pageNo){
		pageNo=1;
	}
	if(!isNaN(pageNo)&&pageNo>0){
		//$j('#divCommentList').html('正在加载......');
		var date=new Date();
		d='newsId='+newsId+'&EgecPerNum='+perPage+'&EgecStart='+((parseInt(pageNo)-1)*perPage);
		d=d+"&t="+getRandom(date.getSeconds());
		$j.ajax({
			url:rootpath+'/newsCommentInForntAction!getList.action',
			cache:false,
			type:"get",
			data:d,
			dataType:"html",
			success:function(msg){
				$j('#divCommentList').html(msg);
			}
		});
	}else{
		window.alert('跳转页面必须为大于0的数字!');	
	}
}
function showCommentList(){
	var t=$j('#linkComment').html();
	var t_show='查看评论内容';
	var t_hide='关闭评论内容';
	if(t==t_hide){
		$j('#linkComment').html(t_show);
		$j('#divCommentList').hide();
	}else{
		$j('#linkComment').html(t_hide);
		$j('#divCommentList').show();
		trunPage();
	};
}

