/* CONFIGURAÇÔES */
var Imagens = new Array();
Imagens[1] = 'novo_top01.jpg';
Imagens[2] = 'novo_top02.jpg';
Imagens[3] = 'novo_top03.jpg';
Imagens[4] = 'novo_top04.jpg';
Imagens[5] = 'novo_top1.jpg';
Imagens[6] = 'novo_top2.jpg';
Imagens[7] = 'novo_top3.jpg';
Imagens[8] = 'novo_top4.jpg';
Imagens[9] = 'novo_top5.jpg';
QtdImagens = Imagens.length-1;

var SlideShowSpeed = 6000; //tempo de espera entre imagens - PADRÃO: 6000 = 6 segundos
var CrossFadeDuration = 50; //tempo de transição

var frame = 0;
var timeout_state = null;

/* PRE-LOAD */
for(var i=1; i<=QtdImagens; i++) {
	Imagens[i-1] = new Image();
	Imagens[i-1].src = "/images/" + Imagens[i];
	}


/* FUNCOES EXTRAS */
function changeOpac(opacity) {
	var object = document.images.PictureBox.style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	}
function aleatorio(inferior,superior){ 
    numPossibilidades = superior - inferior 
    aleat = Math.random() * numPossibilidades 
    aleat = Math.floor(aleat) 
    return parseInt(inferior) + aleat 
	} 
function opacity(opacStart, opacEnd) {
	//speed for each frame
	var speed = 50;
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ")",(timer * speed));
			timer++;
			}
		} 
	else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpac(" + i + ")",(timer * speed));
			timer++;
			}
		}
	}

frame = aleatorio(0,QtdImagens); //Imagens aleatórias

function runSlideShow() {
	if (document.all) {
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans(duration=CrossFadeDuration).Apply();
		document.images.PictureBox.filters.blendTrans.Apply();
		document.images.PictureBox.src = Imagens[frame].src;
		document.images.PictureBox.filters.blendTrans.Play();
		}
	else {
		document.getElementById("PictureDiv").style.backgroundImage = "url(" + Imagens[frame].src + ")";
		opacity(100, 0); //hide
		document.images.PictureBox.src = Imagens[frame].src;
		}
	frame = frame+1;
	if (frame>=QtdImagens) frame = 0;
	setTimeout("runSlideShow()",SlideShowSpeed);
	}

runSlideShow();
