var mycarousel_itemList = [
 {url: "slider/1.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=7"},
 {url: "slider/2.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=129"},
 {url: "slider/3.jpg", href: "http://www.rainbow.net.mk/store/listOneCategory.asp?idCategory=130"},
 {url: "slider/4.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=147"},
 {url: "slider/5.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=171"},
 {url: "slider/6.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=29"},
 {url: "slider/7.jpg", href: "http://www.rainbow.net.mk/store/listOneCategory.asp?idCategory=158"},
 {url: "slider/8.jpg", href: "http://www.rainbow.net.mk/store/listOneCategory.asp?idCategory=44"},
 {url: "slider/9.jpg", href: "http://www.rainbow.net.mk/store/listOneCategory.asp?idCategory=64"},
 {url: "slider/10.jpg", href: "http://www.rainbow.net.mk/store/listItems.asp?idCategory=12"}
];

function mycarousel_itemLoadCallback(carousel, state)
{
    // 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();
    });

    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1]));
    }
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<a href="' + item.href + '"><img src="' + item.url + '" width="150" alt="' + item.url + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
		auto: 3,
		scroll: 1,
        wrap: 'both',
        size: mycarousel_itemList.length,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
    });
});
