function CriaVetor(n) {
	this.length=n;
	for (var x=1;x<=n;x++) {
		this[x]=""
		};
}

DataHoje = new Date();
MesVetor = new CriaVetor(12);
MesVetor[0]="janeiro";
MesVetor[1]="fevereiro";
MesVetor[2]="março";
MesVetor[3]="abril";
MesVetor[4]="maio";
MesVetor[5]="junho";
MesVetor[6]="julho";
MesVetor[7]="agosto";
MesVetor[8]="setembro";
MesVetor[9]="outubro";
MesVetor[10]="novembro";
MesVetor[11]="dezembro";
Mes = MesVetor[DataHoje.getMonth()];
Ano = DataHoje.getFullYear();
Dia = DataHoje.getDate();
DataCompleta = Dia + " de " + Mes + " de " + Ano;

// Valida o form de entrada do curriculo
function validaEntrada(){
	if (document.form.matricula.value == "") {
		window.alert("Campo matricula é obrigatório");
		document.form.matricula.focus();
		return false;
	}
	if (document.form.senha.value == "") {
		window.alert("Você deve digitar a sua Senha.");
		document.form.senha.focus();
		return false;
	}
	return true;
}

// Valida o form de esqueceu senha
function validaEsqueceu(){
	if (document.form.CPF.value == "") {
		window.alert("Campo CPF é obrigatório");
		document.form.CPF.focus();
		return false;
	} else {
		strAux = document.form.CPF.value;
		if (!verificaCPF(strAux)) {
			window.alert("CPF com formato invalido.");
			document.form.CPF.focus();
			return false;
		}
	}
	return true;
}

// Valida o form de cadastro inicial
function validaCadastro(){
	if (document.form.CPF.value == "") {
		window.alert("Campo CPF é obrigatório.");
		document.form.CPF.focus();
		return false;
	} else {
		strAux = document.form.CPF.value;
		if (!verificaCPF(strAux)) {
			window.alert("CPF com formato invalido.");
			document.form.CPF.focus();
			return false;
		}
	}
	if (document.form.senha.value == "") {
		window.alert("Campo Senha é obrigatório.");
		document.form.senha.focus();
		return false;
	}
	if (document.form.senha2.value == "") {
		window.alert("Campo Confirmação de Senha é obrigatório.");
		document.form.senha2.focus();
		return false;
	}
	if (document.form.senha.value != document.form.senha2.value) {
		window.alert("O compo confirmação deve ser igual a senha.");
		document.form.senha2.focus();
		return false;
	}
	if (document.form.lembrete.value == "") {
		window.alert("Campo Lembrete de Senha é obrigatório.");
		document.form.lembrete.focus();
		return false;
	}
	return true;
}

// Validação da pagina de Dados Pessoais
function validaPessoal(f){
	if (f.nome.value == "" || f.nome.value.length < 1){
		alert('Campo Nome é obrigatório.');
		f.nome.focus();
		return false;
	}
	if (f.dataNascimento.value == "" || f.dataNascimento.value.length < 1){
		alert('Campo Data de Nascimento é obrigatório.');
		f.dataNascimento.focus();
		return false;
	}
	if (f.rg.value == "" || f.rg.value.length < 1){
		alert('Campo Identidade é obrigatório.');
		f.rg.focus();
		return false;
	}
	if (f.orgao.value == "" || f.orgao.value.length < 1){
		alert('Campo Órgão Expedidor é obrigatório.');
		f.orgao.focus();
		return false;
	}
	if (f.endereco.value == "" || f.endereco.value.length < 1){
		alert('Campo Endereço Residencial é obrigatório.');
		f.endereco.focus();
		return false;
	}
	if (f.bairro.value == "" || f.bairro.value.length < 1){
		alert('Campo Bairro é obrigatório.');
		f.bairro.focus();
		return false;
	}
	if (f.cidade.value == "" || f.cidade.value.length < 1){
		alert('Campo Cidade é obrigatório.');
		f.cidade.focus();
		return false;
	}
	idx = f.uf.options.selectedIndex;
	estado = f.uf.options[idx].value;
	if (estado == ""){
		alert("Selecione a UF.");
		f.uf.focus();
		return false;
	}
	if (f.dddTelefone.value == "") {
		alert("Campo DDD é obrigatório.");
		f.dddTelefone.focus();
		return false;
	}else{
		if (document.form.dddTelefone.value.length < 2){
			alert("DDD com formato inválido.");
			f.dddTelefone.focus();
			return false;
		}
	}
	if (f.telefone.value == "") {
		alert("Campo Telefone é obrigatório.");
		f.telefone.focus();
		return false;
	}else{
		if (f.telefone.value.length < 7){
			alert("Telefone com formato inválido.");
			f.telefone.focus();
			return false;
		}
	}
	if (f.email.value == "") {
		alert("Campo E-mail é obrigatório.");
		f.email.focus();
		return false;
	}else{
		if (!verificaEmail(f.email.value)){
			alert("E-mail com formato inválido.");
			f.email.focus();
			return false;
		}
	}
	return true;
}

