// JavaScript Document

function MarcaMenu(Div)
{
	Div.style.color = "#000000";
}

function DesmarcaMenu(Div)
{
	Div.style.color = "#FFFFFF";
}

function EnviarEmail() 
{
	if (document.User.edt_Nome.value == "")
	{
		document.User.edt_Nome.style.backgroundColor = "#ffd3a0";
		document.User.edt_Nome.focus();
		return;				
	}
	else
	{
		document.User.edt_Nome.style.backgroundColor = "#ffffff";		
	}
	
	if (document.User.edt_Email.value == "")
	{
		document.User.edt_Email.style.backgroundColor = "#ffd3a0";
		document.User.edt_Email.focus();
		return;				
	}
	else
	{
		document.User.edt_Email.style.backgroundColor = "#ffffff";		
	}	
	
	if ((document.User.edt_Email.value == "") || 
		  (document.User.edt_Email.value.length > 0 && 
		  (document.User.edt_Email.value.indexOf("@",0) == - 1 || 
		   document.User.edt_Email.value.indexOf(".",0) == - 1))) 	
	{	
		document.User.edt_Email.style.backgroundColor = "#ffd3a0";
		alert("O [Email] informado não é válido ...");
		document.User.edt_Email.focus();		
		return;		
	}
	else
	{
		document.User.edt_Email.style.backgroundColor = "#ffffff";
	}	
	
	if (document.User.edt_Assunto.value == "")
	{
		document.User.edt_Assunto.style.backgroundColor = "#ffd3a0";
		document.User.edt_Assunto.focus();
		return;				
	}
	else
	{
		document.User.edt_Assunto.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.User.edt_Mensagem.value == "")
	{
		document.User.edt_Mensagem.style.backgroundColor = "#ffd3a0";
		document.User.edt_Mensagem.focus();		
		return;		
	}
	else
	{
		document.User.edt_Mensagem.style.backgroundColor = "#ffffff";		
	}	
	
	with(document.User)
	{
		method = "post";
		action = "ContatoEnvia.asp";
		submit();
	}
}

