function decode(pText) {
	return unescape(pText.replace(/\+/g,  " "));
}


function $(o) {
	return document.getElementById(o);
}

String.prototype.RegExIkono = function() {
	if (this != "" && this != "*") {
		pos1 = this.indexOf("\"");
		pos2 = this.indexOf("\"",pos1+1);
		text = this;
		textExact = "";
		if (pos2 > pos1) {
			textExact = "(\\b" + text.substr(pos1+1, pos2-pos1-1) + "\\b)";
			text = text.substr(0, pos1-1).trim() + text.substr(pos2+1, text.length).trim();
		}
		if (text.trim() != "") {
			words = text.split(" ");
			text = "";
			for (s in words) {
				palavra = words[s];
				if (text == "") {
					text = "\\b" + palavra + "\\b";
				} else {
					text = text + ".+\\b" + palavra + "\\b";
				}
			}
			text = "(" + text + ")";
		}
		if (text != "" && textExact != "") {
			text = text + ".+" + textExact + "|" + textExact + ".+" + text;
		} else if (text == "") {
			text = textExact;
		}
		return text;	
	} else {
		return "";
	}
}

function preencheCampos(){
	var qry = window.location.search.substr(1);
	if (!qry || qry.length<1 || qry == '') return;
	if (qry.indexOf('@@@')>=0){
		qryArr = qry.split('@@@');
	}
		else{
		qryArr = [qry];
	}
  
	for (var i=0; i<qryArr.length; i++){
		paramArr = qryArr[i].split('***');
		if (paramArr[1] == "text") {
			document.getElementById(paramArr[0]).value = decode(paramArr[2]);
		} else if (paramArr[1] == "checkbox") {
			document.getElementById(paramArr[0]).checked = paramArr[2];
		}
	}
  
	if (window.location.search.substr(1).indexOf('exec_search=true') > 0) {
		if (valida_form()) search_form.submit();
	}

}

function docLoad() {
	// Verifica se a requisição veio da Tree, e seleciona a tab Documento
	if (top.frameTop.frames['conteudo'].location.search.lastIndexOf("rid=") > -1) {
		TabDoc();
	}
}

// Pesquisa somente em um campo por vez
function queryLine(field, value_field, exact) {
	if (exact == true) {
		value_field = "^" + value_field + "\\b";	
	} else {
		if (value_field != "") {
			words = value_field.split(" ");
			value_field = "";
			for (s in words) {
				palavra = words[s];
				if (value_field == "") {
					value_field = "^" + palavra + "\\b";
				} else {
					value_field = value_field + ".+\\b" + palavra + "\\b";
				}
			}
		} else {
			value_field = ".";
		}
	}
	
	var newObject = document.createElement("input");
	newObject.type = "hidden";
	newObject.name = "fx_" + field;
	newObject.value = value_field;
	
	form = document.getElementById("queryline_form");
	form.action = "eyebot.dll/advsearch";
	form.method = "get";
	form.target = "resultado";
	form.appendChild(newObject);
	form.submit();
}

// Pesquisa em vários campos simultâneamente
function queryLine2(field_value, exact) {
	form = $("queryline_form");
	form.action = "eyebot.dll/advsearch";
	form.method = "get";
	form.target = "resultado";

	field_array = field_value.split("|");
	for (n in field_array) {

		field = field_array[n].substr(0, field_array[n].indexOf(":"));
		value_field = field_array[n].substr(field_array[n].indexOf(":")+1).trim();
		if (value_field.indexOf(" ") > 0) {
			value_field = value_field.substr(0, value_field.indexOf(" "));
		}

		if (exact == true) {
			value_field = "^" + value_field + "\\b";	
		} else {
			if (value_field != "") {
				words = value_field.split(" ");
				value_field = "";
				for (s in words) {
					palavra = words[s];
					if (value_field == "") {
						value_field = "^" + palavra + "\\b";
					} else {
						value_field = value_field + ".+\\b" + palavra + "\\b";
					}
				}
			} else {
				value_field = ".";
			}
		}
		var newObject = document.createElement("<input type='hidden' name='fx_" + field + "' value='" + value_field + "'>");
		form.appendChild(newObject);
	}
	form.submit();
}

function salvaPesquisa() {
	document.search_form.action = "salvapesquisa.asp";
	document.search_form.target = "";
	document.search_form.submit();
	document.search_form.target = "resultado";
	document.search_form.action = "../eyebot.dll/advsearch";
}

function cancelaPesquisa() {
	TabDoc(true);
}

function printPreview() {
	myWin = window.open("printpreview.asp","janela","height=520,width=750,resizable=yes");
	myWin.focus();
}

