$(function() {

    if (typeof(noSlide) == 'undefined') noSlide = false;

    if (!noSlide) {
        $("#chained").scrollable({size:1}).circular().autoscroll({
            steps: 1,
            interval: 3000
        });

        $("#chainedsf").scrollable({size:1}).circular().autoscroll({
            steps: 1,
            interval: 3000
        });

        $("#productscategory_list").scrollable({size:1}).circular().autoscroll({
            steps: 1,
            interval: 3000
        });
    }

    $('ul.sf-menu').superfish({
        autoArrows:    false,   // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance
        dropShadows:   false    // completely disable drop shadows by setting this to false
    });

    $('#actualites').cycle({
        fx: 'fade',
        cleartypeNoBg:  true
    });

    $('#valp').cycle({
        fx: 'fade',
        cleartypeNoBg:  true
    });

    $('#slide').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });

    $('#lg').cycle({
        fx: 'scrollHorz',
        speed: 300,
        next: '#lg1',
        prev: '#lg2',
        timeout: 0,
        cleartypeNoBg: true
    });

    if ($('#product_tabs')) {
        $('#product_tabs').tabs('#product_panes > div', {
            event: 'click',
            effect: 'fade'
        });
    }

    if ($('ul.tabs')) {
        $('ul.tabs').tabs('div.panes > div', {
            event: 'click',
            effect: 'fade'
        });
    }

    $('#promos').cycle({
        fx: 'fade',
        cleartypeNoBg:  true
    });

    $('.jqzoom').jqzoom({
        zoomWidth: 325,
        zoomHeight: 360,
        xOffset: 10,
        yOffset: -40,
        title: false,
        position: 'left'
    });

    //$("#vc_produit").dropdownchecklist({width:100});

});

function addFavorite(url, name)
{
    if (navigator.appName != 'Microsoft Internet Explorer') {
        window.sidebar.addPanel(name, url, '');
    }
    else {
        window.external.AddFavorite(url, name);
    }
}

function affiner() {
    var search_query = $('#vc_produit').val() + '+' +
        $('#vc_matiere').val() + '+' +
        $('#vc_collection').val() + '&' +
        'vc_produit=' + $('#vc_produit').val() + '&' +
        'vc_matiere=' + $('#vc_matiere').val() + '&' +
        'vc_collection=' + $('#vc_collection').val();

    window.location.href='search.php?orderby=position&orderway=desc&search_query=' + search_query + '&submit_search=ok';
}

jQuery.fn.liScroll = function(settings) {
    settings = jQuery.extend({
        travelocity: 0.02
    }, settings);
    return this.each(function() {
        var $strip = jQuery(this);
        $strip.addClass("newsticker")
        var stripWidth = 0;
        var $mask = $strip.wrap("<div class='mask'></div>");
        var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");
        var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width
        $strip.find("li").each(function(i){
            stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
        });
        stripWidth = stripWidth + 350;
        $strip.width(stripWidth);
        var totalTravel = stripWidth+containerWidth;
        var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye
        function scrollnews(spazio, tempo){
            $strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
        }
        scrollnews(totalTravel, defTiming);
        $strip.hover(function(){
            jQuery(this).stop();
        },
        function() {
            var offset = jQuery(this).offset();
            var residualSpace = offset.left + stripWidth;
            var residualTime = residualSpace/settings.travelocity;
            scrollnews(residualSpace, residualTime);
        });
    });
};

$(function(){$("ul#ticker01").liScroll();});

