// misc site-wide jquery 

$(function() {
  if ( $('#errorExplanation').length ) {
    $('#errorExplanation').addClass('off_state');
    $('#collected_errors').removeClass('off_state').find('.errors_wrap')
      .append($('#errorExplanation').html());
  }
  // put this in head?:
  $('form .cursor input').focus();
  $('input:text, textarea').hint();
  $('.add_another a').click(function() {
    $(this).parents('.add_another').children('*').toggleClass('off_state');
    return false;
  });
  // remove prev/next carets:
  if ( $("[id$='_pagination']").length ) {
    $(this).find('.prev_page').text('Previous');
    $(this).find('.next_page').text('Next');
  }
}); 

$.fn.digits = function() { 
  return this.each(function() { 
    $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
  })
}



