var url = document.URL
var server =  url.split("/")[0] + "/" + url.split("/")[1] + "/" + url.split("/")[2] 
var isIntranet = (((url.split("/")[2]).substr(0,4)).toUpperCase() == "WEB1")

function BodyOnload(){
	cmDrawFromText ('testHtmlMenu', 'vbl', cmThemePanel, 'ThemePanel');
	var query = window.location.search.substring(1);
	var parms = query.split('?');
	var file = parms[0];
	if (file.substr(0,4) == "dec/") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/arquivos/decisoes/" + file.substr(4,file.lenght) + ".pdf"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};
	if (file.substr(0,3) == "mrj") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/mrj/consultarLocal.html"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};
	if (file.substr(0,4) == "pag/") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/paginas/" + file.substr(4,file.lenght) + ".htm"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};
	if (file.substr(0,3) == "lv/") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/locais/" + file.substr(3,file.lenght) + ".html"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};	
	if (file.substr(0,3) == "1t/") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/1Turno/" + file.substr(3,file.lenght) + ".html"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};	
	if (file.substr(0,3) == "2t/") { 
//		alert(file.substr(0,4))
		arquivo =  "/eleicoes/2008/2turno/" + file.substr(3,file.lenght) + ".html"
//		alert(arquivo)
		document.getElementById("conteudo").src = arquivo 
	};	

}

function abre_url(url)
{
	var link_sel = url;
	var verifica_link_externo = /^http/;
	if (verifica_link_externo.test(link_sel))
	{
		window.open(link_sel,"blank");
	}
	else
	{
		parent.location = link_sel;
	}
}

function abre_pdf(url)
{
	window.open(url,"blank");
}


function exibe(id){
	x = document.getElementById("conteudo")
	x.src = id
}

function verificaUrl()
{
	if (opener != null) {
		if ((opener.urlEleicao != null) && (opener.urlEleicao.length > 0))
		{
			exibe(opener.urlEleicao);
		}
	}
}

function prepara_print(){
	if (window.parent.frames.length == 0) {
		
//		obj =  document.getElementById("body")
		obj2  =  document.getElementById("printer")
		obj3  =  document.getElementById("header")	
		corpo =  document.getElementById("area")	
		
//		obj.style.height = "100%";
//		obj.style.width = "640px";
//		obj.style.overflow = "";
		
		obj2.style.display = "none";
		obj3.style.display = "";
		if ( corpo != null ) {
			corpo.style.height = '100%';
		}
		
		window.print()
	}
}

function imprimir() {
	window.open(document.location.href)
}

function preenche(tipo) {
	if ( tipo == "res" ){
		if ( isIntranet ) {
			document.write("<a href=javascript:window.location='resolucoes/default.asp'>Resoluções</a>")
		}
		else {
			document.write("<a href=javascript:abre_url('http://www.tse.jus.br/downloads/eleicoes2006/instrucoes_resolucoes.html')>Calendário completo</a>")			
		}
	}	
	if ( tipo == "mnu_res" ){
		if ( isIntranet ) {
			document.write("<a href=javascript:exibe('resolucoes/default.asp')>Resoluções</a>")
		}
		else {
			document.write("<a href=javascript:abre_url('http://www.tse.jus.br/downloads/eleicoes2006/instrucoes_resolucoes.html')>Calend&aacute;rio completo</a>")			
		}
	}		
	if ( tipo == "mnu_prop" ){
		if ( isIntranet ) {
			document.write("<a href=javascript:exibe('arq_prestacao/horeleitoral2006.pdf')>Hor&aacute;rios</a>")
		}
		else {
			document.write("<a href=javascript:exibe('arq_prestacao/horeleitoral2006.pdf')>Hor&aacute;rios</a>")			
		}
	}		
	if ( tipo == "jurisprudencia" ){
		if ( isIntranet ) {
			document.write("<a href=javascript:abre_url('http://web1.tre-sp.jus.br/eleicao/2006/desincompatibilizacao/unificada.pdf')>Tabela de Desincompatibiliza&ccedil;&atilde;o</a>")
		}
		else {
			document.write("<a href=javascript:abre_url('http://www.tre-sp.jus.br/legislacao/desincompatibilizacao/unificada.pdf')>Tabela de Desincompatibiliza&ccedil;&atilde;o</a>")
		}
	}		

	if ( tipo == "stat" ){
		if ( isIntranet ) {
			abre_url('http://web1.tre-sp.jus.br:8080/estat/')			
		}
		else {
			abre_url('http://www2.tre-sp.jus.br/estat/')
		}
	}		
}

window.onload = verificaUrl;
window.onload = prepara_print;

