var nodeio = require('./');

var page_numbers_on_page = {
    1: [ '1', '2', '3', '4' ]
  , 2: [ '1', '2', '3', '4' ]
  , 3: [ '2', '3', '4', '5' ]
  , 4: [ '3', '4', '5', '6' ]
  , 5: [ '5', '6', '7', '8' ]
  , 6: [ '6', '7', '8', '9' ]
  , 7: [ '6', '7', '8', '9' ]
  , 8: [ '6', '7', '8', '9' ]
  , 9: [ '6', '7', '8', '9' ]
};

var seen_pages = { 1: true };

exports.Job = new nodeio.Job({}, {
    input: ['1']
  , run: function (page) {
        var self = this;
        page_numbers_on_page[page].forEach(function (page) {
            if (!(page in seen_pages)) {
                self.add(page);
                seen_pages[page] = true;
            }
        });
        this.emit('Loaded page ' + page);
    }
});

