window.addEvent("domready", function(){
	$$('.menu-toggle div').each(function(item, index){
		if(item.hasClass('section') || item.hasClass('current')){
			$$('.menu-content')[index].setStyle("display", "block");
			$$('.menu-content')[index].setStyle("opacity", "1");
			$$('.menu-content')[index].setStyle("height", "auto");
		}else{
			item.addEvent("mouseenter", function(){
				item.set('class', 'current');
			});
			item.addEvent("mouseleave", function(){
				item.set('class', 'link');
			});
			$$('.menu-content')[index].setStyle("display", "none");
			$$('.menu-content')[index].setStyle("opacity", "0");
			$$('.menu-content')[index].setStyle("height", "0px");
		}
	});

	$$('.menu-toggle').each(function(item, index){
		item.addEvent("click", function(){
			$$('.menu-content').each(function(item1, index1){
				var anima = new Fx.Morph(item1, {
					wait: false,
					duration: 'short',
					transition: Fx.Transitions.Quad.easeInOut
				});
				if(index1 != index){
					anima.start({
					'display': 'none',
					'visibility': 'hidden',
					'opacity': 0
					});
					item1.setStyle('height', 0);
				}else{
					if(item1.getStyle("height").toInt() == 0){
						var alt = 0;
						/*item1.getElements('li').each(function(item2, index2){
						var size = item2.getSize();
						alt += size.y;
						});*/
						anima.start({
						'display': 'block',
						'visibility': 'visible',
						'opacity': 1
						});
						item1.setStyle('height', 'auto');
					}else{
						anima.start({
						'display': 'none',
						'visibility': 'hidden',
						'opacity': 0,
						'height': 0
						});
					}
				}
			});
		});
	});

	$('fnormal').addEvent("click", function(){
		$('conteudo').getElements('p').each(function(item, index){
			item.setStyle("font-size", "11px");
		});
		$('conteudo').getElements('h2').each(function(item, index){
			item.setStyle("font-size", "12px");
		});
		$('conteudo').getElements('li').each(function(item, index){
			item.setStyle("font-size", "11px");
		});
		$('conteudo').getElements('a').each(function(item, index){
			item.setStyle("font-size", "11px");
		});

		$('conteudo').getElements('td').each(function(item, index){
			item.setStyle("font-size", "11px");
		});

		$('topo').getElements('a').each(function(item, index){
			item.setStyle("font-size", "10px");
		});

		$('topo').getElements('li').each(function(item, index){
			item.setStyle("font-size", "10px");
		});

		$('esq').getElements('a').each(function(item, index){
			item.setStyle("font-size", "10px");
		});

		$('rodape').getElements('li').each(function(item, index){
			item.setStyle("font-size", "11px");
		});

	});

	$('fpequena').addEvent("click", function(){
		$('conteudo').getElements('p').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});
		$('conteudo').getElements('h2').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});
		$('conteudo').getElements('li').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});
		$('conteudo').getElements('a').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});

		$('conteudo').getElements('td').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});
		$('rodape').getElements('li').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() - 1);
		});
		$('topo').getElements('a').each(function(item, index){
			item.setStyle("font-size", "10px");
		});
		$('topo').getElements('li').each(function(item, index){
			item.setStyle("font-size", "10px");
		});

	});

	$('fgrande').addEvent("click", function(){
		$('conteudo').getElements('p').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});
		$('conteudo').getElements('h2').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});
		$('conteudo').getElements('li').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});
		$('conteudo').getElements('a').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});

		$('conteudo').getElements('td').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});

		$('rodape').getElements('li').each(function(item, index){
			item.setStyle("font-size", item.getStyle('font-size').toInt() + 1);
		});
		$('topo').getElements('a').each(function(item, index){
			item.setStyle("font-size", "10px");
		});

		$('topo').getElements('li').each(function(item, index){
			item.setStyle("font-size", "10px");
		});
	});





	if($("extrabtn")){
		var	fechado = true;
		var anima = new Fx.Tween("extra", {
			wait:false,
			transition:Fx.Transitions.Quad.easeInOut
		});
		$("extrabtn").addEvent("click", function(){
			if(fechado){
				$('extra').setStyle("display", "block");
				anima.start("height", 80);
				fechado = false;
			}else{
				$('extra').setStyle("display", "none");
				anima.start("height", 0);
				fechado = true;
			}
		});
	}

	if($('cn')){
		var req = new Request.HTML({url:'/noticias/NoticiasAjax.php',
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('cn').set('text', '');
			//Inject the new DOM elements into the results div.
			$('cn').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('cn').set('text', 'The request failed.');
		}
		}).get({'op': 'destaqueAjax'});
	}

	if($('extra')){
		$('extra').setStyle("display", "none");
		var req = new Request.HTML({url:'/noticias/NoticiasAjax.php',
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('extra').set('text', '');
			//Inject the new DOM elements into the results div.
			$('extra').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('extra').set('text', 'The request failed.');
		}
		}).get({'op': 'ultimasAjax'});
	}
	if($$('.togglers')){
		var myAccordion = new Accordion($$('.togglers'), $$('.elements'), {
			display: -1,
			alwaysHide: true
		});
	}

});


