What you are trying to make is something completely different from what is described here.
You could remove all events and rename the activelayoutnumber to randomlayoutnumber.
all you have to do when someone clicks the button to go to another layout.
is add the actions to set the layoutnumber to random or choose.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..