// scripts globais

//valida envio de página por email
function SendAmigo(){
d = document.enviaAmigo;
if(d.nome1.value==''){
alert('O campo Seu Nome precisa ser preenchido!');
d.nome1.focus();
return false;
}
if(d.email1.value==''){
alert('O campo Seu Email precisa ser preenchido!');
d.email1.focus();
return false;
}
if(d.email1.value.length<7){
alert('O Seu Email precisa ser válido!');
d.email1.value='';
d.email1.focus();
return false;
}
if(d.email1.value.indexOf('@')==-1 || d.email1.value.indexOf('.')==-1){
alert('O Seu Email precisa ser válido!');
d.email1.value='';
d.email1.focus();
return false;
}
if(d.nome2.value==''){
alert('O campo Nome do seu amigo precisa ser preenchido!');
d.nome2.focus();
return false;
}
if(d.email2.value==''){
alert('O campo Email do seu amigo precisa ser preenchido!');
d.email2.focus();
return false;
}
if(d.email2.value.length<7){
alert('O Email do seu amigo precisa ser válido!');
d.email2.value='';
d.email2.focus();
return false;
}
if(d.email2.value.indexOf('@')==-1 || d.email2.value.indexOf('.')==-1){
alert('O Email do seu amigo precisa ser válido!');
d.email2.value='';
d.email2.focus();
return false;
}

}
//validação de cadastro de email para newsletter
function validaNews(){
d = document.newsletter;
if(d.nome.value=='' || d.nome.value=='Nome'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome</b> precisa ser preenchido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}
if(d.email.value=='' || d.email.value=='Email'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Email</b> precisa ser preenchido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.email.value.length<7){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

}
function fecharInfo(uid,campo){
$('#'+uid).fadeOut("slow");
campo.focus();
}
function fecharJanela(uid){
$("#"+uid).fadeOut("slow");
}

function validaCV(){
d = document.formcv;
if(d.nome.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome</b> precisa ser preenchido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}

if(d.email.value=='' || d.email.value=='Email'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Email</b> precisa ser preenchido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.email.value.length<7){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

if(d.telefone.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.telefone);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Telefone</b> precisa ser preenchido!</div>").fadeIn("slow");
d.telefone.focus();
return false;
}

if(d.file.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.file);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>É necessário anexar seu Currículo antes de prosseguir!</div>").fadeIn("slow");
d.file.focus();
return false;
}
if(d.soma.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.soma);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>Preencha o resultado da soma!</div>").fadeIn("slow");
d.soma.focus();
return false;
}
$('#barrinha').html('<img src=\'/imagens/ajax-loader.gif\' style=\'display:block;\' border=\'0\'>');
}

//validação de cadastro profissional
function validaCadastro(){
d = document.cadastro;

if(d.usuario.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.usuario);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Usuário</b> precisa ser preenchido!</div>").fadeIn("slow");
d.usuario.focus();
return false;
}
if(d.usuario.value.length<8){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.usuario);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Usuário</b> precisa<br>conter um valor de 8 a 16 caracteres!</div>").fadeIn("slow");
d.usuario.value='';
d.usuario.focus();
return false;
}

if(verificaChars(d.usuario.value)==1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.usuario);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Usuário</b> precisa<br>conter caracteres válidos!</div>").fadeIn("slow");
d.usuario.value='';
d.usuario.focus();
return false;
}

if(d.senha.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Senha</b> precisa ser preenchido!</div>").fadeIn("slow");
d.senha.focus();
return false;
}

if(d.senha.value.length<6 || d.senha.value=='123456' || d.senha.value=='012345' || d.senha.value=='000000' || d.senha.value=='111111' || d.senha.value=='222222' || d.senha.value=='333333' || d.senha.value=='444444' || d.senha.value=='555555' || d.senha.value=='666666' || d.senha.value=='777777' || d.senha.value=='888888' || d.senha.value=='999999' || d.senha.value=='654321' || d.senha.value=='543210'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a>No campo <b>Senha</b>, digite uma senha mais segura entre 6 e 16 caracteres.</div>").fadeIn("slow");
d.senha.value='';
d.senha.focus();
return false;
}
if(d.senha2.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha2);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Repita a Senha</b> precisa ser preenchido!</div>").fadeIn("slow");
d.senha2.focus();
return false;
}
if(d.senha.value!=d.senha2.value){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha2);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>As senhas precisam ser iguais!</div>").fadeIn("slow");
d.senha2.value='';
d.senha2.focus();
return false;
}

if(d.nome.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome Completo</b> precisa ser preenchido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}

if(verificaNome(d.nome.value=='')==1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome Completo</b> precisa ser válido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}


if(d.email.value=='' || d.email.value=='Email'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Email</b> precisa ser preenchido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.email.value.length<7){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.telefone.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.telefone);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Telefone</b> precisa ser preenchido!</div>").fadeIn("slow");
d.telefone.focus();
return false;
}

