function commentService() {

    this.addAfaFbComment = function(contentid, fbuid, comment, postedtofacebook, onSuccess, onError) {
        var self = this;
        var posted = false;

        if (postedtofacebook) {
            posted = "true";
        } else {
            posted = "false";
        }
        
        $.ajax({
            type: "POST",
            url: "/ajax/commentService.asmx/addAfaFbComment",
            data: "{ contentid: " + contentid + ", fbuid: " + fbuid + ", comment: '" + comment + "', postedtofacebook: " + posted + " }",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                var result = msg.d
                // Check to see if the request was successful.
                if (result.success) {
                    // pass the result off to the callback.
                    onSuccess(result);
                } else if (onError) {
                    // The call was not successful - call the error function.
                    //onError(result.errors);
                    onError(msg);
                }
            },
            error: AjaxFailed
        });

    }

    this.getAfaFbApprovedComments = function(contentid, onSuccess, onError) {
        var self = this;

        $.ajax({
            type: "POST",
            url: "/ajax/commentService.asmx/getAfaFbApprovedComments",
            data: "{ contentid: " + contentid + " }",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                var result = msg
                // Check to see if the request was successful.
                if (result) {
                    // pass the result off to the callback.
                    onSuccess(result);
                } else if (onError) {
                    // The call was not successful - call the error function.
                    //onError(result.errors);
                    onError(msg);
                }
            },
            error: AjaxFailed
        });

    }
    
    

    // alert user if ajax request failed
    function AjaxFailed(result) {
        alert(result.status + ' ' + result.statusText);
    }  
}