// Validações da pagina de Área de Interesse
function validaInteresse(f){
	acao = document.form.Acao.value;
	if (acao == "Incluir"){
		idx = f.area.option.selectedIndex;
		if (f.area.option[idx].value == ""){
			alert("Selecione uma Área de Interesse.");
			f.area.focus();
			return false;
		}
		idx = f.subArea.option.selectedIndex;
		if (f.subArea.option[idx].value == ""){
			alert("Selecione um Segmento de Interesse.");
			f.subArea.focus();
			return false;
		}
	}
	if (acao == "Alterar"){
		idx = f.area.option.selectedIndex;
		if (f.area.option[idx].value == ""){
			alert("Selecione uma Área de Interesse.");
			f.area.focus();
			return false;
		}
		idx = f.subArea.option.selectedIndex;
		if (f.subArea.option[idx].value == ""){
			alert("Selecione um Segmento de Interesse.");
			f.subArea.focus();
			return false;
		}
	}
	if (acao == "Excluir"){
		if(!confirm("Deseja Excluir esta Área?")){
			return false;
		}
 	}
}
function selecionaArea(){
	document.form.submit();
}

// Validações da pagina de Formacao
function validaFormacao(f){
	acao = f.Acao.value;
	if (acao == "Incluir"){
		if (f.curso.value == ""){
			alert("Campo Curso é obrigatório.");
			f.curso.focus();
			return false;
		}
		if (f.situacao.value == "Concluído"){
			if(f.conclusao.value == ""){
				alert("Informe a data de conclusão!");
				f.conclusao.focus();
				return false;
			}else{
				if (!ValidaData(01,f.conclusao.value.substr(0,2), f.conclusao.value.substr(3,4))){
					alert("Data com formato inválido.")
					f.conclusao.focus();
					return false;
				}
			}
		}
		if (f.instituicao.value == ""){
			alert("Campo Instiuição é obrigatório.");
			f.instituicao.focus();
			return;
		}
	}
	if (acao == "Alterar"){
		if (f.curso.value == ""){
			alert("Campo Curso é obrigatório.");
			f.curso.focus();
			return false;
		}
		if (f.situacao.value == "Concluído"){
			if(f.conclusao.value == ""){
				alert("Informe a data de conclusão!");
				f.conclusao.focus();
				return false;
			}else{
				if (!ValidaData(01,f.conclusao.value.substr(0,2), f.conclusao.value.substr(3,4))){
					alert("Data com formato inválido.")
					f.conclusao.focus();
					return false;
				}
			}
		}
		if (f.instituicao.value == ""){
			alert("Campo Instiuição é obrigatório.");
			f.instituicao.focus();
			return;
		}
	}
	if (acao == "Excluir"){
		if(!confirm("Deseja Excluir esta Escolaridade?")){
			return false;
		}
 	}
}

