Scripting Invoice Numbers in InDesign

I have an indesign document. All pages are identical, each page contains two illustrator images left and right, and two small text boxes left and right.

Each document has 100 pages all the same. What i want to do for each page is take the page number, do some math to it, and make the first/left most textbox that value. Then do more math to the page number and make the second/right most text box that value. Is this the kind of thing I can do with applescript? Forget the math I can figure that part out on my own. But setting values of text boxes, even setting them both to the page number. If AppleScript can do that, I’ll be good to go.

InDesign CS3 btw.