﻿
function pageLoad() {
    //js logic here, runs on every async postback (and on initial load)
    $(document).ready(function() {
        $(".cascade").each(function() {
            $(this).bind("change", function() {
                $("#pnlVolunteers, #pnlSubmit").hide();
            });
        });


        $("#ctl00_ContentPlaceHolder1_FormView1_ddActShifts").bind("change", function(args) {
            var activityId = this.options[this.selectedIndex].value;
            var $panels = $("#pnlVolunteers, #pnlSubmit");
            if (activityId != '') {
                GetRemainingVolunteers(activityId);
                $panels.show();
                $("a[id*='_LinkButton1']").removeAttr("disabled");
            }
            else {
                $panels.hide();
                $("a[id*='_LinkButton1']").attr("disabled", "disabled");
            }
        });

    });

    function GetRemainingVolunteers(activityId) {
        var dataVal = "{activityId : " + activityId + "}"
        $.ajax({
            type: "POST",
            url: "ActivityService.asmx/GetRemainingVolunteers",
            data: dataVal,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                $("#tbVolunteersNeeded").val(msg.d);
            }
        });
    };
}        



