jQuery(document).ready(function () {

    $('span.input_submit').click(function (event) {

        if (!($('.input_text').attr("value") == "Rechercher_")) {
           
            JumpTo("search.aspx?q=" + $('.input_text').attr("value")); 
        }

        else {  
        
        return false;

        }

        
    
    });

    // carousel
    $('.jq_carousel').jcarousel({ scroll: 3 });
    $('#catwrapper').click(function (event) { event.preventDefault(); $('#catwrapper').hide(); });

    // ajouter les masks pour la promo ou les soldes
    $('.promo .image_container a, .soldes .image_container a').append('<span class="mask_picto"></span>');
    $('.reco .image_container a').append('<span class="mask_picto_reco"></span>');
    $('.deal .image_container a').append('<span class="mask_picto_deal"></span>');
    $('.IsVideo a').append('<span class="play_mask_small"></span>');
    //play_mask
    // slideshow plugin "cycle"
    $('.sliderimage').append('<div id="navslide"></div>'); /* pagination */
    $('.sliderimage .slides').cycle({
        speed: 1000,
        timeout: 4000,
        pager: '#navslide',
        slideExpr: 'li',
        fx: 'fade'
    });
    // Small slideshow plugin "cycle"
    $('.SmallSliderImage').append('<div id="navslide"></div>'); /* pagination */
    $('.SmallSliderImage .slides').cycle({
        speed: 1000,
        timeout: 4000,
        pager: '#navslide',
        slideExpr: 'li',
        fx: 'fade'
    });

});

function ShowHide(ItemToShow, GroupToHide) {

    $("ul[id^=Familly_" + GroupToHide + "]").fadeOut();
    $("li[id^=Tab_]").removeClass("active");
    $("li#Tab_" + ItemToShow).addClass("active");
    $('ul#Familly_' + ItemToShow).fadeIn();

}

jQuery.fn.center = function (absolute) {
    return this.each(function () {
        var t = jQuery(this);

        t.css({
            position: absolute ? 'absolute' : 'fixed',
            left: '50%',
            top: '50%',
            zIndex: '99'
        }).css({
            marginLeft: '-' + (t.outerWidth() / 2) + 'px',
            marginTop: '-' + (t.outerHeight() / 2) + 'px'
        });

        if (absolute) {
            t.css({
                marginTop: parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(),
                marginLeft: parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft()
            });
        }
    });
};
