        function FormataData(objeto,teclapress) 
{ 
    var tecla = teclapress.keyCode; 

    //Testa se o campo está selecionado, se estiver, limpa o conteúdo para nova digitação. 
    var selecionado = document.selection.createRange();  
    var selecao        = selecionado.text;  
    if((selecao != "") && (tecla != 8) && (tecla != 9) && (tecla != 13) && (tecla != 35) && (tecla != 36) && (tecla != 46) && (tecla != 16) && (tecla != 17) && (tecla != 18) && (tecla != 20) && (tecla != 27) && (tecla != 37) && (tecla != 38) && (tecla != 39) && (tecla != 40)) {objeto.value = "";} 


    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )&& objeto.value.length < (10)) 
    { 
        vr = objeto.value; 
        vr = vr.replace( "/", "" ); 
        vr = vr.replace( "/", "" ); 
        tam = vr.length; 

        if (tam < 8) 
            { 
                if (tecla != 8) {tam = vr.length + 1 ;} 
            } 
        else 
            { 
                window.event.cancelBubble = true; 
                window.event.returnValue = false; 
            } 
         
        if ((tecla == 8) && (tam > 1)) 
            { 
                tam = tam - 1 ; 
                objeto.value = vr.substr(0,tam); 
                window.event.cancelBubble = true; 
                window.event.returnValue = false; 
            } 
                if ( tam <= 4 && tecla != 8){  
                     objeto.value = vr ; } 

                if ( (tam >= 4) && (tam <= 6) ){ 
                     objeto.value = vr.substr(0, tam - 4) + '/' + vr.substr( tam - 4, 4 ); } 

                if ( (tam >= 6) && (tam <= 8) ){ 
                    objeto.value = vr.substr(0, tam - 6 ) + '/' + vr.substr( tam - 6, 2 ) + '/' + vr.substr( tam - 4, 4 ); } 

                if ((tam == (8)) && tecla != 8) 
                    { 
                        if(tecla >=96 && tecla <=105) 
                            { 
                                tecla = tecla - 48; 
                            } 

                        objeto.value = objeto.value + (String.fromCharCode(tecla)); 
                        window.event.cancelBubble = true; 
                        window.event.returnValue = false; 

                        
                    } 
    } 
    else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46)) 
        { 
            event.returnValue = false; 
        } 
} 

function numerico(campo) {  

// Foi usado como referência o Script do DzaiaCuck, Valew! 

campo.value = campo.value.toLowerCase();  

var caracteres = "abcdefghijklmnopqrstuvwxyzáéíóúàèìòùâêîôûäëïöüãõ@#$%^&*()_+=~` ç.\[]{}<>?!|:;,";  
var retorno  = "";  

for(i=0;i<caracteres.length;i++)  
   {  
     
   for(j=0;j<campo.value.length;j++)  
      {  
      retorno = campo.value.replace(caracteres.substr(i,1),"");  
      campo.value = retorno;  
      }  
   }  

    
}  


function recebe_comentario(nome,valor)
{

  var theDD = eval(document.form.comentario); 
  var newOption; 
  var newDialog; 
  var name; 
  var value; 
   newDialog = nome +" - "+ valor;
   if ( (newDialog == ' ') || (newDialog == null)) 
  { 
   return false; 
  } 

name = newDialog.toUpperCase(); 
  value = newDialog.toUpperCase(); 
  newOption= new Option (name,value); 
  var insertAt = theDD.options.length; 
  theDD.options.length=theDD.options.length + 1; 
  theDD.options[insertAt] = newOption; 
 
 }
function valida_atend() {
var codigo = document.form.codigo.value;
 if (codigo!="") {
   if (codigo.indexOf("/") < 0) {
   alert("O campo código deve conter o seguinte formato 1234/2006.");
   document.form.codigo.focus();
   return false;
   }
  }
}


function mascaraCep(objeto)
{
   if (objeto.value.indexOf("-") == -1 && objeto.value.length > 5){ objeto.value = ""; }
       if (objeto.value.length == 5)
        {
		objeto.value += "-";
	}
      
}


function validaFormBranco(formName, elementos) 
{
  var items, erro, x;
      erro = false;
	  formulario = eval("document."+formName);

    with(formulario) 
	{
	  items = elementos.split(",");
      for(x=0;x<=items.length-1;x++) 
	  {
	    if(eval(items[x]+".value == ''")) 
		{
	      alert("Preencha o campo " + eval(items[x]+".id")+"\nFill out the field "+eval(items[x]+".id"));
	      eval(items[x]+".focus()");
	      erro = true
	      break;
		}
	  }
	}
	return (!erro ? true : false);
}

