(function($) {
	$.extend({
		getCommentForm:function(){
			$.get("/comment.php",{
				action:'form'
			},function(result){
				$("#commentForm").html(result.content.content);
			},'json');
		},
		getCommentList:function(page){
			$.get("/comment.php",{
				action:'list',
				archive_id:comment.archive_id,
				category_id:comment.category_id,
				archive_type:comment.archive_type,
				page:page
			},function(result){
				$("#commentList").html(result.content.content);
			},'json');
		},
		getCommentListAll:function(page){
			$.get("/comment.php",{
				action:'listAll',
				archive_id:comment.archive_id,
				category_id:comment.category_id,
				archive_type:comment.archive_type,
				page:page
			},function(result){
				//	alert(result.content);
				$("#commentList").html(result.content.content);
			},'json');
		},
		submitComment:function(){
			if($('#commentContent').val()==""){
				alert("评论发表失败，评论的内容不能为空!");
			}else{
				$.get("/comment.php",{
					action:'add',
					vcode:$('#vcode').val(),
					archive_id:comment.archive_id,
					category_id:comment.category_id,
					archive_type:comment.archive_type,
					archive_url:comment.archive_url,
					title:'',
					content:$('#commentContent').val()
				},function(result){
					if(result.content.status=="no_vcode"){
						alert("评论发表失败，没有输入验证码!");
					}else if(result.content.status=="vcode_error"){
						alert("评论发表失败，验证码错误!");
						$('#yz').attr("src","/yz.php?ranDom"+Math.random());
					}else if(result.content.status=="yes"){
						//alert("评论发表成功!");
						$('#commentContent').val("");
						$.getCommentList(1);
						$('#vcode').val("");
					}
			},'json');
			}
		},
		submitCommentzz:function(){
			if($('#commentContent').val()==""){
				alert("评论发表失败，评论的内容不能为空!");
			}else{
				$.get("/comment.php",{
					action:'add',
					vcode:$('#vcode').val(),
					archive_id:comment.archive_id,
					category_id:comment.category_id,
					archive_type:comment.archive_type,
					archive_url:comment.archive_url,
					title:'',
					username:$('#wangming').val(),
					content:$('#commentContent').val()
				},function(result){
					if(result.content.status=="no_vcode"){
						alert("评论发表失败，没有输入验证码!");
					}else if(result.content.status=="vcode_error"){
						alert("评论发表失败，验证码错误!");
						$('#yz').attr("src","/yz.php?ranDom"+Math.random());
					}else if(result.content.status=="yes"){
						//alert("评论发表成功!");
						$('#commentContent').val("");
						$.getCommentList(1);
						$('#vcode').val("");
					}
			},'json');
			}
		},
		revertComment:function(){
			if($('#revertContent').val()==""){
				alert("回复的内容不能为空!");
			}else{
				$.ajaxSetup({ cache: false });
				$.get("/comment.php",{
					action:'revert',
					vcode:$('#revertVcode').val(),
					parent_id:$('#parent_id').val(),
					root_id:$('#root_id').val(),
					archive_id:comment.archive_id,
					archive_type:comment.archive_type,
					category_id:comment.category_id,
					title:'',
					content:$('#revertContent').val()
				},function(result){
					if(result.content.status=="no_vcode"){
						alert("没有输入验证码!");
					}else if(result.content.status=="vcode_error"){
						alert("验证码错误!");
					}else if(result.content.status=="yes"){
						$('#revertContent').val("");
						$.getCommentListAll(1);
						$('#revertVcode').val("");
					}
				},'json');
			}
			return true;
		},
		submitComment2:function(){
			if($('#commentContent').val()==""){
				alert("评论的内容不能为空!");
			}else{
				$.ajaxSetup({ cache: false });
				$.get("/comment.php",{
					action:'add',
					vcode:$('#vcode').val(),
					archive_id:comment.archive_id,
					archive_type:comment.archive_type,
					archive_url:comment.archive_url,
					title:$('#title').val(),
					content:$('#commentContent').val()
				},function(result){
					if(result.content.status=="no_vcode"){
						alert("没有输入验证码!");
					}else if(result.content.status=="vcode_error"){
						alert("验证码错误!");
						$('#yz').attr("src","/yz.php?ranDom"+Math.random());
					}else if(result.content.status=="yes"){
						$('#commentContent').val("");
						$.getCommentListAll(1);
						//alert("评论发表成功!");
						$('#vcode').val("");
						$('#yz').attr("src","/yz.php?ranDom"+Math.random());
					}
				},'json');
			}
		}
	});
})(jQuery);