a simple FSM based on Javascript