
var SITE = "http://www.wetnwild.com.br/2009";

var opPonto = "";

/**
 * Listar as cidades pelo estado
 * @param {int} op : id do estado
 */
function listaCidades(op){
    $.ajax({
        header: {
            "Content-Type": "text/html;  charset=ISO-8859-1"
        },
        type: "post",
        data: "acao=listar-cidades&op=" + op,
        url: SITE + "/ajax.php",
        success: function(valor){
            // Preenche o campo com listar de cidades retornada
            $('#esc-cidade').html(valor);
            return true;
        }
    });
}

/**
 * Lista os representantes pela cidade
 * @param {int} op : Id da cidade
 */
function listaRepresentantesCidade(op, pagina){
    $.ajax({
        header: {
            "Content-Type": "text/html;  charset=ISO-8859-1"
        },
        type: "get",
        data: "acao=listar-representantes&op=" + op + "&pagina=" + pagina,
        url: SITE + "/ajax.php",
        dataType: "json",
        success: function(valor){
            // Preenche a tabela com os dados
            $('.tabela tbody').html(valor.conteudo);
            $('#aki-paginacao').html(valor.paginacao);
            return true;
        }
    });
}

function listaPontosVenda(op, pagina){
    $.ajax({
        header: {
            "Content-Type": "text/html;  charset=ISO-8859-1"
        },
        type: "get",
        data: "acao=listar-pontos-de-venda&op=" + op + "&pagina=" + pagina,
        url: SITE + "/ajax.php",
        dataType: "json",
        success: function(valor){
            // Preenche a tabela com os dados
            $('.tabela tbody').html(valor.conteudo);
            $('#aki-paginacao-pontos').html(valor.paginacao);
            return true;
        }
    });
}

function checkUsuario(user){
    $('#resultado').html('<span class=\"preto\">Verificando</span>');
    
    $.ajax({
        header: {
            "Content-Type": "text/html;  charset=ISO-8859-1"
        },
        type: "get",
        data: "acao=check-usuario&user=" + user,
        url: SITE + "/ajax.php",
        dataType: "json",
        success: function(valor){
            // Preenche a tabela com os dados
            $('#resultado').html(valor.resultado);
            return true;
        }
    });
}