function selectionPreview() {
	if (parent.menu.menu_selection.document.getElementById('no_donut')) {
		alert('Não existem documentos selecionados.');	
	} else {
		myWin = window.open("printpreview.asp?selection=true","janela","height=520,width=750,resizable=yes");
		myWin.focus();
	}
}

function showDocComplete() {
	myWin = window.open("printpreview.asp?complete=true","janela","height=520,width=750,resizable=yes");
	myWin.focus();
}

function resizeFrameV() {

	if (navigator.appName.indexOf("Internet Explorer") != -1) {
		if ($("show_v").style.display == "block") {
			top.frameTop.document.getElementById("frame1").setAttribute("cols", "280,*");
			$("show_v").style.display = "none";
			$("hide_v").style.display = "block";
			$("td_menu").style.display = "block";
		} else {
			top.frameTop.document.getElementById("frame1").setAttribute("cols", "9,*");
			$("show_v").style.display = "block";
			$("hide_v").style.display = "none";
			$("td_menu").style.display = "none";
		}
	} else {
		if (parent.frames[1].$("show_v").style.display == "block") {
			 top.frameTop.document.getElementById("frame1").setAttribute("cols", "280,*");
			parent.frames[1].$("show_v").style.display = "none";
			parent.frames[1].$("hide_v").style.display = "block";
			parent.frames[1].$("td_menu").style.display = "block";
			parent.frames[1].location.reload(true);
		} else {
			 top.frameTop.document.getElementById("frame1").setAttribute("cols", "9,*");
			parent.frames[1].$("show_v").style.display = "block";
			parent.frames[1].$("hide_v").style.display = "none";
			parent.frames[1].$("td_menu").style.display = "none";
		}
	}
}

function resizeFrameH(force) {
	if (top.frameTop.resizer.$('show_h').style.display == 'none' && !force) {
		if (top.frameTop.header.showLocator) {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "125,6,*,6,30%,22");
//			top.frameTop.frame2.rows = "125,6,*,6,30%,22";
		} else {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "0,6,*,6,30%,22");
//			top.frameTop.frame2.rows = "0,6,*,6,30%,22";
		}
		top.frameTop.resizer.$('show_h').style.display = 'block';
		top.frameTop.resizer.$('hide_h').style.display = 'none';
	} else {
		if (force) {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "0,6,*,6,0,22");
//			top.frameTop.frame2.rows = "0,6,*,6,0,22";
			top.frameTop.resizer_locator.$('show_h').style.display = 'block';
			top.frameTop.resizer_locator.$('hide_h').style.display = 'none';
		} else {
			if (top.frameTop.header.showLocator) {
				top.frameTop.document.getElementById("frame2").setAttribute("rows", "125,6,*,6,0,22");
//				top.frameTop.frame2.rows = "125,6,*,6,0,22";
			} else {
				top.frameTop.document.getElementById("frame2").setAttribute("rows", "0,6,*,6,0,22");
//				top.frameTop.frame2.rows = "0,6,*,6,0,22";
			}
		}
		top.frameTop.resizer.$('show_h').style.display = 'none';
		top.frameTop.resizer.$('hide_h').style.display = 'block';
	} 
}

function resizeFrameLocator(force) {
	var vResult;
	
	// Verificando se a Tab Documento está selecionada
	if (top.frameTop.tabs.$("doc_bg").className == "bg_on") {
		vResult = "0";
		top.frameTop.resizer.$('show_h').style.display = 'none';
		top.frameTop.resizer.$('hide_h').style.display = 'block';
	} else {
		vResult = "6";
	}
	
	if (top.frameTop.resizer_locator.$('show_h').style.display == 'none' && !force) {
	
		if (top.frameTop.resizer.$('show_h').style.display == 'block') {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "0,6,*,6,30%,22");
		} else {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "0,6,*," + vResult + ",0,22");
		}
		
		top.frameTop.header.showLocator = false;
		top.frameTop.resizer_locator.$('show_h').style.display = 'block';
		top.frameTop.resizer_locator.$('hide_h').style.display = 'none';
	} else {
		if (top.frameTop.resizer.$('show_h').style.display == 'block') {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "125,6,*,6,30%,22");
		} else {
			top.frameTop.document.getElementById("frame2").setAttribute("rows", "125,6,*," + vResult + ",0,22");		
		}
		top.frameTop.header.showLocator = true;
		top.frameTop.resizer_locator.$('show_h').style.display = 'none';
		top.frameTop.resizer_locator.$('hide_h').style.display = 'block';
	} 

}