// Validações da pagina de Certificacao
function validaCertificacao(f){
	acao = f.Acao.value;
	if (acao == "Incluir"){
		if (f.descricao.value == ""){
			alert("Campo Descrição é obrigatório.");
			f.descricao.focus();
			return false;
		}
		if (f.numero.value == ""){
			alert("Campo Número é obrigatório.");
			f.numero.focus();
			return false;
		}
		if(f.data.value == ""){
			alert("Campo Data é obrigatório.");
			f.data.focus();
			return false;
		}else{
			if (!ValidaData(01,f.data.value.substr(0,2), f.data.value.substr(3,4))){
				alert("Data com formato inválido.")
				f.data.focus();
				return false;
			}
		}
		if (f.instituicao.value == ""){
			alert("Campo Instiuição é obrigatório.");
			f.instituicao.focus();
			return;
		}
	}
	if (acao == "Alterar"){
		if (f.descricao.value == ""){
			alert("Campo Descrição é obrigatório.");
			f.descricao.focus();
			return false;
		}
		if (f.numero.value == ""){
			alert("Campo Número é obrigatório.");
			f.numero.focus();
			return false;
		}
		if(f.data.value == ""){
			alert("Campo Data é obrigatório.");
			f.data.focus();
			return false;
		}else{
			if (!ValidaData(01,f.data.value.substr(0,2), f.data.value.substr(3,4))){
				alert("Data com formato inválido.")
				f.data.focus();
				return false;
			}
		}
		if (f.instituicao.value == ""){
			alert("Campo Instiuição é obrigatório.");
			f.instituicao.focus();
			return;
		}
	}
	if (acao == "Excluir"){
		if(!confirm("Deseja Excluir esta Certificação?")){
			return false;
		}
 	}
}

// Valida o form de informação salarial
function validaSalario(f){
	if (f.pretensao.value == "") {
		window.alert("Campo Pretensão Salarial é obrigatório.");
		f.pretensao.focus();
		return false;
	}
	return true;
}

// Função da pag de cursos que habilita e desabilita o campo de tipo certificado
function desabilita(){
	idx = document.form.certificado.options.selectedIndex;
	certificado = document.form.certificado.options[idx].value;
	if (certificado == "1"){
		document.form.tipo.disabled = false;
	}else{
		document.form.tipo.disabled = true;
	}
}

function navegacao(caminho){
	document.form.action = caminho;
	document.form.submit();
}

function cancela(url){
 	location.href = url;
}

function printBoletim() {
	strUrl = 'wescolaBoletimImprimir.asp';
	window.open(strUrl,'boletim','toolbar=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width=675,height=485');
}

function printCalendario() {
	idx = document.fmNextPrev.CURDATE_month.options.selectedIndex;
	mes = document.fmNextPrev.CURDATE_month.options[idx].value;
	ano = document.fmNextPrev.CURDATE_YEAR.value;
	strUrl = 'wescolaCalendarioImprimir.asp?imprimir=1';
	strUrl += '&CURDATE_month=' + mes;
	strUrl += '&CURDATE_year=' + ano;
	window.open(strUrl,'calendario','toolbar=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width=675,height=485');
}

function printComunicado() {
	strUrl = 'wescolaRecadosImprimir.asp';
	window.open(strUrl,'boletim','toolbar=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width=675,height=485');
}

function printArquivo(materia) {
	strUrl = 'wescolaArquivosImprimir.asp?disc='+materia;
	window.open(strUrl,'arquivos','toolbar=yes,menubar=yes,resizable=yes,status=no,scrollbars=yes,width=675,height=485');
}

function selecionaAreaHabilidades(){
	document.form.action = "empregosHabilidades.asp";
	document.form.submit();
}

function mudaHabilidades(codigo,area,subarea,tempoexperiencia){
	document.form2.codigoHabilidades.value = codigo;
	document.form2.area.value = area;
	document.form2.subarea.value = subarea;
	document.form2.tempoexperiencia.value = tempoexperiencia;
	document.form2.action = "empregosHabilidades.asp";
	document.form2.submit();
}

//Funcionalidade: Verifica se o parâmetro é um CPF válido
//Retorna True -> Se o parâmetro for um CPF válido
//Retorna False-> Se o parâmetro não for um CPF válido
//Parâmetros:
//	rcpf1 -> Número do CPF a ser validado
function verificaCPF(cpf){
	if(cpf == "") { return true; }

	cpf = cpf.replace( ".", "" );
	cpf = cpf.replace( ".", "" );
	cpf = cpf.replace( ".", "" );
	cpf = cpf.replace( ".", "" );
	cpf = cpf.replace( "-", "" );

	var dac = "", inicio = 2, fim = 10, soma, digito, i, j
	for (j=1;j<=2;j++) {
		soma = 0
		for (i=inicio;i<=fim;i++) {
			soma += parseInt(cpf.substring(i-j-1,i-j))*(fim+1+j-i)
		}
		if (j == 2) { soma += 2*digito }
		digito = (10*soma) % 11
		if (digito == 10) { digito = 0 }
		dac += digito
		inicio = 3
		fim = 11
	}
	return (dac == cpf.substring(cpf.length-2,cpf.length))
}

