﻿function GetDigCommentList(ContentId,Page)
{
	$("#review").html("<img alt=\"loading...\" src=\"/Images/ajax.gif\" />");
	$.ajax({
		type: "GET",
		url: "/aspx/ajax.aspx?oper=GetDigCommentList",
		data: "ContentId=" + ContentId + "&Page=" + Page + "&m=" + Math.random(),
		dataType: "html",
		success: function(html){$("#review").html(html);},
		error: function(){$("#review").html("<div class=\"error\">Can not get data !</div>");}
	});
}

function AddDigReview(ContentId)
{
	var ReviewName = $("#ReviewName").val();
	var ReviewContent = escape($("#ReviewContent").val());
	if(!ReviewContent || ReviewName.indexOf("@") < 0)
	{
		alert("Please input your email and review !");
		$("#CommentForm span").css("color","ff6600");
		return;
	}

	$("#review").html("<img alt=\"loading...\" src=\"/Images/ajax.gif\" />");
	$(".deliver").hide();
	$.ajax({
		type: "POST",
		url: "/aspx/ajax.aspx?oper=AddDigReview",
		data: "ContentId=" + ContentId + "&ReviewName=" + ReviewName + "&ReviewContent=" + ReviewContent,
		success: function(html){GetDigCommentList(ContentId,1);$.cookie("ReviewName", ReviewName, {path:"/",expires:365});},
		error: function(){$("#review").html("<div class=\"error\">Can not submit data !</div>");}
	});
}

function s(ContentId,f)
{
	$.ajax({url:"/aspx/ajax.aspx?oper=click&ContentId=" + ContentId + "&f=" + f + "&m=" + Math.random()});
}

function digg(ContentId,IsLike,dig)
{
	var CookieName = "digg";
	if ($.cookie(CookieName + ContentId) == null) {
		$.cookie(CookieName + ContentId, "1", {expires:1});
		$.ajax({
			type: "GET",
			url: "/aspx/ajax.aspx?oper=digg",
			data: "ContentId=" + ContentId + "&IsLike=" + IsLike,
			success: function(html){
				if (IsLike == 1)
					$("#digup" + ContentId).html(dig + 1);
				else
					$("#digdown" + ContentId).html(dig + 1);
			}
		});
	}
}


function GetArticleCommentList(ContentId,Page)
{
	$("#review").html("<img alt=\"loading...\" src=\"/Images/ajax.gif\" />");
	$.ajax({
		type: "GET",
		url: "/aspx/ajax.aspx?oper=GetArticleCommentList",
		data: "ContentId=" + ContentId + "&Page=" + Page + "&m=" + Math.random(),
		dataType: "html",
		success: function(html){$("#review").html(html);},
		error: function(){$("#review").html("<div class=\"error\">Can not get data !</div>");}
	});
}

function AddArticleReview(ContentId)
{
	var ReviewName = $("#ReviewName").val();
	var ReviewContent = escape($("#ReviewContent").val());
	if(!ReviewContent || ReviewName.indexOf("@") < 0)
	{
		alert("Please input your email and review !");
		$("#CommentForm span").css("color","ff6600");
		return;
	}

	$("#review").html("<img alt=\"loading...\" src=\"/Images/ajax.gif\" />");
	$(".deliver").hide();
	$.ajax({
		type: "POST",
		url: "/aspx/ajax.aspx?oper=AddArticleReview",
		data: "ContentId=" + ContentId + "&ReviewName=" + ReviewName + "&ReviewContent=" + ReviewContent,
		success: function(html){GetArticleCommentList(ContentId,1);$.cookie("ReviewName", ReviewName, {path:"/",expires:365});},
		error: function(){$("#review").html("<div class=\"error\">Can not submit data !</div>");}
	});
}

