/// <summary> Clears the list of all URL Portals into this library / cms </summary>
 public void Clear()
 {
     All_Portals.Clear();
     defaultPortal = null;
 }
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            // Set the help for these subelements
            const string PORTAL_NAME_HELP = "Name for the system when accessed through this url portal.  This additionally identifies this url portal to administrators.\n\nFor example, Digital Library of the Caribbean, or University of Florida Digital Collections.";
            const string ABBREVIATION_HELP = "Abbreviation for the system, when accessed through this url portal.\n\nFor example, 'dLOC', or UFDC.";
            const string WEB_SKIN_HELP = "Default web skin under which this url portal should be displayed.  If none is probided, it will default to the system web skin.";
            const string AGGREGATION_HELP = "Default aggregation which should be displayed under this url portal.  If none is provided, this url portal will display the main system home page.";
            const string URL_SEGMENT_HELP = "URL segment used for matching purposes to determine which url portal a user is accessing this system from.\n\nA blank URL portal will make this the default portal.";
            const string BASE_PURL_HELP = "Base permanent link URL to be used when constructing permanent URLs for items which do not have itt explicitly entered.\n\nA blank value here will result in the current URL being used as the base for the purl.";

            Tracer.Add_Trace("Portals_AdminViewer.Write_ItemNavForm_Closing", "Adds the portal information to the main form");

            Output.WriteLine("<!-- Portals_AdminViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");
            Output.WriteLine();

            // Add the hidden field
            Output.WriteLine("<!-- Hidden fields are used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_portal_action\" name=\"admin_portal_action\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_portal_tosave\" name=\"admin_portal_tosave\" value=\"\" />");
            Output.WriteLine();

            // Only system admins can edit the URL portals
            string readonly_string = String.Empty;
            string disabled_string = String.Empty;
            if (readOnlyMode)
            {
                readonly_string = " readonly=\"readonly\" ";
                disabled_string = " disabled=\"disabled\" ";
            }

            Output.WriteLine("<!-- URL Portal Edit Form -->");
            Output.WriteLine("<div class=\"sbkPoav_PopupDiv\" id=\"form_portal\" style=\"display:none;\">");
            if (readOnlyMode)
                Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%;\"><tr style=\"height:20px;\"><td style=\"text-align:left;\">VIEW URL PORTAL</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"portal_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            else
                Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%;\"><tr style=\"height:20px;\"><td style=\"text-align:left;\">EDIT URL PORTAL</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"portal_form_close()\">X</a> &nbsp; </td></tr></table></div>");

            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkAdm_PopupTable\">");

            // Add the line for the url portal name
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:145px;\"><label for=\"form_portal_name\">Portal Name:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"form_portal_name\" id=\"form_portal_name\" type=\"text\" value=\"\" " + readonly_string + " /></td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the url portal abbreviation
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_portal_abbr\">System Abbreviation:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"form_portal_abbr\" id=\"form_portal_abbr\" type=\"text\" value=\"\" " + readonly_string + " /></td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the default web skin
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_portal_skin\">Default Web Skin:</label></td>");
            Output.WriteLine("      <td>");

            //Output.WriteLine("        <input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"form_portal_skin\" id=\"form_portal_skin\" type=\"text\" value=\"\" /></td>");

            Output.WriteLine("        <select class=\"sbkPoav_select\" name=\"form_portal_skin\" id=\"form_portal_skin\" " + disabled_string + ">");
            foreach (string thisSkin in UI_ApplicationCache_Gateway.Web_Skin_Collection.Ordered_Skin_Codes)
            {
                Output.WriteLine("          <option value=\"" + thisSkin.ToLower() + "\">" + thisSkin.ToLower() + "</option>");
            }
            Output.WriteLine("        </select>");

            Output.WriteLine("      </td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the default aggregation
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_portal_aggregation\">Default Aggregation:</label></td>");
            Output.WriteLine("        <td>");
            Output.WriteLine("            <select class=\"sbkPoav_select sbkAdmin_Focusable\" name=\"form_portal_aggregation\" id=\"form_portal_aggregation\" " + disabled_string + " >");
            Output.WriteLine("              <option value=\"\"></option>");
            foreach (Item_Aggregation_Related_Aggregations thisAggr in UI_ApplicationCache_Gateway.Aggregations.All_Aggregations)
            {
                if (thisAggr.Code != "ALL")
                {
                    string display = thisAggr.Code.ToLower() + " - " + thisAggr.ShortName;
                    if (display.Length > 40)
                        display = display.Substring(0, 40) + "...";

                    Output.WriteLine("              <option value=\"" + thisAggr.Code.ToUpper() + "\">" + HttpUtility.HtmlEncode(display) + "</option>");
                }
            }
            Output.WriteLine("            </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the base url segment
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_portal_url\">URL Segment:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"form_portal_url\" id=\"form_portal_url\" type=\"text\" value=\"\" " + readonly_string + " /></td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the base purl
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_portal_purl\">Base PURL:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"form_portal_purl\" id=\"form_portal_purl\" type=\"text\" value=\"\" " + readonly_string + " /></td>");
            Output.WriteLine("      <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the buttons and close out the pop-up table
            Output.WriteLine("    <tr style=\"height:35px; text-align: center; vertical-align: bottom;\">");
            Output.WriteLine("      <td colspan=\"3\">");
            if (readOnlyMode)
            {
                Output.WriteLine("        <button title=\"Close this form\" class=\"sbkAdm_RoundButton\" onclick=\"return portal_form_close();\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CLOSE</button>");
            }
            else
            {
                Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return portal_form_close();\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
                Output.WriteLine("        <button title=\"Save changes to this existing portal\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
            }
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
            Output.WriteLine();

            Output.WriteLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Admin_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (actionMessage.Length > 0)
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            Output.WriteLine("  <p>URL portals allow the same SobekCM library to have a very different look and feel and encompass different item aggregations.  Each portal is defined by the incoming URL and the URL for each incoming request is analyzed to ensure it is handled correctly.</p>");
            Output.WriteLine("  <p>For more information about URL portals, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/portals\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</p>");

            // Add portal admin message
            int columns = 6;
            if (readOnlyMode)
            {
                Output.WriteLine("<p>Portal Admins have rights to see these settings. System Admins can change these settings.</p>");
            }
            else
            {
                Output.WriteLine("  <h2>New URL Portal</h2>");
                Output.WriteLine("  <p>To add a new URL portal to this system, enter the information below and press SAVE.</p>");
                Output.WriteLine("  <div class=\"sbkPoav_NewDiv\">");
                Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

                Portal newPortal = new Portal(-1, entered_portal_name, entered_sys_abbrev, entered_aggregation, entered_web_skin, entered_url_segment, entered_base_purl);

                // Add the line for the url portal name
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td style=\"width:145px;\"><label for=\"admin_portal_name\">Portal Name:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"admin_portal_name\" id=\"admin_portal_name\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Name) + "\" /></td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the line for the url portal abbreviation
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td><label for=\"admin_portal_abbr\">System Abbreviation:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"admin_portal_abbr\" id=\"admin_portal_abbr\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Abbreviation) + "\" /></td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the line for the default web skin
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td><label for=\"admin_portal_skin\">Default Web Skin:</label></td>");

                Output.WriteLine("        <td>");

                //Output.WriteLine("        <input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"admin_portal_skin\" id=\"admin_portal_skin\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Default_Web_Skin) + "\" />");

                Output.WriteLine("          <select class=\"sbkPoav_select\" name=\"admin_portal_skin\" id=\"admin_portal_skin\">");

                if (newPortal.Default_Web_Skin.Trim().Length == 0)
                    Output.WriteLine("            <option value=\"\" selected=\"selected\"></option>");
                else
                    Output.WriteLine("            <option value=\"\"></option>");

                foreach (string thisSkin in UI_ApplicationCache_Gateway.Web_Skin_Collection.Ordered_Skin_Codes)
                {
                    if (String.Compare(thisSkin, newPortal.Default_Web_Skin, StringComparison.OrdinalIgnoreCase) == 0)
                        Output.WriteLine("            <option value=\"" + thisSkin.ToLower() + "\" selected=\"selected\">" + thisSkin.ToLower() + "</option>");
                    else
                        Output.WriteLine("            <option value=\"" + thisSkin.ToLower() + "\">" + thisSkin.ToLower() + "</option>");
                }
                Output.WriteLine("          </select>");

                Output.WriteLine("        </td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the line for the default aggregation
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td><label for=\"admin_portal_aggregation\">Default Aggregation:</label></td>");
                Output.WriteLine("        <td>");
                Output.WriteLine("            <select class=\"sbkPoav_select sbkAdmin_Focusable\" name=\"admin_portal_aggregation\" id=\"admin_portal_aggregation\">");
                if (entered_aggregation.Length == 0)
                {
                    Output.WriteLine("              <option value=\"\" selected=\"selected\"></option>");
                }
                else
                {
                    Output.WriteLine("              <option value=\"\"></option>");
                }

                foreach (Item_Aggregation_Related_Aggregations thisAggr in UI_ApplicationCache_Gateway.Aggregations.All_Aggregations)
                {
                    if (thisAggr.Code != "ALL")
                    {
                        string display = thisAggr.Code.ToLower() + " - " + thisAggr.ShortName;
                        if (display.Length > 40)
                            display = display.Substring(0, 40) + "...";

                        if (String.Compare(thisAggr.Code, newPortal.Default_Aggregation, StringComparison.OrdinalIgnoreCase) == 0)
                            Output.WriteLine("              <option value=\"" + thisAggr.Code + "\" selected=\"selected\">" + HttpUtility.HtmlEncode(display) + "</option>");
                        else
                            Output.WriteLine("              <option value=\"" + thisAggr.Code + "\">" + HttpUtility.HtmlEncode(display) + "</option>");
                    }
                }
                Output.WriteLine("            </select>");
                Output.WriteLine("        </td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the line for the base url segment
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td><label for=\"admin_portal_url\">URL Segment:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"admin_portal_url\" id=\"admin_portal_url\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.URL_Segment) + "\" /></td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the line for the base purl
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td><label for=\"admin_portal_purl\">Base PURL:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkPoav_input sbkAdmin_Focusable\" name=\"admin_portal_purl\" id=\"admin_portal_purl\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Base_PURL) + "\" /></td>");
                Output.WriteLine("        <td><img class=\"sbkPoav_HelpButton\" src=\"" + Static_Resources_Gateway.Help_Button_Jpg + "\" onclick=\"alert('" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" title=\"" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", " ") + "\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the SAVE button
                Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"3\"><button title=\"Save new portal\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_portal();\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
                Output.WriteLine("    </table>");
                Output.WriteLine("  </div>");
                Output.WriteLine("  <br />");
                Output.WriteLine();
            }

            Output.WriteLine("  <h2>Existing URL Portals</h2>");
            Output.WriteLine("  <p>The following URL portals are active:</p>");

            Output.WriteLine("  <table class=\"sbkPoav_Table sbkAdm_Table\">");
            Output.WriteLine("    <tr>");
            if (RequestSpecificValues.Current_User.Is_System_Admin)
                Output.WriteLine("      <th class=\"sbkPoav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("      <th class=\"sbkPoav_TableHeader2\">PORTAL<br />NAME</th>");
            Output.WriteLine("      <th class=\"sbkPoav_TableHeader3\">SYSTEM<br />ABBREVIATION</th>");
            Output.WriteLine("      <th class=\"sbkPoav_TableHeader4\">DEFAULT<br />WEB SKIN</th>");
            Output.WriteLine("      <th class=\"sbkPoav_TableHeader5\">DEFAULT<br />AGGREGATION</th>");
            Output.WriteLine("      <th class=\"sbkPoav_TableHeader6\">URL<br />SEGMENT</th>");
            Output.WriteLine("    </tr>");

            // Write the default portal first
            Output.WriteLine("    <tr>");
            if (RequestSpecificValues.Current_User.Is_System_Admin)
            {
                if (UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.ID > 0)
                {
                    Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                    Portal thisPortal = UI_ApplicationCache_Gateway.URL_Portals.Default_Portal;
                    if (readOnlyMode)
                        Output.WriteLine("      <a title=\"View this portal\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup( '" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation.ToUpper() + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">view</a> ) </td>");
                    else
                        Output.WriteLine("      <a title=\"Edit this portal\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup( '" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation.ToUpper() + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">edit</a> ) </td>");
                }
                else
                {
                    Output.WriteLine("    <td>&nbsp;</td>");
                }
            }
            Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.Name) + "</td>");
            Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.Abbreviation) + "</td>");
            Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.Default_Web_Skin) + "</td>");
            Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.Default_Aggregation) + "</td>");
            Output.WriteLine("      <td id=\"sbkPoav_DefaultCell\">default</td>");

            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"" + columns + "\"></td></tr>");

            // Write the data for each portal
            foreach (Portal thisPortal in UI_ApplicationCache_Gateway.URL_Portals.All_Portals)
            {
                if (thisPortal != UI_ApplicationCache_Gateway.URL_Portals.Default_Portal)
                {
                    Output.WriteLine("    <tr>");
                    if (RequestSpecificValues.Current_User.Is_System_Admin)
                    {
                        Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                        if (readOnlyMode)
                        {
                            Output.Write("<a title=\"View this portal\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup( '" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation.ToUpper() + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">view</a> )</td>");
                        }
                        else
                        {
                            Output.Write("<a title=\"Edit this portal\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup( '" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation.ToUpper() + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">edit</a> | ");
                            Output.WriteLine("<a title=\"Delete this portal\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return delete_portal('" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "');\">delete</a> )</td>");
                        }
                    }
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(thisPortal.Name) + "</td>");
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(thisPortal.Abbreviation) + "</td>");
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(thisPortal.Default_Web_Skin) + "</td>");
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(thisPortal.Default_Aggregation) + "</td>");
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(thisPortal.URL_Segment) + "</td>");
                    Output.WriteLine("    </tr>");
                    Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"" + columns + "\"></td></tr>");
                }
            }
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
        }
 /// <summary> Create and add a new portal to this collection URL portals </summary>
 /// <param name="ID"> Primary key for this portal in the database </param>
 /// <param name="Name"> Name for the library when viewed through this portal</param>
 /// <param name="Abbreviation"> Abbreviation used for the library when viewed through this portal </param>
 /// <param name="Default_Aggregation"> Default aggregation, or 'all' if all aggregationPermissions are available </param>
 /// <param name="Default_Web_Skin"> Default web skin used when displayed through this portal </param>
 /// <param name="URL_Segment"> URL segment used to determine if a request comes from this portal </param>
 /// <param name="Base_PURL"> Base PURL to used when constructing a PURL for items within this portal, if it is different than the standard base URL </param>
 /// <returns> Built and added URL Portal for any additional work ( limiting by web skin or aggregationPermissions )</returns>
 public Portal Add_Portal( int ID, string Name, string Abbreviation, string Default_Aggregation, string Default_Web_Skin, string URL_Segment, string Base_PURL )
 {
     Portal returnValue = new Portal(ID, Name, Abbreviation, Default_Aggregation, Default_Web_Skin, URL_Segment, Base_PURL );
     All_Portals.Add(returnValue);
     return returnValue;
 }