$("#siteBody").ready(function(){ var tam = (screen.width-900)/2; $("#siteBody").attr('style','position: absolute; top: 0; left: '+tam+'px; z-index: 1;'); }); function popup(page){ window.open(page,'page','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=1024,height=800'); } valida= { email: function(email) { if (email.length == 0 || email.indexOf('@') < 2) { return false; } else { var mail = email.split('@'); if (mail[1].length == 0 || mail[1].indexOf('.') < 2) { return false; } else { ail = mail[1].split('.'); var c = ail.length; for (i=1;i 1; i--) soma += numeros.charAt(10 - i) * i; resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; if (resultado != digitos.charAt(0)) return false; numeros = cpf.substring(0,10); soma = 0; for (i = 11; i > 1; i--) soma += numeros.charAt(11 - i) * i; resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; if (resultado != digitos.charAt(1)) return false; return true; } else return false; }, cnpj: function(cnpj) { var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais; digitos_iguais = 1; if (cnpj.length != 14) return false; for (i = 0; i < cnpj.length - 1; i++) if (cnpj.charAt(i) != cnpj.charAt(i + 1)) { digitos_iguais = 0; break; } if (!digitos_iguais) { tamanho = cnpj.length - 2; numeros = cnpj.substring(0,tamanho); digitos = cnpj.substring(tamanho); soma = 0; pos = tamanho - 7; for (i = tamanho; i >= 1; i--) { soma += numeros.charAt(tamanho - i) * pos--; if (pos < 2) pos = 9; } resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; if (resultado != digitos.charAt(0)) return false; tamanho = tamanho + 1; numeros = cnpj.substring(0,tamanho); soma = 0; pos = tamanho - 7; for (i = tamanho; i >= 1; i--) { soma += numeros.charAt(tamanho - i) * pos--; if (pos < 2) pos = 9; } resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; if (resultado != digitos.charAt(1)) return false; return true; } else return false; } }; $("#contato").ready(function(){ var nome = $("#nome"); var email = $("#email"); var telefone = $("#telefone"); var assunto = $("#assunto"); var mensagem = $("#mensagem"); telefone.mask('(99)9999-9999'); nome.blur(function(){ if(nome.val() == ''){ nome.attr('class','formerror'); } else { nome.attr('class','form'); } }); email.blur(function(){ if(!valida.email(email.val())){ email.attr('class','formerror'); } else { email.attr('class','form'); } }); telefone.blur(function(){ if(telefone.val() == '' || telefone.val() == '(__)____-____'){ telefone.attr('class','formerror'); } else { telefone.attr('class','form'); } }); assunto.blur(function(){ if(assunto.val() == ''){ assunto.attr('class','formerror'); } else { assunto.attr('class','form'); } }); mensagem.blur(function(){ if(mensagem.val() == ''){ mensagem.attr('class','formerror'); } else { mensagem.attr('class','form'); } }); $("#contato").submit(function(){ var nome = $("#nome"); var email = $("#email"); var telefone = $("#telefone"); var assunto = $("#assunto"); var mensagem = $("#mensagem"); if(nome.val() == ''){ alert('Preencha corretamente o campo NOME'); nome.focus(); return false; } if(!valida.email(email.val())){ alert('Preencha corretamente o campo E-MAIL'); email.focus(); return false; } if(telefone.val() == '' || telefone.val() == '(__)____-____'){ alert('Preencha corretamente o campo TELEFONE'); telefone.focus(); return false; } if(assunto.val() == ''){ alert('Preencha corretamente o campo ASSUNTO'); assunto.focus(); return false; } if(mensagem.val() == ''){ alert('Preencha corretamente o campo MENSAGEM'); mensagem.focus(); return false; } $.post( 'http://www.rubbosp.com.br/index.php/inicio/enviaContato', $("#contato").serialize(), function(response){ if (response.status=='ok'){ alert('Mensagem enviada com sucesso!'); nome.val(''); email.val(''); telefone.val(''); assunto.val(''); mensagem.val(''); } else { alert('Ocorreu algum erro durante o envio\nPor favor contate o administrador.'); } }, 'json' ); return false; }); });