if(d.recaptcha_response_field.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.recaptcha_response_field);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Código de Segurança</b> precisa ser preenchido!</div>").fadeIn("slow");
d.recaptcha_response_field.focus();
return false;
}

}

//validação de atualização de cadastro profissional
function validaCadastroUp(){
d = document.cadastro;


if(d.senha.value!=''){
if(d.senha.value.length<6 || d.senha.value=='123456' || d.senha.value=='012345' || d.senha.value=='000000' || d.senha.value=='111111' || d.senha.value=='222222' || d.senha.value=='333333' || d.senha.value=='444444' || d.senha.value=='555555' || d.senha.value=='666666' || d.senha.value=='777777' || d.senha.value=='888888' || d.senha.value=='999999' || d.senha.value=='654321' || d.senha.value=='543210'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a>No campo <b>Senha</b>, digite uma senha mais segura entre 6 e 16 caracteres.</div>").fadeIn("slow");
d.senha.value='';
d.senha.focus();
return false;
}
if(d.senha2.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha2);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Repita a Senha</b> precisa ser preenchido!</div>").fadeIn("slow");
d.senha2.focus();
return false;
}
if(d.senha.value!=d.senha2.value){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.senha2);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>As senhas precisam ser iguais!</div>").fadeIn("slow");
d.senha2.value='';
d.senha2.focus();
return false;
}
}
if(d.nome.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome Completo</b> precisa ser preenchido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}

if(verificaNome(d.nome.value=='')==1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.nome);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Nome Completo</b> precisa ser válido!</div>").fadeIn("slow");
d.nome.focus();
return false;
}


if(d.email.value=='' || d.email.value=='Email'){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Email</b> precisa ser preenchido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.email.value.length<7){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}

if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.email);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O <b>Email</b> precisa ser válido!</div>").fadeIn("slow");
d.email.value='';
d.email.focus();
return false;
}
if(d.telefone.value==''){
$('#infoBox').html("<div class=\"alerta\"><a href=\"javascript:fecharInfo('infoBox',d.telefone);\" style=\"float:right; text-decoration:none;\"><img src=\"/imagens/fechar.gif\" alt=\"X\" title=\"Fechar Informação\" border=\"0\"></a><br>O campo <b>Telefone</b> precisa ser preenchido!</div>").fadeIn("slow");
d.telefone.focus();
return false;
}

}

function verificaChars(char) {
var caract = new RegExp(/^[0-9a-zA-Z\_\@\-]+$/i);
if(String(char).search(caract)!= -1)
return 0;
else
return 1;
}

function verificaNome(char) {
var caract = new RegExp(/^[a-zA-Z\ ]+$/i);
if(String(char).search(caract)!= -1)
return 0;
else
return 1;
}

function mostraFile(valor,id){

d = document.filiacao;

var text=valor.value;
if(text.length>45)
text = text.substr(0,35) + '...';
document.getElementById(id).innerHTML=text;	

if(d.file.value!='')
$( "form#filiacao" ).attr( "enctype", "multipart/form-data" ).attr( "encoding", "multipart/form-data" );
}
function mostraFileCurr(valor,id){

d = document.formcv;

var text=valor.value;
if(text.length>45)
text = text.substr(0,35) + '...';
document.getElementById(id).innerHTML=text;	

if(d.file.value!='')
$( "form#cadastro" ).attr( "enctype", "multipart/form-data" ).attr( "encoding", "multipart/form-data" );
}
//cadastro filiado
function validaFormFiliacao(){
d = document.filiacao;
$('#infoBox .alerta').hide();
if(d.nome.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEmpresa').show();
d.nome.focus();
return false;
}
if(d.nomef.value==''){
$('#infoBox').fadeIn("slow");
$('#infoFantasia').show();
d.nomef.focus();
return false;
}
if(d.cnpj.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCNPJ').show();
return false;
}
if(ValidaCNPJ(d.cnpj.value)!=1){
$('#infoBox').fadeIn("slow");
$('#infoCNPJ2').show();
return false;
}
if(d.email.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEmail').show();
return false;
}
if(d.email.value.length<7){
$('#infoBox').fadeIn("slow");
$('#infoEmail2').show();
d.email.value='';
return false;
}
if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').fadeIn("slow");
$('#infoEmail2').show();
d.email.value='';
return false;
}
if(d.senha.value==''){
$('#infoBox').fadeIn("slow");
$('#infoSenha').show();
d.senha.focus();
return false;
}
if(d.senha.value.length<6 || d.senha.value=='123456' || d.senha.value=='012345' || d.senha.value=='000000' || d.senha.value=='111111' || d.senha.value=='222222' || d.senha.value=='333333' || d.senha.value=='444444' || d.senha.value=='555555' || d.senha.value=='666666' || d.senha.value=='777777' || d.senha.value=='888888' || d.senha.value=='999999' || d.senha.value=='654321' || d.senha.value=='543210'){
$('#infoBox').fadeIn("slow");
$('#infoSenha2').show();
d.senha.value='';
d.senha.focus();
return false;
}
if(d.csenha.value==''){
$('#infoBox').fadeIn("slow");
$('#infoSenha3').show();
d.csenha.focus();
return false;
}
if(d.senha.value!=d.csenha.value){
$('#infoBox').fadeIn("slow");
$('#infoSenha4').show();
d.csenha.value='';
d.csenha.focus();
return false;
}