function validaNum(tecla)
{
  var num, except, x, achou;
	  achou = false;
	  num = new Array(48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,
	  				  101,102,103,104,105,35,36,45,46,16,37,38,39,40,8,9);
	  for(x=0;x<=num.length-1;x++)
	  {
	    if(tecla == num[x]) achou = true;
	  }
	  return (achou ? true : false);
}

function validaEmail(email)
{
  var mail = email;
  if ((mail.indexOf("@") < 0) || (mail.indexOf(".") < 0) || (mail.indexOf(" ") >= 0) || (mail.length < 7))
  {
	alert("O campo email deve ser conter apenas um endereco eletrônico!");
	return(false);
  }
  else
    return(true);
}

//-----------------------------------------------------------------------------------------------------------------------
function validaTecla(tecla)
{
	var codigos, x;
	var splitCode;
	var existe;
	
	existe = false;
	
	//Valores de 0 a 9
	codigos =  "48,49,50,51,52,53,54,55,56,57,"
	codigos += "96,97,98,99,100,101,102,103,104,105,";
	//Teclas de controle (backspace / tab / del / esquerda / direita)
	codigos += "8,9,46,37,39,";

	//Mouse 	
	codigos +=  "0";

	//Separa os caracteres pela virgula
	splitCode = codigos.split(",");
	
	//Varre o vetor para comprar os codigos de tecla
	for(x=0;x<=splitCode.length;x++) 
	{
		if (tecla == parseInt(splitCode[x])) existe = true
	}
	
	return existe;
}

function avaliaData(campo)
{
	var data;
	var ano, mes, dia, maxDia;
	var retorno;
	
	data = campo.value.split("/");
	
	if (data.length == 3) {
		dia = parseInt(data[0],10);
		mes = parseInt(data[1],10);
		ano = parseInt(data[2],10);
	
		retorno = true;
	
		switch(mes){
			case 1 : maxDia = 31; break;
			case 2 : if(ano % 4 == 0)
						 maxDia = 29
					 else
						 maxDia = 28;
					 break;
			case 3 : maxDia = 31; break;
			case 4 : maxDia = 30; break;
			case 5 : maxDia = 31; break;
			case 6 : maxDia = 30; break;
			case 7 : maxDia = 31; break;
			case 8 : maxDia = 31; break;
			case 9 : maxDia = 30; break;
			case 10 : maxDia = 31; break;
			case 11 : maxDia = 30; break;
			case 12 : maxDia = 31; break;
		}
		
		if (dia > maxDia || dia <= 0) retorno = false;
		else if (mes > 12 || mes <= 0) 	retorno = false;
		else if (ano <= 0 || ano < 1900 || ano > 2100) 	retorno = false;
		// Validação para o campo data da ocorrência
		else if (mes < 06 && ano <= 2003) retorno = false; 
		else if (ano < 2003) retorno = false;
			
		
	}
	
	return retorno
	
}



function validaHora(tecla, campo)
{
	var retorno;
	var count;
	
	retorno = false;
	count = 0;

	//Se passou na validacao das teclas
	if (validaTecla(tecla)) 
	{
		count = campo.value.length;
		//Se tecla for diferente de tab ou do Mouse
		if (tecla != 9 && tecla != 0)	
		{
			//Se tecla for diferente de backspace
			if (tecla != 8)
			{
				switch(count)
				{
					case 2 : campo.value += ":";
							  break;
				}
			}
		} 
		//Se tab for pressionado ...
	} 
	else 
		return retorno;  
}

function validaMoeda(tecla, campo)
{
	var retorno;
	var count;
	var splt;
	
	retorno = false;
	count = 0;

	//Se passou na validacao das teclas
	if (validaTecla(tecla)) 
	{
		count = campo.value.length;
		
		if(campo.value.indexOf(",") < 0 || campo.value == "") 
			campo.value = "0,0" + campo.value;
		else 
		{
		
			//Se tecla for diferente de tab ou do Mouse
			if (tecla != 9 && tecla != 0)	
			{
				//Se tecla for diferente de backspace
				if (tecla != 8 && tecla != 9 && tecla != 46 && tecla != 37 && tecla !=39)
				{
					//campo.value += "0,0";
					splt = campo.value.split(",");
					splt[0] = splt[0] + splt[1].substring(0,1);
					splt[0] = parseInt(splt[0]);
					splt[1] = splt[1].substring(1,splt[1].length)
	
					if(splt[1].length < 2) splt[1] = splt[1] + "0";

					campo.value = splt[0] + "," + splt[1];
				}
			} 
		}
	} 
	
	else return retorno;  
}

