﻿$(document).ready(function () {
    $(".leaguedomain").change(function () {
        // Pass the selected leagueID to a method in the Ajax handler. Then refresh the current page.
        SetSessionVariables("AjaxHandler.ashx?action=setLeagueID&LeagueID=" + $(this).val());
    });

    $(".divisiondomain").change(function () {
        // Pass the selected divisionID to a method in the Ajax handler. Then refresh the current page.
        SetSessionVariables("AjaxHandler.ashx?action=setDivisionID&DivisionID=" + $(this).val());
    });

    $(".seasondomain").change(function () {
        // Pass the selected seasonID to a method in the Ajax handler. Then refresh the current page.
        SetSessionVariables("AjaxHandler.ashx?action=setSeasonID&SeasonID=" + $(this).val());
    });
});

function SetSessionVariables(url) {
    $.ajax({
        type: "GET",
        url: url,
        data: null,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            if (!(result == null)) {
                if (result == true) {
                    window.location.reload();
                }
            }
        }
    });
}
