$(function() {
  var controller = new CNTD;

  poll_visitor_rows();

  // Modal Form Processing
  $('#add-user-form').submit(function(e) {
    e.preventDefault();

    hide_add_user_response_messages();
    if (!controller.check_form_with_error_message(["#username", "#password"], ".empty-field-error")) { return; }

    var request_details = {
      type: 'POST',
      url: urlroot + '/user/add_user',
      data: $(this).serialize(),
      success: function(data) { handle_add_user_callback(data); }
    };

    $.ajax(request_details);

    clear_add_user_input_fields();
  })

  // Modal Display Management
  $('#admin-settings-icon').click(function() {
    show_admin_setting_modal();
  })

  $('body').click(function(e) {
    hide_admin_setting_modal_if_visible(e.target);
  })

  $('.modal-side-nav-bar-link').click(function() {
    hide_admin_setting_tabs();
    deactivate_admin_setting_nav_bar_links();

    var e = $(this);
    toggle_selected_tab(e);
  })
})
