How To Wire It.com and Popular Mechanics have complete diagrams and color code charts for wiring a four-wire trailer. Additional information and diagrams are available on converting or adapting a six- or seven-wire vehicle harness to connect with a four-wire trailer.
Most trailers have three circuits; one for the running lights and one each for the left and right brake lights, with the fourth wire left for grounding. The turn signals are a function of the brake lights and are controlled by the flasher relay in the vehicle, which sends the correct signal to the appropriate filament. On a six-wire trailer the fifth and sixth wires are for trailers that have electric brakes and need an additional 12-volt power source. A seven-wire system uses the additional wire for an auxiliary power supply.
The vehicle to which a trailer is attached must have a matching plug or adapter. Many vehicles, particularly pickups and sport utility vehicles, are factory pre-wired for trailers. Some may even have a connector conveniently placed behind a spring-loaded cap. A new vehicle may have the harness needed in the glove box and simply require being plugged into the appropriate connector. O'Reilly Auto Parts sells adapters and temporary connection kits.