function verificaForca(campo){
    var valor = campo;
    var contemNumeros = /[0-9]/;
    var contemLetras = /[a-z]/i;
    var contemEspecial = /[@#$%&amp;amp;amp;*]/;
    var contagem = 0;
    var numeros = 0;
    var letras = 0;
    var mensagem = "";
    
    if (valor.length > 0) {
        if (contemNumeros.test(valor)) {
            contagem++
            numeros++;
        };
        if (contemLetras.test(valor)) {
            contagem++
            letras++;
        };
        if (contemEspecial.test(valor)) 
            contagem++;
        
        
        if (letras > 0 && numeros > 0) {
            return true
        }
        else {
            alert('Senha invalida, a senha dever conter letras e numeros ');
            return false;
        }
    }
    else {
        alert('Digite sua senha');
    }
}

function checkIDWords(str){
    var regex = /^[\w\.\_\-]+$/;
    return (regex.test(str));
}


function validaEmail(mail){

    var er = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if (mail == "") {
        window.alert("Informe seu e-mail!");
    }
    else 
        if (er.test(mail) == false) {
            window.alert("E-mail inválido!");
        }
}

$(document).ready(function(){


	//$(document).pngFix();

   /*
 $('#ah1 img').mouseout(function(){
        $('#calendario a[class != "h1"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "h1"]').animate({
            opacity: 0.2,
        }, 0);
    });
	
	
    $('#ah2 img').mouseout(function(){
        $('#calendario a[class != "h2"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "h2"]').animate({
            opacity: 0.2,
        }, 1);
    });
	
	
    $('#ah3 img').mouseout(function(){
        $('#calendario a[class != "h3"]').animate({
            opacity: 0.9,
        }, 1)
    }).mouseover(function(){
        $('#calendario a[class != "h3"]').animate({
            opacity: 0.2,
        }, 1);
    });
    
	
	
    $('#ah4 img').mouseout(function(){
        $('#calendario a[class != "h4"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "h4"]').animate({
            opacity: 0.2,
        }, 1);
    });
    
	
	
    $('#ah5 img').mouseout(function(){
        $('#calendario a[class != "h5"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "h5"]').animate({
            opacity: 0.2,
        }, 1);
    });
	
	
	
    $('#ahevento img').mouseout(function(){
        $('#calendario a[class != "hevento"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "hevento"]').animate({
            opacity: 0.2,
        }, 1);
    });
	
	
	
    $('#ahferiado img').mouseout(function(){
        $('#calendario a[class != "hferiado"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "hferiado"]').animate({
            opacity: 0.2,
        }, 1);
    });
	
	
	
    $('#ahfechado img').mouseout(function(){
        $('#calendario a[class != "hfechado"]').animate({
            opacity: 0.9,
        })
    }).mouseover(function(){
        $('#calendario a[class != "hfechado"]').animate({
            opacity: 0.2,
        }, 1);
    });
    
    
*/
    
    
    
    
    
    // Efeito da pagina de duvidas
    $('.duvida .pergunta a').toggle(function(event){
    
        $(this).parents('.duvida').children('.resposta').show();
        
        event.preventDefault(event);
        return false;
    }, function(event){
        $(this).parents('.duvida').children('.resposta').hide();
        
        event.preventDefault(event);
        return false;
    });
    
    // Botao do calendario	
    $(' #anterior').live('click',function(event){
        $('#cotainer').hide();
        $('#loading').show();
        
        $.ajax({
            header: {
                "Content-Type": "text/html;  charset=ISO-8859-1"
            },
            type: "get",
            data: "acao=anterior",
            url: SITE + "/ajax.php",
            dataType: 'html',
            success: function(valor){
            
                $('#cotainer').html(valor);
                $('#cotainer').show();
                $('#loading').hide();
                return true;
            }
        });
        
        event.preventDefault(event);
        return false;
    });
    
    $('#proximo').live('click',function(event){
        $('#cotainer').hide();
        $('#loading').show();
        $.ajax({
            header: {
                "Content-Type": "text/html;  charset=ISO-8859-1"
            },
            type: "get",
            data: "acao=proximo",
            url: SITE + "/ajax.php",
            dataType: 'html',
            success: function(valor){
            
                $('#cotainer').html(valor);
                $('#cotainer').show();
                $('#loading').hide();
                return true;
            }
        });
        
        event.preventDefault(event);
        return false;
    });
    
    // Envia o formulario de cotação
    $('#formulario-cotacao').submit(function(event){
    
        $('#formulario-cotacao input').css('background', 'url(' + SITE + '/template/img/bg-input.png) no-repeat ');
        $('#formulario-cotacao textarea').css('background', 'url(' + SITE + '/template/img/bg-textarea.png) no-repeat ');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#nome').val() == "") {
            $('#nome').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#email').val() == "") {
            $('#email').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#data').val() == "") {
            $('#data').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#quantidade').val() == "") {
            $('#quantidade').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#telefone').val() == "") {
            $('#telefone').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        
        // Verifica se o campo e nulo
        if ($('#proposta').val() == "") {
            $('#proposta').css('background', 'url(' + SITE + '/template/img/bg-textarea-error.png) no-repeat ');
            error = true;
        }
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#formulario-cotacao').serialize();
            $('#formulario-cotacao .bt-submit').val('Enviando...');
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=form-cotacao&" + dados,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    $('#formulario-cotacao .bt-submit').val('Enviado');
                    alert('Pedido de cotação enviado com sucesso.');
                    return true;
                }
            });
        }
        
        return false;
        
    });
    
    // Fim form contato cotacao
    
    
    // Envia a senha para o email alternativo da pessoa 
    $('#bt-senha').click(function(event){
    
        var email = $('#email3').val();
        
        if (email == "") {
            alert("Digite o seu email no campo acima.");
            return false;
        }
        else {
            $("#dica-senha").html('Enviando');
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=senha&email=" + email,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    alert(valor.valor);
                    $("#dica-senha").html('');
                }
            });
        }
        
        event.preventDefault(event);
        return false;
    });
    
    
    // Formulario projeto institucional
    $('#form-projeto').submit(function(event){
    
        $('#form input').css('border', '#e8e8e8e solid 1px');
        $('#form textarea').css('border', '#e8e8e8 solid 1px');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#instituicao').val() == "") {
            $('#instituicao').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#email').val() == "") {
            $('#email').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#responsavel').val() == "") {
            $('#responsavel').css('border', 'red solid 1px');
            error = true;
        }
        
        
        
        
        // Verifica se o campo e nulo
        if ($('#endereco').val() == "") {
            $('#endereco').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#bairro').val() == "") {
            $('#bairro').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#cep').val() == "") {
            $('#cep').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#cidade').val() == "") {
            $('#cidade').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#estado').val() == "") {
            $('#cidade').css('border', 'red solid 1px');
            error = true;
        }
        
        
        // Verifica se o campo e nulo
        if ($('#telefone').val() == "") {
            $('#telefone').css('border', 'red solid 1px');
            error = true;
        }
        
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#form-projeto').serialize();
            
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=form-projetos&" + dados,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    alert('Formulario enviado com sucesso');
                    return true;
                }
            });
        }
        
        return false;
        
    });
    
    
    
    
    
    
    
    
    
    
    
    // esquecia asenha 	
    $('#bt-ok').click(function(event){
    
        var email = $('#email3').val();
        $('#dica-senha').html('Processando...');
        
        $.ajax({
            header: {
                "Content-Type": "text/html;  charset=ISO-8859-1"
            },
            type: "get",
            data: "acao=esqueci-a-senha&email=" + email,
            url: SITE + "/ajax.php",
            dataType: "json",
            success: function(valor){
                // Preenche a tabela com os dados
                $('#dica-senha').html(valor.mensagem);
                return true;
            }
        });
        
        event.preventDefault(event);
        return false;
    });
    
    
    
    
    
    //Programa Fidelidade 
    
    // Mostra a imagem
    $('#prog-fidelidade').show('pulsate', {
        times: 3
    }, 'normal');
    
    // Pega o tempo que a imagem ficara aparecendo
    var imgTempo = $('#tempo').html();
    
    // Esconde a imagem
    setTimeout('$("#prog-fidelidade").hide("pulsate",{ times : 3},"fast")', imgTempo);
    
    // Click na imagem
    $('#prog-fidelidade').click(function(){
        $("#prog-fidelidade").hide('fast');
        alert('Você acaba de ganhar pontos');
        
        $.ajax({
            header: {
                "Content-Type": "text/html;  charset=ISO-8859-1"
            },
            type: "get",
            data: "acao=cad-ponto",
            url: SITE + "/ajax.php"
        });
    })
    
    
    
    
    
    // verifica se tem caracteres speciais no username 
    $('#usuario').blur(function(){
        if (!checkIDWords($(this).val())) {
            alert('usuário invalido');
            $(this).focus();
        }
        else {
            if (checkUsuario($(this).val())) {
                $(this).focus();
            }
        }
    })
    
    // Verifica se a senha e valida 
    $('#senha').blur(function(){
        verificaForca($(this).val());
    });
    
    $('#senha2').blur(function(){
        if (!($(this).val() == $('#senha').val())) {
            alert('Confirmação de senha errada');
        }
    });
    
    $('#email').blur(function(){
        validaEmail($(this).val());
    });
    
    $('#email2').blur(function(){
        if (!($(this).val() == $('#email').val())) {
            alert('Confirmação de email errada');
        }
    });
    
    
    
    
    
    // Combobox de shows 
    $('#esc-shows').change(function(){
        window.location = SITE + '/shows-e-eventos/shows/' + $(this).val();
    });
    
    
    
    // Combobox de shows 
    $('#esc-eventos').change(function(){
        window.location = SITE + '/shows-e-eventos/eventos/' + $(this).val();
    });
    
    
    
    // Listagem de Cidades 
    $('#esc-estado').change(function(){
        $('#esc-cidade').html('<option>Carregando...</option>');
        listaCidades($(this).val());
    });
    
    // Listagem de representantes por cidade
    $('#esc-cidade').change(function(){
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaRepresentantesCidade($(this).val(), 1);
    });
    
    $('#aki-paginacao a').live("click", function(event){
        pagina = $(this).html();
        opCidade = $('#esc-cidade').val();
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaRepresentantesCidade(opCidade, pagina);
        event.preventDefault(event);
        return false;
        
    });
    
    
    
    ///////////////////////////////////////////////////////////////////////
    // Listagem de pontos de venda da regiao metropolitana
    $('#esc-metropolitana').change(function(){
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaPontosVenda($(this).val(), 1);
        opPonto = "#esc-metropolitana";
    });
    
    // Listagem de pontos de venda da regiao Interior
    $('#esc-interior').change(function(){
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaPontosVenda($(this).val(), 1);
        opPonto = "#esc-interior";
    });
    
    
    // Listagem de pontos de venda da regiao Litoral
    $('#esc-litoral').change(function(){
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaPontosVenda($(this).val(), 1);
        opPonto = "#esc-litoral";
    });
    
    
    // Listagem de pontos de venda da regiao Outros Estados
    $('#esc-outros').change(function(){
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaPontosVenda($(this).val(), 1);
        opPonto = "#esc-outros";
    });
    
    
    // Paginacao dos pontos de vendas	
    $('#aki-paginacao-pontos a').live("click", function(event){
        pagina = $(this).html();
        opCidade = $(opPonto).val();
        $('.tabela tbody').html('<tr><td colspan="3" style="width:100%;text-align:center;"><img src="' + SITE + '/template/img/loading.gif" alt="Carregando" /></td></tr>');
        listaPontosVenda(opCidade, pagina);
        event.preventDefault(event);
        return false;
        
    });
    
    
    
    // Envio formulario Trabalhe conosco
    
    $('#contato').submit(function(event){
    
    
    
        $('#formulario-contato input').css('border', '#666666 solid 1px');
        $('#formulario-contato textarea').css('border', '#666666 solid 1px');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#nome').val() == "") {
            $('#nome').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#email').val() == "") {
            $('#email').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#cpf').val() == "") {
            $('#cpf').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#nascimento').val() == "") {
            $('#nascimento').css('border', 'red solid 1px');
            error = true;
        }
        
        
        // Verifica se o campo e nulo
        if ($('#endereco').val() == "") {
            $('#endereco').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#numero').val() == "") {
            $('#numero').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#bairro').val() == "") {
            $('#bairro').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#cep').val() == "") {
            $('#cep').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#esc-cidade').val() == "") {
            $('#esc-cidade').css('border', 'red solid 1px');
            error = true;
        }
        // Verifica se o campo e nulo
        if ($('#cargo').val() == "0") {
            $('#cargo').css('border', 'red solid 1px');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#telefone_residencial').val() == "") {
            $('#telefone_residencial').css('border', 'red solid 1px');
            error = true;
        }
        
        
        
        if ($('#cv').val() == "") {
            $('#cv').css('border', 'red solid 1px');
            error = true;
        }
        else {
            arquivo = $('#cv').val();
            extensao = arquivo.split(".");
            if ((extensao[1] != "doc") || (extensao[1] != "doc")) {
                alert("Tipo de arquivo invalido");
            }
        }
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#contato').serialize();
            
            return true;
            /*
            
             $.ajax({
            
             header: {"Content-Type": "text/html;  charset=ISO-8859-1"},
            
             type: "get",
            
             data: "acao=form-trabalhe&"+dados,
            
             url: SITE+ "/ajax.php",
            
             dataType: "json",
            
             success: function(valor){
            
             // Preenche a tabela com os dados
            
             alert('Formulario enviado com sucesso');
            
             return true;
            
             }
            
             });	*/
            
        }
        
        return false;
        
    });
    
    
    
    // Envio formulario Contato
    
    $('#formulario-contato').submit(function(event){
    
    
        $('#formulario-contato input').css('background', 'url(' + SITE + '/template/img/bg-input.png) no-repeat ');
        $('#formulario-contato textarea').css('background', 'url(' + SITE + '/template/img/bg-textarea.png) no-repeat ');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#nome').val() == "") {
            $('#nome').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#email').val() == "") {
            $('#email').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        
        // Verifica se o campo e nulo
        if ($('#telefone').val() == "") {
            $('#telefone').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        
        // Verifica se o campo e nulo
        if ($('#mensagem').val() == "") {
            $('#mensagem').css('background', 'url(' + SITE + '/template/img/bg-textarea-error.png) no-repeat ');
            error = true;
        }
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#formulario-contato').serialize();
            $('#formulario-contato .bt-submit').val('Enviando...');
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=form-contato&" + dados,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    $('#formulario-contato .bt-submit').val('Enviado');
                    alert('Mensagem enviada com sucesso.');
                    return true;
                }
            });
        }
        
        return false;
        
    });
    
    
    // Envio formulario patrocinio
    
    $('#formulario-parceiro').submit(function(event){
    
        $('#formulario-parceiro input').css('background', 'url(' + SITE + '/template/img/bg-input.png) no-repeat ');
        $('#formulario-parceiro textarea').css('background', 'url(' + SITE + '/template/img/bg-textarea.png) no-repeat ');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#empresa').val() == "") {
            $('#empresa').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#endereco').val() == "") {
            $('#endereco').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#telefone').val() == "") {
            $('#telefone').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#contato_responsavel').val() == "") {
            $('#contato_responsavel').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#produto_servico').val() == "") {
            $('#produto_servico').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#plubico-alvo').val() == "") {
            $('#plubico-alvo').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#proposta').val() == "") {
            $('#proposta').css('background', 'url(' + SITE + '/template/img/bg-textarea-error.png) no-repeat ');
            error = true;
        }
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#formulario-parceiro').serialize();
            $('#formulario-parceiro .bt-submit').val('Enviando...');
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=form-parceiro&" + dados,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    $('#formulario-parceiro .bt-submit').val('Enviado');
                    alert('Mensagem enviada com sucesso.');
                    return true;
                }
            });
        }
        
        return false;
        
    });
    
    
    
    
    
    
    
    
    
    
    
    // Envio formulario patrocinio
    
    $('#formulario-patrocinio').submit(function(event){
    
        $('#formulario-patrocinio input').css('background', 'url(' + SITE + '/template/img/bg-input.png) no-repeat ');
        $('#formulario-patrocinio textarea').css('background', 'url(' + SITE + '/template/img/bg-textarea.png) no-repeat ');
        
        
        var error = false;
        
        // Verifica se o campo e nulo
        if ($('#empresa').val() == "") {
            $('#empresa').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#endereco').val() == "") {
            $('#endereco').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#telefone').val() == "") {
            $('#telefone').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#contato_responsavel').val() == "") {
            $('#contato_responsavel').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#ramo_atividade').val() == "") {
            $('#ramo_atividade').css('background', 'url(' + SITE + '/template/img/bg-input-error.png) no-repeat ');
            error = true;
        }
        
        // Verifica se o campo e nulo
        if ($('#proposta').val() == "") {
            $('#proposta').css('background', 'url(' + SITE + '/template/img/bg-textarea-error.png) no-repeat ');
            error = true;
        }
        
        if (error == true) {
            alert('Preencha todos os campos obrigátorios')
        }
        else {
            var dados = $('#formulario-patrocinio').serialize();
            $('#formulario-patrocinio .bt-submit').val('Enviando...');
            
            $.ajax({
                header: {
                    "Content-Type": "text/html;  charset=ISO-8859-1"
                },
                type: "get",
                data: "acao=form-patrocinio&" + dados,
                url: SITE + "/ajax.php",
                dataType: "json",
                success: function(valor){
                    // Preenche a tabela com os dados
                    $('#formulario-patrocinio .bt-submit').val('Enviado');
                    alert('Mensagem enviada com sucesso.');
                    return true;
                }
            });
        }
        
        return false;
        
    });
    
    
    
    
    
    $('.pane-os-projeto').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    $('.pane-os-duvidas').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    $('.pane-os-imprensa').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    $('.pane-os').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    $('.pane-os2').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    $('.pane-os3').jScrollPane({
        showArrows: true,
        scrollbarWidth: 15,
        arrowSize: 16
    });
    
    
    $('a[rel*=popup]').lightBox({
        overlayBgColor: '#000',
        overlayOpacity: 0.8,
        imageLoading: SITE + '/template/js/lightbox/images/lightbox-ico-loading.gif',
        imageBtnClose: SITE + '/template/js/lightbox/images/lightbox-btn-close.gif',
        imageBtnPrev: SITE + '/template/js/lightbox/images/lightbox-btn-prev.gif',
        imageBtnNext: SITE + '/template/js/lightbox//images/lightbox-btn-next.gif',
        imageBlank: SITE + '/template/js/lightbox//images/lightbox-blank.gif',
        txtImage: 'Imagem',
        txtOf: 'de'
    });
    
});