String.prototype.trim = function()
{
	return this.replace(/^\s*|\s*$/g,"");
}

//Pesquisa do menu lateral	
function searchExec() {
var pesquisa = parent.menu_pesquisas.$('expr').innerHTML;

	if (pesquisa.trim() == "texto a ser pesquisado" || pesquisa.trim() == "") {
		alert('Digite um ou mais termos para iniciar sua pesquisa.');
		parent.menu_pesquisas.$('expr').focus();
		return;
	}
	loader(true);
	parent.menu_pesquisas.document.pesquisa.submit();
	showResult();
	top.frameTop.resultado.focus();
	top.frameTop.menu.menuDesliza(4, true);	
}

//Pesquisa do header	
function fastSearchExec() {
var pesquisa = $('expr').value;

	if (pesquisa.trim() == "Pesquisar..." || pesquisa.trim() == "") {
		alert('Digite um ou mais termos para iniciar sua pesquisa.');
		return;
	}
	loader(true);
	top.frameTop.header.pesquisa.submit();
	showResult();
	top.frameTop.resultado.focus();
	top.frameTop.menu.menuDesliza(4, true);
}

function showResult() {
	TabDocResult();
}

//onSubmit das pesquisas avançadas	
function showResultAdv () {
	loader(true);
	//top.frameTop.header.$("expr").value = "Pesquisar...";
	top.frameTop.menu.menuDesliza(4, true);
}

top.showResultAdv = function () {
	TabDocResult();
}

function showDocResult(doc, objeto) {
	var classScroll = top.frameTop.tabs.$("res_bg").className      // Dependendendo da classe do aba resultado irá rolar a linha do resultado até deixá-la visível
	if (top.frameTop.frames["conteudo"].location.href.substr(top.frameTop.conteudo.location.href.indexOf("?")) != doc.substr(doc.indexOf("?"))) { 
		loader(true);
	}
	top.frameTop.frames["conteudo"].location.href = doc;
	TabDocResult();
	try {
		if (classScroll == "bg_on") {
			top.frameTop.resultado.document.getElementById(objeto).scrollIntoView();
		}
	} catch(e) {
		//	
	}
}

function showDoc(doc) {
	if (top.frameTop.frames["conteudo"].location.href.substr(top.frameTop.conteudo.location.href.indexOf("?")) != doc.substr(doc.indexOf("?"))) { 
		loader(true);
	}
	top.frameTop.frames["conteudo"].location.href = doc;
}

function showDocHistory(doc) {
	if (top.frameTop.frames["conteudo"].location.href.substr(top.frameTop.conteudo.location.href.indexOf("?")) != doc.substr(doc.indexOf("?"))) { 
		loader(true);
	}
	top.frameTop.frames["conteudo"].location.href = doc;
	TabDoc();
}

function navigateResult(order, force) {
	loader(true);
	if (force) {
		top.frameTop.frames["conteudo"].location = "../eyebot.dll?nav=" + order + "&time=" + new Date().getTime() + "#highlight";
	} else {
		top.frameTop.frames["conteudo"].location = "eyebot.dll?nav=" + order + "&time=" + new Date().getTime() + "#highlight";
	}
}	


function navigatePages(order) {
	loader(true);
	TabDoc();
	top.frameTop.frames["conteudo"].location.href = "eyebot.dll?navPage=" + order + "&time=" + new Date().getTime() + "#highlight";
}

function navigatePagesControl(prior, next, complete) {
	try {
		top.frameTop.header.$("pagePrior").disabled = prior;
		top.frameTop.header.$("pageNext").disabled = next;
		top.frameTop.header.$("pageComplete").disabled = complete;
		if (prior) {
			top.frameTop.header.$("imgPagePrior").src = "images/anterior_16_off.gif";
			top.frameTop.header.$("imgPagePrior").style.cursor = "default";
		} else {
			top.frameTop.header.$("imgPagePrior").src = "images/anterior_16.gif";
			top.frameTop.header.$("imgPagePrior").style.cursor = "pointer";
		}
		if (next) {
			top.frameTop.header.$("imgPageNext").src = "images/posterior_16_off.gif";
			top.frameTop.header.$("imgPageNext").style.cursor = "default";
		} else {
			top.frameTop.header.$("imgPageNext").src = "images/posterior_16.gif";
			top.frameTop.header.$("imgPageNext").style.cursor = "pointer";
		}
		if (complete) {
			top.frameTop.header.$("imgComplete").src = "images/complete_16p_off.gif";
			top.frameTop.header.$("imgComplete").style.cursor = "default";
		} else {
			top.frameTop.header.$("imgComplete").src = "images/complete_16p.gif";
			top.frameTop.header.$("imgComplete").style.cursor = "pointer";
		}
	} catch(e) {
		//
	}	
}