function clearDefaultandCSS(el) {
	if (!el.defaultValue) {
		el.defaultValue = el.value;
	}
	if (el.defaultValue == el.value) {
		el.value = "";
	}
	/*	// If Dynamic Style is supported, clear the style
	removeClass(el, "patternFormFieldDefaultColor"); /* removeClass is included in TwistyContrib/twist.js */
}
function setDefaultText(el) {
	if (el.value == "" && el.defaultValue) el.value = el.defaultValue;
	//	addClass(el, "patternFormFieldDefaultColor");
}

function seleciona(targ,selObj,restore){ //v3.0
	if(selObj.options[selObj.selectedIndex].value.substr(0,5) == 'http:'){
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}else if(selObj.options[selObj.selectedIndex].value == 'vazio'){
		document.forms['consultaProcesso'].elements['consulta'].style.background='#f2f2f2';
		document.forms['consultaProcesso'].elements['consulta'].disabled = true;
	}else{
		document.forms['consultaProcesso'].elements['consulta'].disabled = false;
		document.forms['consultaProcesso'].elements['consulta'].style.background='#FFFFFF';

	}
}

//---------------------------------------

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
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_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}

function popup(x) { //v6.0
	window.open("popup.php?forum="+x,"foruns","height=180,width=400,left=0,top=0,scrollbars=yes");
}
function printPage() {
	if (window.print) {
		window.print();
		return false;
	}
	return true;
}
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 apenasnumericos(caracter) {
	if(document.all) { // Internet Explorer
		var tecla = caracter.keyCode;
	} else { // Nestcape
		var tecla = caracter.which;
	}
	if(tecla > 47 && tecla < 58) { // numeros de 0 a 9
		return true;
	}else if (tecla == 8 || tecla == 0 || tecla == 13) { // backspace
		return true;
	}else{
		return false;
	}
}

function FormatDate(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 ) {
			Campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		}
		if ( tam >= 5 && tam <= 10 ){
			Campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 );
		}
	}
}
function FormataCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres)
{
	var wTecla, wVr, wTam;
	// alert(pForm[pCampo].value);
	wTecla = pTeclaPres.keyCode;
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "-", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ",", "" );
	wVr = wVr.toString().replace( "/", "" );
	wTam = wVr.length ;

	if (wTam < pTamMax && wTecla != 8) { wTam = wVr.length + 1 ; }
	if (wTecla == 8 ) { wTam = wTam - 1 ; }
	if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
		if ( wTam <= 2 ){ pForm[pCampo].value = wVr; }
		if (wTam > pPosTraco && wTam <= pTamMax) { wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam); }
		if ( wTam == pTamMax){ wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam); }
		pForm[pCampo].value = wVr;
	}
}

function valida(form) {
	if(form.cpf.value == '') {
		alert('Favor informar número do CPF/CNPJ. ');
		form1.cpf.focus();
		return false;
	}
	if(form.senha.value=='') {
		alert('Favor informar a Senha.');
		form1.senha.focus();
		return false;
	}
	return true;
}

function LembrarSenha() {
	window.open('dj/recuperasenha.php?pag=14&ord=58&cpf='+sonumeros(form1.cpf.value),'_self');
}

