﻿$(document).ready(function() {

    buildArtistListing(0, 0);

    $(".ArtistsRowDropDown").change(function() {

        buildArtistListing(this.value, 0);
    });

});

function buildArtistListing(MediumID, PageIndex) {

    $.ajax({

        type: "POST",
        url: "Default.aspx/BuildArtistListing",
        data: "{'MediumID':'" + MediumID + "','PageIndex':'" + PageIndex + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {

            $('#ArtistListing').html(msg.d);

            $('.ArtistsArtistRow').each(function(i) {

                var TheArtistID = 0;
                TheArtistID = $(this).attr("rel");

                var TheMediumID = $('.ArtistsRowDropDown').val();

                BuildArtistRows(TheArtistID);

            });

        }
    });

}




function BuildArtistRows(ArtistID) {

    $.ajax({

        type: "POST",
        url: "Default.aspx/BuildArtistRow",
        data: "{'ArtistID':'" + ArtistID + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {

            $('.ArtistsArtistRow:[rel=' + ArtistID + ']').html(msg.d);

        }
    });

}