function QueryComment(URL)
{
	var json = new Array();
	$('#CommentHtml').html('<table class="TabAll"><tr class="Row0" align=center><td><br><b><font color="#339900">评论加载中，请稍后....</font></b><br><br></td></tr></table>');
	$.getJSON(
		URL+'&'+GetTime(),
		function(json)
		{
			try
			{
				var CommentHtml = '';
				var Tpl = '';
				$.each(json.Data, function(i,item){
					Tpl = '<tr class="Row0"><td>&nbsp;第 <b>#Floor#</b> 楼&nbsp;&nbsp;由 <u><a href="#UserHost#" target="_blank"><b>#NiName#</b></a></u> 于 <font color="#3300FF">#CommentTime#</font> 发表  #EditURL#  #DeleteURL#</td></tr><tr class="Row0"><td height=70 width=380 valign="top">&nbsp;#CommentContent#</td></tr>';
					Tpl = Tpl.replace('#Floor#'          , item.Floor);
					Tpl = Tpl.replace('#UserHost#'       , item.UserHost);
					Tpl = Tpl.replace('#NiName#'         , item.NiName);
					Tpl = Tpl.replace('#CommentTime#'    , item.CommentTime);
					Tpl = Tpl.replace('#CommentContent#' , item.CommentContent);
					Tpl = Tpl.replace('#EditURL#'        , item.EditURL=='Y' ? '<img src="/images/btn_edit.gif" alt="编辑评论" border="0" style="cursor:pointer;" onclick="EditComment(\''+CommentObjectURL+'&EditID='+item.CommentID+'\');">' : '&nbsp;');
					Tpl = Tpl.replace('#DeleteURL#'      , item.DeleteURL=='Y' ? '<img src="/images/btn_delete.gif" alt="删除评论" border="0" style="cursor:pointer;" onclick="RemoveComment(\''+CommentObjectURL+'&RemoveID='+item.CommentID+'\');">' : '&nbsp;');
					CommentHtml = CommentHtml + Tpl;
				});
				$('#CommentHtml').html('<table class="TabAll">'+CommentHtml+'</table>');
			}
			catch (e)
			{
				$('#CommentHtml').html('<table class="TabAll"><tr class="Row0" align=center><td><br><b>'+NoCommentTip+'</b><br><br></td></tr></table>');
			}
		}
	);
}
function EditComment(URL)
{
	alert('该功能尚未开放！');
}
function RemoveComment(URL)
{
	if(confirm('确信要删除该评论？'))
	{
		$.get(
			URL,
			function(data)
			{
				QueryComment(GetCommentURL);
				alert(data);
			}
		); 
	}
}
function addSmile(val)
{
	var CommentContent = $("#CommentContent").val();
	CommentContent += "[Cool" + val + "]";
	$("#CommentContent").val(CommentContent);
}

