Fixed the whole problem now, I put all the frame checks at the top of the block for each control, the problem is that you were checking the frame count prior assigning it to 'state' when it should be before. I made some other minor fixes as well.
Also:
COMMENT YOUR CODE!!!!