/* Minification failed. Returning unminified contents.
(7,26): run-time error CSS1031: Expected selector, found '='
(7,26): run-time error CSS1025: Expected comma or open brace, found '='
(125,1): run-time error CSS1019: Unexpected token, found '$'
(125,2): run-time error CSS1019: Unexpected token, found '('
(125,9): run-time error CSS1031: Expected selector, found ')'
(125,9): run-time error CSS1025: Expected comma or open brace, found ')'
(127,2): run-time error CSS1019: Unexpected token, found ')'
 */
/* ============================================================
 *
 * js/app/artisticcompany/list.js
 *
 * ========================================================== */

var artisticcompany_list = {

    fnSetActivePage: function (e) {
        if (e != "All") {
            $("#__filter").val(e);
            $("#btn-default-" + e.toLowerCase()).attr("style", "background:#fff600; color:black; font-weight:600;");
            $("#page__" + e.toLowerCase()).fadeIn(500);
        }
    },

    fnRemoveActivePage: function (e) {
        $("#btn-default-" + e.toLowerCase()).removeAttr("style");
        $("#page__" + e.toLowerCase()).hide();
    },

    fnGoToFilter: function (e) {
        artisticcompany_list.fnRemoveActivePage($("#__filter").val());
        artisticcompany_list.fnGetComposerByLastName(e, false);
    },

    fnGetArtisticCompanyName: function (e) {
        $.ajax({
            url: window.location.origin + "/ArtisticCompany/AjxGetArtisticCompanyName",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken(),
                filter: e
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $("#data-container").html(result);
                var _pagetotal = $("#__pagetotal").val();
                artisticcompany_list.fnSetActivePage(e);
                artisticcompany_list.fnInitializePagination(_pagetotal);

                $("button[class*=' btn-default']").removeClass("active");
                $(".btn-default-" + e).addClass("active");

                $("#data-container").fadeIn(500);
                $("#divfilter").fadeIn(500);
                if (_pagetotal != "0") {
                    $("#divpaging").fadeIn(500);
                }
                else {
                    $("#divpaging").hide();
                }

                $("#divWaiting").hide();
            },
            error: function (xhr, ajaxOptions, thrownError) {
                $("#data-container").html("");
            }
        });
    },

    fnGetAllArtisticCompany: function () {
        $.ajax({
            url: window.location.origin + "/ArtisticCompany/AjxGetAllArtisticCompany",
            data: {
                __RequestVerificationToken: common_helpers.fnGetToken()
            },
            type: "POST",
            cache: false,
            success: function (result) {
                $("#data-container").html(result);
                var _pagetotal = $("#__pagetotal").val();
                artisticcompany_list.fnSetActivePage("All");
                artisticcompany_list.fnInitializePagination(_pagetotal);

                $("#data-container").fadeIn(500);
                $("#divfilter").fadeIn(500);
                if (_pagetotal != "0") {
                    $("#divpaging").fadeIn(500);
                }
                else {
                    $("#divpaging").hide();
                }

                $("#divWaiting").hide();
            },
            error: function (xhr, ajaxOptions, thrownError) {
                $("#data-container").html("");
            }
        });
    },

    fnSetLetterFilter: function (e) {
        $("button[class*=' btn-default']").removeClass("active");
        $(".btn-default-" + e).addClass("active");
        $("#letterFilter").html(e.toUpperCase())
    },

    fnInitializePagination: function (e) {
        $('#pagination-container').pagination({
            dataSource: common_helpers.fnCreateNumberArray(e),
            pageSize: 1,
            prevText: "PREVIOUS",
            nextText: " NEXT",
            autoHidePrevious: true,
            autoHideNext: true,
            callback: function (data, pagination) {
                artisticcompany_list.fnSetPageContent(data);
            }
        });

    },

    fnSetPageContent: function (e) {
        var _oldpage = $("#__page").val();
        if (_oldpage != e) {
            $("#page__" + _oldpage).hide();
            $("#page__" + e).show();
            $("#__page").val(e);
        }
    }

};

$(window).ready(function () {
    artisticcompany_list.fnGetAllArtisticCompany();
});