function validaEsqueceu(){
	if (document.form.CPF.value == "") {
		window.alert("Você deve digitar o seu CPF");
		document.form.CPF.focus();
		return false;
	} else {
		strAux = document.form.CPF.value;
		strAux = strAux.replace('.','');
		strAux = strAux.replace('-','');
		
		if (!verificaCPF(strAux)) {
			window.alert("CPF com formato invalido");
			document.form.CPF.focus();
			return false;
		}
	}
	
	return true;
}



function ValidaFormacao(f)
{

if (f.sel_curso.value == "" || f.sel_curso.value.length < 1)
{
  alert('Você deve informar o Curso.');
  f.sel_curso.focus();
  return false;
}

if (f.sel_situacao.value == "" || f.sel_situacao.value.length < 1)
{
  alert('Você deve informar a situação deste curso.');
  f.sel_situacao.focus();
  return false;
}

if (f.txt_conclusao.value == "" || f.txt_conclusao.value.length < 1)
{
  alert('Você deve informar quando seu curso foi concluído ou a previsão para a conclusão.');
  f.txt_conclusao.focus();
  return false;
}

if (f.txt_instituicao.value == "" || f.txt_instituicao.value.length < 1)
{
  alert('Você deve informar o nome da instituição de ensino.');
  f.txt_instituicao.focus();
  return false;
}
return true;
}

function mascara_cep()
{
	if (document.form.txt_cep.value.length=="2")
	{
		document.form.txt_cep.value = document.form.txt_cep.value + "."
	}
	if (document.form.txt_cep.value.length=="6")
	{
		document.form.txt_cep.value = document.form.txt_cep.value + "-"
	}
}

function mascaraMatricula(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length + 1;
	//alert(tam);
	if ( tecla != 9 && tecla != 8 ){
		if ( tam <= 3 ){ Campo.value = vr ; }
		if ( (tam == 4) ){
	 		Campo.value = vr.substr( 0, 2 ) + '-' + vr.substr( 2, tam ) ; }
		if ( (tam > 4) && (tam <= 9) ){
	 		Campo.value = vr.substr( 0, 2 ) + '-' + vr.substr( 2, 1 )  + '-' + vr.substr( 3, tam ) ; }
	 	//if ( (tam > 6) && (tam <= 9) ){
	 	//	Campo.value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr( 6, tam ) ; }
	 	//if ( (tam > 9) && (tam <= 11) ){
		 //	Campo.value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr( 6, 3 ) + '-' + vr.substr( 9, tam ) ; }
	}
}



function ValidaCertificacao(f)
{

if (f.txt_curso.value == "" || f.txt_curso.value.length < 1)
{
  alert('Você deve informar a Certificação.');
  f.txt_curso.focus();
  return false;
}

if (f.txt_situacao.value == "" || f.txt_situacao.value.length < 1)
{
  alert('Você deve informar o Número da certificação.');
  f.txt_situacao.focus();
  return false;
}

if (f.txt_conclusao.value == "" || f.txt_conclusao.value.length < 1)
{
  alert('Você deve informar a data da Conclusão do Curso.');
  f.txt_conclusao.focus();
  return false;
}

if (f.txt_instituicao.value == "" || f.txt_instituicao.value.length < 1)
{
  alert('Você deve informar o nome da Instituição certificadora.');
  f.txt_instituicao.focus();
  return false;
}
return true;
}

function ValidaIdiomas(f)
{

if (f.sel_idioma.value == "" || f.sel_idioma.value.length < 1)
{
  alert('Escolha uma opção.');
  f.sel_idioma.focus();
  return false;
}

if (f.sel_le.value == "" || f.sel_le.value.length < 1)
{
  alert('Escolha uma opção.');
  f.sel_le.focus();
  return false;
}

if (f.sel_fala.value == "" || f.sel_fala.value.length < 1)
{
  alert('Escolha uma opção.');
  f.sel_fala.focus();
  return false;
}

if (f.sel_escreve.value == "" || f.sel_escreve.value.length < 1)
{
  alert('Escolha uma opção.');
  f.sel_escreve.focus();
  return false;
}
return true;
}


