//##########################################################################################
function apagarCampo(elem, vl){
	if(elem.value == vl){
		elem.value = '';
	}
}
//##########################################################################################
function checarExper(escolha){
	if(escolha == 's'){
		document.getElementById('expop').style.display = 'block';
		document.getElementById('chexp_s').checked = true;
		document.getElementById('chexp_n').checked = false;
	}else{
		document.getElementById('expop').style.display = 'none';
		document.getElementById('chexp_n').checked = true;
		document.getElementById('chexp_s').checked = false;
	}
}
//##########################################################################################
function checarConcluido(elem){
	if(elem.checked == true){
		document.getElementById('dtterminofor_0').style.display = 'block';
	}else{
		document.getElementById('dtterminofor_0').style.display = 'none';
	}
}
//##########################################################################################
function checarVisto(elem, op){
	if(op){
		if(elem.value != '10'){
			document.getElementById('ident_visto').style.display = 'block';
			document.getElementById('divvisto').style.display = 'block';
			document.getElementById('tdvisto').height = '23';
		}else{
			document.getElementById('ident_visto').style.display = 'none';
			document.getElementById('divvisto').style.display = 'none';
			document.getElementById('tdvisto').height = '0';
		}
	}
}
//##########################################################################################
function checarInstituicao(elem){
	if(elem.value == '_Outras'){
		document.getElementById('m25').style.display = 'block';
	}else{
		document.getElementById('m25').style.display = 'none';
	}
}
//##########################################################################################

