Trailer light problems

I got new truck and was hooking up the wiring harness when I discovered a strange problem. When my truck lights are off, everything works fine, brakes, blinkers etc. When my truck lights are on, the lights work and blinkers work but when you put the brakes on, everything goes off. Any ideas?