function navigateControl(left, right, current, len) {
	try {		
		if (left) {
			top.frameTop.header.$("navFirst").disabled = false;
			top.frameTop.header.$("imgFirst").src = "images/achado_primeiro.gif";
			top.frameTop.header.$("imgFirst").style.cursor = "pointer";
			top.frameTop.header.$("navPrior").disabled = false;
			top.frameTop.header.$("imgPrior").src = "images/achado_anterior.gif";
			top.frameTop.header.$("imgPrior").style.cursor = "pointer";
			top.frameTop.resultado.$("navFirst").disabled = false;
			top.frameTop.resultado.$("imgFirst").src = "../images/achado_primeiro.gif";
			top.frameTop.resultado.$("imgFirst").style.cursor = "pointer";
			top.frameTop.resultado.$("navPrior").disabled = false;
			top.frameTop.resultado.$("imgPrior").src = "../images/achado_anterior.gif";
			top.frameTop.resultado.$("imgPrior").style.cursor = "pointer";
		} else {
			top.frameTop.header.$("navFirst").disabled = true;
			top.frameTop.header.$("imgFirst").src = "images/achado_primeiro_off.gif";
			top.frameTop.header.$("imgFirst").style.cursor = "default";
			top.frameTop.header.$("navPrior").disabled = true;
			top.frameTop.header.$("imgPrior").src = "images/achado_anterior_off.gif";
			top.frameTop.header.$("imgPrior").style.cursor = "default";
			top.frameTop.resultado.$("navFirst").disabled = true;
			top.frameTop.resultado.$("imgFirst").src = "../images/achado_primeiro_off.gif";
			top.frameTop.resultado.$("imgFirst").style.cursor = "default";
			top.frameTop.resultado.$("navPrior").disabled = true;
			top.frameTop.resultado.$("imgPrior").src = "../images/achado_anterior_off.gif";
			top.frameTop.resultado.$("imgPrior").style.cursor = "default";
		}
		if (right) {
			top.frameTop.header.$("navLast").disabled = false;
			top.frameTop.header.$("imgLast").src = "images/achado_ultimo.gif";
			top.frameTop.header.$("imgLast").style.cursor = "pointer";
			top.frameTop.header.$("navNext").disabled = false;
			top.frameTop.header.$("imgNext").src = "images/achado_posterior.gif";
			top.frameTop.header.$("imgNext").style.cursor = "pointer";
			top.frameTop.resultado.$("navLast").disabled = false;
			top.frameTop.resultado.$("imgLast").src = "../images/achado_ultimo.gif";
			top.frameTop.resultado.$("imgLast").style.cursor = "pointer";
			top.frameTop.resultado.$("navNext").disabled = false;
			top.frameTop.resultado.$("imgNext").src = "../images/achado_posterior.gif";
			top.frameTop.resultado.$("imgNext").style.cursor = "pointer";
		} else {
			top.frameTop.header.$("navLast").disabled = true;
			top.frameTop.header.$("imgLast").src = "images/achado_ultimo_off.gif";
			top.frameTop.header.$("imgLast").style.cursor = "default";
			top.frameTop.header.$("navNext").disabled = true;
			top.frameTop.header.$("imgNext").src = "images/achado_posterior_off.gif";
			top.frameTop.header.$("imgNext").style.cursor = "default";
			top.frameTop.resultado.$("navLast").disabled = true;
			top.frameTop.resultado.$("imgLast").src = "../images/achado_ultimo_off.gif";
			top.frameTop.resultado.$("imgLast").style.cursor = "default";
			top.frameTop.resultado.$("navNext").disabled = true;
			top.frameTop.resultado.$("imgNext").src = "../images/achado_posterior_off.gif";
			top.frameTop.resultado.$("imgNext").style.cursor = "default";
		}

		top.frameTop.header.$("editSelectedResult").value = current;
		top.frameTop.header.$("editTotalResult").value = len;
		top.frameTop.header.$("editSelectedResult").maxLength = top.frameTop.header.$("editTotalResult").value.length;
		if (eval(len) > 0) {
			top.frameTop.header.$("editSelectedResult").style.color = "#666666";
			top.frameTop.header.$("editTotalResult").style.color = "#666666";
			top.frameTop.header.$("editResult").style.color = "#666666";
			top.frameTop.header.$("editSelectedResult").readOnly = false;
		} else {
			top.frameTop.header.$("editSelectedResult").style.color = "#CCCCCC";
			top.frameTop.header.$("editTotalResult").style.color = "#CCCCCC";
			top.frameTop.header.$("editResult").style.color = "#CCCCCC";
			top.frameTop.header.$("editSelectedResult").readOnly = true;
		}
	} catch(e) {
		//
	}
}

