//###############################################################################//
// VARIAVEIS GLOBAIS                                                             //
//###############################################################################//
var ext = "asp";
if (global_numero_serie==2223) {
	var global_out_of_bounds        = 0;
	var global_top_buscas           = 222;
	var global_div4_rapida          = 256;
	if (global_versao==3) {
		var global_top_buscas       = 217; 
		var global_div4_combinada   = 310;
	} else {
		if (global_session_data==1) { 
			var global_div4_combinada   = 355;
		}else{
			var global_div4_combinada   = 327;
		}
	}
	var global_div4_legislacao = 327;
} else {
	var global_out_of_bounds        = -900;	
	var global_top_buscas           = 137;
	var global_div4_rapida          = 171;
	if (global_versao==3) {
		var global_top_buscas       = 132; 
		var global_div4_combinada   = 225;
	} else {
		if (global_session_data==1) { 
			var global_div4_combinada   = 270;
		}else{
			var global_div4_combinada   = 242;
		}
	}
	var global_div4_legislacao = 242;
}
var global_ababr1 = "1px solid "+global_busca_contornos;
var global_ababr2 = "1px solid #e3e3e3";

var global_frame = null;
var main_frame = null;
if (parent.hiddenFrame != null) {
	var global_frame = parent.hiddenFrame;
	var main_frame = parent.mainFrame;
} else if (parent.parent.hiddenFrame != null) {
	var global_frame = parent.parent.hiddenFrame;
	var main_frame = parent.parent.mainFrame;
} else {
	var global_frame = parent.parent.parent.hiddenFrame;
	var main_frame = parent.parent.parent.mainFrame;
};

var global_ficha_marc = 0;
var global_marc_tags = 0;
var volta_div4 = 0;
if (global_boasvindas == 1) {
	global_top_buscas = global_top_buscas + 21;
	global_div4_legislacao = global_div4_legislacao + 21;
	global_div4_rapida = global_div4_rapida + 21;
	global_div4_combinada = global_div4_combinada + 21;
}

//Adequação BBLA - Exibir um link abaixo do banner (metodista)
if (parent.hiddenFrame != undefined) {
	if ((parent.hiddenFrame.iBusca_Projeto > 0) && (global_numero_serie == 3386)) {
		global_top_buscas = global_top_buscas + 20;
		global_div4_legislacao = global_div4_legislacao + 20;
		global_div4_rapida = global_div4_rapida + 20;
		global_div4_combinada = global_div4_combinada + 20;
	}
}

function encodeURL(url)
{
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = url;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function decodeURL(url)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = url;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
   } // while
   return plaintext;
};

//#######################################################################################//
// FUNÇÂO MOVE LAYER                                                                     //
// alterna o modo de busca RAPIDA / COMBINADA e LEGISLAÇÂO ao clicar nas abas                           
//#######################################################################################//
function move_layer() { //v3.0
	var acao,top2,top3,topL,obj1,obj2,obj3,args=move_layer.arguments;
	acao=args[3];
	  if ((obj1=MM_findObj(args[0]))!=null && (obj2=MM_findObj(args[1]))!=null && (obj3=MM_findObj(args[2]))!=null) {
		var tabr = MM_findObj(args[4]);	
		var linkr = MM_findObj(args[6]);
		var tabc = MM_findObj(args[5]);		
		var linkc = MM_findObj(args[7]);
		var tabl = MM_findObj(args[8]);
		var linkl = MM_findObj(args[9]);
		var objL = MM_findObj(args[10]);
		if (global_versao==3) {
			acao = "combinada";
		}
		if (obj1.style && obj2.style && obj3.style && objL.style) {
			obj1=obj1.style;
			obj2=obj2.style;
			obj3=obj3.style;
			objL=objL.style;				
			if (acao == 'rapida') {
				top1 = global_top_buscas;
				top2 = global_out_of_bounds;
				top3 = global_div4_rapida;
				topL = global_out_of_bounds;
				obj1.visibility='visible';
				obj2.visibility='hidden';
				objL.visibility='hidden';				
				if ((linkr != null) && (linkc != null) && (linkl != null)) {
					if (linkr.style && linkc.style) {
						linkr = linkr.style;
						linkc = linkc.style;
						linkl = linkl.style;
						linkr.background = global_aba1;
						linkc.background = global_ababk;
						linkl.background = global_ababk;												
					}
				}
				if ((tabr != null) && (tabc != null) && (tabl != null)) {
						if (tabr.style && tabc.style) {
						tabr = tabr.style;
						tabc = tabc.style;
						tabl = tabl.style;
						tabr.background = global_aba1;
						tabr.borderTop = global_ababr1;
						tabc.background = global_ababk;
						tabc.borderTop = global_ababr2; 
						tabc.borderRight = global_ababr2;
						tabl.background = global_ababk;
						tabl.borderTop = global_ababr2; 
						tabl.borderRight = global_ababr2;  						
					}
				}				
				global_frame.modo_busca = "rapida";
				global_frame.modo_busca_bak = "rapida";
				if ((obj4=MM_findObj('rapida_campo'))!=null) {
					document.frm_rapida.rapida_campo.focus();
				}
			} else if (acao == 'legislacao') {
				top1 = global_out_of_bounds;
				top2 = global_out_of_bounds;
				top3 = global_div4_legislacao;
				topL = global_top_buscas;
				if ((obj5=MM_findObj('div5'))!=null) {
					obj5=obj5.style;
					obj5.top = global_div4_combinada;
				}
				if ((obj6=MM_findObj('div6'))!=null) {
					obj6=obj6.style;
					obj6.top = global_div4_combinada;
				}
				obj1.visibility='hidden';
				obj2.visibility='hidden';
				objL.visibility='visible';
				if ((linkr != null) && (linkc != null)) {
					if (linkr.style && linkc.style) {
						linkr = linkr.style;
						linkc = linkc.style;
						linkl = linkl.style;
						linkc.background = global_ababk;
						linkr.background = global_ababk;
						linkl.background = global_aba2;
					}
				}				
				if ((tabr != null) && (tabc != null)) {
					if (tabr.style && tabc.style) {
						tabr = tabr.style;
						tabc = tabc.style;
						tabl = tabl.style;
						tabc.background = global_ababk;
						tabc.borderTop = global_ababr2; 
						tabc.borderRight = global_ababr2;
						tabr.background = global_ababk;
						tabr.borderTop = global_ababr2;
						tabl.background = global_aba2;
						tabl.borderTop = global_ababr2; 
						tabl.borderRight = global_ababr2; 
					}
				}
				global_frame.modo_busca = "legislacao";
				global_frame.modo_busca_bak = "legislacao";				
				habilitaEntre('ass');
				if (document.frm_legislacao != null) {
					if (document.frm_legislacao.leg_normas != null) {
						document.frm_legislacao.leg_normas.focus();
					} else {
						if (document.frm_legislacao.leg_normas_desc != null) {
							document.frm_legislacao.leg_normas_desc.focus();
						} else {
							document.frm_legislacao.leg_campo1.focus();
						}
					}
				}
			} else {		
				top1 = global_out_of_bounds;
				top2 = global_top_buscas;
				top3 = global_div4_combinada;
				topL = global_out_of_bounds;
				if ((obj5=MM_findObj('div5'))!=null) {
					obj5=obj5.style;
					obj5.top = global_div4_combinada;
				}
				if ((obj6=MM_findObj('div6'))!=null) {
					obj6=obj6.style;
					obj6.top = global_div4_combinada;
				}
				obj1.visibility='hidden';
				obj2.visibility='visible';
				objL.visibility='hidden';
				if ((linkr != null) && (linkc != null)) {
					if (linkr.style && linkc.style) {
						linkr = linkr.style;
						linkc = linkc.style;
						linkl = linkl.style;
						linkc.background = global_aba2;
						linkr.background = global_ababk;
						linkl.background = global_ababk;
					}
				}				
				if ((tabr != null) && (tabc != null)) {
					if (tabr.style && tabc.style) {
						tabr = tabr.style;
						tabc = tabc.style;
						tabl = tabl.style;
						tabc.background = global_aba2;
						tabc.borderTop = global_ababr1;
						tabc.borderRight = global_ababr1;
						tabr.background = global_ababk;
						tabr.borderTop = global_ababr2;
						tabl.background = global_ababk;
						tabl.borderTop = global_ababr2; 
						tabl.borderRight = global_ababr2;  
					}
				}
				global_frame.modo_busca = "combinada";
				global_frame.modo_busca_bak = "combinada";				
				document.frm_combinada.comb_campo1.focus();
			}
			obj1.top=top1;
			obj2.top=top2;
			obj3.top=top3;
			objL.top=topL;
		}
		if (args[2]=='div4') {
			detalhes(global_frame.modo_busca);
		}
		if (args[2]=='div5') {
			fichaMarc(global_frame.modo_busca);
		}
		if (args[2]=='div6') {
			marcTags(global_frame.modo_busca);
		}
	}
}