function validaMoeda2(tecla, campo, numdigitos)
{
	var retorno;
	var count;
	var splt;
	var valor;
	
	retorno = false;
	count = 0;

	//Se passou na validacao das teclas
	if (validaTecla(tecla)) 
	{
		count = campo.value.length;
		
		if(campo.value.indexOf(",") < 0 || campo.value == "") 
		{
			valor = campo.value
			campo.value = "0,";
			for(x=1;x<=numdigitos;x++)
				campo.value += "0";
				
			campo.value += valor;
		}
		else 
		{
			//Se tecla for diferente de tab ou do Mouse
			if (tecla != 9 && tecla != 0)	
			{
				//Se tecla for diferente de backspace
				if (tecla != 8 && tecla != 9 && tecla != 46 && tecla != 37 && tecla !=39)
				{
					//campo.value += "0,0";
					splt = campo.value.split(",");
					splt[0] = splt[0] + splt[1].substring(0,1);
					splt[0] = parseInt(splt[0]);
					splt[1] = splt[1].substring(1,splt[1].length)

					if(splt[1].length < numdigitos)
					   for(x=0;x=(numdigitos-splt[1].length);x++) 
					   {
						  splt[1] = splt[1] + "0";
					   }

					campo.value = splt[0] + "," + splt[1];
				}
			} 
		}
	} 
	
	else return retorno;  
}

// Separa o total de horas com :
function validaHoras(tecla, campo)
{
	var retorno;
	var count;
	var splt;
	
	retorno = false;
	count = 0;

	//Se passou na validacao das teclas
	if (validaTecla(tecla)) 
	{
		count = campo.value.length;
		
		if(campo.value.indexOf(":") < 0 || campo.value == "") 
			campo.value = "0:0" + campo.value;
		else 
		{
		
			//Se tecla for diferente de tab ou do Mouse
			if (tecla != 9 && tecla != 0)	
			{
				//Se tecla for diferente de backspace
				if (tecla != 8 && tecla != 9 && tecla != 46 && tecla != 37 && tecla !=39){
					//campo.value += "0,0";
					splt = campo.value.split(":");
					splt[0] = splt[0] + splt[1].substring(0,1);
					splt[0] = parseInt(splt[0]);
					splt[1] = splt[1].substring(1,splt[1].length)
	
					if(splt[1].length < 2) splt[1] = splt[1] + "0";

					campo.value = splt[0] + ":" + splt[1];
				}
			} 
		}
	} 
	
	else return retorno;  
}

function validaPeriodo()
{

var x,y;
var data , data2;
var temp = "";
var retorno = true;

  if (document.form.txtDataIni.value != "") 
  {

	data = document.form.txtDataIni.value.split("/")
	data2 = document.form.txtDataFim.value.split("/")
    x = ((data[2]) + "" + (data[1]) + "" + (data[0]))
    y = ((data2[2]) + "" + (data2[1]) + "" + (data2[0]))

    if (x > y) 
	{
		alert("Data 'De' deve ser menor ou igual que data 'Até'!")
		form.txtDataIni.value = ""
		form.txtDataIni.focus()
		retorno = false
    }
  }
  return retorno
}

function formatTime(hora) 
{
var temp = hora;

  tempSplt = temp.split(":");
  if(tempSplt.length>1) {
	  if(tempSplt[0]>23) tempSplt[0]="23";
	  if(tempSplt[1]>59) tempSplt[1]="59";
	  temp=tempSplt[0]+":"+tempSplt[1];
  }
  else temp="";

  return(temp);
}
  
