function dimensiona(){
	if (parseInt(navigator.appVersion)>3) {
 		/*if (navigator.appName=="Netscape") {
  			winW = window.innerWidth-20;
  			//winH = window.innerHeight;
 		}*/
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winW = document.body.offsetWidth;
  			//winH = document.body.offsetHeight;
 		} else {
			winW = window.innerWidth-20;
  		}
	}
	var centro = document.getElementById('centro');
	var larg = winW-292+'px';
	centro.style.width = larg;
	
	//dimensiona INICIAL
	var inicialDestaques = document.getElementById('inicialDestaques');
	if(inicialDestaques) { 
		inicialDestaques.style.width = (((winW-292)*0.6)-0)+'px';
		var hID = inicialDestaques.offsetHeight;
	}
	var avisos = document.getElementById('avisos');
	if(avisos) { 
		avisos.style.width = (((winW-292)*0.4)-8)+'px';
		var hAv = avisos.offsetHeight;
		if(hID > hAv){		
			//alert("Maior hID = "+hID+" e hAv = "+hAv);
			avisos.lastChild.style.height = (hID-31)+'px';
		}else{	
			//alert("Menor hID = "+hID+" e hAv = "+hAv);
			var numb;
			if(inicialDestaques.childNodes.item(3).firstChild.offsetHeight > 20) numb = 45;
			else numb = 28;
			//if(hID != hAv) inicialDestaques.childNodes.item(3).lastChild.style.height = (hAv-numb)+'px';
		}
	}
	
	var inicialAgenda = document.getElementById('inicialAgenda');
	if(inicialAgenda) { 
		inicialAgenda.style.width = (((winW-292)*0.50)-0)+'px';
		var hIA = inicialAgenda.offsetHeight;
	}
	var inicialArtigos = document.getElementById('inicialArtigos');
	if(inicialArtigos) { 
		inicialArtigos.style.width = (((winW-292)*0.50)-8)+'px';
		inicialArtigos.style.height = (hIA-7)+'px';
	}
	var inicialImagens = document.getElementById('inicialImagens');
	if(inicialImagens) { 
		inicialImagens.style.width = (((winW-292)*0.50)-0)+'px';
		var hII = Math.floor(inicialImagens.offsetHeight);
	}
	var inicialVideos = document.getElementById('inicialVideos');
	if(inicialVideos) { 
		inicialVideos.style.width = (((winW-292)*0.50)-8)+'px';
		var hIV = Math.floor(inicialVideos.offsetHeight);
		if(hII > hIV){
			inicialVideos.style.height = (hII-7)+'px';
			//alert('hII>hIV - imagens='+hII+' - videos='+hIV);
		}
		else			
		if(hII < hIV){
			inicialImagens.style.height = hIV+'px';
			//alert('hII<hIV - imagens='+hII+' - videos='+hIV);
		}
	}
	var inicialHistoria = document.getElementById('inicialHistoria');
	if(inicialHistoria) { 
		inicialHistoria.style.width = (((winW-292)*0.33)-0)+'px';
		var hH = Math.floor(inicialHistoria.offsetHeight);
	}
	var inicialFolclore = document.getElementById('inicialFolclore');
	if(inicialFolclore) { 
		inicialFolclore.style.width = (((winW-292)*0.33)-0)+'px';
		var hF = Math.floor(inicialFolclore.offsetHeight);
	}
	var inicialMeioambiente = document.getElementById('inicialMeioambiente');
	if(inicialMeioambiente) { 
		inicialMeioambiente.style.width = (((winW-292)*0.33)-8)+'px';
		var hM = Math.floor(inicialMeioambiente.offsetHeight);
		var max1 = Math.max(hH,hF);
		var max2 = Math.max(max1,hM);
		if(max1 != max2){
			inicialHistoria.style.height = max2+'px';
			inicialFolclore.style.height = max2+'px';
			inicialMeioambiente.style.height = max2+'px';
		} 
	}
	
	var firstDest = document.getElementById('firstDest');
	if(firstDest){
		var hfd = firstDest.offsetHeight;
		var rest = (hfd-192)/2;
		
		var opiniao = document.getElementById('opiniao');
		opiniao.style.height = rest+'px';
		var opinioes = opiniao.childNodes[1];
		opinioes.style.height = rest-14+'px';
		
		var agendaInicial = document.getElementById('agendaInicial');
		agendaInicial.style.height = rest+'px';
		var agendaInicialopinioes = agendaInicial.childNodes[1];
		agendaInicialopinioes.style.height = rest-14+'px';
	}

}

