To work in Thailand legally, you will need a B visa and a work permit (the blue workbook). Normally, you need a B visa first in order to obtain the work permit. Before applying for a B visa, you should consult the Labour Department to see which jobs you can apply for as a foreigner (many jobs are reserved solely for Thai nationals).
If you want to work in Thailand, the normal procedure would be to apply for a B visa in your country of residence, with a Letter of Approval from the Thai Labour Department. After arriving in Thailand, you would then apply for your work permit. The work permit can also be requested by your employer before you arrive.
If you enter Thailand on another visa (i.e. a tourist visa) and then look for a job, you are unlikely to receive a work permit. However, you have more of a chance if you are offered a job by a company which is legally allowed to employ foreigners (yet this is still not guaranteed). In either case, you will still have to leave the country to apply for a B visa before you can apply for your work permit.
To apply for a work (B) visa, you will probably need some or all of the following:
Spouses and children of a B visa holder will need a non-immigrant O visa, which is also issued to foreigners who wish to retire in Thailand.
For more information check the website of the Ministry of Foreign Affairs .