//** Created: Gary Raberov
//** Oct 2nd, 2009

var mycarousel_itemList = [
    {url: '../../../Img/Home/Carousel/Icons/BedRoomSets_PNG.png', title: '/bedroom-furniture/package-specials.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Sofas_PNG.png', title: '/living-room-furniture/sofas.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/DinetteSets_PNG.png', title: '/dining-room-furniture/casual/package-specials.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/QueenMattress_PNG.png', title: '/mattresses/queen-mattress-sets.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Entertainment_PNG.png', title: '/entertainment-furniture/wall-units-and-stands.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Chairs_PNG.png', title: '/living-room-furniture/chairs.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/QueenBed_PNG.png', title: '/bedroom-furniture/queen-beds.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/CocktailTables_PNG.png', title: '/occasional-tables/cocktail-tables.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/DiningSets_PNG.png', title: '/dining-room-furniture/formal/package-specials.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/AccentPieces_PNG.png', title: '/home-accents/accent-pieces.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/LivingRoomSets_PNG.png', title: '/living-room-furniture/package-specials.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/TwinBeds_PNG.png', title: '/kids-furniture/twin-beds.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Recliners_PNG.png', title: '/living-room-furniture/motion/recliner-rockers.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Rugs_PNG.png', title: '/home-accents/area-rugs.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/KingBed_PNG.png', title: '/bedroom-furniture/king-beds.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Sectional_PNG.png', title: '/living-room-furniture/sectionals.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/KidsBedroomSets2_PNG.png', title: '/kids-furniture/package-specials.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/DiningTables_PNG.png', title: '/dining-room-furniture/formal/tables.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/KingMattress_PNG.png', title: '/mattresses/king-mattress-sets.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/OccasionalTables_PNG.png', title: '/occasional-tables/table-sets.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/SleeperSofas_PNG.png', title: '/living-room-furniture/sleepers.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Dressers-Chests_PNG.png', title: '/bedroom-furniture/dressers.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/FullBed_PNG.png', title: '/kids-furniture/full-beds.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Lamps_PNG.png', title: '/home-accents/lighting.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/HomeOffice_PNG.png', title: '/home-accents/home-office.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/DinetteTables_PNG.png', title: '/dining-room-furniture/casual/tables.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Lofts-BunkBeds_PNG.png', title: '/kids-furniture/loft-bunk-beds.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/Nightstands_PNG.png', title: '/bedroom-furniture/nightstands.aspx'},
    {url: '../../../Img/Home/Carousel/Icons/SofalTables_PNG.png', title: '/occasional-tables/sofa-tables.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 + '" /></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();
//} 

