// JavaScript Document
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//TESTE

function hideSelectBoxes(){

	selects = document.getElementsByTagName("select");

	for (i = 0; i != selects.length; i++) {

		selects[i].style.visibility = "hidden";

	}

}

// ---------------------------------------------------

function showMsgMapa(obj){
	if(document.getElementById){
	    var el = document.getElementById(obj);
	    var ar = document.getElementById("msgMapas");
		
	    if(el.style.display == "none"){
		    for (var i=0; i<ar.length; i++){
			    ar[i].style.display = "none";
		    }
		    el.style.display = "block";
	    }else{
		    el.style.display = "none";
	    }
	}
}

function mostraDuvidas(qual){
	var aDuvida = document.getElementById(qual);
	var aImagem = document.getElementById('img'+qual);
		if(aDuvida.style.display=='' || aDuvida.style.display=='none' )
		{
			aDuvida.style.display='block';
			aImagem.src='../Util/img/conteudo/ico_pergunta_menos.gif';
		}
		else
		{
			aDuvida.style.display='none';
			aImagem.src='../Util/img/conteudo/ico_pergunta_mais.gif';
		}				
	}
	
function swapAba(e,bImg) {
	if(e == 1) {
		document.getElementById("tblHome1").style.display = 'block';
		document.getElementById("tblHome2").style.display = 'none';
		document.getElementById("abaAnchieta").src = 'Util/img/botoes/bt_aba_anchieta.gif';
		document.getElementById("abaConego").src = 'Util/img/botoes/bt_aba_conego_domenico_off.gif';
	}
	else if(e == 2) {
		document.getElementById("tblHome2").style.display = 'block';
		document.getElementById("tblHome1").style.display = 'none';
		document.getElementById("abaConego").src = 'Util/img/botoes/bt_aba_conego_domenico.gif';
		document.getElementById("abaAnchieta").src = 'Util/img/botoes/bt_aba_anchieta_off.gif';
	}
}

function showMenu(e) {
	var ele = e.getElementsByTagName("ul")[0];	
	if(ele.style.display!='block') ele.style.display='block';
}

function hideMenu(e) {
	e.getElementsByTagName("ul")[0].style.display='none';
}

function aplicaFlash(swf, width, height, wmode, cache, flashvars) {
	var noCache = "";
	if (cache == undefined || cache == '') {var noCache = "?" + new Date();}
	if (wmode != "opaque" && wmode != "transparent") {wmode = "transparent";}
	var monta_swf = "";
	monta_swf += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='"+ width +"' height='"+ height +"' title=''>";
	monta_swf += "<param name='movie' value='"+ swf +"'>";
	monta_swf += "<param name='quality' value='high'>";
	monta_swf += "<param name='menu' value='0'>";
	monta_swf += "<param name='flashvars' value='"+ flashvars +"'>";	
	monta_swf += "<param name='wmode' value='"+ wmode +"'>";
	monta_swf += "<embed src='"+ swf +"' flashvars='"+ flashvars +"' quality='high' wmode='"+ wmode +"' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ width +"' height='"+ height +"'></embed>";
	monta_swf += "</object>";
	//document.write('<textarea rows=40 cols=80>' + monta_swf + '</textarea>');
	document.write(monta_swf);
}

// POP-UP
function popPedagios(){
	window.open('tabela01.htm','popup','width=735,height=580,scrollbars=yes,resizable=no,top=50,left=50')
}

function popImpressao(){
	window.open('../impressao.htm','popup','width=670,height=580,scrollbars=yes,resizable=no,top=50,left=50')
}

function mostraMapa() {
	document.getElementById('modalBox').style.display='block';
	/*bloqueiaBarra();*/
}

function fechaMapa() {
	document.getElementById('modalBox').style.display='none';
	/*liberaBarra();*/
}

function bloqueiaBarra()
{
    is = new checkBrowser();
    if(is.ie6)
	{
		document.getElementById('corpo').style.overflow = 'hidden';
	}
	else
	{
		if (is.ie)
		{
			document.getElementById('corpo').scroll = 'no';
		}
		else
		{
			document.getElementById('corpo').style.overflow = 'hidden';
		}
	}
}