function ValidaCursos(f)
{

if (f.txt_curso.value == "" || f.txt_curso.value.length < 1)
{
  alert('Você deve informar o nome do Curso.');
  f.txt_curso.focus();
  return false;
}

if (f.txt_descricao.value == "" || f.txt_descricao.value.length < 1)
{
  alert('Você deve informar a descrição do Curso.');
  f.txt_descricao.focus();
  return false;
}

if (f.txt_instituicao.value == "" || f.txt_instituicao.value.length < 1)
{
  alert('Você deve informar o local onde foi realizado o Curso.');
  f.txt_instituicao.focus();
  return false;
}

if (f.txt_carga_horaria.value == "" || f.txt_carga_horaria.value.length < 1)
{
  alert('Você deve informar a Carga Horária do Curso.');
  f.txt_carga_horaria.focus();
  return false;
}
return true;
}

function ValidaHabilidades(f)
{

if (f.area.value == "" || f.area.value.length < 1)
{
  alert('Informe a área.');
  f.area.focus();
  return false;
}

if (f.subarea.value == "" || f.subarea.value.length < 1)
{
  alert('Informe a sub área.');
  f.subarea.focus();
  return false;
}

if (f.tempoexperiencia.value == "" || f.tempoexperiencia.value.length < 1)
{
  alert('Informe o tempo de Experiência.');
  f.tempoexperiencia.focus();
  return false;
}
return true;
}


function ValidaValor(f)
{

if (f.txt_pretensao.value == "" || f.txt_pretensao.value.length < 1)
{
  alert('Informe o Valor.');
  f.txt_pretensao.focus();
  return false;
}
return true;
}

function ValidaHistorico(f)
{

if (f.txt_empresa.value == "" || f.txt_empresa.value.length < 1)
{
  alert('Você deve informar o nome da Empresa.');
  f.txt_empresa.focus();
  return false;
}

if (f.txt_entrada.value == "" || f.txt_entrada.value.length < 1)
{
  alert('Você deve informar a data de Admissão.');
  f.txt_entrada.focus();
  return false;
}

if (f.txt_saida.value == "" || f.txt_saida.value.length < 1)
{
  alert('Informe a data atual caso ainda esteja na empresa.');
  f.txt_saida.focus();
  return false;
}

if (f.txt_cargo.value == "" || f.txt_cargo.value.length < 1)
{
  alert('Você deve informar o Cargo exercido.');
  f.txt_cargo.focus();
  return false;
}

if (f.txt_atividades.value == "" || f.txt_atividades.value.length < 1)
{
  alert('Descreva as atividades desenvolvidas.');
  f.txt_atividades.focus();
  return false;
}

return true;
}


function Valida_Valor(valor)
{
	
	//expressão de caracteres inválidos para valor
	var expressaoRegular= /[a-zA-Z\''\"!@#\$%¨\&\*\(\)\-_\+=\{\}\[\]´`\^~|<>:;?\\\/]/g; 
	resposta = valor.match(expressaoRegular); 
	if (resposta == null)//não tem nenhum dos caracteres que não podem ser aceitos
	{
		//expressão de caracteres aceitos - dígitos, ponto e vírgula
		expressaoRegular= /[0-9.,]/;
		resposta = valor.match(expressaoRegular);
		if (resposta)
			return true;
		else
			return false;
	}
	else
		return false;
}//Objetivo:	Esta função tem a finalidade de ir colocando o valor digitado no campo em formato monetário.
//Parâmetros:	Recebe como parâmetro o nome completo do campo onde está sendo digitado o valor,
//		por exemplo ''''''''''''''''document.frmInclusao.valor.value''''''''''''''''.



function somenteNumero(event) {
	if (!(event.keyCode >= 48 && event.keyCode <= 57)) {
		event.returnValue = false;
 	}
}

function FormataCPF(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length + 1;
	//alert(tam);
	if ( tecla != 9 && tecla != 8 ){
		if ( tam <= 3 ){ Campo.value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		Campo.value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, tam ) ; }
	 	if ( (tam > 6) && (tam <= 9) ){
	 		Campo.value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr( 6, tam ) ; }
	 	if ( (tam > 9) && (tam <= 11) ){
		 	Campo.value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr( 6, 3 ) + '-' + vr.substr( 9, tam ) ; }
	}
}

