﻿
   	    id_usu = "";
   	    nom_usu = "";
   	    id_tip_usu = "";
   	    fot_per = "";
   	    tipo_mural = "";
   	    tam = 0;
   	    
        
   	    $(document).ready(function () {

   	        $("#conteudo_eventos").hide();
   	        $("#conteudo_logado").hide();
   	        $("#logado").hide();
   	        $("body").ezBgResize({
   	            img: "images/fundo_home.jpg", // Relative path example.  You could also use an absolute url (http://...).
   	            opacity: 1, // Opacity. 1 = 100%.  This is optional.
   	            center: true // Boolean (true or false). This is optional. Default is true.
   	        });

   	        

   	    });

   	    function popAgenda(idAge, idDiv, destino) {
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/infoAgenda.aspx?id=' + idAge, {}, function (data) {
   	            if (data != "1") {
   	                if (destino == "infoAgenda") {
   	                   
   	                    $(idDiv).css("width", "700px");
   	                    $(idDiv).css("height", "400px");
   	                    $(idDiv).css("left", "50%");
   	                    $(idDiv).css("top", "50%");
   	                    $(idDiv).css("margin-left", "-350px");
   	                    $(idDiv).css("margin-top", "-200px");
   	                    $(idDiv).css("overflow-y", "scroll");
   	                }
   	                $(idDiv).slideUp(1000);
   	                $(idDiv).html(data);

   	                $(idDiv).slideDown(500);
   	                //Cufon.replace(idDiv);
   	                $("#loading").fadeOut(300);

   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	        
   	    }

   	    function fechaPopCoont() {
   	        $("#popConteudo").css("overflow", "hidden");
   	        $("#popConteudo").css("overflow-y", "hidden");
   	        $("#popConteudo").css("overflow-x", "hidden");
   	        $("#popConteudo").slideUp(500);
   	        $("#lightbox").fadeOut(500);
   	        $("#popConteudo").empty();
   	    }

   	    function popEventos(tipo) {
   	        limpa();
   	        // verific o tamanho
   	        tam = $(window).height();
            if (parseInt(tam) < 672) {
   	            $("#banners_bai").css("bottom", "-45px");
   	        }
   	        else {
   	            $("#banners_bai").css("bottom", "1px");
            }
   	        // teste d ebanners
            /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	            $("#banners_dir").fadeIn(1000);
   	        });
            */
   	        if (id_usu != "") {
   	            // apareco
   	            $(".pos_btn").show();
   	        } else {
   	            $(".pos_btn").hide();
            }
   	        
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $(".slider-wrap").show();

   	        $(".coda-slider-wrapper").hide();
   	        $("#xxx").html('');
   	        $("#xxx1").html('');
   	        $.post('ajax/agenda.aspx', { "tipo": tipo }, function (data) {
   	            if (data != "1") {
   	                $(".slider-wrap").show();
   	                $("#xxx").html(data);
   	                jQuery("div#slider1").codaSlider();
   	                //Cufon.replace(".fotoInterna");

   	                $("#lightbox").fadeOut(500);
   	                $("#loading").fadeOut(300, function () {
   	                   
                    });
   	                
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    ////////////////////////////////////////////////////////////////////////////////
        /// funcao que chama a pop do login
   	    function popLogin() {
   	        // teste d ebanners
   	        limpa()
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	        if (id_usu == "") {
   	            $("#popConteudo").empty();
   	            $("#lightbox").css("filter", "alpha(opacity=65)");
   	            $("#lightbox").fadeIn(500);
   	            $("#loading").fadeIn(300);
   	            $.post('ajax/formLogin.aspx', {}, function (data) {
   	                if (data != "1") {
   	                    /*
                        $("#popConteudo").css("left", "30%");
   	                    $("#popConteudo").css("width", "40%");
   	                    $("#popConteudo").css("height", "25%");
   	                    $("#popConteudo").css("top", "35%");
                        */
   	                    $("#popConteudo").css("width", "230px");
   	                    $("#popConteudo").css("height", "165px");
   	                    $("#popConteudo").css("left", "50%");
   	                    $("#popConteudo").css("top", "50%");
   	                    $("#popConteudo").css("margin-left", "-115px");
   	                    $("#popConteudo").css("margin-top", "-75px");
   	                    
   	                    $("#popConteudo").css("overflow", "hidden");
   	                    $("#popConteudo").slideDown(500);
   	                    $("#popConteudo").html(data);
   	                    Cufon.replace('#popConteudo');
   	                    $("#loading").fadeOut(300);
   	                   
   	                }
   	                else {
   	                    $("#loading").fadeOut(300);
   	                    $("#lightbox").fadeOut(500);
   	                    alert('Sistema temporariamente indisponível.')
   	                }

   	            });
   	        }
   	    }
   	    ///////////////////////////////////////////////////////////////////////////
   	    //// fim da popLogin
   	    ///////////////////////////////////////////////////////////////////////////

   	    ///////////////////////////////////////////////////////////////////////////
   	    //// funcao que efetua o login
   	    ///////////////////////////////////////////////////////////////////////////
   	    function doLogin() {
   	        var usu = $("#txtLogin").val();
   	        var sen = $("#txtSenha").val();
   	        if (usu == "" || sen == "") {
   	            alert('Digite seu usuário e senha corretamente!')
   	            return
   	        }
   	        else {
   	            $("#loading").fadeIn(300);
   	            $.ajax({
   	                type: "POST",
   	                url: "ajax/doLogin.aspx",
   	                data: { "usu": usu, "sen": sen },
   	                timeout: 10000,
   	                async: false,
   	                beforeSend: function () {
   	                    $("#lightbox").css("filter", "alpha(opacity=65)");
   	                    $("#lightbox").fadeIn(500);
   	                    $("#botao_logar").hide();
   	                },
   	                complete: function () {
   	                    $("#lightbox").fadeOut(500);
   	                    $("#loading").fadeOut(300);
   	                    $("#botao_logar").show();
   	                },
   	                cache: false,
   	                success: function (result) {
   	                    if (result != "1") {
   	                        var inf = result.split("||");
   	                        id_usu = inf[0];
   	                        nom_usu = inf[1];
   	                        id_tip_usu = inf[2];

   	                        // verifico se o usuario tem acesso a mes redonda

   	                        if (id_tip_usu != 3) {
   	                            $("#mesa").hide();
   	                        }

   	                        fot_per = inf[3];
   	                        $("#logado").fadeIn(500);
   	                        $("#conteudo_logado").fadeIn(500);
   	                        $("#popConteudo").slideUp(500);
   	                        $("#popConteudo").empty();

   	                        $("#foto_logado").html(fot_per);

   	                        $("#tit_logado").html('Bem vindo(a) ' + nom_usu + '!');
   	                        $("#tit_logado").addClass("titReplace");

   	                        //Cufon.replace('#conteudo_logado');
   	                        chamaInbox();
   	                        setInterval("chamaInbox()", 60000);
   	                        if (inf[4] > 60) {
   	                            alert("Sua senha não é trocada a mais de " + inf[4] + " dias, por favor efetue a troca na área de Perfil!");
   	                        }

   	                    }
   	                    else {
   	                        alert("Usuário não encontrado!");
   	                    }

   	                    $("#lightbox").fadeOut(500);
   	                    $("#botao_logar").show();


   	                },
   	                error: function (error) {

   	                    alert("Sistema temporariamente indisponível!");
   	                }
   	            });
   	        }
  	    }
   	    ///////////////////////////////////////////////////////////////////////////
   	    //// fim doLogin
  	    ///////////////////////////////////////////////////////////////////////////


  	    ///////////////////////////////////////////////////////////////////////////
  	    ////  funcao inbox
  	    ///////////////////////////////////////////////////////////////////////////
  	    function chamaInbox() {
  	        $("#inbox").html("Carregando...");
  	        Cufon.replace("#inbox");
  	        $.post('ajax/inbox.aspx', {}, function (data) {
  	            if (data != "1") {

  	                $("#inbox").html(data);
  	                //Cufon.replace("#inbox");
  	            }
  	            else {

  	                alert('Sistema temporariamente indisponível.')
  	            }

  	        });
  	    }
  	    ///////////////////////////////////////////////////////////////////////////
  	    ////  fim inbox
  	    ///////////////////////////////////////////////////////////////////////////
  	    ////////////////////

  	    function popPerfil() {
  	        limpa();
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formPerfil.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").css("width", "550px");
   	                $("#popConteudo").css("height", "420px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-280px");
   	                $("#popConteudo").css("margin-top", "-210px");
   	                $("#popConteudo").css("overflow-y", "scroll");
   	                $("#popConteudo").css("overflow-x", "hidden");
   	                $("#popConteudo").slideDown(500);
   	                $("#popConteudo").html(data);
   	                jQuery("div#slider1").codaSlider();
   	                //Cufon.replace('#popConteudo');
   	               
   	                $("#loading").fadeOut(300);
   	               
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });

   	    }

   	    ////////////////////
   	    function carrega() {
            // sumo com o botao de proximos passeio da agenda
   	        $(".pos_btn").hide();
   	        limpa();

   	        // verific o tamanho
   	        tam = $(window).height();
   	        if (parseInt(tam) < 672) {
   	            $("#banners_bai").css("bottom", "-45px");
   	        }
   	        else {
   	            $("#banners_bai").css("bottom", "1px");
   	        }
   	        $(".slider-wrap").hide();
   	        $(".coda-slider-wrapper").show();
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
            $("#loading").fadeIn(300);
            $("#xxx").html('');
            $("#xxx1").html('');
   	        $.post('ajax/fotos.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $(".coda-slider-wrapper").show();
   	                $("#xxx1").html(data);
   	                jQuery("div#coda-slider-2").codaSlider();
   	                //Cufon.replace(".fotoInterna");
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }

   	    function popFotos(idPass) {
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
            $("#loading").fadeIn(500);
   	        $.post('ajax/galeriafotos.aspx?id=' + idPass, {}, function (data) {
   	            if (data != "1") {

   	                $("#popConteudo").empty;
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("width", "880px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-440px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#loading").fadeOut(500);
   	                $("#popConteudo").html(data);
   	                $("#popConteudo").slideDown(500);
   	                
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
            // popconteudo w=90% l=5% h 75
   	    }

   	    //////////////////////////////////////////////
   	    //// popcontato
   	    //////////////////////////////////////////////
   	    function popContato() {
   	        limpa()
   	        // teste d ebanners
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	        $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formContato.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").empty;
   	                $("#popConteudo").css("height", "320px");
   	                $("#popConteudo").css("width", "700px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-350px");
   	                $("#popConteudo").css("margin-top", "-160px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace('#popConteudo');
   	                $("#loading").fadeOut(300);
   	                
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim popcontato
   	    //////////////////////////////////////////////

   	    /////////////////////////////////////////////
   	    //// busca do moral por data
   	    /////////////////////////////////////////////
   	    function busca_mural_data() {
   	        var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
   	        var msgErro = 'Digite uma data válida! Ex: 25/12/2000';
   	        if ($("#txtDe").val() != "" || $("#txtDe").val() != "") { 

                if (($("#txtDe").val().match(expReg)) && ($("#txtDe").val() != '')) {

   	            } else {
   	                alert(msgErro);
   	                $("#txtDe").focus();
   	                return;
   	            }

   	            if (($("#txtAte").val().match(expReg)) && ($("#txtAte").val() != '')) {

   	            } else {
   	                alert(msgErro);
   	                $("#txtAte").focus();
   	                return;
   	            }
   	        }
   	        $('#content_mural').html('');
   	        qtd = 0;
   	        mural(0, 10, tipo_mural, $("#txtDe").val(), $("#txtAte").val());
        }
   	    


   	    //////////////////////////////////////////////
   	    //// pop Mural
   	    //////////////////////////////////////////////
   	    var qtd = 0
   	    var calculando = 0;
   	    var total = 90000;
   	    function popMural(tipo) {
   	        limpa();
   	        tipo_mural = tipo;
   	        qtd = 0
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formMural.aspx?id='+tipo_mural, {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").empty;
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("width", "880px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-440px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").css("overflow-y", "hidden");
   	                $("#popConteudo").css("overflow-x", "hidden");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace('#popConteudo');
   	                $("#loading").fadeOut(300);
   	                mural(0, 10, tipo_mural,'','');
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    
   	    //////////////////////////////////////////////
   	    //// fim Mural
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    //// funcao que popula o mural
   	    //////////////////////////////////////////////
   	    

   	    function mural(ini, reg, tip, de, ate) {
   	        limpa();
   	        //$("#lightbox").fadeIn(500);
   	        //$("#popConteudo").slideDown(500);
   	        $("#loading").fadeIn(500);
   	        $.post('ajax/scrollMural.aspx?ini=' + qtd + '&reg=' + reg + '&tip=' + tip + '&de=' + de + '&ate=' + ate, {}, function (data) {
   	            var dados = data;
   	            var info = dados.split("||");
   	            $('#content_mural').append(info[0]);
   	            //Cufon.replace("#mural");
   	            total = info[1];
   	            calculando = 0;
   	            $("#loading").fadeOut(500);
   	        });


   	        $("#mural").scroll(function () {
   	          
   	            //document.getElementById("update").value = ($("#mural").scrollTop() + +$(document).height() - ($(document).height() - $("#mural").height())) + " " + $("#content_mural").height() + " " + $(document).height() + " " + ($(document).height() - $("#mural").height()) + " " + calculando + " " + total
   	            if (($("#mural").scrollTop() + $(document).height() - ($(document).height() - $("#mural").height())) > $("#content_mural").height() && calculando == 0 && qtd < total) {
   	                calculando = 1;
   	                qtd = qtd + 10;
   	                mural(qtd, 10, tip, $("#txtDe").val(), $("#txtAte").val());
   	            }
   	        });


   	    }
   	    //////////////////////////////////////////////
   	    //// fim funcao que popula o mural
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    //// limpa
   	    //////////////////////////////////////////////
   	    function limpa() {
   	        $(".slider-wrap").hide();
   	        $("#conteudo_eventos").empty();
   	        $("#conteudo_historia").empty();
   	        $("#banners_bai").css("bottom", "1px");
   	        
   	    }
   	    //////////////////////////////////////////////
   	    //// fim funcao limpa
   	    //////////////////////////////////////////////


   	    //////////////////////////////////////////////
   	    //// funcao contatos
   	    //////////////////////////////////////////////
   	    function contatos() {
   	        limpa();
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formContatos.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").css("width", "630px");
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-315px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	               
   	                $("#loading").fadeOut(300);
   	                
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim contatos
   	    //////////////////////////////////////////////


   	    //////////////////////////////////////////////
   	    // funcao atualiza perfil
   	    //////////////////////////////////////////////
   	    function atualizaPerfil() {
   	        
   	        var txtEmail = $("#txtEmail").val();
   	        var txtEndereco = $("#txtEndereco").val();
   	        var txtBairro = $("#txtBairro").val();
   	        var txtTelefone = $("#txtTelefone").val();
   	        var txtCelular = $("#txtCelular").val();
   	        var txtData = $("#txtData").val();
   	        var txtConvenio = $("#txtConvenio").val();
   	        var txtMoto = $("#txtMoto").val();
   	        var pro_usu = $("#pro_usu").val();

   	        var cpf = $("#cpf").val();
   	        var rg = $("#rg").val();
   	        var tip_san = $("#tip_san").val();
   	        var res_med = $("#res_med").val();

   	        var est_usu = $("#est_usu").val();
   	        var cid_usu = $("#cid_usu").val();
   	        var uf_nas = $("#uf_nas").val();
   	        var cid_nas = $("#cid_nas").val();

   	        if (txtEmail == "") {
   	            alert('Digite seu e-mail!')
   	            $("#txtEmail").focus();
   	            return
   	        }
   	        else {
   	            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txtEmail))) {
   	                alert("É necessário o preenchimento de um endereço de e-mail válido.");
   	                $("#txtEmail").focus();
   	                return false;
   	            }
   	        }

   	        if (txtEndereco == "") {
   	            alert('Digite seu endereço!')
   	            $("#txtEndereco").focus();
   	            return
   	        }

   	        if (txtBairro == "") {
   	            alert('Digite seu bairro!')
   	            $("#txtBairro").focus();
   	            return
   	        }

   	        if (txtTelefone == "") {
   	            alert('Digite seu telefone!')
   	            $("#txtTelefone").focus();
   	            return
   	        }

   	        if (txtCelular == "") {
   	            alert('Digite seu celular!')
   	            $("#txtCelular").focus();
   	            return
   	        }

   	        var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
   	        var msgErro = 'Digite uma data válida! Ex: 25/12/2000';
   	        if (($("#txtData").val().match(expReg)) && ($("#txtData").val() != '')) {

   	        } else {
   	            alert(msgErro);
   	            $("#txtData").focus();
   	            return;
   	        } 

   	        if (txtConvenio == "") {
   	            alert('Digite seu convênio!')
   	            $("#txtConvenio").focus();
   	            return
   	        }

   	        if (txtMoto == "") {
   	            alert('Digite sua moto!')
   	            $("#txtMoto").focus();
   	            return
   	        }


            /*
   	        var dataString //= "&chkMat=" + inf;

   	        dataString ="txtEmail="+txtEmail;
   	        dataString +="&txtEndereco="+txtEndereco;
   	        dataString +="&txtBairro="+txtBairro;
   	        dataString +="&txtTelefone="+txtTelefone;
   	        dataString +="&txtCelular="+txtCelular;
   	        dataString +="&txtData="+txtData;
   	        dataString +="&txtConvenio="+txtConvenio;
   	        dataString += "&txtMoto=" + txtMoto;
   	        dataString += "&pro_usu=" + pro_usu;

   	        dataString += "&cpf=" + cpf;
   	        dataString += "&rg=" + rg;
   	        dataString += "&tip_san=" + tip_san;
   	        dataString += "&res_med=" + res_med;
            */
   	        $.ajax({
   	            type: "POST",
   	            url: "ajax/atualizaPerfil.aspx",
   	            data: { "txtEmail": txtEmail, "txtEndereco": txtEndereco, "txtBairro": txtBairro, "txtTelefone": txtTelefone, "txtCelular": txtCelular, "txtData": txtData,
   	                "txtConvenio": txtConvenio, "txtMoto": txtMoto, "pro_usu": pro_usu, "cpf": cpf, "rg": rg, "tip_san": tip_san, "res_med": res_med, "est_usu": est_usu, "cid_usu": cid_usu,
   	                "uf_nas": uf_nas, "cid_nas": cid_nas
                 },
   	            cache: false,

   	            success: function (html) {

   	                if (html == "0") {

   	                    alert('Perfil atualizado com sucesso!')

   	                }
   	                else {
   	                    alert("Sistema temporariamente indispónível");
   	                }

   	            },
   	            error: function (xhr, er) {
   	                alert("Erro: " + xhr.status + " - " + xhr.statusText + " \n" + "Tipo de erro: " + er);
   	                $("#loading").fadeOut(300);

   	            }, beforeSend: function () {

   	                $("#loading").fadeIn(300);
   	            },
   	            complete: function () {
   	                $("#loading").fadeOut(300);
   	            }

   	        });
   	    }
        
   	    //////////////////////////////////////////////
   	    // fim funcao atualiza perfil
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    // funcao atualizaFoto
   	    //////////////////////////////////////////////
   	    function atualizaFoto() {
   	        $.ajax({
   	            type: "POST",
   	            url: "ajax/pegaFoto.aspx",
   	            data: {  },
   	            timeout: 10000,
   	            async: false,
   	            beforeSend: function () {
   	                $("#loading").fadeIn(300);
   	            },
   	            complete: function () {
   	                $("#loading").fadeOut(300);
   	            },
   	            cache: false,
   	            success: function (result) {
   	                if (result != "1") {
   	                    var image = "<img src='images/users/" + result + "' id='fotoPerfil'/>";
   	                    var imagelogado = "<img src='images/users/" + result + "'class='foto_perfil' id='fotoPerfil'/>";
   	                    $("#foto_upload").html(image);
   	                    $("#foto_logado").html(imagelogado);
   	                }
   	                else {

   	                }

   	            },
   	            error: function (error) {

   	                alert("Sistema temporariamente indisponível!");
   	            }
   	        });
   	        
   	    }
   	    //////////////////////////////////////////////
   	    // fim atualizaFoto
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    // funcao mensagens
   	    //////////////////////////////////////////////
   	    function popMensagem() {
   	        limpa();
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/scrollMensagem.aspx?inicio=0&registros=19', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").empty;
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("width", "880px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-440px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow-y", "scroll");
   	                $("#popConteudo").css("overflow-x", "hidden");
   	                $("#popConteudo").css("color", "#fff");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace('#popConteudo');
   	                $("#loading").fadeOut(300);

                    

   	                //mural(0, 10, tipo_mural);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }

   	    //////////////////////////////////////////////
   	    //  fim mensagens
   	    //////////////////////////////////////////////
   	    //// funcao que buusca as respostas das msgs
   	    function msgs(idMsg) {
   	        var ul = document.getElementById("msg_" + idMsg);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/respMsg.aspx?id=' + idMsg, {}, function (data) {
   	            if (data != "0" || data != 0) {
   	                $(ul).html(data)

   	                $("#loading").fadeOut(300);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }



   	    function adm() {
   	        limpa();
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/admfotos.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").empty;
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("width", "880px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-440px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow-y", "scroll");
   	                $("#popConteudo").css("overflow-x", "hidden");
   	                $("#popConteudo").css("color", "#fff");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace('#popConteudo');
   	                $("#loading").fadeOut(300);
   	                //mural(0, 10, tipo_mural);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });



   	    }
        //////////////////////////////////////////////////////////////////
        /// fuuncao abreBoxMsg() abre a caixa para selecionar os destnatarios
        /////////////////////////////////////////////////////////////////
   	    function abreBoxMsg() {
   	        $("#boxMsgUsuarios").toggle(500);
   	    }
        ////////////////////////////////////////////////////////////////
        /// fim abreBoxMsg();
   	    ////////////////////////////////////////////////////////////////


         //////////////////////////////////////////////////////////////////
        /// fuuncao abreBoxMsg() abre a caixa para selecionar os destnatarios
        /////////////////////////////////////////////////////////////////
   	    function envMsg() {
   	        var dest = $("#facebook-demo").val();
   	        var tit = document.getElementById("txtTitulo").value;
   	        var msg = document.getElementById("txtDscMsg").value;

   	        if (!tit) {
   	            alert("Digite o título da mensagem");
   	            return;
   	        }
   	        if (!msg) {
   	            alert("Digite uma mensagem");
   	            return;
   	        }


   	        if (dest != '') {
   	            $.post('ajax/gravaNovaMsg.aspx', { texto: msg, id: dest, tit: tit }, function (data) {

   	                if (data != "0") {
   	                    $("input").each(function (i) {
   	                        var nome = this.id;

   	                        if (nome.indexOf("facebook-demo") >= 0) {
   	                            //alert(this.value)
   	                            $("#loading").fadeIn(300);
   	                            $("#btnEnvMsg").attr("disabled", "disabled");
   	                            if (this.value != '') {
   	                                $.post('ajax/gravaMensResp.aspx', { texto: msg, id: this.value, idMsg: data }, function (data) {
   	                                    if (data != "0") {

   	                                    }
   	                                    else {
   	                                        $("#loading").fadeOut(300);
   	                                        $("#btnEnvMsg").attr("disabled", "");
   	                                        alert('Sistema temporariamente indisponível.')
   	                                    }

   	                                });
   	                            }
   	                        } else {
   	                            //this.style.color = "";
   	                        }
   	                    });
   	                    $("#loading").fadeOut(300);
   	                    $("#btnEnvMsg").attr("disabled", "");
   	                    alert('Mensagem enviada com sucesso!');
   	                    $("#boxMsgUsuarios").toggle(500);

   	                }
   	                else {
   	                    $("#loading").fadeOut(300);
   	                    $("#btnEnvMsg").attr("disabled", "");
   	                    alert('Sistema temporariamente indisponível.')
   	                    return
   	                }
   	                $
   	            });
   	          
   	        }


   	      

   	    }
        ////////////////////////////////////////////////////////////////
        /// fim abreBoxMsg();
   	    ////////////////////////////////////////////////////////////////

   	    //////////// funcao que grava e busca as msgs novamente
   	    function gravaResMsg(idMsg) {

   	        var ul = document.getElementById("respostas_" + idMsg);
   	        var texto = document.getElementById("txtResp_" + idMsg).value;
   	        var id = idMsg;
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/gravaRespMsg.aspx', { texto: texto, id: id }, function (data) {
   	            if (data != "0") {
   	                msgs(idMsg);


   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }



   	    ///////// funcao para se inscrever no passeio
   	    function insPasseio(id) {
   	        
   	        
   	        ///////////////////////////
   	        $.ajax({
   	            type: "POST",
   	            url: "ajax/gravaAgenda.aspx",
   	            data: { "id": id },
   	            timeout: 30000,
   	            async: false,
   	            beforeSend: function () {
   	                $("#ins_agenda a").attr("href", "#");
   	                $("#loading").fadeIn(300);
   	            },
   	            complete: function () {
   	               
   	                $("#loading").fadeOut(300);
   	            },
   	            cache: false,
   	            success: function (result) {
   	                if (result != "1") {
   	                    $("#ins_agenda").html("Você já se cadastrou para esse passeio.");

   	                    //Cufon.replace('#popConteudo');
   	                    $("#ins_agenda").attr("href", "#");
   	                }
   	                else {
   	                    alert("Sistema temporariamente indisponível!");
   	                }

   	              
   	              


   	            },
   	            error: function (error) {

   	                alert("Sistema temporariamente indisponível!");
   	            }
   	        });
   	    }


   	    /////////////////////////////////////
   	    // funcao que busca as imgs para adm
        // recebe o id do passeio como parametro
   	    ////////////////////////////////////
   	    function imgsAdm(idPas) {
   	        if ($("#ddlPasseio").val() != 'Selecione um Passeio') {
   	            
   	            $.ajax({
   	                type: "POST",
   	                url: "ajax/listaImgsPas.aspx",
   	                data: { "id": idPas },
   	                timeout: 10000,
   	                async: false,
   	                beforeSend: function () {
   	                    $("#loading").fadeIn(300);
   	                },
   	                complete: function () {
   	                    $("#loading").fadeOut(300);
   	                    $("#contUp").show();
   	                    //$('#uploadify').uploadifySettings('script', 'ajax/uploadGaleria.aspx?idUsu=<%=session("id_usu") %>&idPas=' + $("#ddlPasseio").val());
   	                    
   	                    //$("#contUp").attr("disabled", "disabled");
   	                },
   	                cache: false,
   	                success: function (result) {
   	                    if (result != "1") {
   	                        $("#divfotos").html(result);
   	                    }
   	                    else {
   	                        $("#divfotos").html('');
   	                    }

   	                },
   	                error: function (error) {

   	                    alert("Sistema temporariamente indisponível!");
   	                }
   	            });
   	        }
   	        else {
   	            
   	            $("#contUp").hide();
   	            $("#divfotos").empty();
   	        }

   	        
   	    }
   	    ////////////////////////////////////
   	    /// fim
   	    /////////////////////////////////////

   	    ///////////////////////////////////
   	    // funcao que deleta a imagem
   	    // recebendo como parametro o id da mesma
   	    ////////////////////////////////////
   	    function deletaImg(id) {
   	        var answer = confirm("Deseja realmente excluir essa foto?")
   	        // se sim
            if (answer) {
                
                $.ajax({
                    type: "POST",
                    url: "ajax/deletaImg.aspx",
                    data: { "id": id },
                    timeout: 10000,
                    async: false,
                    beforeSend: function () {
                        $("#loading").fadeIn(300);
                    },
                    complete: function () {
                        $("#loading").fadeOut(300);
                    },
                    cache: false,
                    success: function (result) {
                        if (result != "1") {
                            imgsAdm($("#ddlPasseio").val());
                        }
                        else {
                             
                        }

                    },
                    error: function (error) {

                        alert("Sistema temporariamente indisponível!");
                    }
                });
   	        }
   	        else {
   	            
   	        }
   	    }
   	    /////////////////////////////////////
   	    // fim
   	    /////////////////////////////////////

   	    //////////////////////////////////////////////
   	    //// funcao livrovisita
   	    //////////////////////////////////////////////
   	    function popLivroVisita() {
   	        // teste d ebanners
   	        limpa()
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formLivroVisitas.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").css("width", "630px");
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-315px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace("#popConteudo");
   	                $("#loading").fadeOut(300);

   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim livrovisita
   	    //////////////////////////////////////////////

   	    //////////////////////////////////
   	    function denunciaLivro(idLivro) {
   	        $("#loading").fadeIn(300);
   	        $("#lightbox").fadeIn(500);
   	        var ulFora = document.getElementById("livro_" + idLivro);

   	        $.post('ajax/denuncia_livro.aspx', { "id": idLivro }, function (data) {
   	            if (data != "1") {

   	                $(ulFora).empty();
   	                alert('Livro denunciado com sucesso!')
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });



   	    }

   	    //////////////////////////////////
   	    function denunciaClassificado(idLivro) {
   	        $("#loading").fadeIn(300);
   	        $("#lightbox").fadeIn(500);
   	        var ulFora = document.getElementById("cla_" + idLivro);

   	        $.post('ajax/denuncia_classificado.aspx', { "id": idLivro }, function (data) {
   	            if (data != "1") {

   	                $(ulFora).fadeOut();
   	                alert('Classificado denunciado com sucesso!')
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);

   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });



   	    }

   	    ////////////////////////////////////////////////////
   	    function gravaLivro() {
   	        var tudo = "";
   	        
   	        var txtNomeL = document.getElementById("txtNomeL").value;
   	        var txtTelefoneL = document.getElementById("txtTelefoneL").value;
   	        var txtCidadeL = document.getElementById("txtCidadeL").value;
   	        var txtEstadoL = document.getElementById("txtEstadoL").value;
   	        var txtMensagemL = document.getElementById("txtMensagemL").value;

   	        if (txtNomeL == "") {
   	            alert('Digite o seu nome!')
   	            $("#txtNomeL").focus();
                return
            }
            if (txtEstadoL == "") {
                alert('Digite o seu estado!')
                $("#txtEstadoL").focus();
                return
            }
            if (txtCidadeL == "") {
                alert('Digite a sua cidade!')
                $("#txtCidadeL").focus();
                return
            }
            

            if (txtTelefoneL == "") {
                alert('Digite o seu telefone!')
                $("#txtTelefoneL").focus();
                return
            }
            
            if (txtMensagemL == "") {
                alert('Digite o sua mensagem!')
                $("#txtMensagemL").focus();
                return
            }

   	        var botao = document.getElementById("btnLivro");

   	        cache: false;

   	        $(botao).attr("disabled", true);
   	        $(botao).val("Aguarde...")
   	        $("#loading").fadeIn(500);
   	        $.post('ajax/gravaLivro.aspx', { txtNomeL: txtNomeL, txtTelefoneL: txtTelefoneL, txtCidadeL: txtCidadeL, txtEstadoL: txtEstadoL, txtMensagemL: txtMensagemL
   	        }, function (data) {
   	            if (data != "0") { // verifico se deu certo
   	                var minhaData = new Date();
   	                $('#detalhes_livro').empty();
   	                dadosContatos(0, 10);

   	              
   	                document.getElementById("txtNomeL").value = "";
   	                document.getElementById("txtTelefoneL").value = "";
   	                document.getElementById("txtCidadeL").value = "";
   	                document.getElementById("txtEstadoL").value = "";
   	                document.getElementById("txtMensagemL").value = "";

   	                $(botao).attr("disabled", false);
   	                $(botao).val("Enviar")
   	                $("#loading").fadeOut(500);
   	                alert("Livro enviado com sucesso!")

   	            }
   	            else {
   	                alert('Sistema temporariamente indisponível.')
   	                $(botao).attr("disabled", false);
   	                $(botao).val("Enviar")
   	            }

   	        });

   	    }
   	    //////////////////////////////////////////////
   	    //// funcao classificados
   	    //////////////////////////////////////////////
   	    function popClassificados() {
   	        limpa()
   	        // teste d ebanners
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formClassificados.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").css("width", "630px");
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-315px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow", "hidden");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace("#popConteudo");
   	                $("#loading").fadeOut(300);

   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim classificados
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    //// funcao gravaClassificado
   	    //////////////////////////////////////////////
   	    function gravaClassificado() {
   	        var tudo = "";

   	        var txtNomeL = document.getElementById("txtNomeL").value;
   	        var txtEmailL = document.getElementById("txtEmailL").value;
   	        var txtDescL = document.getElementById("txtDescL").value;
   	        var txtPrecoL = document.getElementById("txtPrecoL").value;
   	         

   	        if (txtNomeL == "") {
   	            alert('Digite o seu nome!')
   	            $("#txtNomeL").focus();
   	            return
   	        }
   	        if (txtEmailL == "") {
   	            alert('Digite o seu e-mail!')
   	            $("#txtEmailL").focus();
   	            return
   	        }
   	        if (txtDescL == "") {
   	            alert('Digite a descrição!')
   	            $("#txtDescL").focus();
   	            return
   	        }


   	        if (txtPrecoL == "") {
   	            alert('Digite o preço!')
   	            $("#txtPrecoL").focus();
   	            return
   	        }

   	        
   	        var botao = document.getElementById("btnLivro");

   	        cache: false;

   	        $(botao).attr("disabled", true);
   	        $(botao).val("Aguarde...")
   	        $("#loading").fadeIn(500);
   	        $.post('ajax/gravaClassificado.aspx', { txtNomeL: txtNomeL, txtEmailL: txtEmailL, txtDescL: txtDescL, txtPrecoL: txtPrecoL
   	        }, function (data) {
   	            if (data != "0") { // verifico se deu certo
   	                var minhaData = new Date();
   	                $('#detalhes_livro').empty();
   	                dadosCla(0, 10);


   	                document.getElementById("txtNomeL").value = "";
   	                document.getElementById("txtEmailL").value = "";
   	                document.getElementById("txtDescL").value = "";
   	                document.getElementById("txtPrecoL").value = "";
   	               

   	                $(botao).attr("disabled", false);
   	                $(botao).val("Enviar")
   	                $("#loading").fadeOut(500);
   	                alert("Classificado enviado com sucesso!")

   	            }
   	            else {
   	                alert('Sistema temporariamente indisponível.')
   	                $(botao).attr("disabled", false);
   	                $(botao).val("Enviar")
   	            }

   	        });

   	    }
   	    //////////////////////////////////////////////
   	    //// fim gravaClassificado
   	    //////////////////////////////////////////////


   	    //////////////////////////////////////////////
   	    //// funcao popCadastro
   	    //////////////////////////////////////////////
   	    function popCadastro() {
   	        // teste d ebanners
   	        limpa()
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/formCadastro.aspx', {}, function (data) {
   	            if (data != "1") {
   	                $("#popConteudo").css("width", "630px");
   	                $("#popConteudo").css("height", "480px");
   	                $("#popConteudo").css("left", "50%");
   	                $("#popConteudo").css("top", "50%");
   	                $("#popConteudo").css("margin-left", "-315px");
   	                $("#popConteudo").css("margin-top", "-240px");
   	                $("#popConteudo").css("overflow-y", "auto");
   	                $("#popConteudo").slideDown(1000);
   	                $("#popConteudo").html(data);
   	                //Cufon.replace("#popConteudo");
   	                $("#loading").fadeOut(300);

   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim popCadastro
   	    //////////////////////////////////////////////

   	    //////////////////////////////////////////////
   	    //// funcao grava_motolcube
   	    //////////////////////////////////////////////
   	    function grava_motolcube() {
   	        var txtNomeL = document.getElementById("txtNomeL").value;
   	        var txtEstadoL = document.getElementById("txtEstadoL").value;
   	        var txtCidadeL = document.getElementById("txtCidadeL").value;
   	        var txtPres = document.getElementById("txtPres").value;
   	        var txtNumSoc = document.getElementById("txtNumSoc").value;
   	        var txtSite = document.getElementById("txtSite").value;
   	        var txtTelefoneL = document.getElementById("txtTelefoneL").value;
   	        var txtEmail = document.getElementById("txtEmail").value;
   	        var dta_ani_mot = document.getElementById("dta_ani_mot").value;
   	        var dta_reuniao = document.getElementById("dta_reuniao").value;
   	        var local_reuniao = document.getElementById("local_reuniao").value;
   	        var txtMensagemL = document.getElementById("txtMensagemL").value;


   	        if (txtNomeL == "") {
   	            alert('Digite o nome do motoclube!')
   	            $("#txtNomeL").focus();
   	            return
   	        }

            var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
   	        var msgErro = 'Digite uma data válida! Ex: 25/12/2000';
   	        if ($("#dta_ani_mot").val() != "") {
   	            if (($("#dta_ani_mot").val().match(expReg)) && ($("#dta_ani_mot").val() != '')) {

   	            } else {
   	                alert(msgErro);
   	                $("#dta_ani_mot").focus();
   	                return;
   	            }
   	            
            }

   	        if (txtEmail == "") {
   	            alert('Digite o seu e-mail!')
   	            $("#txtEmail").focus();
   	            return
   	        }
   	        if (txtMensagemL == "") {
   	            alert('Digite o sua mensagem!')
   	            $("#txtMensagemL").focus();
   	            return
   	        }
   	      



   	        $("#loading").fadeIn(300);
   	        $.post('ajax/emailCadastro.aspx', { txtNomeL: txtNomeL, txtEstadoL: txtEstadoL, txtCidadeL: txtCidadeL, txtPres: txtPres, txtNumSoc: txtNumSoc, txtSite: txtSite, txtTelefoneL: txtTelefoneL, txtEmail: txtEmail, txtMensagemL: txtMensagemL,
   	            dta_ani_mot: dta_ani_mot, dta_reuniao: dta_reuniao, local_reuniao: local_reuniao
   	        }, function (data) {
   	            if (data != "1") {

   	                $("#loading").fadeOut(300);
   	                alert('Motoclube cadastrado com sucesso!')
   	                
   	                $("#popConteudo").slideUp(1000);
   	                $("#popConteudo").empty();
   	                $("#lightbox").fadeOut(500);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);

   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }
   	    //////////////////////////////////////////////
   	    //// fim enviaEmail
   	    //////////////////////////////////////////////


   	    /*
   	    funcao que chama a historia
        */

   	    ////////////////////
   	    function popHistoria() {
   	        limpa();

   	        // verific o tamanho
   	        tam = $(window).height();
   	        if (parseInt(tam) < 672) {
   	            $("#banners_bai").css("bottom", "-25px");
   	        }
   	        else {
   	            $("#banners_bai").css("bottom", "1px");
   	        }
   	        // teste d ebanners
   	        /*
   	        $("#banners_bai").fadeOut(1000, function () {

   	        $("#banners_dir").fadeIn(1000);
   	        });
   	        */

   	 
   	        $("#lightbox").css("filter", "alpha(opacity=65)");
   	        $("#lightbox").fadeIn(500);
   	        $("#loading").fadeIn(300);
   	        $.post('ajax/historia.aspx', {}, function (data) {
   	            if (data != "1") {

   	                $("#conteudo_historia").html(data);
   	                $("#conteudo_historia").fadeIn(1000);
   	                
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	            }
   	            else {
   	                $("#loading").fadeOut(300);
   	                $("#lightbox").fadeOut(500);
   	                alert('Sistema temporariamente indisponível.')
   	            }

   	        });
   	    }

   	    /*
   	    funcao que altera a senha do usuario logado
        */
   	    function alteraSenha() {

   	        if ($("#txtSenhaAtu").val() == "") {
   	            alert("Digite a senha atual");
   	            return;
            }

            if ($("#txtNovaSenha").val() == "") {
                alert("Digite a senha nova");
                return;
            }
            if ($("#txtNovaSenha").val().length < 5) {
                alert("A senha deve ter no mínimo 5 caracteres!");
                return;
            } else {
                $("#loading").fadeIn(300);
                $.post('ajax/atualiza_senha.aspx', { "txtSenhaAtu": $("#txtSenhaAtu").val(), "txtNovaSenha": $("#txtNovaSenha").val() }, function (data) {
                    if (data != "1") {
                        if (data == "0") {
                            alert('Senha alterada com sucesso!')
                        }
                        // senha nao confere com a atual
                        if (data == "2") {
                            alert('Senha atual não confere!')
                        }
                        
                        $("#loading").fadeOut(300);
                    }
                    else {
                        $("#loading").fadeOut(300);
                        
                        alert('Sistema temporariamente indisponível.')
                    }

                });
            }
        }

        /*
        funcao que envia a senha para o usuario
        */
        function esqueci_senha() {
            if ($("#txtLogin").val() == "") {
                alert('Digite seu login!');
                $("#txtLogin").focus();
                return
            } else {
                $("#loading").fadeIn(300);
                $.post('ajax/envia_senha.aspx', { "txtLogin": $("#txtLogin").val() }, function (data) {
                    if (data != "1") {
                        if (data == "0") {
                            alert('Senha enviada com sucesso!')
                        }
                        // senha nao confere com a atual
                        if (data == "2") {
                            alert('Usuário não encontrado!')
                        }

                        $("#loading").fadeOut(300);
                    }
                    else {
                        $("#loading").fadeOut(300);

                        alert('Sistema temporariamente indisponível.')
                    }

                });
            }
        }

        // funcao que busca os aniversariantes
        function aniversarios(mes) {
            limpa();
            $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
            $("#loading").fadeIn(300);
            $.post('ajax/formAniversarios.aspx', {"mes":mes}, function (data) {
                if (data != "1") {
                    $("#popConteudo").css("width", "630px");
                    $("#popConteudo").css("height", "480px");
                    $("#popConteudo").css("left", "50%");
                    $("#popConteudo").css("top", "50%");
                    $("#popConteudo").css("margin-left", "-315px");
                    $("#popConteudo").css("margin-top", "-240px");
                    $("#popConteudo").css("overflow-y", "auto");
                    $("#popConteudo").slideDown(1000);
                    $("#popConteudo").html(data);
                    //Cufon.replace("#popConteudo");
                    $("#loading").fadeOut(300);

                }
                else {
                    $("#loading").fadeOut(300);
                    $("#lightbox").fadeOut(500);
                    alert('Sistema temporariamente indisponível.')
                }

            });
        }
        //// funcao que denuncia a foto
        function denuncia_foto(id) {
            
            $("#loading").fadeIn(300);
            $.post('ajax/denuncia_foto.aspx', { "id": id }, function (data) {
                if (data != "1") {

                    $("#loading").fadeOut(300);
                    alert('Foto denunciada! Ela não aparecerá mais na galeria. Aguarde moderador.');
                     return;

                }
                else {
                    $("#loading").fadeOut(300);

                    alert('Sistema temporariamente indisponível.')
                }

            });
        }
        /////////////////////////////////////////////////////////
        function popDocumentos(idPass) {
            $("#lightbox").css("filter", "alpha(opacity=65)");
            $("#lightbox").fadeIn(500);
            $("#loading").fadeIn(500);
            $.post('ajax/documentos.aspx', {}, function (data) {
                 

                    $("#popConteudo").empty;
                    $("#popConteudo").css("height", "480px");
                    $("#popConteudo").css("width", "880px");
                    $("#popConteudo").css("left", "50%");
                    $("#popConteudo").css("top", "50%");
                    $("#popConteudo").css("margin-left", "-440px");
                    $("#popConteudo").css("margin-top", "-240px");
                    $("#popConteudo").css("overflow-y", "scroll");
                    $("#loading").fadeOut(500);
                    $("#popConteudo").html(data);
                    $("#popConteudo").slideDown(500);
                    //Cufon.replace("#popConteudo");
                

            });
            // popconteudo w=90% l=5% h 75
        }
//   	    function atualiza_dados_mural() {
//   	        $.post('ajax/scrollMensagem.aspx?inicio=0&registros=19', {}, function (data) {
//   	            if (data != "1") {
//   	                $("#popConteudo").empty;
//   	                $("#popConteudo").css("height", "550px");
//   	                $("#popConteudo").css("width", "880px");
//   	                $("#popConteudo").css("left", "50%");
//   	                $("#popConteudo").css("top", "50%");
//   	                $("#popConteudo").css("margin-left", "-440px");
//   	                $("#popConteudo").css("margin-top", "-280px");
//   	                $("#popConteudo").css("overflow-y", "scroll");
//   	                $("#popConteudo").css("overflow-x", "hidden");
//   	                $("#popConteudo").css("color", "#fff");
//   	                $("#popConteudo").slideDown(1000);
//   	                $("#popConteudo").html(data);
//   	                Cufon.replace('#popConteudo');
//   	                $("#loading").fadeOut(300);



//   	                //mural(0, 10, tipo_mural);
//   	            }
//   	            else {
//   	                $("#loading").fadeOut(300);
//   	                $("#lightbox").fadeOut(500);
//   	                alert('Sistema temporariamente indisponível.')
//   	            }

//   	        });
        //   	   }


        function cancala_papeletas() {
            var answer = confirm("Deseja realmente cancelar sua inscrição no passeio?")
            var pass = $("#ddlPasseio").val();
            
            // se sim
            if (pass != "Selecione um Passeio") {
                if (answer) {

                    $.ajax({
                        type: "POST",
                        url: "ajax/cancela_insc.aspx",
                        data: { "id": pass },
                        timeout: 10000,
                        async: false,
                        beforeSend: function () {
                            $("#loading").fadeIn(300);
                        },
                        complete: function () {
                            $("#loading").fadeOut(300);
                        },
                        cache: false,
                        success: function (result) {
                            if (result != "1") {
                                $("#ddlPasseio option[value='" + pass + "']").remove();

                                alert("Inscrição retirada com sucesso!");

                            }
                            else {
                                alert("Sistema temporariamente indisponível!");
                            }

                        },
                        error: function (error) {

                            alert("Sistema temporariamente indisponível!");
                        }
                    });
                }
            }
            
            else {

            }
        }

        function cancala_papeletas_pass(id) {
            var answer = confirm("Deseja realmente cancelar sua inscrição no passeio?")
            var pass = id;

            // se sim
            if (pass != "Selecione um Passeio") {
                if (answer) {

                    $.ajax({
                        type: "POST",
                        url: "ajax/cancela_insc.aspx",
                        data: { "id": pass },
                        timeout: 10000,
                        async: false,
                        beforeSend: function () {
                            $("#loading").fadeIn(300);
                        },
                        complete: function () {
                            $("#loading").fadeOut(300);
                        },
                        cache: false,
                        success: function (result) {
                            if (result != "1") {
                                

                                alert("Inscrição retirada com sucesso!");

                            }
                            else {
                                alert("Sistema temporariamente indisponível!");
                            }

                        },
                        error: function (error) {

                            alert("Sistema temporariamente indisponível!");
                        }
                    });
                }
            }

            else {

            }
        }
