/**
 * Clear Channel utilities library.
 *
 * Author: rramaiah
 * Created on: Jan 27, 2009
 */

/**
 * Handles the "Report Offensive Content" link.
 */
function report_offensive_comment(btn, nodeId, wsUrl) {
    if (btn.value == 'Reported') {
        alert('The content has already been reported.');
        return false;
    }

    if (!confirm('Are you sure you want to report this content as offensive?')) {
        return false;
    }

    YAHOO.util.Connect.asyncRequest('GET', wsUrl + '/' + nodeId, {
        success: function (o) {
            if (o.responseText.indexOf('OK') == 0) {
                alert('The content has been reported.');
            }
            else {
                alert('An error occurred reporting this content!');
            }
        },

        failure: function (o) {
            alert('Ajax request failed!');
        }
    });

    btn.value = 'Reported';

    return false;
}