
String.prototype.trim = function(){
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
} //String.trim


function submitform()
{
	if(critica()== true)
	{
		document.formcontato.submit();
	}
}

function retornform()
{
	if(critica()== true)
	{
		document.formcontato.retorn();
	}
}

function resetform()
{
document.formcontato.reset();
}

function critica()
{
	if ((document.formcontato.fm_nome_requerente.value)=="")
	{
		alert("Por favor, é necessário o preenchimento do campo Nome");
		document.formcontato.fm_nome_requerente.focus();
		return false;
	}
	
		var valid = true;
	
		for (i = 0; i < document.formcontato.fm_nome_requerente.value.length; i++){
		
			ch = document.formcontato.fm_nome_requerente.value.charAt(i).toLowerCase();
			if ((ch < 'a' || ch > 'z') && ch != " ")
				valid = false;
		}

		if (!valid) {
			alert("Só digite letras (sem acentos) no campo \" Nome : \" !");
			document.formcontato.fm_nome_requerente.focus();
			return false;
		}

	if ((document.formcontato.fm_mail_requerente.value)=="") {
		alert("Por favor, é necessário o preenchimento do campo E-mail")
		document.formcontato.fm_mail_requerente.focus();
		return false;
	}

		if (document.formcontato.fm_mail_requerente.value.length <= 0) {
		alert("Por favor, é necessário o preenchimento do campo E-mail")
		document.formcontato.fm_mail_requerente.focus();
		return false;
		}
		
		if ((document.formcontato.fm_mail_requerente.value.indexOf("@") == -1)) {
			alert ("Este não é um endereço de e-mail válido!");
			document.formcontato.fm_mail_requerente.focus();
			return false;
	   }
	
		if ((document.formcontato.fm_mail_requerente.value.indexOf(".") == -1)) {
		 alert ("Este não é um endereço de e-mail válido!");
		 document.formcontato.fm_mail_requerente.focus();
		 return false;
		}
	
	if ((document.formcontato.fm_mail2_requerente.value)=="") {
		alert("Por favor, é necessário a confirmação do e-mail")
		document.formcontato.fm_mail2_requerente.focus();
		return false;
	}

		if (document.formcontato.fm_mail2_requerente.value.length <= 0) {
		alert("Por favor, é necessário a confirmação do e-mail")
		document.formcontato.fm_mail2_requerente.focus();
		return false;
		}
		
		if ((document.formcontato.fm_mail2_requerente.value.indexOf("@") == -1)) {
			alert ("Este não é um endereço de e-mail válido!");
			document.formcontato.fm_mail2_requerente.focus();
			return false;
	   }
	
		if ((document.formcontato.fm_mail2_requerente.value.indexOf(".") == -1)) {
		 alert ("Este não é um endereço de e-mail válido!");
		 document.formcontato.fm_mail2_requerente.focus();
		 return false;
		}
	
	if((document.formcontato.fm_mail_requerente.value) != (document.formcontato.fm_mail2_requerente.value)) {
		alert ("Email não confere!");
		document.formcontato.fm_mail2_requerente.focus();
		return false;
	}
	
	if ((document.formcontato.fm_descricao.value)=="")
	{
		alert("Por favor, é necessário o preenchimento do campo Mensagem");
		document.formcontato.fm_descricao.focus();
		return false;
	}
return true;
}

/*function limpabusca() {
	
	if(document.formbusca.busca.value=="digite aqui") {
		document.formbusca.busca.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_tema.value=="digite aqui") {
		document.formbusca_noticias.fm_localizar_tema.value="";
		return false;
	}
	return true;
}*/

function limpabusca_noticias() {
	
	if(document.formbusca_noticias.fm_localizar_tema.value=="digite aqui") {
		document.formbusca_noticias.fm_localizar_tema.value="";
		return false;
	}
	
	if(document.formbusca_noticias.fm_localizar_tema.value=="digite aqui") {
		document.formbusca_noticias.fm_localizar_tema.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_de_dia.value=="d") {
		document.formbusca_noticias.fm_localizar_de_dia.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_de_mes.value=="m") {
		document.formbusca_noticias.fm_localizar_de_mes.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_de_ano.value=="a") {
		document.formbusca_noticias.fm_localizar_de_ano.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_ate_dia.value=="d") {
		document.formbusca_noticias.fm_localizar_ate_dia.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_ate_mes.value=="m") {
		document.formbusca_noticias.fm_localizar_ate_mes.value="";
		return false;
	}
	if(document.formbusca_noticias.fm_localizar_ate_ano.value=="a") {
		document.formbusca_noticias.fm_localizar_ate_ano.value="";
		return false;
	}
	return true; 
}

function UsaEnterBusca_noticias(evento){
	if (evento.keyCode == 13){
	document.formbusca_noticias.submit()
	}
}

function UsaEnterBusca_noticiasAntigas(evento){
	if (evento.keyCode == 13){
	document.formbusca_noticiasAntiga.submit()
	}
}

/*-----------------------------------------------------------------------------
AUTOR: Raphael vitor <sun.raphael@gmail.com> | 22/05/2007 10:04
DESCRIÇÃO: Função que valida o campo de busca, não permitindo caracteres especiais e a ausencia de caracteres.
*/
function submitBusca()
{
	//if(validaBuscaGeral()== true)
	//{
		document.formbusca.submit();
	//}
}
/*Faz limpeza de strings. Utilizada pela função de validação de campos obrigatorios 
function limparstring(field)
   {
   while (field.search(" ")!=-1){
   field=field.replace(" ","");
   }
   return(field2);
   }
  */
   
function validaBuscaGeral(field)
{
 
 var valid = "abcdefghijklmnopqrstuvxzwy0123456789?! ";
 var ok = "yes";
 var temp;
 var espaco = field.value.trim();
 
 /*for (var i=0; i<field.value.length; i++) {
 temp = " " + field.value.substring(i, i+1).toLowerCase();
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {
    field.style.backgroundColor="#FFFFCC";    
    document.write("Só digite letras, sem acentos e caracteres especiais.");
    field.value='';    
   }*/
  
}

/*Funcao nao funciona no firefox
chamada = UsaEnterBusca(this)
function UsaEnterBusca()
{
	if (window.event.keyCode == 13)
	{
    	event.returnValue=false; 
    	event.cancel = true;
		submitBusca();
	}
	return true; 
}*/

//chamada = UsaEnterBusca(event)
function UsaEnterBusca(evento){
	if (evento.keyCode == 13){
	submitBusca();
	}
}

/*-----------------------------------------------------------------------------------------------------------------*/

/*function Mudar(opt){
	if(opt == 11){
		document.getElementById(FGTS).style.display = "inline";
	}
	else{
		document.getElementById(FGTS).style.display = "none";
	}
}*/

/*-----------------------------------------------------------------------------
AUTOR: Eduardo Gonçalves <edugsdf@gmail.com> | 22/11/2006 17:04
DESCRIÇÃO: Função que limpa um campo, com base em sua referencia:
           Exemplo: onfocus="fLimparCampo(this)" 
*/
function fLimparCampo(objCampo){
	objCampo.value = '';
}