//#######################################################################################//
// FUNÇÂO validaTecla
//#######################################################################################//
function validaTecla(disp,campo, event, modo, dta,cont,modo_busca,numerico) { 
	var BACKSPACE = 8; 
	var key; 
	var tecla; 
	CheckTAB=true;
	if(navigator.appName.indexOf("Netscape")!= -1) {
		tecla= event.which; 
	} else {
		tecla= event.keyCode; 
	}
	if ( tecla == 13 ) {
		atualizaGeral();
		if (modo == 3) {
			CombBib();
			document.frm_geral.geral_bib.value = global_frame.geral_bib;
			atualizaComb_campos()
			atualizaComb_filtros();
			atualizaComb_logica();
			atualizaComb_opcoes();
			if (global_session_data==1) {
				atualizaComb_outros();
				atualizaComb_datas();
			}
			Confere(dta,modo,cont,modo_busca);
		}else if (modo == 4) {
			AutoresBib();
			atualizaAuts();
			return Confere_aut();
		}else if (modo == 5) {
			atualizaLeg_campos()
			return Confere(dta,modo,cont,modo_busca);
		}else if (modo == 6) {
			atualizaAutsDSI();
			return Confere_aut_dsi();
		}else{		
			RapidaBib();
			var tam_campo = document.frm_rapida.rapida_campo.value.length;
			if (tam_campo < global_limite_min_busca){
				var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
				msg = msg.replace('%s', global_limite_min_busca);
				alert(msg);
				document.frm_rapida.rapida_campo.focus();
				return false;
			} else {
				atualizaRapida();
			}
			document.body.style.cursor = "wait";
			if (global_frame.statusLoading==1) {
				return false;
			}
			var val_campo = Trim(document.frm_rapida.rapida_campo.value);
			var tam_campo = val_campo.length;		
			if (tam_campo >= global_limite_min_busca) {
				return Confere(dta,modo,'valida_tecla',modo_busca);
			}else{
				var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
				msg = msg.replace('%s', global_limite_min_busca);
				alert(msg);
				document.frm_rapida.rapida_campo.focus();
				document.body.style.cursor = "default";
				return false;
			}
		}	
	}
	if ( numerico > 0 ) {
		switch (campo.name){
			case "data_ass_inicio_dia" :
				var tam_campo = document.frm_legislacao.data_ass_inicio_dia.value.length;
				if (tam_campo==2){
					document.frm_legislacao.data_ass_inicio_mes.focus();
				}					
				break;
			case "data_ass_inicio_mes" :
				var tam_campo = document.frm_legislacao.data_ass_inicio_mes.value.length;
				if (tam_campo==2){
					document.frm_legislacao.data_ass_inicio_ano.focus();
				}					
				break;
			case "data_ass_inicio_ano" :
				var tam_campo = document.frm_legislacao.data_ass_inicio_ano.value.length;
				if (tam_campo == 4 && document.frm_legislacao.sel_data_ass.value == 3){
					document.frm_legislacao.data_ass_fim_dia.focus();
				}					
				break;
			case "data_ass_fim_dia" :
				var tam_campo = document.frm_legislacao.data_ass_fim_dia.value.length;
				if (tam_campo==2) {
					document.frm_legislacao.data_ass_fim_mes.focus();
				}					
				break;
			case "data_ass_fim_mes" :
				var tam_campo = document.frm_legislacao.data_ass_fim_mes.value.length;
				if (tam_campo==2){
					document.frm_legislacao.data_ass_fim_ano.focus();
				}					
				break;
		}
		if (global_session_data==1) {
			if (document.frm_combinada.Data_Inicio_dia.value>31){
				alert(getTermo(global_frame.iIdioma, 1283, 'Digite um dia válido.', 0));
				document.frm_combinada.Data_Inicio_dia.focus();
				return false;
			}
			if (document.frm_combinada.Data_Inicio_mes.value>12){
				alert(getTermo(global_frame.iIdioma, 1284, 'Digite um mês válido.', 0));
				document.frm_combinada.Data_Inicio_mes.focus();
				return false;
			}
			if (document.frm_combinada.Data_Fim_dia.value>31){
				alert(getTermo(global_frame.iIdioma, 1283, 'Digite um dia válido.', 0));
				document.frm_combinada.Data_Fim_dia.focus();
				return false;
			}
			if (document.frm_combinada.Data_Fim_mes.value>12){
				alert(getTermo(global_frame.iIdioma, 1284, 'Digite um mês válido.', 0));
				document.frm_combinada.Data_Fim_mes.focus();
				return false;
			}
			switch (campo.name){
				case "Data_Inicio_dia" :
					var tam_campo = document.frm_combinada.Data_Inicio_dia.value.length;
					if (tam_campo==2){
						document.frm_combinada.Data_Inicio_mes.focus();
					}					
					break;
				case "Data_Inicio_mes" :
					var tam_campo = document.frm_combinada.Data_Inicio_mes.value.length;
					if (tam_campo==2){
						document.frm_combinada.Data_Inicio_ano.focus();
					}				
					break;
				case "Data_Inicio_ano" :
					var tam_campo = document.frm_combinada.Data_Inicio_ano.value.length;
					if (tam_campo==4){
						document.frm_combinada.Data_Fim_dia.focus();
					}
					break;
				case "Data_Fim_dia" :
					var tam_campo = document.frm_combinada.Data_Fim_dia.value.length;
					if (tam_campo==2){
						document.frm_combinada.Data_Fim_mes.focus();
					}				
					break;
				case "Data_Fim_mes" :
					var tam_campo = document.frm_combinada.Data_Fim_mes.value.length;
					if (tam_campo==2){
						document.frm_combinada.Data_Fim_ano.focus();
					}				
					break;
				case "Data_Fim_ano" :
					var tam_campo = document.frm_combinada.Data_Fim_ano.value.length;
					if (tam_campo==4){
						document.frm_combinada.bt_comb.focus();
					}
					break;
			} 
		}
	}
}
//#######################################################################################//
// FUNÇÂO Confere
//#######################################################################################//
function Confere(dta,modo,cont,modo_busca) {
	if (modo == 1) {
		RapidaBib();	
		var val_campo = Trim(document.frm_rapida.rapida_campo.value);
		var tam_campo = val_campo.length;		
		global_frame.geral_bib = document.frm_geral.geral_bib.value;
		if (tam_campo >= global_limite_min_busca) {
			SubmeteBusca(1,"resultado");
			return false;
		}else{
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_rapida.rapida_campo.focus();
			return false;
		}
	}
	if (modo == 3) {
		CombBib();
		global_frame.geral_bib = document.frm_geral.geral_bib.value;
		var val_campo1 = Trim(document.frm_combinada.comb_campo1.value);
		var val_campo2 = Trim(document.frm_combinada.comb_campo2.value);
		var val_campo3 = Trim(document.frm_combinada.comb_campo3.value);
		var val_campo4 = Trim(document.frm_combinada.comb_campo4.value);		
		var tam_campo1 = val_campo1.length;
		var tam_campo2 = val_campo2.length;
		var tam_campo3 = val_campo3.length;
		var tam_campo4 = val_campo4.length;
		if (global_session_data==1) {
			var tam_outros = document.frm_combinada.comb_conteudo_outros.value.length;
			var tam_Inicio_dia = document.frm_combinada.Data_Inicio_dia.value.length;
			var tam_Inicio_mes = document.frm_combinada.Data_Inicio_mes.value.length;
			var tam_Inicio_ano = document.frm_combinada.Data_Inicio_ano.value.length;
			var tam_Fim_dia = document.frm_combinada.Data_Fim_dia.value.length;
			var tam_Fim_mes = document.frm_combinada.Data_Fim_mes.value.length;
			var tam_Fim_ano = document.frm_combinada.Data_Fim_ano.value.length;	
		}
		var submete = 1;
		var total = 0;
		if (global_session_data==1) {
			var total_data_inicial = 0;
			var total_data_fim = 0;
			var total_datas = 0;
		}
		if (tam_campo1 > 0 && tam_campo1 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_combinada.comb_campo1.focus();
			submete=0;
			return false;
		}
		if (tam_campo2 > 0 && tam_campo2 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_combinada.comb_campo2.focus();
			submete=0;
			return false;
		}
		if (tam_campo3 > 0 && tam_campo3 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_combinada.comb_campo3.focus();
			submete=0;
			return false;
		}
		if (tam_campo4 > 0 && tam_campo4 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_combinada.comb_campo4.focus();
			submete=0;
			return false;
		}		
		if (global_session_data==1) {		
			if (document.frm_combinada.comb_outros.value == 'nenhum' && tam_outros > 0) {
				alert(getTermo(global_frame.iIdioma, 1286, 'Você precisa escolher um campo.', 0));
				document.frm_combinada.comb_outros.focus();
				submete=0;
				return false;
			}
			if (document.frm_combinada.comb_outros.value != 'tombo') {		
				if (tam_outros > 0 && tam_outros < global_limite_min_busca) {
					var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
					msg = msg.replace('%s', global_limite_min_busca);
					alert(msg);
					document.frm_combinada.comb_conteudo_outros.focus();
					submete=0;
					return false;
				}
			}else{
				if (tam_outros > 0) {
					tam_outros = global_limite_min_busca;
				}
			}
			if (document.frm_combinada.comb_outros.value == 'nenhum' && tam_outros > 0) {
				alert(getTermo(global_frame.iIdioma, 1286, 'Você precisa escolher um campo.', 0));
				document.frm_combinada.comb_outros.focus();
				submete=0;
				return false;
			}
			total_data_inicial = tam_Inicio_dia + tam_Inicio_mes + tam_Inicio_ano;
			total_data_fim = tam_Fim_dia + tam_Fim_mes + tam_Fim_ano;
			if (total_data_inicial > 0 || total_data_fim > 0) {
				if (total_data_inicial > 0) {
					if (!isDate(formataData(document.frm_combinada.Data_Inicio_mes.value,"mes") + "/" + formataData(document.frm_combinada.Data_Inicio_dia.value,"dia") + "/" + formataData(document.frm_combinada.Data_Inicio_ano.value,"ano"))) {
						alert(getTermo(global_frame.iIdioma, 1285, 'Você precisa digitar uma data válida.', 0));
						document.frm_combinada.Data_Inicio_dia.focus();
						return false;
					} else {
						//alert('validou: '+formataData(document.frm_combinada.Data_Inicio_mes.value,"mes") + "/" + formataData(document.frm_combinada.Data_Inicio_dia.value,"dia") + "/" + formataData(document.frm_combinada.Data_Inicio_ano.value,"ano"));
						document.frm_combinada.Data_Inicio_dia.value = formataData(document.frm_combinada.Data_Inicio_dia.value,"dia");
						document.frm_combinada.Data_Inicio_mes.value = formataData(document.frm_combinada.Data_Inicio_mes.value,"mes");
						document.frm_combinada.Data_Inicio_ano.value = formataData(document.frm_combinada.Data_Inicio_ano.value,"ano");
					}
				}
				
				
				if (total_data_fim > 0) {
					var data_valida = true;
					var dif_ano = document.frm_combinada.Data_Fim_ano.value - document.frm_combinada.Data_Inicio_ano.value;
					if (dif_ano < 0) {
						data_valida = false;
					}else if(dif_ano == 0) {
						var dif_mes = document.frm_combinada.Data_Fim_mes.value - document.frm_combinada.Data_Inicio_mes.value;
						if (dif_mes < 0) {
							data_valida = false;
						}else if(dif_mes == 0) {
							var dif_dia = document.frm_combinada.Data_Fim_dia.value - document.frm_combinada.Data_Inicio_dia.value;
							if (dif_dia < 0) {
								data_valida = false;
							}
						}
					}
					if (!isDate(formataData(document.frm_combinada.Data_Fim_mes.value,"mes") + "/" + formataData(document.frm_combinada.Data_Fim_dia.value,"dia") + "/" + formataData(document.frm_combinada.Data_Fim_ano.value,"ano"))) {
						alert(getTermo(global_frame.iIdioma, 1285, 'Você precisa digitar uma data válida.', 0));
						document.frm_combinada.Data_Fim_dia.focus();
						return false;
					} else {
						//alert('validou: '+formataData(document.frm_combinada.Data_Fim_mes.value,"mes") + "/" + formataData(document.frm_combinada.Data_Fim_dia.value,"dia") + "/" + formataData(document.frm_combinada.Data_Fim_ano.value,"ano"));
						document.frm_combinada.Data_Fim_dia.value = formataData(document.frm_combinada.Data_Fim_dia.value,"dia");
						document.frm_combinada.Data_Fim_mes.value = formataData(document.frm_combinada.Data_Fim_mes.value,"mes");
						document.frm_combinada.Data_Fim_ano.value = formataData(document.frm_combinada.Data_Fim_ano.value,"ano");
					}
					if (data_valida==false) {
						alert(getTermo(global_frame.iIdioma, 1059, 'Data inválida, a data inicial deve ser menor que a final.', 0));
						document.frm_combinada.Data_Inicio_dia.focus();
						return false;					
					}
				}
				
			}
			total_datas = parseInt(total_data_inicial) + parseInt(total_data_fim);
			total = parseInt(tam_campo1) + parseInt(tam_campo2) + parseInt(tam_campo3) + parseInt(tam_campo4) + parseInt(total_datas) + parseInt(tam_outros);
		}else{
			total = tam_campo1 + tam_campo2 + tam_campo3 + tam_campo4;
		}
		
		if (total < global_limite_min_busca || submete == 0) {
			alert(getTermo(global_frame.iIdioma, 1289, 'Preencha algum campo para fazer a pesquisa.', 0));
			document.frm_combinada.comb_campo1.focus();
			return false;
		}else{
			SubmeteBusca(3,"resultado");
		}
	}
	if (modo == 5) {
		var tam_campo1 = document.frm_legislacao.leg_campo1.value.length;
		var tam_campo2 = document.frm_legislacao.leg_campo2.value.length;
		var tam_campo3 = document.frm_legislacao.leg_campo3.value.length;
		var tam_campo4 = document.frm_legislacao.leg_campo4.value.length;
		var tam_campo5 = document.frm_legislacao.leg_campo5.value.length;
		var tam_campo6 = document.frm_legislacao.leg_campo6.value.length;
		var tam_num = document.frm_legislacao.leg_numero.value.length;
		if (document.frm_legislacao.leg_normas != null) {
			var tam_normas = document.frm_legislacao.leg_normas.value;
		} else {
			var tam_normas = -1;
		}
		if (document.frm_legislacao.leg_normas_desc != null) {
			var tam_normas_desc = document.frm_legislacao.leg_normas_desc.value.length;
		} else {
			var tam_normas_desc = 0;
		}
		var submete = 1;
		var total = 0;		
		var tam_da1 = document.frm_legislacao.data_ass_inicio_dia.value.length;
		var tam_da2 = document.frm_legislacao.data_ass_inicio_mes.value.length;
		var tam_da3 = document.frm_legislacao.data_ass_inicio_ano.value.length;
		if ((tam_da1 + tam_da2 + tam_da3) > 0) {
			var data_ass_inicio_dia = formataData(document.frm_legislacao.data_ass_inicio_dia.value,"dia");
			var data_ass_inicio_mes = formataData(document.frm_legislacao.data_ass_inicio_mes.value,"mes");
			var data_ass_inicio_ano = formataData(document.frm_legislacao.data_ass_inicio_ano.value,"ano");
			if (!isDate(data_ass_inicio_mes + "/" + data_ass_inicio_dia + "/" + data_ass_inicio_ano)) {
				alert(getTermo(global_frame.iIdioma, 1285, 'Você precisa digitar uma data válida.', 0));
				document.frm_legislacao.data_ass_inicio_dia.focus();
				submete=0;
				return false;
			} else {
				var data_ass_inicio = data_ass_inicio_dia + "/" + data_ass_inicio_mes + "/" + data_ass_inicio_ano;
			}			
		}		
		var sel_data_ass = document.frm_legislacao.sel_data_ass.value;
		if (sel_data_ass==3) {
			if ((tam_da1 + tam_da2 + tam_da3) == 0) {
				alert(getTermo(global_frame.iIdioma, 1287, 'Você precisa digitar uma data inicial.', 0));
				document.frm_legislacao.data_ass_inicio_dia.focus();
				submete=0;
				return false;
			}
			var tam_da4 = document.frm_legislacao.data_ass_fim_dia.value.length;
			var tam_da5 = document.frm_legislacao.data_ass_fim_mes.value.length;
			var tam_da6 = document.frm_legislacao.data_ass_fim_ano.value.length;
			if ((tam_da4 + tam_da5 + tam_da6) == 0) {
				alert(getTermo(global_frame.iIdioma, 1288, 'Você precisa digitar uma data final.', 0));
				document.frm_legislacao.data_ass_fim_dia.focus();
				submete=0;
				return false;
			}			
			var data_ass_fim_dia = formataData(document.frm_legislacao.data_ass_fim_dia.value,"dia");
			var data_ass_fim_mes = formataData(document.frm_legislacao.data_ass_fim_mes.value,"mes");
			var data_ass_fim_ano = formataData(document.frm_legislacao.data_ass_fim_ano.value,"ano");
			if (!isDate(data_ass_fim_mes + "/" + data_ass_fim_dia + "/" + data_ass_fim_ano)) {
				alert(getTermo(global_frame.iIdioma, 1285, 'Você precisa digitar uma data válida.', 0));
				document.frm_legislacao.data_ass_fim_dia.focus();
				submete=0;
				return false;
			} else {
				var data_ass_fim = data_ass_fim_dia + "/" + data_ass_fim_mes + "/" + data_ass_fim_ano;
			}
		} else {
			var tam_da4 = 0;
			var tam_da5 = 0;
			var tam_da6 = 0;
		}	
		if (tam_normas_desc > 0 && tam_normas_desc < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_normas_desc.focus();
			submete=0;
			return false;
		}
		if (tam_campo1 > 0 && tam_campo1 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo1.focus();
			submete=0;
			return false;
		}
		if (tam_campo2 > 0 && tam_campo2 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo2.focus();
			submete=0;
			return false;
		}
		if (tam_campo3 > 0 && tam_campo3 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo3.focus();
			submete=0;
			return false;
		}
		if (tam_campo4 > 0 && tam_campo4 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo4.focus();
			submete=0;
			return false;
		}
		if (tam_campo5 > 0 && tam_campo5 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo5.focus();
			submete=0;
			return false;
		}
		if (tam_campo6 > 0 && tam_campo6 < global_limite_min_busca) {
			var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
			msg = msg.replace('%s', global_limite_min_busca);
			alert(msg);
			document.frm_legislacao.leg_campo6.focus();
			submete=0;
			return false;
		}
		total = parseInt(tam_normas_desc) + parseInt(tam_campo1) + parseInt(tam_campo2) + parseInt(tam_campo3) + parseInt(tam_campo4) + parseInt(tam_campo5) + parseInt(tam_campo6);
		total = parseInt(total) + parseInt(tam_da1) + parseInt(tam_da2) + parseInt(tam_da3) + parseInt(tam_da4) + parseInt(tam_da5) + parseInt(tam_da6);
		if (tam_num > 0) {
			tam_num = global_limite_min_busca;
		}else{
			tam_num = 0;
		}
		if (tam_normas > 0) {
			tam_normas = global_limite_min_busca;
		}else{
			tam_normas = 0;
		}
		total = parseInt(total) + parseInt(tam_num) + parseInt(tam_normas);
		
		if (total < global_limite_min_busca || submete == 0) {
			alert(getTermo(global_frame.iIdioma, 1289, 'Preencha algum campo para fazer a pesquisa.', 0));
			if (document.frm_legislacao.leg_normas != null) {
				document.frm_legislacao.leg_normas.focus();
			} else {
				if (document.frm_legislacao.leg_normas_desc != null) {
					document.frm_legislacao.leg_normas_desc.focus();
				} else {
					document.frm_legislacao.leg_campo1.focus();
				}
			}
			return false;
		}else{
			SubmeteBusca(5,"resultado");
		}
		
	}			
}
//#######################################################################################//
// FUNÇÂO atribuiComb
//#######################################################################################//
function atribuiComb() {
	document.frm_combinada.comb_campo1.value = global_frame.comb_campo1;
	document.frm_combinada.comb_campo2.value = global_frame.comb_campo2;
	document.frm_combinada.comb_campo3.value = global_frame.comb_campo3;
	document.frm_combinada.comb_campo4.value = global_frame.comb_campo4;	
	document.frm_combinada.comb_filtro1.value = global_frame.comb_filtro1;
	document.frm_combinada.comb_filtro2.value = global_frame.comb_filtro2;
	document.frm_combinada.comb_filtro3.value = global_frame.comb_filtro3;
	document.frm_combinada.comb_filtro4.value = global_frame.comb_filtro4;	
	document.frm_combinada.comb_logica1.value = global_frame.comb_logica1;
	document.frm_combinada.comb_logica2.value = global_frame.comb_logica2;
	document.frm_combinada.comb_logica3.value = global_frame.comb_logica3;	
	document.frm_combinada.comb_ano1.value = global_frame.comb_ano1;
	document.frm_combinada.comb_ano2.value = global_frame.comb_ano2;	
	if (document.frm_combinada.comb_material != null) {
		document.frm_combinada.comb_material.value = global_frame.comb_material;
	}
	if (global_versao != 3) {
		if (document.frm_combinada.comb_idioma != null) {
			document.frm_combinada.comb_idioma.value = global_frame.comb_idioma;
		}
	}
	document.frm_combinada.comb_ordenacao.value = global_frame.comb_ordenacao;	
	document.frm_combinada.comb_bib.value = global_frame.geral_bib;
	document.frm_geral.geral_bib.value = global_frame.geral_bib;
	if (global_session_data==1) {
		document.frm_combinada.comb_logica_outros.value = global_frame.comb_logica_outros;
		document.frm_combinada.comb_outros.value = global_frame.comb_outros;
		document.frm_combinada.comb_conteudo_outros.value = global_frame.comb_conteudo_outros;
		document.frm_combinada.comb_logica_datas.value = global_frame.comb_logica_datas;
		document.frm_combinada.Data_Inicio_dia.value = formataData(global_frame.Data_Inicio_dia,"dia");
		document.frm_combinada.Data_Inicio_mes.value = formataData(global_frame.Data_Inicio_mes,"mes");
		document.frm_combinada.Data_Inicio_ano.value = formataData(global_frame.Data_Inicio_ano,"ano");
		document.frm_combinada.Data_Fim_dia.value = formataData(global_frame.Data_Fim_dia,"dia");
		document.frm_combinada.Data_Fim_mes.value = formataData(global_frame.Data_Fim_mes,"mes");
		document.frm_combinada.Data_Fim_ano.value = formataData(global_frame.Data_Fim_ano,"ano");
	}
}
//#######################################################################################//
// FUNÇÂO atribuiLegs
//#######################################################################################//
function atribuiLegs() {
	document.frm_legislacao.leg_campo1.value = global_frame.leg_campo1;
	document.frm_legislacao.leg_campo2.value = global_frame.leg_campo2;
	document.frm_legislacao.leg_campo3.value = global_frame.leg_campo3;
	document.frm_legislacao.leg_campo4.value = global_frame.leg_campo4;	
	document.frm_legislacao.leg_campo5.value = global_frame.leg_campo5;
	document.frm_legislacao.leg_campo6.value = global_frame.leg_campo6;
	if (document.frm_legislacao.leg_normas != null) {
		document.frm_legislacao.leg_normas.value = global_frame.leg_normas;
	}
	if (document.frm_legislacao.leg_normas_desc != null) {
		document.frm_legislacao.leg_normas_desc.value = global_frame.leg_normas_desc;
	}
	document.frm_legislacao.leg_numero.value = global_frame.leg_numero;
	document.frm_legislacao.sel_data_ass.value = global_frame.leg_sel_data_ass;
	document.frm_legislacao.data_ass_inicio_dia.value = global_frame.leg_data_ass_inicio_dia;
	document.frm_legislacao.data_ass_inicio_mes.value = global_frame.leg_data_ass_inicio_mes;
	document.frm_legislacao.data_ass_inicio_ano.value = global_frame.leg_data_ass_inicio_ano;
	document.frm_legislacao.data_ass_fim_dia.value = global_frame.leg_data_ass_fim_dia;
	document.frm_legislacao.data_ass_fim_mes.value = global_frame.leg_data_ass_fim_mes;
	document.frm_legislacao.data_ass_fim_ano.value = global_frame.leg_data_ass_fim_ano;
	habilitaEntre('ass');
}
//#######################################################################################//
// FUNÇÂO atualizaComb_outros
//#######################################################################################//
function atualizaComb_outros() {
	global_frame.comb_logica_outros = document.frm_combinada.comb_logica_outros.value;
	global_frame.comb_outros = document.frm_combinada.comb_outros.value;
	global_frame.comb_conteudo_outros = document.frm_combinada.comb_conteudo_outros.value;
}
//#######################################################################################//
// FUNÇÂO atualizaComb_datas
//#######################################################################################//
function atualizaComb_datas() {
	global_frame.comb_logica_datas = document.frm_combinada.comb_logica_datas.value;
	global_frame.Data_Inicio_dia = document.frm_combinada.Data_Inicio_dia.value;
	global_frame.Data_Inicio_mes = document.frm_combinada.Data_Inicio_mes.value;
	global_frame.Data_Inicio_ano = document.frm_combinada.Data_Inicio_ano.value;
	global_frame.Data_Fim_dia = document.frm_combinada.Data_Fim_dia.value;
	global_frame.Data_Fim_mes = document.frm_combinada.Data_Fim_mes.value;
	global_frame.Data_Fim_ano = document.frm_combinada.Data_Fim_ano.value;	
}
//#######################################################################################//
// FUNÇÂO Resetar
// 
//#######################################################################################//
function Resetar() {
	if ((global_frame.iFixarBibUsu != 1) || (global_frame.iFixarBib != 1)) {
		global_frame.geral_bib = 0;
	}
	if (global_frame.modo_busca=="telacheia") {
		global_frame.modo_busca="rapida";
	}
	global_frame.rapida_campo = '';
	global_frame.rapida_filtro = global_campo_default1;
	global_frame.comb_campo1 = '';
	global_frame.comb_campo2 = '';
	global_frame.comb_campo3 = '';
	global_frame.comb_campo4 = '';
	global_frame.comb_filtro1 = global_campo_default1;
	global_frame.comb_filtro2 = global_campo_default2;
	global_frame.comb_filtro3 = global_campo_default3;
	global_frame.comb_filtro4 = global_campo_default4;
	global_frame.comb_logica1 = 'E';
	global_frame.comb_logica2 = 'E';
	global_frame.comb_logica3 = 'E';	
	global_frame.comb_ano1 = '';
	global_frame.comb_ano2 = '';
	global_frame.comb_material = 0;
	if (global_versao != 3) {
		global_frame.comb_idioma = 0;
	}	
	if (global_session_data==1) {
		global_frame.comb_logica_outros = "E";
		global_frame.comb_outros = 'nenhum';
		global_frame.comb_conteudo_outros = '';
		global_frame.comb_logica_datas = "E";
		global_frame.Data_Inicio_dia = '';
		global_frame.Data_Inicio_mes = '';
		global_frame.Data_Inicio_ano = '';
		global_frame.Data_Fim_dia = '';
		global_frame.Data_Fim_mes = '';
		global_frame.Data_Fim_ano = '';
	}
	global_frame.leg_campo1 = "";
	global_frame.leg_campo2 = "";
	global_frame.leg_campo3 = "";
	global_frame.leg_campo4 = "";
	global_frame.leg_campo5 = "";
	global_frame.leg_campo6 = "";
	global_frame.leg_normas = -1;
	global_frame.leg_normas_desc = "";
	global_frame.leg_numero = "";
	global_frame.leg_sel_data_ass = 0;
	global_frame.leg_data_ass_inicio_dia = "";
	global_frame.leg_data_ass_inicio_mes = "";
	global_frame.leg_data_ass_inicio_ano = "";
	global_frame.leg_data_ass_fim_dia = "";
	global_frame.leg_data_ass_fim_mes = "";
	global_frame.leg_data_ass_fim_ano = "";
}

