$(document).ready(function() {
	
    function mycarousel_initCallback(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };
			
    $('#mycarousel').jcarousel({
        auto: 4,
        initCallback: mycarousel_initCallback
    });
			
			
    /*Menu*/
				
    $('#menu > ul > li').bind("mouseenter",function(){
        $(this).find(".sous_menu").css('display','block');
        $(this).find('a:first').addClass('selected');
    }).bind("mouseleave",function(){
        $(this).find(".sous_menu").css('display','none');
        $(this).find('a:first').removeClass('selected');
    });

			
    /*Onglet*/
			
    $('.tab-mea').hover(function () {
        _id = $(this).attr('id');
        $('.produit-grid').hide();
        $('#tab_'+_id).show();
        $('.tab-mea').removeClass('active');
        $(this).addClass('active');
        if($(this).parent().hasClass('tab_promotion')){
            $('.tab_bloc').css('border-color','#97BF0D');
            $('.tab_promotion a').css('border-right-color','#97BF0D');
            $('.onglet li a').css('border-bottom-color','#97BF0D');
        }
        if($(this).parent().hasClass('tab_nouveaute')){
            $('.tab_bloc').css('border-color','#DEDB00');
            $('.tab_nouveaute a').css('border-right-color','#DEDB00');
            $('.tab_promotion a').css('border-right-color','#DEDB00');
            $('.onglet li a').css('border-bottom-color','#DEDB00');
        }
        if($(this).parent().hasClass('tab_vente')){
            $('.tab_bloc').css('border-color','#DEC8AB');
            $('.tab_nouveaute a').css('border-right-color','#DEC8AB');
            $('.onglet li a').css('border-bottom-color','#DEC8AB');
        }
    });
    $('.petitBlocProduit').bind('mouseenter',function () {
        $(this).find('.actions').css('display','block');
    }).bind("mouseleave",function(){
        $(this).find('.actions').css('display','none');
    });

    $('.marque select').selectmenu();


    // Menu marque Header
    $('#search_manufacturer').change(function() {
        window.location.href = $(this).val();
    })
    
    $(".blockcmsmodal").fancybox({
            'transitionIn'	:	'elastic',
            'transitionOut'	:	'elastic',
            'height'            :       200,
            'width'             :       200,
            'ajax'              :       {
                                            type : "POST",
                                            data : 'ajax=true'
                                        }    
    });

});


