If you are arrested for any offence, the police will allow you the opportunity to make a phone call to your embassy or consulate in Thailand if you have one, or to a friend or relative if not. There's a whole set of legal codes governing the length of time and manner in which you can be detained before being charged or put on trial, but a lot of discretion is left up to the police. With foreigners the police are more likely to bend these codes in your favour. However, as with police worldwide, if you don't show respect you will make matters worse. Thai law does not presume an indicted detainee to be either 'guilty' or 'innocent' but rather a 'suspect' whose guilt or innocence will be decided in court.
Trials are usually speedy.
Thailand has its share of attorneys, and if you think you're a high arrest risk for whatever reason, it might be a good idea to get out the Bangkok yellow pages, copy down a few phone numbers and carry them with you. The best way to deal with most serious hassles regarding ripoffs or thefts is to contact the Tourist Police, who are used to dealing with foreigners, rather than the regular Thai police. The Tourist Police maintain a hotline - dial 1155 from any phone in Thailand, and ask for extension 1. The Tourist Police can also be very helpful in cases of arrest. Although they typically have no jurisdiction over the kinds of cases handled by regular cops, they may be able to help with translation or with contacting your embassy.