function numerico(e){
	if (document.all)
		var tecla = event.keyCode;
	else 
		var tecla = e.which;	
	if(tecla == 0)
		return true;		
	var caractere = String.fromCharCode(tecla);	
	var strValidos = "0123456789";
	if (strValidos.indexOf(caractere) == -1 )
		return false;
	return true;
}


function enviaContato()
{	
	//NOME
	var campo = $("#txtNome");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Nome'</b>.");
		campo.focus();
		return false;
	}			
	
	//EMAIL
	var campo = $("#txtEmail");
	if(campo.val() != "")
	{
		if(!validaEmail(campo.val()))
		{
			msgErro("E-mail inválido.");		
			campo.focus();
			return false;
		}
	}
	else
	{
		msgErro("Preencha o campo <b>'E-mail'</b>.");
		campo.focus();
		return false;
	}
	
	//TELEFONE PARA CONTATO
	var campo = $("#txtTel");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Telefone para Contato'</b>.");
		campo.focus();
		return false;
	}
	
	//INSTITUIÇÃO
	var campo = $("#txtInst");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Instituição'</b>.");
		campo.focus();
		return false;
	}
	
	//NÚMERO DO CONTRATO
	var campo = $("#txtContrato");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Número do Contrato'</b>.");
		campo.focus();
		return false;
	}	

	//ASSUNTO
	var campo = $("#txtAssunto");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Assunto'</b>.");
		campo.focus();
		return false;
	}			

	//MENSAGEM
	var campo = $("#txtMensagem");
	if(campo.val() == "")
	{
		msgErro("Preencha o campo <b>'Mensagem'</b>.");
		campo.focus();
		return false;
	}

	$("#frmContato").submit();
}

function validaEmail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

function msgErro(msg){
	$("#msgValidaForm").html(msg);
	$("#msgValidaForm").show();
}
