// This is used for full, interactive forms
// use fancyForm full, usable forms.  This plugin communicates with the user entirely through popups, where fancyForm
// modifies the form to show what the user should change
(function($) {
    $.fn.fancyAction = function( options ) {

        // search me as to why, but json has to be set in each the
        // ajax/ajaxSubmit calls manually instead of in the defaults.  It's
        // 4:50AM so I don't care right now.

        var defaults = {
            type: 'GET',
            success: function( responseText ) {
                $.jGrowl( responseText.Message );
                return options.postSuccess( responseText );
            },
            postSuccess: function( responseText ) {}
        };

        var options = $.extend( defaults, options );

        if( $(this).attr('href') ) {
            $.ajax({
                url: $(this).attr('href'),
                success: options.success,
                cache: false,
                dataType: 'json'
            });

        } else if( $(this).attr('action') ) {
            $(this).ajaxSubmit({
                success: options.success
                , type: options.type
                , dataType: 'json'
            });
        }

    };

})(jQuery);

