﻿function StopButton(){
	document.getElementById(arguments[0]).disabled=true;
	document.getElementById(arguments[0]).value="提交("+arguments[1]+")";
	if(--arguments[1]>0){
		window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000);
	}
	if(arguments[1]<=0){
		document.getElementById(arguments[0]).value='提交';
		document.getElementById(arguments[0]).disabled=false;
	}
}
function showme(){	
		//$('#comment').show();
		
		$('#ctl00_main_CommentSubmit').attr("disabled", true);

}		
function GetComment($ID,$Page){
    $('#comment').show();
	$.ajax({
		url:"Comment.aspx?action=ajax_getcomment&id="+$ID+"&page="+$Page+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
		    //alert(arguments[0]);
			$('#comment').html(arguments[0]);
			//$('#ctl00_main_CommentSubmit').attr("disabled", true);
		}
	});
}
function SendComment(){	
		var $CommentParentID	=arguments[0];
		//var $CommentUser		=$('#CommentUser').val();
		var $CommentText		=$('#CommentText').val();
		var $CommentValidate	=$('#CommentValidate').val();
		//if ($.trim($CommentUser)=='')
		//{
		//	alert('请您填写昵称！');
		//	$('#CommentUser').focus();
		//	return false;
		//}
		if ($.trim($CommentValidate)=='')
		{
			alert('请您填写验证码！');
			$('#CommentValidate').focus();
			return false;
		}		
		if ($.trim($CommentText)=='')
		{
			alert('请您填写回复内容！');
			$('#CommentText').focus();
			return false;
		}
		if ($CommentText.length<5||$CommentText.length>200)
		{
			alert('内容必须在5-200字之间！');		
			return false;
		}
		//StopButton('ctl00_main_CommentSubmit',10);
		$('#ctl00_main_CommentSubmit').attr("disabled", true);
		$.ajax({
		    url: "Comment.aspx?action=ajax_sendcomment&commentparentid=" + $CommentParentID + "&commenttext=" + escape($CommentText) + "&commentvalidate=" + escape($CommentValidate) + "&time=" + new Date().toString(),
		    type: 'GET',
		    error: function() { alert('数据执行出错'); },
		    success: function() {
		        if (arguments[0] == 'ERROR') {
		            alert('验证码出错！');
		            $('#ctl00_main_CommentSubmit').removeAttr("disabled");
		        } else {
		            GetComment($CommentParentID, 0);
		            alert(arguments[0]);
		            $("#CommentText").val("");
		            //验证成功时，刷新验证码图片
		            //$("#CommentValidateImages").attr("src","../sitecontrol/GetCode.aspx?s="+Math.random());
		            //$('#ctl00_main_CommentSubmit').removeAttr("disabled");
		           
		            $('#postdiv').hide(500);
		        }
 
		        $("#CommentValidate").val("");
		    }


		});
//SetCookie("CommentUser",$CommentUser,3);
}
