It depends on many things, none of which we can answer here
Your credit will be affected for 5-7 years from the foreclosure, but if your credit scores are really high, they may still be high enough to qualify. They will also look at your debt to income ratios and how much money you have to put down for a downpayment.
I HIGHLY recommend that you sit down face to face with a GOOD, LOCAL lender to discuss your situation. Note that a bank will typically only lend only their own loan packages, while a mortgage broker can look at different banks to see which has the best package for you.
You may also want to talk to a local HUD/FHA counselor about your situation. They will have no vested interest in whether you buy or not... more