function Digg(URL, ObjectID, Score)
{
	$.get(
		URL+'&'+GetTime(),
		function(data)
		{
			LastScore = Score+1
			if(data==1) $('#Digg-'+ObjectID).html('<b>'+LastScore+'</b>谢谢！');
			else alert('您已经投票过了！谢谢！');
		}
	); 
}
function SubmitArticleComment()
{
	if($("#Comment-ArticleID").val()=='')
	{
		alert('无效文章编号！');
		return false;
	}
	else if($("#Comment-UserID").val()=='')
	{
		alert('所以属于用户编号无效！');
		return false;
	}
	else if($("#CommentContent").val()=='')
	{
		alert('请输入评论内容！');
		$("#CommentContent").focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: PostCommentURL,
		dataType: "html",
		data: "ArticleID="+$("#Comment-ArticleID").val()+"&SiteID="+$("#Comment-UserID").val()+"&CommentContent="+$("#CommentContent").val(),
		error: function(d) {alert("评论发表失败！");},
		beforeSend: function(){$("#Comment-Submit").attr('disabled',' true');$("#Comment-Tip").val('评论发表中，请等待...');},
		complete:function(){$("#Comment-Submit").removeAttr("disabled");$("#Comment-Tip").val('');},
		success:
		function(data)
		{
			QueryComment(GetCommentURL);
			$("#CommentContent").val('');
			//alert(data);
			location.href="#LastComment";
		}
	});
}
function SubmitPhotoComment()
{
	if($("#Comment-PhotoID").val()=='')
	{
		alert('无效相片编号！');
		return false;
	}
	else if($("#Comment-UserID").val()=='')
	{
		alert('所以属于用户编号无效！');
		return false;
	}
	else if($("#CommentContent").val()=='')
	{
		alert('请输入评论内容！');
		$("#CommentContent").focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: PostCommentURL,
		dataType: "html",
		data: "PhotoID="+$("#Comment-PhotoID").val()+"&SiteID="+$("#Comment-UserID").val()+"&CommentContent="+$("#CommentContent").val(),
		error: function(d) {alert("评论发表失败！");},
		beforeSend: function(){$("#Comment-Submit").attr('disabled',' true');$("#Comment-Tip").val('评论发表中，请等待...');},
		complete:function(){$("#Comment-Submit").removeAttr("disabled");$("#Comment-Tip").val('');},
		success:
		function(data)
		{
			QueryComment(GetCommentURL);
			$("#CommentContent").val('');
			//alert(data);
			location.href="#LastComment";
		}
	});
}
function SubmitMusicComment()
{
	if($("#Comment-MusicID").val()=='')
	{
		alert('无效音乐编号！');
		return false;
	}
	else if($("#Comment-UserID").val()=='')
	{
		alert('所以属于用户编号无效！');
		return false;
	}
	else if($("#CommentContent").val()=='')
	{
		alert('请输入评论内容！');
		$("#CommentContent").focus();
		return false;
	}

	$.ajax({
		type: "POST",
		url: PostCommentURL,
		dataType: "html",
		data: "MusicID="+$("#Comment-MusicID").val()+"&SiteID="+$("#Comment-UserID").val()+"&CommentContent="+$("#CommentContent").val(),
		error: function(d) {alert("评论发表失败！");},
		beforeSend: function(){$("#Comment-Submit").attr('disabled',' true');$("#Comment-Tip").val('评论发表中，请等待...');},
		complete:function(){$("#Comment-Submit").removeAttr("disabled");$("#Comment-Tip").val('');},
		success:
		function(data)
		{
			QueryComment(GetCommentURL);
			$("#CommentContent").val('');
			//alert(data);
			location.href="#LastComment";
		}
	});
}
function QueryRelated(URL)
{
	var json = new Array();
	$('#RelatedHtml').html('<table class="TabAll"><tr class="Row0" align=center><td><br><b><font color="#339900">加载中，请稍后....</font></b><br><br></td></tr></table>');
	$.getJSON(
		URL+'&CharSet=UTF-8&'+GetTime(),
		function(json)
		{
			try
			{
				var RelatedHtml = '';
				var Tpl = '';
				$.each(json.Data, function(i,item){
					Tpl = '<tr class="Row0 f14"><td>&nbsp;&nbsp;<A class="black" title="今日点击：#TodayClick#&nbsp;&nbsp;历史点击：#ClickTotal# 发布时间：#PublishDate#&nbsp;&nbsp;#PublishTime#"  HREF="#ViewURL#" target=_blank>#Title#</a></td><td align=left width=30%>#PublishDate#&nbsp;|&nbsp;<a class=blue href="#UserHost#" target=_blank>#PublishNiName#</a></td></tr>';
					Tpl = Tpl.replace('#TodayClick#'     , item.TodayClick);
					Tpl = Tpl.replace('#ClickTotal#'     , item.ClickTotal);
					Tpl = Tpl.replace('#PublishDate#'    , item.PublishDate);
					Tpl = Tpl.replace('#PublishTime#'    , item.PublishTime);
					Tpl = Tpl.replace('#PublishDate#'    , item.PublishDate);
					Tpl = Tpl.replace('#PublishNiName#'  , item.PublishNiName);

					if(parseInt(item.ArticleID)>0)
					{
						Tpl = Tpl.replace('#Title#'        , item.ArticleTitle);
						Tpl = Tpl.replace('#ViewURL#'      , item.ViewArticleURL);
						Tpl = Tpl.replace('#UserHost#'      , item.SiteArticleURL);
					}
					else if(parseInt(item.PhotoID)>0)
					{
						Tpl = Tpl.replace('#Title#'        , item.PhotoTitle);
						Tpl = Tpl.replace('#ViewURL#'      , item.ViewPhotoURL);
						Tpl = Tpl.replace('#UserHost#'      , item.UserHost);
					}
					RelatedHtml = RelatedHtml + Tpl;
				});
				$('#RelatedHtml').html('<table class="TabAll">'+RelatedHtml+'</table>');
			}
			catch (e)
			{
				$('#RelatedHtml').html('<table class="TabAll"><tr class="Row0 f14" align=center><td><br><b>尚无相关内容</b><br><br></td></tr></table>');
			}
		}
	);
}