/************************************************
* function verificaEmail
* Verifica se um email é válido
* Input: email a ser verificado
************************************************/
function verificaEmail(email) {
	var s = new String(email);
	// { } ( ) < > [ ] | \ /
	if ((s.indexOf("{")>=0) || (s.indexOf("}")>=0) || (s.indexOf("(")>=0) || (s.indexOf(")")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("[")>=0) || (s.indexOf("]")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0) )
		return false;
	if (vogalAcentuada(email))
		return false;
	// & * $ % ? ! ^ ~ ` ' "
	if ((s.indexOf("&")>=0) || (s.indexOf("*")>=0) || (s.indexOf("$")>=0) || (s.indexOf("%")>=0) || (s.indexOf("?")>=0) || (s.indexOf("!")>=0) || (s.indexOf("^")>=0) || (s.indexOf("~")>=0) || (s.indexOf("`")>=0) || (s.indexOf("'")>=0) )
		return false;
	// , ; : = #
	if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
		return false;
	// procura se existe apenas um @
	if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
		return false;
	// verifica se tem pelo menos um ponto após o @
	if (s.lastIndexOf(".") < s.indexOf("@"))
		return false;
	return true;
}

function FormataCEP(campo){
	if (campo.value.length=="5"){
		campo.value = campo.value + "-";
	}
}

function formataMesAno(campo){
	if (campo.value.length=="2"){
		campo.value = campo.value + "/";
	}
}

function FormataData(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	
	if ( tecla != 9 && tecla != 8 ){
	if ( tam > 2 && tam < 5 )
	Campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
	if ( tam >= 5 && tam <= 10 )
		Campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
	}
}

function FormataValor(Campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	sinal = "";
	if (vr.substring(0,1) == "0"){
		vr = vr.replace("0,0","");
		vr = vr.replace("0,","");
	}
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ",", "" );
	tam1 = vr.length;
	tam = vr.length+1;
	
	if (tam >= tammax){
		teclapres.returnValue = false;
	}else{
		if ( tecla != 9 && tecla != 8 ){
			//if ( tam <= 3 ){ valorFormatado = vr ; }
			if (tam > 0 && tam < 2 )
				Campo.value = '0,0' + vr.substr(0,tam - 1);
			if (tam >= 2 && tam < 3 )
				Campo.value = '0,' + vr.substr(0,tam);
			if ( (tam >= 3) && (tam <= 5) ){
				Campo.value = vr.substr(0,tam - 2) + ',' + vr.substr(tam - 2, tam);	}
			if ( (tam > 5) && (tam <= 8) ){
		 		Campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3) + ',' + vr.substr(tam - 2, tam) ; }
		 	if ( (tam > 8) && (tam <= 11) ){
			 	Campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam -5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
			if ( (tam > 11) && (tam <= 14) ){
				Campo.value = vr.substr( 0, tam-11 ) + '.' + vr.substr( tam-11, 3 ) + '.' + vr.substr( tam-8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		}
	}
}

/* Formata o valor quando ele vem de alguma função e precisar e estar no padrão moeda*/
function formatacaoValor(valor) {
	sinal = "";
	if(valor.indexOf("-")!=-1){ sinal = "-"; }
	arrValor = valor.split('.');
	if (arrValor.length > 1){
		decimal = arrValor[1] + "0000";
		if(decimal.length > 2){ decimal = decimal.substring(0,2); }
		decimal = "," + decimal;
	}else{
		decimal = ",00";
	}
	vr = limpaValor(arrValor[0]);
	
	tam = vr.length;

	if ( tam <= 3 ){ valorFormatado = vr ; }
 	if ( (tam > 3) && (tam <= 6) ){
 		valorFormatado = vr.substr( 0, tam - 3 ) + '.' + vr.substr( tam - 3, tam ) ; }
 	if ( (tam >= 7) && (tam <= 9) ){
 		valorFormatado = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, tam ) ; }
 	if ( (tam >= 10) && (tam <= 12) ){
	 	valorFormatado = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, tam ) ; }
	if ( (tam >= 13) && (tam <= 15) ){
		valorFormatado = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, tam ) ; }
	if ( (tam >= 16) && (tam <= 19) ){
		valorFormatado = vr.substr( 0, tam - 15 ) + '.' + vr.substr( tam - 15, 3 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, tam ) ;}
	
	valorFormatado = sinal + valorFormatado + decimal;
	return valorFormatado;
}

// Verifica se uma string tem vogais acentuadas
function vogalAcentuada(s) {
	ls = s.toLowerCase();
	if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
		return true;
}