//////////
function abre_janela(mypage, myname, w, h,scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+15+',left='+15+',scrollbars='+scroll+',resizable,statusbar=no'
	win = window.open('http://www.pirenopolis.tur.br/portal/'+mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

///////////////
function mostrasub(id,top){
	document.getElementById(id).style.display='block';
	document.getElementById(id).style.top=top+'px';
}

////////////////
function escondesub(id,top){
	document.getElementById(id).style.display='none';
}

////////////////////
function mostraindice(){
	document.getElementById('indicelista').style.display='block';
	document.getElementById('mostraind').style.display='none';
	document.getElementById('escondeind').style.display='block';
	document.getElementById('indice').style.width='250px';
}

/////////////////////
function escondeindice(){
	document.getElementById('indicelista').style.display='none';
	document.getElementById('mostraind').style.display='block';
	document.getElementById('escondeind').style.display='none';
	document.getElementById('indice').style.width='87px';
}

///////////////////////
function abrirFormHerb(){
    document.getElementById("inserirespecie").style.display="block";
    document.getElementById("fechaForm").style.display="inline";
}

////////////////////////
function fecharFormHerb(){
    document.getElementById("inserirespecie").style.display="none";
    document.getElementById("fechaForm").style.display="none";
}

////////////////////////
function buscaGenero(familia){
	if(window.XMLHttpRequest){
    	ajax = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
    	ajax = new ActiveXObject("Msxml2.XMLHTTP");
		if(!ajax){
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	if(ajax){
		//iniciaRequisicao(metodo,url,bool);
	} else alert("Seu navegador não possui suporte para esta aplicação!");
	
 	//limpa o select
    var genero=document.getElementById("genero");
    while(genero.options.length>0) genero.options[0]=null;
    genero.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ");

    //Monta a url com a uf
    ajax.open("GET","herbariodigital.php?modo=form&acao=buscagen&familia="+familia,true);

    ajax.onreadystatechange=function() {
        if (ajax.readyState==4){
            //limpa o select
            var g=document.getElementById("genero")
            while(g.options.length>0)g.options[0]=null
            //Transforma a lista de cidades JSON em Javascript
            var ageneros=eval((ajax.responseText))
            //popula o select com a lista de cidades obtida
                g.options[g.options.length]=new Option("- - Escolha um gênero de "+familia+" - -","");
            for(var i=0;i<ageneros.length;i++){
                ageneros[i]=unescape(ageneros[i]);
                g.options[g.options.length]=new Option(ageneros[i],ageneros[i]);
            }
        }
    }

    ajax.send(null)
}

////////////////////////
var numImg=1;
function anuncioPousada(nome){
	var div = document.getElementById('anuncioPousada');
	var clique = div.childNodes[1].lastChild.firstChild;
	if (clique.style.color == 'red'){
	    clique.style.color = 'blue';
  	} else {
    	clique.style.color = 'red';
  	}
}

///////////////////////
function mudaImagemAnuncio(nome){
	var div = document.getElementById('anuncioPousada');
		var imgAnun = div.firstChild;
	if(numImg<5){
		numImg = numImg+1;
		//alert(numImg);
	} else {
		numImg = 1;	
	}
	if(imgAnun.href=="http://www.hotelmandala.com.br/"){
		imgAnun.href="http://www.pousadamandalapirenopolis.com.br/";
		div.childNodes[1].lastChild.firstChild.href = "http://www.pousadamandalapirenopolis.com.br/";
	} else {
		imgAnun.href="http://www.hotelmandala.com.br/"; 
		div.childNodes[1].lastChild.firstChild.href = "http://www.hotelmandala.com.br/";	
	}
	imgAnun.firstChild.src = 'imagens/banners/mandala'+numImg+'.jpg';	
}

//////////////////////
var popup;
var intervalo;
function mostrarpopup(){
	popup = document.getElementById('popup');
	popup.style.display = 'block';
	intervalo = window.setInterval(transpop,2000);
}

/////////////////////
var alpha=1;
function transpop(){
	popup.style.opacity = alpha;
	popup.style.filter = 'alpha(opacity='+(alpha*100)+')';
	alpha = (alpha-0.1);
	//alert(alpha);
	if(alpha<0.5){
		clearInterval(intervalo);
		popup.style.display = 'none';
	}
}

//////////////////
window.onload = function(){
   	//dimensiona();
	//var intervalID = setInterval(dimensiona, 1000);
}