/* Minification failed. Returning unminified contents.
(2,10): run-time error CSS1031: Expected selector, found 'changeTZ('
(2,10): run-time error CSS1025: Expected comma or open brace, found 'changeTZ('
(20,10): run-time error CSS1031: Expected selector, found 'refreshGrid('
(20,10): run-time error CSS1025: Expected comma or open brace, found 'refreshGrid('
(32,10): run-time error CSS1031: Expected selector, found 'clearHold('
(32,10): run-time error CSS1025: Expected comma or open brace, found 'clearHold('
(39,10): run-time error CSS1031: Expected selector, found 'setupAppt('
(39,10): run-time error CSS1025: Expected comma or open brace, found 'setupAppt('
(64,10): run-time error CSS1031: Expected selector, found 'setTime('
(64,10): run-time error CSS1025: Expected comma or open brace, found 'setTime('
(74,10): run-time error CSS1031: Expected selector, found 'showTimes('
(74,10): run-time error CSS1025: Expected comma or open brace, found 'showTimes('
(92,10): run-time error CSS1031: Expected selector, found 'CallMeSetupHeldDone('
(92,10): run-time error CSS1025: Expected comma or open brace, found 'CallMeSetupHeldDone('
 */

function changeTZ(zone, str) {

    $('#_hidTZ').val(zone);

    $.post("/CallMeAppt/changeTZ", {
        "tz": zone,
        '__RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
    }, function (data) {

        $("#divGrid").html(data);

        $("#spTZPopup").html(str);
        $("#divCurTZ").html(str);

    });

}

function refreshGrid() {
    $.post("/CallMeAppt/changeTZ",
        {
            "tz": $('#_hidTZ').val(),
            '__RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
        }, function (data) {

            $("#divGrid").html(data);

        });
}

function clearHold(holdKey) {
    $.post("/CallMeAppt/clearAnyHeld", { "holdKey": $('#holdKey').val() }, function (data) {

    });
    return false;
}

function setupAppt(holdKey) {
    $.post("/CallMeAppt/setup4Entry",
        {
            "token": $('#_hidAppt').val(),
            "holdKey": holdKey,
            '__RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
        },
        function (data) {

            $("#modTimeConfirm").removeClass("fade").modal("hide");
            if (data.length === 0) {

                $('#modNotAvail').modal();
            }
            else {

                $("#divModEntryHdr").html(data);
                $("#hidTokenID").val($('#_hidAppt').val());
                $('#modEntry').modal();
            }

        });

}

function setTime(value, longD) {

    $('#divselectedtime').html(longD);
    $('#_hidAppt').val(value);

    $("#modTimes").removeClass("fade").modal("hide");
    $('#modTimeConfirm').modal();

}

function showTimes(str) {

    if (str === null || str.length === 0)
        return true;

    $.post("/CallMeAppt/getCallbackTimes",
        {
            "times": str,
            '__RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
        },
        function (data) {

            $("#modTimes").html(data);
            $('#modTimes').modal();

        });
}

function CallMeSetupHeldDone(data) {
    if (data === "dup") {
        $("#modEntry").removeClass("fade").modal("hide");
        $('#modEmailAlready').modal();
        clearHold("");
    }
    else if (data === "invalid") {
        $("#modEntry").removeClass("fade").modal("hide");
        $('#modNotAvail').modal();
    }
    else {
        window.location = data;
    }

}