function liberaBarra()
{
    is = new checkBrowser();
    if(is.ie6)
	{
		document.getElementById('corpo').style.overflow = 'scroll';
	}
	else
	{
		if (is.ie)
		{
			document.getElementById('corpo').style.overflow = 'scroll';			
		}
		else
		{
			document.getElementById('corpo').style.overflow = 'scroll';
		}
	}
}

function checkBrowser(){
	T=this;
	b=navigator.appName;
	v=navigator.appVersion;
	u=navigator.userAgent;
	if(b=='Netscape')T.b='ns'
	else if(b=='Microsoft Internet Explorer')T.b='ie'
	else T.b=b
	T.v=parseInt(v);
	T.ns=(T.b=='ns'&&T.v>=4);
	T.ns4=(T.b=='ns'&&T.v==4);
	T.ns5=(T.b=='ns'&&T.v==5);
	T.ns6=(T.b=='ns'&&T.v==5);
	T.ie=(T.b=='ie'&&T.v>=4);
	T.ie4=(u.indexOf('MSIE 4')>0);
	T.ie5=(u.indexOf('MSIE 5.0')>0);
	T.ie55=(u.indexOf('MSIE 5.5')>0);
	T.ie6=(u.indexOf('MSIE 6.0')>0);
	if(T.ie5)T.v=5;
	if(T.ie55)T.v=5.5;
	if(T.ie6)T.v=6;
	T.min=(T.ns||T.ie);
	T.dom=(T.v>=5);
	T.win=(u.indexOf('Win')>0);
	T.mac=(u.indexOf('Mac')>0);
}

//ABAS

function trocaAbas(aba,opcao)
{
    var x = document.getElementById(aba +'_'+ opcao);
    var listaAbas = document.getElementById('abasLista').getElementsByTagName('div').length;
    for (var i=0; i<listaAbas; i++)
    {
        if (opcao == (i+1))
        {
            x.className = 'aba_on';
            document.getElementById('container_'+ opcao).style.display = 'block';
        }
        else
        {
            document.getElementById(aba + '_' + (i+1)).className = 'aba_off';
            document.getElementById('container_'+ (i+1)).style.display = 'none';
        }
    }
}

//LIGHTBOX
function fechaLightBox() {
	document.getElementById('lightBox').style.display='none';
	document.getElementById('overlay').style.display='none';
}

function abreLightBox(p_divConteudo){
	if(document.getElementById){
		
		var divConteudo = document.getElementById(p_divConteudo);
		var divOverLay = document.getElementById("overlay");
		
		if(divOverLay){
			if(divOverLay.style.display != "block") divOverLay.style.display = "block";
			else divOverLay.style.display = "none";
		}
		
		if(divConteudo){
			if(divConteudo.style.display != "block") divConteudo.style.display = "block";
			else divConteudo.style.display = "none";
		}
	}
}

function mostraMapa() {
	document.getElementById('modalBox').style.display='block';
	/*bloqueiaBarra();*/
}

function fechaMapa() {
	document.getElementById('modalBox').style.display='none';
	/*liberaBarra();*/
}

function faq(idFaq, idMostrar) {
	asDuvidas = document.getElementById(idFaq).getElementsByTagName("dd").length;

	for(i=0; i<asDuvidas; i++) {
		
		if(document.getElementById(idFaq).getElementsByTagName("dd")[i].id != 'faq_' + idMostrar) {
			document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
			document.getElementById('ico_'+(i+1)).innerHTML='[+]';
		}
		else {
		
			if(document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display != 'block') {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'block';
				document.getElementById('ico_'+idMostrar).innerHTML='[-]';
			}
			else {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
				document.getElementById('ico_'+idMostrar).innerHTML='[+]';
			}
			
		}
	}
}