if(d.endereco.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEndereco').show();
d.endereco.focus();
return false;
}
if(d.numero.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCompl').show();
d.numero.focus();
return false;
}
if(d.cep.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCep').show();
d.cep.focus();
return false;
}
if(d.cidade.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCidade').show();
d.cidade.focus();
return false;
}
if(d.estado.value==''){
$('#infoBox').fadeIn("slow");
$('#infoUF').show();
d.estado.focus();
return false;
}
if(d.apresentacao.value==''){
$('#infoBox').fadeIn("slow");
$('#infoSobreEmpresa').show();
d.apresentacao.focus();
return false;
}
if(d.email2.value!=''){
	if(d.email2.value.length<7){
	$('#infoBox').fadeIn("slow");
	$('#infoEmail2a').show();
	d.email2.value='';
	d.email2.focus();
	return false;
	}
	if(d.email2.value.indexOf('@')==-1 || d.email2.value.indexOf('.')==-1){
	$('#infoBox').fadeIn("slow");
	$('#infoEmail2a').show();
	d.email2.value='';
	d.email2.focus();
	return false;
	}	
}
if(d.tel1.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel1').show();
d.tel1.focus();
return false;
}
if(d.tel1.value!='' && d.tel1_tipo.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel2').show();
d.tel1_tipo.focus();
return false;
}

if(d.tel2.value!='' && d.tel2_tipo.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel3').show();
d.tel2_tipo.focus();
return false;
}

if(d.file.value==''){
$('#infoBox').fadeIn("slow");
$('#infoArquivo').show();
return false;
}

if(d.soma.value==''){
$('#infoBox').fadeIn("slow");
$('#infoSoma').show();
d.soma.focus();
return false;
}

d.submit();
}

function exibeAlertaChars(){
$('#infoBox').fadeIn("slow");
$('#infoChars').show();
}

//atualização filiado
function validaFiliacaoNew(){
d = document.filiacao;
$('#infoBox .alerta').hide();
if(d.nome.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEmpresa').show();
d.nome.focus();
return false;
}
if(d.nomef.value==''){
$('#infoBox').fadeIn("slow");
$('#infoFantasia').show();
d.nomef.focus();
return false;
}
if(d.email.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEmail').show();
d.email.focus();
return false;
}
if(d.email.value.length<7){
$('#infoBox').fadeIn("slow");
$('#infoEmail2').show();
d.email.value='';
d.email.focus();
return false;
}
if(d.email.value.indexOf('@')==-1 || d.email.value.indexOf('.')==-1){
$('#infoBox').fadeIn("slow");
$('#infoEmail2').show();
d.email.value='';
d.email.focus();
return false;
}
if(d.senha.value!=''){
	if(d.senha.value.length<6 || d.senha.value=='123456' || d.senha.value=='012345' || d.senha.value=='000000' || d.senha.value=='111111' || d.senha.value=='222222' || d.senha.value=='333333' || d.senha.value=='444444' || d.senha.value=='555555' || d.senha.value=='666666' || d.senha.value=='777777' || d.senha.value=='888888' || d.senha.value=='999999' || d.senha.value=='654321' || d.senha.value=='543210'){
	$('#infoBox').fadeIn("slow");
	$('#infoSenha2').show();
	d.senha.value='';
	d.senha.focus();
	return false;
	}
	if(d.csenha.value==''){
	$('#infoBox').fadeIn("slow");
	$('#infoSenha3').show();
	d.csenha.focus();
	return false;
	}
	if(d.senha.value!=d.csenha.value){
	$('#infoBox').fadeIn("slow");
	$('#infoSenha4').show();
	d.csenha.value='';
	d.csenha.focus();
	return false;
	}
}
if(d.endereco.value==''){
$('#infoBox').fadeIn("slow");
$('#infoEndereco').show();
d.endereco.focus();
return false;
}
if(d.numero.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCompl').show();
d.numero.focus();
return false;
}
if(d.cep.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCep').show();
d.cep.focus();
return false;
}
if(d.cidade.value==''){
$('#infoBox').fadeIn("slow");
$('#infoCidade').show();
d.cidade.focus();
return false;
}
if(d.estado.value==''){
$('#infoBox').fadeIn("slow");
$('#infoUF').show();
d.estado.focus();
return false;
}
if(d.apresentacao.value==''){
$('#infoBox').fadeIn("slow");
$('#infoSobreEmpresa').show();
d.apresentacao.focus();
return false;
}
if(d.email2.value!=''){
	if(d.email2.value.length<7){
	$('#infoBox').fadeIn("slow");
	$('#infoEmail2a').show();
	d.email2.value='';
	d.email2.focus();
	return false;
	}
	if(d.email2.value.indexOf('@')==-1 || d.email2.value.indexOf('.')==-1){
	$('#infoBox').fadeIn("slow");
	$('#infoEmail2a').show();
	d.email2.value='';
	d.email2.focus();
	return false;
	}	
}
if(d.tel1.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel1').show();
d.tel1.focus();
return false;
}
if(d.tel1.value!='' && d.tel1_tipo.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel2').show();
d.tel1_tipo.focus();
return false;
}
if(d.tel2.value!='' && d.tel2_tipo.value==''){
$('#infoBox').fadeIn("slow");
$('#infoTel3').show();
d.tel2_tipo.focus();
return false;
}
d.submit();
}


