<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Rich Galichon (rich@galichon.net) -->
<!-- Web Site: http://www.galichon.net -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
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=468 HEIGHT=60 BORDER=0 ALT='" + alt + "'></A>");
}
banner.prototype.dispBanner = dispBanner;
banners = new Array();
banners[0] = new banner("http://www.galichon.net/images/ banner/galichon_logo.jpg",
//баннер 1 - 16 процентов
"http://www.galichon.net target='_blank'",
"Описание к баннеру 1",
10);
banners[1] = new banner("http://imageserv.imgis.com/images/
Ad13700St1Sz1Sq1_Ban1.gif", //баннер 2 -
50 процентов
"http://www.banner1-url-here.com target='_blank'",
"Описание к баннеру 2",
30);
banners[2] = new banner("http://imageserv.imgis.com/images/
Ad13189St1Sz1Sq5_Ban10.gif", //баннер 3 -
33 процента
"http://www.banner2-url-here.com target='_blank'",
"Описание к баннеру 3",
20);
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=468 HEIGHT=60 BORDER=0 ALT='" + banners[i].alt + "'></A>");
return banners[i];
break;
}
}
}
// End -->
</script>
|