﻿// -------- player error handler helper functions ------- //

// display an authentication error
function player_show_authenticationError() {
    $(document).bind('afterReveal.facebox', function() {
        $("#facebox_footer").css({ "display": "none" });
    });

    $.facebox({ div: "#player_authentication_error_dialog" });
}


// -- player jquery error handler helper functions -- //

// handle an ajax error returned by jQuery's $.ajax function
function player_jQuery_ajaxRequestFailed(XMLHttpRequest, textStatus, errorThrown) {

    if ((XMLHttpRequest) &&
       ((XMLHttpRequest.status == g_httpStatusCode_unauthorised) ||
        (XMLHttpRequest.status == g_httpStatusCode_forbidden))) {
        player_show_authenticationError();
    }
}


// -------- player extjs error handling ------- //

// handle an ajax load failure
function player_extJs_ajaxLoadFailed(proxy, options, response, error) {

    if (response.status === 0) {
        // drop on floor
    }
    else if ((response.status == g_httpStatusCode_unauthorised) ||
             (response.status == g_httpStatusCode_forbidden)) {
        player_show_authenticationError();
    }
    else {
        // report the error back to the server
        ajax_logError(response, proxy.conn.url, proxy.options, error);
    }
}