function goTo(page) {
	if ((page > eval(top.frameTop.header.$("editTotalResult").value)) || (page <= 0) || ("abcdefghijklmnopqrstuwxyz".indexOf(page) > -1) ) {
		alert("Digite um valor entre 1 e " + top.frameTop.header.$("editTotalResult").value);
		top.frameTop.header.$("editSelectedResult").value = "";
		top.frameTop.header.$("editSelectedResult").setFocus();
	} else {
		top.frameTop.frames["conteudo"].location.href = "eyebot.dll?resultid=" + page + "&time=" + new Date().getTime() + "#highlight";
	}
}

function validateNumbers() {
	if('0123456789'.indexOf(String.fromCharCode(event.keyCode)) == -1) {
		event.returnValue = false;
	}	
}

function loader(show) {
	if (show) {
		top.document.getElementById("loader").style.display = "block";
	} else {
		top.document.getElementById("loader").style.display = "none";
		//Usando a rotina de loader para garantir o scroll do highlight.
		try{
			top.frameTop.conteudo.document.getElementById("highlight").scrollIntoView();
		} catch(e){
			//	
		}
	}
}

function SyncTree(idNode) {
	try{
		if (navigator.appName.indexOf("Internet Explorer") != -1) {
			parent.menu.menu_tree.document.getElementById("flashTree").selectNode(idNode);
		} else {
			parent.menu.menu_tree.document.embeds['flashTreeFF'].selectNode(idNode);	
		}
	}
	catch(e){
		//
	}
}

function SyncLocator(baseId, PageId) {
	top.frameTop.frames['locator'].location = "eyebot.dll/synclocator?base=" + baseId + "&page=" + PageId + "&time=" + new Date().getTime();
}

function RefreshHistory(object) {
	//try{
	/*
		if (object) {
			if (navigator.appName.indexOf("Internet Explorer") != -1) {
				parent.document.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();
			} else {
				parent.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();
			}
		} else {
			if (navigator.appName.indexOf("Internet Explorer") != -1) {
				parent.document.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();
			} else {
				parent.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();					
			}
		}
	*/

	if (navigator.appName.indexOf("Internet Explorer") != -1) {
		parent.document.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();
	} else {
		parent.frames[1].$('menu_history').src = "eyebot.dll/history?" + new Date().getTime();					
	}

	
	//}
	//catch(e){
		//
	//}
}

function RefreshHistorySearch(object) {
	//try{
	/*	
		if (object) {
			if (navigator.appName.indexOf("Internet Explorer") != -1) {
				parent.document.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();			
			} else {
				parent.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();
			}
		} else {
		
			//if (parent.menu.$("area_pesquisas_efetuadas").style.display == "block") {
			
				if (navigator.appName.indexOf("Internet Explorer") != -1) {			
					parent.document.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();
				} else {
					parent.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();				
				}
			//}
		}
	*/		

	if (navigator.appName.indexOf("Internet Explorer") != -1) {			
		parent.document.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();
	} else {
		parent.frames[1].$('menu_pesquisas_efetuadas').src = "eyebot.dll/historysearch?" + new Date().getTime();				
	}

	
	//}
	//catch(e){
		//
	//}
}

function ManageSelection(baseId, pageId, checked) {
	try{
		if (checked) {
			AddSelection(baseId, pageId);	
		} else {
			parent.menu.$('menu_selection').src = "eyebot.dll/selection?base=" + baseId + "&del_id=" + pageId + "&" + new Date().getTime();
		}
		
	}
	catch(e){
		//
	}
}

function AddSelection(baseId, pageId) {
	try{
		parent.menu.$('menu_selection').src = "eyebot.dll/selection?base=" + baseId + "&add_id=" + pageId + "&" + new Date().getTime();		
	}
	catch(e){
		//
	}
}

function DelSelection(baseId, pageId) {
	try{
		document.location.href = "../eyebot.dll/selection?base=" + baseId + "&del_id=" + pageId + "&" + new Date().getTime();
		top.frameTop.conteudo.document.getElementById("select").checked = false;
	}
	catch(e){
		//
	}
}

function CheckSelected(check) {
	try{
		top.frameTop.conteudo.document.getElementById("select").checked = check;
	}
	catch(e){
		//
	}
}

