
(function ($) {

    //------------------------------------------------------------------------------------------
    // build carousel for SAGE cmd
    //------------------------------------------------------------------------------------------
    // parameters : sageCmd : sage commands
    //------------------------------------------------------------------------------------------
    // return : carousel model
    //-----------------------------------------------------------------------------------------
    $.fn.buildSageCmdCarousel = function (sageCmd) {

        var carousel = new $.fn.carouselModel();

        for (var i = 0; i < sageCmd.length; i++) {
            // create horizontal carousel
            var carouselHoriz = new $.fn.carouselHorizModel(sageCmd[i].name);
            for (var j = 0; j < sageCmd[i].cmdList.length; j++) {
                // add tiles in horizontal carousel
                var isFirst = (j == 0);
                var isLast = (j == (sageCmd[i].cmdList.length - 1));
                var backgroudColor = sageCmd[i].cmdList[j].backgroudColor;
                var carouselTile = new $.fn.carouselTileModel(sageCmd[i].cmdList[j], sageCmd[i].cmdList[j].enable, backgroudColor, isFirst, isLast);
                carouselHoriz.tileList.push(carouselTile);
            }
            carousel.horizList.push(carouselHoriz);
        }

        return carousel;
    }

   
})(jQuery);