/// <summary> Creates the specific results viewer according the user's preferences in the current request mode </summary>
        private void create_resultwriter()
        {
            if ( RequestSpecificValues.Results_Statistics.Total_Items == 0)
            {
                resultWriter = new No_Results_ResultsViewer(RequestSpecificValues);
                return;
            }

            // If this is default, determine the type from the aggregation (currently) or user
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Default)
            {
                if ( !String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Coordinates))
                    RequestSpecificValues.Current_Mode.Result_Display_Type = Result_Display_Type_Enum.Map;
                else
                {
                    string user_view = "default";
                    if (HttpContext.Current.Session["User_Default_View"] != null)
                        user_view = HttpContext.Current.Session["User_Default_View"].ToString();
                    RequestSpecificValues.Current_Mode.Result_Display_Type = RequestSpecificValues.Hierarchy_Object.Default_Result_View;
                    switch (user_view)
                    {
                        case "brief":
                            if (RequestSpecificValues.Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Brief))
                                RequestSpecificValues.Current_Mode.Result_Display_Type = Result_Display_Type_Enum.Brief;
                            break;

                        case "thumb":
                            if (RequestSpecificValues.Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Thumbnails))
                                RequestSpecificValues.Current_Mode.Result_Display_Type = Result_Display_Type_Enum.Thumbnails;
                            break;

                        case "table":
                            if (RequestSpecificValues.Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Table))
                                RequestSpecificValues.Current_Mode.Result_Display_Type = Result_Display_Type_Enum.Table;
                            break;

                    }

                }
            }

            // Create the bookshelf view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Bookshelf)
            {
                if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.My_Sobek)
                {
                    resultWriter = new Bookshelf_View_ResultsViewer(RequestSpecificValues);
                }
                else
                {
                    resultWriter = new Brief_ResultsViewer(RequestSpecificValues);
                }
            }

            // Create the result writer and populate the sort list for BRIEF view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Brief)
            {
                resultWriter = new Brief_ResultsViewer(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for THUMBNAIL view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Thumbnails)
            {
                resultWriter = new Thumbnail_ResultsViewer(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for TABLE view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Table)
            {
                resultWriter = new Table_ResultsViewer(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for FULL view
            if ((RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Full_Citation) || (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Full_Image))
            {
                resultWriter = new Full_ResultsViewer(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for MAP view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Map)
            {
                resultWriter = new Google_Map_ResultsViewer(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for MAP view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Map_Beta)
            {
                resultWriter = new Google_Map_ResultsViewer_Beta(RequestSpecificValues);
            }

            // Create the result writer and populate the sort list for TEXT view
            if (RequestSpecificValues.Current_Mode.Result_Display_Type == Result_Display_Type_Enum.Export)
            {
                resultWriter = new Export_File_ResultsViewer(RequestSpecificValues);
            }

            // Populate the sort list and sort the result set
            sortOptions = String.Empty;
            StringBuilder sort_options_builder = new StringBuilder(1000);
            if ((resultWriter.Sortable) && (!RequestSpecificValues.Current_Mode.Is_Robot))
            {
                // Add the special sorts for browses
                if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Aggregation) // browse info only
                {
                    if (RequestSpecificValues.Current_Mode.Info_Browse_Mode.ToUpper().IndexOf("NEW") >= 0)
                    {
                        if (RequestSpecificValues.Current_Mode.Sort == 0)
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Added", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Added", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }

                        if (RequestSpecificValues.Current_Mode.Sort == 1)
                        {
                            sort_options_builder.Append("      <option value=\"" + 1 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 1 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }
                    }
                    else
                    {
                        if ((RequestSpecificValues.Current_Mode.Sort == 0) || (RequestSpecificValues.Current_Mode.Sort == 1))
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                        }
                    }
                }

                // Add the special sorts for searches
                if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Results)
                {
                    if (RequestSpecificValues.Current_Mode.Sort == 0)
                    {
                        sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Rank", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 0 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Rank", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }

                    if (RequestSpecificValues.Current_Mode.Sort == 1)
                    {
                        sort_options_builder.Append("      <option value=\"" + 1 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 1 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Title", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                }

                // Add the bibid sorts if this is an internal user
                if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn) && (RequestSpecificValues.Current_User.Is_Internal_User))
                {
                    if (RequestSpecificValues.Current_Mode.Sort == 2)
                    {
                        sort_options_builder.Append("      <option value=\"" + 2 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("BibID Ascending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 2 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("BibID Ascending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }

                    if (RequestSpecificValues.Current_Mode.Sort == 3)
                    {
                        sort_options_builder.Append("      <option value=\"" + 3 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("BibID Descending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 3 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("BibID Descending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                    }
                }

                // Add the publication date sorts
                if (RequestSpecificValues.Current_Mode.Sort == 10)
                {
                    sort_options_builder.Append("      <option value=\"" + 10 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Ascending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                }
                else
                {
                    sort_options_builder.Append("      <option value=\"" + 10 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Ascending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                }

                if (RequestSpecificValues.Current_Mode.Sort == 11)
                {
                    sort_options_builder.Append("      <option value=\"" + 11 + "\" selected=\"selected\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Descending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                }
                else
                {
                    sort_options_builder.Append("      <option value=\"" + 11 + "\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Date Descending", RequestSpecificValues.Current_Mode.Language) + "</option>" + Environment.NewLine );
                }

                sortOptions = sort_options_builder.ToString();
            }
        }
        /// <summary> Gets the indicated results viewer, by results viewer code, usually from the URL </summary>
        /// <param name="ViewerCode"> Code which indicates which results viewer </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
        /// <param name="PagedResults"> Actual pages of results </param>
        /// <returns> Either the results vieweer, or NULL </returns>
        public static iResultsViewer Get_Results_Viewer(string ViewerCode, RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults)
        {
            // Get the match by viewer code
            ResultsSubViewerConfig config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode(ViewerCode);

            // If no match, just try by viewer type then
            if (config == null)
            {
                config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByType(ViewerCode);
            }

            // If still null, return NULL
            if (config == null)
            {
                return(null);
            }

            // Was an assembly indicated
            if (String.IsNullOrEmpty(config.Assembly))
            {
                // Return a standard class
                switch (config.Class)
                {
                case "SobekCM.Library.ResultsViewer.Bookshelf_ResultsViewer":
                    return(new Bookshelf_View_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.Brief_ResultsViewer":
                    return(new Brief_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.Export_ResultsViewer":
                    return(new Export_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.Google_Map_ResultsViewer":
                    return(new Google_Map_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.Table_ResultsViewer":
                    return(new Table_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.Thumbnail_ResultsViewer":
                    return(new Thumbnail_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));

                case "SobekCM.Library.ResultsViewer.No_Results_ResultsViewer":
                    return(new No_Results_ResultsViewer(RequestSpecificValues, ResultsStats, PagedResults));
                }

                // If it made it here, there is no assembly, but it is an unexpected type.
                // Just create it from the same assembly then
                try
                {
                    Assembly       dllAssembly    = Assembly.GetCallingAssembly();
                    Type           prototyperType = dllAssembly.GetType(config.Class);
                    iResultsViewer returnObj      = (iResultsViewer)Activator.CreateInstance(prototyperType);
                    return(returnObj);
                }
                catch (Exception)
                {
                    // Not sure exactly what to do here, honestly
                    return(null);
                }
            }


            // An assembly was indicated
            try
            {
                // Try to find the file/path for this assembly then
                Assembly dllAssembly      = null;
                string   assemblyFilePath = UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Assembly(config.Assembly);
                if (assemblyFilePath != null)
                {
                    dllAssembly = Assembly.LoadFrom(assemblyFilePath);
                }
                Type           prototyperType = dllAssembly.GetType(config.Class);
                iResultsViewer returnObj      = (iResultsViewer)Activator.CreateInstance(prototyperType);
                return(returnObj);
            }
            catch (Exception ee)
            {
                // Not sure exactly what to do here, honestly
                if (ee.Message.Length > 0)
                {
                    return(null);
                }
                return(null);
            }
        }
        /// <summary> Gets the indicated results viewer, by results viewer code, usually from the URL </summary>
        /// <param name="ViewerCode"> Code which indicates which results viewer </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ResultsStats"> Statistics about the results to display including the facets </param>
        /// <param name="PagedResults"> Actual pages of results </param>
        /// <returns> Either the results vieweer, or NULL </returns>
        public static iResultsViewer Get_Results_Viewer(string ViewerCode, RequestCache RequestSpecificValues, Search_Results_Statistics ResultsStats, List <iSearch_Title_Result> PagedResults)
        {
            // Determine the actual viewercode
            string viewerCode = ViewerCode;

            if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.My_Sobek)
            {
                if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.ViewerCode))
                {
                    viewerCode = RequestSpecificValues.Current_Mode.ViewerCode;
                }
                else
                {
                    viewerCode = "brief";
                }
            }

            // Get the match by viewer code
            ResultsSubViewerConfig config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode(viewerCode);

            // If no match, just try by viewer type then
            if (config == null)
            {
                config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByType(viewerCode);
            }

            // If this is still NULL, just try to get the brief view
            if (config == null)
            {
                config = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Results.GetViewerByCode("brief");
            }

            // If still null, return NULL
            if (config == null)
            {
                return(null);
            }

            // Was an assembly indicated
            if (String.IsNullOrEmpty(config.Assembly))
            {
                iResultsViewer returnValue = null;

                // Return a standard class
                switch (config.Class)
                {
                case "SobekCM.Library.ResultsViewer.Bookshelf_ResultsViewer":
                    returnValue = new Bookshelf_View_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.Brief_ResultsViewer":
                    returnValue = new Brief_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.Export_ResultsViewer":
                    returnValue = new Export_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.Google_Map_ResultsViewer":
                    returnValue = new Google_Map_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.Table_ResultsViewer":
                    returnValue = new Table_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.Thumbnail_ResultsViewer":
                    returnValue = new Thumbnail_ResultsViewer();
                    break;

                case "SobekCM.Library.ResultsViewer.No_Results_ResultsViewer":
                    returnValue = new No_Results_ResultsViewer();
                    break;
                }

                if (returnValue == null)
                {
                    // If it made it here, there is no assembly, but it is an unexpected type.
                    // Just create it from the same assembly then
                    try
                    {
                        Assembly dllAssembly    = Assembly.GetCallingAssembly();
                        Type     prototyperType = dllAssembly.GetType(config.Class);
                        returnValue = (iResultsViewer)Activator.CreateInstance(prototyperType);
                    }
                    catch (Exception ee)
                    {
                        RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "Exception when creating a results viewer from the current assembly via reflection");
                        RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", ee.Message);

                        // Not sure exactly what to do here, honestly
                        return(null);
                    }
                }

                // If a results viewer was created, finish the construction and return it
                if (returnValue != null)
                {
                    returnValue.RequestSpecificValues = RequestSpecificValues;
                    returnValue.ResultsStats          = ResultsStats;
                    returnValue.PagedResults          = PagedResults;
                    return(returnValue);
                }

                // Return value must be NULL
                RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "NULL value when creating a results viewer from the current assembly (via reflection)");
                return(null);
            }


            // An assembly was indicated
            try
            {
                // Try to find the file/path for this assembly then
                Assembly dllAssembly      = null;
                string   assemblyFilePath = UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Assembly(config.Assembly);
                if (assemblyFilePath != null)
                {
                    dllAssembly = Assembly.LoadFrom(assemblyFilePath);
                }
                Type           prototyperType = dllAssembly.GetType(config.Class);
                iResultsViewer returnObj      = (iResultsViewer)Activator.CreateInstance(prototyperType);

                // If a results viewer was created, finish the construction and return it
                if (returnObj != null)
                {
                    returnObj.RequestSpecificValues = RequestSpecificValues;
                    returnObj.ResultsStats          = ResultsStats;
                    returnObj.PagedResults          = PagedResults;
                    return(returnObj);
                }

                // Return value must be NULL
                RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "NULL value when creating a results viewer from a separate assembly via reflection");
                return(null);
            }
            catch (Exception ee)
            {
                RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", "Exception when creating a results viewer from a separate assembly via reflection");
                RequestSpecificValues.Tracer.Add_Trace("ResultsViewer_Factory", ee.Message);

                return(null);
            }
        }
        /// <summary> Creates the specific results viewer according the user's preferences in the current request mode </summary>
        private void create_resultwriter()
        {
            if ( resultsStatistics.Total_Items == 0)
            {
                resultWriter = new No_Results_ResultsViewer
                                   {CurrentMode = currentMode, Results_Statistics = resultsStatistics};
                return;
            }

            // If this is default, determine the type from the aggregation (currently) or user
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Default)
            {
                if (currentMode.Coordinates.Length > 0)
                    currentMode.Result_Display_Type = Result_Display_Type_Enum.Map;
                else
                {
                    string user_view = "default";
                    if (HttpContext.Current.Session["User_Default_View"] != null)
                        user_view = HttpContext.Current.Session["User_Default_View"].ToString();
                    currentMode.Result_Display_Type = Hierarchy_Object.Default_Result_View;
                    switch (user_view)
                    {
                        case "brief":
                            if (Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Brief))
                                currentMode.Result_Display_Type = Result_Display_Type_Enum.Brief;
                            break;

                        case "thumb":
                            if (Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Thumbnails))
                                currentMode.Result_Display_Type = Result_Display_Type_Enum.Thumbnails;
                            break;

                        case "table":
                            if (Hierarchy_Object.Result_Views.Contains(Result_Display_Type_Enum.Table))
                                currentMode.Result_Display_Type = Result_Display_Type_Enum.Table;
                            break;

                    }

                }
            }

            // Create the bookshelf view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Bookshelf)
            {
                if (currentMode.Mode == Display_Mode_Enum.My_Sobek)
                {
                    resultWriter = new Bookshelf_View_ResultsViewer(allItems, currentUser);
                }
                else
                {
                    resultWriter = new Brief_ResultsViewer(allItems);
                }
            }

            // Create the result writer and populate the sort list for BRIEF view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Brief)
            {
                resultWriter = new Brief_ResultsViewer(allItems);
            }

            // Create the result writer and populate the sort list for THUMBNAIL view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Thumbnails)
            {
                resultWriter = new Thumbnail_ResultsViewer(allItems);
                ((Thumbnail_ResultsViewer)resultWriter).Code_Manager = codeManager;
            }

            // Create the result writer and populate the sort list for TABLE view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Table)
            {
                resultWriter = new Table_ResultsViewer(allItems);
            }

            // Create the result writer and populate the sort list for FULL view
            if ((currentMode.Result_Display_Type == Result_Display_Type_Enum.Full_Citation) || (currentMode.Result_Display_Type == Result_Display_Type_Enum.Full_Image))
            {
                resultWriter = new Full_ResultsViewer(allItems);
            }

            // Create the result writer and populate the sort list for MAP view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Map)
            {
                resultWriter = new Map_ResultsViewer(allItems);
            }

            // Create the result writer and populate the sort list for TEXT view
            if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Export)
            {
                resultWriter = new Export_File_ResultsViewer(allItems, currentUser);
            }

            resultWriter.CurrentMode = currentMode;
            resultWriter.Results_Statistics = resultsStatistics;
            resultWriter.Paged_Results = pagedResults;
            resultWriter.HierarchyObject = Hierarchy_Object;
            resultWriter.Translator = translations;

            // Populate the sort list and sort the result set
            sortOptions = String.Empty;
            StringBuilder sort_options_builder = new StringBuilder(1000);
            if ((resultWriter.Sortable) && (!currentMode.Is_Robot))
            {
                // Add the special sorts for browses
                if (currentMode.Mode == Display_Mode_Enum.Aggregation_Browse_Info)
                {
                    if (currentMode.Info_Browse_Mode.ToUpper().IndexOf("NEW") >= 0)
                    {
                        if (currentMode.Sort == 0)
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + translations.Get_Translation("Date Added", currentMode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\">" + translations.Get_Translation("Date Added", currentMode.Language) + "</option>" + Environment.NewLine );
                        }

                        if (currentMode.Sort == 1)
                        {
                            sort_options_builder.Append("      <option value=\"" + 1 + "\" selected=\"selected\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 1 + "\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                        }
                    }
                    else
                    {
                        if ((currentMode.Sort == 0) || (currentMode.Sort == 1))
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                        }
                        else
                        {
                            sort_options_builder.Append("      <option value=\"" + 0 + "\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                        }
                    }
                }

                // Add the special sorts for searches
                if (currentMode.Mode == Display_Mode_Enum.Results)
                {
                    if (currentMode.Sort == 0)
                    {
                        sort_options_builder.Append("      <option value=\"" + 0 + "\" selected=\"selected\">" + translations.Get_Translation("Rank", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 0 + "\">" + translations.Get_Translation("Rank", currentMode.Language) + "</option>" + Environment.NewLine );
                    }

                    if (currentMode.Sort == 1)
                    {
                        sort_options_builder.Append("      <option value=\"" + 1 + "\" selected=\"selected\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 1 + "\">" + translations.Get_Translation("Title", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                }

                // Add the bibid sorts if this is an internal user
                if (currentMode.Internal_User)
                {
                    if (currentMode.Sort == 2)
                    {
                        sort_options_builder.Append("      <option value=\"" + 2 + "\" selected=\"selected\">" + translations.Get_Translation("BibID Ascending", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 2 + "\">" + translations.Get_Translation("BibID Ascending", currentMode.Language) + "</option>" + Environment.NewLine );
                    }

                    if (currentMode.Sort == 3)
                    {
                        sort_options_builder.Append("      <option value=\"" + 3 + "\" selected=\"selected\">" + translations.Get_Translation("BibID Descending", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                    else
                    {
                        sort_options_builder.Append("      <option value=\"" + 3 + "\">" + translations.Get_Translation("BibID Descending", currentMode.Language) + "</option>" + Environment.NewLine );
                    }
                }

                // Add the publication date sorts
                if (currentMode.Sort == 10)
                {
                    sort_options_builder.Append("      <option value=\"" + 10 + "\" selected=\"selected\">" + translations.Get_Translation("Date Ascending", currentMode.Language) + "</option>" + Environment.NewLine );
                }
                else
                {
                    sort_options_builder.Append("      <option value=\"" + 10 + "\">" + translations.Get_Translation("Date Ascending", currentMode.Language) + "</option>" + Environment.NewLine );
                }

                if (currentMode.Sort == 11)
                {
                    sort_options_builder.Append("      <option value=\"" + 11 + "\" selected=\"selected\">" + translations.Get_Translation("Date Descending", currentMode.Language) + "</option>" + Environment.NewLine );
                }
                else
                {
                    sort_options_builder.Append("      <option value=\"" + 11 + "\">" + translations.Get_Translation("Date Descending", currentMode.Language) + "</option>" + Environment.NewLine );
                }

                sortOptions = sort_options_builder.ToString();
            }
        }