Wow, 4.0.5 is really old so none of the current set of stuff would help (for 5.1.0 I would recommend Eclipse + JBoss Tools and looking over the many good tutorials that come with JBoss Tools). For 4.0.5 I would suggest getting a copy of JBoss Developer's Notebook or JBoss at Work. I recall that JBoss at Work targetted JBoss AS 4.0.2, so it should be reasonably correct (hard to say because there were often major changes from 4.0.2 to .3 to .4 and finally to .5).
I assumed the version was 405 as the folder is named jboss405.
How could I check the exact version installed?
The version number is typically part of the directory name, so 4.0.5 is a good guess. The best way is to look at the console log or boot.log file - one of the entries there will give the exatc version, something like this:
18:56:15,320 INFO [Server] Release ID: JBoss [Trinity] 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)