function getComment(appid,tid,aimuid,containerid,type,secret)
{
	var url = '/comment/index.php';
	
	if(type=='view'){
		var url = '/comment/vindex.php';
	}

	if (!secret)
	{
		secret = 0;
	}
	
	new Ajax.Request(url,
		{
			method: 'get',
			evalJS : true, 
			parameters : '_a=showadd&appid='+appid+'&tid='+tid+'&aimuid='+aimuid+'&secret='+secret+'&j=' + Math.random(),
			onComplete:function(ret){
				var res = ret.responseText;
				eval('res = ' + res + ';');
				if (res['status'] == "succ")
				{
					$(containerid).innerHTML = res['data'];
				}
				
			}
		}
	);
}



function doAddComment(appid,tid,aimuid)
{
	if ($F('comment_content') == "")
	{
		alert("内容太少了  \n\n 再多写一些吧  :)");
		return false;
	}else
	{
		if ($F('comment_content').reallength() > 499)
		{
			alert('内容太多了吧？\n\n 删点内容再提交吧');
			return false;
		}
		var url = '/comment/index.php'; 
		if ($('is_secret').checked == true)
		{
			var is_secret = 1;
		}else
		{
			var is_secret = 0;
		}
		
		new Ajax.Request(url,
			{
				method: 'get',
				parameters : '_a=doadd&content=' + encodeURIComponent($F('comment_content')) + '&appid=' + appid + '&tid=' + tid + '&aimuid=' + aimuid +'&is_secret=' + is_secret +'&j=' + Math.random(),
				
				onComplete:function(ret){
					var res = ret.responseText;
					eval('res = ' + res + ';');
					
					if (res['status'] == 'succ')	// 检验成功
					{	
						$('comment_content').value = "";
						$('is_secret').checked = false;
						var comment_new = $('comment_new_container').innerHTML;
						var comment_new = res['data'] + comment_new;
						$('comment_new_container').innerHTML = comment_new;
					}
					else
					{
						alert(res['desc']);
					}
				}
			}
		);	
	}
}


function showCommentReply(commentId)
{
	if (!commentId)
	{
		alert("没有评论的ID  \n\n 请尝试刷新页面  :)");
		return false;
	}else
	{
		var url = '/comment/index.php'; 
		
		new Ajax.Request(url,
			{
				method: 'get',
				parameters : '_a=showreply&commentid=' + commentId + '&j=' + Math.random(),
				
				onComplete:function(ret){
					var res = ret.responseText;
					eval('res = ' + res + ';');
					
					if (res['status'] == 'succ')	// 检验成功
					{
						$('reply_container_' + commentId).innerHTML = res['data'];
						$('reply_container_' + commentId).style.display = '';
						$('commentReplyInput_' + commentID).focus();
					}
					else
					{
						alert("发生错误 \n\n 请重试一遍   :)");
					}
				}
			}
		);	
	}
}


//提交回复
function doAddReply(commentid)
{
	
	if ($F('commentReplyInput_'+commentid) == "")
	{
		alert("回复的内容太少了  \n\n 再多写一些");
		return false;
	}else
	{
		var url ='/comment/index.php'; 
		
		new Ajax.Request(url,
			{
				method: 'get',
				parameters : '_a=doaddreply&content=' + encodeURIComponent($F('commentReplyInput_'+commentid)) + '&commentid=' + commentid + '&j=' + Math.random(),
				
				onComplete:function(ret){
					var res = ret.responseText;
					eval('res = ' + res + ';');
					
					if (res['status'] == 'succ')	// 检验成功
					{
						var replyContent = $('newreplycontainer_'+commentid).innerHTML;
						$('newreplycontainer_'+commentid).innerHTML =replyContent + res['data'];
						$('reply_container_' + commentid).style.display = "none";
					}
					else
					{
						alert(res['desc']);
					}
				}
			}
		);	
	}
	
}