function GetComment($target,$tid){
	$.ajax({		
	url:"/async/comment.jhtml?target="+$target+"&tid="+$tid+"&time="+new Date().toString(),
	type:'GET',
	success:function(){
		$('#comment').html(arguments[0]);
	}
	});
}
function SendComment(){	
	var $CommentType=$('#comment_ctype').val(),//评论类型
		$CommentTid=$('#comment_ctid').val(),//评论ID
		$CommentScore=$('#comment_score').val(),//评论分数
		$CommentContent=$('#comment_content').val(),//评论内容
		$CommentRand=$('#comment_rand').val();//评论验证码
	if(!$CommentScore){
		alert('请选择评分!');
		return false;
	}
	if (trim($CommentContent)=='' || trim($CommentContent).length<1)
	{
		alert('评论内容不能为空!');
		$('#comment_content').focus();
		return false;
	}
	$.ajax({		
	url:"/async/comment.jhtml?method=submit&target="+$CommentType+"&tid="+$CommentTid+"&content="+escape(escape($CommentContent))+"&score="+$CommentScore+"&rand="+$CommentRand+"&time="+new Date().toString(),
	type:'GET',
	success:function(){
		var html = trim(arguments[0]);
		if (html=='ERROR_CODE'){
			alert("验证码不正确");
		}else if(html == "ERROR_LOGIN"){
			alert("你没有登录不能评论");
		}else if(html == "ERROR_ACCT"){
			alert("账号被禁用");
		}else if(html == "ERROR_CONTENT"){
			alert("内容不合法");
		}else if(html == "MSG_ACTIVE"){
			alert("您的评论已经提交,但是需要审核");
		}else{
			
			$('#comment_content').val("");
			$('#comment_rand').val("");
			$('#comment_score').val("");
			$(".commentsuc").show();
			$(".commentsuc").fadeOut(3000);
			$('#comment').html(html);
		}
	}
	});
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
/*商品评分效果*/
$(function(){
	//通过修改样式来显示不同的星级
	$("ul.rating li a").click(function(){
	     var title = $(this).attr("title");
		 $(this).parents("ul.rating").siblings("b").text(title);
		 var cl = $(this).parent().attr("class");
		 $(this).parent().parent().removeClass().addClass("rating "+cl+"star");
		 $("#comment_score").val($(this).text());
		 $(this).blur();//去掉超链接的虚线框
		 return false;
	});
	$("#comment_rand").one("click",function(){
		$(".codePic").click();
	});
});
