// JavaScript Document
$(document).ready(function(){

    $(".telefone").mask("(99) 9999-9999");
    $("#cep").mask("99999-999");

    $("a.galeria").fancybox();

    $('.ad-gallery').adGallery({ effect: 'fade' });

    $('#container-2').tabs({ fxShow: { height: 'show', opacity: 'show' } });

    $(".link-to-content-expand").click(function(){

       var indice = $(".link-to-content-expand").index(this);

       $(".content-expand").eq(indice).slideToggle("slow");

       return false;
    });

     $('#como_conheceu').change(function(){
        if(($(this).val() == 'Outro')) {
            $('p.como_conheceu').css('display','block');
            if($('body').find('#outro').size() == 0) {
                var html = '<label for="outro">Favor especificar</label><br /><input type="text" name="outro" id="outro" class="char" value="" />';
                $(html).appendTo('p.como_conheceu');
            }
        } else {
            $('p.como_conheceu').css('display','none');
        }

    });

    $('#news_nome').val('Nome...');
    $('#news_nome').focus(function(){ if($(this).val() == 'Nome...') {$(this).val(''); }});
    $('#news_nome').blur(function(){ if($(this).val() == '') {$(this).val('Nome...'); }});

    $('#news_email').val('E-mail...');
    $('#news_email').focus(function(){ if($(this).val() == 'E-mail...') {$(this).val(''); }});
    $('#news_email').blur(function(){ if($(this).val() == '') {$(this).val('E-mail...'); }});

    $("dt a").click(function(){

       var indice = $("dt a").index(this);

       if($('.mais').eq(indice).html() == '[+]') {

           $('.mais').eq(indice).html('[-]')
           $("dd").eq(indice).slideDown();
       } else {

           $('.mais').eq(indice).html('[+]')
           $("dd").eq(indice).slideUp();
       }

       return false;
    });

    $("select[name=id_tratamento]").change(function(){ document.tratamento.submit(); });
    $("select[name=filtro]").change(function(){ document.cursos.submit(); });

    $("#bom-amigo-email").validate({
            rules: {
                    email_amigo: {
                            required: true,
                            email: true
                    },
                    nome_amigo: "required"
            }
    });

    $("#bom-amigo-carta").validate({
            rules: {
                    code: {
                        required: true,
                        number: false
                    },
                    nome_amigo: "required",
                    rua: "required",
                    bairro: "required",
                    cep: "required",
                    cidade: "required",
                    estado: "required"
            }
    });

});



