$(document).ready(function() { $('input[type=text],input[type=password],textarea').keyup(function() { if($(this).val().length > 0) $(this).css({borderColor:'#dbdfdb'}); }); }); values = ''; function getCheckboxValues(name) { $('input[type=checkbox][name='+name+']:checked').each(function() { if($(this).val()!='Outro') { if(values == '') values += $(this).val(); else values += ', '+$(this).val(); } else { values += ', '+$('#'+name+'_outro').val(); } }); temp = values; values = ''; return temp; } value = ''; function getRadioValue(name) { $('input[type=radio][name='+name+']:checked').each(function() { if($(this).val()!='Outro') value = $(this).val(); else if(value != '') value = ', '+$('#'+name+'_Outro').val(); else value = $('#'+name+'_Outro').val(); }); temp = value; value = ''; return temp; } tipo=''; msg =''; function setFocus(id) { $('#'+id).css({borderColor:"#FF0000"}); $('#'+id).focus(); } function finishAjax(response) { if(response == 1) { //window.location = '/cadastro/ok/'+tipo; if(msg=='') alert('Mensagem enviada com sucesso!'); else alert(msg); $('form').each(function() { this.reset(); }); } else { var err = response.split(','); alert(err[1]); setFocus(err[2]); } } endereco = ''; function envia_contato() { $.post("/contato/enviar", { nome: $('#nome').val(), empresa: $('#empresa').val(), email: $('#email').val(), telefone: $('#telefone').val(), cidade: $('#cidade').val(), estado: $('#estado').val(), mensagem: $('#mensagem').val(), departamento: $('#departamento').val() }, function(response) { finishAjax(response); }); return false; } function validaReservas() { ok = ''; $.post("/reservas/", { dt_check_in: $('#check_in').val(), dt_check_out: $('#check_out').val(), adultos: $('#adultos').val(), criancas: $('#criancas').val(), valida: 1 }, function(response) { if(response != 1) finishAjax(response); else document.form_reserva.submit(); }); //if(ok == 1) return true; return false; } function validaNews() { $.post("/home/news", { nome: $('#nome').val(), email: $('#email').val(), aniversario: $('#aniversario').val() }, function(response) { msg = 'Cadastro efetuado com sucesso!'; finishAjax(response); }); return false; } function removerNews() { $.post("/home/removerNews", { nome: $('#nome').val(), email: $('#email').val(), aniversario: $('#aniversario').val() }, function(response) { msg = 'E-mail removido com sucesso!'; finishAjax(response); }); return false; } function enviaReservas() { ok = ''; $.post("/reservas/enviar", { check_in: $('#check_in').val(), check_out: $('#check_out').val(), adultos: $('#adultos').val(), criancas: $('#criancas').val(), nome: $('#nome').val(), endereco: $('#endereco').val(), complemento: $('#complemento').val(), bairro: $('#bairro').val(), cidade: $('#cidade').val(), pais: $('#pais').val(), estado: $('#estado').val(), cpf: $('#cpf').val(), telefone: $('#telefone').val(), email: $('#email').val(), comentarios: $('#comentarios').val() }, function(response) { finishAjax(response); }); //if(ok == 1) return true; return false; }