var Banners     = new Array();
var Links       = new Array();
var Peso        = new Array();
var AuxPeso     = new Array();
var Title       = new Array();
var Tipo        = new Array();
var Width       = new Array();
var Height      = new Array();
var Expira      = new Array();
var Ativo       = new Array();
var Data        = new Date();
var sData       = Data.setTime(Data);

var NumVisibleBanners = 3;

  Ativo[0] = 1;
  if (Ativo[0] == 1) {
    Banners[0] = "banners/portatil-portabilidade.jpg";
    Links[0] = "preditor-tecnologia.htm#portatil";
    Title[0] = "Preditor Portátil - maior portabilidade do mercado";
    Tipo[0] = "IMAGEM";
    Width[0] = "250";
    Height[0] = "";
    Peso[0] = 1;
  }


  Ativo[1] = 1;
  if (Ativo[1] == 1) {
    Banners[1] = "banners/portatil-simples.jpg";
    Links[1] = "preditor-tecnologia.htm#portatil";
    Title[1] = "Preditor Portátil - fácil e simples";
    Tipo[1] = "IMAGEM";
    Width[1] = "250";
    Height[1] = "";
    Peso[1] = 1;
  }


  Ativo[2] = 1;
  if (Ativo[2] == 1) {
    Banners[2] = "banners/hardware-rede.jpg";
    Links[2] = "preditor-tecnologia.htm#hardware";
    Title[2] = "Hardware Preditor - padrão ethernet e protocolo TCP/IP";
    Tipo[2] = "IMAGEM";
    Width[2] = "250";
    Height[2] = "";
    Peso[2] = 1;
  }


  Ativo[3] = 1;
  if (Ativo[3] == 1) {
    Banners[3] = "banners/hardware-canais.jpg";
    Links[3] = "preditor-tecnologia.htm#hardware";
    Title[3] = "Hardware Preditor - 6 canais simultâneos";
    Tipo[3] = "IMAGEM";
    Width[3] = "250";
    Height[3] = "";
    Peso[3] = 1;
  }


  Ativo[4] = 1;
  if (Ativo[4] == 1) {
    Banners[4] = "banners/software-estimacao.jpg";
    Links[4] = "preditor-tecnologia.htm#software";
    Title[4] = "Software Preditor - estimação automática de velocidades";
    Tipo[4] = "IMAGEM";
    Width[4] = "250";
    Height[4] = "";
    Peso[4] = 1;
  }


  Ativo[5] = 1;
  if (Ativo[5] == 1) {
    Banners[5] = "banners/software-diagnostico.jpg";
    Links[5] = "preditor-tecnologia.htm#software";
    Title[5] = "Software Preditor - auxílio ao diagnóstico e curvas de tendência";
    Tipo[5] = "IMAGEM";
    Width[5] = "250";
    Height[5] = "";
    Peso[5] = 1;
  }


  Ativo[6] = 1;
  if (Ativo[6] == 1) {
    Banners[6] = "banners/software-rotas.jpg";
    Links[6] = "preditor-tecnologia.htm#software";
    Title[6] = "Software Preditor - aquisições automáticas";
    Tipo[6] = "IMAGEM";
    Width[6] = "250";
    Height[6] = "";
    Peso[6] = 1;
  }


  Ativo[7] = 1;
  if (Ativo[7] == 1) {
    Banners[7] = "banners/preditor-esa.jpg";
    Links[7] = "preditor-esa.htm";
    Title[7] = "Sistema Preditor - Análise da Assinatura Elétrica";
    Tipo[7] = "IMAGEM";
    Width[7] = "250";
    Height[7] = "";
    Peso[7] = 1;
  }


  Ativo[8] = 1;
  if (Ativo[8] == 1) {
    Banners[8] = "banners/preditor-falhas.jpg";
    Links[8] = "preditor-esa.htm";
    Title[8] = "Sistema Preditor - falhas elétricas e mecânicas";
    Tipo[8] = "IMAGEM";
    Width[8] = "250";
    Height[8] = "";
    Peso[8] = 1;
  }


  Ativo[9] = 1;
  if (Ativo[9] == 1) {
    Banners[9] = "banners/preditor-energia.jpg";
    Links[9] = "preditor-esa.htm";
    Title[9] = "Sistema Preditor - consumo e qualidade de energia";
    Tipo[9] = "IMAGEM";
    Width[9] = "250";
    Height[9] = "";
    Peso[9] = 1;
  }

document.write("<table width='100%'  border='0' cellspacing='2' cellpadding='0'>\n<tr>\n");

if (NumVisibleBanners > Banners.length) {
	NumVisibleBanners = Banners.length;
}

for (k=0; k < NumVisibleBanners; k++) {
	var TotalBanner = 0;
	var pWidth      = "";
	var pHeight     = "";
	var Aleatorio;
	var IndexPeso;
	var StBanner;
	var StLink;
	var StTitle;
	var StWidth;
	var StHeight;
	var sExpira;
	var pWidth;
	var pHeight;

	for (i=0; i <= Banners.length; i++)
	{
	  if (Ativo[i] == 0 || Peso[i] == undefined) { continue; }
	  TotalBanner += Peso[i];
	}

	Aleatorio = Math.round(Math.random() * (TotalBanner-1));


	IndexPeso = 0;
	for (i=0; i <= Banners.length; i++)
	{
		if (Ativo[i] == 0 || Peso[i] == undefined) { continue; }
	 	for (x = 0; x < Peso[i]; x++)
	  	{
	    	AuxPeso[IndexPeso] = i;
		    IndexPeso++;
		}
	}

	StBanner  = Banners[AuxPeso[Aleatorio]];
	StLink    = Links[AuxPeso[Aleatorio]];
	StTitle   = Title[AuxPeso[Aleatorio]];
	StWidth   = Width[AuxPeso[Aleatorio]];
	StHeight  = Height[AuxPeso[Aleatorio]];
	
	// garante que o banner não será mostrado denovo
	Ativo[AuxPeso[Aleatorio]] = 0;
	Peso[AuxPeso[Aleatorio]] = 0;

	if (StWidth != "")
	{
	  pWidth = " width='" + StWidth + "'";
	}

	if (StHeight != "")
	{
	  pHeight = " height='" + StHeight + "'";
	}

	document.write("<td align='center'>");
	if (Tipo[AuxPeso[Aleatorio]] == "IMAGEM")
	{
	  document.write("<a href='" + StLink + "'><img src='" + StBanner + "' border='0' alt='Banner' title='" + StTitle + "'" + pWidth + pHeight + "></a>");
	}
	else
	{
	  document.write("<embed src='" + StBanner + "' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' width='" + StWidth + "' height='" + StHeight + "''>");
	}
	document.write("</td>\n");
}
document.write("</tr>\n</table>\n");

