function banner(img_source,url,alt,chance) { this.img_source = img_source; this.url = url; this.alt = alt; this.chance = chance; } function display() { with (this) document.write("" + alt + ""); } banner.prototype.display = display; banners = new Array(); banners[0] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/1.jpg", "", "", 10); banners[1] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/2.jpg", "", "", 10); banners[2] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/3.jpg", "", "", 10); banners[3] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/4.jpg", "", "", 10); banners[4] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/5.jpg", "", "", 10); banners[5] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/6.jpg", "", "", 10); banners[6] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/7.jpg", "", "", 10); banners[7] = new banner("http://www.poolweb.com/site/ATI_Front_Page_B/8.jpg", "", "", 10); sum_of_all_chances = 0; for (i = 0; i < banners.length; i++) { sum_of_all_chances += banners[i].chance; } function display_banner() { 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("" + banners[i].alt + ""); return banners[i]; break; } } } //-->