/*** ENVIAR CONTATO ***/ $("#b_contato").ready(function () { $("body").append('
'); }); $("#frm_contato").ready(function() { $("#frm_contato").submit(function () { submitContato(); return false; }); }); $(".localizacao").ready(function () { $(".localizacao a.mapa").click(function () { $("#overlay").css("height",$(document).height() + "px"); $("#overlay").slideDown(300); $.get("/home/contato/mapaAjax", {}, function(retorno) { retorno = retorno.replace('id="mapa"','id="mapa" class="loading"'); $("body").append(retorno); $("#mapa img").load(function () { $(this).fadeIn(300); addCloseMapaEvent(); }); }); return false; }); }); function addCloseMapaEvent() { $("#mapa .bt_fechar").click(function () { $("#mapa").fadeOut(200, function() { $("#overlay").slideUp(300); $("#mapa").remove(); }); return false; }); } function submitContato() { $("#frm_contato fieldset .msg_sucesso").remove(); $("#frm_contato fieldset .msg_erro").remove(); $("#frm_contato fieldset").append("

enviando...

"); $("#frm_contato input.bt").attr("disabled","disabled"); $("#frm_contato input.bt").addClass("disabled"); var params = $('#frm_contato').serialize(); $.getJSON("/home/contato/enviarAjax", params, function(retorno) { if (retorno.err_nome) $("#err_nome").html(decodeText(retorno.err_nome)); else $('#err_nome').html(""); if (retorno.err_fone) $('#err_fone').html(decodeText(retorno.err_fone)); else $('#err_fone').html(""); if (retorno.err_email) $('#err_email').html(decodeText(retorno.err_email)); else $('#err_email').html(""); if (retorno.err_assunto) $('#err_assunto').html(decodeText(retorno.err_assunto)); else $('#err_assunto').html(""); if (retorno.err_msg) $('#err_msg').html(decodeText(retorno.err_msg)); else $('#err_msg').html(""); if (retorno.msg_erro) $("#frm_contato fieldset").append('
' + decodeText(retorno.msg_erro) + '
'); else $("#frm_contato fieldset .msg_erro").remove(); if (retorno.msg_sucesso) { if (retorno.msg_sucesso) { $("#nome").val(""); $("#empresa").val(""); $("#fone").val(""); $("#email").val(""); $("#assunto").val(""); $("#mensagem").val(""); } $("#frm_contato fieldset").append(''); $("#frm_contato fieldset .msg_sucesso").height($("#frm_contato fieldset").height() - parseInt($("#frm_contato fieldset .msg_sucesso").css("padding-top"))); $("#frm_contato fieldset .msg_sucesso").slideDown(200); } else { $("#frm_contato fieldset .msg_sucesso").remove(); } $("#frm_contato fieldset p.c_loading").remove(); $("#frm_contato input.bt").removeAttr("disabled"); $("#frm_contato input.bt").removeClass("disabled"); $("#frm_contato input.bt").focus(); }); }