$(function () {
	
	$('#chorizontal').jcarousel({ scroll: 4 });

    $('.banner:first').fadeIn(350)
        .css('background-image', 'url('+ $('.banner:first').children().attr('src') +')');

    for(var i=1; i<=$('#destaque .banner').size(); i++) $('#destaque').append('<button>'+ i +'</button>');

    $('#destaque button:first').css('margin-top', '60px');
    $('#destaque button:first').addClass('btOn');

    var interval = setInterval('banner('+ false +', '+ true +')', 7000);

    $('#destaque button').click(function () {
        clearInterval(interval);
        var show = $(this).html();
        banner(show, false);
    });

    
    $('#tiraDuvidas, #tiraDuvidas a').click(function () {
        $('#coluna1').toggle();
        $('#coluna2').toggle();
        return false;
    });

    $('li.menufaq').click(function () {
        var num = $('li.menufaq').index(this) + 1;
        $('ul.menufaq li').each(function () {
            $(this).removeClass('active');
        });
        $(this).addClass('active');
        $('.conteudoFaq').hide();
        $('.conteudoFaq:eq('+ num +')').show();
        return false;
    });

});

function banner(show, auto) {
    $('.banner').each(function () {
        if(!$(this).is(':hidden')) {
            $(this).fadeOut(450);
            i = $('.banner').index(this);
            if(auto == true) {
                i++;
                if(i == $('.banner').size()) i = 0;
            }
        }
    });
    if(show) i = show - 1;
    $('#destaque button').removeClass('btOn');
    $('#destaque button:eq('+i+')').addClass('btOn');
    $('.banner:eq('+i+')').fadeIn(350)
        .css('background-image', 'url('+ $('.banner:eq('+i+')').children().attr('src') +')');
}
