function banner(imgSource,chance) {
   this.imgSource = imgSource;
   this.chance = chance;
}

function dispBanner() {
   with (this) document.write("<img src='" + imgSource + "' width='560' height='178'>");
}

banner.prototype.dispBanner = dispBanner;
banners = new Array();

banners[0] = new banner("media/fotos/intro01.jpg",
                        10);
banners[1] = new banner("media/fotos/intro02.jpg",
                        10);
banners[2] = new banner("media/fotos/intro03.jpg",
                        10);
banners[3] = new banner("media/fotos/intro04.jpg",
                        10);

sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
  sum_of_all_chances += banners[i].chance;
}

function randomBanner() {
  chance_limit = 0;
  randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
  for (i = 0; i < banners.length; i++) {
    chance_limit += banners[i].chance;
    if (randomly_selected_chance <= chance_limit) {
        document.write("<img src='" + banners[i].imgSource + "' width='560' height='178'>");
      	return banners[i];
      	break;
    }
  }
}