var index = 0;

function nextPage() {
    if (window.location.hash.length <= 1) { // frame id not specified implicitly
        index = (index + 1) % pages.length;
        document.getElementById("" + index).scrollIntoView();
    }
}

function initMon() {
    var windowHeight = window.innerHeight;
    var framesRoot = document.getElementById("frames");

    for (var i = 0; i < pages.length; i++) {
        var frame = document.createElement("iframe");
        frame.setAttribute("id", i);
        frame.setAttribute("height", windowHeight);
        frame.setAttribute("frameborder", 0);
        frame.setAttribute("scrolling", "no");
        frame.src = pages[i];
        framesRoot.appendChild(frame);
    }
}

function reloadFrame(idx) {
    var frame = document.getElementById("" + idx);
    frame.src = frame.src;
}

initMon();
setInterval(nextPage, 30000);