//#######################################################################################//
// FUNÇÂO TelaCheia
//#######################################################################################//
function TelaCheia(acao,div_atual,veio_de) {
	if (acao=='manter_auts') {
		if(global_frame.layerY=='div4') {
			fichaMarcAuts(global_frame.modo_busca);
		}else{
			marcTagsAuts(global_frame.modo_busca);
		}
	}
	if (acao=="trocar") {
		if (global_frame.modo_busca=="telacheia") {
			if (div_atual=='div4') {				
				Visualizar('div1','div2','div4','desativar',global_frame.modo_busca_bak);
			}else if (div_atual=='div5'){
				Visualizar('div1','div2','div5','desativar',global_frame.modo_busca_bak);
			}else{
				Visualizar('div1','div2','div6','desativar',global_frame.modo_busca_bak);
			}
			for (var i = 1; i <= global_frame.iNumAbas; i++) {
				var cheia = MM_findObj('tela_cheia'+i);
				var normal = MM_findObj('tela_normal'+i);
				if ((cheia != null) && (normal != null)) {
						if (cheia.style && normal.style) {
							cheia = cheia.style;
							normal = normal.style;
							cheia.visibility = 'visible';
							normal.visibility = 'hidden';
						}
				}
			}
		} else {
			if (div_atual=='div4') {
				Visualizar('div1','div2','div4','ativar',global_frame.modo_busca);
			}else if (div_atual=='div5'){
				Visualizar('div1','div2','div5','ativar',global_frame.modo_busca);
			}else{
				Visualizar('div1','div2','div6','ativar',global_frame.modo_busca);
			}		
			for (var i = 1; i <= global_frame.iNumAbas; i++) {
				var cheia = MM_findObj('tela_cheia'+i);
				var normal = MM_findObj('tela_normal'+i);
				if ((cheia != null) && (normal != null)) {
						if (cheia.style && normal.style) {
							cheia = cheia.style;
							normal = normal.style;
							cheia.visibility = 'hidden';					
							normal.visibility = 'visible';						
						}
				}
			}			
		}
	} else {
		if (global_frame.modo_busca == "telacheia") {
			if (div_atual=='div4') {
				Visualizar('div1','div2','div4','ativar',global_frame.modo_busca_bak);
			} else if (div_atual=='div5'){
				Visualizar('div1','div2','div5','ativar',global_frame.modo_busca_bak);
			} else {
				Visualizar('div1','div2','div6','ativar',global_frame.modo_busca_bak);
			}			
			for (var i = 1; i <= global_frame.iNumAbas; i++) {
				var cheia = MM_findObj('tela_cheia'+i);
				var normal = MM_findObj('tela_normal'+i);
				if ((cheia != null) && (normal != null)) {
						if (cheia.style && normal.style) {
							cheia = cheia.style;
							normal = normal.style;
							cheia.visibility = 'hidden';
							normal.visibility = 'visible';
						}
				}
			}
		} else {
			if (div_atual == 'div4') {
				Visualizar('div1','div2','div4','desativar',global_frame.modo_busca);
			} else if (div_atual=='div5') {				
				Visualizar('div1','div2','div5','desativar',global_frame.modo_busca);
			} else {
				Visualizar('div1','div2','div6','desativar',global_frame.modo_busca);
			}
			for (var i = 1; i <= global_frame.iNumAbas; i++) {
				var cheia = MM_findObj('tela_cheia'+i);
				var normal = MM_findObj('tela_normal'+i);
				if ((cheia != null) && (normal != null)) {
						if (cheia.style && normal.style) {
							cheia = cheia.style;
							normal = normal.style;
							cheia.visibility = 'visible';
							normal.visibility = 'hidden';
						}
				}
			}
		}
	}
}

//#######################################################################################//
// FUNÇÂO Visualizar
//#######################################################################################//
function Visualizar() { 
	if (global_versao < 3) {
		var acao,obj1,obj2,obj3,args=Visualizar.arguments;
		if ((obj1=MM_findObj(args[0]))!=null && (obj2=MM_findObj(args[1]))!=null && (obj3=MM_findObj(args[2]))!=null) {
			acao=args[3];
			modo_busca=args[4];
			if (obj1.style && obj2.style && obj3.style) {
				obj1=obj1.style;
				obj2=obj2.style;
				obj3=obj3.style;
				if (acao=='ativar') {
					obj3.top = 0;
					obj1.visibility='hidden';
					obj2.visibility='hidden';
					
					global_frame.modo_busca="telacheia";
					document.frm_geral.geral_bib.style.display = 'none';
				}else{
					document.frm_geral.geral_bib.style.display = '';
					if (args[2]=='div4') {
						if (modo_busca=="combinada") {
							move_layer('div1','div2','div4','combinada','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else if (modo_busca=="legislacao") {
							move_layer('div1','div2','div4','legislacao','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else{
							move_layer('div1','div2','div4','rapida','tab_rap','tab_comb','lk_rap','lk_comb','tab_legis','lk_legis','divL');
						}
					}else if (args[2]=='div5') {
						if (modo_busca=="combinada") {
							move_layer('div1','div2','div5','combinada','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else if (modo_busca=="legislacao") {
							move_layer('div1','div2','div4','legislacao','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else{
							move_layer('div1','div2','div5','rapida','tab_rap','tab_comb','lk_rap','lk_comb','tab_legis','lk_legis','divL');
						}
					}else if (args[2]=='div6') {
						if (modo_busca=="combinada") {
							move_layer('div1','div2','div6','combinada','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else if (modo_busca=="legislacao") {
							move_layer('div1','div2','div4','legislacao','tab_rap','tab_comb', 'lk_rap', 'lk_comb','tab_legis','lk_legis','divL');
						}else{
							move_layer('div1','div2','div6','rapida','tab_rap','tab_comb','lk_rap','lk_comb','tab_legis','lk_legis','divL');
						}
					}				
				}
			}				
		}
	}
}

//========================================================================

function LayerX() {
	if (global_frame != null) {
		global_frame.layerX = 'div4';
	}
}
function LayerY() {
	if (global_frame != null) {
		global_frame.layerY = 'div4';
	}
}

function mantemLinks(aba1,aba2) {
	var tabr = MM_findObj('tab_rap');	
	var linkr = MM_findObj('lk_rap');
	var tabc = MM_findObj('tab_comb');		
	var linkc = MM_findObj('lk_comb');
	var tabl = MM_findObj('tab_legis');
	var linkl = MM_findObj('lk_legis');
	if (global_frame.modo_busca=="combinada") {
		if ((linkr != null) && (linkc != null)) {
			if (linkr.style && linkc.style) {
				linkr = linkr.style;
				linkc = linkc.style;
				linkl = linkl.style;
				linkr.background = global_ababk;
				linkc.background = global_aba1;						
			}
		}
		if ((tabr != null) && (tabc != null)) {
			if (tabr.style && tabc.style) {
				tabr = tabr.style;
				tabc = tabc.style;
				tabl = tabl.style;
				tabc.background = global_aba2;
				tabc.borderTop = global_ababr1;
				tabc.borderRight = global_ababr1;
				tabr.background = global_ababk;
				tabr.borderTop = global_ababr2;
				tabl.background = global_ababk;
				tabl.borderTop = global_ababr2; 
				tabl.borderRight = global_ababr2; 
			}
		}
	} else if (global_frame.modo_busca=="legislacao") {
		if ((linkr != null) && (linkc != null)) {
			if (linkr.style && linkc.style) {
				linkr = linkr.style;
				linkc = linkc.style;
				linkl = linkl.style;
				linkr.background = global_aba1;
				linkc.background = global_ababk;						
			}
		}
		if ((tabr != null) && (tabc != null)) {
			if (tabr.style && tabc.style) {
				tabr = tabr.style;
				tabc = tabc.style;
				tabl = tabl.style;
				tabr.background = global_aba1;
				tabr.borderTop = global_ababr1;
				tabc.background = global_ababk;
				tabc.borderTop = global_ababr2; 
				tabc.borderRight = global_ababr2;
				tabl.background = global_ababk;
				tabl.borderTop = global_ababr2; 
				tabl.borderRight = global_ababr2;
			}
		}				
	} else {
		if ((linkr != null) && (linkc != null)) {
			if (linkr.style && linkc.style) {
				linkr = linkr.style;
				linkc = linkc.style;
				linkl = linkl.style;
				linkr.background = global_aba1;
				linkc.background = global_ababk;						
			}
		}
		if ((tabr != null) && (tabc != null)) {
			if (tabr.style && tabc.style) {
				tabr = tabr.style;
				tabc = tabc.style;
				tabl = tabl.style;
				tabr.background = global_aba1;
				tabr.borderTop = global_ababr1;
				tabc.background = global_ababk;
				tabc.borderTop = global_ababr2; 
				tabc.borderRight = global_ababr2;
				tabl.background = global_ababk;
				tabl.borderTop = global_ababr2; 
				tabl.borderRight = global_ababr2;
			}
		}				
	}
}

function BloqueiaNaoNumerico(campo, event) { 
	var BACKSPACE = 8; 
	var key; 
	var tecla; 
	CheckTAB=true;
	if(navigator.appName.indexOf("Netscape")!= -1) 
		tecla= event.which; 
	else 
		tecla= event.keyCode; 

	if ( (tecla != 13) && (tecla != 8)  && (tecla != 9) && (tecla != 46) && (tecla < 37 || tecla > 40) && (tecla < 96 || tecla > 105) && (tecla < 48 || tecla > 57)) {
		return false;  
	}else{
		return true;
	}
}

function BloqueiaNaoNumericoDecimal(campo, event) { 
	var BACKSPACE = 8; 
	var key; 
	var tecla; 
	CheckTAB=true;
	if(navigator.appName.indexOf("Netscape")!= -1) 
	tecla= event.which; 
	else 
	tecla= event.keyCode; 
	if ( (tecla != 110) && (tecla != 13) && (tecla != 8)  && (tecla != 9) && (tecla != 46) && (tecla < 37 || tecla > 40) && (tecla < 96 || tecla > 105) && (tecla < 48 || tecla > 57)) {
		return false;  
	}else{
		return true;
	}
}

function Confere_aut() {
	global_frame.geral_bib = document.frm_geral.geral_bib.value;
	tam_campo = document.frm_aut.aut_campo.value.length;
	AutoresBib();
	if (tam_campo >= global_limite_min_busca) {
		SubmeteBusca(4,"autoridades");
	}else{
		var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
		msg = msg.replace('%s', global_limite_min_busca);
		alert(msg);
		document.frm_aut.aut_campo.focus();
		return false;
	}
}

function Confere_aut_dsi() {
	tam_campo = document.frm_aut.aut_campo.value.length;
	if (tam_campo >= global_limite_min_busca) {
		SubmeteBusca(6,"autoridades");
	}else{
		var msg = getTermo(global_frame.iIdioma, 1278, 'Você precisa digitar no mínimo %s caracteres para a busca.', 0);
		msg = msg.replace('%s', global_limite_min_busca);
		alert(msg);
		document.frm_aut.aut_campo.focus();
		return false;
	}
}

function SubmeteBusca(modo,cont) {
	if (global_frame.statusLoading==1) {
		return false;
	}
	statusLoading(1);
	document.body.style.cursor = "wait";	
	if (modo == 1) {
		if (global_frame.iBusca_Projeto > 0) {
			document.frm_rapida.action = document.frm_rapida.action + '&projeto=' + global_frame.iBusca_Projeto;
		}
		document.frm_rapida.submit();
	}else if (modo == 2) {
		alert(getTermo(global_frame.iIdioma, 1308, 'Desculpe, o sistema está indisponível no momento.', 0));
	}else if (modo == 3) {
		if (global_frame.iBusca_Projeto > 0) {
			document.frm_combinada.action = document.frm_combinada.action + '&projeto=' + global_frame.iBusca_Projeto;
		}
		document.frm_combinada.submit();
	}else if (modo == 4) {
		atualizaAuts();
		if (global_frame.iBusca_Projeto > 0) {
			document.frm_aut.action = document.frm_aut.action + '&projeto=' + global_frame.iBusca_Projeto;
		}
		document.frm_aut.submit();	
	}else if (modo == 5) {
		if (global_frame.iBusca_Projeto > 0) {
			document.frm_legislacao.action = document.frm_legislacao.action + '&projeto=' + global_frame.iBusca_Projeto;
		}
		document.frm_legislacao.submit();	
	}else if (modo == 6) {
		atualizaAutsDSI();
		document.frm_aut.submit();
	}
}

function atualizaRapida() {
	global_frame.rapida_campo = document.frm_rapida.rapida_campo.value;
	global_frame.rapida_filtro = document.frm_rapida.rapida_filtro.value;
}

function atualizaAuts() {
	global_frame.aut_campo = document.frm_aut.aut_campo.value;
	global_frame.aut_filtro = document.frm_aut.aut_filtro.value;
}

function atualizaAutsDSI() {
	global_frame.aut_campo_dsi = document.frm_aut.aut_campo.value;
	global_frame.aut_filtro_dsi = document.frm_aut.aut_filtro.value;
}

function atualizaLeg_campos() {
	global_frame.leg_campo1 = document.frm_legislacao.leg_campo1.value;
	global_frame.leg_campo2 = document.frm_legislacao.leg_campo2.value;
	global_frame.leg_campo3 = document.frm_legislacao.leg_campo3.value;
	global_frame.leg_campo4 = document.frm_legislacao.leg_campo4.value;
	global_frame.leg_campo5 = document.frm_legislacao.leg_campo5.value;
	global_frame.leg_campo6 = document.frm_legislacao.leg_campo6.value;
	if (document.frm_legislacao.leg_normas != null) {
		global_frame.leg_normas = document.frm_legislacao.leg_normas.value;
	} else {
		global_frame.leg_normas = -1;
	}
	if (document.frm_legislacao.leg_normas_desc != null) {
		global_frame.leg_normas_desc = document.frm_legislacao.leg_normas_desc.value;
	} else {
		global_frame.leg_normas_desc = "";
	}
	global_frame.leg_numero = document.frm_legislacao.leg_numero.value;
	
	var tam_da1 = document.frm_legislacao.data_ass_inicio_dia.value.length;
	var tam_da2 = document.frm_legislacao.data_ass_inicio_mes.value.length;
	var tam_da3 = document.frm_legislacao.data_ass_inicio_ano.value.length;
	if ((tam_da1 + tam_da2 + tam_da3) > 0) {
		if (tam_da1 == 1) {
			var data_ass_inicio_dia = "0"+document.frm_legislacao.data_ass_inicio_dia.value;
		} else if (tam_da1 == 2) {
			var data_ass_inicio_dia = document.frm_legislacao.data_ass_inicio_dia.value;
		} else {
			var data_ass_inicio_dia = "";
		}
		if (tam_da2 == 1) {
			var data_ass_inicio_mes = "0"+document.frm_legislacao.data_ass_inicio_mes.value;
		} else if (tam_da2 == 2) {
			var data_ass_inicio_mes = document.frm_legislacao.data_ass_inicio_mes.value;
		} else {
			var data_ass_inicio_mes = "";
		}
		if (tam_da3 == 1) {
			var data_ass_inicio_ano = "200"+document.frm_legislacao.data_ass_inicio_ano.value;
		} else if (tam_da3 == 2) {
			if (document.frm_legislacao.data_ass_inicio_ano.value > 50) {
				var data_ass_inicio_ano = "19"+document.frm_legislacao.data_ass_inicio_ano.value;
			} else {
				var data_ass_inicio_ano = "20"+document.frm_legislacao.data_ass_inicio_ano.value;
			}
		} else if (tam_da3 == 3) {
			var data_ass_inicio_ano = "0"+document.frm_legislacao.data_ass_inicio_ano.value;
		} else if (tam_da3 == 4) {
			var data_ass_inicio_ano = document.frm_legislacao.data_ass_inicio_ano.value;
		} else {
			var data_ass_inicio_ano = "";
		}
		global_frame.leg_data_ass_inicio_dia = data_ass_inicio_dia;
		global_frame.leg_data_ass_inicio_mes = data_ass_inicio_mes;
		global_frame.leg_data_ass_inicio_ano = data_ass_inicio_ano;
		
	}		
	global_frame.leg_sel_data_ass = document.frm_legislacao.sel_data_ass.value;
	if (global_frame.leg_sel_data_ass==3) {
		var tam_da4 = document.frm_legislacao.data_ass_fim_dia.value.length;
		var tam_da5 = document.frm_legislacao.data_ass_fim_mes.value.length;
		var tam_da6 = document.frm_legislacao.data_ass_fim_ano.value.length;
		if (tam_da4 == 1) {
			var data_ass_fim_dia = "0"+document.frm_legislacao.data_ass_fim_dia.value;
		} else if (tam_da4 == 2) {
			var data_ass_fim_dia = document.frm_legislacao.data_ass_fim_dia.value;
		} else {
			var data_ass_fim_dia = "";
		}
		if (tam_da5 == 1) {
			var data_ass_fim_mes = "0"+document.frm_legislacao.data_ass_fim_mes.value;
		} else if (tam_da5 == 2) {
			var data_ass_fim_mes = document.frm_legislacao.data_ass_fim_mes.value;
		} else {
			var data_ass_fim_mes = "";
		}
		if (tam_da6 == 1) {
			var data_ass_fim_ano = "200"+document.frm_legislacao.data_ass_fim_ano.value;
		} else if (tam_da6 == 2) {
			if (document.frm_legislacao.data_ass_fim_ano.value > 50) {
				var data_ass_fim_ano = "19"+document.frm_legislacao.data_ass_fim_ano.value;
			} else {
				var data_ass_fim_ano = "20"+document.frm_legislacao.data_ass_fim_ano.value;
			}
		} else if (tam_da6 == 3) {
			var data_ass_fim_ano = "0"+document.frm_legislacao.data_ass_fim_ano.value;
		} else if (tam_da6 == 4) {
			var data_ass_fim_ano = document.frm_legislacao.data_ass_fim_ano.value;
		} else {
			var data_ass_fim_ano = "";
		}
		global_frame.leg_data_ass_fim_dia = data_ass_fim_dia;
		global_frame.leg_data_ass_fim_mes = data_ass_fim_mes;
		global_frame.leg_data_ass_fim_ano = data_ass_fim_ano;
	}
}

function atualizaComb_campos() {
	global_frame.comb_campo1 = document.frm_combinada.comb_campo1.value;
	global_frame.comb_campo2 = document.frm_combinada.comb_campo2.value;
	global_frame.comb_campo3 = document.frm_combinada.comb_campo3.value;
	global_frame.comb_campo4 = document.frm_combinada.comb_campo4.value;
}

function atualizaComb_filtros() {
	global_frame.comb_filtro1 = document.frm_combinada.comb_filtro1.value;
	global_frame.comb_filtro2 = document.frm_combinada.comb_filtro2.value;
	global_frame.comb_filtro3 = document.frm_combinada.comb_filtro3.value;
	global_frame.comb_filtro4 = document.frm_combinada.comb_filtro4.value;
}

function atualizaComb_logica() {
	global_frame.comb_logica1 = document.frm_combinada.comb_logica1.value;
	global_frame.comb_logica2 = document.frm_combinada.comb_logica2.value;
	global_frame.comb_logica3 = document.frm_combinada.comb_logica3.value;
}

function atualizaComb_opcoes() {
	global_frame.comb_ano1 = document.frm_combinada.comb_ano1.value;
	global_frame.comb_ano2 = document.frm_combinada.comb_ano2.value;
	if (document.frm_combinada.comb_material != null) {
		global_frame.comb_material = document.frm_combinada.comb_material.value;
	} else {
		global_frame.comb_material = 0;
	}
	if (global_versao != 3) {
		if (document.frm_combinada.comb_idioma != null) {
			global_frame.comb_idioma = document.frm_combinada.comb_idioma.value;
		} else {
			global_frame.comb_idioma = 0;
		}
	}
	global_frame.comb_ordenacao = document.frm_combinada.comb_ordenacao.value;
}

function atribuiRapida() {
	document.frm_rapida.rapida_campo.value = global_frame.rapida_campo;
	document.frm_rapida.rapida_filtro.value = global_frame.rapida_filtro;
	document.frm_rapida.rapida_bib.value = global_frame.geral_bib;
	document.frm_geral.geral_bib.value = global_frame.geral_bib;
}

function atribuiAuts() {
	document.frm_aut.aut_campo.value = global_frame.aut_campo;
	document.frm_aut.aut_filtro.value = global_frame.aut_filtro;
	document.frm_aut.aut_bib.value = global_frame.geral_bib;
	document.frm_geral.geral_bib.value = global_frame.geral_bib;	
}

function atribuiAutsDSI() {
	document.frm_aut.aut_campo.value = global_frame.aut_campo;
	document.frm_aut.aut_filtro.value = global_frame.aut_filtro;
}

function novaPesquisa(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca=rapida&liberar_sessoes=sim";
	Resetar();
}

function volta_resultado(modo,pag)
{
	if (global_frame.vetor_pag.length==0) 
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=resultado_fak";
	} 
	else 
	{
		var v_pag = "";
		var sPagCorrente = "";
		var sIndCorrente = "";
		
		for(var i = 1; i <= global_frame.vetor_pag.length - 1; i++)
		{
			if(global_frame.vetor_pag[i] == undefined)
			{
				v_pag = v_pag + "|";				
				sPagCorrente = sPagCorrente + "|";
				sIndCorrente = sIndCorrente + "|";				
			}
			else
			{
				if(global_frame.vetor_pag[i][global_frame.arPagCorrente[i]]== undefined) 
				{
					v_pag = v_pag + "|";
					sPagCorrente = sPagCorrente + "|";
					sIndCorrente = sIndCorrente + "|";
				} 
				else 
				{
					// Códigos da página
					v_pag = v_pag + "|" + global_frame.vetor_pag[i][global_frame.arPagCorrente[i]];
					// Páginas correntes
					sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrente[i];
					//Índices correntes
					sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrente[i];
				}		
			}
		}	
		
		parent.mainFrame.location = "index."+ext+
									"?modo_busca="+modo+
									"&content=resultado&veio_de=paginacao&pagina="+sPagCorrente+
									"&vetor_pag='"+v_pag+"'"+
									"&Servidor="+global_frame.iSrvCorrente+
									"&iSrvCombo="+global_frame.geral_bib+
									"&indice="+sIndCorrente+
									"&iIdioma="+global_frame.iIdioma+
									LinkDestacaPalavras();
	}
}

function volta_autoridade(modo,pag)
{
	if (modo=="linkAutInfo") {
		LinkPesquisa(global_frame.modo_busca,1);
	} 
	else 
	{
		var acao = 1;
		global_frame.modo_busca="rapida";
	
		if (global_frame.vetor_pag_auts.length == 0)  
		{
			acao = 0;
		} 
		else 
		{
			var v_pag = "";
			var sPagCorrente = "";
			var sIndCorrente = "";
			
			for(var i = 1; i <= global_frame.vetor_pag_auts.length - 1; i++)
			{
				if(global_frame.vetor_pag_auts[i] == undefined)
				{
					v_pag = v_pag + "|";				
					sPagCorrente = sPagCorrente + "|";
					sIndCorrente = sIndCorrente + "|";				
				}			
				else
				{
					if(global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]]==undefined) 
					{
						v_pag = v_pag + "|";
						sPagCorrente = sPagCorrente + "|";
						sIndCorrente = sIndCorrente + "|";
					} 
					else 
					{
						// Códigos da página
						v_pag = v_pag + "|" + global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]];
						// Páginas correntes
						sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrenteAut[i];
						//Índices correntes
						sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrenteAut[i];
					}		
				}
			}			
		}
		
		if (acao == 0) 
		{
			url = "index."+ext+"?modo_busca=rapida&aut=1&veio_de=nova_autoridade&content=autoridades_fak";
		}
		else
		{	
			url = "index."+ext+"?modo_busca=rapida&aut=1&content=autoridades&veio_de=menu&aut_pag='"+v_pag+"'&pagina="+sPagCorrente+"&Servidor="+global_frame.iSrvCorrente_Aut+"&iSrvCombo="+global_frame.geral_bib+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras("autoridades");
		}	
			
		parent.mainFrame.location = url;
	}	
}

