isNN=(navigator.appName=="Netscape")?1:0;
isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;

function trocaImagem(pnAvanca) {
	var loImagem = document.getElementById("imagem_destaque");
	var loTitulo = document.getElementById("titulo_destaque");
	
	//nereidFade(loImagem, 0, 50, 5);
	
	if (pnAvanca == -1) {
		lnPosicao--;
	} else {
		lnPosicao++;
	}
	if (lnPosicao >= lnQtd_Fotos) {
		lnPosicao = 0;
	}
	if (lnPosicao < 0) {
		lnPosicao = (lnQtd_Fotos - 1);
	}
	
	// Fading
	fadeValue = 0;
	var obj = document.getElementById("imagem_destaque");
	if (isIE) {
		obj.filters.alpha.opacity = fadeValue;
	} else {
		obj.style.opacity = fadeValue / 101;
		obj.style.MozOpacity = fadeValue / 101;
		obj.style.KhtmlOpacity = fadeValue / 101;
	}
	
	loImagem.src = "../recorte.php?image=conteudo/imagens/" + lcFoto[lnPosicao] + "&w=250&h=186";
	loTitulo.innerHTML = lcTitulo[lnPosicao];
	
	temporizador = 0;
}

// Faz o fade
function loading(pnOpcao) {
	wait=100;
	if (pnOpcao == -1) {
		fadeValue -= 10;
	} else {
		fadeValue += 10;
	}
	
	var obj = document.getElementById("imagem_destaque");
	if (isIE) {
		obj.filters.alpha.opacity = fadeValue;
	} else {
		obj.style.opacity = fadeValue / 101;
		obj.style.MozOpacity = fadeValue / 101;
		obj.style.KhtmlOpacity = fadeValue / 101;
	}
	
	if (fadeValue <= 100) {
		setTimeout('loading()', wait);
	}
}

// Muda as imagens sozinho
function slideshow() {
	if (slide) {
		temporizador++;
		if (temporizador > 7) {
			trocaImagem(0);
			temporizador = 0;
		}
		setTimeout("slideshow()", 1000);
	}
}

// Dá uma pausa no slide
function pausa() {
	slide = !(slide);
	if (slide) {
		slideshow();
	}
}

// Gera o link
function getLink() {
	if (lnCodigo[lnPosicao] != "undefined") {
		document.location.href = "../conteudo/?id=" + lnCodigo[lnPosicao];
	}
}