function EnviarCurriculo() 
{
	if (document.Cadastro.edt_CPF.value == "")
	{
		document.Cadastro.edt_CPF.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_CPF.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_CPF.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.Cadastro.edt_CPF.value.length < 14)
	{
		document.Cadastro.edt_CPF.style.backgroundColor = "#ffd3a0";
		alert("Campo [CPF] preenchido incorretamente ...");
		document.Cadastro.edt_CPF.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_CPF.style.backgroundColor = "#ffffff";		
	}		
	
	if (document.Cadastro.edt_Nome.value == "")
	{
		document.Cadastro.edt_Nome.style.backgroundColor = "#ffd3a0";	
		document.Cadastro.edt_Nome.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Nome.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.Cadastro.edt_Nascimento.value == "")
	{
		document.Cadastro.edt_Nascimento.style.backgroundColor = "#ffd3a0";			
		document.Cadastro.edt_Nascimento.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Nascimento.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.Cadastro.edt_Nascimento.value.length < 8)
	{
		document.Cadastro.edt_Nascimento.style.backgroundColor = "#ffd3a0";
		alert("Campo [Data de Nascimento] preenchido incorretamente ...");
		document.Cadastro.edt_Nascimento.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Nascimento.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.Cadastro.Combo_Deficiente.value == "")
	{
		alert("Campo [Deficiente] não preenchido ...");
		document.Cadastro.Combo_Deficiente.focus();
		return;				
	}		
	
	if ((document.Cadastro.Radio_Sexo[0].checked == false) &&
			(document.Cadastro.Radio_Sexo[1].checked == false))
	{
		alert("Campo [Sexo] não preenchido ...");
		return;				
	}
	
	if (document.Cadastro.edt_Pai.value == "")
	{
		document.Cadastro.edt_Pai.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Pai.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Pai.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_Mae.value == "")
	{
		document.Cadastro.edt_Mae.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Mae.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Mae.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_Naturalidade.value == "")
	{
		document.Cadastro.edt_Naturalidade.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Naturalidade.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Naturalidade.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_Email.value == "")
	{
		document.Cadastro.edt_Email.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Email.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Email.style.backgroundColor = "#ffffff";		
	}
	
	if ((document.Cadastro.edt_Email.value == "") || 
		  (document.Cadastro.edt_Email.value.length > 0 && 
		  (document.Cadastro.edt_Email.value.indexOf("@",0) == - 1 || 
		   document.Cadastro.edt_Email.value.indexOf(".",0) == - 1))) 	
	{	
		document.Cadastro.edt_Email.style.backgroundColor = "#ffd3a0";		
		alert("O [Email] informado não é válido ...");
		document.Cadastro.edt_Email.focus();		
		return;		
	}
	else
	{
		document.Cadastro.edt_Email.style.backgroundColor = "#ffffff";		
	}	
	
	if (document.Cadastro.edt_TelRes.value == "")
	{
		document.Cadastro.edt_TelRes.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_TelRes.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_TelRes.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_Endereco.value == "")
	{
		document.Cadastro.edt_Endereco.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Endereco.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Endereco.style.backgroundColor = "#ffffff";		
	}												
	
	if (document.Cadastro.edt_Bairro.value == "")
	{
		document.Cadastro.edt_Bairro.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Bairro.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Bairro.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_Cidade.value == "")
	{
		document.Cadastro.edt_Cidade.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Cidade.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Cidade.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.Combo_Estado.value == "")
	{
		alert("Campo [Estado] não preenchido ...");
		document.Cadastro.Combo_Estado.focus();
		return;				
	}	
	
	if (document.Cadastro.edt_CEP.value == "")
	{
		document.Cadastro.edt_CEP.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_CEP.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_CEP.style.backgroundColor = "#ffffff";		
	}
	
	if (document.Cadastro.edt_CEP.value.length < 9)
	{
		document.Cadastro.edt_CEP.style.backgroundColor = "#ffd3a0";		
		alert("Campo [CEP] preenchido incorretamente ...");
		document.Cadastro.edt_CEP.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_CEP.style.backgroundColor = "#ffffff";		
	}

	if (document.Cadastro.edt_Cargo.value == "")
	{
		document.Cadastro.edt_Cargo.style.backgroundColor = "#ffd3a0";		
		document.Cadastro.edt_Cargo.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Cargo.style.backgroundColor = "#ffffff";		
	}

	if (document.Cadastro.Combo_Areas.value == "")
	{
		alert("Campo [Áreas de Atuação] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Chk_Funcional[0].checked == false) &&
			(document.Cadastro.Chk_Funcional[1].checked == false) &&
			(document.Cadastro.Chk_Funcional[2].checked == false) &&
			(document.Cadastro.Chk_Funcional[3].checked == false) &&
			(document.Cadastro.Chk_Funcional[4].checked == false))
	{
		alert("Campo [Tipo de relação Funcional] não preenchido ...");

		return;				
	}

	if (document.Cadastro.Combo_Salario.value == "")
	{
		alert("Campo [Remuneração Atual/Última Mensal] não preenchido ...");
		document.Cadastro.Combo_Salario.focus();
		return;				
	}

	if (document.Cadastro.Combo_NivelProfissional.value == "")
	{
		alert("Campo [Nivel Profissional] não preenchido ...");
		document.Cadastro.Combo_NivelProfissional.focus();
		return;				
	}

	if ((document.Cadastro.Radio_Localidade[0].checked == false) &&
			(document.Cadastro.Radio_Localidade[1].checked == false) &&
			(document.Cadastro.Radio_Localidade[2].checked == false))
	{
		alert("Campo [Aceita ser transferido de localidade] não preenchido ...");
		return;				
	}

	if (document.Cadastro.Combo_NivelAcademico.value == "")
	{
		alert("Campo [Nível Acadêmico] não preenchido ...");
		document.Cadastro.Combo_NivelAcademico.focus();
		return;				
	}

//	if (document.Cadastro.Combo_Instituicoes.value == "")
//	{
//		alert("Campo [Instituição de ensino superior] não preenchido ...");
//		document.Cadastro.Combo_Instituicoes.focus();
//		return;				
//	}

//	if (document.Cadastro.Combo_Curso.value == "")
//	{
//		alert("Campo [Curso] não preenchido ...");
//		document.Cadastro.Combo_Curso.focus();
//		return;				
//	}

//	if (document.Cadastro.edt_Conclusao.value == "")
//	{
//		document.Cadastro.edt_Conclusao.style.backgroundColor = "#ffd3a0";		
//		document.Cadastro.edt_Conclusao.focus();
//		return;				
//	}
//	else
//	{
//		document.Cadastro.edt_Conclusao.style.backgroundColor = "#ffffff";		
//	}
	
	if (document.Cadastro.edt_Conclusao.value != "")
	{
	if (document.Cadastro.edt_Conclusao.value.length < 5)
		{
			document.Cadastro.edt_Conclusao.style.backgroundColor = "#ffd3a0";		
			alert("Campo [Conclusão] preenchido incorretamente ...");
			document.Cadastro.edt_Conclusao.focus();
			return;				
		}
		else
		{
			document.Cadastro.edt_Conclusao.style.backgroundColor = "#ffffff";		
		}
	}
	
	if (document.Cadastro.Combo_NivelIngles.value == "")
	{
		alert("Campo [Nível de Inglês] não preenchido ...");
		document.Cadastro.Combo_NivelIngles.focus();
		return;				
	}

	if (document.Cadastro.Combo_NivelEspanhol.value == "")
	{
		alert("Campo [Nível de Espanhol] não preenchido ...");
		document.Cadastro.Combo_NivelEspanhol.focus();
		return;				
	}

	if ((document.Cadastro.Radio_Word[0].checked == false) &&
			(document.Cadastro.Radio_Word[1].checked == false) &&
			(document.Cadastro.Radio_Word[2].checked == false) &&			
			(document.Cadastro.Radio_Word[3].checked == false))
	{
		alert("Campo [Conhecimentos - Word] não preenchido ...");
		return;				
	}
	
	if ((document.Cadastro.Radio_Excel[0].checked == false) &&
			(document.Cadastro.Radio_Excel[1].checked == false) &&
			(document.Cadastro.Radio_Excel[2].checked == false) &&			
			(document.Cadastro.Radio_Excel[3].checked == false))
	{
		alert("Campo [Conhecimentos - Excel] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_PPT[0].checked == false) &&
			(document.Cadastro.Radio_PPT[1].checked == false) &&
			(document.Cadastro.Radio_PPT[2].checked == false) &&			
			(document.Cadastro.Radio_PPT[3].checked == false))
	{
		alert("Campo [Conhecimentos - Power Point] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_SQL[0].checked == false) &&
			(document.Cadastro.Radio_SQL[1].checked == false) &&
			(document.Cadastro.Radio_SQL[2].checked == false) &&			
			(document.Cadastro.Radio_SQL[3].checked == false))	
	{
		alert("Campo [Conhecimentos - SQL] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_SAP[0].checked == false) &&
			(document.Cadastro.Radio_SAP[1].checked == false) &&
			(document.Cadastro.Radio_SAP[2].checked == false) &&			
			(document.Cadastro.Radio_SAP[3].checked == false))	
	{
		alert("Campo [Conhecimentos - SAP] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_VB[0].checked == false) &&
			(document.Cadastro.Radio_VB[1].checked == false) &&
			(document.Cadastro.Radio_VB[2].checked == false) &&			
			(document.Cadastro.Radio_VB[3].checked == false))		
	{
		alert("Campo [Conhecimentos - Visual Basic] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_Net[0].checked == false) &&
			(document.Cadastro.Radio_Net[1].checked == false) &&
			(document.Cadastro.Radio_Net[2].checked == false) &&			
			(document.Cadastro.Radio_Net[3].checked == false))		
	{
		alert("Campo [Conhecimentos - .Net] não preenchido ...");
		return;				
	}

	if ((document.Cadastro.Radio_ASP[0].checked == false) &&
			(document.Cadastro.Radio_ASP[1].checked == false) &&
			(document.Cadastro.Radio_ASP[2].checked == false) &&			
			(document.Cadastro.Radio_ASP[3].checked == false))		
	{
		alert("Campo [Conhecimentos - ASP] não preenchido ...");
		return;				
	}
	
	if (document.Cadastro.edt_Curriculo.value == "")
	{
		document.Cadastro.edt_Curriculo.style.backgroundColor = "#ffd3a0";		
		alert("Campo Currículo não preenchido ...");
		document.Cadastro.edt_Curriculo.focus();
		return;				
	}
	else
	{
		document.Cadastro.edt_Curriculo.style.backgroundColor = "#ffffff";		
	}
		
	with(document.Cadastro)
	{
		method = "post";
		action = "CadastroEnvia.asp";
		submit();
	}
}

function formata_data( x, tecla)
{
	separador = "/";
			
	tecla = tecla.keyCode;
			
	valor = x.value.split('');
	formatado = "";
			
	i = 0;
			
	while( i < valor.length)
	{
		caractere = valor[i];
		numeros = /^\d+$/;
		
		if(numeros.test(caractere) || caractere == separador)
		{
			formatado += String(caractere);
		}
		
		if((formatado.length == 2 || formatado.length == 5 ) && tecla != 8 )
		{
			formatado += separador; i++;
		}
							
		i++;
	}
			
	x.value = formatado;
}

function formata_conclusao( x, tecla)
{
	separador = "/";
			
	tecla = tecla.keyCode;
			
	valor = x.value.split('');
	formatado = "";
			
	i = 0;
			
	while( i < valor.length)
	{
		caractere = valor[i];
		numeros = /^\d+$/;
		
		if(numeros.test(caractere) || caractere == separador)
		{
			formatado += String(caractere);
		}
		
		if((formatado.length == 2 ) && tecla != 4 )
		{
			formatado += separador; i++;
		}
							
		i++;
	}
			
	x.value = formatado;
}

function formata_cep( x, tecla)
{
	separador = "-";
			
	tecla = tecla.keyCode;
			
	valor = x.value.split('');
	formatado = "";
			
	i = 0;
			
	while( i < valor.length)
	{
		caractere = valor[i];
		numeros = /^\d+$/;
		
		if(numeros.test(caractere) || caractere == separador)
		{
			formatado += String(caractere);
		}
		
		if((formatado.length == 5 ) && tecla != 8 )
		{
			formatado += separador; i++;
		}
							
		i++;
	}
			
	x.value = formatado;
}

function formata_cpf( x, tecla)
{
	separador = ".";
	separador1 = "-";	
			
	tecla = tecla.keyCode;
			
	valor = x.value.split('');
	formatado = "";
			
	i = 0;
			
	while( i < valor.length)
	{
		caractere = valor[i];
		numeros = /^\d+$/;
		
		if(numeros.test(caractere) || caractere == separador)
		{
			formatado += String(caractere);
		}
		
		if(( formatado.length == 3 || formatado.length == 7 ) && tecla != 11 )
		{
			formatado += separador; i++;
		}
		
		if(( formatado.length == 11 ) && tecla != 11 )
		{
			formatado += separador1; i++;
		}		
							
		i++;
	}
			
	x.value = formatado;
}

function NumerosKeyPress(tecla)
{
  if(typeof(tecla) == 'undefined')
  
  var tecla = window.event; 
  var codigo = (tecla.which ? tecla.which : tecla.keyCode ? tecla.keyCode : tecla.charCode);

	if (codigo == '13' || codigo == '27' || codigo == '46' || codigo == '8' || codigo == '37' || codigo == '39')	
	{
    return true;
	}
	else if (codigo < '48' || codigo > '58')
	{
    return false;
	}  
}

function NumerosKeyDown()
{
  if (event.ctrlKey)
  {
    return false;
	}
	
	return true;
}

function Mascara(formato, keypress, objeto)
{
	campo = eval (objeto);

	// CEP
	if (formato == 'cep')
	{
		separador = '-'; 
		conjunto1 = 5;
		
		if (campo.value.length == conjunto1)
		{
			campo.value = campo.value + separador;
		}
	}
	
	// CPF
	if (formato == 'cpf')
	{
		separador = '.'; 
		separador1 = '-'; 
		conjunto1 = 3;
		conjunto2 = 7;
		conjunto3 = 11;
		
		if (campo.value.length == conjunto1)
		{
			campo.value = campo.value + separador;
		}

		if (campo.value.length == conjunto2)
		{
			campo.value = campo.value + separador;
		}
		
		if (campo.value.length == conjunto3)
		{
			campo.value = campo.value + separador1;
		}
	}
	
	// DATA
	if (formato == 'data')
	{
		separador = '/'; 
		conjunto1 = 2;
		conjunto2 = 5;
			
		if (campo.value.length == conjunto1)
		{
			campo.value = campo.value + separador;
		}
		if (campo.value.length == conjunto2)
		{
			campo.value = campo.value + separador;
		}
	}
	
	// CONCLUSÃO
	if (formato == 'conclusao')
	{
		separador = '/'; 
		conjunto1 = 2;
			
		if (campo.value.length == conjunto1)
		{
			campo.value = campo.value + separador;
		}
	}	
}

function Numeros(objeto)
{
	if (event.keyCode == '13')
	{
	}
	else if (event.keyCode < '48' || event.keyCode > '58')
	{
		alert('Digite apenas números!');
		event.keyCode = '127';
		objeto.focus();		
	}
}

function CampoFile()
{
	if (event.keyCode == '13')
	{
		alert('Selecione o arquivo pelo botão Procurar!');
		return false;
	}
	else if (event.keyCode < '57' || event.keyCode > '58') 
	{
		alert('Selecione o arquivo pelo botão Procurar!')
		return false;
	}
}
