You can put in your contract that the EMD will not be given until your offer is accepted. As was already stated, though, sometimes they will want it up front- it just depends on which bank you are working with.
I did not have the EMD for my first few deals, so I did what you are describing, and used my buyer's deposit. I would start shopping the deal around to my investors while I was still countering w the bank, and if I found someone interested, I would accept the offer, have my buyer write me a check, and then use that money to give to the bank. You have to be careful doing this, though, as you might get caught with your pants down, and end up with no buyer and no earnest money, and have to back out of the deal. Once you start backing out of deals, your offers are a lot less likely to be accepted.
I agree with Christian that the best way to get deals is to offer large EMDs and drop the contingencies. My best deals came when I was offering 5k or more as a deposit. I talked to a guy last week who is cleaning house here in Tampa, and he told me he is offering 10-15k EMDs. It makes a difference for sure.
Good luck,
Steph