
String.prototype.trim = function(){
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
} //String.trim

function nova_jan(newwindow)
   {
      var desktop = window.open(newwindow,'new_window','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes');
   }

/*function limpalegislacao() {
	
	if(document.formlegis.txtLegislacao.value=="palavra-chave") {
		document.formlegis.txtLegislacao.value="";
		return false;
	}
	return true;
}*/

/*
function Buscar(){
	with(document.formlegis){
		//var txtLegislacaoAux;
		
		if(txtLegislacao.value == ""){
			alert("Favor informar um critério para busca!");
			txtLegislacao.focus();
			return false;
		}
		
		//txtLegislacao = txtLegislacao.value;
		//txthidden = "legislacao";
	
		//action = "auxBuscaAvancada.asp?Query="+txtLegislacao+"&Query="+txtLegislacao

		//action = "/geral/busca/auxBuscaAvancada.asp?Query=" + document.formlegis.legislacao.value + "txtLegislacao=" + document.formlegis.txtLegislacao.value;	
		//submit();
	}
}
*/

function submitform()
{
	if(critica()== true)
	{
		document.formlegis.submit();
	}
}

function retornform()
{
	if(critica()== true)
	{
		document.formlegis.retorn();
	}
}

function FormatarValor(){
	if ( (window.event.keyCode >= 45) && (window.event.keyCode <= 57) ){
		return(true)
	}else{
		window.event.keyCode = 0;
		return(false);
	}
}
//--------------------------------------------------------------------------
function Help(estilo,obj,Posicaoleft, Posicaotop,txt)
{
	if(!obj.readOnly)
	{
	obj.style.backgroundColor = "#FEF2C2";
	
	document.getElementById("Help").style.left = Posicaoleft;
	document.getElementById("Help").style.top = Posicaotop;

	switch(estilo)
	{
		case 1:
				document.getElementById("Help2").style.left = Posicaoleft - 7;
				document.getElementById("Help2").style.top = Posicaotop + 5;
				break;
		case 2:
				document.getElementById("Help3").style.left = Posicaoleft + 5;
				document.getElementById("Help3").style.top = Posicaotop - 7;
				break;
		case 3:
				document.getElementById("Help3").style.left = Posicaoleft + 173;
				document.getElementById("Help3").style.top = Posicaotop - 7;
				break;
		
		case 4:
				document.getElementById("Help4").style.left = Posicaoleft + 188;
				document.getElementById("Help4").style.top = Posicaotop + 5;
				break;
				
		case 5:
				document.getElementById("Help5").style.left = Posicaoleft + 173;
				document.getElementById("Help5").style.top = Posicaotop + 91;
				break;
	}
	
	
	texto = txt;
										
	document.getElementById("TextoHelp").innerHTML = texto;
	document.getElementById("Help").style.display = "inline";
	
	if (estilo == 1) {
		document.getElementById("Help2").style.display ="inline";
	}
	else if (estilo == 4) {
		document.getElementById("Help4").style.display ="inline";
	}
	else if (estilo == 5) {
		document.getElementById("Help5").style.display ="inline";
	}
	else {
		document.getElementById("Help3").style.display ="inline";
	}
	}
}
function RetiraAcentos(Campo) {
   var Acentos = "áàãââÁÀÃÂéêÉÊíÍóõôÓÔÕúüÚÜçÇabcdefghijklmnopqrstuvxwyz";
   var Traducao ="AAAAAAAAAEEEEIIOOOOOOUUUUCCABCDEFGHIJKLMNOPQRSTUVXWYZ";
   var Posic, Carac;
   var TempLog = "";
   for (var i=0; i < Campo.length; i++)
   {
   Carac = Campo.charAt (i);
   Posic  = Acentos.indexOf (Carac);
   if (Posic > -1)
	  TempLog += Traducao.charAt (Posic);
   else
      TempLog += Campo.charAt (i);
   }
      return (TempLog);
}
//
// No form tem que incluir a seguinte linha
// <INPUT onblur="document.formulario.nomecampo.value = RetiraAcentos(document.formulario.nomecampo.value)" title="Informe o nome, sem acentos.&#13;&#10;Mas se vc colocar acentos, o input não aceitará..." maxLength=60 size=40 name=nomecampo>
//

													
					
function RetirarHelp(obj)
{
	if(!obj.readOnly)
	{
		obj.style.backgroundColor = "";
		document.getElementById("Help").style.display = "none";
		document.getElementById("Help2").style.display ="none";
		document.getElementById("Help3").style.display ="none";
		document.getElementById("Help4").style.display ="none";	
		document.getElementById("Help5").style.display ="none";
	}
}

function LinkTema(lnk){
	location.href(lnk);
}

function Buscar(){
	
	with(document.formlegis){
		//var txtLegislacaoAux;
		validaTamanho = txtLegislacao.value.length;
		if(validaTamanho <= 1){
			alert("Favor informar um critério para busca!");
			txtLegislacao.focus();
			return false;
		}
				
	
		//txtLegislacaoAux = txtLegislacao.value;
		//txthidden = "legislacao";
	
		//action = "auxBuscaAvancada.asp?Query="+txtLegislacao+"&Query="+txtLegislacao

		action = "/geral/busca/auxBuscaAvancada.asp?Query=" + document.formlegis.legislacao.value + "&txtLegislacao=" + document.formlegis.txtLegislacao.value;	
		submit();
	}
}

function UsaEnterBusca_legis(evento){
	if (evento.keyCode == 13){
	Buscar();
	}
}
