function StopButton(){
	document.getElementById(arguments[0]).disabled=true;
	document.getElementById(arguments[0]).value="Submit Comment("+arguments[1]+")";
	if(--arguments[1]>0){
		window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000);
	}
	if(arguments[1]<=0){
		document.getElementById(arguments[0]).value='Submit Comment';
		document.getElementById(arguments[0]).disabled=false;
	}
}
function GetComment($ID,$Page){
	$.ajax({
		url:"/plug/Comments/Comment.asp?action=ajax_getcomment&id="+$ID+"&page="+$Page+"&time"+new Date().toString(),
		type:'POST',
		success:function(){
			$('#comment').html(arguments[0]);
		}
	});
}
function SendComment(){	
		var $CommentParentID =arguments[0];
		var $CommentUser =$('#CommentUser').val();
		var $CommentMail =$('#CommentMail').val();
		var $CommentText =$('#CommentText').val();
		var $CommentValidate =$('#CommentValidate').val();
		if ($.trim($CommentUser)=='')
		{
			alert('please fill the required fields(name).');
			$('#CommentUser').focus();
			return false;
		}
		if ($.trim($CommentMail)==''|| ($CommentMail).search('@') == -1)
		{
			alert('please fill the required fields(email).');
			$('#CommentMail').focus();
			return false;
		}
		if ($.trim($CommentValidate)=='')
		{
			alert('Please enter the verification code.');
			$('#CommentValidate').focus();
			return false;
		}		
		if ($.trim($CommentText)=='')
		{
			alert('Please enter your words!');
			$('#CommentText').focus();
			return false;
		}
		if ($CommentText.length<5||$CommentText.length>5000)
		{
			alert('No more than 5,000 characters, please.');		
			return false;
		}
		StopButton('CommentSubmit',10);
	$.ajax({
		url:"/plug/Comments/Comment.asp?action=ajax_sendcomment&commentparentid="+$CommentParentID+"&commentuser="+escape($CommentUser)+"&commentmail="+escape($CommentMail)+"&commenttext="+escape($CommentText)+"&commentvalidate="+escape($CommentValidate)+"&time="+new Date().toString(),
		type:'POST',
		success:function(){
			if (arguments[0]=='ERROR')
			{
				alert('Please enter the verification code.');
			}else{
				GetComment($CommentParentID,0);
				alert(arguments[0]);
				$("#CommentText").val("");
					//验证成功时，刷新验证码图片
				$("#CommentValidateImages").attr("src","/plug/Comments/Code.asp?s="+Math.random());
			}
			$("#CommentValidate").val("");
		}
	});
//SetCookie("CommentUser",$CommentUser,3);
}