If you plan on keeping the D40 for a while and you know that the lenses have to be AF-S to AF, meaning that you will have to manually focus with everything else, I'd consider older AI lenses. KEH is conservative with their grading and I often purchase BGN grade lenses from them. A BGN grade 50mm f/2 AI lens will run you about $40-50. And the build quality is so much better than the current AF versions of f/1.8 and f/1.4 lenses. Something to ponder.
Bill