// var mytestimonials_itemList = [];

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)
{
//alert('remove: '+i);
    carousel.remove(i);
}

function mytestimonials_itemVisibleInCallback(carousel, item, i, state, evt)
{
// alert('visible in');
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mytestimonials_itemList.length);
    carousel.add(i, mytestimonials_itemList[idx - 1]);
}

function mypreview_itemVisibleOutCallback(carousel, item, i, state, evt)
{
// alert('remove: '+i);
	carousel.remove(i);
}

function mypreview_itemVisibleInCallback(carousel, item, i, state, evt)
{
// alert('visible in');
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mypreview_itemList.length);
    carousel.add(i, mypreview_itemList[idx - 1]);
}

function mytestimonials_itemVisibleOutCallback(carousel, item, i, state, evt)
{
// alert('remove: '+i);
	carousel.remove(i);
}

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    // return '<a href="#" onClick="alert('+uid+');"><img src="' + item.url + '" width="75" height="75" alt="' + name+ '" /></a>';
    return '<a href="'+item.href+'" onClick="alert('+item.href+');"><img src="' + item.url + '" alt="' + item.name + '" /><br/><span class="jcarousel-clip-item-name">'+item.name+'</span></a>';
}

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
        auto: 3,
        scroll: 1,
        animation: 'fast',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });
    
    // mytestimonials_itemList = jQuery('#mytestimonials li');
    // alert (mytestimonials_itemList.length);
    
    jQuery('#mytestimonials').jcarousel({
    	wrap: 'circular',
    	vertical: true,
    	auto: 8,
    	scroll: 1,
    	animation: 'slow',
    	itemVisibleInCallback: {onBeforeAnimation: mytestimonials_itemVisibleInCallback},
    	itemVisibleOutCallback: {onAfterAnimation: mytestimonials_itemVisibleOutCallback}
    });
    /*
    jQuery('#mypreview').jcarousel({
    	wrap: 'circular',
    	vertical: true,
    	auto: 1,
    	scroll: 1,
    	animation: 'slow',
    	itemVisibleInCallback: {onBeforeAnimation: mypreview_itemVisibleInCallback},
    	itemVisibleOutCallback: {onAfterAnimation: mypreview_itemVisibleOutCallback}
    });
    */
});


