/*
    recipe_view.js Popup for meal plan category subscription
    Dependencies : Prototype JavaScript framework 1.6
                   utilities.js
*/

var SOSCuisine = SOSCuisine || {};

SOSCuisine.recipeView =
{
    addToExcludedRecipeList: function(obj, recipeId)
    {
        this.recipeId = recipeId;

        if (this.windowExcludeRecipeWarning == null)
        {
            var options =
            {
                title: $('windowAlertTitle').innerHTML,
                message: $('windowAlertMessage').innerHTML,
                submitValue: $('windowAlertSubmit').innerHTML,
                cancelValue: $('windowAlertCancel').innerHTML,
                showSubmit: true,
                showCancel: true,
                callback:
                {
                    success: function(args)
                    {
                        this.redirectTo("add_to_excluded_recipe");
                    } .bind(this),

                    cancel: function() { }
                }
            }
            this.windowExcludeRecipeWarning = new SOSCuisine.WindowAlert("window_exclude_recipe_warning", options);
        }

        this.windowExcludeRecipeWarning.show({ source: obj });

    },

    removeFromExcludedRecipeList: function(obj, recipeId)
    {
        this.redirectTo("remove_from_excluded_recipe");
    },

    redirectTo: function(action)
    {
        var url = document.location.href.replace(document.location.search, "");
        var queryParams = document.location.search.toQueryParams();
        queryParams.recipe_action = action;
        window.location = url + "?" + Object.toQueryString(queryParams);
    }

};