Patricia did a good job of answering things, but I will add to this a little.
FHA recently released a provision called "back to work" that allows you to apply as soon as 1 year after the final action on your BK or foreclosure, whichever was later.
To qualify, the BK and surrender have to be a direct result of an event resulting in job loss or income loss of at least 20%. You need to be able to document this and you also need to document that before the job loss your credit was in good shape,
Otherwise, you're looking at the 3 year waiting period.
Hope this helps!