An earnest money deposit is to show the Buyer's sincerity. Period. Once all the terms of the contract (sales price, repair cap, closing date, etc.) are agreed upon by all parties, the Seller will take his property off the market, the Realtor will discontinue marketing the property and the earnest money is deposited -- usually in the Listing Realtor's escrow account.
Should problems arise with financing or inspection results, the earnest money could be refunded to the Buyer. If the transaction goes through to closing, the earnest money amount is credited towards the Buyer's closing expenses.
The point of earnest money is to show the Seller that you are sincere in your intention of purchasing his property and moving forward in a diligent manner to ensure a successful transaction. I usually ask my Buyer's to write a check for 1% of the sales price for the amount of earnest money.
Other up-front expenses in your home purchase will include the cost of your appraisal and your inspections.
Good luck in your home search. Call me if I can be of assistance!