The locks use gravity and water from Gatun Lake (which is fed from rivers in the mountains) to raise and lower boats 80 feet total to reach the necessary height to cross the higher elevation in the middle of the country.
As ships enter, the first lock is opened to allow the water level to become the same. Then the lock behind the ship is closed, and the lock in front of them is opened to allow the boat to be raised. Each ship going through the canal runs on their own power, trains along side the locks help the ships to stay straight. After going through the first two sets of locks, the boats must go through Gatun lake to reach the other locks on the other side.
It takes a boat about 8 hours to go through the canal. Each boat pays for its passage by its weight. When smaller sail boats go through, they sometimes put them with other smaller boats in the locks. The locks are 120 feet wide and 1,000 feet long. We didn't get to see a really really big boat go through, but the one above was still a decent size, at least for us.
It amazes me the number of people that died in order to create the canal. There are memorials to those who died by the Miraflores locks, and a special exhibit in the museum as well. Most of the people who perished, did so because of tropical illnesses and poor medical treatment. The canal has helped the country of Panama became a wealthier and more developped country than its central American neighbors, and the Panama government took complete control over in the canal from the U.S. in 2000. The Panama government also has started an expansion project for the canal to help the canal accomodate world shipping needs.