While the original post with the javascript function to display "All attachments" on page load is almost three years, this was only now updated to optionally collapse the the attachments. Thanks for the request. :)
The linked blog post also contains a small documentation how to use the Category and ElementName field of the SQL statements in the related attachments.
READ MORE: here.