function aplicaFlash(swf, width, height, wmode, cache) {
	var noCache = "";
	if (cache == undefined || cache == '') {var noCache = "?" + new Date();}
	if (wmode != "opaque" && wmode != "transparent") {wmode = "transparent";}
	var monta_swf = "";
	monta_swf += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+ width +"' height='"+ height +"' title=''>";
	monta_swf += "<param name='movie' value='"+ swf + noCache +"'>";
	monta_swf += "<param name='quality' value='high'>";
	monta_swf += "<param name='menu' value='0'>";
	monta_swf += "<param name='wmode' value='"+ wmode +"'>";
	monta_swf += "<embed src='"+ swf + noCache +"' quality='high' wmode='"+ wmode +"' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ width +"' height='"+ height +"'></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}

function carregaVideo(nome) {
	var monta_video = "<object id='mediaPlayer'  width='320' align='left'  height='304' hspace='6' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,0902' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
	monta_video += "<param name='fileName' value='"+nome+"'>";
	monta_video += "<param name='animationatStart' value='1'>";
	monta_video += "<param name='transparentatStart' value='1'>";
	monta_video += "<param name='autoStart' value='1'>"
	monta_video += "<param name='ShowControls' value='1'>";
	monta_video += "<param name='ShowDisplay' value='0'>";
	monta_video += "<param name='ShowStatusBar' value='1'>";
	monta_video += "<param name='loop' value='0'>";
	monta_video += "<embed  type='application/x-mplayer2'  pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer'  name='mediaPlayer'  displaysize='4'  transparentatStart='1' autosize='0' bgcolor='#f3f7ef' showcontrols='1'  showtracker='1' showdisplay='0'  showstatusbar='0'  videoborder3d='1'  width='320'  height='304' src='"+nome+"'  autostart='1'  designtimesp='5311'  loop='0'></embed></object>";
	document.write(monta_video);	
}

$(document).ready(function(){
		$(document).pngFix();
	});
	
var arrayTables = new Array();
var indiceArr = 0;

function navegaTables(p_inc)
{
    escondeTables();
    indiceArr = indiceArr + p_inc;
    if (indiceArr < 0)
        indiceArr = 0;
    else if (indiceArr > arrayTables.length - 1)
        indiceArr = arrayTables.length - 1;
        
    if(document.getElementById(arrayTables[indiceArr])!=undefined){
        document.getElementById(arrayTables[indiceArr]).style.display = "inline";
    }
}

function escondeTables()
{
    for (var i = 0; i < arrayTables.length; i++)
    {
        if(document.getElementById(arrayTables[i])!=undefined){
            document.getElementById(arrayTables[i]).style.display = "none";
        }
    }
}
function fecharDHTML() {
	document.getElementById('divDhtmlHome').style.display = 'none';
}



function element_id(id){
	return document.getElementById(id);
}
function change(Bot_G, Bot_P, Content){
	var Qtda_bot = 4;

	for (i=1; i<=Qtda_bot; i++){
		element_id("bot_0"+[i]).style.display="none";
		element_id("bot_0"+[i]+"_p").style.display="block";
		element_id("text_0"+[i]).style.display="none";
	}

	if (i > 0){
		element_id(Bot_G).style.display="block";
		element_id(Bot_P).style.display="none";
		element_id(Content).style.display="block";
	}
}

function AlternaLightBox(p_divConteudo, p_imgSource){
	if(document.getElementById){
	    
	    var o_divConteudo = document.getElementById(p_divConteudo);
	    var o_OverLay = document.getElementById("msgMapas");
	    
	    if(o_OverLay){
	        if(o_OverLay.style.display != "block") o_OverLay.style.display = "block";
	        else o_OverLay.style.display = "none";
	    }
	    
	    if(o_divConteudo){
	        if(o_divConteudo.style.display != "block") o_divConteudo.style.display = "block";
	        else o_divConteudo.style.display = "none";
	        
	        var o_imgSource = document.getElementById("imgMapas");
	        if(o_imgSource && p_imgSource != "") o_imgSource.src = p_imgSource;
	    }
	}
}