var mainLayer;
var mainX, mainY;
var mainLayerImage;
var nestedLayer;

function init() {

  var img;

  // Find, position and initialize the main layer.

  mainLayer = getLayer("main");
  img = getImage("position");
  mainX = getImagePageLeft(img) + parseInt(img.border, 10);
  mainY = getImagePageTop(img) + parseInt(img.border, 10);
  moveLayerTo(mainLayer, mainX, mainY);
  clipLayer(mainLayer, 0, 0, img.width, img.height);
  //setBgColor(mainLayer, "#ffffff");
  showLayer(mainLayer);

  // Find the image on the main layer.

  mainLayerImage = getImage("pic");

  // Find and initialize the nested layer.

  nestedLayer = getLayer("nested");
  inheritLayer(nestedLayer);
}

// Code for scrolling the main layer continuously.

var scrollValue = 0;

function scroll() {

  if (scrollValue != 0) {
    scrollLayerBy(mainLayer, 0, scrollValue, true);
    setTimeout("scroll()", 24);
  }
}