Just to clarify, as this can be confusing for many buyers - a "condo, or condominium" is a form of ownership. as is a "cooperative". There is also a 39;fee simple" form of ownership, in which you own the property outright, with no restrictions.
With a condo, you are given a deed to the unit (you own it), and are generally free to make any interior chamges, and to sell to anyone you choose - there are bylaws which must be followed, and usually monthly maintenance fees that take care of the common areas and/or exterior - with a coop, however, you own a percentage of the building or complex, but not the unit itself, and generally you need permission from the coop board before you can alter the interior or sell to anyone - this is more restrictive than a condo..
A townhome is the style of the building - genrally it is a multi-storied building - it may or may not have common, adjoining walls. A townhome can be a condo, or it can also be a cooperative, or fee simple - it depends on how the ownership is structured.
Make sure before buying any condo or coop that you have read a copy of the bylaws (rules and regulations) so that you understand what you can and can't do. These bylaws can vary greatly from complex to complex, and will tell you whether, for example, dogs are allowed on the premises, or even (in the case of my own complex) whether you're allowed to have a hanging plant by your front door!