function exibeAlertaChars(){
$('#infoBox').fadeIn("slow");
$('#infoChars').show();
}

//verifica CNPJ
function ValidaCNPJ(cnpj) {

  var i = 0;
  var l = 0;
  var strNum = "";
  var strMul = "6543298765432";
  var character = "";
  var iValido = 1;
  var iSoma = 0;
  var strNum_base = "";
  var iLenNum_base = 0;
  var iLenMul = 0;
  var iSoma = 0;
  var strNum_base = 0;
  var iLenNum_base = 0;

  if (cnpj == "")
	return (0);

  l = cnpj.length;
  for (i = 0; i < l; i++) {
	caracter = cnpj.substring(i,i+1)
	if ((caracter >= '0') && (caracter <= '9'))
	   strNum = strNum + caracter;
  };

  if(strNum.length != 14)
	return (0);

  strNum_base = strNum.substring(0,12);
  iLenNum_base = strNum_base.length - 1;
  iLenMul = strMul.length - 1;
  for(i = 0;i < 12; i++)
	iSoma = iSoma +
			parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
			parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
	iSoma = 0;

  strNum_base = strNum_base + iSoma;
  iSoma = 0;
  iLenNum_base = strNum_base.length - 1
  for(i = 0; i < 13; i++)
	iSoma = iSoma +
			parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
			parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10)

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
	iSoma = 0;
  strNum_base = strNum_base + iSoma;
  if(strNum != strNum_base)
	return (0);

  return (1);

}

function tem_numeros(texto){
var numeros="0123456789";
   for(i=0; i<texto.length; i++){
      if (numeros.indexOf(texto.charAt(i),0)!=-1){
         return 1;
      }
   }
   return 0;
} 

function val_chars(texto){
var chars="0123456789abcdefghijklmnopqrstuvwxizABCDEFGHIJKLMNOPQRSTUVWXYZ&$@#_";
var alphaExp = /^[a-zA-Z-0-9$@_&]+$/;  
   for(i=0; i<texto.length; i++){
      if (chars.indexOf(texto.charAt(i),0)!=-1 && texto.match(alphaExp)){
         return 1;
      }
   }
   return 0;
} 


//formatação máscara
function formatar(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;
    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "#") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } 
      else { // qualquer caracter...
        return true;
      } 
    }
    else {
      return true;
    }
  }

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = '0,00'; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf(',') < 0) { s += ',00'; }
	if(s.indexOf(',') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
function executaAcoesView(iddiv){
		$(iddiv).ready(function(){
            $('.mini').slideUp("slow");									
			$(iddiv).slideDown("slow");
		});
}
/*
 $(document).ready(function() {
            $("#meuspan").tooltip({ // Esta linha cria  tooltip e passa os paramentros abaixo
                track: true, // Para que possa se movimentar
                delay: 0, // Tempo de carregamento
                showBody: " - ", // o que esta dividindo o titulo e o conteudo
                top: -15, // Espaçamento do topo
                left: 5 // Espaçamento da direita
            });
        });
*/

$(function(){
			//var largura = screen.width;
			//var altura =  screen.height;
			var largura="100%";
			var altura="100%";
            $("#infoBox").css("width",largura);
			$("#infoBox").css("margin","0");
			  $("#infoBox").css("height",altura);
			   $("#infoBox").css("minHeight","1024");
			  $("#infoBox2").css("width",largura);
			  $("#infoBox2").css("height",altura);
			   $("#infoBox2").css("minHeight","1024")
			  $("#infoBox").css("margin","0");
        });
