On arrival in Thailand through an international airport (Bangkok and Phuket) you will receive a 30day entry permit. If you enter Thailand via land borders you are granted a 15day entry permit. All permits can be extended for a duration of 30days at a fee of 1.900Baht. You may extend for another 7 days following the 30 day extension for another fee of 1.900Baht.
You can apply for a Thai 3 months or 6 months Visa at any Thai embassy. Rules, fees and applications change frequently so make sure you have all documents up to date before an application.
More information on Thai Visas can be found on this website
http://www.thaivisa.com/274.0.html
There is an overstay fine of 500Baht each day. You can overstay for 40 days following heavy fines and prison. Again please make sure you get up to date news on any regulations concerning Visas and permits for Thailand.