
// MÓDULO MACHADO ASSOCIADOS
// http://www.bpsinternet.com.br

function switchImage(imgName, imgSrc) 
	{
	if (document.images){
		if (imgSrc != "none"){
      		document.images[imgName].src = imgSrc;
    	}
	}
}

function SlideShow(slideList, image, speed, name, slinkList)          
{
  this.slideList = slideList;
  this.slinkList = slinkList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}

SlideShow.prototype.play = SlideShow_play;  

function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    switchImage(image, slideList[current]);
	//document.getElementById('link_banner').href = String(slinkList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}
var myTempoSegundos = 4;
var mySlideList1 = ['/imagens/fotos/c1.jpg','/imagens/fotos/c2.jpg','/imagens/fotos/c3.jpg','/imagens/fotos/c4.jpg','/imagens/fotos/c5.jpg','/imagens/fotos/c6.jpg','/imagens/fotos/c7.jpg','/imagens/fotos/c8.jpg'];
var myLinkList1 = ['#','#','#','#','#'];
var BPSBanners = new SlideShow(mySlideList1, 'slide1', (myTempoSegundos*1000), "BPSBanners", myLinkList1);

function Inicializa() {
	BPSBanners.play()
}

var BPS_news_atual = 0;
var BPS_news_dados = new Array();
function BPSNewsTickerFader(qtd_news, tempo, tempo_fade) {
	
	//Sai se objeto nao existe
	if (!(document.getElementById("news_tabela"))) { return }
	
	//Inicialização
	changeOpac(100, "news_tabela");
	
	//Atualiza conteúdo
	pacote_dados = String(BPS_news_dados[BPS_news_atual]);
	array_dados = pacote_dados.split("~");
	document.getElementById("news_data").innerHTML = String(array_dados[0]);
	document.getElementById("news_texto").innerHTML = String(array_dados[1]);
	document.getElementById("news_link").href = String(array_dados[2]);
	
	//Inicializa o loop infinito
	setTimeout("BPSNewsTickerFaderEsconde(" + qtd_news + "," + tempo + "," + tempo_fade + ")", tempo);
}

function BPSNewsTickerFaderEsconde(qtd_news, tempo, tempo_fade) {
	
	//Sai se objeto nao existe
	if (!(document.getElementById("news_tabela"))) { return }

	//Esconde antigo
	opacity("news_tabela", 100, 0, tempo_fade);
	
	//prepara próxima mostrada
	setTimeout("BPSNewsTickerFaderMostra(" + qtd_news + "," + tempo + "," + tempo_fade + ")", tempo_fade + 10);
}

function BPSNewsTickerFaderMostra(qtd_news, tempo, tempo_fade) {
	
	//Sai se objeto nao existe
	if (!(document.getElementById("news_tabela"))) { return }
	
	//Atualiza news atual
	BPS_news_atual++;
	if (BPS_news_atual >= qtd_news) { BPS_news_atual = 0;}
	
	//Atualiza conteúdo
	pacote_dados = String(BPS_news_dados[BPS_news_atual]);
	array_dados = pacote_dados.split("~");
	document.getElementById("news_data").innerHTML = String(array_dados[0]);
	document.getElementById("news_texto").innerHTML = String(array_dados[1]);
	document.getElementById("news_link").href = String(array_dados[2]);
	
	//Mostra
	opacity("news_tabela", 0, 100, tempo_fade);
	
	//Prepara próxima escondida
	setTimeout("BPSNewsTickerFaderEsconde(" + qtd_news + "," + tempo + "," + tempo_fade + ")", tempo);
	
}