function formatDate(data) 
{
  var temp = data;
  
  tempSplt = temp.split("/");
  if(tempSplt.length>2) 
  {
	  if(tempSplt[0]>31) tempSplt[0]="31";
	  if(tempSplt[1]>12) tempSplt[1]="12";
	  switch(parseInt(tempSplt[1])) 
	  {
		  case 1  : if(tempSplt[0]>31) tempSplt[0]=31; break;
		  case 2  : if((tempSplt[2] % 4)>0) 
		  			{
					    if(tempSplt[0]>28) 
					    { 
					        tempSplt[0]=28; 
					    }
					}
				    else 
					{
					    if(tempSplt[0]>29) 
					    { 
					        tempSplt[0]=29;  
					    }
					}
				    break;
		  case 3  : if(tempSplt[1]>31) tempSplt[0]=31; break;
		  case 4  : if(tempSplt[1]>30) tempSplt[0]=30; break;
		  case 5  : if(tempSplt[1]>31) tempSplt[0]=31; break;
		  case 6  : if(tempSplt[1]>30) tempSplt[0]=30; break;
		  case 7  : if(tempSplt[1]>31) tempSplt[0]=31; break;
		  case 8  : if(tempSplt[1]>31) tempSplt[0]=31; break;
		  case 9  : if(tempSplt[1]>30) tempSplt[0]=30; break;
		  case 10 : if(tempSplt[0]>31) tempSplt[0]=31; break;
		  case 11 : if(tempSplt[0]>30) tempSplt[0]=30; break;
		  case 12 : if(tempSplt[0]>31) tempSplt[0]=31; break;
	  }
	  temp=tempSplt[0]+"/"+tempSplt[1]+"/"+tempSplt[2]
  }
  else temp="";
  
  return(temp);
}
function abre_janela(width, height, nome) {
var top; var left;
top = ( (screen.height/2) - (height/2) )
left = ( (screen.width/2) - (width/2) )
window.open('',nome,'width='+width+',height='+height+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+left+',top='+top);
}

function ContaCaracteres_PP()
			{
			  intCaracteres = 100 - document.form.comentario.value.length;
			  if (intCaracteres > 0) {
			    document.form.contador.value = intCaracteres;
			    return true;
			  } else {
			    document.form.contador.value = 0;
			    document.form.comentario.value = document.form.comentario.value.substr(0,100)
				//alert("A mensagem digitada ultrapassou o limite de 100 posições." + "\r" + "As palavras que ultrapassaram o limite serão retiradas.");
			    return false;
			  }
			} 
			

function mascara_hora(hora){ 
    var myhora = ''; 
   myhora = myhora + hora; 
   if (myhora.length == 2){ 
     myhora = myhora + ':'; 
    document.forms[0].hora.value = myhora; 
     } 
   if (myhora.length == 5){ 
    verifica_hora(); 
      } 
  } 
           
 function verifica_hora(){ 
    hrs = (document.forms[0].hora.value.substring(0,2)); 
   min = (document.forms[0].hora.value.substring(3,5)); 
                     
    situacao = ""; 
// verifica data e hora 
   if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59)){ 
      situacao = "falsa"; 
  } 
               
   if (document.forms[0].hora.value == "") { 
      situacao = "falsa"; 
 } 

   if (situacao == "falsa") { 
     alert("Hora inválida!"); 
     document.forms[0].hora.focus(); 
  } 
 } 
 
 function mascara_data(data){ 
var mydata = ''; 
mydata = mydata + data; 
if (mydata.length == 2){ 
mydata = mydata + '/'; 
} 
if (mydata.length == 5){ 
mydata = mydata + '/'; 
} 
return mydata; 
} 
function verifica_data(data) { 
if (data.value != "") {
dia = (data.value.substring(0,2));
mes = (data.value.substring(3,5)); 
ano = (data.value.substring(6,10)); 
situacao = ""; 
if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
situacao = "falsa"; 
} 
if (mes < 01 || mes > 12 ) { 
situacao = "falsa"; 
}
if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
situacao = "falsa"; 
} 
if (situacao == "falsa") { 
data.focus();
data.select();
alert("Data inválida! Por favor digite a data no formato dd/mm/aaaa."); 
}
} 
}

