function openContent(item) {
    $('#'+item+' b').toggleClass('open')
    $('#'+item+' .content').slideToggle('normal');
    $(this).toggleClass('open');
}


$(function() {
    $('#banner_content').cycle({
        fx:      'fade',
        timeout: 20000,
        speed:  500,
        next:   '#banner-next',
        prev:   '#banner-prev'
    });

    $('#banners-linhas').cycle('fade');

    $(".content-inner, #banner-next, #banner-prev").hover(function() {
        $("#banner-next, #banner-prev").show();
    }, function() {
        $("#banner-next, #banner-prev").hide();
    });

    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    $('#banner').css({
        'width':maskWidth,
        'height':maskHeight
    });
    $('#banner_content').css({
        'width':maskWidth,
        'height':maskHeight
    });

    $(window).resize(function() {
        //armazena a largura e a altura da tela
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
        //Define largura e altura
        $('#banner').css({
            'width':maskWidth,
            'height':maskHeight
        });
        $('#banner_content').css({
            'width':maskWidth,
            'height':maskHeight
        });
        $('.banner').css({
            'width':maskWidth,
            'height':maskHeight
        });

    });




    $('.js-submit-onchange').change(function() {
        $(this).parents('form:eq(0)').submit();
    });

    $("a[rel=produto-detalhe]").fancybox({
        'padding' : 80
    });
    $("#boxs.foto .sub .verMais").click(function() {
        $("a[rel=produto-detalhe]:eq(1)").click();
        return false;
    });
    $("a[rel=produto-video]").click(function() {
        $.fancybox({
            'padding'		: 0,
            'autoScale'		: false,
            'transitionIn'	: 'none',
            'transitionOut'	: 'none',
            'title'			: this.title,
            'width'		: 680,
            'height'		: 495,
            'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'			: 'swf',
            'swf'			: {
                'wmode'		: 'transparent',
                'allowfullscreen'	: 'true'
            }
        });

        return false;
    });


    $('#linhas_home li').hover(
        function() {
            $('.destaque', this).stop(true, false).animate({
                opacity: 0
            });
        },
        function() {
            $('.destaque', this).stop(true, false).animate({
                opacity: 1
            });
        }
        );
            
    $("#produto-autocomplete").autocomplete({
        source: 'produtos/busca.js'
    });

    $('#empresa #banner-interno .content-inner ul a').click(function() {
        $.scrollTo('#' + this.href.split('#')[1], 500, {});
        return false;
    });


    $("#list-novidades li strong").click(function() {
        $(".content", $(this).parent()).slideToggle();
    });

});




$(document).ready(function()
{
    $('#mapa-map area').each(function() {
        $(this).attr('title', $(this).attr('alt'));
    });
    
    $('#mapa-map area').qtip({        
        position: {
            my: 'bottom center',
            target: 'mouse',
            viewport: $(window), // Keep it on-screen at all times if possible
            adjust: {
                x: 0,
                y: -5
            }
        },
        hide: {
            fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
        },
        style: 'ui-tooltip-shadow'
    });
});
