A ball cock, or fill valve, is the part in a toilet that controls the amount of water in the tank. Its job is to ensure that the right amount of water is in the tank so that the toilet does not overflow when the lever is pushed. As the name indicates, this item is made up of a hollow ball, which is attached to a lever that affixes to the rest of the toilet mechanism. It is mounted near the top of the tank. The ball cock is usually made of either metal or plastic, and can usually be easily replaced when necessary.
The mechanism is made up of a ball that floats in the water, which is affixed to a long lever. This lever attaches to a valve that is connected to the piece that houses the incoming supply of water. When the water reaches a certain line near the top of the tank, the float rises enough to force the lever to close the valve, which stops the flow of water. Thus, a broken ball cock may result in the toilet either overflowing, or even just slowly leaking excess water into the bowl, wasting it. Fortunately, this piece of equipment is usually quite inexpensive, and can be found at most home improvement stores.
It is best to understand how a toilet works, and how the ball cock fits into the mechanism, before repairing this part. When the toilet is flushed, a chain usually pulls the flapper valve upward, which will then gradually sink slower than the water level does. Once the water from the tank is emptied into the bowl, the floating ball slowly lowers until the fill valve is activated, causing the water to gradually fill the tank once more. At the same time, the overflow tube slowly fills up with a small stream of water to feed into the bowl until the right amount of water is present. When the flapper valve is closed, the fill valve will continue to allow the flow of water until the tank's level is replenished.
The ball cock can be found in either metal or plastic, and either type can be used as long as the threaded shank matches the old one. In fact, it is helpful to bring the old ball cock when purchasing a new one to make sure that it will be compatible with the toilet. It should be noted that while the plastic type is cheaper and will not corrode, it is not usually as sturdy as the metal kind.