// JavaScript Document
// <![CDATA[
function init(redirect,nome){
	try{
		if(self.parent.frames.length == 0)
			self.parent.location="index.php?pagina="+redirect;
		else if (self.parent.frames[0].name != nome) {
			//alert(self.parent.frames[0].name);
			self.parent.location="index.php?pagina="+redirect;
		}
	}
	catch(exception){}
}
// ]]>

function iframeAutoHeight(quem){
    //by Micox - elmicox.blogspot.com - elmicox.com - webly.com.br  
    if(navigator.appName.indexOf(" Internet Explorer")>-1){ //ie sucks
        var func_temp = function(){
            var val_temp = quem.contentWindow.document.body.scrollHeight + 15
            quem.style.height = val_temp + "px";
        }
        setTimeout(function() { func_temp() },100) //ie sucks
    }else{
        var val = quem.contentWindow.document.body.parentNode.offsetHeight + 15
        quem.style.height= val + "px";
    }    
}

function changeFoto(numFoto)
{
	contador = 0;
	var objThumb = document.getElementById('thumb'+fotoAtual);	
	objThumb.className = 'thumb';
	
	fotoAtual = numFoto;
	objThumb = document.getElementById('thumb'+fotoAtual);	
	objThumb.className = 'thumbOn';
	
	clearInterval(timerAlteraFoto);
	
	var obj = document.getElementById('imagemGrande');	
	if(obj) obj.src = fotos[numFoto];
	
	obj.onload = function() {
		if(statusSlide)
			startTimer();
	}
}

var contador = 0;
var timerAlteraFoto;
var fotoAtual = 0;
var statusSlide = 1;

function startTimer()
{
	timerAlteraFoto = setInterval("aumentaContador()",50);	
}

function showStatusBar()
{
	var obj = document.getElementById('tempoProximaFoto');
	obj.style.width = contador + "%";	
}

function changeSlideshowStatus()
{
	statusSlide = !statusSlide;
	var obj = document.getElementById('opcaoSlideshow');
	if(statusSlide)
	{
		startTimer();
		obj.innerHTML = "Parar slideshow";
	}
	else
	{
		clearInterval(timerAlteraFoto);
		contador = 0;
		showStatusBar();
		obj.innerHTML = "Continuar slideshow";
	}
}

function aumentaContador()
{
	contador = contador + 2;

	if(contador > 100)
	{
		contador = 100;
		foto = fotoAtual + 1 >= fotos.length ? 0 : fotoAtual + 1;
		changeFoto(foto);
	}
	else
	{
		showStatusBar();
	}
	
}

function showhide(element,show) {
	if(show == true && element != assistindo) document.getElementById(element).style.display = 'block';
	else document.getElementById(element).style.display = 'none';
}

function showvideo(videoid, text) {
	writetext('Você está assistindo: '+ text,'assistindo');
	assistindo = videoid;
}

function writetext(text, id) {
  var txtField = document.getElementById(id);
  txtField.innerHTML = text;
  document.getElementById(id).style.display = 'block';
}

	function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',noresizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}
