var elite_security_guard_keyboard_navigation_loop = function (elem) {
  var elite_security_guard_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
  var elite_security_guard_firstTabbable = elite_security_guard_tabbable.first();
  var elite_security_guard_lastTabbable = elite_security_guard_tabbable.last();
  elite_security_guard_firstTabbable.focus();

  elite_security_guard_lastTabbable.on('keydown', function (e) {
    if ((e.which === 9 && !e.shiftKey)) {
      e.preventDefault();
      elite_security_guard_firstTabbable.focus();
    }
  });

  elite_security_guard_firstTabbable.on('keydown', function (e) {
    if ((e.which === 9 && e.shiftKey)) {
      e.preventDefault();
      elite_security_guard_lastTabbable.focus();
    }
  });

  elem.on('keyup', function (e) {
    if (e.keyCode === 27) {
      elem.hide();
    };
  });
};