var Wick = Wick || {};
Wick.Selectable = (function(){
  $selectable = $('.js-selectable'),
    selected = 'js-selectable_selected';

  function bindEvents() {
    $selectable.on('click', function(e){
      var $action = $(e.target).closest('a, button, input, .rbn');

      if ($action.length || $(this).hasClass(selected)){
        return;
      }

      $selectable.removeClass(selected);
      $(this).addClass(selected);

      $('.user-address__wrapper .btn-delivery-details').insertAfter('.js-selectable_selected');
    });
  }

  if (!$selectable.length){
    return;
  }

  bindEvents();
})();
