var mycarousel_itemList = [
    {url: 'images/main/s-salony.png', 	title: 'Salony - Meble Prestige', 	link: 'projekty/salony.html'},
    {url: 'images/main/s-kuchnie.png', 	title: 'Kuchnie - Meble Prestige', 	link: 'projekty/kuchnie.html'},
    {url: 'images/main/s-biura.png', 		title: 'Biura - Meble Prestige', 		link: 'projekty/biura.html'},
    {url: 'images/main/s-szafy.png', 		title: 'Szafy - Meble Prestige', 		link: 'projekty/szafy.html'}
];

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<a href="' + item.link + '"><img src="' + item.url + '" height="525" alt="' + item.title + '" /></a>'; //width="250"
};

/**
 * Custom navigation
 **/
function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({

        buttonNextHTML: false,
        buttonPrevHTML: false,
        initCallback: mycarousel_initCallback,

        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}

    });
});