/****************************\
 FUNCAO QUE CRIA O OBJETO AJAX
 \****************************/
function criarAjax(){
    var ajax;
    try {
        ajax = new XMLHttpRequest();
    } 
    catch (ee) {
        try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (E) {
                ajax = false;
            }
        }
    }
    return ajax;
}


try {
    xmlhttp = new XMLHttpRequest();
} 
catch (ee) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (E) {
            xmlhttp = false;
        }
    }
}


function enviar_enquete(){

    var pergunta = document.votacao.cod_pergunta.value;
    
    //O voto. Cria uma variÃ¡vel como a opÃ§Ã£o escolhida.
    if (document.votacao.escolha1.checked) 
        var voto = 0
    else 
        if (document.votacao.escolha2.checked) 
            var voto = 1
        else 
            if (document.votacao.escolha3.checked) 
                var voto = 2
            else 
                if (document.votacao.escolha4.checked) 
                    var voto = 3
                else 
                    var voto = ""
    
    if ((voto != 0) && (voto != 1) && (voto != 2) && (voto != 3)) {
        alert("Escolha uma opÃ§ao para poder votar!")
    }
    else {
        //Abre a conexÃ£o
        xmlhttp.open("GET", SITE + "/scripts/votar.php?voto=" + voto + "&per=" + pergunta, true);
        
        //FunÃ§Ã£o para tratamento do retorno
        xmlhttp.onreadystatechange = function(){
        
            if (xmlhttp.readyState == 4) {
            
                //Mostra mensagem
                var mensagem = xmlhttp.responseText;
                mensagem = mensagem.replace(/\+/g, " ");
                mensagem = unescape(mensagem);
                document.getElementById('votacao').innerHTML = mensagem;
            }
        }
        
        //Executa
        xmlhttp.send(null)
    }
    
    return false;
}

