I'm not going to read through all your code yet, because you say you can only display the first 10 menu items.

You need to take that diagram you made in post #1, draw it out on paper, and start...