﻿function trim(str){
	return str.replace(/^\s+|\s+$/g,"");
}

function isBlank(txtField){
  if (trim(txtField.value))
    return (false);
  else
    return(true);
}

function is_empty(inputStr) {
   if (inputStr == "")
      return true;
   else
      return false;
}
function is_pos_integer(inputVal) {
   if (!inputVal) return false;
   inputStr = inputVal.toString();
   var i, oneChar;
   for (i = 0; i < inputStr.lenght; i++) {
      oneChar = inputStr.charAt(i);
      if ((oneChar < "0") || (oneChar > "9"))
         return false;
   }
   return true;
}
function is_pos_numeric(inputVal) {
   if (!inputVal) return false;
   inputStr = inputVal.toString();
   var i, oneChar;
   for (i = 0; i < inputStr.lenght; i++) {
      oneChar = inputStr.charAt(i);
      if (((oneChar < "0") || (oneChar > "9")) && (oneChar != ",") && (oneChar != "."))
         return false;
   }
   return true;
}

// Validação do formulário "Trabalhe Conosco"
//valida form contato
function validaCurriculo(theForm){
	
	if (isBlank(theForm.fldNome)){
		alert("Preencha o Campo Nome.");
		return false;
	}
	
	if (isBlank(theForm.fldCidade)){
		alert("Preencha o Campo Cidade.");
		return false;
	}
	
	if (isBlank(theForm.fldBairro)){
		alert("Preencha o Campo Bairro.");
		return false;
	}
	
	if (isBlank(theForm.fldEmail)){
		alert("Preencha o Campo Email.");
		return false;
	}
	
	if (!isBlank(theForm.fldEmail)){				
		arroba = theForm.fldEmail.value.indexOf("@");
		ponto = theForm.fldEmail.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido!"); 
			return false;
		}						
	}
	
	if (isBlank(theForm.fldDtNascimento)){
		alert("Preencha o Campo Data de Nascimento.");
		return false;
	}
	
	if (isBlank(theForm.fldEndereco)){
		alert("Preencha o Campo Endereço.");
		return false;
	}
	
	if (isBlank(theForm.fldUf)){
		alert("Preencha o Campo UF.");
		return false;
	}
	
	if (isBlank(theForm.fldCep)){
		alert("Preencha o Campo CEP.");
		return false;
	}
	
	if (isBlank(theForm.fldTelefone)){
		alert("Preencha o Campo Telefone.");
		return false;
	}
	
	if (isBlank(theForm.fldNacionalidade)){
		alert("Preencha o Campo Nacionalidade.");
		return false;
	}
	
	return true;
}

// Validação do formulário "Profissionais"
//valida form contato
function validaProssional(theForm){
	
	if (isBlank(theForm.fldNome)){
		alert("Preencha o Campo Nome.");
		return false;
	}
	
	if (isBlank(theForm.fldEndereco)){
		alert("Preencha o Campo Endereço.");
		return false;
	}
	
	if (isBlank(theForm.fldCidade)){
		alert("Preencha o Campo Cidade.");
		return false;
	}
	
	if (isBlank(theForm.fldUf)){
		alert("Preencha o Campo UF.");
		return false;
	}
	
	if (isBlank(theForm.fldBairro)){
		alert("Preencha o Campo Bairro.");
		return false;
	}
	
	if (isBlank(theForm.fldCep)){
		alert("Preencha o Campo CEP.");
		return false;
	}
	
	if (isBlank(theForm.fldEmail)){
		alert("Preencha o Campo Email.");
		return false;
	}
	
	if (!isBlank(theForm.fldEmail)){				
		arroba = theForm.fldEmail.value.indexOf("@");
		ponto = theForm.fldEmail.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido!"); 
			return false;
		}						
	}
	
	if (isBlank(theForm.fldTelefone)){
		alert("Preencha o Campo Telefone.");
		return false;
	}
	
	if (isBlank(theForm.fldTelefoneFax)){
		alert("Preencha o Campo FAX.");
		return false;
	}
	
	if (isBlank(theForm.fldEmpresa)){
		alert("Preencha o Campo Empresa.");
		return false;
	}
	
	return true;
}

	  
// Validação do formulário Parceiros"
//valida form contato
function validaParceiro(theForm){
	
	if (isBlank(theForm.fldNome)){
		alert("Preencha o Campo Nome.");
		return false;
	}
	
	if (isBlank(theForm.fldCelular)){
		alert("Preencha o Campo Celular.");
		return false;
	}
	
	if (isBlank(theForm.fldDtNascimento)){
		alert("Preencha o Campo Data de Nascimento.");
		return false;
	}
	
	if (isBlank(theForm.fldEmail)){
		alert("Preencha o Campo Email.");
		return false;
	}
	
	if (!isBlank(theForm.fldEmail)){				
		arroba = theForm.fldEmail.value.indexOf("@");
		ponto = theForm.fldEmail.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido!"); 
			return false;
		}						
	}
	
	if (isBlank(theForm.fldEstadoCivil)){
		alert("Preencha o Campo Data de Estado Civil.");
		return false;
	}
	
	if (isBlank(theForm.fldEscolaridade)){
		alert("Preencha o Campo Escolaridade.");
		return false;
	}
	
	if (isBlank(theForm.fldCPF)){
		alert("Preencha o Campo CPF.");
		return false;
	}
	
	if (isBlank(theForm.fldProfissao)){
		alert("Preencha o Campo Profissão.");
		return false;
	}
	
	if (isBlank(theForm.fldEndereco)){
		alert("Preencha o Campo Endereço.");
		return false;
	}
	
	if (isBlank(theForm.fldEmpresa)){
		alert("Preencha o Campo Empresa.");
		return false;
	}
	
	if (isBlank(theForm.fldCidade)){
		alert("Preencha o Campo Cidade.");
		return false;
	}
	
	if (isBlank(theForm.fldUf)){
		alert("Preencha o Campo UF.");
		return false;
	}
	
	if (isBlank(theForm.fldTelefone)){
		alert("Preencha o Campo Telefone.");
		return false;
	}
	
	if (isBlank(theForm.fldRamo)){
		alert("Preencha o Campo Ramo.");
		return false;
	}
	
	if (isBlank(theForm.fldCargo)){
		alert("Preencha o Campo Cargo.");
		return false;
	}
	
	if (isBlank(theForm.fldTempoEmpresa)){
		alert("Preencha o Campo Tempo de Empresa.");
		return false;
	}
