$(document).ready(function(){
    car_len = 6
    $("div.carousel").each(function(){
        name = $(this).attr('rel')
        next = $(name + " .supp-next")
        prev = $(name + " .supp-prev")
        cr_cfg = {
            btnNext: next,
            btnPrev: prev,
            circular: false,
            visible: car_len,
            scroll: car_len,
            afterEnd: function(elems){
                if ( $(elems).nextAll().length <= car_len ) {
                    next.css('visibility', 'visible')
                }
                else {
                    next.css('visibility', 'visible')
                }
                if ( $(elems).prevAll().length < car_len ) {
                    prev.css('visibility', 'hidden')
                }
                else {
                    prev.css('visibility', 'visible')
                }
            }
        }
        if ( $(this).children('ul').children().length > car_len ) {
            $(this).jCarouselLite(cr_cfg);
        }
        else {
            next.hide(0)
            prev.hide(0)
            $(this).addClass("no-carousel")
        }
    })

    $("ul.tabs").tabs("div.panes > div");

    qtip_style = {
        // color: 'white',
        background: '#d5dbde',
        border: {
            width: 12,
            radius: 12,
            color: '#d5dbde'
        },
        name: 'light',
        // tip: 'bottomRight'
        tip: true,
        width: {
            max: 500
        }
    }
    
    $("img.supp-prod-pic").each(function(){
        cont_id = $(this).attr('rel')
        // $("#debug").append(" " + $(cont_id).width() + "x" + $(cont_id).height())
        $(this).qtip({
            content: $(cont_id),
            show: {
                when: {
                    event: 'mouseover'
                },
                delay: 0,
                effect: {
                    type: 'fade',
                    length: 50
                }
            },
            style: qtip_style,
            position: {
                corner: {
                    target: 'topRight',
                    tooltip: 'bottomLeft'
                },
                adjust: {
                    screen: true
                }
            },
            hide: {
                when: {
                    event: 'mouseout'
                },
                effect: {
                    type: 'fade',
                    length: 200
                }
            }
        })
    })
    
    $(".link-variants").click(function(){return false})
})
