Button programming

I have a frames page with a flash file on the bottom html and a normal html page on the top frame (target: main). I have this page setup so that the flash file loads up different html pages in the top(like a slide show). My list box (selects an individual page) works fine. I simply called pages at target: main when the user selects a certain item. But the buttons seem to be giving me some trouble. I can’t seem to make the next button go ahead one page and the prev go back one. What I have tried so far is to add a variable to track what page is loaded and then tell it to add 1 to the value of the file name. Each file name has a numeric value at the end of it, in order.