private void InitMasterPage()
    {
        if (dialogMode)
        {
            SetTitle("Objects/CMS_WebPartContainer/object.png", GetString("container_edit.editcontainer"), "newedit_container", "helpTopic");

            string selector = QueryHelper.GetString("selectorid", string.Empty);
            if (!string.IsNullOrEmpty(selector) && RequestHelper.IsPostBack())
            {
                ScriptHelper.RegisterWOpenerScript(this);

                // Add selector update script
                string updateScript = string.Format(@"if (wopener && wopener.US_SelectNewValue_{0}) {{ wopener.US_SelectNewValue_{0}('{1}'); }}", selector, webPartContainer.ContainerName);
                ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", updateScript, true);
            }
        }
        else
        {
            SetTitle("Objects/CMS_WebPartContainer/object.png", GetString("container_edit.headercaption"), "newedit_container", "helpTopic");

            // Set breadcrumbs
            InitBreadcrumbs(2);
            SetBreadcrumb(0, GetString("container_edit.itemlistlink"), ResolveUrl("Container_List.aspx"), "_parent", null);
            SetBreadcrumb(1, webPartContainer.ContainerDisplayName, null, null, null);
        }

        // Set tabs
        InitTabs("content");
        int i = 0;

        string url = URLHelper.RemoveParameterFromUrl("Container_Edit_General.aspx" + URLHelper.Url.Query, "saved");

        if (containerId == 0)
        {
            url = URLHelper.AddParameterToUrl(url, "name", webPartContainer.ContainerName);
        }

        SetTab(i++, GetString("general.general"), url, "SetHelpTopic('helpTopic', 'newedit_container');");

        if (!dialogMode)
        {
            if (!StorageHelper.IsExternalStorage(webPartContainer.GetThemePath()))
            {
                SetTab(i++, GetString("stylesheet.theme"), "Container_Edit_Theme.aspx?containerId=" + webPartContainer.ContainerID, "SetHelpTopic('helpTopic', 'webpartcontainer_theme_tab');");
            }

            SetTab(i++, GetString("general.sites"), "Container_Edit_Sites.aspx?containerId=" + webPartContainer.ContainerID, "SetHelpTopic('helpTopic', 'webpartcontainer_sites_tab');");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup the filesystem browser
        int containerId = QueryHelper.GetInteger("containerid", 0);

        if (containerId > 0)
        {
            WebPartContainerInfo ci = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId);
            EditedObject = ci;

            if (ci != null)
            {
                // Ensure the theme folder
                themeElem.Path = ci.GetThemePath();
            }
        }
        else
        {
            EditedObject = null;
        }
    }