var mycarousel_itemList = [
    {url: '/sites/all/themes/aom/images/carousel-thirdeye.png', title: 'MediaFlow', link: '/thirdeye'},
    {url: '/sites/all/themes/aom/images/carousel-mediaflow.png', title: 'Thirdeye', link: '/mediaflow'},
     {url: '/sites/all/themes/aom/images/carousel-touchzone.png', title: 'Touchzone', link: '/touchzone'}
];

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);
};

function myInit(carousel){
	jQuery('#te_btn').bind('click',function() {
		carousel.scroll(1,true);
        return false;
	});
	jQuery('#mf_btn').bind('click',function() {
		carousel.scroll(2,true);
        return false;
	});
	jQuery('#tz_btn').bind('click',function() {
		carousel.scroll(3,true);
        return false;
	});
}

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{return '<a href="' + item.link + '" target="_self"><img src="' + item.url + '" width="940" height="275" alt="' + item.title + '" /></a>';;
};

jQuery(document).ready(function() {
    jQuery('#aomcarousel').jcarousel({
        wrap: 'circular',
        initCallback: myInit,
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });

});
