var imagelistload = new Array();
var imagelist = new Array('01.jpg','02.jpg','03.jpg','04.jpg','05.jpg','06.jpg','07.jpg','08.jpg','09.jpg','10.jpg');
var imagebytes = new Array(55026,39352,57944,40269,44627,25893,38620,43111,36051,31508);
var i = 0, currentbytes = 0, totalbytes = 0, totalkilobytes = 0;
var timer;

function startload() {
  for(x=0; x<imagebytes.length; x++) totalbytes += imagebytes[x];
  totalkilobytes = Math.round(totalbytes / 1024);
  loadimages();
}

function loadimages() {
  imagelistload[i] = new Image();
  imagelistload[i].src = imagelist[i];
  timer = setTimeout('checkload()',100);
}

function checkload() {
  if(imagelistload[i].complete) {
    currentbytes += imagebytes[i];
    percent = Math.round(currentbytes / totalbytes * 100);
    kilobytes = Math.round(currentbytes / 1024);
    updateimages();
    i++;
    loadimages();
    if(imagelistload.length>=imagelist.length+1) {
      --i;
      updateimages();
      clearTimeout(timer);
      setTimeout('urlchange()',1000);
    }
  }
  else { setTimeout('checkload()',100); }
}

function updateimages() {
  if(document.all) {
    document.all['current_image'].innerHTML = '<font color="#0000CC">' + imagelist[i] + '</font> (' + (i+1) + '/' + imagelist.length + ')';
    document.all['total_progress'].innerHTML = '<font color="#0000CC">' + percent + '%</font> (' + kilobytes + '/' + totalkilobytes + 'kB)';
    document.all['progressbar'].style.width = percent * 3.8;
  }
  else if(document.getElementById) {
    document.getElementById('current_image').innerHTML = '<font color="#0000CC">' + imagelist[i] + '</font> (' + (i+1) + '/' + imagelist.length + ')';
    document.getElementById('total_progress').innerHTML = '<font color="#0000CC">' + percent + '%</font> (' + kilobytes + '/' + totalkilobytes + 'kB)';
    document.getElementById('progressbar').style.width = percent * 3.8;
  }
}

function urlchange() {
  top.location = 'main.html';
}
