﻿function ReviewVote(reviewId, helpful) {
    $.ajax({
        url: '/review~vote',
        data: { ReviewId: reviewId, helpful: helpful },
        success: function (R) {
            if (R == 'True') {
                LoadReviewActions(reviewId);
                AlertMsg('XP given to review writer!');
            }
            else if (R == 'False') {
                AlertMsg('You\'ve already voted on this review.');
            }
            else {
                parent.location = '/site~register';
            }
        },
        error: function (x) { AlertError(x) }
    });
}
 
function LoadReviewActions(reviewId) {
    $('#divReviewActions' + reviewId).html('<img src="/img/icn/spin.gif" />');
    $.get('/review~GetActionsHTML', { ReviewId: reviewId }, function (R) { $('#divReviewActions' + reviewId).html(R); });
}
function RemoveReview(reviewId) {
    if (confirm('Remove this review forever?')) {
        $.get('/review~RemoveReview', { ReviewId: reviewId },
    function (R) {
        if (NextReview) {
            NextReview(1);
        }
    });
    }
}

function ReviewResponse(reviewId, response) {
    $.ajax({
        url: "/Review~Respond",
        data: { ReviewId: reviewId, Response: response },
        success: function () {
            CloseModal();
            parent.NextReview(1);
        },
        error: function (x) { AlertError(x) }
    });
}