dojo.require("site.cardSet");
dojo.require("generic.menu");

dojo.addOnLoad(
    function() {
    
        // init recipe cards
        var recipe_card_data = page_data.catalog.recipe_card;
        if (typeof recipe_card_data !== "undefined") {
            if (recipe_card_data.cards.length > 0) {  
            	dojo.require("site.layout.RecipeCardSet");
                var recipeCards = new site.layout.RecipeCardSet({
                    cards: recipe_card_data.cards,
                    container: "recipe_img", 
                    buttonNext: "btn_recipe_next", 
                    buttonPrevious: "btn_recipe_prev",
                    counterCurrent: "recipe_count_current",
                    counterTotal: "recipe_count_total",
                    productMax: 4
                });
                recipeCards.startup();
                
                // init recipe card filter menu
                var recipeFilter = new generic.menu({
                    menu: "recipe_filter_menu",
                    target: "recipe_filter_menu_hd"
                });
                dojo.query("#recipe_filter_menu a div").forEach(
                    function(node) {
                        var recipeFilterLink = new generic.menuItem({
                            domNode: node,
                            rolloverClass: "on"
                        });
                    }
                );
            }
        }
        
        // init stylist cards
        var stylist_card_data = page_data.catalog.stylist_favorites;
        if (typeof stylist_card_data !== "undefined") {
            if (stylist_card_data.cards.length > 0) {
                var stylistCards = new site.cardSet({
                    cards: stylist_card_data.cards,         
                    name: "stylist_card",
                    container: "fav_container", 
                    buttonNext: "btn_stylist_next", 
                    buttonPrevious: "btn_stylist_prev",
                    counterCurrent: "stylist_count_current",
                    counterTotal: "stylist_count_total",
                    productMax: 2 // page_data lists more than 2 products, but template only shows 2
                });
                stylistCards.startup();
            }
        }        
    }
);
