How do those fish that change gender and reproduce work?
This phenomenon is called ‘sequential hermaphroditism’. There are two kinds: protoandry (where it starts out male and turns female) and protogyny (the opposite). Change is usually determined by social structures. In protogyny (e.g. clownfish) the largest female will turn into a male if the dominant male is removed. In protoandry (e.g. wrasse) it is generally a bit more complicated – see wikipedia!. This exists in other animals apart from fish – e.g. beavers! There are various mechanisms for the actual sex change involving various genes being switched on or off. There’s a good paper summarising the general idea in my sources (the springerlink one).