u can do one thing ,just take one status variable which contain info of whichframe has to be clicked, then whatever frame will be clicked check with statusand do appropriate action.