You need a type D flip-flop, and a way to actuate the mechanism (simple if a
voltage input will suffice, but may need a relay).
If you want to use only discrete, a circuit like this will work:
http://webpages.charter.net/dawill/Images/Frequency Divider.gif
Or you can use a logic chip or two to perform the same function.
Tim