function RefreshSelection(object) {
	try{
		if (object) {
			parent.document.frames['menu'].$('menu_selection').src = "eyebot.dll/selection?" + new Date().getTime();
		} else {
			if (parent.menu.$("area_selecionados").style.display == "block") {
				parent.document.frames['menu'].$('menu_selection').src = "eyebot.dll/selection?" + new Date().getTime();
			}
		}
	}
	catch(e){
		//
	}
}

function ClearSelection() {
	try{
		CheckSelected(false);
		parent.menu.$('menu_selection').src = "eyebot.dll/selection?clear=true&" + new Date().getTime();
	}
	catch(e){
		//
	}
}

function color(objeto) {
	if (objeto.className == "botao") {
		objeto.className = "botao_over";
	} 
}

function decolor(objeto) {
	if (objeto.className == "botao_over") {
		objeto.className = "botao";
	}
}

function menuDesliza(menu, force) {

	if (menu == 1) {
		if ($('area_pesquisas').style.display == 'block') {
			$('area_pesquisas').style.display = 'none';
			$('area_escape').style.display = 'block';
			
			$('bt_pesquisas').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'block';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';			
			$('area_selecionados').style.display = 'none';
			
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao_selected';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 2) {
		if ($('area_minhas_pesquisas').style.display == 'block') {
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_escape').style.display = 'block';
			
			$('bt_minhas_pesquisas').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'block';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';			
			$('area_selecionados').style.display = 'none';
			
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao_selected';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 3) {
		if ($('area_historico').style.display == 'block') {
			$('area_historico').style.display = 'none';
			$('area_escape').style.display = 'block';
			
			$('bt_historico').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'block';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';			
			$('area_selecionados').style.display = 'none';
			
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao_selected';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 4) {
		if ($('area_fontes').style.display == 'block' && !force) {

			$('area_fontes').style.display = 'none';
			$('area_escape').style.display = 'block';

			$('refreshTree').style.display = 'none';
			$('bt_fontes').className = 'botao';
			//$('bt_fontes').colSpan = '3';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';


			$('area_fontes').style.display = 'block';
			
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';
			$('area_selecionados').style.display = 'none';


			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = '';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao_selected';
			$('bt_fontes').colSpan = '1';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 5) {
		if ($('area_suporte').style.display == 'block') {
			$('area_suporte').style.display = 'none';
			$('area_escape').style.display = 'block';
		
			$('bt_suporte').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'block';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';
			$('area_selecionados').style.display = 'none';
			
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao_selected';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 6) {
		if ($('area_pesquisas_efetuadas').style.display == 'block') {
			$('area_pesquisas_efetuadas').style.display = 'none';
			$('area_escape').style.display = 'block';
		
			$('bt_pesquisas_efetuadas').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'block';
			$('area_selecionados').style.display = 'none';

			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao_selected';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	} else if (menu == 7) {
		if ($('area_selecionados').style.display == 'block') {
			$('area_selecionados').style.display = 'none';
			$('area_escape').style.display = 'block';
		
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('bt_selecionados').className = 'botao';
			//$('bt_selecionados').colSpan = '3';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';
			$('area_selecionados').style.display = 'block';

			/*
			$('showSelection').style.display = 'inline';
			$('clearSelection').style.display = 'inline';
			*/

			

			$('showSelection').style.display = '';
			$('clearSelection').style.display = '';			

			
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao_selected';
			//$('bt_selecionados').colSpan = '1';
		}
	} else if (menu == 8) {
		if ($('area_manual').style.display == 'block') {
			$('area_manual').style.display = 'none';
			$('area_escape').style.display = 'block';
		
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('bt_manual').className = 'botao';
		} else {
			$('area_pesquisas').style.display = 'none';
			$('area_minhas_pesquisas').style.display = 'none';
			$('area_historico').style.display = 'none';
			$('area_fontes').style.display = 'none';
			$('area_suporte').style.display = 'none';
			$('area_manual').style.display = 'block';
			$('area_escape').style.display = 'none';
			$('area_pesquisas_efetuadas').style.display = 'none';
			$('area_selecionados').style.display = 'none';
			
			$('showSelection').style.display = 'none';
			$('clearSelection').style.display = 'none';
			$('refreshTree').style.display = 'none';
			$('bt_pesquisas').className = 'botao';
			$('bt_minhas_pesquisas').className = 'botao';
			$('bt_historico').className = 'botao';
			$('bt_fontes').className = 'botao';
			$('bt_fontes').colSpan = '3';
			$('bt_suporte').className = 'botao';
			$('bt_manual').className = 'botao_selected';
			$('bt_pesquisas_efetuadas').className = 'botao';
			$('bt_selecionados').className = 'botao';
			$('bt_selecionados').colSpan = '3';
		}
	}	
}

function Slide(objeto) {
	if (objeto.id == "doc_bg") {
		top.frameTop.tabs.$("doc_left").className = "left_on";
		top.frameTop.tabs.$("doc_bg").className = "bg_on";
		top.frameTop.tabs.$("doc_right").className = "right_on";
		top.frameTop.tabs.$("res_left").className = "left";
		top.frameTop.tabs.$("res_bg").className = "bg";
		top.frameTop.tabs.$("res_right").className = "right";
		top.frameTop.tabs.$("docres_left").className = "left";
		top.frameTop.tabs.$("docres_bg").className = "bg";
		top.frameTop.tabs.$("docres_right").className = "right";
		top.frameTop.tabs.$("pesq_left").className = "left";
		top.frameTop.tabs.$("pesq_bg").className = "bg";
		top.frameTop.tabs.$("pesq_right").className = "right";
	} else if (objeto.id == "res_bg") {
		top.frameTop.tabs.$("doc_left").className = "left";
		top.frameTop.tabs.$("doc_bg").className = "bg";
		top.frameTop.tabs.$("doc_right").className = "right";
		top.frameTop.tabs.$("res_left").className = "left_on";
		top.frameTop.tabs.$("res_bg").className = "bg_on";
		top.frameTop.tabs.$("res_right").className = "right_on";
		top.frameTop.tabs.$("docres_left").className = "left";
		top.frameTop.tabs.$("docres_bg").className = "bg";
		top.frameTop.tabs.$("docres_right").className = "right";
		top.frameTop.tabs.$("pesq_left").className = "left";
		top.frameTop.tabs.$("pesq_bg").className = "bg";
		top.frameTop.tabs.$("pesq_right").className = "right";
	} else if (objeto.id == "docres_bg") {
		top.frameTop.tabs.$("doc_left").className = "left";
		top.frameTop.tabs.$("doc_bg").className = "bg";
		top.frameTop.tabs.$("doc_right").className = "right";
		top.frameTop.tabs.$("res_left").className = "left";
		top.frameTop.tabs.$("res_bg").className = "bg";
		top.frameTop.tabs.$("res_right").className = "right";
		top.frameTop.tabs.$("docres_left").className = "left_on";
		top.frameTop.tabs.$("docres_bg").className = "bg_on";
		top.frameTop.tabs.$("docres_right").className = "right_on";
		top.frameTop.tabs.$("pesq_left").className = "left";
		top.frameTop.tabs.$("pesq_bg").className = "bg";
		top.frameTop.tabs.$("pesq_right").className = "right";
	} else if (objeto.id == "pesq_bg") {
		top.frameTop.tabs.$("doc_left").className = "left";
		top.frameTop.tabs.$("doc_bg").className = "bg";
		top.frameTop.tabs.$("doc_right").className = "right";
		top.frameTop.tabs.$("res_left").className = "left";
		top.frameTop.tabs.$("res_bg").className = "bg";
		top.frameTop.tabs.$("res_right").className = "right";
		top.frameTop.tabs.$("docres_left").className = "left";
		top.frameTop.tabs.$("docres_bg").className = "bg";
		top.frameTop.tabs.$("docres_right").className = "right";
		top.frameTop.tabs.$("pesq_left").className = "left_on";
		top.frameTop.tabs.$("pesq_bg").className = "bg_on";
		top.frameTop.tabs.$("pesq_right").className = "right_on";
	}
}

function TabDoc(tab) {
	var local = top.frameTop.frames["conteudo"].location.href.substr(0, top.frameTop.frames["conteudo"].location.href.lastIndexOf("/")+1);

	Slide(top.frameTop.tabs.$("doc_bg"));
	
	if (top.frameTop.header.showLocator) {
		top.frameTop.$("frame2").rows = "125,6,*,0,0,22";
		top.frameTop.resizer_locator.$('show_h').style.display = "none";
		top.frameTop.resizer_locator.$('hide_h').style.display = "block";
	} else {
		top.frameTop.$("frame2").rows = "0,6,*,0,0,22";
		top.frameTop.resizer_locator.$('show_h').style.display = "block";
		top.frameTop.resizer_locator.$('hide_h').style.display = "none";
	}
	if (local.lastIndexOf("pesquisas/") > -1 && tab) {
		top.frameTop.conteudo.location.replace(local.replace("pesquisas/", "") + "eyebot.dll?selectedid=true");
	}
}

function TabDocResult(tab) {
	var local = top.frameTop.frames["conteudo"].location.href.substr(0, top.frameTop.frames["conteudo"].location.href.lastIndexOf("/")+1);
	Slide(top.frameTop.tabs.$("docres_bg"));
	if (top.frameTop.header.showLocator) {
		top.frameTop.$("frame2").rows = "125,6,*,6,30%,22";
		top.frameTop.resizer_locator.$('show_h').style.display = "none";
		top.frameTop.resizer_locator.$('hide_h').style.display = "block";
	} else {
		top.frameTop.$("frame2").rows = "0,6,*,6,30%,22";
		top.frameTop.resizer_locator.$('show_h').style.display = "block";
		top.frameTop.resizer_locator.$('hide_h').style.display = "none";
	}
	top.frameTop.resizer.$('show_h').style.display = "block";
	top.frameTop.resizer.$('hide_h').style.display = "none";
	if (top.frameTop.frames["conteudo"].location.href.lastIndexOf("pesquisas.asp") > -1 && tab) {
		//top.frameTop.conteudo.location.replace(top.frameTop.frames["conteudo"].location.href.replace("pesquisas/pesquisas.asp", "") + "eyebot.dll?selectedid=true");
		top.frameTop.conteudo.location = top.frameTop.frames["conteudo"].location.href.replace("pesquisas/pesquisas.asp", "") + "eyebot.dll?selectedid=true";
	} else if (local.lastIndexOf("pesquisas/") > -1 && tab) {
		//top.frameTop.conteudo.location.replace(local.replace("pesquisas/", "") + "eyebot.dll?selectedid=true");
		top.frameTop.conteudo.location = local.replace("pesquisas/", "") + "eyebot.dll?selectedid=true";
	}
}

function TabResult() {
	Slide(top.frameTop.tabs.$("res_bg"));
	top.frameTop.$("frame2").rows = "0,0,0,0,*,22";
}

function TabPesquisa(id, execute) {
	// Se execute = true -> abre o form preenchendo os campos e executa a pesquisa
	if (!execute) execute = false;
	var local = document.URL;
	local = local.replace("menu/menu_minhas_pesquisas.asp", "");
	local = local.replace(/\?id_del=\d{1,}/, "");
	local = local.replace("menu/menu_pesquisas.asp", "");
	local = local.replace("header.asp", "");
	local = local.replace("tabs.asp", "");
	local = local.replace("home.asp", "");
	Slide(top.frameTop.tabs.$("pesq_bg"));
	if (id) {
		//top.frameTop.conteudo.location.replace(local + "pesquisas/pesquisas.asp?execute=" + execute + "&id=" + id);
		//top.frameTop.conteudo.src = local + "pesquisas/pesquisas.asp?execute=" + execute + "&id=" + id;
		top.frameTop.conteudo.location = local + "pesquisas/pesquisas.asp?execute=" + execute + "&id=" + id;
	} else {
		//top.frameTop.conteudo.location.replace(local + "pesquisas/pesquisas.asp");
		//top.frameTop.conteudo.src = local + "pesquisas/pesquisas.asp";
		top.frameTop.conteudo.location = local + "pesquisas/pesquisas.asp";
	}
	top.frameTop.$("frame2").rows = "0,0,*,0,0,22";
}


function TabPesquisaHistorySearch(formulario, conteudo, execute) {
	// Se execute = true -> abre o form preenchendo os campos e executa a pesquisa
	if (!execute) execute = false;
	var local = document.URL;
	rExp = /eyebot.dll\/historysearch\?\d{1,}/;
	local = local.replace(rExp, "");
	Slide(top.frameTop.tabs.$("pesq_bg"));
	top.frameTop.conteudo.location.replace(local + "pesquisas/pesquisas.asp?execute=" + execute + "&id=" + formulario + "&conteudo=" + conteudo);
	top.frameTop.$("frame2").rows = "0,0,*,0,0,22";
}

function showHome() {
	Slide(top.frameTop.tabs.$("doc_bg"));
	top.frameTop.$("frame2").rows = "0,0,*,0,0,22";
	top.frameTop.conteudo.location.replace("home.asp");
}

function flashTreeView() {
	document.write('<object name="flashTree" id="flashTree" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="100%">');
	document.write('<param name="movie" value="Tree.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<embed src="Tree.swf" width="100%" height="100%" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
	document.write('</object>');
}

function linkAnchor(anchor) {
	document.location.href = "eyebot.dll?anchor=" + anchor;
}