///////////////////////////////////////////////////
// banners[x] = new banner(<banner source image>,                                           
//                         <url to link to when the banner is clicked>,                     
//                         <alt>                                                            
//                         <the chance this banner has in which to be randomly selected>);  
// To increase the chance of a banner being randomly selected, increase it's corresponding  
// 'chance' property relative to the other banners.                                         
///////////////////////////////////////////////////

function banner(imgSource,url,alt,chance) {
this.imgSource = imgSource;
this.url = url;
this.alt = alt;
this.chance = chance;
}
function dispBanner() {
with (this) document.write("<A HREF=" + url + "><IMG SRC='" + imgSource + "' WIDTH=400 HEIGHT=70 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.dispBanner = dispBanner;
banners = new Array();
banners[0] = new banner("http://www.focusnatura.com/banners/banner-1.jpg",
                        "http://www.madeiratourism.org target='_blank'",
                        "banner-1",
                        0);
banners[1] = new banner("http://www.focusnatura.com/banners/banner-2.jpg",
                        "http://www.madeiratourism.org target='_blank'",
                        "banner-2",
                        0);
banners[2] = new banner("http://www.focusnatura.com/banners/banner-3.jpg",
                        "http://www.madeiratourism.org target='_blank'",
                        "banner-3",
                        0);
banners[3] = new banner("http://www.focusnatura.com/banners/banner-4.jpg",
                        "http://www.madeiratourism.org target='_blank'",
                        "banner-4",
                        0);
banners[4] = new banner("http://www.focusnatura.com/banners/banner-5.jpg",
                        "http://www.madeiratourism.org target='_blank'",
                        "banner-5",
                        0);
banners[5] = new banner("http://www.focusnatura.com/banners/banner-6.jpg",
                        "http://www.sra.pt target='_blank'",
                        "banner-6",
                        30);
banners[6] = new banner("http://www.focusnatura.com/banners/banner-7.jpg",
                        "http://www.sra.pt target='_blank'",
                        "banner-7",
                        30);
banners[7] = new banner("http://www.focusnatura.com/banners/banner-8.jpg",
                        "http://www.sra.pt target='_blank'",
                        "banner-8",
                        30);
banners[8] = new banner("http://www.focusnatura.com/banners/banner-9.jpg",
                        "http://www.madeiraplus.com target='_blank'",
                        "banner-9",
                        30);
banners[9] = new banner("http://www.focusnatura.com/banners/banner-10.jpg",
                        "http://www.greenstorm.pt target='_blank'",
                        "banner-10",
                        0);

///////////////////////////////////////////////////
// banners[x] = new banner(<banner source image>,                                           //                         <url to link to when the banner is clicked>,                     //                         <alt>                                                            //                         <the chance this banner has in which to be randomly selected>);  
// To increase the chance of a banner being randomly selected, increase it's corresponding  // 'chance' property relative to the other banners.                                         
///////////////////////////////////////////////////
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("<A HREF=" + banners[i].url + "><IMG SRC='" + banners[i].imgSource + "' WIDTH=400 HEIGHT=70 BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
      }
   }
}
//  End -->
