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=\"564\" height=\"94\" border=\"0\" alt=\"" + alt + "\"></a>");
}

//banner.prototype.display = display;

banners = new Array();							
banners = new Array(
			new Array(new banner("", "", "", 100)),
			new Array(new banner("", "", "", 100)),
			new Array(new banner("", "", "", 100)),
			new Array(
				new banner("/vgnmedia/downld/NCM0001_NAB-Volunteers_185x60px_v1.gif", 
					"/wps/wcm/connect/nab/campaigns/39/?WT.seg_1=SPAAH&WT.ac=SPAAH",
					"NAB Community Volunteering. Find out more",
					50),
				new banner("/vgnmedia/downld/NBB1339_MGLT-P3_185x60_v1.gif", 
					"http://oms.nab.com.au/MoreGiveLessTake?WT.seg_1=UJN&WT.ac=UJN",
					"Give and take in action. Find out more",
					50)
			)
		);

function display_banner(bannerIndex) {
	var bannerIndex = isNaN(bannerIndex)?0:bannerIndex;
	var sum_of_all_chances = 0;
	for (j = 0; j < banners[bannerIndex].length; j++) {
		sum_of_all_chances += banners[bannerIndex][j].chance;
	}
	chance_limit = 0;
	randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
	for (i = 0; i < banners[bannerIndex].length; i++) {
		chance_limit += banners[bannerIndex][i].chance;
		if (randomly_selected_chance <= chance_limit) {
			if (bannerIndex == 0) {
				document.write("<img src=\"" + banners[bannerIndex][i].img_source + "\" width=\"564\" height=\"143\" alt=\"" + banners[bannerIndex][i].alt + "\">");
			} else {
				document.write("<a href=\"" + banners[bannerIndex][i].url + "\"><img src=\"" + banners[bannerIndex][i].img_source + "\" width=\"185\" alt=\"" + banners[bannerIndex][i].alt + "\"></a>");
			}
			return banners[bannerIndex][i];
			break;
		}
	}
}