function ValidaCpf(num){
	if(num.length == 11){
		n1=num.substr(0,1)*1; n2=num.substr(1,1)*1; n3=num.substr(2,1)*1; n4=num.substr(3,1)*1;
		n5=num.substr(4,1)*1; n6=num.substr(5,1)*1; n7=num.substr(6,1)*1; n8=num.substr(7,1)*1;
		n9=num.substr(8,1)*1;
		d1= 11 - ((n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10)%11);
		if (d1 >= 10) d1 = 0;
		d2= 11 - ((d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11) % 11);
		if (d2 >= 10) d2 = 0;
		if ((d1+d2) != (num.substr(9,1)*1 + num.substr(10,1)*1)){
			alert('CPF inválido');
			form1.cpf.focus();
			return false;
		}
	}
	else {
		if(num.length == 14){
			n1=num.substr(0,1)*1; n2=num.substr(1,1)*1; n3=num.substr(2,1)*1; n4=num.substr(3,1)*1;
			n5=num.substr(4,1)*1; n6=num.substr(5,1)*1; n7=num.substr(6,1)*1; n8=num.substr(7,1)*1;
			n9=num.substr(8,1)*1; n10=num.substr(9,1)*1; n11=num.substr(10,1)*1; n12=num.substr(11,1)*1;
			d1= 11 - ((n12*2+n11*3+n10*4+n9*5+n8*6+n7*7+n6*8+n5*9+n4*2+n3*3+n2*4+n1*5)%11);
			if (d1 >= 10) d1 = 0;
			d2= 11 - ((d1*2+n12*3+n11*4+n10*5+n9*6+n8*7+n7*8+n6*9+n5*2+n4*3+n3*4+n2*5+n1*6) % 11);
			if (d2 >= 10) d2 = 0;
			if ((d1+d2) != (num.substr(12,1)*1 + num.substr(13,1)*1)){
				alert('CNPJ inválido');
				form1.cpf.focus();
				return false;
			}
		}
		else{
			alert('Favor informar CPF/CNPJ com número dígitos correto.');
			form1.cpf.focus();
			return false;
		}
	}
	return true;
}

function sonumeros (string) {
	s = '';
	for (x=0;x<string.length;x++) {
		if(string.substr(x,1) == '.') { s += ''; }
		else if (string.substr(x,1) == '/') { s += ''; }
		else if (string.substr(x,1) == ' ') { s += ''; }
		else if (string.substr(x,1) == '-') { s += ''; }
		else if (string.substr(x,1) == '*') { s += ''; }
		else if (string.substr(x,1) == '<') { s += ''; }
		else if (string.substr(x,1) == '>') { s += ''; }
		else if (string.substr(x,1) == '%') { s += ''; }
		else if (string.substr(x,1) == '#') { s += ''; }
		else if (string.substr(x,1) == '@') { s += ''; }
		else if (string.substr(x,1) == '(') { s += ''; }
		else if (string.substr(x,1) == ')') { s += ''; }
		else if (string.substr(x,1) == '|') { s += ''; }
		else if (string.substr(x,1) == '_') { s += ''; }
		else { s += string.substr(x,1); }
	}
	return (s);
}

function checkup(form) {
	if( valida(form) && ValidaCpf(sonumeros(form.cpf.value)) ) { return true; }
	return false
}

function webmail() {
	window.open('mail/msglist.php','webmail','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=790,height=500,top=2,left=2')
	user = formwebmail.usuario.value
	password = formwebmail.pass.value
	formwebmail.reset()
	formwebmail.f_user.value = user
	formwebmail.f_pass.value = password
	formwebmail.six.value = 0
}

function djcleanfields() {
	cpff = formdj.ccpf.value
	senhaa= formdj.ssenha.value
	formdj.reset()
	formdj.cpf.value = cpff
	formdj.senha.value = senhaa
	formdj.frame.value = 'bogus'
}

