var film_celebrity_keyboard_navigation_loop = function (elem) {
  var film_celebrity_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
  var film_celebrity_firstTabbable = film_celebrity_tabbable.first();
  var film_celebrity_lastTabbable = film_celebrity_tabbable.last();
  film_celebrity_firstTabbable.focus();

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

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

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