Javascript state machine for those who like their states medium rare.