I LOVE the d80!!!! My buddy's d40, to my knowlege, is mechanically the same. The differences are in the size of the lcd screen in the back, and some other features. But, from what I understand, they are the same otherwise.
the d80 has a max of 10.2 MegaPixels and not sure of the d40 ( I'm assuming it would be slightly smaller ).
You can't go wrong with Nikon. It's really what's behind the viewfinder that makes the great shots. ;) I think the quality of the reef tank shots are superb. I need to convert some of mine to an acceptable format/size to post but you can' trust me when I say they are magnificent. :D