//Carlin
/*function checarNacio(escolha){
	if(escolha == 's'){
		document.getElementById('expop').style.display = 'block';
		document.getElementById('chexp_s').checked = true;
		document.getElementById('chexp_n').checked = false;
	}else{
		document.getElementById('expop').style.display = 'none';
		document.getElementById('chexp_n').checked = true;
		document.getElementById('chexp_s').checked = false;
	}
}*/
//##########################################################################################
function valCargo(){
	if(document.getElementById('tipo_pretendido_0').value == '0'){
		alert('Selecione um Tipo');
		return false;
	}
	if(document.getElementById('cargo_pretendido_0').value == '0'){
		alert('Selecione um Cargo');
		return false;		
	}
		return true;
}
//##########################################################################################
function enviarCargo(){
	if(valCargo()){
		var id = document.getElementById('cargo_pretendido_0').value
		var existe = gerLista(id, true, 'lstcargo');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'&cod_tipo='+document.getElementById('tipo_pretendido_0').value;
			strPost = strPost+'&cod_cargo='+document.getElementById('cargo_pretendido_0').value;
			
			//reseta 
			document.getElementById('cargo_pretendido_0').options[0].selected = true;
			
			insConteudo('cargo', strPost, 'menu_6_inserir_cargo.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}	
}
//##########################################################################################
function valArea(){
	if(document.getElementById('area_interesse_0').value == '0'){
		alert('Selecione uma Área');
		controle = false;
		return false;		
	}
		return true;
}
//##########################################################################################
function enviarArea(){
	if(valArea()){
		var id = document.getElementById('area_interesse_0').value
		var existe = gerLista(id, true, 'lstinteresse');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'&cod_area='+document.getElementById('area_interesse_0').value;

			//reseta 
			document.getElementById('area_interesse_0').options[0].selected = true;
			
			insConteudo('area', strPost, 'menu_6_inserir_area.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}	
}
//##########################################################################################
function valFormacao(){
	if(document.getElementById('formacao_0').value == '0'){
		alert('Selecione uma Formação');
		return false;
	}
	if(document.getElementById('tipofor_0').value == '0'){
		alert('Selecione um Tipo');
		return false;		
	}
	if((document.getElementById('instfor_0').value == '0')||(document.getElementById('instfor_0').value == '99999')){
		if(document.getElementById('instfor2_0').value == ''){
			alert('Selecione uma Instituição ou preencha ou nome da Instituição');
			return false;		
		}
	}
	if(document.getElementById('dtiniciofor_0').value == ''){
		alert('Data de início inválida');
		//document.getElementById('dtiniciofor_0').focus();
		return false;
	}else{
		data_ini = document.getElementById('dtiniciofor_0').value.split("/");
		dia_ini = data_ini[0];
		mes_ini = data_ini[1];
		ano_ini = stringToFloat(data_ini[2]);
		if((dia_ini == '29' ) && (mes_ini == '02') && ((ano_ini%4) != 0) || (ano_ini.length < 4)){
			alert('Data de início inválida');
			//document.getElementById('dtiniciofor_0').focus();
			return false;
		}else{
			if(!doDate(document.getElementById('dtiniciofor_0').value, 4)){
				alert('Data de início inválida');
				//document.getElementById('dtiniciofor_0').focus();
				return false;
			}
		}		
	}
	if(document.getElementById('concluidofor_0').checked == true){
		if(document.getElementById('dtterminofor_0').value == ''){
			alert('Data de conclusão inválida');
			//document.getElementById('dtterminofor_0').focus();
			return false;			
		}else{
			data_ter = document.getElementById('dtterminofor_0').value.split("/");
			dia_ter = data_ter[0];
			mes_ter = data_ter[1];
			ano_ter = stringToFloat(data_ter[2]);
			if((dia_ter == '29' ) && (mes_ter == '02') && ((ano_ter%4) != 0) || (ano_ter.length < 4)){
				alert('Data de conclusão inválida');
				//document.getElementById('dtterminofor_0').focus();
				return false;
			}else{
				if(!doDate(document.getElementById('dtterminofor_0').value, 4)){
				alert('Data de início inválida');
				//document.getElementById('dtterminofor_0').focus();
				return false;
				}
			}
		}
	}
	return true;
}
//##########################################################################################
function enviarFormacao(){
	if(valFormacao()){
		var id = document.getElementById('formacao_0').value;
		var existe = gerLista(id, true, 'lstformacao');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'&codtipo='+url_encode(document.getElementById('tipofor_0').value);
			strPost = strPost+'&codformacao='+document.getElementById('formacao_0').value;
			strPost = strPost+'&codinst='+url_encode(document.getElementById('instfor_0').value);
			strPost = strPost+'&codinst2='+url_encode(document.getElementById('instfor2_0').value);
			strPost = strPost+'&dtinicio='+url_encode(document.getElementById('dtiniciofor_0').value);
			strPost = strPost+'&dttermino='+url_encode(document.getElementById('dtterminofor_0').value);
			strPost = strPost+'&observacao='+url_encode(document.getElementById('observacaofor_0').value);	
			
			//resetar 

			document.getElementById('tipofor_0').options[0].selected	 = true;
			document.getElementById('formacao_0').options[0].selected = true;
			document.getElementById('instfor_0').options[0].selected	 = true;
			document.getElementById('instfor2_0').value               = '';
			document.getElementById('dtiniciofor_0').value            = '';
			document.getElementById('dtterminofor_0').value           = '';
			document.getElementById('observacaofor_0').value          = ''
			document.getElementById('concluidofor_0').checked         = false;
			
			desHabilita(2,6,false);
			
			insConteudo('formacao', strPost, 'menu_2_inserir_formacao.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}
}
//##########################################################################################

function valCurso(){
	if(document.getElementById('curso_0').value == ''){
		alert('Preencha o Curso');
		//document.getElementById('curso_0').focus();
		return false;
	}
	if(document.getElementById('cargacur_0').value == ''){
		alert('Preencha a Carga Horária');
		//document.getElementById('cargacur_0').focus();
		return false;		
	}
	if(document.getElementById('instcur_0').value == ''){
		alert('Preencha a Entidade');
		//document.getElementById('instcur_0').focus();
		return false;		
	}
	if(document.getElementById('dtiniciocur_0').value == ''){
			alert('Data de início inválida');
			//document.getElementById('dtiniciocur_0').focus();
			return false;
	}else{
		data_ini = document.getElementById('dtiniciocur_0').value.split("/");
		dia_ini = data_ini[0];
		mes_ini = data_ini[1];
		ano_ini = stringToFloat(data_ini[2]);
		if((dia_ini == '29' ) && (mes_ini == '02') && ((ano_ini%4) != 0) || (ano_ini.length < 4)){
			alert('Data de início inválida');
			//document.getElementById('dtiniciocur_0').focus();
			return false;
		}else{
			if(!doDate(document.getElementById('dtiniciocur_0').value, 4)){
				alert('Data de início inválida');
				//document.getElementById('dtiniciocur_0').focus();
				return false;
			}
		}		
	}
	if(document.getElementById('dtterminocur_0').value == ''){
		alert('Data de conclusão inválida');
		//document.getElementById('dtterminocur_0').focus();
		return false;			
	}else{
		data_ter = document.getElementById('dtterminocur_0').value.split("/");
		dia_ter = data_ter[0];
		mes_ter = data_ter[1];
		ano_ter = stringToFloat(data_ter[2]);
		if((dia_ter == '29' ) && (mes_ter == '02') && ((ano_ter%4) != 0) || (ano_ter.length < 4)){
			alert('Data de conclusão inválida');
			//document.getElementById('dtterminocur_0').focus();
			return false;
		}else{
			if(!doDate(document.getElementById('dtterminocur_0').value, 4)){
				alert('Data de início inválida');
				//document.getElementById('dtterminocur_0').focus();
				return false;
			}
		}
	}
	return true
}
//##########################################################################################

function enviarCurso(){
	if(valCurso()){
		//Por nao ter id
		var id = (1 + stringToFloat(document.getElementById('ultlstcurso').value));
		
		document.getElementById('ultlstcurso').value = id;
		var existe = gerLista(id, true, 'lstcurso');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'carga='+url_encode(document.getElementById('cargacur_0').value);
			//alert(id);
			strPost = strPost+'&codcurso='+id;
			strPost = strPost+'&curso='+url_encode(document.getElementById('curso_0').value);
			strPost = strPost+'&inst='+url_encode(document.getElementById('instcur_0').value);
			strPost = strPost+'&dtinicio='+url_encode(document.getElementById('dtiniciocur_0').value);
			strPost = strPost+'&dttermino='+url_encode(document.getElementById('dtterminocur_0').value);
			strPost = strPost+'&observacao='+url_encode(document.getElementById('observacaocur_0').value);
			
			//resetar 
			document.getElementById('cargacur_0').value      = '';
			document.getElementById('curso_0').value         = '';
			document.getElementById('instcur_0').value       = '';
			document.getElementById('dtiniciocur_0').value   = '';
			document.getElementById('dtterminocur_0').value  = '';
			document.getElementById('observacaocur_0').value = '';
			
			desHabilita(8,7,false);
			
			insConteudo('curso', strPost, 'menu_2_inserir_curso.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}
}
//##########################################################################################

function valIdioma(){
	if(document.getElementById('idioma_0').value == '0'){
		alert('Selecione o Idioma');
		//document.getElementById('idioma_0').focus();
		return false;
	}
	if(document.getElementById('nivelidi_0').value == '0'){
		alert('Selecione o Nível');
		//document.getElementById('nivelidi_0').focus();
		return false;		
	}
	if(document.getElementById('tempoidi_0').value == ''){
		alert('Preencha o Tempo de Experiência');
		//document.getElementById('tempoidi_0').focus();
		return false;		
	}
	if(document.getElementById('experienciaidi_0').value == ''){
		alert('Preencha a Experiência');
		//document.getElementById('experienciaidi_0').focus();
		return false;		
	}
	return true;
}
//##########################################################################################

function enviarIdioma(){
	if(valIdioma()){
		var id = document.getElementById('idioma_0').value;
		var existe = gerLista(id, true, 'lstidioma');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'codidioma='+document.getElementById('idioma_0').value;
			strPost = strPost+'&codnivel='+document.getElementById('nivelidi_0').value;
			strPost = strPost+'&tempo='+url_encode(document.getElementById('tempoidi_0').value);
			strPost = strPost+'&codexperiencia='+url_encode(document.getElementById('experienciaidi_0').value);
			strPost = strPost+'&escola='+url_encode(document.getElementById('escolaidi_0').value);
			strPost = strPost+'&prova='+url_encode(document.getElementById('provaidi_0').value);
			
			//resetar
			document.getElementById('idioma_0').options[0].selected	       = true;
			document.getElementById('nivelidi_0').options[0].selected    	 = true;
			document.getElementById('experienciaidi_0').options[0].selected = true;
			document.getElementById('tempoidi_0').value                     = '';
			document.getElementById('escolaidi_0').value                    = '';
			document.getElementById('provaidi_0').value                     = '';
			
			desHabilita(3,5,false);
			
			insConteudo('idioma', strPost, 'menu_3_inserir_idioma.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}
}
//##########################################################################################
contexp = 0; 
function valExperiencia(){
	if(contexp <= 3){
		if(document.getElementById('empresaexp_0').value == ''){
			alert('Preencha o Nome da Empresa');
			//document.getElementById('empresaexp_0').focus();
			return false;
		}
		if(document.getElementById('atividadeexp_0').value == '0'){
			alert('Selecione o Ramo de Atividade');
			//document.getElementById('atividadeexp_0').focus();
			return false;		
		}
		if(document.getElementById('estadoexp_0').value == '0'){
			alert('Selecione o Estado');
			//document.getElementById('estadoexp_0').focus();
			return false;		
		}
		if(document.getElementById('municipioexp_0').value == '0'){
			alert('Selecione a Cidade');
			//document.getElementById('municipioexp_0').focus();
			return false;		
		}
		if(document.getElementById('telefoneexp_0').value.legth < 13){
			alert('Preencha o Telefone');
			//document.getElementById('telefoneexp_0').focus();
			return false;		
		}
		if(document.getElementById('dtadmissaoexp_0').value == ''){
			alert('Data de admissão inválida');
			//document.getElementById('dtadmissaoexp_0').focus();
			return false;			
		}else{
			data_ter = document.getElementById('dtadmissaoexp_0').value.split("/");
			dia_ter = data_ter[0];
			mes_ter = data_ter[1];
			ano_ter = stringToFloat(data_ter[2]);
			if((dia_ter == '29' ) && (mes_ter == '02') && ((ano_ter%4) != 0) || (ano_ter.length < 4)){
				alert('Data de admissão inválida');
				//document.getElementById('dtadmissaoexp_0').focus();
				return false;
			}else{
				if(!doDate(document.getElementById('dtadmissaoexp_0').value, 4)){
					alert('Data de admissão inválida');
					//document.getElementById('dtadmissaoexp_0').focus();
					return false;
				}
			}
		}
	
		if(document.getElementById('dtdesligaexp_0').value != ''){
			data_ter = document.getElementById('dtdesligaexp_0').value.split("/");
			dia_ter = data_ter[0];
			mes_ter = data_ter[1];
			ano_ter = stringToFloat(data_ter[2]);
			if((dia_ter == '29' ) && (mes_ter == '02') && ((ano_ter%4) != 0) || (ano_ter.length < 4)){
				alert('Data de desligamento inválida');
				//document.getElementById('dtdesligaexp_0').focus();
				return false;
			}else{
				if(!doDate(document.getElementById('dtdesligaexp_0').value, 4)){
					alert('Data de desligamento inválida');
					//document.getElementById('dtdesligaexp_0').focus();
					return false;
				}
			}

			//menor e mairor
			//================================
			dtadm = document.getElementById('dtadmissaoexp_0').value;
			dtdes = document.getElementById('dtdesligaexp_0').value;
			if(dataMenorMaior(dtadm, dtdes) != "menor"){
				alert('Data de admissão deve ser inferior a Data de Desligamento');
				return false;
			}else{
			
				if(document.getElementById('motivosaidaexp_0').value == ''){
					alert('Preencha o motivo da saída');
					//document.getElementById('motivosaidaexp_0').focus();
					return false;		
				}			
			
			}
		//================================
	}

		
		

		if(document.getElementById('primeirocargoexp_0').value == ''){
			alert('Preencha o primeiro Cargo');
			//document.getElementById('primeirocargoexp_0').focus();
			return false;		
		}
		if(document.getElementById('ultimocargoexp_0').value == ''){
			alert('Preencha o último Cargo');
			//document.getElementById('ultimocargoexp_0').focus();
			return false;		
		}
		if(document.getElementById('ultimosalarioexp_0').value == ''){
			alert('Preencha o último Salário');
			//document.getElementById('ultimosalarioexp_0').focus();
			return false;		
		}
		return  true;
		contexp++;
	}else{
		alert('Somente 3 inserções são permitidas');
		return false;
	}
}
//##########################################################################################

function enviarExperiencia(){
	if(valExperiencia()){
		//Por nao ter id
		var id = (1 + stringToFloat(document.getElementById('ultlstexperiencia').value));
		document.getElementById('ultlstexperiencia').value = id;
		var existe = gerLista(id, true, 'lstexperiencia');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'empresa='+url_encode(document.getElementById('empresaexp_0').value);
			strPost = strPost+'&codexp='+id;
			strPost = strPost+'&codatividade='+url_encode(document.getElementById('atividadeexp_0').value);
			strPost = strPost+'&uf='+url_encode(document.getElementById('estadoexp_0').value);
			strPost = strPost+'&codmunicip='+url_encode(document.getElementById('municipioexp_0').value);
			strPost = strPost+'&telefone='+url_encode(document.getElementById('telefoneexp_0').value);
			strPost = strPost+'&dtadmissao='+url_encode(document.getElementById('dtadmissaoexp_0').value);
			strPost = strPost+'&dtdesliga='+url_encode(document.getElementById('dtdesligaexp_0').value);
			strPost = strPost+'&motivosaida='+url_encode(document.getElementById('motivosaidaexp_0').value);
			strPost = strPost+'&primeirocargo='+url_encode(document.getElementById('primeirocargoexp_0').value);
			strPost = strPost+'&ultimocargo='+url_encode(document.getElementById('ultimocargoexp_0').value);
			strPost = strPost+'&ultimosalario='+url_encode(document.getElementById('ultimosalarioexp_0').value);
			strPost = strPost+'&observacao='+url_encode(document.getElementById('observacaoexp_0').value);
			
			//resetar
			document.getElementById('atividadeexp_0').options[0].selected = true;
			document.getElementById('estadoexp_0').options[0].selected	  = true;
			document.getElementById('municipioexp_0').options[0].selected = true;
			document.getElementById('empresaexp_0').value                 = '';
			document.getElementById('telefoneexp_0').value                = '';
			document.getElementById('dtadmissaoexp_0').value              = '';
			document.getElementById('dtdesligaexp_0').value               = '';
			document.getElementById('motivosaidaexp_0').value             = '';
			document.getElementById('primeirocargoexp_0').value           = '';
			document.getElementById('ultimocargoexp_0').value             = '';
			document.getElementById('ultimosalarioexp_0').value           = '';
			document.getElementById('observacaoexp_0').value              = '';
			
			
			
			insConteudo('experiencia', strPost, 'menu_4_inserir_experiencia.php', id);
			
		}else{
			alert('Você já inseriu este item');	
		}
	}
}
//##########################################################################################

function valHabilidade(){
	if(document.getElementById('habilidadehab_0').value == '0'){
		alert('Selecione uma Habilidade');
		return false;
	}
	if(document.getElementById('habilidadehab_0').value != '0'){
		if(document.getElementById('nivelhab_0').value == '0'){
			alert('Selecione um Nível');
			return false;		
		}
	}
	return true;
}
//##########################################################################################
function enviarHabilidade(){
	if(valHabilidade()){
		var id = document.getElementById('habilidadehab_0').value;
		var existe = gerLista(id, true, 'lsthabilidade');
		if(existe){//Inseriu
			strPost = '';
			strPost = strPost+'codhab='+document.getElementById('habilidadehab_0').value;
			strPost = strPost+'&codnivel='+document.getElementById('nivelhab_0').value;
			
			//resetar
			document.getElementById('habilidadehab_0').options[0].selected	= true;
			document.getElementById('nivelhab_0').options[0].selected	   = true;
			
			
			insConteudo('habilidade', strPost, 'menu_3_inserir_habilidade.php', id);
		}else{
			alert('Você já inseriu este item');	
		}
	}
}
//##########################################################################################
function ocuMostFormacao(elem){
	if(elem.value == '0'){
		desHabilita(2,6,false);
	}else{
		desHabilita(2,6,true);
	}
	document.getElementById('m25').style.display = "block";
}

function ocuMostIdioma(elem){
	if(elem.value == '0'){
		desHabilita(3,5,false);
	}else{
		desHabilita(3,5,true);
	}
}

function ocuMostOutras(elem){
	if(elem.checked == false){
		desHabilita(5,1,false);
	}else{
		desHabilita(5,1,true);
	}	
}

function ocuMostOutras2(elem){
	if(elem.checked == false){
		desHabilita(6,4,false);
	}else{
		desHabilita(6,4,true);
	}	
}

function ocuMostOutras3(elem){
	if(elem.checked == false){
		desHabilita(7,1,false);
		document.getElementById('deficiencia').options[0].selected = true;
	}else{
		desHabilita(7,1,true);
	}	
}

function ocuMostOutras4(elem){
	if(elem.checked == false){
		desHabilita(9,4,false);
	}else{
		desHabilita(9,4,true);
	}	
}

function ocuMostMotivoSaida(elem){
	if(elem.value.length <= 0){
		document.getElementById('motivosaidaexp_0').style.display = "none";
		document.getElementById('lbmotivosaida').style.display = "none";
		document.getElementById('tdmotivosaida').height = '0';
	}else{
		document.getElementById('motivosaidaexp_0').style.display = "block"
		document.getElementById('lbmotivosaida').style.display = "block";
		document.getElementById('tdmotivosaida').height = '23';		
	}	
}

function ocuMostCurso(elem){
	if(elem.value.length <= 0){

	}else{
		desHabilita(8,7,true);
	}	
}

//##########################################################################################
function desHabilita(grp,quant,op){
	if(op == true){ //habilita
		for(i=1; i<=quant; i++){
			document.getElementById('m'+grp+''+i).style.display = 'block';			
		}
	}else{ //desabilita
		for(i=1; i<=quant; i++){
			document.getElementById('m'+grp+''+i).style.display = 'none';			
		}
	}
}

//##########################################################################################
function ocuIndicadoAux(elem){
	if(elem.checked == false){
		document.getElementById('m51').style.display = 'none';
		document.getElementById('m91').style.display = 'none';
		document.getElementById('m92').style.display = 'none';
		document.getElementById('m93').style.display = 'none';		
		document.getElementById('m94').style.display = 'none';				
		document.getElementById('rad01').checked = false;				
		document.getElementById('rad02').checked = false;				
	}
}





//##########################################################################################
function valLembrarSenha(form){
	if(document.getElementById('cpflogin1').value == ''){
		alert('Informe o número do CPF');	
		//document.getElementById('cpflogin1').focus();
		return false;
	}	
	s = limpa_string(document.getElementById('cpflogin1').value);
	if (valida_CPF(document.getElementById('cpflogin1').value) == false ){
		alert("CPF inválido");
		//document.getElementById('cpflogin1').focus();
		return false;
	}
	doc = eval('document.'+form);
	doc.action = "lembrasenha.php";
	doc.submit();
}


//##########################################################################################
function validarLogin1(form){
	if(document.getElementById('cpflogin1').value == ''){
		alert('CPF: preenchimento obrigatório');	
		//document.getElementById('cpflogin1').focus();
		return false;
	}	
	s = limpa_string(document.getElementById('cpflogin1').value);
		if (valida_CPF(document.getElementById('cpflogin1').value) == false ){
	   	alert("CPF inválido");
		 	//document.getElementById('cpflogin1').focus();
		   return false;
		}
	if(document.getElementById('senhalogin1').value == ''){
		alert('Senha: preenchimento obrigatório');	
		//document.getElementById('senhalogin1').focus();
		return false;
	}	
	doc = eval('document.'+form);
	doc.submit();	
}
//##########################################################################################
function validarLogin2(form){
	if(document.getElementById('cpflogin2').value == ''){
		alert('CPF: preenchimento obrigatório');	
		//document.getElementById('cpflogin2').focus();
		return false;
	}	
	s = limpa_string(document.getElementById('cpflogin2').value);
	if (valida_CPF(document.getElementById('cpflogin2').value) == false ){
		alert("CPF inválido");
		//document.getElementById('cpflogin2').focus();
		return false;
	}
	if(document.getElementById('senhalogin2').value == ''){
		alert('Senha: preenchimento obrigatório');	
		//document.getElementById('senhalogin2').focus();
		return false;
	}		
	if(document.getElementById('senhalogin2').value != document.getElementById('rsenhalogin2').value){
		alert('Senhas não conferem.')
		return false;
	}
	if(document.getElementById('emaillogin2').value == ''){
		alert('Email: preenchimento obrigatório');	
		//document.getElementById('emaillogin2').focus();
		return false;
	}
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emaillogin2').value)))	{
		alert(document.getElementById('emaillogin2').value+" não é um e-mail válido.") ;
		//document.getElementById('emaillogin2').focus();
		return false;
	}	
	doc = eval('document.'+form);
	doc.submit();
}
//##########################################################################################
function limpa_string(S)
{
// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	for (var i=0; i<S.length; i++)
	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)
		{
			temp=temp+digito
		}
	}
	return temp
}
//##########################################################################################
function valida_CPF(s)
{
	var i;
	s = limpa_string(s);
	var comp = 00000000000;
	for (i=0; i<=9; i++)
	{
		if(s == comp)
		{
			return false;
		}
		comp = comp + 11111111111; 
	}
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
    if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}
//##########################################################################################
function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var comp = 00000000000000;
	for (i=0; i<=9; i++)
	{
		if(s == comp)
		{
			return false;
		}
		comp = comp + 11111111111111; 
	}	
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}
//##########################################################################################