function LinkDestacaPalavras(sOrigem){
	var sRet = "";

	if (sOrigem == undefined)
		sOrigem = parent.hiddenFrame.content;

	if (sOrigem == 'autoridades'){
		sRet = "campo1="+parent.hiddenFrame.rapida_filtro+"&valor1="+parent.hiddenFrame.aut_campo.replace(" ", "_");
	}
	else                                                //Philos
	if ( (parent.hiddenFrame.modo_busca == "rapida") && (global_versao != 3) ){
		sRet = "campo1="+parent.hiddenFrame.rapida_filtro+"&valor1="+parent.hiddenFrame.rapida_campo.replace(" ", "_");
	}
	else                                                  //Philos
	if ((parent.hiddenFrame.modo_busca == "combinada") || (global_versao == 3) ){
		sRet1 = (parent.hiddenFrame.comb_campo1 != null) && (parent.hiddenFrame.comb_campo1.length > 0) ? "campo1="+parent.hiddenFrame.comb_filtro1+"&valor1="+parent.hiddenFrame.comb_campo1.replace(" ", "_") : "";
		sRet2 = (parent.hiddenFrame.comb_campo2 != null) && (parent.hiddenFrame.comb_campo2.length > 0) ? "campo2="+parent.hiddenFrame.comb_filtro2+"&valor2="+parent.hiddenFrame.comb_campo2.replace(" ", "_") : "";
		sRet3 = (parent.hiddenFrame.comb_campo3 != null) && (parent.hiddenFrame.comb_campo3.length > 0) ? "campo3="+parent.hiddenFrame.comb_filtro3+"&valor3="+parent.hiddenFrame.comb_campo3.replace(" ", "_") : "";
		sRet4 = (parent.hiddenFrame.comb_campo4 != null) && (parent.hiddenFrame.comb_campo4.length > 0) ? "campo4="+parent.hiddenFrame.comb_filtro4+"&valor4="+parent.hiddenFrame.comb_campo4.replace(" ", "_") : "";
		sRet5 = (parent.hiddenFrame.comb_campo5 != null) && (parent.hiddenFrame.comb_campo5.length > 0) ? "campo5="+parent.hiddenFrame.comb_filtro5+"&valor5="+parent.hiddenFrame.comb_campo5.replace(" ", "_") : "";
		sRet = sRet1;
		if (sRet2.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet2 : sRet2);

		if (sRet3.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet3 : sRet3);
			
		if (sRet4.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet4 : sRet4);
			
		if (sRet5.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet5 : sRet5);
	}
	else
	if (parent.hiddenFrame.modo_busca == "legislacao" || sOrigem == "legislacao"){
		//Para entender o valor da variável campo adiante, ver em funcoes.php o método GetPosCampoPesquisa
		//Exceto para os campos específicos de legislação (orgão de origem, ementa, texto integral e número)
		
		//Palavra-Chave
		sRet1 = (parent.hiddenFrame.leg_campo1 != null) && (parent.hiddenFrame.leg_campo1.length > 0) ? "campo1=palavra_chave&valor1=" + parent.hiddenFrame.leg_campo1.replace(" ", "_") : "";
		
		//Autor
		sRet2 = (parent.hiddenFrame.leg_campo2 != null) && (parent.hiddenFrame.leg_campo2.length > 0) ? "campo2=autor&valor2=" + parent.hiddenFrame.leg_campo2.replace(" ", "_") : "";
		
		//Orgão de Origem
		sRet3 = (parent.hiddenFrame.leg_campo3 != null) && (parent.hiddenFrame.leg_campo3.length > 0) ? "campo3=0&valor3=" + parent.hiddenFrame.leg_campo3.replace(" ", "_") : "";
		
		//Assunto
		sRet4 = (parent.hiddenFrame.leg_campo4 != null) && (parent.hiddenFrame.leg_campo4.length > 0) ? "campo4=assunto&valor4=" + parent.hiddenFrame.leg_campo4.replace(" ", "_") : "";
		
		//Ementa
		sRet5 = (parent.hiddenFrame.leg_campo5 != null) && (parent.hiddenFrame.leg_campo5.length > 0) ? "campo5=resumo_campo&valor5=" + parent.hiddenFrame.leg_campo5.replace(" ", "_") : "";
		
		//Texto integral
		sRet6 = (parent.hiddenFrame.leg_campo6 != null) && (parent.hiddenFrame.leg_campo6.length > 0) ? "campo6=0&valor6=" + parent.hiddenFrame.leg_campo6.replace(" ", "_") : "";
		
		//Número
		sRet7 = (parent.hiddenFrame.leg_numero != null) && (parent.hiddenFrame.leg_numero.length > 0) ? "campo7=13&valor7=" + parent.hiddenFrame.leg_numero.replace(" ", "_") : "";
		
		//Norma
		sRet8 = (parent.hiddenFrame.leg_normas != null) && (parent.hiddenFrame.leg_normas.length > 0) ? "campo8=14&valor8=" + parent.hiddenFrame.leg_normas.replace(" ", "_") : "";
		
		if (sRet1.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet1 : sRet1);

		if (sRet2.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet2 : sRet2);

		if (sRet3.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet3 : sRet3);
			
		if (sRet4.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet4 : sRet4);
			
		if (sRet5.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet5 : sRet5);
			
		if (sRet6.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet6 : sRet6);
			
		if (sRet7.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet7 : sRet7);
			
		if (sRet8.length > 0)
			sRet = sRet + ((sRet.length > 0) ? "&"+sRet8 : sRet8);
	}

	sRet = Trim(sRet);
	if (sRet != ''){
		sRet = "&" + sRet;
	}

	return sRet;
}

