function AbreFotos(obj) {
	document.getElementById("i_frame").src = obj.href;
	document.getElementById("fundoopaco").style.display = 'block';
	document.getElementById('fundoopaco').style.height = '1005px';
	document.getElementById('fundoopaco').style.width = '980px';
}

function Fechar(objid) {
	document.getElementById(objid).style.display = 'none';
}

function DigitaData(campo) {
	var data = new String( campo.value );
	var wData = '';
	var cont = 0;

	for (i=0; i<data.length ; i++) {
		if (i <= 1) {
			if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' ) {
				wData += data.charAt(i);
			} else {
			cont++;
			}
		}
		if (i == 2) { 
			if ( data.charAt(i) == '/' ) {
				wData += data.charAt(i);
			} else {
				if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' ) {
					wData += '/';
					wData += data.charAt(i);
					cont ++;
				} else {
					wData += '/'; 
					cont ++;
				}
			}
		}
		if (i > 2 && i <= 4) {
			if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' ) {
				wData += data.charAt(i);
			} else {
				cont++;
			}
		} 
		if (i == 5) { 
			if ( data.charAt(i) == '/' ) {
				wData += data.charAt(i);
			} else {
				if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' ) {
					wData += '/';
					wData += data.charAt(i);
					cont++;
				} else {
					wData += '/';
					cont++;
				}
			}
		}
		if (i > 5 && i <= 9) {
			if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' ) {
				wData += data.charAt(i);
			} else {
				cont++;
			}
		}

		if (i > 9 ) {
			cont++;
		} 
	}
	if ( cont > 0 ) {
		campo.value = wData;
	}
} 

function DigitaCep() {
	var wData =  document.form1.cep.value;
	var s = document.form1.cep.value;
	
    if (event.keyCode != 8) {
		if (document.form1.cep.value.length == 5) {
	 		if (s.charAt(document.form1.cep.value-1) != "-") {
	 			wData = s.slice(0, document.form1.cep.value-1)+"-"+
				s.slice(5, 1);
			}
		}
	}
	document.form1.cep.value = wData;	
} 

function Verifica_CPF(campo) {
var CPF = campo.value; 
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = CPF.substr(9, 2); 
for (I=0; I<=8; I++) {
  DIGITO[I] = CPF.substr( I, 1);
}
POSICAO = 10;
SOMA = 0;
   for (I=0; I<=8; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
}
   else{
       DIGITO[9] = 11 - DIGITO[9];
}
POSICAO = 11;
SOMA = 0;
   for (I=0; I<=9; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[10] = SOMA % 11;
   if (DIGITO[10] < 2) {
        DIGITO[10] = 0;
   }
   else {
        DIGITO[10] = 11 - DIGITO[10];
   }
DV = DIGITO[9] * 10 + DIGITO[10];
   if (DV != DV_INFORMADO) {
      return 0;
   }  else {
      return 1;
   }
}

function verificados() {
	if (document.form1.rg.value.length == 0) {
		alert("É obrigatório o preenchimento do RG !");
		document.form1.rg.focus();
		return false;
	}
	if (document.form1.rgorgao.value.length == 0) {
		alert("É obrigatório o preenchimento do Orgão Expeditor do RG !");
		document.form1.rgorgao.focus();
		return false;
	}
	if (document.form1.rguf.value == "E") {
		alert("É obrigatório a informação da UF onde foi expedida a RG !");
		document.form1.estadocivil.focus();
		return false;
	}
	if (document.form1.nome.value.length == 0) {
		alert("É obrigatório o preenchimento do Nome !");
		document.form1.nome.focus();
		return false;
	} else {
		n=document.form1.nome.value.indexOf(' ');
		if (n<1 || n==(document.form1.nome.value.length-1)) {
			alert("Sobrenome não informado!");
			document.form1.nome.focus();
			return false;
		}
	}
	if (document.form1.cpf.value.length == 0) {
		alert("É obrigatório o preenchimento do CPF do Candidato !");
		document.form1.cpf.focus();
		return false;
	} else {
      if (Verifica_CPF(document.form1.cpf) == 0) {
			alert("CPF do Candidato informado está incorreto!");
		    document.form1.cpf.focus();
		    return false;	 
	  }
	}
	if (document.form1.nascimento.value.length == 0) {
		alert("É obrigatório o preenchimento da Data de Nascimento !");
		document.form1.nascimento.focus();
		return false;
	} else {
		if (document.form1.nascimento.value.length != 10) {
			alert("Data de Nascimento inválida !");
			document.form1.nascimento.focus();
			return false;}
	}
	if (document.form1.sexo.value == "E") {
		alert("É obrigatório a informação de seu Sexo !");
		document.form1.sexo.focus();
		return false;
	}
	if (document.form1.estadocivil.value == "E") {
		alert("É obrigatório a informação de seu Estado Civil !");
		document.form1.estadocivil.focus();
		return false;
	}
	if (document.form1.logradouro.value.length == 0) {
		alert("É obrigatório o preenchimento do Logradouro (Rua ou Avenida) !");
		document.form1.logradouro.focus();
		return false;
	}
	if (document.form1.numero.value.length == 0) {
		alert("É obrigatório o preenchimento do número de endereço !");
		document.form1.numero.focus();
		return false;
	}
	if (document.form1.bairro.value.length == 0) {
		alert("É obrigatório o preenchimento do Bairro !");
		document.form1.bairro.focus();
		return false;
	}
	if (document.form1.uf.value == "E") {
		alert("É obrigatório a informação da UF do endereço !");
		document.form1.uf.focus();
		return false;
	}
	if (document.form1.cidade.value.length == 0) {
		alert("É obrigatório o preenchimento da Cidade !");
		document.form1.cidade.focus();
		return false;
	}
	if (document.form1.cep.value.length == 0) {
		alert("É obrigatório o preenchimento do CEP !");
		document.form1.cep.focus();
		return false;
	}
	if (document.form1.email.value.length != 0) {
		p=document.form1.email.value.indexOf('@');
		if (p<1 || p==(document.form1.email.value.length-1)) {
			alert("O E-mail não é válido!");
			document.form1.email.focus();
			return false;}
	}
	if (document.form1.cidadenascimento.value.length == 0) {
		alert("É obrigatório o preenchimento da Cidade onde nasceu !");
		document.form1.cidadenascimento.focus();
		return false;
	}
	if (document.form1.ufnascimento.value == "E") {
		alert("É obrigatório a informação da UF de nascimento !");
		document.form1.ufnascimento.focus();
		return false;
	}	
	return true;	
}

