﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
$(document).ready(function() {

    $(".reportAbuseForm").hide();
    $(".abuseReportReciept").hide();
    $(".abuseReportError").hide();

    $("a.showReportAbuseForm").click(function(event) {
    var anchor = $(event.currentTarget);
        var form = anchor.parent().parent().next().find(".reportAbuseForm");
        anchor.hide("fast", function() { form.show("fast"); });
        event.preventDefault();
    });

    $("button.reportAbuse").click(function(event) {
        var button = $(event.currentTarget);
        var reportThisKey = button.siblings(".reportThisKey").val();
        var abuseDescription = button.siblings(".abuseDescription").val();

        var requestBatch = new RequestBatch();
        var action = createAction(reportThisKey, abuseDescription); // Specific implementations provided elsewhere
        requestBatch.AddToRequest(action);
        requestBatch.BeginRequest(serverUrl, function(responseBatch) {
            var toShow = "abuseReportReciept";
            if (responseBatch == null ||
                responseBatch.Messages == null ||
                responseBatch.Messages.length == 0 ||
                responseBatch.Messages[0].Message != "ok") {
                toShow = "abuseReportError";
            }
            button.parent().hide("fast", function() { button.parent().siblings("." + toShow).show("fast"); });
        });
    });
});