function LinkDetalhes(modo,qtde,pos_vetor,cod_obra,pag,veio,tipo) {
	if(veio == "sels") {
		var iServidor = global_frame.iSrvCorrente_MySel;
	} else {
		var iServidor = global_frame.iSrvCorrente;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=detalhe&qtde="+qtde+"&posicao_vetor="+pos_vetor+"&codigo_obra="+cod_obra+"&pagina="+pag+"&veio_de="+veio+"&biblioteca="+global_frame.geral_bib+"&tipo_obra="+tipo+"&Servidor="+iServidor+"&iIdioma="+global_frame.iIdioma+projeto+LinkDestacaPalavras();
}

function LinkDetalhesPeriodico(modo,qtde,pos_vetor,cod_obra,pag,veio,art,tipo) { //FILTRA ARTIGO
	if(veio == "sels") {
		var iServidor = global_frame.iSrvCorrente_MySel;
	} else {
		var iServidor = global_frame.iSrvCorrente;	
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}

	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=detalhe&qtde="+qtde+"&posicao_vetor="+pos_vetor+"&codigo_obra="+cod_obra+"&pagina="+pag+"&veio_de="+veio+"&biblioteca="+global_frame.geral_bib+"&filtra_artigo="+art+"&tipo_obra="+tipo+"&Servidor="+iServidor+"&iIdioma="+global_frame.iIdioma+projeto;
}

function AbasLayerX() {
	if (global_frame.layerX=='div4') {


		var tda = MM_findObj('tdx_a1');
		var linka = MM_findObj('lk_a1');
		var tdb = MM_findObj('tdx_b1');
		var linkb = MM_findObj('lk_b1');
		var tdc = MM_findObj('tdx_c1');
		var linkc = MM_findObj('lk_c1');
		var tddt1 = MM_findObj('tdx_dt1');
		var tddt2 = MM_findObj('tdx_dt2');

		var tddt3 = MM_findObj('tdx_dt3');
		var tddt4 = MM_findObj('tdx_dt4');
		if ((tda != null) && (linka != null)) {
			tda = tda.style;
			linka = linka.style;
			tda.background = global_css_detalhe_esquerda;
			linka.color = '#006699';
			tda.borderTop = '1px solid #999999';
			tda.borderBottom = '0px solid #00ff00';
			tda.borderLeft = '0px solid #999999';
			tda.borderRight = '1px solid #999999';
			tddt1.style.background = global_css_detalhe_esquerda;
			tddt2.style.background = global_css_detalhe_esquerda;
			tddt3.style.background = global_css_detalhe_esquerda;
			tddt4.style.background = global_css_detalhe_esquerda;
		}
		if ((tdb != null) && (linkb != null)) {
			tdb = tdb.style;
			linkb = linkb.style;
			tdb.background = '#f2f2f2';
			linkb.color = '#999999';
			tddt2.style.borderTop = '1px solid #999999';
		}
		if ((tdc != null) && (linkc != null)) {
			tdc = tdc.style;
			linkc = linkc.style;
			tdc.background = '#f2f2f2';
			linkc.color = '#999999';
			tddt3.style.borderTop = '1px solid #999999';
		}
	}else if (global_frame.layerX=='div5') {
		var tda = MM_findObj('tdx_a2');
		var linka = MM_findObj('lk_a2');
		var tdb = MM_findObj('tdx_b2');
		var linkb = MM_findObj('lk_b2');
		var tdc = MM_findObj('tdx_c2');
		var linkc = MM_findObj('lk_c2');
		var tdfm1 = MM_findObj('tdx_fm1');
		var tdfm2 = MM_findObj('tdx_fm2');
		var tdfm3 = MM_findObj('tdx_fm3');
		var tdfm4 = MM_findObj('tdx_fm4');
		if ((tda != null) && (linka != null)) {
			tda = tda.style;
			linka = linka.style;
			tda.background = '#f2f2f2';
			linka.color = '#999999';
			tdfm1.style.borderTop = '1px solid #999999';
		}
		if ((tdb != null) && (linkb != null)) {
			tdb = tdb.style;
			linkb = linkb.style;
			tdb.background = '#E1E8EE';
			linkb.color = '#006699';
			tdb.borderTop = '1px solid #999999';
			tdb.borderBottom = '0px solid #999999';
			tdb.borderLeft = '1px solid #999999';
			tdb.borderRight = '1px solid #999999';
			tdfm1.style.background = '#E1E8EE';
			tdfm2.style.background = '#E1E8EE';
			tdfm3.style.background = '#E1E8EE';
			tdfm4.style.background = '#E1E8EE';
		}
		if ((tdc != null) && (linkc != null)) {
			tdc = tdc.style;
			linkc = linkc.style;
			tdc.background = '#f2f2f2';
			linkc.color = '#999999';
			tdfm3.style.borderTop = '1px solid #999999';
		}
	}else if (global_frame.layerX=='div6') {
		var tda = MM_findObj('tdx_a3');
		var linka = MM_findObj('lk_a3');
		var tdb = MM_findObj('tdx_b3');
		var linkb = MM_findObj('lk_b3');
		var tdc = MM_findObj('tdx_c3');
		var linkc = MM_findObj('lk_c3');
		var tdmt1 = MM_findObj('tdx_mt1');
		var tdmt2 = MM_findObj('tdx_mt2');
		var tdmt3 = MM_findObj('tdx_mt3');
		var tdmt4 = MM_findObj('tdx_mt4');
		if ((tda != null) && (linka != null)) {
			tda = tda.style;
			linka = linka.style;
			tda.background = '#f2f2f2';
			linka.color = '#999999';
			tdmt1.style.borderTop = '1px solid #999999';
		}
		if ((tdb != null) && (linkb != null)) {
			tdb = tdb.style;
			linkb = linkb.style;
			tdb.background = '#f2f2f2';
			linkb.color = '#999999';
			tdmt2.style.borderTop = '1px solid #999999';
		}
		if ((tdc != null) && (linkc != null)) {
			tdc = tdc.style;
			linkc = linkc.style;
			tdc.background = '#E8F2FD';

			linkc.color = '#006699';
			tdc.borderTop = '1px solid #999999';
			tdc.borderBottom = '0px solid #00ff00';
			tdc.borderLeft = '1px solid #999999';
			tdc.borderRight = '1px solid #999999';
			tdmt1.style.background = '#E8F2FD';
			tdmt2.style.background = '#E8F2FD';
			tdmt3.style.background = '#E8F2FD';
			tdmt4.style.background = '#E8F2FD';
		}
	}	
}

function AbasLayerY() {
	if (global_frame.layerY=='div4') {

		var tda = MM_findObj('tda_a1');
		var linka = MM_findObj('la_a1');
		var tdb = MM_findObj('tda_b1');
		var linkb = MM_findObj('la_b1');
		var tdfm1 = MM_findObj('tda_fm1');
		var tdfm2 = MM_findObj('tda_fm2');
		var tdfm3 = MM_findObj('tda_fm3');
		if ((tda != null) && (linka != null)) {
			tda = tda.style;
			linka = linka.style;
			tda.background = global_css_detalhe_esquerda;
			linka.color = '#006699';
			tda.borderTop = '1px solid #999999';
			tda.borderBottom = '0px solid #00ff00';
			tda.borderLeft = '0px solid #999999';
			tda.borderRight = '1px solid #999999';
			tdfm1.style.background = global_css_detalhe_esquerda;
			tdfm2.style.background = global_css_detalhe_esquerda;
			tdfm3.style.background = global_css_detalhe_esquerda;
		}
		if ((tdb != null) && (linkb != null)) {
			tdb = tdb.style;
			linkb = linkb.style;
			tdb.background = '#f2f2f2';
			linkb.color = '#999999';
			tdfm2.style.borderTop = '1px solid #999999';
		}
	}else if (global_frame.layerY=='div5') {
		var tda = MM_findObj('tda_a2');
		var linka = MM_findObj('la_a2');
		var tdb = MM_findObj('tda_b2');
		var linkb = MM_findObj('la_b2');
		var tdmt1 = MM_findObj('tda_mt1');
		var tdmt2 = MM_findObj('tda_mt2');
		var tdmt3 = MM_findObj('tda_mt3');
		if ((tda != null) && (linka != null)) {
			tda = tda.style;
			linka = linka.style;
			tda.background = '#f2f2f2';
			linka.color = '#999999';
			tdmt1.style.borderTop = '1px solid #999999';
		}
		if ((tdb != null) && (linkb != null)) {
			tdb = tdb.style;
			linkb = linkb.style;
			tdb.background = '#E8F2FD';
			linkb.color = '#006699';
			tdb.borderTop = '1px solid #999999';
			tdb.borderBottom = '0px solid #00ff00';
			tdb.borderLeft = '1px solid #999999';
			tdb.borderRight = '1px solid #999999';
			tdmt1.style.background = '#E8F2FD';
			tdmt2.style.background = '#E8F2FD';
			tdmt3.style.background = '#E8F2FD';
		}
	}	
}

function URLdecode(str) {
	s = new String(str);
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");	
	s = s.replace("_#39;","'");	
	s = s.replace("_#39;","'");	
	s = s.replace("_#39;","'");
	s = s.replace("_#39;","'");	
	s = s.replace("_#39;","'");	
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	s = s.replace("_"," ");
	return s;
}

function LinkBuscaInst(modo,cod,desc,iServidor) 
{
	if ((iServidor == "") || (iServidor == 0) || (iServidor == undefined)) {
		iServidor = 1;
	}
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	if (modo == "combinada") 
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.comb_campo1 = URLdecode(desc);
		global_frame.comb_filtro1 = "palavra_chave";
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=inst&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}
	else
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.rapida_campo = URLdecode(desc);
		global_frame.rapida_filtro = "palavra_chave";
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=inst&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}
}

function LinkBuscaAssunto(modo,cod,desc,iServidor)
{
	if (modo == "iframe") 
	{
		if (parent.hiddenFrame != null) {
			global_frame = parent.hiddenFrame;
		} else if (parent.parent.hiddenFrame != null) {
			global_frame = parent.parent.hiddenFrame;
		} else {
			global_frame = parent.parent.parent.hiddenFrame;
		}		
		modo = global_frame.modo_busca;

		if (parent.mainFrame != null) {
			mainFrame = parent.mainFrame;
		} else if (parent.parent.mainFrame != null) {
			mainFrame = parent.parent.mainFrame;
		} else {
			mainFrame = parent.parent.parent.mainFrame;
		}

		var locationHome = "../index."+ext;
	} 
	else 
	{
		if (parent.mainFrame != null) {
			mainFrame = parent.mainFrame;
		} else if (parent.parent.mainFrame != null) {
			mainFrame = parent.parent.mainFrame;
		} else {
			mainFrame = parent.parent.parent.mainFrame;
		}
		var locationHome = "index."+ext;
	}

	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)){
		iServidor = 1;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}	
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var url = locationHome+"?modo_busca="+modo+"&content=busca_link&por=assunto&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	
	if (modo == "combinada") {
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.comb_campo1 = URLdecode(desc);
		global_frame.comb_filtro1 = "assunto";
		mainFrame.location = url;
	}else{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.rapida_campo = URLdecode(desc);
		global_frame.rapida_filtro = "assunto";
		mainFrame.location = url;
	}
}

function LinkBuscaEvento(modo,cod,desc,iServidor)
{
	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)){
		iServidor = 1;
	}
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	if (modo == "combinada") 
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.comb_campo1 = URLdecode(desc);
		global_frame.comb_filtro1 = "palavra_chave";
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=eventos&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}
	else
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.rapida_campo = URLdecode(desc);
		global_frame.rapida_filtro = "palavra_chave";
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=eventos&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}
}

function LinkBuscaTitUnif(modo,cod,desc,iServidor) 
{
	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)){
		iServidor = 1;
	}
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	Resetar();
	global_frame.geral_bib = bib;
	global_frame.rapida_campo = URLdecode(desc);
	global_frame.rapida_filtro = "palavra_chave";
	
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=titunif&codigo="+cod+"&submeteu="+modo+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
}

function LinkBuscaAutor(modo,cod,desc,iServidor)
{
	if (modo == "iframe") {
		if (parent.hiddenFrame != null) {
			global_frame = parent.hiddenFrame;
		} else if (parent.parent.hiddenFrame != null) {
			global_frame = parent.parent.hiddenFrame;
		} else {
			global_frame = parent.parent.parent.hiddenFrame;
		}
		modo = global_frame.modo_busca;
		
		if (parent.mainFrame != null) {
			mainFrame = parent.mainFrame;
		} else if (parent.parent.mainFrame != null) {
			mainFrame = parent.parent.mainFrame;
		} else {
			mainFrame = parent.parent.parent.mainFrame;
		}
		
		var locationHome = "../index."+ext;
	} else {
		if (parent.mainFrame != null) {
			mainFrame = parent.mainFrame;
		} else if (parent.parent.mainFrame != null) {
			mainFrame = parent.parent.mainFrame;
		} else {
			mainFrame = parent.parent.parent.mainFrame;
		}
		var locationHome = "index."+ext;
	}	

	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)) {
		iServidor = 1;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var url = locationHome+"?modo_busca="+modo+"&content=busca_link&por=autor&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	
	if (modo == "combinada") 
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.comb_campo1 = URLdecode(desc);
		global_frame.comb_filtro1 = "autor";
		mainFrame.location = url;
	}
	else
	{
		Resetar();
		global_frame.geral_bib = bib;
		global_frame.rapida_campo = URLdecode(desc);
		global_frame.rapida_filtro = "autor";
		mainFrame.location = url;
	}	
}

function LinkBuscaOrgao(modo,cod,desc,iServidor) {
	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)){
		iServidor = 1;
	}	
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	if (modo == "combinada") {
		Resetar();
		global_frame.comb_campo1 = URLdecode(desc);
		global_frame.comb_filtro1 = "autor";
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&por=orgao&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}else{
		Resetar();
		global_frame.modo_busca = "rapida";
		global_frame.rapida_campo = URLdecode(desc);
		global_frame.rapida_filtro = "autor";
		parent.mainFrame.location = "index."+ext+"?modo_busca=rapida&content=busca_link&por=orgao&codigo="+cod+"&submeteu="+modo+"&desc="+encodeURL(desc)+"&bib="+bib+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
	}
}

function LinkBuscaAutoridade(modo,cod,desc,iServidor) 
{
	if((iServidor == "") || (iServidor == 0) || (iServidor == undefined)){
		iServidor = 1;
	}
	
	var bib = global_frame.geral_bib;
	if (global_frame.iMultiServbib == 1) {
		bib = iServidor;
	}
	
	var projeto = "";
	if (global_frame.iBusca_Projeto > 0) {
		projeto = "&projeto="+global_frame.iBusca_Projeto;
	}
	
	Resetar();
	global_frame.geral_bib = bib;
	global_frame.rapida_campo = URLdecode(desc);
	global_frame.rapida_filtro = "palavra_chave";
	
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=busca_link&codAut="+cod+"&submeteu="+modo+"&Servidor="+iServidor+projeto+"&iIdioma="+global_frame.iIdioma;
}

function LinkLogin(modo) {
	var msg_login = getTermo(global_frame.iIdioma, 95, 'Login', 0);
	abrePopup(ext+'/login.'+ext+'?modo_busca='+modo+"&iIdioma="+global_frame.iIdioma,msg_login,320,220,false,false);
}

function LinkBuscaEmenta(cod,desc,serv) {
	var msg_ementa = getTermo(global_frame.iIdioma, 1319, 'Ementa', 0);
	abrePopup(ext+'/textos.'+ext+'?codigo='+cod+'&desc='+encodeURL(desc)+'&servidor='+serv+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras(),msg_ementa,680,450,true,true);
}

function LinkBuscaTextoInt(cod,desc,serv) {
	var msg_texto = getTermo(global_frame.iIdioma, 1320, 'Texto integral', 0);
	abrePopup(ext+'/textos.'+ext+'?codigo='+cod+'&desc='+encodeURL(desc)+'&servidor='+serv+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras(),msg_texto,680,450,true,true);
}

function LinkBuscaResumo(cod,desc,serv) {
	var msg_resumo = getTermo(global_frame.iIdioma, 1214, 'Resumo', 0);
	abrePopup(ext+'/textos.'+ext+'?codigo='+cod+'&desc='+encodeURL(desc)+'&servidor='+serv+'&iIdioma='+global_frame.iIdioma,msg_resumo,680,450,true,true);
}

function LinkBuscaNotas(cod,desc,serv) {
	var msg_notas = getTermo(global_frame.iIdioma, 183, 'Notas', 0);
	abrePopup(ext+'/textos.'+ext+'?codigo='+cod+'&desc='+encodeURL(desc)+'&servidor='+serv+'&iIdioma='+global_frame.iIdioma,msg_notas,680,450,true,true);
}

function LinkSugestao(modo) {
	var msg_sugestoes = getTermo(global_frame.iIdioma, 1321, 'Sugestões', 0);
	abrePopup(ext+'/nova_sugestao.'+ext+'?modo_busca='+modo+'&iIdioma='+global_frame.iIdioma,msg_sugestoes,720,425,false,false);
}

function LinkInteresse(modo) {
	Reset_auts_dsi();
	
	global_frame.arPagCorrenteAutDSI = new Array;
	global_frame.arIndCorrenteAutDSI = new Array;
	global_frame.vetor_pag_auts_dsi = new Array;
	global_frame.vetor_auts_dsi = new Array;
	
	global_frame.arSelecaoDSI = new Array;
	
	var msg_dsi = getTermo(global_frame.iIdioma, 1322, 'Perfil de interesse', 0);
	abrePopup(ext+'/novo_interesse.'+ext+'?modo_busca='+modo+'&iIdioma='+global_frame.iIdioma,msg_dsi,720,460,false,false);
}

function ExcluiDSI(modo,autoridade) {
	var msg_dsi = getTermo(global_frame.iIdioma, 1322, 'Perfil de interesse', 0);
	abrePopup(ext+'/novo_interesse.'+ext+'?modo_busca='+modo+'&acao=excluir&autoridade='+autoridade+'&iIdioma='+global_frame.iIdioma,msg_dsi,300,100,false,false)
}

function AlterarEmail(modo) {
	var msg_email = getTermo(global_frame.iIdioma, 129, 'E-mail', 0);
	abrePopup(ext+'/alterar_email.'+ext+'?modo_busca='+modo+"&iIdioma="+global_frame.iIdioma,msg_email,320,220,false,false);
}

function dsiSelMaterial(modo) {
	var msg_mat = getTermo(global_frame.iIdioma, 175, 'Material', 0);
	abrePopup(ext+'/dsi_sel_material.'+ext+'?modo_busca='+modo+"&iIdioma="+global_frame.iIdioma,msg_mat,380,470,false,false);
}

function dsiSelBib(modo) {
	var msg_bib = getTermo(global_frame.iIdioma, 3, 'Biblioteca', 0);
	abrePopup(ext+'/dsi_sel_bib.'+ext+'?modo_busca='+modo+"&iIdioma="+global_frame.iIdioma,msg_bib,380,470,false,false);
}

function dsiSelArea(modo) {
	var msg_area = getTermo(global_frame.iIdioma, 705, 'Área', 0);
	abrePopup(ext+'/dsi_sel_area.'+ext+'?modo_busca='+modo+"&iIdioma="+global_frame.iIdioma,msg_area,380,470,false,false);
}

function LinkHome(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=default&iIdioma="+global_frame.iIdioma;
}

function LinkReservas(modo) {
	//Adequação Itaú
	//Filtra os serviços para exibir informações somente de uma biblioteca
	var iFiltroBib = 0;
	if ((global_numero_serie ==	4090) || (global_numero_serie == 4184)) {
		if (global_frame.iFixarBib == 1) {
			iFiltroBib = global_frame.geral_bib;
		}
	}
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=reservas&iIdioma="+global_frame.iIdioma+"&iFiltroBib="+iFiltroBib;
}

function LinkAquisicoes(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=aquisicoes&iIdioma="+global_frame.iIdioma;
}

function LinkDSI(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=dsi&iIdioma="+global_frame.iIdioma;
}

function LinkCirculacoes(modo) {
	bloqueia_renovar(0);
	//Adequação Itaú
	//Filtra os serviços para exibir informações somente de uma biblioteca
	var iFiltroBib = 0;
	if ((global_numero_serie ==	4090) || (global_numero_serie == 4184)) {
		if (global_frame.iFixarBib == 1) {
			iFiltroBib = global_frame.geral_bib;
		}
	}
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=circulacoes&iIdioma="+global_frame.iIdioma+"&iFiltroBib="+iFiltroBib;
}

function LinkBibCurso(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=bib_curso&iIdioma="+global_frame.iIdioma;
}

function LinkMensagens(modo) {
	//Adequação Itaú
	//Filtra os serviços para exibir informações somente de uma biblioteca
	var iFiltroBib = 0;
	if ((global_numero_serie ==	4090) || (global_numero_serie == 4184)) {
		if (global_frame.iFixarBib == 1) {
			iFiltroBib = global_frame.geral_bib;
		}
	}
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=mensagens&iIdioma="+global_frame.iIdioma+"&iFiltroBib="+iFiltroBib;
}

