The wai seems like such a simple thing, put your hands together, bow slightly, smile..... It is a part of Thai culture that you imagine is easy to embrace. But it is an important part of the social behavior of Thais and has many nuances. Thai's are sensitive to their perceived social status and the wai is an intricate part of that system.
The higher you hold your hands (somewhere between chest level and forehead level) reflects the level of respect you are paying to the person you are wai-ing. The higher your hands, the more respect. So, if you are wai-ing your friend you would hold your hands around your chest, wai-ing your boss or your teacher hold your hands somewhere about face level and if you are wai-ing a monk you would hold your hands at forehead level.
There are other 'rules' such as the person who wais first often gives a slight bow, the person returning the wai does not. Don't initiate a wai with someone younger, wait for them to wai first then return it. If you are entering a store and the worker wais you, you don't wai back. Regardless of age, you should always be first to wai a person of higher social status.
Except in situation where someone is serving you (ie: at a convenience store) you should always return a wai. If you find yourself wai-ed to when your hands are full you need to make an effort to show you would return the wai if you could by at least attempting to raise your hands together. This can prove difficult when you shop as much as I do, I am often walking around with hands full of purchases.
The wai can also be used as an apology or thank-you.
Lucky for us, the Thais are very kind, gentle people and foreigners are forgiven for any amount of inappropriate wai-ing behavior. Generally, as long as you are trying to embrace their culture and include a big smile with your wai it will be accepted with gratitude and a returned smile. In fact, we have found on many occasions taking the time to wai a Thai in a respectful hello can open alot of doors and just in general make things run smoother. It comes down to the common courtesy of respecting the culture of the country you are in and extending politeness since you are the foreigner. Need to change your train ticket departure time or want something not on the menu? Starting with a wai and smile, then your request; can make a big difference.