function StopButton(){
	document.getElementById(arguments[0]).disabled=true;
	document.getElementById(arguments[0]).value="Submit Review("+arguments[1]+")";
	if(--arguments[1]>0){
		window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000);
	}
	if(arguments[1]<=0){
		document.getElementById(arguments[0]).value='Submit Review';
		document.getElementById(arguments[0]).disabled=false;
	}
}
function GetComment($ID,$Page,$channel){
	$.ajax({
		url:"/comment.asp?action=ajax_getcomment&id="+$ID+"&page="+$Page+"&channel="+$channel+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#comment').html(arguments[0]);
		}
	});
}
function SendComment(){	
		var $CommentParentID	=arguments[0];
		var $comment_rank		=$("input[@type=radio][@checked]").val();
		var $nickname		=$('#nickname').val();
		var $useremail		=$('#useremail').val();
		var $title		=$('#title').val();
		var $channel		=$('#channel').val();
		var $CommentText		=$('#CommentText').val();
		var $CommentValidate	=$('#CommentValidate').val();
		
		if ($.trim($nickname)=='')
		{
			alert('Enter your reviewer nickname');
			$('#nickname').focus();
			return false;
		}
		if ($.trim($useremail)=='')
		{
			alert('Enter your email');
			$('#useremail').focus();
			return false;
		}
		if ($.trim($CommentText)=='')
		{
			alert('Enter your review content');
			$('#CommentText').focus();
			return false;
		}
		if ($CommentText.length<5||$CommentText.length>20000)
		{
			alert('Content must be between 5-20000 words');		
			return false;
		}
		if ($.trim($CommentValidate)=='')
		{
			alert('Enter the numbers');
			$('#CommentValidate').focus();
			return false;
		}		
		StopButton('CommentSubmit',10);
	$.ajax({
		url:"/comment.asp?action=ajax_sendcomment&commentparentid="+$CommentParentID+"&nickname="+encodeURIComponent(escape($nickname))+"&useremail="+encodeURIComponent(escape($useremail))+"&comment_rank="+escape($comment_rank)+"&title="+encodeURIComponent(escape($title))+"&channel="+escape($channel)+"&commenttext="+$CommentText+"&commentvalidate="+escape($CommentValidate)+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
			if (arguments[0]=='ERROR')
			{
				alert('Code error!');
			}else{
				GetComment($CommentParentID,0,$channel);
				alert(arguments[0]);
				$("#CommentText").val("");
					//验证成功时，刷新验证码图片
				$("#CommentValidateImages").attr("src","/inc/code.asp?s="+Math.random());
			}
			$("#CommentValidate").val("");
		}
	});
//SetCookie("email",$email,3);
}