// FUNCAO PARA VERIFICAÇÃO DE CAMPOS NÃO PREENCHIDOS
// OU PREENCHIDOS APENAS COM ESPAÇOS EM BRANCO
function verificaBranco(parametro) {
	teste_parametro = "false"; //variavel para teste de espacos em branco
	tamanho_parametro = parametro.length;
	if (tamanho_parametro != 0)	{
		for (i = 0; i < tamanho_parametro; i++)	{
			if (parametro.charAt(i) != " ")	{
				teste_parametro = "true"; /*existe caracter diferente de branco*/
			}
		}
		if (teste_parametro == "false") { //todos os caracteres digitados são brancos
			return false;
		}else{
			return true;
		}
	}else{
		return false;
	}	
}

//Funcionalidade:	Valida a Data retornando True se for uma Data 
//					válida e False se não for.
//					Antes de se usar esta função deve-se garantir que os parâmetros
//					passados sejam numéricos e inteiros.
// PARÂMETROS: 
//		Dia = Dia da Data(caracteres numericos), 
//		Mes = Mes da Data(caracteres numericos), 
//		Ano = Ano da Data(caracteres numericos)
function ValidaData(dia,mes,ano) {	
	var v_dia;
	var v_mes;
	var v_ano;
	
	if (!valida_inteiro(dia)){
		return (false);		
	}
	if (!valida_inteiro(mes)){
		return (false);		
	}
	if (!valida_inteiro(ano)){
		return (false);		
	}
				
	v_dia = dia;
	v_mes = mes;
	v_ano = ano;
		
	if (v_dia.length < 2){ return(false);}
	if (v_mes.length < 2){ return(false);}
	if (v_ano.length < 4){ return(false);}
		
	if (((v_ano < 1900) || (v_ano > 2079)) && (v_ano.length != 0)){
		return(false);
	}

	if (v_dia > 31 || v_dia < 1){ return(false);}
	if (v_mes > 12 || v_mes < 1){ return(false);}
		
	if (v_dia == "31") {
		if ((v_mes == "04") || (v_mes == "06") || (v_mes == "09") || (v_mes == "11")){
			return(false);
		}
	}
	
	//Validação de Ano Bissexto
	if (v_mes == "02") {
		if (!(v_ano%4)) {
			if (v_dia > 29)	{
				return(false);
			}
		}else if (v_dia > 28){
			return(false);
		}
	}
		
	//o -if- abaixo testa se algum campo foi preenchido e outro deixado em branco deixando a data incompleta
	if (((v_dia != "") || (v_mes != "") || (v_ano != "")) && ((v_dia == "") || (v_mes == "") || (v_ano == "")))	{
		return(false);
	}
	return(true);
}

function mudaMatricula(){
	idx = document.matricula.matriculaCod.options.selectedIndex;
	if(document.matricula.matriculaCod.options[idx].value != "0"){
		document.matricula.submit();
	}
}

function imprimirTela(){
	w=window.open('','newwin');
	
	vHtml = '<head><link href=\'../_styles/template_css.css\' rel=\'stylesheet\'>';
	vHtml += '<link href=\'../_styles/css_lxmenu.css\' rel=\'stylesheet\'>';
	vHtml += '<link href=\'../_styles/estilos.css\' rel=\'stylesheet\'></head>';
	vHtml += '<bo'+'dy onLoad=\'window.print();window.close();\'>';
	vHtml += '<table width=\'640\'>'+document.getElementById('t1').innerHTML+'</table></bo'+'dy>';
	
	w.document.write(vHtml);
	w.document.close();
	//return false;
}

function limpaValor(vr){
	for (limpa=0;limpa<vr.length;limpa++){
		if ((vr.indexOf("-")!=-1)||(vr.indexOf("+")!=-1)||(vr.indexOf("/")!=-1)||(vr.indexOf(".")!=-1)||(vr.indexOf(",")!=-1)){
			vr = vr.replace("-","");
			vr = vr.replace("-","");
			vr = vr.replace("-","");
			vr = vr.replace("-","");
			vr = vr.replace("-","");
			vr = vr.replace("+","");
			vr = vr.replace("+","");
			vr = vr.replace("+","");
			vr = vr.replace("+","");
			vr = vr.replace("+","");
			vr = vr.replace("+","");
			vr = vr.replace("*","");
			vr = vr.replace("/","");
			vr = vr.replace(",","");
			vr = vr.replace(",","");
			vr = vr.replace(".","");
			vr = vr.replace(".","");
			vr = vr.replace(".","");
			vr = vr.replace(".","");
		}  
	}
	return vr;
}