//** Created: Gary Raberov
//** Oct 2nd, 2009



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.title +'"><img src="' + item.url + '" /></a>'; //alt="' + item.title + '"

};

function SetupHomeCarousel(MyCarouselId, Vertical)
{
    jQuery(document).ready(function() {
        
        jQuery('#'+MyCarouselId).jcarousel({
            // Configuration goes here
            // itemLoadCallback: itemLoadCallbackFunction
            vertical: Vertical,
            //buttonNextEvent: 'mouseover',
            //buttonPrevEvent: 'mouseover',
            scroll: 3,
            animation: "slow",
            wrap: "circular",
            itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
            itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
        });
    });
}

// for Ajax to register with script manager
// if( Sys && Sys.Application ){
//   Sys.Application.notifyScriptLoaded();
//} 

