/// <summary> Gets all the page errors set by the user  </summary>
        /// <param name="ThisItemID"></param>
        public void Get_QC_Errors(int ThisItemID)
        {
            //Get the DataTable of all page errors for this item from the database
            qc_errors_table = SobekCM_Item_Database.Get_QC_Errors_For_Item(ThisItemID);
            QC_Error thisError = new QC_Error();

            if (HttpContext.Current.Session["QC_Errors"] == null)
            {
                //Build the dictionary of errors from the DataTable pulled
                qc_errors_dictionary = new Dictionary<string, QC_Error>();
            }
            else
            {
                qc_errors_dictionary = (Dictionary<string, QC_Error>)HttpContext.Current.Session["QC_Errors"];
            }
            foreach (DataRow thisRow in qc_errors_table.Rows)
            {
                thisError.FileName = thisRow["FileName"].ToString();
                int temp_error_id;
                Int32.TryParse(thisRow["ErrorID"].ToString(), out (temp_error_id));
                thisError.Error_ID = temp_error_id;
                thisError.isVolumeError = Convert.ToBoolean(thisRow["isVolumeError"]);
                thisError.Description = thisRow["Description"].ToString();
                switch (thisRow["ErrorCode"].ToString())
                {
                    case "1":
                        thisError.ErrorName = "Overcropped";
                        break;

                    case "2":
                        thisError.ErrorName = "Image Quality Error";
                        break;

                    case "3":
                        thisError.ErrorName = "Technical Spec Error";
                        break;

                    case "4":
                        thisError.ErrorName = "Other (specify)";
                        thisError.Description = HttpContext.Current.Request.Form["txtErrorOther1"] ?? String.Empty;
                        break;

                    case "5":
                        thisError.ErrorName = "Undercropped";
                        break;

                    case "6":
                        thisError.ErrorName = "Orientation Error";
                        break;

                    case "7":
                        thisError.ErrorName = "Skew Error";
                        break;

                    case "8":
                        thisError.ErrorName = "Blur Needed";
                        break;

                    case "9":
                        thisError.ErrorName = "Unblur Needed";
                        break;

                    case "10":
                        thisError.ErrorName = "Other (specify)";
                        thisError.Description = HttpContext.Current.Request.Form["txtErrorOther2"] ?? String.Empty;
                        break;

                    //Volume error cases
                    case "12":
                        volumeErrorPresent = true;
                        thisError.isVolumeError = true;
                        volumeErrorCode = "12";
                        break;

                    case "13":
                        volumeErrorPresent = true;
                        thisError.isVolumeError = true;
                        volumeErrorCode = "13";
                        break;

                }
            }
            //Save this dictionary to the session
            HttpContext.Current.Session["QC_Errors"] = qc_errors_dictionary;
        }
        /// <summary> Sets the QC Error for a page </summary>
        /// <param name="ItemID"></param>
        /// <param name="ErrorCode"></param>
        /// <param name="AffectedPageFilename"></param>
        public void SaveQcError(int ItemID, string ErrorCode, string AffectedPageFilename)
        {
            QC_Error thisError = new QC_Error();
            thisError.Description = String.Empty;
            thisError.ErrorCode = ErrorCode;
            thisError.FileName = AffectedPageFilename;
            switch (ErrorCode)
            {
                //0 indicates no error, so delete if present from the database and dictionary
                case "0":
                    if (qc_errors_dictionary.ContainsKey(ItemID + AffectedPageFilename))
                    {
                        //Delete the previous error for this file from the database
                        SobekCM_Item_Database.Delete_QC_Error(ItemID, AffectedPageFilename);

                        //Also remove any previous entry from the session dictionary
                        qc_errors_dictionary.Remove(ItemID + AffectedPageFilename);

                    }
                    break;

                case "1":
                    thisError.ErrorName = "Overcropped";
                    break;

                case "2":
                    thisError.ErrorName = "Image Quality Error";
                    break;

                case "3":
                    thisError.ErrorName = "Technical Spec Error";
                    break;

                case "4":
                    //thisError.ErrorName = "Other (specify)";
                    thisError.ErrorName = HttpContext.Current.Request.Form["txtErrorOther1"] ?? String.Empty;
                    if (String.IsNullOrEmpty(thisError.ErrorName))
                        thisError.ErrorName = "Other (specify)";
                    thisError.Description = HttpContext.Current.Request.Form["txtErrorOther1"] ?? String.Empty;
                    break;

                case "5":
                    thisError.ErrorName = "Undercropped";
                    break;

                case "6":
                    thisError.ErrorName = "Orientation Error";
                    break;

                case "7":
                    thisError.ErrorName = "Skew Error";
                    break;

                case "8":
                    thisError.ErrorName = "Blur Needed";
                    break;

                case "9":
                    thisError.ErrorName = "Unblur Needed";
                    break;

                case "10":
                    //thisError.ErrorName = "Other (specify)";
                    thisError.ErrorName = HttpContext.Current.Request.Form["txtErrorOther2"] ?? "Other (specify)";
                    thisError.Description = HttpContext.Current.Request.Form["txtErrorOther2"] ?? String.Empty;
                    break;

                //11 indicates no Volume error, so simply delete any volume errors present for this item
                case "11":
                    volumeErrorPresent = false;
                    volumeErrorCode = "11";
                    break;

                //Now handle the volume errors
                case "12":
                    thisError.ErrorName = "Invalid Images";
                    volumeErrorPresent = true;
                    thisError.isVolumeError = true;
                    volumeErrorCode = "12";
                    break;

                case "13":
                    thisError.ErrorName = "Incorrect Volume";
                    volumeErrorPresent = true;
                    thisError.isVolumeError = true;
                    volumeErrorCode = "13";
                    break;

            }
            if (qc_errors_dictionary.ContainsKey(ItemID + AffectedPageFilename))
            {
                //Delete the previous error for this file from the database
                SobekCM_Item_Database.Delete_QC_Error(ItemID, AffectedPageFilename);

                //Also remove any previous entry from the session dictionary
                qc_errors_dictionary.Remove(ItemID + AffectedPageFilename);

            }
            //Now save this error to the DB, and update the dictionary
            if (ErrorCode != "11" && ErrorCode != "0")
            {
                thisError.Error_ID = SobekCM_Item_Database.Save_QC_Error(ItemID, AffectedPageFilename, thisError.ErrorCode, thisError.Description, thisError.isVolumeError);
                if (qc_errors_dictionary == null)
                    qc_errors_dictionary = new Dictionary<string, QC_Error>();

                qc_errors_dictionary.Add(ItemID + AffectedPageFilename, thisError);
            }

            //Update the session dictionary with the updated one
            HttpContext.Current.Session["QC_Errors"] = qc_errors_dictionary;
        }
        /// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("QC_ItemViewer.Write_Main_Viewer_Section", "");
            }

            int images_per_page = thumbnailsPerPage;
            int size_of_thumbnails = thumbnailSize;

            filenamesFromMets = new List<string>();

            //Get the current QC page number
            int current_qc_viewer_page_num;
            if ((!String.IsNullOrEmpty(CurrentRequest.ViewerCode)) && (CurrentRequest.ViewerCode.Replace("qc", "").Length > 0))
                Int32.TryParse(CurrentRequest.ViewerCode.Replace("qc", ""), out current_qc_viewer_page_num);

            // Save the current viewer code
            string current_view_code = CurrentRequest.ViewerCode;
            ushort current_view_page = CurrentRequest.Page.HasValue ? CurrentRequest.Page.Value : ((ushort)1);

            // Start the citation table
            Output.WriteLine("\t\t<!-- QUALITY CONTROL VIEWER OUTPUT -->");

            //	Output.WriteLine("\t\t<td align=\"left\" height=\"40px\" ><span class=\"SobekViewerTitle\"><b>" + translator.Get_Translation(title, CurrentRequest.Language) + "</b></span></td></tr>");
            Output.WriteLine("\t</tr><tr>");
            Output.WriteLine("\t\t<td>");

            Output.WriteLine("<!-- Hidden field is used for postbacks to add new form elements (i.e., new page, etc..) -->");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_behaviors_request\" name=\"QC_behaviors_request\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_affected_file\" name=\"QC_affected_file\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"Main_Thumbnail_File\" name=\"Main_Thumbnail_File\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"Autosave_Option\" name=\"Autosave_Option\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_move_relative_position\" name=\"QC_move_relative_position\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_move_destination\" name=\"QC_move_destination\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_Sortable\" name=\"QC_Sortable\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"autonumber_mode_from_form\" name=\"autonumber_mode_from_form\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"Autonumber_number_system\" name=\"Autonumber_number_system\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"Autonumber_text_without_number\" name=\"Autonumber_text_without_number\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"Autonumber_number_only\" name=\"Autonumber_number_only\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"Autonumber_last_filename\" name=\"Autonumber_last_filename\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_window_height\" name=\"QC_window_height\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_window_width\" name=\"QC_window_width\" value=\"\"/>");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_sortable_option\" name=\"QC_sortable_option\" value=\"" + makeSortable + "\">");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_autonumber_option\" name=\"QC_autonumber_option\" value=\"" + autonumber_mode + "\">");
            Output.WriteLine("<input type=\"hidden\" id=\"QC_error_number\" name=\"QC_error_number\" value=\"\"/> ");

            // Start the main div for the thumbnails

            ushort page = (ushort)(CurrentRequest.Page.HasValue ? CurrentRequest.Page.Value - 1 : (ushort)0);
            if (page > (static_pages.Count - 1) / images_per_page)
                page = (ushort)((static_pages.Count - 1) / images_per_page);

            //Outer div which contains all the thumbnails
            if ((allThumbnailsOuterDiv1Height > 0) && (allThumbnailsOuterDiv1Width > 0))
                Output.WriteLine("<div id=\"allThumbnailsOuterDiv1\" class=\"qcContainerDivClass\" style=\"width:" + allThumbnailsOuterDiv1Width + "px;height:" + allThumbnailsOuterDiv1Height + "px;\"><span id=\"allThumbnailsOuterDiv\" align=\"left\" style=\"float:left\" class=\"doNotSort\">");
            else
            {
                Output.WriteLine("<div id=\"allThumbnailsOuterDiv1\" class=\"qcContainerDivClass\"><span id=\"allThumbnailsOuterDiv\" align=\"left\" style=\"float:left\" class=\"doNotSort\">");
            }

            // Determine the main thumbnail
            int main_thumbnail_index;
            if (!String.IsNullOrEmpty(hidden_main_thumbnail))
                Int32.TryParse(hidden_main_thumbnail, out main_thumbnail_index);

            //Add the division types from the current QC Config profile to a local dictionary
            Dictionary<string, bool> qcDivisionList = new Dictionary<string, bool>();
            foreach (QualityControl_Division_Config qcDivConfig in qc_profile.Division_Types)
            {
                qcDivisionList.Add(qcDivConfig.TypeName, qcDivConfig.isNameable);
            }

            //Get the division types from the Page Tree (from this METS), and the extra ones not in the profile to the
            foreach (KeyValuePair<Page_TreeNode, Division_TreeNode> node in childToParent)
            {
                string type = node.Value.Type;
                string label = node.Value.Label;
                if (!qcDivisionList.ContainsKey(type))
                {
                    bool isNameable = (!String.IsNullOrEmpty(label));
                    qcDivisionList.Add(type, isNameable);
                }
            }

            // Determine some values including some icon sizes, based on current thumbnail size
            int error_icon_height;
            int error_icon_width = 20;
            int pick_main_thumbnail_height;
            int pick_main_thumbnail_width;
            int arrow_height;
            int arrow_width;
            string division_text = "Division:";
            string pagination_text = "Pagination:";
            const string division_name_text = "Name:";
            const string division_tooltip_text = "Division";
            const string division_checkbox_tooltip = "Check for the beginning of a new division type";
            string division_box;
            string pagination_box;
            string icon_class;
            switch (size_of_thumbnails)
            {
                case 2:
                    error_icon_height = 25;
                    error_icon_width = 25;
                    pick_main_thumbnail_height = 25;
                    pick_main_thumbnail_width = 25;
                    arrow_height = 17;
                    arrow_width = 20;
                    division_box = "sbkQc_DivisionBox_Medium";
                    pagination_box = "sbkQc_PageBox_Medium";
                    icon_class = "sbkQc_PageOptionsIcon_Medium";
                    break;

                case 3:
                    error_icon_height = 30;
                    error_icon_width = 30;
                    pick_main_thumbnail_height = 30;
                    pick_main_thumbnail_width = 30;
                    arrow_height = 22;
                    arrow_width = 25;
                    division_box = "sbkQc_DivisionBox_Large";
                    pagination_box = "sbkQc_PageBox_Large";
                    icon_class = "sbkQc_PageOptionsIcon_Large";
                    break;

                case 4:
                    error_icon_height = 30;
                    error_icon_width = 30;
                    pick_main_thumbnail_height = 30;
                    pick_main_thumbnail_width = 30;
                    arrow_height = 22;
                    arrow_width = 25;
                    division_box = "sbkQc_DivisionBox_Full";
                    pagination_box = "sbkQc_PageBox_Full";
                    icon_class = "sbkQc_PageOptionsIcon_Full";
                    break;

                default:
                    error_icon_height = 20;
                    pick_main_thumbnail_height = 20;
                    pick_main_thumbnail_width = 20;
                    arrow_height = 12;
                    arrow_width = 15;
                    division_box = "sbkQc_DivisionBox_Small";
                    pagination_box = "sbkQc_PageBox_Small";
                    icon_class = "sbkQc_PageOptionsIcon_Small";
                    division_text = "D:";
                    pagination_text = "Page:";
                    break;
            }

            // Set some mouse-over text
            string info_text = "View technical image information";
            string delete_text = "Delete this page and related files";
            string view_text = "Open this page in a new window";
            string error_text = "Mark an error on this page image";

            //// Build the javascript to add references to the non-displayed pages
            //StringBuilder javascriptBuilder = new StringBuilder(4000);
            //for (int page_index = 0; page_index < page*images_per_page; page_index++)
            //{
            //	Page_TreeNode thisPage = (Page_TreeNode) static_pages[page_index];
            //	javascriptBuilder.AppendLine("\t\t");
            //}

            Output.WriteLine("<script type=\"text/javascript\">var thumbnailImageDictionary={};</script>");

            //Save the global image folder location
            Output.WriteLine("<script type=\"text/javascript\">Set_Default_Images('" + Static_Resources_Gateway.No_Pages_Jpg + "', '" + Static_Resources_Gateway.Nothumb_Jpg + "');</script>");

            //Save all the thumbnail image locations in the JavaScript global image dictionary
            List<string> image_by_pageindex = new List<string>();
            List<string> file_sans_by_pageindex = new List<string>();
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < static_pages.Count; i++)
            {
                Page_TreeNode thisPage = (Page_TreeNode)static_pages[i];
                string filename = String.Empty;
                string thumbnail_filename = String.Empty;
                string filename_sansextension = String.Empty;

                // Look for a thumbnail in the actual METS
                foreach (SobekCM_File_Info thisFile in thisPage.Files.Where((ThisFile => ThisFile.System_Name.IndexOf("thm.jpg") > 0)))
                {
                    //set the image url to fetch the small thumbnail .thm image
                    thumbnail_filename = thisFile.System_Name;
                    filename_sansextension = thisFile.File_Name_Sans_Extension;

                }

                // Try to construct a thumbnail from the JPEG image then
                foreach (SobekCM_File_Info thisFile in thisPage.Files.Where((ThisFile => (ThisFile.System_Name.IndexOf(".jpg") > 0) && (ThisFile.System_Name.IndexOf("thm.jpg") < 0))))
                {
                    //set the image url to fetch the small thumbnail .thm image
                    filename = thisFile.System_Name;
                    filename_sansextension = thisFile.File_Name_Sans_Extension;
                }

                // If a jpeg was found, but not a thumb, try to guess the thumbnail
                if (thumbnail_filename.Length == 0)
                    thumbnail_filename = filename.Replace(".jpg", "thm.jpg");

                // Check that the thumbnail exists (TODO:  cache this so it only happens once)
                if (thumbnail_filename.Length > 0)
                {
                    string thumbnail_check = qc_item.Source_Directory + "\\" + thumbnail_filename;
                    if (!File.Exists(thumbnail_check))
                    {
                        thumbnail_filename = String.Empty;
                    }
                }

                // Compute the thumbnail and regular URLs
                string thumbnail_url = (qc_item.Web.Source_URL + "/" + thumbnail_filename).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://");
                // If nothing found (but this is a page division) use the no thumbs image
                if (thumbnail_filename.Length == 0)
                {
                    thumbnail_url = Static_Resources_Gateway.Nothumb_Jpg;
                }

                string image_url;
                if (size_of_thumbnails > 1)
                {
                    //Check that the JPEG image exists
                    if (filename.Length > 0)
                    {
                        string filename_check = qc_item.Source_Directory + "\\" + filename;
                        if (!File.Exists(filename_check))
                        {
                            filename = String.Empty;
                        }
                    }

                    image_url = (qc_item.Web.Source_URL + "/" + filename).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://");
                    if (filename.Length == 0)
                    {
                        image_url = Static_Resources_Gateway.Missingimage_Jpg;
                    }

                }

                else
                {
                    image_url = thumbnail_url;
                }

                //Add the image to the javascript dictionary
                builder.AppendLine("<script type=\"text/javascript\">QC_Add_Image_To_Dictionary('" + filename_sansextension + "','" + image_url + "','" + thumbnail_url + "');</script>");

                // Add the actual image to display, by index
                image_by_pageindex.Add(image_url);
                file_sans_by_pageindex.Add(filename_sansextension);
            }

            // Step through each page in the item
            Division_TreeNode lastParent = null;
            for (int page_index = page * images_per_page; (page_index < (page + 1) * images_per_page) && (page_index < static_pages.Count); page_index++)
            {
                Page_TreeNode thisPage = (Page_TreeNode)static_pages[page_index];
                Division_TreeNode thisParent = childToParent[thisPage];

                // Get the image URL
                CurrentRequest.Page = (ushort)(page_index + 1);
                CurrentRequest.ViewerCode = (page_index + 1).ToString();

                //set the image url to fetch the small thumbnail .thm image
                string image_url = image_by_pageindex[page_index];
                string filename_sans_extension = file_sans_by_pageindex[page_index];
                string filenameToDisplay = filename_sans_extension;
                int itemID = SobekCM_Item_Database.Get_ItemID(BriefItem.BibID, BriefItem.VID);
                string url = UrlWriterHelper.Redirect_URL(CurrentRequest).Replace("&", "&amp;").Replace("\"", "&quot;");

                QC_Error thisError = new QC_Error();
                bool errorPresentThisPage = false;
                if (qc_errors_dictionary.ContainsKey(itemID.ToString() + filename_sans_extension))
                {
                    errorPresentThisPage = true;
                    thisError = qc_errors_dictionary[itemID.ToString() + filename_sans_extension];
                }

                bool duplicateFile = false;

                if (filenamesFromMets.Contains(filename_sans_extension))
                    duplicateFile = true;
                else
                {
                    filenamesFromMets.Add(filename_sans_extension);
                }

                if (duplicateFile)
                    continue;

                // Start the box for this thumbnail
                Output.WriteLine("<!-- PAGE " + page_index + " ( " + filename_sans_extension + " ) -->");
                Output.WriteLine("<a name=\"" + thisPage.Label + "\" id=\"" + thisPage.Label + "\"></a>");
                Output.WriteLine("<span class=\"sbkQc_Span\" id=\"span" + page_index + "\" onclick=\"return qcspan_onclick(event, this.id);\" onmouseover=\"return qcspan_mouseover(this.id);\" onmouseout=\"return qcspan_mouseout(this.id);\" >");
                Output.WriteLine("  <table>");

                //Truncate the filename if too long
                string filenameTooltipText = String.Empty;
                int truncated_length = 13;
                int length_to_check = 16;
                if (size_of_thumbnails == 2)
                {
                    truncated_length = 20;
                    length_to_check = 25;
                }
                else if (size_of_thumbnails == 3)
                {
                    truncated_length = 25;
                    length_to_check = 30;
                }

                if (filename_sans_extension.Length > length_to_check)
                {
                    // Are there numbers at the end?
                    if (Char.IsNumber(filenameToDisplay[filenameToDisplay.Length - 1]))
                    {
                        int number_length = 1;
                        while (Char.IsNumber(filenameToDisplay[filenameToDisplay.Length - (1 + number_length)]))
                            number_length++;

                        int characters = truncated_length - number_length;
                        if (characters < 2)
                            filenameToDisplay = "..." + filenameToDisplay.Substring(filenameToDisplay.Length - Math.Min(number_length, truncated_length));
                        else
                        {
                            filenameTooltipText = filenameToDisplay;
                            filenameToDisplay = filenameToDisplay.Substring(0, characters) + "..." + filenameToDisplay.Substring(filenameToDisplay.Length - number_length);
                        }
                    }
                    else
                    {
                        filenameTooltipText = filenameToDisplay;
                        filenameToDisplay = filenameToDisplay.Substring(0, truncated_length) + "...";
                    }
                }
                //End filename truncation

                // Start the top row and add the main thumbnail and filename
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td colspan=\"2\">");

                //Write the main thumbnail icon
                Output.WriteLine("        <input type=\"hidden\" id=\"filename" + page_index + "\" name=\"filename" + page_index + "\" value=\"" + filename_sans_extension + "\" />");
                if (hidden_main_thumbnail.ToLower() == filename_sans_extension.ToLower())
                    Output.WriteLine("       <a onclick=\"apply_Main_Thumbnail_Cursor_Control();return false;\" href=\"\"><img id=\"pick_main_thumbnail" + page_index + "\" src=\"" + Static_Resources_Gateway.Thumbnail_Large_Gif + "\" class=\"QC_MainThumbnail_Visible\" style=\"height:" + pick_main_thumbnail_height + "px;width:" + pick_main_thumbnail_width + "px;\" /></a>");
                else
                    Output.WriteLine("        <a onclick=\"apply_Main_Thumbnail_Cursor_Control();return false;\" href=\"\" ><img id=\"pick_main_thumbnail" + page_index + "\" src=\"" + Static_Resources_Gateway.Thumbnail_Large_Gif + "\" class=\"QC_MainThumbnail_Hidden\" style=\"height:" + pick_main_thumbnail_height + "px;width:" + pick_main_thumbnail_width + "px;\" /></a>");

                //Write the filename on the top left corner
                Output.WriteLine("<span class=\"sbkQc_Filename\" title=\"" + filenameTooltipText + "\">" + filenameToDisplay + "</span>");

                Output.WriteLine("        <input type=\"checkbox\" id=\"chkMoveThumbnail" + page_index + "\" name=\"chkMoveThumbnail" + page_index + "\" class=\"sbkQc_Checkbox\" onchange=\"qccheckbox_onchange(event, this.id);\"/>");
                //Default "0": No error
                string error_code_to_set_form = "0";
                if (errorPresentThisPage)
                    error_code_to_set_form = thisError.ErrorCode;

                Output.WriteLine("<span id=\"error" + page_index + "\" class=\"errorIconSpan\"><a href=\"\" onclick=\"return popup('form_qcError');\"><img title=\"" + error_text + "\" height=\"" + error_icon_height + "\" width=\"" + error_icon_width + "\" src=\"" + Static_Resources_Gateway.Cancel_Ico + "\" onclick=\"Set_Error_Page('" + filename_sans_extension + "','" + error_code_to_set_form + "');\"/></a></span>");

                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");

                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td colspan=\"2\">");

                //Add the style class if this page has an error
                string error_Class_Name = "QC_No_Page_Error";
                if (errorPresentThisPage)
                    error_Class_Name = "QC_Page_Error_Small";

                // Write the image, based on current thumbnail size
                switch (size_of_thumbnails)
                {
                    case 2:
                        {
                            Output.Write("        <img id=\"child" + image_url + "\"  src=\"" + image_url + "\" alt=\"MISSING THUMBNAIL\" class=\"sbkQc_Thumbnail_Medium\" onclick=\"thumbnail_click(this.id,'" + url + "');return false;\" style=\" z-index:1;\"/>");

                            if (errorPresentThisPage)
                            {
                                error_Class_Name = "QC_Page_Error_Medium";
                                Output.WriteLine("<span style=\"\" class=\"" + error_Class_Name + "\">" + thisError.ErrorName + "</span>");
                            }

                        }

                        break;

                    case 3:
                        {
                            Output.WriteLine("        <img id=\"child" + image_url + "\" src=\"" + image_url + "\" alt=\"MISSING THUMBNAIL\" class=\"sbkQc_Thumbnail_Large\" onclick=\"thumbnail_click(this.id,'" + url + "');return false;\" />");
                            if (errorPresentThisPage)
                            {
                                error_Class_Name = "QC_Page_Error_Large";
                                Output.WriteLine("<span style=\"\" class=\"" + error_Class_Name + "\">" + thisError.ErrorName + "</span>");
                            }

                        }
                        break;

                    case 4:
                        {

                            Output.WriteLine("        <img id=\"child" + image_url + "\" src=\"" + image_url + "\"  alt=\"MISSING THUMBNAIL\" class=\"sbkQc_Thumbnail_Full\" onclick=\"thumbnail_click(this.id,'" + url + "');return false;\"  />");
                            if (errorPresentThisPage)
                            {
                                error_Class_Name = "QC_Page_Error_Full";
                                Output.WriteLine("<span style=\"\" class=\"" + error_Class_Name + "\">" + thisError.ErrorName + "</span>");
                            }
                        }
                        break;

                    default:
                        {
                            Output.WriteLine("        <img  src=\"" + image_url + "\" alt=\"MISSING THUMBNAIL\" class=\"sbkQc_Thumbnail_Small\" onclick=\"thumbnail_click(this.id,'" + url + "');return false;\" />");

                            if (errorPresentThisPage)
                                Output.WriteLine("<span style=\"\" class=\"" + error_Class_Name + "\">" + thisError.ErrorName + "</span>");
                        }
                        break;
                }

                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");

                // Add the text box for entering the name of this page
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td class=\"sbkQc_PaginationText\">" + pagination_text + "</td>");
                Output.WriteLine("      <td><input type=\"text\" id=\"textbox" + page_index + "\" name=\"textbox" + page_index + "\" class=\"" + pagination_box + "\" value=\"" + HttpUtility.HtmlEncode(thisPage.Label) + "\" onchange=\"PaginationTextChanged(this.id);\"></input></td>");
                Output.WriteLine("    </tr>");

                // Was this a new parent?
                bool newParent = thisParent != lastParent;

                // Add the Division prompting, and the check box for a new division
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td class=\"sbkQc_DivisionText\" align=\"left\">");
                Output.WriteLine("        <span title=\"" + division_tooltip_text + "\">" + division_text + "</span>");
                Output.WriteLine("        <span title=\"" + division_checkbox_tooltip + "\">");
                Output.Write("          <input type=\"checkbox\" id=\"newDivType" + page_index + "\" name=\"newdiv" + page_index + "\" value=\"new\" onclick=\"UpdateDivDropdown(this.id);\"");
                if (newParent)
                    Output.Write(" checked=\"checked\"");
                Output.WriteLine("/>");
                Output.WriteLine("        </span>");
                Output.WriteLine("      </td>");

                // Determine the text for the parent
                string parentLabel = String.Empty;
                string parentType = "Chapter";
                if (thisParent != null)
                {
                    parentLabel = thisParent.Label;
                    parentType = thisParent.Type;

                }

                // Add the division box
                Output.WriteLine("      <td>");
                if (newParent)
                {
                    Output.WriteLine("        <select id=\"selectDivType" + page_index + "\" name=\"selectDivType" + page_index + "\" class=\"" + division_box + "\" onclick=\"DivisionTypeChanged(this.id);\">");
                }
                else
                {
                    Output.WriteLine("        <select id=\"selectDivType" + page_index + "\" name=\"selectDivType" + page_index + "\" class=\"" + division_box + "\" disabled=\"disabled\" onclick=\"DivisionTypeChanged(this.id);\">");
                }

                Output.Write("          ");
                //Iterate through all the division types in this profile+local to this METS
                bool showTextDivName = false;
                foreach (KeyValuePair<string, bool> divisionType in qcDivisionList)
                {
                    if (divisionType.Key == parentType && divisionType.Value == false)
                        Output.Write("<option value=\"" + divisionType.Key + "\" selected=\"selected\">" + divisionType.Key + "</option>");
                    else if (divisionType.Key == parentType && divisionType.Value)
                    {
                        Output.Write("<option value=\"!" + divisionType.Key + "\" selected=\"selected\">" + divisionType.Key + "</option>");
                        showTextDivName = true;
                    }
                    else if (divisionType.Value)
                        Output.Write("<option value=\"!" + divisionType.Key + "\">" + divisionType.Key + "</option>");
                    else
                        Output.Write("<option value=\"" + divisionType.Key + "\">" + divisionType.Key + "</option>");
                }
                Output.WriteLine();
                Output.WriteLine("        </select>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");

                //Add the textbox for named divisions
                if (showTextDivName)
                    Output.WriteLine("    <tr id=\"divNameTableRow" + page_index + "\" style=\"visibility:visible;\">");
                else
                    Output.WriteLine("    <tr id=\"divNameTableRow" + page_index + "\" style=\"visibility:hidden;\">");
                Output.WriteLine("      <td class=\"sbkQc_NamedDivisionText\" align=\"left\">" + division_name_text + "</td>");

                if (newParent)
                {
                    Output.WriteLine("      <td><input type=\"text\" id=\"txtDivName" + page_index + "\" name=\"txtDivName" + page_index + "\" class=\"" + pagination_box + "\" value=\"" + HttpUtility.HtmlEncode(parentLabel) + "\" onchange=\"DivNameTextChanged(this.id);\"/></td>");
                }
                else
                {
                    Output.WriteLine("      <td><input type=\"text\" disabled=\"disabled\" id=\"txtDivName" + page_index + "\" name=\"txtDivName" + page_index + "\" class=\"" + pagination_box + "\" value=\"" + HttpUtility.HtmlEncode(parentLabel) + "\" onchange=\"DivNameTextChanged(this.id);\"/></td></tr>");
                }
                Output.WriteLine("    </tr>");

                //Add the span with the on-hover-options for the page thumbnail
                Output.WriteLine("    <tr>");
                //  Output.WriteLine("      <td colspan=\"2\">");
                Output.WriteLine("<td>");
                Output.WriteLine("        <span id=\"movePageArrows" + page_index + "\" class=\"sbkQc_MovePageArrowsSpan\">");
                Output.WriteLine("          <a href=\"\" onclick=\"popup('form_qcmove'); update_popup_form('" + page_index + "','" + filename_sans_extension + "','Before'); return false;\"><img src=\"" + Static_Resources_Gateway.Arw05lt_Img + "\" style=\"height:" + arrow_height + "px;width:" + arrow_width + "px;\" alt=\"Missing Icon Image\" title=\"Move selected page(s) before this page\"/></a>");
                Output.WriteLine("          <a href=\"\" onclick=\"popup('form_qcmove'); update_popup_form('" + page_index + "','" + filename_sans_extension + "','After'); return false;\"><img src=\"" + Static_Resources_Gateway.Arw05rt_Img + "\" style=\"height:" + arrow_height + "px;width:" + arrow_width + "px;\" alt=\"Missing Icon Image\" title=\"Move selected page(s) after this page\"/></a>");
                Output.WriteLine("        </span>");
                Output.WriteLine("</td>");
                Output.WriteLine("<td>");
                Output.WriteLine("        <span id=\"qcPageOptions" + page_index + "\" class=\"sbkQc_PageOptionsSpan\">");
                Output.WriteLine("          <img title=\"" + info_text + "\" src=\"" + Static_Resources_Gateway.Main_Information_Ico + "\" class=\"" + icon_class + "\" alt=\"Missing Icon Image\" />");
                Output.WriteLine("          <a href=\"" + url + "\" target=\"_blank\" title=\"" + view_text + "\" ><img src=\"" + Static_Resources_Gateway.View_Ico + "\" class=\"" + icon_class + "\" alt=\"Missing Icon Image\" /></a>");
                Output.WriteLine("          <img title=\"" + delete_text + "\" onClick=\"return ImageDeleteClicked('" + filename_sans_extension + "');\" src=\"" + Static_Resources_Gateway.Trash01_Ico + "\" class=\"" + icon_class + "\" alt=\"Missing Icon Image\" />");

                Output.WriteLine("        </span>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");

                // Finish this one division
                Output.WriteLine("  </table>");
                Output.WriteLine("</span>");
                Output.WriteLine();

                // Save the last parent
                lastParent = thisParent;

            }

            //Close the outer div
            Output.WriteLine("</span></div>");

            // Write the javascript to add images to the dictionaries (built above)
            Output.WriteLine(builder);

            // Restore the mode
            CurrentRequest.ViewerCode = current_view_code;
            CurrentRequest.Page = current_view_page;

            // Add the popup form

            //      navRowBuilder.AppendLine();
            Output.WriteLine("<!-- Pop-up form for moving page(s) by selecting the checkbox in image -->");
            Output.WriteLine("<div class=\"qcmove_popup_div\" id=\"form_qcmove\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"popup_title\"><table width=\"100%\"><tr><td align=\"left\">MOVE SELECTED PAGES</td><td align=\"right\"> &nbsp; <a href=\"#template\" onclick=\" popdown( 'form_qcmove' ); \">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"popup_table\">");

            // Add the rows of data
            Output.WriteLine("<tr><td>Move selected pages:</td>");
            Output.WriteLine("<td><input type=\"radio\" name=\"rbMovePages\" id=\"rbMovePages1\" value=\"After\" checked=\"true\" onclick=\"rbMovePagesChanged(this.value);\">After");
            Output.WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;</td>");
            Output.WriteLine("<td><select id=\"selectDestinationPageList1\" name=\"selectDestinationPageList1\" onchange=\"update_preview();\">");
            //Add the select options

            //iterate through the page items
            if (static_pages.Count > 0)
            {
                foreach (Page_TreeNode thisFile in static_pages)
                {
                    if (( thisFile.Files != null ) && ( thisFile.Files.Count > 0 ))
                        Output.WriteLine("<option value=\"" + thisFile.Files[0].File_Name_Sans_Extension + "\">" + thisFile.Files[0].File_Name_Sans_Extension + "</option>");
                }
            }

            Output.WriteLine("</td></tr>");
            Output.WriteLine("<tr><td></td><td><input type=\"radio\" name=\"rbMovePages\" id=\"rbMovePages2\" value=\"Before\" onclick=\"rbMovePagesChanged(this.value);\">Before</td>");

            Output.WriteLine("<td><select id=\"selectDestinationPageList2\"  name=\"selectDestinationPageList2\" onchange=\"update_preview();\" disabled=\"true\">");

            //iterate through the page items
            if (static_pages.Count > 0)
            {
                foreach (Page_TreeNode thisFile in static_pages)
                {
                    if ((thisFile.Files != null) && (thisFile.Files.Count > 0))
                        Output.WriteLine("<option value=\"" + thisFile.Files[0].File_Name_Sans_Extension + "\">" + thisFile.Files[0].File_Name_Sans_Extension + "</option>");
                }
            }
            Output.WriteLine("</select></td></tr>");

            //Add the div for the preview section
            Output.WriteLine("<tr><td colspan=\"3\"><div id=\"popupPreviewDiv\" class=\"popup_form_preview_div\"> ");
            Output.WriteLine("<div align=\"center\" id=\"preview_title\" class=\"sbkQC_preview_title\">PREVIEW</div><br/>");
            Output.WriteLine("<table cellpadding=\"15\"><tr>");
            Output.WriteLine("<td><span id=\"PrevThumbanail\" class=\"sbkQc_Span\"><table><tr><td><span id=\"prevFileName\" class=\"sbkQc_Filename\"></span></td></tr><tr><td><img src=\"about:blank\" alt=\"Missing thumbnail image\" id=\"prevThumbnailImage\"></img></td></tr></table></span></td>");
            Output.WriteLine("<td><span id=\"PlaceholderThumbnail1\" class=\"sbkQc_Span\" style=\"position:absolute; margin: -16px 0 0 16px;\"><table><tr><td><span id=\"placeHolderText1\" class=\"sbkQc_Filename\"/></td></tr><tr><td><img src=\"about:blank\" alt=\"Missing image\" id=\"PlaceholderThumbnailImage1\"></img></td></tr></table></span>");
            Output.WriteLine("<span id=\"PlaceholderThumbnail2\" class=\"sbkQc_Span\" style=\"position:absolute; margin: -8px 0 0 8px;\"><table><tr><td><span id=\"placeHolderText2\" class=\"sbkQc_Filename\"/></td></tr><tr><td><img src=\"about:blank\" alt=\"Missing image\" id=\"PlaceholderThumbnailImage2\"></img></td></tr></table></span>");
            Output.WriteLine("<span id=\"PlaceholderThumbnail3\" class=\"sbkQc_Span\" style=\"position:relative; margin: 0 0 0 0;\"><table><tr><td><span id=\"placeHolderText3\" class=\"sbkQc_Filename\"/></td></tr><tr><td><img src=\"about:blank\" alt=\"Missing image\" id=\"PlaceholderThumbnailImage3\"></img></td></tr></table></span></td>");
            Output.WriteLine("<td><span id=\"NextThumbnail\" class=\"sbkQc_Span\" style=\"margin: 0 0 0 10px;\"><table><tr><td><span id=\"nextFileName\" class=\"sbkQc_Filename\" class=\"sbkQc_Filename\"/></td></tr><tr><td><img src=\"about:blank\" alt=\"Missing thumbnail image\" id=\"nextThumbnailImage\"></img></td></tr></table></span></td>");
            Output.WriteLine("</table>");

            Output.WriteLine("</div></td></tr>");

            //End div for the preview section

            //Add the Cancel & Move buttons
            Output.WriteLine("    <tr><td colspan=\"3\" style=\"text-align:center\">");
            Output.WriteLine("      <br /><button title=\"Move selected pages\" class=\"sbkQc_MoveButtons\" onclick=\"move_pages_submit();return false;\">SUBMIT</button>&nbsp;");
            Output.WriteLine("      <button title=\"Cancel this move\" class=\"sbkQc_MoveButtons\" onclick=\"return cancel_move_pages();\">CANCEL</button>&nbsp;<br />");
            Output.WriteLine("    </td></tr>");

            // Finish the popup form
            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();

            //Add the popup form for the error screen
            Output.WriteLine("<!-- Pop-up form for marking page errors -->");
            Output.WriteLine("<div class=\"sbkMySobek_PopupForm \" id=\"form_qcError\" style=\"display:none;\">");

            //Output.WriteLine("  <div class=\"popup_title\"><table width=\"100%\"><tr><td align=\"left\">FILE ERROR</td><td align=\"right\"> &nbsp; <a href=\"#template\" onclick=\" popdown( 'form_qcError' ); \">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <div class=\"sbkMySobek_PopupTitle\"><table width=\"100%\"><tr><td align=\"left\">FILE ERROR</td><td align=\"right\"> &nbsp; <a href=\"#template\" onclick=\" popdown( 'form_qcError' ); \">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine(" <div class=\"qcErrorForm_LeftDiv\">");
            Output.WriteLine("     <fieldset class=\"qcFormDivFieldset\"><legend class=\"qcErrorFormSubHeader\">Recapture required</legend>");
            Output.WriteLine("     <table class=\"error_popup_table_left\">");
            Output.WriteLine("         <tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError1\" value=\"1\" onclick=\"\"/>Overcropped </td></tr>");
            Output.WriteLine("         <tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError2\" value=\"2\" onclick=\"\"/>Image Quality Error </td></tr>");
            Output.WriteLine("         <tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError3\" value=\"3\" onclick=\"\"/>Technical Spec Error </td></tr>");
            Output.WriteLine("         <tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError4\" value=\"4\" onclick=\"\"/><input type=\"textarea\" id=\"txtErrorOther1\" name=\"txtErrorOther1\" rows=\"40\" value=\"Other(specify)\"/> </td></tr>");
            Output.WriteLine("         <tr><td><br/></td></tr>");
            Output.WriteLine("         <tr><td><br/></td></tr>");
            Output.WriteLine("     </table>");
            Output.WriteLine("     </fieldset>");
            Output.WriteLine("</div>");

            //Add the second table on the right with the 'Processing Required' errors
            Output.WriteLine("<div class=\"qcErrorForm_RightDiv\">");
            Output.WriteLine("<fieldset class=\"qcFormDivFieldset\"><legend class=\"qcErrorFormSubHeader\">Processing required</legend>");
            Output.WriteLine("<table class=\"error_popup_table_left\">");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError5\" value=\"5\" onclick=\"\"/>Undercropped</td>");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError6\" value=\"6\" onclick=\"\"/>Orientation Error</td>");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError7\" value=\"7\" onclick=\"\"/>Skew Error</td>");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError8\" value=\"8\" onclick=\"\"/>Blur Needed</td>");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError9\" value=\"9\" onclick=\"\"/>Unblur needed</td>");
            Output.WriteLine("<tr><td><input type=\"radio\" name=\"rbFile_errors\" id=\"rbError10\" value=\"10\" onclick=\"\"/><input type=\"textarea\" rows=\"40\" id=\"txtErrorOther2\" name=\"txtErrorOther2\" value=\"Other(specify)\"/></td>");
            Output.WriteLine("</tr>");
            Output.WriteLine("</table>");
            Output.WriteLine("</fieldset>");
            Output.WriteLine("</div>");
            Output.WriteLine("<br/><br/>");

            //Start the last div for the "No file error" option and the buttons
            Output.WriteLine("<div class=\"qcErrorForm_LeftDiv\">");
            Output.WriteLine("<input type=\"radio\" name=\"rbFile_errors\" id=\"rbError11\" value=\"0\" onclick=\"\" checked/>No file error");
            Output.WriteLine("</div>");

            //Add the Cancel & Submit buttons
            Output.WriteLine("<div class=\"qcErrorForm_RightDiv\">");
            Output.WriteLine("    <table><tr><td colspan=\"3\" style=\"text-align:center\">");
            Output.WriteLine("      <br /><button title=\"Save this error\" class=\"sbkMySobek_BigButton\" onclick=\"save_qcErrors();return false;\">SUBMIT</button>&nbsp;");
            Output.WriteLine("      <button title=\"Cancel\" class=\"sbkMySobek_BigButton\" onclick=\"popdown('form_qcError')\">CANCEL</button>&nbsp;<br />");
            Output.WriteLine("    </td></tr>");
            Output.WriteLine("</div>");

            // Finish the popup form
            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();

            //End the popup for the error screen

            // Finish the citation table
            Output.WriteLine("\t\t</td>");
            Output.WriteLine("\t\t<!-- END QUALITY CONTROL VIEWER OUTPUT -->");

            //If the current url has an anchor, call the javascript function to animate the corresponding span background color
            Output.WriteLine("<script type=\"text/javascript\">addLoadEvent(MakeSpanFlashOnPageLoad());</script>");
            Output.WriteLine("<script type=\"text/javascript\">addLoadEvent(Configure_QC(" + static_pages.Count + "));</script>");
            Output.WriteLine("<script type=\"text/javascript\">addLoadEvent(MakeSortable1());</script>");

            //If the autosave option is not set, or set to true, set the interval (3 minutes) for autosaving
            if (String.IsNullOrEmpty(autosave_option.ToString()) || autosave_option)
                Output.WriteLine("<script type=\"text/javascript\">setInterval(qc_auto_save, 180* 1000);</script>");

            //Add the Complete and Cancel buttons at the end of the form
            Output.WriteLine("</tr><tr><td colspan=\"100%\">");
            //Output.WriteLine("<span id=\"displayTimeSaved\" class=\"displayTimeSaved\" style=\"float:left\">" + displayTimeText + "</span>");
            //Start inner table
            const string CRITICAL_VOLUME_TEXT = "Critical Volume Error: ";
            Output.WriteLine("<div id=\"sbkQc_BottomRow\">");
            if (volumeErrorPresent)
                Output.WriteLine("<span class=\"sbkQc_CriticalVolumeErrorRed\">" + CRITICAL_VOLUME_TEXT + "<select id=\"sbk_ddlCriticalVolumeError\" class=\"sbkQc_ddlCriticalVolumeError\" onchange=\"ddlCriticalVolumeError_change(this.value);\">");
            else
                Output.WriteLine("<span class=\"sbkQc_CriticalVolumeError\">" + CRITICAL_VOLUME_TEXT + "<select id=\"sbk_ddlCriticalVolumeError\" class=\"sbkQc_ddlCriticalVolumeError\" onchange=\"ddlCriticalVolumeError_change(this.value);\">");
            Output.WriteLine(!volumeErrorPresent ? "<option value=\"11\" selected>No Volume Error</option>" : "<option value=\"11\">No Volume Error</option>");

            if (volumeErrorPresent && volumeErrorCode == "12")
                Output.WriteLine("<option value=\"12\" selected>Invalid Images</option>");
            else
            {
                Output.WriteLine("<option value=\"12\">Invalid Images</option>");
            }
            if (volumeErrorPresent && volumeErrorCode == "13")
                Output.WriteLine("<option value=\"13\" selected>Incorrect Volume</option>");
            else
                Output.WriteLine("<option value=\"13\">Incorrect Volume</option>");
            Output.WriteLine("</select></span>");

            Output.WriteLine("<span id=\"sbkQC_BottomRowTextSpan\">Comments: </span><textarea cols=\"50\" id=\"txtComments\" name=\"txtComments\"></textarea> ");
            Output.WriteLine("<button type=\"button\" class=\"sbkQc_MainButtons\" onclick=\"save_submit_form();\">Complete</button>");
            Output.WriteLine("<button type=\"button\" class=\"sbkQc_MainButtons\" onclick=\"behaviors_cancel_form();\">Cancel</button>");
            //Close inner table
            Output.WriteLine("</div>");
            Output.WriteLine("</td></tr>");

            ////Add button to move multiple pages
            //Output.WriteLine("<div id=\"divMoveOnScroll\" class=\"qcDivMoveOnScrollHidden\"><button type=\"button\" id=\"btnMovePages\" name=\"btnMovePages\" class=\"btnMovePages\" onclick=\"return popup('form_qcmove', 'btnMovePages', 280, 400 );\">Move to</button></div>");
            ////Add the button to delete pages
            //Output.WriteLine("<div id=\"divDeleteMoveOnScroll\" class=\"qcDivDeleteButtonHidden\"><button type=\"button\" id=\"btnDeletePages\" name=\"btn DeletePages\" class=\"btnDeletePages\" onclick=\"DeleteSelectedPages();\" >Delete</button></div>");
        }