function ScreenChange(direction)
{
  if (direction == 2)
  {
    --currentCol;
    if (currentCol < 1)
      currentCol = maxCols;
    ShowScreen ();
    return;
  }
  if (direction == 3)
  {
    ++currentCol;
    if (currentCol > maxCols)
      currentCol = 1;
    ShowScreen ();
    return;
  }
  if (direction == 0)
  {
    --currentRow[currentCol-1];
    if (currentRow[currentCol-1] < 1)
      currentRow[currentCol-1] = maxRows;
    ShowScreen ();
    return;
  }
  if (direction == 1)
  {
    ++currentRow[currentCol-1];
    if (currentRow[currentCol-1] > maxRows)
      currentRow[currentCol-1] = 1;
    ShowScreen ();
    return;
  }
}

function ShowScreen ()
{
  document.screen.src = screens[(currentCol - 1) * maxRows 
                                + currentRow[currentCol - 1] - 1].src;
}

function prepareScreens (screenName)
{
  screens = new Array (maxCols * maxRows);
  currentRow = new Array (maxCols);
  for (var i = 0; i < maxCols * maxRows; i++)
  {
    screens[i] = new Image();
    screens[i].src = "../images/wb/" + screenName + (i+1) + ".png";
    if (i < maxCols)
      currentRow[i] = 1;
  }
}