function LinkTrocaSenha(modo) {
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=troca_senha&iIdioma="+global_frame.iIdioma;
}

function LinkLogout(modo) {
	parent.mainFrame.location = ext+"/logout."+ext+"?logout=sim&modo_busca="+modo+"&libarar_sessoes=sim&iIdioma="+global_frame.iIdioma;
}

function LinkPesquisa(modo,acao,veio_de) {
	var dir = "";
	if (veio_de == ext) {
		dir = "../";
	}
	
	if (global_frame.vetor_pag.length == 0)  
	{
		acao = 0;
	} 
	else 
	{
		var v_pag = "";
		var sPagCorrente = "";
		var sIndCorrente = "";
		
		for(var i = 1; i <= global_frame.vetor_pag.length - 1; i++)
		{
			if(global_frame.vetor_pag[i] == undefined)
			{
				v_pag = v_pag + "|";				
				sPagCorrente = sPagCorrente + "|";
				sIndCorrente = sIndCorrente + "|";				
			}
			else
			{
				if(global_frame.vetor_pag[i][global_frame.arPagCorrente[i]]== undefined) 
				{
					v_pag = v_pag + "|";
					sPagCorrente = sPagCorrente + "|";
					sIndCorrente = sIndCorrente + "|";
				} 
				else 
				{
					// Códigos da página
					v_pag = v_pag + "|" + global_frame.vetor_pag[i][global_frame.arPagCorrente[i]];
					// Páginas correntes
					sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrente[i];
					//Índices correntes
					sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrente[i];
				}		
			}
		}
	}
	
	if (acao == 0) 
	{
		parent.mainFrame.location = dir + "index."+ext+"?modo_busca="+modo+"&content=resultado_fak&iIdioma="+global_frame.iIdioma;
	}
	else
	{
		parent.mainFrame.location = dir + "index."+ext+
									"?modo_busca="+modo+
									"&content=resultado&veio_de=menu&pagina="+sPagCorrente+
									"&vetor_pag='"+v_pag+"'"+
									"&Servidor="+global_frame.iSrvCorrente+
									"&iSrvCombo="+global_frame.geral_bib+
									"&indice="+sIndCorrente+
									"&iIdioma="+global_frame.iIdioma+
									LinkDestacaPalavras("resultado");
	}
}

function LinkSelecao(modo,veio_de) {
	var dir = "";
	if (veio_de == ext) {
		dir = "../";
	}
	
	parent.mainFrame.location = dir + "index."+ext+"?modo_busca="+modo+"&content=selecao&veio_de=menu&Servidor="+global_frame.iSrvCorrente_MySel+"&iIdioma="+global_frame.iIdioma;
}

function LinkAutoridades(modo,acao) {
	
	global_frame.modo_busca="rapida";
	if (global_frame.vetor_pag_auts.length == 0)  
	{
		acao = 0;
	} 
	else 
	{
		var v_pag = "";
		var sPagCorrente = "";
		var sIndCorrente = "";
		
		for(var i = 1; i <= global_frame.vetor_pag_auts.length - 1; i++)
		{
			if(global_frame.vetor_pag_auts[i] == undefined)
			{
				v_pag = v_pag + "|";				
				sPagCorrente = sPagCorrente + "|";
				sIndCorrente = sIndCorrente + "|";				
			}			
			else
			{
				if(global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]]==undefined) 
				{
					v_pag = v_pag + "|";
					sPagCorrente = sPagCorrente + "|";
					sIndCorrente = sIndCorrente + "|";
				} 
				else 
				{
					// Códigos da página
					v_pag = v_pag + "|" + global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]];
					// Páginas correntes
					sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrenteAut[i];
					//Índices correntes
					sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrenteAut[i];
				}		
			}
		}
	}
	
	if (acao == 0) 
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca=rapida&aut=1&veio_de=nova_autoridade&content=autoridades_fak&iIdioma="+global_frame.iIdioma;
	}
	else
	{	
		parent.mainFrame.location = "index."+ext+"?modo_busca=rapida&aut=1&content=autoridades&veio_de=menu&aut_pag='"+v_pag+"'&pagina="+sPagCorrente+"&Servidor="+global_frame.iSrvCorrente_Aut+"&iSrvCombo="+global_frame.geral_bib+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras("autoridades");
	}
	
	move_layer('div1','div2','div4','rapida','tab_rap','tab_comb','lk_rap','lk_comb','#e6e6e6','#cccccc','divL');
}

function LinkDetalheAutoridade(modo,qtde,pos_vetor,cod_aut,pag,veio) {

	if(veio == "linkAutInfo") {
		var iServidor = global_frame.iSrvCorrente;
	} else {
		var iServidor = global_frame.iSrvCorrente_Aut;	
	}
	
	var sLinkDestacaAutoridade = "";
	
	if (global_frame.aut_campo.length > 0){
		sLinkDestacaAutoridade = "&campo1=palavra_chave&valor1="+parent.hiddenFrame.aut_campo.replace(" ", "_");
	}
	parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content=detalhe_autoridades&qtde="+qtde+"&posicao_vetor="+pos_vetor+"&codigo_aut="+cod_aut+"&pagina="+pag+"&veio_de="+veio+"&aut=1"+"&Servidor="+iServidor+"&iIdioma="+global_frame.iIdioma+sLinkDestacaAutoridade;
}

function ReservaEx(logado,cod_usu,tipo,cod_obra,ano,vol,ed,bib,veio_de,serv) {
	var docroot = ext+'/';
	if (veio_de=='../') {
		var popup = true;
	} else {
		var popup = false;
	}
	var url_res = docroot+'reserva.'+ext+'?codigo_usuario='+cod_usu+'&codigo_obra='+cod_obra+'&ano='+ano+'&volume='+vol+'&edicao='+ed+'&biblioteca='+bib+'&veio_de=detalhe_reservaex&tipo_obra='+tipo+'&servidor='+serv+"&iIdioma="+global_frame.iIdioma;
	var url_log = docroot+'login.'+ext+'?modo_busca=rapida&codigo_obra='+cod_obra+'&ano='+ano+'&volume='+vol+'&edicao='+ed+'&biblioteca='+bib+'&veio_de=reservaex&tipo_obra='+tipo+'&servidor='+serv+"&iIdioma="+global_frame.iIdioma;

	var msg_reserva = getTermo(global_frame.iIdioma, 348, 'Reserva', 0);

	if (logado == 0) {
		if (popup == true) {
			parent.abrePopup2(url_log,msg_reserva,320,210,false,false);
		} else {
			abrePopup(url_log,msg_reserva,320,210,false,false);
		}
	} else {
		if (popup == true) {
			parent.abrePopup2(url_res,msg_reserva,320,210,false,false);
		} else {
			abrePopup(url_res,msg_reserva,320,210,false,false);
		}
	}
}

function resetar_sels() { 
	parent.mainFrame.location = "index."+ext+"?modo_busca="+global_frame.modo_busca+"&content=selecao&acao=resetar&veio_de=resetar&Servidor="+global_frame.iSrvCorrente_MySel+"&iIdioma="+global_frame.iIdioma;
	Resetar();
}

function envia_sels() { 
	var msg_email = getTermo(global_frame.iIdioma, 1318, 'Enviar e-mail', 0);
	abrePopup(ext+'/envia_sels.'+ext+'?acao=conferir&Servidor='+global_frame.iSrvCorrente_MySel+"&iIdioma="+global_frame.iIdioma,msg_email,320,210,false,false);
}

function imp_minhas_sels() {
	var msg_minhasel = getTermo(global_frame.iIdioma, 963, 'Minha seleção', 0);
	abrePopup(ext+'/imprimirSels.'+ext+'?Servidor='+global_frame.iSrvCorrente_MySel+"&iIdioma="+global_frame.iIdioma,msg_minhasel,698,490,false,true);
}

function solic_sels() { 
	var msg_solic = getTermo(global_frame.iIdioma, 825, 'Solicitar consulta', 0);
	abrePopup(ext+'/lista_imp.'+ext+'?acao=conferir&Servidor='+global_frame.iSrvCorrente_MySel+"&iIdioma="+global_frame.iIdioma,msg_solic,320,210,false,false);
}

function validaTeclaLogin(campo, e, rm) { 
	var key; 
	var tecla; 
	var validou = true;
	var strValidChars = "0813";
	var tecla = window.event ? e.keyCode : e.which; 
	if ( strValidChars.indexOf( tecla ) > -1 ) {
		validou = false;
	}
	key = String.fromCharCode( tecla); 
	if (rm == 1) {
		if ((!isNum(key)) && (validou==true)) {
			alert(getTermo(global_frame.iIdioma, 1309, 'Este campo deve ser numérico.', 0));
			return false;
		}
	}
	if ( tecla == 13 ) {
		var tam_login = document.login.codigo.value.length;
		//var tam_senha = document.login.senha.value.length;
		if (tam_login == 0) {
			alert(getTermo(global_frame.iIdioma, 1310, 'O campo código não pode ser vazio.', 0));
			document.login.codigo.focus();
			return false;
		}
		document.login.submit();		
	}
	return true;
}

