$(function() {
  
  $('#centered #signup').corner('8px');
  
  $('.show-extended-card').click(function() {
    $(this).next().slideToggle();
    return false;
  });
  
  $('#q').labelify({ text: 'label', labelledClass: 'highlight' });
  
  $('.thumb .toggle-edit').livequery(function() {
    $(this).click(function() {
      $(this).parent().siblings('.edit').slideToggle();
      return false;
    });
  });
  
  $('#oauth-register a').livequery(function() {
    $(this).click(function() {
      $('#add-app').toggle();
      return false;
    });
  });
  
  /* User achievements */
  $('.achievements dd li').simpletooltip();
  
  
  /* Category selection */
  $('.category-selection').livequery(function() {
    var $selectors_container = $(this);
    var $selectors = $selectors_container.find('select');
    $selectors.change(function() {
      var categories = $selectors.map(function() {
        return this.value;
      }).get().join(',');
      $selectors_container.find('.category-list:first').val(categories);
    });
    
  });
  
});

function oauthLoading() {
  $('#oauth-app input[type="submit"]').addClass('disabled');
  $('#oauth-app .spinner').show();
}

function oauthComplete() {
  $('#oauth-app .spinner').hide();
  $('#oauth-app input[type="submit"]').removeClass('disabled');
}
