/*
    form_meal_plan_category_subscribe.js Popup for meal plan category subscription
    Dependencies : Prototype JavaScript framework 1.6
                   utilities.js
*/

var SOSCuisine = SOSCuisine || {};

SOSCuisine.windowMealPlanCategorySubscribe =    
{
    container : null,

    initialize : function()
    {
       
    },

    loadContent : function(mealPlanCategoryCode)
    {
       this.container.style.backgroundImage = "url(" + SOSCuisine.config.urlRoot + "media/images/ajax-loader.gif)";
       this.container.style.height = "200px";
       new Ajax.Request(SOSCuisine.config.urlRoot + "meal_plan_category_subscribe.php", 
       {
           method : "get",
           encoding: 'iso-8859-1',
           parameters : {meal_plan_category_code: mealPlanCategoryCode, ajax : true},
           onSuccess : function(transport) 
           {
              this.container.style.height = "auto";
              this.container.style.backgroundImage = "";              
              var response = transport.responseText || "";
              this.container.innerHTML = response;
           }.bind(this)
       });
    },

    setSelectVisibility : function(visible)
    {
       nodes = document.getElementsByTagName('select');
       for (var i = 0; i < nodes.length; i++)
       {
           nodes[i].style.visibility = visible;
       }
    },
                        
    show : function(mealPlanCategoryCode, redirectUrl)
    {       
       this.redirectUrl = redirectUrl;
       if (this.container == null)
       {
           this.container = document.getElementById("modal_dialog_content_meal_plan_category_subscribe");
       }
       
       if (window.scrollTo) 
       {
           window.scrollTo(0,0);
       }        
       
       SOSCuisine.overlay.showOverlay();
       document.getElementById("modal_dialog_meal_plan_category_subscribe").style.visibility = "visible";
       document.getElementById("sidebar_ads").style.display = "none";           
       
       this.loadContent(mealPlanCategoryCode);       
    },

    hide : function()
    {
       document.getElementById("modal_dialog_meal_plan_category_subscribe").style.visibility = "hidden";
       document.getElementById("sidebar_ads").style.display = "block";           
       SOSCuisine.overlay.hideOverlay();
       this.container.innerHTML = "";
    }
};
