Out of the 2 suggested go for the SB600 as when you decide to upgrade your D40 to a D80 or D200 you will be able to use it remotely.
However, if you can afford it or can wait to save a little more I'd go for the SB800 as this a little more powerful, allows you to use an external battery pack (if you want) and has a PC sync socket to allow you to use wired studio flash setups.
I have the SB600 and I wish I had spent the extra £50-£70 on the SB800 when I bought the SB600.