var coupon_flash_deals_keyboard_navigation_loop = function (elem) {
  var coupon_flash_deals_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
  var coupon_flash_deals_firstTabbable = coupon_flash_deals_tabbable.first();
  var coupon_flash_deals_lastTabbable = coupon_flash_deals_tabbable.last();
  coupon_flash_deals_firstTabbable.focus();

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

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

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