(function(){ function open_create_institution_modal(evt) { evt.preventDefault(); jQuery.get("/plugin/mpog_software/create_institution", function(response){ jQuery("#institution_dialog").html(response); set_events(); jQuery("#institution_dialog").dialog({ modal: true, width: 500, height: 530, position: 'center', close: function() { jQuery("#institution_dialog").html(""); jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); } }); }); } function show_public_institutions_fields() { jQuery(".public-institutions-fields").show(); jQuery("label[for='institutions_acronym']").html(jQuery("#acronym_translate").val()); } function show_private_institutions_fields() { jQuery(".public-institutions-fields").hide(); jQuery("label[for='institutions_acronym']").html(jQuery("#fantasy_name_translate").val()); jQuery("#institutions_governmental_power option").selected(0); jQuery("#institutions_governmental_sphere option").selected(0); } function get_selected_institution_type() { var radio_buttons = jQuery("input[type='radio'][name='type']"); var type = ""; for( var i = 0; i < radio_buttons.length; i++ ) { if( radio_buttons[i].checked ) { type = radio_buttons[i].value; break; } } return type; } function get_post_data() { return { community : { name : jQuery("#community_name").val()}, governmental : { power : jQuery("#institutions_governmental_power").selected().val(), sphere : jQuery("#institutions_governmental_sphere").selected().val() } , institution : { cnpj: jQuery("#institutions_cnpj").val(), type: get_selected_institution_type(), acronym : jQuery("#institutions_acronym").val() }, authenticity_token : jQuery("input[name='authenticity_token']").val(), recaptcha_response_field : jQuery('#recaptcha_response_field').val(), recaptcha_challenge_field : jQuery('#recaptcha_challenge_field').val() } } function success_ajax_response(response) { close_loading(); if(response.success){ jQuery("#institution_dialog").html("