Rather than iterating through your page indices, just get
pages[Math.floor(Math.random()*pages.length)]
If you want to avoid duplication, ie. go through the pages in a random order, then keep your current code but - before the setInterval
- shuffle the array. Personally I'd use
pages.sort(function(a,b) {return Math.random()-0.5;});
But I know there are picky people out there who will say this isn't "random enough"... -shrugs-