$(function() {
    $('#group-select').change(function() {
        $('#group-form').submit();
    });
});

/* This stops IE7's nasty caching behavior. As the server has to regenerate the
data anyway, this won't make a performance difference for other clients. */
jQuery.ajaxSetup({ cache: false});

function stripCommas(numString) {
    var re = /,/g;
    return numString.replace(re,"");
}

// makes a form display a confirmation dialog before actually submitting
// form_selector - the form to create a confirmation dialog for
// dialog_selector - the dialog div to display
// true_title - button title to submit the form
// false_title - button title to cancel the form's submission
function confirmWithDialog(form_selector, dialog_selector, true_title, false_title)
{
    // submit if true is clicked, otherwise close the dialog
    var buttons = {};
    buttons[true_title] = function() { $(form_selector).submit(); };
    buttons[false_title] = function() { $(this).dialog('close'); };
    
    // bind the dialog
    $(dialog_selector).dialog({
        autoOpen: false,
        buttons: buttons,
        modal: true,
        overlay: {
            opacity: 0.75,
            background: "black"
        },
        resizable: false,
        width: 400
    });
    
    // override the form's click event handling, submit is handled by the dialog
    $(form_selector + ' input[type=submit]').click(function() {
        $(dialog_selector).dialog('open');
        return false;
    });
}
