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 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;
	    }
	}
}

function showMsgMapa(obj){
	if(document.getElementById){
	    var el = document.getElementById(obj);
	    var ar = document.getElementById("msgMapas");
		alert ("aqui");
	    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";
	    }
	}
}



/************ LIGHTBOX ***************/
function abreLightbox() {
		document.getElementById('modalBox').style.display = 'block';
}

function fechaLightbox() {
		document.getElementById('modalBox').style.display = 'none';
}

// ---------------------------------------------------

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='/iFileExplorer/Dados/Arquivos/EcoVias Site/img/conteudo/ico_pergunta_menos.gif';
		}
		else
		{
			aDuvida.style.display='none';
			aImagem.src='/iFileExplorer/Dados/Arquivos/EcoVias Site/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 = '/iFileExplorer/Dados/Arquivos/Ecovias%20Site/img/botoes/bt_aba_anchieta.gif';
		document.getElementById("abaConego").src = '/iFileExplorer/Dados/Arquivos/Ecovias%20Site/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 = '/iFileExplorer/Dados/Arquivos/Ecovias%20Site/img/botoes/bt_aba_conego_domenico.gif';
		document.getElementById("abaAnchieta").src = '/iFileExplorer/Dados/Arquivos/Ecovias%20Site/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('/iFileExplorer/Dados/Arquivos/EcoVias Site/htm/tabela01.htm','popup','width=735,height=580,scrollbars=yes,resizable=no,top=50,left=50')
}

//function mostraMapa() {
//	document.getElementById('modalBox').style.display='block';
//	bloqueiaBarra();
//}

function fechaMapa() {
	document.getElementById('boxMapa').style.display='none';
	document.getElementById('msgMapas').style.display='none';
}

//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);
//}

function ClimaTempoToggleTable(p_indiceTabela, p_Acao, p_ClientId){
    var TabelaSeguinte;
    //ctl00_ctl00_cplhConteudo_rptClimaTempo_ctl11_tblClimaTempo11
    var ClientIdAtual;
    var ClientIdSeguinte;
	var ClientIdAnterior;
	
    ClientIdAtual = p_ClientId.substring(0, p_ClientId.lastIndexOf("ctl")) + "ctl0" + (p_indiceTabela) + "_";
    ClientIdSeguinte = p_ClientId.substring(0, p_ClientId.lastIndexOf("ctl")) + "ctl0" + (p_indiceTabelaProx) + "_";
    ClientIdAnterior = p_ClientId.substring(0, p_ClientId.lastIndexOf("ctl")) + "ctl0" + (p_indiceTabelaAnt) + "_";
	
    var TabelaAtual = document.getElementById(ClientIdAtual + "tblClimaTempo" + p_indiceTabela);
    //alert(ClientId);
    
    switch(p_Acao){
        case 'A':
            TabelaSeguinte = document.getElementById(ClientIdSeguinte + "tblClimaTempo" + (parseInt(p_indiceTabela) - 1));
            if(!TabelaSeguinte){
                var Tabelas = document.getElementsByTagName("table");
                for(i = 0; i < Tabelas.length; i ++){
                    if(Tabelas[i].id.indexOf(ClientIdAnterior + "tblClimaTempo") != -1){
                        TabelaSeguinte = Tabelas[i];
                    }
                }
            }
            break;
        case 'P':
            TabelaSeguinte = document.getElementById(ClientIdSeguinte + "tblClimaTempo" + (parseInt(p_indiceTabela) + 1));
            //alert(ClientIdSeguinte + "tblClimaTempo" + (parseInt(p_indiceTabela) + 1));
            if(!TabelaSeguinte){
                TabelaSeguinte = document.getElementById(ClientIdSeguinte + "tblClimaTempo0");
            }
            break;
    }

	if(TabelaSeguinte)
	{
		TabelaSeguinte.style.display = '';
	    TabelaAtual.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 fecharDHTML() {
	document.getElementById('divDhtmlHome').style.display = 'none';
}