var UsedPixels = 0, TotalPixels = 400;
var Random = new Array ( ), RandomIndex = 0, RandomTotal = 50;
var AvailableLines = new Array ( ), LinesTotal = 3;
var PartsTotal;

function drawLine ( x1, y1, x2, y2 )
{
  var dy = y2 - y1;
  var dx = x2 - x1;
  var d = 0;
  var my = Math.round ( dy / 100 );
  alert ( dy );
  alert ( my );
  for ( y = 0; y < dy; y+=my )
  {
    // fraction of y
    fy = y / dy;
    x = dx * fy + x1;
    pixel = document.all['div' + UsedPixels].style;
    pixel.pixelTop = y + y1;
    pixel.pixelLeft = x;
    //pixel.display = 'block';
    pixel.visibility = 'visible';
    UsedPixels++;
  }
}

function EraseRemaining ( )
{
  for ( c = UsedPixels; c < TotalPixels; c++ )
  {
    //document.all['div' + d].style.display = 'none';
    document.all['div' + c].style.visibility = 'hidden';
  }
}

function LinesInit ( TotalParts )
{
  var c, html = '';
  var Width = window.document.documentElement.offsetWidth;
  var Height = window.document.documentElement.offsetHeight;

  PartsTotal = TotalParts;
  for ( c = 0; c < TotalPixels; c++ )
  {
    html += '<img src="pixel.gif" id="div' + c + '" style="position:absolute;visibility:hidden;width:1px;height:1px;top:1px;left:1px;background-color:BlueViolet;" />';
  }
  document.all.content.innerHTML = html;

  var lastX = Math.random ( ) * Width, lastY = Math.random ( ) * Height;
  var currentX, currentY;
  for ( d = 0; d < PartsTotal; d++ )
  {
    for ( c = 0; c < LinesTotal; c++ )
    {
      currentX = Math.random ( ) * Width;
      currentY = Math.random ( ) * Height;
      AvailableLines[c * LinesTotal + d] = new Array ( lastX, currentX, lastY, currentY );
      lastX = currentX;
      lastY = currentY;
    }
  }
}

function Lines ( Part, Percentage )
{
  UsedPixels = 0;
  for ( c = Part, d = 0; d < LinesTotal; c+=LinesTotal, d++ )
  {
    var Current = AvailableLines[c];
    drawLine ( Current[0], Current[2],
               (Current[1] - Current[0]) * Percentage / 100 + Current[0],
               (Current[3] - Current[2]) * Percentage / 100 + Current[2] );
  }
  EraseRemaining ( );
}