function FechaLogin(modo) {
	//Adequação Itaú
	//Filtra os serviços para exibir informações somente de uma biblioteca
	var iFiltroBib = 0;
	if ((global_numero_serie ==	4090) || (global_numero_serie == 4184)) {
		if (global_frame.iFixarBib == 1) {
			iFiltroBib = global_frame.geral_bib;
		}
	}
	parent.document.location='../index.'+ext+'?modo_busca='+modo+'&content=mensagens&iIdioma='+global_frame.iIdioma+"&iFiltroBib="+iFiltroBib;
	parent.fechaPopup(); 
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1) {
		return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE == "") {
		return "";
	} else {
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0) {
		return	"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1) {
		if(VALUE.charAt(iTemp) == w_space) {
		} else {
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1) {
		return "";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length) {
		if(VALUE.charAt(iTemp) == w_space) {
		} else {
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function validateEmail()
{
	var email = document.frm_sels.sels_email.value;
	email = email.replace(",",";");
	var array_email=email.split(";");
	var email_num=0;
	var invalido = 0;
	while (email_num < array_email.length)
	{
		array_email[email_num] = Trim(array_email[email_num]);
		if (typeof(array_email[email_num]) != "string") {
			invalido+=1;
		}else if (!array_email[email_num].match(/^[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/)) {
			invalido+=1;
		}
		email_num+=1;
	}
	

	if (invalido > 0) {
		alert(getTermo(global_frame.iIdioma, 1317, 'O e-mail não é válido.', 0));
		return false;
	}else{
		document.frm_sels.submit();
	}
}

function bloqueia_renovar(acao) {
	if (acao == 1) { 
		global_frame.bloqueia_renovar = 1;
	}else{
		global_frame.bloqueia_renovar = 0;
	}
}

function LinkTelaCheia() {
	if (global_frame.layerX=='div4') {
		if ((obj6=MM_findObj('div6'))!=null) {
		//if ((obj5=MM_findObj('tela_cheia5'))!=null) {
			//alert('aq5');
			if (obj5.style) {
				//alert('aq55');
				//obj5=obj5.style;
				//obj5.visibility='hidden';
			}
		}
		if ((obj6=MM_findObj('tela_cheia6'))!=null) {
			if (obj6.style) {
				//alert('aq6');
				obj6=obj6.style;
				obj6.visibility='hidden';
			}
		}
	}else if (global_frame.layerX=='div5'){
		if ((obj4=MM_findObj('tela_cheia4'))!=null) {
			if (obj4.style) {
				obj4=obj4.style;
				obj4.visibility='hidden';
			}
		}
		if ((obj6=MM_findObj('tela_cheia6'))!=null) {
			if (obj6.style) {
				obj6=obj6.style;
				obj6.visibility='hidden';
			}
		}
		
	}else if (global_frame.layerX=='div6'){
		if ((obj4=MM_findObj('tela_cheia4'))!=null) {
			if (obj4.style) {
				obj4=obj4.style;
				obj4.visibility='hidden';
			}
		}
		if ((obj5=MM_findObj('tela_cheia5'))!=null) {
			if (obj5.style) {
				obj5=obj5.style;
				obj5.visibility='hidden';
			}
		}
	}
}

function mantemFoco(modo) {
	if (modo == "rapida") {
		document.frm_rapida.rapida_campo.focus();
		atribuiRapida();
	}else if (modo == "combinada") {
		atribuiComb();
		document.frm_combinada.comb_campo1.focus();
	}else if (modo == "legislacao") {
		atribuiLegs();
		document.frm_legislacao.leg_campo1.focus();
	}else if (modo == "aut") {
		atribuiAuts();
		document.frm_aut.aut_campo.focus();
	}
}

//----------------------------------------------------------------------

function LinkLembrarSenha() {
	var tam_codigo = document.login.codigo.value.length;
	if (document.login.servidor != null) {
		var serv = document.login.servidor.value;
		var url = ext+'/lembrar.'+ext+'?codigo='+document.login.codigo.value+'&servidor='+serv+"&iIdioma="+global_frame.iIdioma;
	} else {
		var url = ext+'/lembrar.'+ext+'?codigo='+document.login.codigo.value+"&iIdioma="+global_frame.iIdioma;		
	}
	if (tam_codigo == 0 ) {
		alert(getTermo(global_frame.iIdioma, 1312, 'Para ver a lembrança de sua senha, preencha o campo Login e clique em Lembrar.', 0));
	}else{		
		parent.abrePopup2(url,'Login',320,220,false,false);
	}
}

function RapidaBib() {
	document.frm_rapida.rapida_bib.value = document.frm_geral.geral_bib.value;
}

function AutoresBib() {
	if ((document.frm_geral != null) && (document.frm_aut != null)) {
		document.frm_aut.aut_bib.value = document.frm_geral.geral_bib.value;
	}
}

function CombBib() {
	document.frm_combinada.comb_bib.value = document.frm_geral.geral_bib.value;
}

function atualizaGeral(){
	if (document.frm_geral != null) {
		global_frame.geral_bib = document.frm_geral.geral_bib.value;
	}
}

function Reset_rapida() {
	if (global_frame.modo_busca=="telacheia") {
		global_frame.modo_busca="rapida";
	}
	if ((global_frame.iFixarBibUsu != 1) || (global_frame.iFixarBib != 1)) {
		global_frame.geral_bib = 0;
	}
	global_frame.rapida_campo = '';
	global_frame.rapida_filtro = global_campo_default1;
	document.frm_rapida.rapida_campo.focus();
}

function Reset_auts() {
	if (global_frame.modo_busca=="telacheia") {
		global_frame.modo_busca="rapida";
	}
	if ((global_frame.iFixarBibUsu != 1) || (global_frame.iFixarBib != 1)) {
		global_frame.geral_bib = 0;
	}
	global_frame.aut_campo = "";
	global_frame.aut_filtro = "qualquer";
	document.frm_aut.aut_campo.focus();
}

function Reset_auts_dsi() {
	global_frame.modo_busca="rapida";
	global_frame.aut_campo_dsi = "";
	global_frame.aut_filtro_dsi = "qualquer";
	if (document.frm_aut != null) {
		document.frm_aut.aut_campo.focus();
	}
}

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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function ValidaLogin(rm) {
	var tam_codigo = document.login.codigo.value.length;
	if (tam_codigo == 0) {
		alert(getTermo(global_frame.iIdioma, 1310, 'O campo código não pode ser vazio.', 0));
		document.login.codigo.focus();
		return false;
	}
	document.login.submit();
}

function isNumeric(strString) {
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) {
		return false;
	}
	for (i = 0; i < strString.length && blnResult == true; i++)	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}
	return blnResult;
}

function isNum( caractere ) 
{ 
  var strValidos = "0123456789" 
  if ( strValidos.indexOf( caractere ) == -1 ) return false; 
  return true; 
}

function habilitaEntre(tipo) {
	if (tipo=='cad') {
		var data = document.frm_legislacao.sel_data_cad.value;
		var obj1 = MM_findObj("data_cad_fim_dia");
		var obj2 = MM_findObj("data_cad_fim_mes");
		var obj3 = MM_findObj("data_cad_fim_ano");
		var obj4 = MM_findObj("data_cad_a");
		var obj5 = MM_findObj("data_cad_comp");
	} else {
		var data = document.frm_legislacao.sel_data_ass.value;
		var obj1 = MM_findObj("data_ass_fim_dia");
		var obj2 = MM_findObj("data_ass_fim_mes");
		var obj3 = MM_findObj("data_ass_fim_ano");
		var obj4 = MM_findObj("data_ass_a");
		var obj5 = MM_findObj("data_ass_comp");
	}
	if (obj1.style && obj2.style && obj3.style && obj4.style && obj5.style) {
		obj1=obj1.style;
		obj2=obj2.style;
		obj3=obj3.style;
		obj4=obj4.style;
		obj5=obj5.style;
		if (data != 3) {
			obj1.display="none";
			obj2.display="none";
			obj3.display="none";
			obj4.display="none";
			obj5.display="inline";
		} else {
			obj1.display="inline";
			obj2.display="inline";
			obj3.display="inline";
			obj4.display="inline";
			obj5.display="none";
		}
	}	
}


/*******************************************************************************************/
// DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
// Declaring valid date character, minimum year and maximum year
/*******************************************************************************************/
var dtCh= "/";
var minYear=0001;
var maxYear=2500;
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}

function formataData(dt,parte) {
	var tam_d = dt.length;
	var dt_final = "";
	if (parte == "ano") {
		if (tam_d == 1) {
			dt_final = "200"+dt;
		} else if (tam_d == 2) {
			if (dt > 50) {
				dt_final = "19"+dt;
			} else {
				dt_final = "20"+dt;
			}
		} else if (tam_d == 3) {
			dt_final = "0"+dt;
		} else if (tam_d == 4) {
			dt_final = dt;
		} else {
			dt_final = "";
		}
	} else {
		if (tam_d == 1) {
			dt_final = "0"+dt;
		} else if (tam_d == 2) {
			dt_final = dt;
		} else {
			dt_final = "";
		}
	}
	return dt_final;
}

function exibeRefbib(tipo,cod,serv) {
	var frm_ajx = document.getElementById('ajxFrame');
	frm_ajx.src = ext+"/ajxReferencias."+ext+"?tipo="+tipo+"&codigo="+cod+"&Servidor="+serv+"&iIdioma="+global_frame.iIdioma;
	
	var msg_aguarde = getTermo(global_frame.iIdioma, 32, "Carregando", 0) + "...";	
	var msg_refbib = getTermo(global_frame.iIdioma, 792, 'Referência bibliográfica', 0) + ":";
	var msg_fechar = getTermo(global_frame.iIdioma, 220, 'fechar', 2);

	var div_refbib = document.getElementById('div_refbib');
	var url = ext+"/referencias."+ext+"?tipo="+tipo+"&codigo="+cod+"&Servidor="+serv+"&iIdioma="+global_frame.iIdioma;
	msg = "<table width='740px' height='70px' border=0 cellspacing=1 bgcolor=#CCCCCC>";
	msg = msg + "<tr><td bgcolor=#FFFFFF width='740px' height='50px'><em>"+msg_refbib+"</em><br>";
	msg = msg + "<center><img src='imagens/mozilla_blu.gif' border='0'><br><br>"+msg_aguarde+"</center>";
	msg = msg + "<br><div align='right'><img src='icons/folderopen.gif' border=0' onClick='tiraRefbib()' style='cursor:pointer;'><a class='link_serv' onClick='tiraRefbib()' style='cursor:pointer;'>"+msg_fechar+"</div></td></tr></table><br>";
	div_refbib.innerHTML = msg;
}

function tiraRefbib() {
	var div_refbib = document.getElementById('div_refbib');
	msg = "";
	div_refbib.innerHTML = msg;
}

function exibeRefbib_Artigo(tipo,cod,obra,codex,serv) 
{
	var div_refbib = document.getElementById('div_refbib');
	var url = "referencias."+ext+"?tipo="+tipo+"&codigo="+cod+"&obra="+obra+"&codex="+codex+"&Servidor="+serv+"&iIdioma="+global_frame.iIdioma;
	
	msg = "<table width='310px' height='90px' border=0 cellspacing=1 bgcolor=#999999>";
	msg = msg + "<tr><td bgcolor=#FFFFFF width='310px' height='90px'>";
	msg = msg + "<iFrame width='310px' height='90px' id='rbFrame' name='rbFrame' frameborder='0' border='0' src='"+url+"' scrolling='auto'></iFrame>";
	msg = msg + "</td></tr></table>"
	div_refbib.innerHTML = msg;
}

function exibeBibcomp(cod) {
	var msg_bibcomp = getTermo(global_frame.iIdioma, 1315, 'Bibliografia complementar', 0);
	abrePopup(ext+'/bibcomp_main.'+ext+'?codigo='+cod+'&servidor='+global_frame.iSrvCorrente+"&iIdioma="+global_frame.iIdioma,msg_bibcomp,400,380,false,true);
}

function statusLoading(acao) {
	if (global_versao==2) {
		global_frame.statusLoading = acao;
		var loading = document.getElementById('loading');
		if (loading != null) {
			var content = '';
			if (acao==1) {
				var msg = getTermo(global_frame.iIdioma, 1314, 'Buscando', 0) + "...";
				var content = '<img src="imagens/mozilla_blu.gif" border="0" title="'+msg+'">';
			}
			if (global_frame.modo_busca=="rapida") {
				var posicao = global_div4_rapida + 67;
			} else if (global_frame.modo_busca=="telacheia") {
				var posicao = 67;
			} else {
				var posicao = global_div4_combinada + 67;
			}
			loading.style.top = posicao+"px";
			loading.innerHTML = content;
		}
	} else {
		global_frame.statusLoading = 0;
	}
}

function LinkPaginacao(modo,local,pag,ind,qtd,bak,content) 
{
	if (pag >= global_frame.limite_vetores) 
	{
		pag = global_frame.limite_vetores - 1;
	}

	if (content == "autoridades") 
	{
		// Guarda a página corrente do servidor corrente
		global_frame.arPagCorrenteAut[global_frame.iSrvCorrente_Aut] = pag;
		// Guarda o índice corrente do servidor corrente
		global_frame.arIndCorrenteAut[global_frame.iSrvCorrente_Aut] = ind;
		
		// Monta uma string com a página corrente de cada Aba (Servidor de Aplicação)
		var v_pag = "";
		var sIndCorrente = "";
		var sPagCorrente = "";
		
		for(var i = 1; i <= global_frame.vetor_pag_auts.length - 1; i++)
		{	
			if(global_frame.vetor_pag_auts[i] == undefined)
			{
				v_pag = v_pag + "|";
				sPagCorrente = sPagCorrente + "|"; 
				sIndCorrente = sIndCorrente + "|"; 			
			}
			else
			{																
				if(global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]]==undefined) 
				{
					v_pag = v_pag + "|";
					sPagCorrente = sPagCorrente + "|"; 
					sIndCorrente = sIndCorrente + "|"; 
				} 
				else 
				{
					v_pag = v_pag + "|" + global_frame.vetor_pag_auts[i][global_frame.arPagCorrenteAut[i]];
					
					if ((local == 'primeiro') && (i == global_frame.iSrvCorrente_Aut))
					{
						sPagCorrente = sPagCorrente + "|1";
						sIndCorrente = sIndCorrente + "|1";
					}
					else if ((local == 'ultimo') && (i == global_frame.iSrvCorrente_Aut))
					{
						sPagCorrente = sPagCorrente + "|" + qtd;
						sIndCorrente = sIndCorrente + "|" + ind;
					}
					else
					{
						sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrenteAut[i];
						sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrenteAut[i];
					}
				}		
			}
		}	
		content = content+"&aut=1&aut_pag='"+v_pag+"'&Servidor="+global_frame.iSrvCorrente_Aut+"&iSrvCombo="+global_frame.geral_bib;
	} 
	else 
	{
		// Guarda a página corrente do servidor corrente
		global_frame.arPagCorrente[global_frame.iSrvCorrente] = pag;
		// Guarda o índice corrente do servidor corrente
		global_frame.arIndCorrente[global_frame.iSrvCorrente] = ind;
		
		// Monta uma string com a página corrente de cada Aba (Servidor de Aplicação)
		var v_pag = "";
		var sIndCorrente = "";
		var sPagCorrente = "";
		
		for(var i = 1; i <= global_frame.vetor_pag.length - 1; i++)
		{		
			if(global_frame.vetor_pag[i] == undefined)
			{
				v_pag = v_pag + "|";
				sPagCorrente = sPagCorrente + "|"; 
				sIndCorrente = sIndCorrente + "|"; 			
			}
			else
			{							
				if(global_frame.vetor_pag[i][global_frame.arPagCorrente[i]]==undefined) 
				{
					v_pag = v_pag + "|";
					sPagCorrente = sPagCorrente + "|"; 
					sIndCorrente = sIndCorrente + "|"; 
				} 
				else 
				{
					v_pag = v_pag + "|" + global_frame.vetor_pag[i][global_frame.arPagCorrente[i]];
					
					if ((local == 'primeiro') && (i == global_frame.iSrvCorrente))
					{
						sPagCorrente = sPagCorrente + "|1";
						sIndCorrente = sIndCorrente + "|1";
					}
					else if ((local == 'ultimo') && (i == global_frame.iSrvCorrente))
					{
						sPagCorrente = sPagCorrente + "|" + qtd;
						sIndCorrente = sIndCorrente + "|" + ind;
					}
					else
					{
						sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrente[i];
						sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrente[i];
					}
				}		
			}
		}	
		
		content = content+"&vetor_pag='"+v_pag+"'&Servidor="+global_frame.iSrvCorrente+"&iSrvCombo="+global_frame.geral_bib;
	}
	
	document.body.style.cursor = "wait";
	statusLoading(1);
	
	if (local=='primeiro')
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content="+content+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
		global_frame.modo_busca_bak = bak;
		TelaCheia('manter',global_frame.layerX,'paginacao');
	} 
	else if (local=='anterior') 
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content="+content+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
		global_frame.modo_busca_bak = bak;
		TelaCheia('manter',global_frame.layerX,'paginacao');
	} 
	else if (local=='proximo') 
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content="+content+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
		global_frame.modo_busca_bak = bak;
		TelaCheia('manter',global_frame.layerX,'paginacao');
	} 
	else if (local=='ultimo') 
	{
		parent.mainFrame.location = "index."+ext+"?modo_busca="+modo+"&content="+content+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
	} 
	else 
	{
		var url = "index."+ext+"?modo_busca="+modo+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&content="+content+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
		parent.mainFrame.location = url;
	}
}

function LinkPaginacaoAutDSI(modo,local,pag,ind,qtd) 
{
	if (pag >= global_frame.limite_vetores) 
	{
		pag = global_frame.limite_vetores - 1;
	}
	
	// Guarda a página corrente do servidor corrente
	global_frame.arPagCorrenteAutDSI[1] = pag;
	// Guarda o índice corrente do servidor corrente
	global_frame.arIndCorrenteAutDSI[1] = ind;
	
	// Monta uma string com a página corrente de cada Aba (Servidor de Aplicação)
	var v_pag = "";
	var sIndCorrente = "";
	var sPagCorrente = "";
	
	if(global_frame.vetor_pag_auts_dsi[1] == undefined)
	{
		v_pag = v_pag + "|";
		sPagCorrente = sPagCorrente + "|"; 
		sIndCorrente = sIndCorrente + "|"; 			
	}
	else
	{																
		if(global_frame.vetor_pag_auts_dsi[1][global_frame.arPagCorrenteAutDSI[1]]==undefined) 
		{
			v_pag = v_pag + "|";
			sPagCorrente = sPagCorrente + "|"; 
			sIndCorrente = sIndCorrente + "|"; 
		} 
		else 
		{
			v_pag = v_pag + "|" + global_frame.vetor_pag_auts_dsi[1][global_frame.arPagCorrenteAutDSI[1]];
			
			if (local == 'primeiro')
			{
				sPagCorrente = sPagCorrente + "|1";
				sIndCorrente = sIndCorrente + "|1";
			}
			else if (local == 'ultimo')
			{
				sPagCorrente = sPagCorrente + "|" + qtd;
				sIndCorrente = sIndCorrente + "|" + ind;
			}
			else
			{
				sPagCorrente = sPagCorrente + "|" + global_frame.arPagCorrenteAutDSI[1];
				sIndCorrente = sIndCorrente + "|" + global_frame.arIndCorrenteAutDSI[1];
			}
		}		
	}

	var param_pag = "&aut_pag='"+v_pag+"'";
	
	document.body.style.cursor = "wait";
	statusLoading(1);
	
	if (local=='primeiro')
	{
		var url = "novo_interesse."+ext+"?modo_busca="+modo+"&acao=buscar"+param_pag+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma;
		document.location = url;
	} 
	else if (local=='anterior') 
	{
		var url = "novo_interesse."+ext+"?modo_busca="+modo+"&acao=buscar"+param_pag+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma;
		document.location = url;
	} 
	else if (local=='proximo') 
	{
		var url = "novo_interesse."+ext+"?modo_busca="+modo+"&acao=buscar"+param_pag+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma;
		document.location = url;
	} 
	else if (local=='ultimo') 
	{
		var url = "novo_interesse."+ext+"?modo_busca="+modo+"&acao=buscar"+param_pag+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&iIdioma="+global_frame.iIdioma;
		document.location = url;
	} 
	else 
	{
		var url = "novo_interesse."+ext+"?modo_busca="+modo+"&veio_de=paginacao&pagina="+sPagCorrente+"&indice="+sIndCorrente+"&submeteu="+modo+"&acao=buscar"+param_pag+"&iIdioma="+global_frame.iIdioma;
		document.location = url;
	}
}

function LinkAutBorder(acao,pos) {
	if (pos==0) {
		var obj = document.getElementById('autImg').style;
	} else {
		var obj = document.getElementById('autImg'+pos).style;
	}
	if (acao == 1) {
		obj.borderBottom='1px solid #008ADD';
		obj.borderTop='1px solid #008ADD';
		obj.borderLeft='1px solid #008ADD';
		obj.borderRight='1px solid #008ADD';
		obj.backgroundImage='url(imagens/aut_2.gif)';
	} else {
		obj.borderBottom='1px solid #f2f2f2';
		obj.borderTop='1px solid #f2f2f2';
		obj.borderLeft='1px solid #f2f2f2';
		obj.borderRight='1px solid #f2f2f2';
		obj.backgroundImage='url(imagens/aut_1.gif)';
	}
}

function LinkAssuntoBorder(acao,pos) {
	var obj = document.getElementById('assuntoImg'+pos).style;
	if (acao == 1) {
		obj.borderBottom='1px solid #008ADD';
		obj.borderTop='1px solid #008ADD';
		obj.borderLeft='1px solid #008ADD';
		obj.borderRight='1px solid #008ADD';
		obj.backgroundImage='url(imagens/assunto_2.gif)';
	} else {
		obj.borderBottom='1px solid #f2f2f2';
		obj.borderTop='1px solid #f2f2f2';
		obj.borderLeft='1px solid #f2f2f2';
		obj.borderRight='1px solid #f2f2f2';
		obj.backgroundImage='url(imagens/assunto_1.gif)';
	}
}

function LinkAutInfo(bak,cod,desc) {
	LinkDetalheAutoridade(global_frame.modo_busca,1,0,cod,1,bak);
	global_frame.aut_campo = URLdecode(desc);
}

function servicosResultOver (nome) {
	var obj = document.getElementById(nome).style;	
	obj.backgroundColor = "#FFFFFF";
	obj.color = "#000066";
}

function servicosResultOut (nome) {
	var obj = document.getElementById(nome).style;
	if (nome.indexOf("_s_sel") >= 0) {
		var desc = nome.substring(0,nome.indexOf("_s_sel")) + "_s_sel";
		var codObra = nome.substring(desc.length,nome.length);
		var id_check = nome.substring(0,nome.indexOf("_s_sel")) + "_cksel" + codObra;
		var check = document.getElementById(id_check);
		if ((check == null) || (check.checked == false)) {
			obj.backgroundColor = "#f2f2f2";
			obj.color = "#000000";
		} else {
			obj.backgroundColor = "#d1e2ec";
			obj.color = "#000000";
		}
	} else {
		obj.backgroundColor = "#f2f2f2";
		obj.color = "#000000";
	}
}

function LinkImpRecibo(servidor) {
	var msg_recibo = getTermo(global_frame.iIdioma, 589, 'Recibo de renovação', 0);
	abrePopup(ext+'/imprimirRecibo.'+ext+'?servidor='+servidor+"&iIdioma="+global_frame.iIdioma,msg_recibo,688,500,false,true);
}

