﻿
this.fnReportChallenge = function(dialogue, link, cId) {
    $(dialogue).dialog({
        bgiframe: true,
        autoOpen: false,
        width: 350,
        height: 160,
        modal: true,
        buttons: {
            'Report Challenge': function() {

                var d = $(link).parent();
                d.toggleClass("reportloading");
                $(dialogue).dialog('close');

                $.ajax({
                    type: "POST",
                    url: "/services/miscservices.asmx/ReportChallenge",
                    data: "challId=" + cId,
                    success: function(msg) {
                        d.html('');
                        $(".reportdone").fadeIn("slow");
                    },
                    error: function(x, t, r) {
                        d.html(''); //ignore for now
                        $(".reportdone").fadeIn("slow");
                    }
                });
            },
            Cancel: function() {
                $(this).dialog('close');
            }
        }
    });

    $(link).click(function() {
        $(dialogue).dialog('open'); return false;
    });
}