Be careful with the D40... They have a special propriatary lense setup - you can only use AF-S Lenses on the D40, and those tend to run big bucks per lense.... well I should say you can use other Nikon lenses, but the autofocus feature only works if the lense is a AF-S model.
Here is an example : This is the lense that I do the majority of my shooting with (~$400): Nikon AF 70-300
Here is the AF-S Equivalent (~$670) : Nikon AF-S 70-300
If you are okay spending more on lenses, then the D40 would be a great camera. I've got a D70 and a D80, and love them both to death. (I have shot the Canon Digital Rebel, and the 30D - but would choose my Nikon's over either of them) I was going to buy the D40x (the 10MP one) but the autofocus lense issue really didn't sit well with me (Bought the D80 instead). Most of my photography is action sports related (Paintball tournaments, and motorcycle racing).
My other piece of advice - if you do buy a Nikon, spring the extra couple hundred and buy it in the 'kit' rather than just the body. The 18-135mm lense that comes with the kit is AMAZING! Very versatile, and generally an all around great lense, well worth the money for it.
Best of luck with your shopping. If you want to see any pics from either of my cameras, let me know, and i'll throw some up on the net somewhere
B