// 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))
        {
            x.className = 'aba_on';
            document.getElementById('container_'+ opcao).style.display = 'block';
        }
        else
        {
            document.getElementById(aba + '_' + (i)).className = 'aba_off';
            document.getElementById('container_'+ (i)).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='[+]';
			}
			
		}
	}
}

//BGS
function DefineFundo(area)
{
    switch(area)
    {
        case "Ecopatio":
        case "Quem_Somos":
        case "Infra_Estrutura":
        case "Localizacao":
        case "Estatisticas":
        case "Seguranca,_Qualidade_e_Meio Ambiente":
        case "A_Ecorodovias":
        case "Artigos":
        case "Clipping":
        case "Entrevistas":
        case "Nossos_Clientes":
        case "Fale_Conosco":
			document.body.className = "bg01";
            break;
            
        case "Cameras_On_Line":
        case "Fotos":
        case "Patio_Regulador_de_Veiculos_de_Carga":
        case "Dicas":
        case "Mapas":
        case "Seguranca_na_Estrada":
        case "Servicos_na_Rodovia":
        case "Postos_de_Servico":
        case "Links":
        case "Consultor_On_Line":
            document.body.className = "bg02";
            break;
        
        default: document.body.className = "bg01";
            break;
    }
}


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 fecharDHTML() {
	document.getElementById('divDhtmlHome').style.display = 'none';
}