function postquery(consulta, local) {
	var template =  /^[0-9\-\.]+/
	/*if (!template.test(consulta.elements('dePesquisa').value)) {
	alert('Insira um número de processo válido para esta pesquisa.')
	consulta.elements('dePesquisa').value = ''
	consulta.elements('dePesquisa').focus()
	return false
	}*/
	GET = ''
	for ( var i=0,n=consulta.elements.length; i<n; i++ ) { GET +=consulta.elements[i].name+'='+consulta.elements[i].value+'?' }
	//window.open('consult_view.html?open='+local+'?_'+GET,'_self','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=787,height=546,top=2,left=10')
	GET2 = local+'?_'+GET
	consulta.reset()
	consulta.elements('open').value = GET2
	return true
}
function pop(html,path) {
	window.open(html+'?arq='+path,'photo','toolbars=no, scrollbars=no')
}
var tgs = new Array('span');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large' );
var startSz = 1;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;

	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 4 ) sz = 4;
	startSz = sz;

	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function efetuaPesquisa(){
	var selObj = document.forms['form1'].elements['select'];
	var opcao = selObj.options[selObj.selectedIndex].value;
	var consulta = document.forms['form1'].elements['textfield'].value;
	switch(opcao){
		case "consulta":
		document.forms['form1'].action = "http://www.trf3.gov.br/trf3r/index.php?id=26";
		document.forms['form1'].elements['v1'].value = "Consulta";
		document.forms['form1'].elements['v1'].name = "op";
		document.forms['form1'].elements['textfield'].name = "Processo";
		return true;
		break;

		case "acordao":
		document.forms['form1'].action = "http://www.trf3.gov.br/trf3r/index.php?id=20";
		document.forms['form1'].elements['v1'].value = "resultado";
		document.forms['form1'].elements['v1'].name = "op";
		document.forms['form1'].elements['textfield'].name = "processo";
		return true;
		break;

		case "atos":
		document.forms['form1'].action = "http://www.trf3.gov.br/trf3r/index.php?id=61&min=20";
		document.forms['form1'].elements['v1'].value = "buscar";
		document.forms['form1'].elements['v1'].name = "op";
		document.forms['form1'].elements['v2'].value = "0";
		document.forms['form1'].elements['v2'].name = "min";
		document.forms['form1'].elements['textfield'].name = "query";
		return true;
		break;

		case "jfsp":
		document.forms['form1'].action = "http://www.jfsp.jus.br/cp_varas.htm";
		document.forms['form1'].elements['v1'].value = "11";
		document.forms['form1'].elements['v1'].name = "Ind";
		document.forms['form1'].elements['v2'].value = "0";
		document.forms['form1'].elements['v2'].name = "Forum";
		document.forms['form1'].elements['v3'].value = "11";
		document.forms['form1'].elements['v3'].name = "Consulta";
		document.forms['form1'].elements['textfield'].name = "Proc";
		return true;
		break;

		/*case "jef":
		document.forms['form1'].action = "http://jef.jfsp.gov.br/consultapro.php?tela=1&pagina=";
		document.forms['form1'].elements['v1'].name = "frase";
		document.forms['form1'].elements['frase'].value = "";
		document.forms['form1'].elements['textfield'].name = "num_regist";
		return true;
		break;*/
	}
}

function jumpMenu(){ //v3.0
	var selObj = document.forms['form1'].elements['select'];
	if(document.all) { // Internet Explorer
		var targ = 'parent';
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	}else{
		location.href = selObj.options[selObj.selectedIndex].value;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

var hotkey=42 // * JFSP
var destination="http://www.jfsp.jus.br/foruns-federais/"

var hotkey1=35 // # TRF3R
var destination1="http://www.trf3.jus.br/trf3r/index.php?id=26"

var hotkey2=37 // % JEF
var destination2="http://www.jfsp.jus.br/jef/"

if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e){
	if (document.layers){
		if (e.which==hotkey){
			window.location=destination

		}else if (e.which==hotkey1){
			window.location=destination1

		}else if (e.which==hotkey2){
			window.location=destination2
		}
	}else if (document.all){
		if (event.keyCode==hotkey){
			window.location=destination
		}else if (event.keyCode==hotkey1){
			window.location=destination1
		}else if (event.keyCode==hotkey2){
			window.location=destination2
		}
	}
}
document.onkeypress=backhome

isNS = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

function mostraJan(parametro) {
	if (parametro == '1'){
		if (isIE){
			document.all.Layer1.style.visibility = "visible";
		}else if (isNS){
			document.getElementById("Layer1").style.visibility = "visible";
		}
	}else{
		if (isIE){
			document.all.Layer1.style.visibility = "hidden";
		}else if (isNS){
			document.getElementById("Layer1").style.visibility = "hidden";
		}
	}
}

function tocaAudio(id) {
	janela = window.open("http://www.trf3.jus.br/som2.php?ConsultaTRF="+id, "som", "width=0,height=0");
}

function abreJanela(link, nome, prop){
	janela = window.open(link, nome, prop);
	location.href=document.URL;
}

function imagemg(linkimg,width,height) {
	window.open(linkimg,"imagem","height="+height+",width="+width+",left=0,top=0,scrollbars=no");
}

function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}

window.defaultStatus = " INTERNET - TRF3ª REGIÃO";
