var hideEventSelectorExecutor;
var eventsSelectDivId = "eventSelectDiv";

//gets the value of a radio field
function $RF(el, radioGroup) {
    if ($(el).type && $(el).type.toLowerCase() == 'radio') {
        radioGroup = $(el).name;
        el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }
    var checked = $(el).getInputs('radio', radioGroup).find(
            function(re) {
                return re.checked;
            }
            );
    return (checked) ? $F(checked) : null;
}

//hides hidden form elements.  Some cases it's hard to set style of hidden elements (GSP checkboxes)
function hidehidden() {
    var inputs = document.getElementsByTagName("input");
    if (inputs) {
        for (var i = 0; i < inputs.length; i++) {
            var input = inputs[i];

            if ("hidden" == input.type) {
                input.style.display = "none";
            }
        }
    }
}

//show the event select menu
function showEventsMenu(ajaxEndpt) {
    //show the div
    Effect.BlindDown(eventsSelectDivId, { duration: 0 });
    //get the contents for the div
    new Ajax.Updater(eventsSelectDivId, ajaxEndpt, {onSuccess: function() {
        //do nothing for now...
    }});
    return false;
}

//start the timed hide of the event selector
function startEventsSelectDivHide() {
    hideEventSelectorExecutor = new PeriodicalExecuter(function() {
        $(eventsSelectDivId).hide();
        hideEventSelectorExecutor.stop();
    }, .6);
}

//cancel the timed hide of the event selector
function cancelEventsSelectDivHide() {
    if (hideEventSelectorExecutor != null) {
        hideEventSelectorExecutor.stop();
    }
}