// RETIRADO POR SOLICITACAO DO CLIENTE (BRAGA - 13/07/2011	
//	if (isBlank(theForm.fldCidadeComercial)){
//		alert("Preencha o Campo Cidade Comercial.");
//		return false;
//	}
//	
//	if (isBlank(theForm.fldUfComercial)){
//		alert("Preencha o Campo UF Comercial.");
//		return false;
//	}
//	
//	if (isBlank(theForm.fldBairro)){
//		alert("Preencha o Campo Bairro.");
//		return false;
//	}
//	
//		if (isBlank(theForm.fldCep)){
//		alert("Preencha o Campo CEP.");
//		return false;
//	}
//		
//	if (isBlank(theForm.fldTelefoneComercial)){
//		alert("Preencha o Campo Telefone Comercial.");
//		return false;
//	}
//		
//	if (isBlank(theForm.fldCnpj)){
//		alert("Preencha o Campo CNPJ.");
//		return false;
//	}
//		
	return true;
}

function validaParametros (theForm){
	
	if (isBlank(theForm.email_contato)){
		alert("Preencha o Campo Email para receber contatos.");
		document.form1.email_contato.focus();
		return false;
	}
	
	if (!isBlank(theForm.email_contato)){				
		arroba = theForm.email_contato.value.indexOf("@");
		ponto = theForm.email_contato.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido no campo Email para receber contatos!");
			document.form1.email_contato.focus();
			return false;
		}						
	}
	
	if (isBlank(theForm.email_curriculo)){
		alert("Preencha o Campo Email para receber cadastros de currículos.");
		document.form1.email_curriculo.focus();
		return false;
	}
	
	if (!isBlank(theForm.email_curriculo)){				
		arroba = theForm.email_curriculo.value.indexOf("@");
		ponto = theForm.email_curriculo.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido no campo Email para receber cadastros de currículos!"); 
			document.form1.email_curriculo.focus();
			return false;
		}						
	}
	
	if (isBlank(theForm.email_parceiro)){
		alert("Preencha o Campo Email para receber cadastros de parceiros.");
		document.form1.email_parceiro.focus();
		return false;
	}
	
	if (!isBlank(theForm.email_parceiro)){				
		arroba = theForm.email_parceiro.value.indexOf("@");
		ponto = theForm.email_parceiro.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido no campo Email para receber cadastros de parceiros!");
			document.form1.email_parceiro.focus();
			return false;
		}						
	}
	
	if (isBlank(theForm.email_profissioanal)){
		alert("Preencha o Campo Email para receber cadastros de profissionais.");
		document.form1.email_profissioanal.focus();
		return false;
	}
	
	if (!isBlank(theForm.email_profissioanal)){				
		arroba = theForm.email_profissioanal.value.indexOf("@");
		ponto = theForm.email_profissioanal.value.indexOf(".");
		if (arroba == "-1" || ponto == "-1") { 
			alert("E-mail Invalido no campo Email para receber cadastros de profissionais!"); 
			document.form1.email_profissioanal.focus();
			return false;
		}						
	}
		
	return true;
}