//#######################################################################################//
// FUNÇÂO detalhes 
//#######################################################################################//
function detalhes(modo) {
	if (modo == 'combinada') {
		var pos = global_div4_combinada;
	}else if (modo == 'legislacao') {
		var pos = global_div4_legislacao;
	}else if (modo == 'telacheia') {
		var pos = 0;
	}else{
		var pos = global_div4_rapida;
	}
	global_frame.layerX = 'div4';
	if (global_frame.modo_busca=="telacheia") {
		Visualizar('div1','div2','div4','ativar',global_frame.modo_busca_bak);
	}
	if ((obj4=MM_findObj('div4'))!=null) {
		if (obj4.style) {
			obj4=obj4.style;
			if ((obj5=MM_findObj('div5'))!=null) {
				if (obj5.style) {
					obj5=obj5.style;
					if ((obj6=MM_findObj('div6'))!=null) {
						obj6=obj6.style;
						obj4.visibility='visible';
						obj4.top = pos;
						obj5.visibility='hidden';
						obj5.top = global_out_of_bounds;
						obj6.visibility='hidden';
						obj6.top = global_out_of_bounds;
						AbasLayerX();
					}
				}
			}
		}
	}	
}
//#######################################################################################//
// FUNÇÂO fichaMarcAuts 
//#######################################################################################//
function fichaMarcAuts(modo) {
	if (modo == 'combinada') {
		var pos = global_div4_combinada;
	}else if (modo == 'legislacao') {
		var pos = global_div4_legislacao;
	}else if (modo == 'telacheia') {
		var pos = 0;
	}else{
		var pos = global_div4_rapida;
	}
	global_frame.layerY = 'div4';
	if (global_frame.modo_busca=="telacheia") {
		Visualizar('div1','div2','div4','ativar',global_frame.modo_busca_bak);
	}
	if ((obj4=MM_findObj('div4'))!=null) {
		if (obj4.style) {
			obj4=obj4.style;
			if ((obj5=MM_findObj('div5'))!=null) {
				if (obj5.style) {
					obj5=obj5.style;
					obj4.visibility='visible';
					obj4.top = pos;
					obj5.visibility='hidden';
					obj5.top = global_out_of_bounds;
					AbasLayerY();					
				}
			}
		}
	}	
}
//#######################################################################################//
// FUNÇÂO fichaMarc 
//#######################################################################################//
function fichaMarc(modo) {
	if (modo == 'combinada') {
		var pos = global_div4_combinada;
	}else if (modo == 'legislacao') {
		var pos = global_div4_legislacao;
	}else if (modo == 'telacheia') {
		var pos = 0;
	}else{
		var pos = global_div4_rapida;
	}
	global_frame.layerX = 'div5';
	if (global_frame.modo_busca=="telacheia") {
		Visualizar('div1','div2','div5','ativar',global_frame.modo_busca_bak);
	}
	if ((obj4=MM_findObj('div4'))!=null) {
		if (obj4.style) {
			obj4=obj4.style;
			if ((obj5=MM_findObj('div5'))!=null) {
				if (obj5.style) {
					obj5=obj5.style;
					if ((obj6=MM_findObj('div6'))!=null) {
						obj6=obj6.style;
						obj4.visibility='hidden';
						obj4.top = global_out_of_bounds;
						obj5.visibility='visible';
						obj5.top = pos;
						obj6.visibility='hidden';
						obj6.top = global_out_of_bounds;
						AbasLayerX();
					}
				}
			}
		}
	}
}
//#######################################################################################//
// FUNÇÂO marcTagsAuts 
//#######################################################################################//
function marcTagsAuts(modo) {
	if (modo == 'combinada') {
		var pos = global_div4_combinada;
	}else if (modo == 'legislacao') {
		var pos = global_div4_legislacao;
	}else if (modo == 'telacheia') {
		var pos = 0;
	}else{
		var pos = global_div4_rapida;
	}
	global_frame.layerY = 'div5';
	if (global_frame.modo_busca=="telacheia") {
		Visualizar('div1','div2','div4','ativar',global_frame.modo_busca_bak);
	}
	if ((obj4=MM_findObj('div4'))!=null) {
		if (obj4.style) {
			obj4=obj4.style;
			if ((obj5=MM_findObj('div5'))!=null) {
				if (obj5.style) {
					obj5=obj5.style;
					obj4.visibility='hidden';
					obj4.top = global_out_of_bounds;
					obj5.visibility='visible';
					obj5.top = pos;
					AbasLayerY();
				}
			}
		}
	}	
}
//#######################################################################################//
// FUNÇÂO marcTags
//#######################################################################################//
function marcTags(modo) {
	if (modo == 'combinada') {
		var pos = global_div4_combinada;
	}else if (modo == 'legislacao') {
		var pos = global_div4_legislacao;
	}else if (modo == 'telacheia') {
		var pos = 0;
	}else{
		var pos = global_div4_rapida;
	}
	global_frame.layerX = 'div6';
	if (global_frame.modo_busca=="telacheia") {
		Visualizar('div1','div2','div6','ativar',global_frame.modo_busca_bak);
	}
	if ((obj4=MM_findObj('div4'))!=null) {
		if (obj4.style) {
			obj4=obj4.style;
			if ((obj5=MM_findObj('div5'))!=null) {
				if (obj5.style) {
					obj5=obj5.style;
					if ((obj6=MM_findObj('div6'))!=null) {
						obj6=obj6.style;
						obj4.visibility='hidden';
						obj4.top = global_out_of_bounds;
						obj5.visibility='hidden';
						obj5.top = global_out_of_bounds;
						obj6.visibility='visible';
						obj6.top = pos;
						AbasLayerX();
					}
				}
			}
		}
	}	
}

function habilitaMarc(val,layer,exibe,cod) {
	if (val){
		var dDet = document.getElementById('div4').style;
		var dFic = document.getElementById('div5').style;
		var dMar = document.getElementById('div6').style;
		if (global_frame.modo_busca == 'combinada') {
			var pos = global_div4_combinada;
		}else if (global_frame.modo_busca == 'legislacao') {
			var pos = global_div4_legislacao;
		}else if (global_frame.modo_busca == 'telacheia') {
			var pos = 0;
		}else{
			var pos = global_div4_rapida;
		}		
		if (exibe == 'detalhes') {
			global_frame.layerX = 'div4';
			AbasLayerX();
			dDet.visibility = 'visible';
			dDet.top = pos;
			dFic.visibility = 'hidden';
			dFic.top = global_out_of_bounds;
			dMar.visibility = 'hidden';
			dMar.top = global_out_of_bounds;
		} else if (exibe == 'fichaMarc') {
			global_frame.layerX = 'div5';
			AbasLayerX();
			dDet.visibility = 'hidden';
			dDet.top = global_out_of_bounds;
			dFic.visibility = 'visible';
			dFic.top = pos;
			dMar.visibility = 'hidden';
			dMar.top = global_out_of_bounds;
			ajxCall("ajxFichaMarc",cod,global_ficha_marc);
			global_ficha_marc = 1;
		} else if (exibe == 'marcTags') {
			global_frame.layerX = 'div6';
			AbasLayerX();
			dDet.visibility = 'hidden';
			dDet.top = global_out_of_bounds;
			dFic.visibility = 'hidden';
			dFic.top = global_out_of_bounds;
			dMar.visibility = 'visible';
			dMar.top = pos;
			ajxCall("ajxMarcTags",cod,global_marc_tags);
			global_marc_tags = 1;
		} else {
			global_frame.layerX = 'div4';
			dDet.visibility = 'visible';
			dDet.top = pos;
			dFic.visibility = 'hidden';
			dFic.top = global_out_of_bounds;
			dMar.visibility = 'hidden';
			dMar.top = global_out_of_bounds;
		}
	}
}

function ajxCall (pag,cod,loaded) {
	if (loaded == 0) {
		var obj = document.getElementById("ajxFrame");
		obj.src = ext+"/"+pag+"."+ext+"?cod="+cod+"&servidor="+global_frame.iSrvCorrente+"&iIdioma="+global_frame.iIdioma+LinkDestacaPalavras();
	}
}

function abreMarc(cod,veio) {
	if(veio == "sels") {
		var iServidor = global_frame.iSrvCorrente_MySel;
	} else {
		var iServidor = global_frame.iSrvCorrente;	
	}

	window.open(ext+'/iso2709.'+ext+'?codigo='+cod+'&veio_de='+veio+'&Servidor='+iServidor+"&iIdioma="+global_frame.iIdioma,'MarcPopup','location=no,scrollbars=yes,menubar=yes,toolbar=no,resizable=yes,left=20,top=170,width=700,height=210')
}

function redimensiona(obj,tam) {
	var obj_s = document.getElementById(obj).style;
	obj_s.width=tam;
}

//#######################################################################################//
// args: "nº de abas", "aba selecionada"
function Mostra_Aba(nAbas,AbaSel,sOrigem,sPrefixo) 
{ 
	arAbas = new Array(nAbas+1);
	for (var i = 1; i <= nAbas; i++)
	{
		arAbas[i]=MM_findObj(sPrefixo+'_div_aba'+i);
		if(arAbas[i] != null) 
		{	
			tdObj = MM_findObj(sPrefixo+'_td_aba'+i);
			
			if(i == AbaSel)
			{
				// Marca o servidor de aplicação corrente				
				if(sOrigem == "Pesquisa")
				{
					global_frame.iSrvCorrente = i;
				}	
				else if(sOrigem == "Autoridades")
				{
					global_frame.iSrvCorrente_Aut = i;
				}
				else if(sOrigem == "MySel")
				{
					global_frame.iSrvCorrente_MySel = i;
				}			
				
				// Mostra a aba referente ao servidor corrente
				arAbas[i].style.display = "block";				
				
				// Atualiza o CSS da aba				
				if(tdObj != null)
				{
					if(navigator.appName.indexOf("Netscape")!= -1)
					{
						tdObj.setAttribute("class",'td_aba_ativa');
					}
					else
					{
						tdObj.setAttribute("className",'td_aba_ativa');
					}
				}
			}
			else
			{
				// Esconde a aba referente ao servidor corrente
				arAbas[i].style.display = "none";
				
				// Atualiza o CSS da aba
				if(tdObj != null)
				{
					if(navigator.appName.indexOf("Netscape")!= -1)
					{
						tdObj.setAttribute("class",'td_aba_inativa');
					}
					else
					{
						tdObj.setAttribute("className",'td_aba_inativa');
					}				
				}				
			}
		}
	}	
}
//#######################################################################################//
// ROTINAS DE CONTROLE DA MINHA SELEÇÂO
//#######################################################################################//

function fichas_marcar_todos(srv) {
	var desc = "srv" + srv + "_cksel";	
	var doc = document;
	tag = doc.getElementsByTagName('input');
	for(i=tag.length-1;i>=0;i--) {
		if (tag[i].type == "checkbox") {
			if (tag[i].id.substring(0,desc.length) == desc) {
				var codObra = tag[i].id.substring(desc.length,tag[i].id.length);
				tag[i].checked = true;
				
				var td = doc.getElementById("srv" + srv + "_s_sel" + codObra);
				if (td != null) {
					td.style.background = "#d1e2ec";
				}
			}
		}
	}
}

function fichas_desmarcar_todos(srv) {
	var desc = "srv" + srv + "_cksel";
	var doc = document;
	tag = doc.getElementsByTagName('input');
	for(i=tag.length-1;i>=0;i--) {
		if (tag[i].type == "checkbox") {			
			if (tag[i].id.substring(0,desc.length) == desc) {
				var codObra = tag[i].id.substring(desc.length,tag[i].id.length);
				tag[i].checked = false;
				
				var td = doc.getElementById("srv" + srv + "_s_sel" + codObra);
				if (td != null) {
					td.style.background = "#f2f2f2";
				}
			}
		}
	}
}

function ficha_selecionar(srv,cod) {
	var desc = "srv" + srv + "_cksel" + cod;
	var doc = document;
	tag = doc.getElementById(desc);
	if (tag != null) {
		if (tag.checked == true) {
			tag.checked = false;
		} else {
			tag.checked = true;
		}
	}
}

function enviar_minha_selecao(srv) {
	if (parent.hiddenFrame != null) {
		armazena_selecao();		
		var c = parent.hiddenFrame.arSelecao[srv].length;
		var msg_minhasel = getTermo(global_frame.iIdioma, 963, 'Minha seleção', 0);
		if (c == 0) {
			alert(getTermo(global_frame.iIdioma, 1313, 'Nenhum título foi selecionado.', 0));
		} else if (c == 1) {
			var cods = parent.hiddenFrame.arSelecao[srv][0];
			var codObra = cods.substring(0,cods.indexOf('.'));
			var tipoObra = cods.substring(cods.indexOf('.')+1,cods.length);
			abrePopup(ext+"/selecionar." + ext + "?veio_de=grid&codigo=" + codObra + "&tipo=" + tipoObra + "&servidor=" + srv + "&iIdioma="+global_frame.iIdioma,msg_minhasel,320,210,false,false);
		} else {
			var cods = "";
			for (i = 0; i < c; i++) {
				if (cods != "") {
					cods = cods + ",";
				}
				cods = cods + parent.hiddenFrame.arSelecao[srv][i];
			}
			abrePopup(ext+"/selecionar." + ext + "?veio_de=grid&codigos=" + cods + "&servidor=" + srv + "&iIdioma="+global_frame.iIdioma,msg_minhasel,320,210,false,false);
		}
	}
}

function enviar_minha_selecao_bibcurso(srv) {
	var c = 0;
	var desc = "srv" + srv + "_cksel";
	var cods = "";
	var doc = document;
	tag = doc.getElementsByTagName('input');
	for(i=tag.length-1;i>=0;i--) {
		if (tag[i].type == "checkbox") {			
			if ((tag[i].id.substring(0,desc.length) == desc) && (tag[i].checked == true)) {
				if (cods != "") {
					cods += ",";
				}
				cods = cods + tag[i].value;
				c++;
			}
		}
	}
	var msg_minhasel = getTermo(global_frame.iIdioma, 963, 'Minha seleção', 0);
	if (c == 0) {
		alert(getTermo(global_frame.iIdioma, 1313, 'Nenhum título foi selecionado.', 0));
	} else if (c == 1) {
		var codObra = cods.substring(0,cods.indexOf('.'));
		var tipoObra = cods.substring(cods.indexOf('.')+1,cods.length);
		abrePopup(ext+"/selecionar." + ext + "?veio_de=grid&codigo=" + codObra + "&tipo=" + tipoObra + "&servidor=" + srv + "&iIdioma="+global_frame.iIdioma,msg_minhasel,320,210,false,false);
	} else {
		abrePopup(ext+"/selecionar." + ext + "?veio_de=grid&codigos=" + cods + "&servidor=" + srv + "&iIdioma="+global_frame.iIdioma,msg_minhasel,320,210,false,false);
	}
}

function find_array(a,s) {
	for (index = 0; index < a.length; index++) {
		if (a[index] == s) {
			return index;
		}
	}
	return -1;
}

function delete_array(a,pos) {
	for (index = pos; index < a.length; index++) {
		//Não é o ultimo registro
		if (index < (a.length-1)) {
			a[index] = a[index+1];
		} else {
			a[index] = undefined;
		}
	}
	a.length = a.length-1;
}

function armazena_selecao() {
	if (parent.hiddenFrame != null) {
		if ((parent.hiddenFrame.content == "resultado") || (parent.hiddenFrame.content == "busca_link")) {
			for (iSrv = 1; iSrv <= parent.hiddenFrame.iNumAbas; iSrv++) {
				if (parent.hiddenFrame.arSelecao[iSrv] == undefined) {
					parent.hiddenFrame.arSelecao[iSrv] = new Array;
				}
				var check = "srv" + iSrv + "_cksel";
				var tag = document.getElementsByTagName('input');
				for(i = tag.length - 1; i >= 0; i--) {
					if (tag[i].type == "checkbox") {
						if (tag[i].id.substring(0,check.length) == check) {
							//Adiciona na lista
							if (tag[i].checked == true) {
								var valor = tag[i].value;
								if (find_array(parent.hiddenFrame.arSelecao[iSrv],valor) < 0) {
									parent.hiddenFrame.arSelecao[iSrv][parent.hiddenFrame.arSelecao[iSrv].length] = valor;
								}
							//Remove na lista
							} else if (tag[i].checked == false) {
								var valor = tag[i].value;
								var iPos  = find_array(parent.hiddenFrame.arSelecao[iSrv],valor);
								if (iPos >= 0) {
									delete_array(parent.hiddenFrame.arSelecao[iSrv],iPos);
								}
							}
						}
					}
				}
			}
		}
	}
}

function marca_selecao() {
	if (parent.hiddenFrame != null) {
		if ((parent.hiddenFrame.content == "resultado") || (parent.hiddenFrame.content == "busca_link")) {
			for (iSrv = 1; iSrv <= parent.hiddenFrame.iNumAbas; iSrv++) {
				if (parent.hiddenFrame.arSelecao[iSrv] != undefined) {
					for (cod = 0; cod < parent.hiddenFrame.arSelecao[iSrv].length; cod++) {
						var valor = parent.hiddenFrame.arSelecao[iSrv][cod];
						valor = valor.substring(0,valor.length-2);
						var check = document.getElementById("srv" + iSrv + "_cksel" + valor);
						if (check != null) {
							check.checked = true;	
						}
						var td = document.getElementById("srv" + iSrv + "_s_sel" + valor);
						if (td != null) {
							td.style.background = "#d1e2ec";
						}
					}
				}
			}
		}
	}
}

function alteraIdioma(idioma) {
	var idiomaOld = global_frame.iIdioma;
	global_frame.iIdioma = idioma;
	
	if ((global_frame.content == "resultado") || (global_frame.content == "busca_link")) {
		LinkPesquisa(global_frame.modo_busca,1,'');
	} else if (global_frame.content == "selecao") {
		LinkSelecao(global_frame.modo_busca,'');
	} else if (global_frame.content == "detalhe") {
		var pos_idioma = main_frame.location.toString().indexOf("iIdioma=" + idiomaOld);
		var pos_marc = main_frame.location.toString().indexOf("ve_marc=");
		var	url_marc = "ve_marc="+global_frame.layerX;
		if (pos_marc < 0) {		
			if (pos_idioma >= 0) {
				var urlAux = main_frame.location.toString().replace("#", "") + "&" + url_marc;
				main_frame.location = urlAux.replace("iIdioma=" + idiomaOld, "iIdioma=" + idioma);
			} else {
				main_frame.location = main_frame.location + "&refresh_popup=1&iIdioma="+idioma + "&" + url_marc;
			}
		} else {		
			var div_marc = main_frame.location.toString().substring(pos_marc,main_frame.location.toString().length);
			div_marc = div_marc.replace("#", "");
					
			var pos_e = div_marc.indexOf("&");
			if (pos_e >= 0) {
				div_marc = div_marc.substring(0,pos_e);
			}
			
			if (pos_idioma >= 0) {
				var urlAux = main_frame.location.toString().replace("#", "");
				urlAux = urlAux.replace(div_marc, url_marc);
				main_frame.location = urlAux.replace("iIdioma=" + idiomaOld, "iIdioma=" + idioma);
			} else {
				var urlAux = main_frame.location + "&refresh_popup=1&iIdioma="+idioma;
				urlAux = urlAux.replace(div_marc, url_marc);
				main_frame.location = urlAux;
			}
		}
	} else {
		var pos_idioma = main_frame.location.toString().indexOf("iIdioma=" + idiomaOld);
		if (pos_idioma >= 0) {
			main_frame.location =  main_frame.location.toString().replace("iIdioma=" + idiomaOld, "iIdioma=" + idioma);
		} else {
			var pos = main_frame.location.toString().indexOf("?");
			if (pos < 0) {
				main_frame.location = main_frame.location + "?refresh_popup=1&iIdioma="+idioma;
			} else {
				main_frame.location = main_frame.location + "&refresh_popup=1&iIdioma="+idioma;
			}
		}
	}
}