
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("<A HREF="+url+"><IMG SRC='"+img_source+"' WIDTH=150 HEIGHT=40 BORDER=0 ALT='" + alt + "'></A>");
}

banner.prototype.display = display;
banners = new Array();
banners[0] = new banner("http://www.1cbt.com/banner-graphics/ordernow-ban.gif",
                        "http://www.order.baryalang.com",
                        "Order On Line Now",
                        10)
banners[1] = new banner("http://www.1cbt.com/banner-graphics/md1-text.gif",
                        "http://www.md-hosting.com",
                        "MD Hosting",
                        10)
banners[2] = new banner("http://www.1cbt.com/banner-graphics/md1a-text.gif",
                        "http://www.md-hosting.com",
                        "MD Hosting",
                        10)
banners[3] = new banner("http://www.1cbt.com/banner-graphics/creating.gif",
                        "http://www.md-hosting.com",
                        "MD Hosting",
                        10)
banners[4] = new banner("http://www.1cbt.com/banner-graphics/md1-logo.gif",
                        "http://www.md-hosting.com",
                        "MD Hosting",
                        10)
banners[5] = new banner("http://www.1cbt.com/banner-graphics/md2-logo.gif",
                        "http://www.md-hosting.com",
                        "MD Hosting",
                        10);
banners[6] = new banner("http://www.1cbt.com/banner-graphics/10-dot-com.gif",
                        "http://www.siteservices.us",
                        "Site Services International Domain Registration",
                        10);
banners[7] = new banner("http://www.1cbt.com/banner-graphics/555-dot-com.gif",
                        "http://www.siteservices.us",
                        "Site Services International Domain Registration",
                        10);
banners[8] = new banner("http://www.1cbt.com/banner-graphics/bbs-logo-150.gif",
                        "http://www.baryabuysell.com",
                        "Barya Buy Sell",
                        10)
banners[9] = new banner("http://www.1cbt.com/banner-graphics/blang.gif",
                        "http://www.baryalang.com",
                        "Barya Lang Web Page Design",
                        10)
banners[10] = new banner("http://www.1cbt.com/banner-graphics/isa.gif",
                        "http://www.1job.us",
                        "Internet Sales Associate Information",
                        10)
banners[11] = new banner("http://www.1cbt.com/banner-graphics/ordernow-ban.gif",
                        "http://www.order.baryalang.com",
                        "Order On Line Now",
                        10)
banners[12] = new banner("http://www.1cbt.com/banner-graphics/fwt.gif",
                        "http://www.freewebtemplates.com/rank/in.php?id=barya",
                        "Get Ideas for Web Pages",
                        10)
banners[13] = new banner("http://www.1cbt.com/banner-graphics/1ph-banner.gif",
                        "http://www.1ph.org",
                        "Number 1 Philippine Organizations",
                        10)

banners[14] = new banner("http://www.1cbt.com/banner-graphics/1cbt-banner.gif",
                        "http://www.1cbt.com",
                        "Number 1 Consumer Buying Tool",
                        10)

banners[15] = new banner("http://www.1cbt.com/banner-graphics/1wbt-banner.gif",
                        "http://www.1wbt.com",
                        "One World Business Team",
                        10)

banners[16] = new banner("http://www.1cbt.com/banner-graphics/happypinoy.gif",
                        "http://www.happypinoy.org",
                        "Happy Pinoy Writers Organization",
                        10)


sum_of_all_chances = 0;
for (i = 0; i < banners.length; i++) {
   sum_of_all_chances += banners[i].chance;
}

function display_banner(pgid) {
   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("<A HREF=" + banners[i].url + "><IMG SRC='" + banners[i].img_source + "' WIDTH=150 HEIGHT=40 BORDER=0 ALT='" + banners[i].alt + "' title='Click to go to " + banners[i].alt + "'></A>");
         return banners[i];
         break;
      }
   }
}

