﻿var isSending = false;
function doQuickContact(AniShow) {
   
        showQuickC();
   

}
function GetRadioButtonValue(id) { //Returns selected value or -1 if no selection
    var radio = document.getElementsByName(id);
    for (var j = 0; j < radio.length; j++) {
        if (radio[j].checked)
           return  radio[j].value;
    }
    return -1;
}
function SetRadioButtonValue(id, val) { //Sets selected value or -1 if no selection
    var radio = document.getElementsByName(id);
    for (var j = 0; j < radio.length; j++) {
        if (radio[j].value == val)
            radio[j].checked = true;
        else
            radio[j].checked = false;
    }
}

function sndReply(results, eventArgs) {
    $("#errQc").hide();
    isSending = false;
    if (results != null) {
        if (results != "") {
            $("#pnlQCSend").hide();
            if (results[0] == "Y") {
                $("#errQc")[0].innerHTML = results;
                $("#errQc").show();
                $("#errQc").animate({
                    backgroundColor: "#fff600"

                }, 500, 'linear',
                    function () {
                        $("#errQc").animate({
                            backgroundColor: "transparent"

                        }, 2000);
                    }
                );

            }
                else if (results == "true") {
                isSending = true;
                $("#errQc")[0].innerHTML = "Message sent.";
                $("#errQc").show();
                setTimeout(function () { $("#pnlQuickContact").dialog("close"); clearQC(); $("#errQc").hide(); isSending = false; }, 2000);
            }
        }
    }
}

function showQuickC(ctlID) {
    $(document).ready(function () {
        $("#pnlQuickContact").dialog("destroy");
        setTimeout(function () {
            $("#pnlQuickContact").dialog({
                title: "Quick Contact Request",
                height: 470,
                width: 405,
                show: "fold",
                hide: "fold",
                modal: true,
                open: function () {
                    $("#pnlQCSend").hide();
                    $("#errQc").hide();
                },
                buttons: {
                    Send: function () {
                        if (!isSending) {
                            isSending = true;
                            $("#errQc").hide();
                            $("#pnlQCSend").show();
                            doSend();
                        }
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                        clearQC();
                    }
                }

            })
        }, 0);
    });
}

