

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();
    });
	
}


function LoadCarousel(){

    jQuery('.shop_carousel').hide();
    jQuery('.shop_carousel').find('img').each(function(){
        image_address = $(this).attr('src');
        var preload = new Image();
        preload.src = image_address;
    });
    jQuery('.shop_carousel').show();

    jQuery('#mycarousel').jcarousel({
        auto: 5,
        wrap: 'last',
        scroll: 1,
        initCallback: mycarousel_initCallback
    });

}

function LoadBalloons(){
    $('.acc_list_body li a img').each(InitBalloons);
};

function InitBalloons(){

    var ID= $(this).attr('id');

    $(this).qtip({
        content: {
            prerender: true,
            url: 'ajax/shop/bubbleItem.php',
            data: {
                id: ID
            },
            method: 'post'
        },

        show: {
            delay: 0
        },
        hide: {
            //delay:1000,
            fixed:true,
            when:'mouseleave'
        },
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            border: {
                width: 0,
                radius: 1,
                color: 'fff'
            },
            padding: '2px 2px',
            title: {
                'padding': '1px' ,
                'background-color':'transparent'
            },
            tip: {
                size: {
                    x: 0,
                    y: 0
                }
            }
        }
    });

    return true;
}

function LoadPopulars(){

   var params = {type:'nav,acc',limit:3,split:1};

    $.post(
        'ajax/shop/products.php?retrieve=populars',
        {data: JSON.stringify(params) },
        function(data){
           var pop = '#shop_populars_';
           
           for(t in data){
               pdata = data[t];
                for(i in pdata){
                   p = pdata[i];
                   n = parseInt(i)+1;
                   counter = $('<div></div>').html(n);
                   var link = $('<a></a>');

                   if(p['ProductCode'].toLowerCase().indexOf('nav') == 0)
                    link = $('<a></a>').attr('href',"index.php?swt=0155&ipr="+p['ProductId']);

                   link.html(p['ProductName']);

                   litem = $('<li></li>').append(counter).append(link);

                   $(pop+t).append(litem);
               }
           }
 
        },
        'json'
        );

}