// ITS Soluções Interativas
// Desenvolvedor: Cezinha Gehm
// 2004/04/22
//
// Esse script faz rodar imagens em algum local pré-determinado

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>");
//		}

function dispBanner() {
	with (this) document.write("<img src='" + imgSource + "' width=592 height=150 border=0>");
		}
banner.prototype.dispBanner = dispBanner;
banners = new Array();

//banners[0] = new banner("../visual/imagens/topo1.jpg",	aqui vai a referência da imagem
//"../conteudo/index.php",									aqui vai a url
//"Banner 1",												aqui vai o alt
//10);														aqui vai a taxa de visualização (de 1 a 10)
banners[0] = new banner("../visual/imagens/topo1.jpg",
"",
"",
10);
banners[1] = new banner("../visual/imagens/topo2.jpg",
"",
"",
10);
banners[2] = new banner("../visual/imagens/topo3.jpg",
"",
"",
10);
banners[3] = new banner("../visual/imagens/topo4.jpg",
"",
"",
10);

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>");
document.write("<img src='" + banners[i].imgSource + "' width=592 height=150 border=0>");
	return banners[i];
	break;
		}
		}
		}
		
// inserir isso no local onde deve aparecer a imagem ou o banner

//<SCRIPT LANGUAGE="JavaScript">
//<!--
//this_banner = randomBanner();
//-->
//< /SCRIPT>		
		
		