//** Created: Gary Raberov
//** Oct 2nd, 2009

/*

var mycarousel_itemList = [
    {url: '/Img/Home/Carousel/Icons/icon-sofas.png', title: '/living-room-furniture/sofas.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-dinettesets.png', title: '/dining-room-furniture/dining-sets.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-washersdryers.png', title: '/appliances/washer-dryers/washers-dryers.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-queenmattresssets.png', title: '/mattresses/queen-mattress-sets.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-refrigerators.png', title: '/appliances/refrigerators.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-bedroomsets.png', title: '/bedroom-furniture/bedroom-sets.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-freezers.png', title: '/appliances/freezers.aspx'}, 
    {url: '/Img/Home/Carousel/Icons/icon-recliners.png', title: '/living-room-furniture/motion/recliner-rockers.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-twinbeds.png', title: '/youth-furniture/twin-beds.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-ranges.png', title: '/appliances/ranges.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-sectionals.png', title: '/living-room-furniture/sectionals.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-plasmatvs.png', title: '/electronics/televisions/all-sizes/plasma-tvs.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-queenbeds.png', title: '/bedroom-furniture/queen-beds.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-dishwashers.png', title: '/appliances/dishwashers.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-fullmattresssets.png', title: '/mattresses/full-mattress-sets.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-tvstands.png', title: '/entertainment-furniture/wall-units-and-stands.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-cocktailtables.png', title: '/occasional-tables/cocktail-tables.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-sofabeds.png', title: '/living-room-furniture/sleepers.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-nighttables.png', title: '/bedroom-furniture/nightstands.aspx'},
    {url: '/Img/Home/Carousel/Icons/icon-dresserschests.png', title: '/bedroom-furniture/dressers.aspx'}
];

*/

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 + '" alt="' + item.title + '" /></a>';
};

function SetupHomeCarousel(MyCarouselId, Vertical){    
    $(document).ready(function() {        
        $('#'+MyCarouselId).jcarousel({
            // Configuration goes here
            // itemLoadCallback: itemLoadCallbackFunction
            vertical: Vertical,
            scroll: 4,
            animation: "slow",
            wrap: "circular",
            itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
            itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
        });        
    });
}