function checa_numerico(String) {
var mensagem = "Este campo aceita somente números"
var msg = "";
if (isNaN(String)) msg = mensagem;
return msg;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function confirmSubmit(msg)
{
var mensagem = msg;
var agree=confirm(mensagem);
if (agree)
	return true ;
else
	return false ;
}
function teste1 (param)
{
var temp = param;
alert (temp);
}

function confirma_p_cancelar(msg,relato)
{
var mensagem = msg;

var agree=confirm(mensagem);
if (agree)
	 window.open('include/inc_p_cancelar.php?relato='+relato+'', 'Relato', 'width=10, height=10, scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=400');
else
	return false ;
}

function confirma_cancelar(msg,relato)
{
var mensagem = msg;

var agree=confirm(mensagem);
if (agree)
	 window.open('include/inc_cancelar.php?relato='+relato+'', 'Relato', 'width=10, height=10, scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=400');
else
	return false ;
}

//Validação do campo outros
function ValidaOutros (paramcampo,paramcampo2)
{
   var tempcampo  = paramcampo;
   var tempcampo2 = paramcampo2;
   if(tempcampo == "OUTROS" && tempcampo2 == "")
	 {
	 alert ("Campo outros obrigatório\n Obligator field other");
     document.form.txtTpRelatOutros.focus();
	 document.imgOutros.src = "img/bolinha.gif";					
	 }
   else
	return true;
}


// Apaga a data de ocorrência
function ApagaData (campo)
{
  campo.value = "";
  
}
//Validação para a data de ocorrência
function datainclusao(paramdata1,paramdata2)
{
   var data1 = paramdata1.split("/");
   var data2 = paramdata2.split("/");
   var ano1, mes1, dia1;   
   var ano2, mes2, dia2;
   
   
   dia1 = parseInt(data1[0],10);
   mes1 = parseInt(data1[1],10);
   ano1 = parseInt(data1[2],10);
	
   dia2 = parseInt(data2[0],10);
   mes2 = parseInt(data2[1],10);
   ano2 = parseInt(data2[2],10);
   
   
  
   if (mes1 <= mes2 && ano1 <= ano2 && dia1 < dia2) 
   {
    	  alert ("Data de ocorrência não pode ser posterior a data de inclusão.\n Date of occurrence cannot be posterior the date of inclusion.");
    	 document.form.txtDataOcorr.focus();
         document.form.txtDataOcorr.value = "";
		  
		  return(true);
          		  
   } 
   else
   if (ano1 <= ano2 && mes1 < mes2) 
   {
    	  alert ("Data de ocorrência não pode ser posterior a data de inclusão.\n Date of occurrence cannot be posterior the date of inclusion.");
    	 document.form.txtDataOcorr.focus();
         document.form.txtDataOcorr.value = "";
		  
		  return(true);
   } 
   else
   if (ano1 < ano2) 
   {
    	  alert ("Data de ocorrência não pode ser posterior a data de inclusão.\n Date of occurrence cannot be posterior the date of inclusion.");
         document.form.txtDataOcorr.focus();
         document.form.txtDataOcorr.value = "";
		  return(true);
   } 
     
  //alert ("A data está correta");  
 
  return(false);
}

//******************************************************************************************************************
function valida(formName)
{
    if(validaFormBranco(formName,"txtDataOcorr,txtHoraOcorr,cmbTipoRelat,txtRelato,cmbLocalOcorr,cmbOrigem,cmbTpResposta")) 
	{
		with(document.form)
		{
								
			// Inicio Validação do campo Tipo de resposta			
			if(cmbTpResposta.options[cmbTpResposta.selectedIndex].text == "E-MAIL")
			{
				if(validaFormBranco(formName,"txtEmail"))
					return(true);
				else
					return(false);
			}
			else if(cmbTpResposta.options[cmbTpResposta.selectedIndex].text == "CARTA")
			{
				if(cmbPais.options[cmbPais.selectedIndex].text == "BRASIL")
				{
					if(validaFormBranco(formName,"txtEndereco,cmbUF,cmbMunicipio"))
						
						return(true);
					else
						return(false);
				}
				else
				{
					if(validaFormBranco(formName,"txtEndereco,txtOutroMunicipio,"))
						return(true);
					else
						return(false);
				}
			}// Final Validação do campo Tipo de resposta
			else
					return(true);
		} 
	}
    else return(false);
} 
// Controla as imagens de * para validação menos do campo outros.

function setImg(value)
{
	
	document.imgEmail.src = "";
	document.imgEndereco.src = "";
	document.imgUF.src = "";
	document.imgMunicipio.src = "";
	document.imgOutroMunicipio.src = "";
	
	if(value == "CARTA")
	{
		if(document.form.cmbPais.options[document.form.cmbPais.selectedIndex].text == "BRASIL")
		{
			document.imgEndereco.src = "img/bolinha.gif";
			document.imgUF.src = "img/bolinha.gif";
			document.imgMunicipio.src = "img/bolinha.gif";
		}
		else
		{
			document.imgEndereco.src = "img/bolinha.gif";
			document.imgOutroMunicipio.src = "img/bolinha.gif";
		}
	}
	else if(value == "E-MAIL")
	{
		document.imgEmail.src = "img/bolinha.gif";
	}
		
	
}

<!--

//-->

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


    