new function() {
  var app;
  
  if (top.page && top.page.start)
    app = top.page;
  else {
    app = new App(window);
    app.start(function() {
      app.body = app.load(document.body);
    })
  }
  
  app.start(function() {
    app.handle('click', function(e) {
      var com;
      if (!(com = app.com(e.target, true)) || !com.names.image)
        app.body.clear('LBed').select('open');
    })    
  })

  app.bind('gallery', {
    init: function() {
      var LB = this.collect('LB');
      
      this.cmd({
        select: function(i) {
          i = parseInt(i);
          this.visit('image', function() {
            if (!this.names.thumb)
              this.toggle('foc', --i == 0);
          })
        },
      
        LB: function(i) {
          i = parseInt(i);
          app.body.apply('LBed').select('open', LB[i - 1]);
        }
      })
    }
  });
  app.bind('image');
}