try $900 for the AF-S 12-24, pretty much your only choice if you want a wide lens that will autofocus on your D40.
Or you can defeat half the purpose of shooting Nikon and buy the sigma 10-20 for $500.
The advantage of the sigma is that it's 2mm wider, that's an equiv. of 15mm vs 18 on APS-C. That's a big difference, and that could be worth it. I can see that being useful.
The disadvantage is that depreciation hits harder if you try to sell it off, it's not a Nikkor so if Nikon has any tricks up their sleeves, the sigma most likely wont' be ready, and i've heard alot about autofocus problems with the 10-20.
Personally, if I needed a the viewing angle of a 15mm, I would buy the sigma and (at least try to) not look back, otherwise, i'd keep everything in the family and use the 12-24.
Even used you're hard pressed to get something. Cheapest/widest at that level that'll work with a D40 is the kit 18-55.
Once you get below - or above - the midrange 24-85 lenses it seems like prices go up quickly - at a rate proportional to their speed.
Some third party lenses - like the Tokina 12-24 are decent values compared to Nikon but others....... the good ones are fewer in number than the mediocre ones.
Ebay and other places have some cheap "add-on" lenses that work with the 18-55 to give you a wider angle ($40 or so if I remember right) but can't say if they're worth it or not. Might work for what you want but I'd try one before buying.