Transistorlike behavior of a Bose-Einstein condensate in a triple-well potential