How does the Panama Canal Locks Work?

The Panama Canal locks work like a beaver dam that opens. The locks hold the water at a certain level and open or close to make the levels even. There are always two sets of locks, using the area between them as a leveling area.