private void split_add_subjects(SobekCM_Item Package, string Data )
        {
            if (Data.IndexOf("--") < 0)
                Package.Bib_Info.Add_Subject(new Subject_Info_Standard(Data, null));
            else
            {
                Subject_Info_Standard subject = new Subject_Info_Standard();
                string[] splitter = Data.Split("-".ToCharArray());
                foreach (string thisSplit in splitter)
                {
                    if (thisSplit.Length == 0)
                        continue;

                    string tsl = thisSplit.ToLower().Trim();

                    // Was this geographic?
                    if ((tsl.IndexOf("county") >= 0) || (tsl.IndexOf("(nev.)") > 0) || (tsl.IndexOf("henderson") >= 0) || (tsl.IndexOf("nevada") >= 0) || (tsl.IndexOf("las vegas") >= 0) || (tsl.IndexOf("(ariz.)") >= 0)
                        || (tsl.IndexOf("california") >= 0) || (tsl.IndexOf("los angeles") >= 0) || (tsl.IndexOf("(calif.)") >= 0) || (tsl.IndexOf("russia") >= 0) || (tsl.IndexOf("lake mead") >= 0) || (tsl.IndexOf("(ariz.)") >= 0)
                        || (tsl.IndexOf("united states") >= 0) || (tsl.IndexOf("(ariz.)") >= 0) || (tsl.IndexOf("el paso") >= 0) || (tsl.IndexOf("texas") >= 0) || (tsl.IndexOf("(ariz.)") >= 0) || (tsl.IndexOf("boulder city") >= 0)
                        || (tsl.IndexOf("pittman") >= 0) || (tsl.IndexOf("gabbs") >= 0) || (tsl.IndexOf("california") >= 0) || (tsl.IndexOf("colorado") >= 0)
                        || (tsl.IndexOf("reno") >= 0) || (tsl.IndexOf("(ariz.)") >= 0) || ( tsl == "japan"))
                        subject.Add_Geographic(thisSplit.Trim().Replace("\"",""));
                    // Was this temporal?
                    else if ((tsl.IndexOf("20th century") >= 0) || (tsl.IndexOf("war, 19") >= 0))
                        subject.Add_Temporal(thisSplit.Trim());
                    else if (tsl.IndexOf("maps, topographic") >= 0)
                        subject.Add_Genre(thisSplit.Trim());
                    else
                        subject.Add_Topic(thisSplit.Trim());
                }

                Package.Bib_Info.Add_Subject(subject);
            }
        }
        /// <summary> Saves the data rendered by this element to the provided bibliographic object during postback </summary>
        /// <param name="Bib"> Object into which to save the user's data, entered into the html rendered by this element </param>
        public override void Save_To_Bib(SobekCM_Item Bib)
        {
            string subject_text = String.Empty;

            string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
            foreach (string thisKey in getKeys)
            {
                if (thisKey.IndexOf(html_element_name.Replace("_", "") + "_text") == 0)
                {
                    subject_text = HttpContext.Current.Request.Form[thisKey];
                }

                if (thisKey.IndexOf(html_element_name.Replace("_", "") + "_select") == 0)
                {
                    string subject_type = HttpContext.Current.Request.Form[thisKey];
                    Subject_Info_Standard standardSubject = new Subject_Info_Standard {Authority = "fast"};

                    if (subject_text.Trim().Length > 0)
                    {
                        switch (subject_type)
                        {
                            case "genre":
                                standardSubject.Add_Genre( subject_type );
                                break;

                            case "geographic":
                                standardSubject.Add_Geographic( subject_type );
                                break;

                            case "occupational":
                                standardSubject.Add_Occupation( subject_type );
                                break;

                            case "temporal":
                                standardSubject.Add_Temporal( subject_type );
                                break;

                            case "topic":
                                standardSubject.Add_Topic( subject_type );
                                break;
                        }

                        if ((standardSubject.Topics_Count > 0) || (standardSubject.Genres_Count > 0) || (standardSubject.Geographics_Count > 0) || (standardSubject.Occupations_Count > 0) || (standardSubject.Temporals_Count > 0))
                            Bib.Bib_Info.Add_Subject(standardSubject);
                    }

                    subject_text = String.Empty;
                }
            }
        }
        /// <summary> Gets the collection of MARC tags to be written for this digital resource </summary>
        /// <param name="CatalogingSourceCode"> Cataloging source code for the 040 field, ( for example FUG for University of Florida ) </param>
        /// <param name="LocationCode"> Location code for the 852 |a - if none is given the system abbreviation will be used. Otherwise, the system abbreviation will be put in the 852 |b field. </param>
        /// <param name="ReproductionAgency"> Agency responsible for reproduction, or primary agency associated with the SobekCM instance ( for the added 533 |c field ) </param>
        /// <param name="ReproductionPlace"> Place of reproduction, or primary location associated with the SobekCM instance ( for the added 533 |b field ) </param>
        /// <param name="SystemName"> Name used for this SobekCM (or otherwise) digital repository system </param>
        /// <param name="SystemAbbreviation"> Abbrevation used for this SobekCM (or otherwise) digital repository system </param>
        /// <param name="ThumbnailBase"> Base URL for the thumbnail to be included</param>
        /// <returns> Collection of MARC tags to be written for this digital resource </returns>
        public MARC_Record To_MARC_Record(string CatalogingSourceCode, string LocationCode, string ReproductionAgency, string ReproductionPlace, string SystemName, string SystemAbbreviation, string ThumbnailBase )
        {
            // Find the first aggregation name
            string first_aggr_name = String.Empty;
            if (Behaviors.Aggregation_Count > 0)
            {
                foreach (Aggregation_Info thisAggr in Behaviors.Aggregations)
                {
                    if (( String.Compare(thisAggr.Code, "ALL", true) != 0 ) && (( String.IsNullOrEmpty(thisAggr.Type)) || (thisAggr.Type.IndexOf("INSTITUT", StringComparison.InvariantCultureIgnoreCase) < 0)))
                    {
                        first_aggr_name = thisAggr.Name;
                        break;
                    }
                }
            }

            // Create the sorted list
            MARC_Record tags = new MARC_Record();

            // Compute the sobekcm type, which will be used for some of these mappings
            TypeOfResource_SobekCM_Enum sobekcm_type = BIBInfo.SobekCM_Type;

            // Build a hashtable of all the pertinent genres
            Dictionary<string, string> genreHash = new Dictionary<string, string>();
            if (Bib_Info.Genres_Count > 0)
            {
                foreach (Genre_Info thisGenre in Bib_Info.Genres)
                {
                    if ((thisGenre.Authority == "marcgt") || (thisGenre.Authority == "sobekcm"))
                    {
                        genreHash[thisGenre.Genre_Term] = thisGenre.Genre_Term;
                    }
                }
            }

            // ADD THE 006 FOR ONLINE MATERIAL
            StringBuilder bldr006 = new StringBuilder("m     o  ");
            switch (Bib_Info.SobekCM_Type)
            {
                case TypeOfResource_SobekCM_Enum.Book:
                case TypeOfResource_SobekCM_Enum.Newspaper:
                case TypeOfResource_SobekCM_Enum.Multivolume:
                case TypeOfResource_SobekCM_Enum.Serial:
                    bldr006.Append("d");
                    break;

                case TypeOfResource_SobekCM_Enum.Video:
                case TypeOfResource_SobekCM_Enum.Audio:
                    bldr006.Append("i");
                    break;

                case TypeOfResource_SobekCM_Enum.Photograph:
                case TypeOfResource_SobekCM_Enum.Map:
                case TypeOfResource_SobekCM_Enum.Aerial:
                    bldr006.Append("c");
                    break;

                case TypeOfResource_SobekCM_Enum.Archival:
                    bldr006.Append("m");
                    break;

                default:
                    bldr006.Append(" ");
                    break;
            }
            bldr006.Append(" ");

            // Government publication?
            int govt_publication = 0;
            add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("federal government publication"), 'f', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("local government publication"), 'l', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("government publication"), 'o', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref govt_publication, 1, bldr006);
            add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref govt_publication, 1, bldr006);
            if (govt_publication == 0)
            {
                bldr006.Append(" ");
            }
            bldr006.Append("      ");
            tags.Add_Field(6, "  ", bldr006.ToString());

            // ADD THE 007 FOR ELECTRONIC RESOURCE
            StringBuilder bldr007 = new StringBuilder("cr  n");
            switch (Bib_Info.SobekCM_Type)
            {
                case TypeOfResource_SobekCM_Enum.Audio:
                case TypeOfResource_SobekCM_Enum.Video:
                    bldr007.Append("a");
                    break;

                default:
                    bldr007.Append(" ");
                    break;
            }
            bldr007.Append("---ma mp");
            tags.Add_Field(new MARC_Field(7, "  ", bldr007.ToString()));

            // ADD THE MAIN ENTITY NAME
            if (Bib_Info.hasMainEntityName)
            {
                MARC_Field main_entity_marc = Bib_Info.Main_Entity_Name.to_MARC_HTML(false);

                switch (Bib_Info.Main_Entity_Name.Name_Type)
                {
                    case Name_Info_Type_Enum.Personal:
                        main_entity_marc.Tag = 100;
                        break;

                    case Name_Info_Type_Enum.Corporate:
                        main_entity_marc.Tag = 110;
                        break;

                    case Name_Info_Type_Enum.Conference:
                        main_entity_marc.Tag = 111;
                        break;

                    case Name_Info_Type_Enum.UNKNOWN:
                        main_entity_marc.Tag = 720;
                        break;
                }
                tags.Add_Field(main_entity_marc);
            }

            // ADD THE OTHER NAMES
            if (Bib_Info.Names_Count > 0)
            {
                foreach (Name_Info name in Bib_Info.Names)
                {
                    if ((!String.IsNullOrEmpty(name.Full_Name)) || (!String.IsNullOrEmpty(name.Given_Name)) || (!String.IsNullOrEmpty(name.Family_Name)))
                    {
                        MARC_Field name_marc = name.to_MARC_HTML(false);

                        switch (name.Name_Type)
                        {
                            case Name_Info_Type_Enum.Personal:
                                name_marc.Tag = 700;
                                break;

                            case Name_Info_Type_Enum.Corporate:
                                name_marc.Tag = 710;
                                break;

                            case Name_Info_Type_Enum.Conference:
                                name_marc.Tag = 711;
                                break;

                            case Name_Info_Type_Enum.UNKNOWN:
                                name_marc.Tag = 720;
                                break;
                        }

                        tags.Add_Field(name_marc);
                    }
                }
            }

            // ADD THE DONOR
            if ((Bib_Info.hasDonor) && (Bib_Info.Donor.Full_Name.Length > 0))
            {
                MARC_Field donor_marc = Bib_Info.Donor.to_MARC_HTML(false);

                switch (Bib_Info.Donor.Name_Type)
                {
                    case Name_Info_Type_Enum.Personal:
                    case Name_Info_Type_Enum.UNKNOWN:
                        donor_marc.Indicators = donor_marc.Indicators[0] + "3";
                        donor_marc.Tag = 796;
                        tags.Add_Field(donor_marc);
                        break;

                    case Name_Info_Type_Enum.Corporate:
                    case Name_Info_Type_Enum.Conference:
                        donor_marc.Indicators = donor_marc.Indicators[0] + "3";
                        donor_marc.Tag = 797;
                        tags.Add_Field(donor_marc);
                        break;
                }
            }

            // ADD THE 260
            if ((Bib_Info.Origin_Info.Publishers_Count > 0) || (Bib_Info.Origin_Info.Date_Issued.Length > 0) || (Bib_Info.Origin_Info.MARC_DateIssued.Length > 0))
            {
                MARC_Field publisher_tag = new MARC_Field();
                StringBuilder builder260 = new StringBuilder();
                publisher_tag.Tag = 260;
                publisher_tag.Indicators = "  ";
                int pub_count = 0;
                if (Bib_Info.Publishers_Count > 0)
                {
                    foreach (Publisher_Info thisPublisher in Bib_Info.Publishers)
                    {
                        int place_count = 1;
                        bool place_added = false;
                        // ADD ALL THE |a 's for this publisher
                        if (thisPublisher.Places_Count > 0)
                        {
                            foreach (Origin_Info_Place thisPlace in thisPublisher.Places)
                            {
                                if (thisPlace.Place_Text.Length > 0)
                                {
                                    place_added = true;
                                    if (place_count > 1)
                                    {
                                        builder260.Append("; |a " + thisPlace.Place_Text + " ");
                                    }
                                    else
                                    {
                                        builder260.Append("|a " + thisPlace.Place_Text + " ");
                                    }
                                    place_count++;
                                }
                            }
                        }
                        if (!place_added)
                        {
                            builder260.Append("|a [S.l.] ");
                        }
                        builder260.Append(": ");

                        // Add the |b for this publisher
                        string pubName = thisPublisher.Name.Trim();
                        if ((pubName.Length > 2) && (pubName[pubName.Length - 1] == ','))
                        {
                            pubName = pubName.Substring(0, pubName.Length - 1);
                        }

                        builder260.Append("|b " + thisPublisher.Name);
                        pub_count++;

                        if (pub_count == Bib_Info.Publishers_Count)
                        {
                            if ((Bib_Info.Origin_Info.Date_Issued.Length > 0) || (Bib_Info.Manufacturers_Count > 0))
                            {
                                builder260.Append(", ");
                            }
                        }
                        else
                        {
                            builder260.Append(" ; ");
                        }
                    }
                }

                if (Bib_Info.Origin_Info.MARC_DateIssued.Length > 0)
                {
                    builder260.Append("|c " + Bib_Info.Origin_Info.MARC_DateIssued);
                }
                else if (Bib_Info.Origin_Info.Date_Issued.Length > 0)
                {
                    builder260.Append("|c " + Bib_Info.Origin_Info.Date_Issued);
                }

                if (Bib_Info.Manufacturers_Count > 0)
                {
                    foreach (Publisher_Info thisManufacturer in Bib_Info.Manufacturers)
                    {
                        int place_count = 1;
                        bool place_added = false;
                        // ADD ALL THE |e 's for this manufacturer
                        if (thisManufacturer.Places_Count > 0)
                        {
                            foreach (Origin_Info_Place thisPlace in thisManufacturer.Places)
                            {
                                if (thisPlace.Place_Text.Length > 0)
                                {
                                    place_added = true;
                                    if (place_count > 1)
                                    {
                                        builder260.Append("; |e " + thisPlace.Place_Text + " ");
                                    }
                                    else
                                    {
                                        builder260.Append(" |e (" + thisPlace.Place_Text + " ");
                                    }
                                    place_count++;
                                }
                            }
                        }
                        if (!place_added)
                        {
                            builder260.Append("|e ( [S.l.] ");
                        }
                        builder260.Append(": ");

                        // Add the |f for this manufacturer
                        builder260.Append("|f " + thisManufacturer.Name + ")");
                    }
                }
                else
                {
                    builder260.Append(".");
                }

                publisher_tag.Control_Field_Value = builder260.ToString();
                tags.Add_Field(publisher_tag);
            }

            // ADD ALL THE FREQUENCIES
            if (Bib_Info.Origin_Info.Frequencies_Count > 0)
            {
                foreach (Origin_Info_Frequency frequency in Bib_Info.Origin_Info.Frequencies)
                {
                    if (frequency.Authority != "marcfrequency")
                    {
                        MARC_Field frequency_tag = new MARC_Field {Tag = 310, Indicators = "  "};

                        if (frequency.Term.IndexOf("[") < 0)
                        {
                            frequency_tag.Control_Field_Value = "|a " + frequency.Term;
                        }
                        else
                        {
                            if (frequency.Term.IndexOf("[ FORMER") > 0)
                            {
                                frequency_tag.Tag = 321;
                                int square_bracket_index = frequency.Term.IndexOf("[");
                                frequency_tag.Control_Field_Value = "|a " + frequency.Term.Substring(0, square_bracket_index).Trim() + " |b " + frequency.Term.Substring(square_bracket_index + 9).Replace("]", "").Trim();
                            }
                            else
                            {
                                int square_bracket_index2 = frequency.Term.IndexOf("[");
                                frequency_tag.Control_Field_Value = "|a " + frequency.Term.Substring(0, square_bracket_index2).Trim() + " |b " + frequency.Term.Substring(square_bracket_index2 + 1).Replace("]", "").Trim();
                            }
                        }
                        tags.Add_Field(frequency_tag);
                    }
                }
            }

            // Determine if there is a link to another version of this material
            bool another_version_exists = false;
            if (Bib_Info.RelatedItems_Count > 0)
            {
                if (Bib_Info.RelatedItems.Where(relatedItem => relatedItem.URL.Length > 0).Any(relatedItem => relatedItem.Relationship == Related_Item_Type_Enum.OtherVersion))
                {
                    another_version_exists = true;
                }
            }

            // ADD ALL THE NOTES
            string statement_of_responsibility = "";
            string electronic_access_note = "";
            if (Bib_Info.Notes_Count > 0)
            {
                foreach (Note_Info thisNote in Bib_Info.Notes)
                {
                    switch (thisNote.Note_Type)
                    {
                        case Note_Type_Enum.StatementOfResponsibility:
                            statement_of_responsibility = thisNote.Note;
                            break;

                        case Note_Type_Enum.ElectronicAccess:
                            electronic_access_note = thisNote.Note;
                            break;

                        case Note_Type_Enum.PublicationStatus:
                        case Note_Type_Enum.InternalComments:
                            // DO nothing
                            break;

                        default:
                            tags.Add_Field(thisNote.to_MARC_HTML());
                            break;
                    }
                }
            }

            // Add an 856 pointing to this item first
            MARC_Field tag856 = new MARC_Field {Tag = 856, Indicators = "40"};
            string url = Bib_Info.Location.PURL;
            if (url.Length == 0)
            {
                url = web.Service_URL;
            }
            string linkText = "Electronic Resource";
            if ((Bib_Info.Type.MODS_Type == TypeOfResource_MODS_Enum.Text))
                linkText = "Click here for full text";
            if ((another_version_exists) && ( SystemAbbreviation.Length > 0 ))
            {
                if (electronic_access_note.Length > 0)
                    tag856.Control_Field_Value = "|3 " + SystemAbbreviation + " Version |u " + url + " |y " + linkText + " |z " + electronic_access_note;
                else
                    tag856.Control_Field_Value = "|3 " + SystemAbbreviation + " Version |u " + url + " |y " + linkText;
            }
            else
            {
                if (electronic_access_note.Length > 0)
                    tag856.Control_Field_Value = "|u " + url + " |y " + linkText + " |z " + electronic_access_note;
                else
                    tag856.Control_Field_Value = "|u " + url + " |y " + linkText;
            }
            tags.Add_Field(tag856);

            // ADD THE RELATED ITEMS
            if (Bib_Info.RelatedItems_Count > 0)
            {
                foreach (Related_Item_Info relatedItem in Bib_Info.RelatedItems)
                {
                    // Add the main tag
                    tags.Add_Field(relatedItem.to_MARC_HTML());

                    // If there is a URL listed, add another tag
                    if (relatedItem.URL.Length > 0)
                    {
                        MARC_Field linking_tag = new MARC_Field {Tag = 856, Indicators = "42"};
                        if (relatedItem.Relationship == Related_Item_Type_Enum.OtherVersion)
                            linking_tag.Indicators = "41";

                        StringBuilder linking856_builder = new StringBuilder();
                        if (relatedItem.URL_Display_Label.Length > 0)
                        {
                            linking856_builder.Append("|3 " + XML_Writing_Base_Type.Convert_String_To_XML_Safe_Static(relatedItem.URL_Display_Label) + " ");
                        }
                        else
                        {
                            switch (relatedItem.Relationship)
                            {
                                case Related_Item_Type_Enum.Host:
                                    linking856_builder.Append("|3 Host material ");
                                    break;

                                case Related_Item_Type_Enum.OtherFormat:
                                    linking856_builder.Append("|3 Other format ");
                                    break;

                                case Related_Item_Type_Enum.OtherVersion:
                                    linking856_builder.Append("|3 Other version ");
                                    break;

                                case Related_Item_Type_Enum.Preceding:
                                    linking856_builder.Append("|3 Preceded by ");
                                    break;

                                case Related_Item_Type_Enum.Succeeding:
                                    linking856_builder.Append("|3 Succeeded by ");
                                    break;

                                default:
                                    linking856_builder.Append("|3 Related item ");
                                    break;
                            }
                        }

                        // Add the URL
                        linking856_builder.Append("|u " + XML_Writing_Base_Type.Convert_String_To_XML_Safe_Static(relatedItem.URL) + " ");

                        // Add the title if there is one
                        if ((relatedItem.hasMainTitle) && (relatedItem.Main_Title.Title.Length > 0))
                        {
                            linking856_builder.Append("|y " + XML_Writing_Base_Type.Convert_String_To_XML_Safe_Static(relatedItem.Main_Title.Title));
                        }

                        linking_tag.Control_Field_Value = linking856_builder.ToString().Trim();
                        tags.Add_Field(linking_tag);
                    }
                }
            }

            // ADD THE TARGET AUDIENCE
            string skipped_marctarget = String.Empty;
            bool done_with_skipped = false;
            if (Bib_Info.Target_Audiences_Count > 0)
            {
                foreach (TargetAudience_Info targetAudience in Bib_Info.Target_Audiences)
                {
                    if (targetAudience.Authority.Length > 0)
                    {
                        // This part is kinda wierd.  basically, one marctarget audience can be included in the
                        // leader, so it does not need to be included in the 521 as well.  But, if there is
                        // more than one "marctarget" audience, I want ALL of them to show up here.
                        if (targetAudience.Authority == "marctarget")
                        {
                            if (skipped_marctarget.Length == 0)
                            {
                                skipped_marctarget = targetAudience.Audience;
                            }
                            else
                            {
                                if (!done_with_skipped)
                                {
                                    tags.Add_Field(521, "  ", "|a " + skipped_marctarget + " |b marctarget");
                                    done_with_skipped = true;
                                }

                                tags.Add_Field(521, "  ", "|a " + targetAudience.Audience + " |b " + targetAudience.Authority);
                            }
                        }
                        else
                        {
                            tags.Add_Field(521, "  ", "|a " + targetAudience.Audience + " |b " + targetAudience.Authority);
                        }
                    }
                    else
                    {
                        tags.Add_Field(521, "  ", "|a " + targetAudience.Audience);
                    }
                }
            }

            //// ADD THE ORIGINAL CATALOGING SOURCE INFORMATION
            //if (this.Bib_Info.Record.MARC_Record_Content_Sources.Count > 0)
            //{
            //    MARC_XML_Field origCatSource = new MARC_XML_Field();
            //    StringBuilder builder599 = new StringBuilder();
            //    origCatSource.Tag = "599";
            //    origCatSource.Indicators = "  ";
            //    builder599.Append("|a " + this.Bib_Info.Record.MARC_Record_Content_Sources[0]);
            //    if (this.Bib_Info.Record.MARC_Record_Content_Sources.Count > 1)
            //    {
            //        builder599.Append(" |c " + this.Bib_Info.Record.MARC_Record_Content_Sources[1]);
            //    }
            //    int orig_count = 2;
            //    while (orig_count < this.Bib_Info.Record.MARC_Record_Content_Sources.Count)
            //    {
            //        builder599.Append(" |d " + this.Bib_Info.Record.MARC_Record_Content_Sources[orig_count]);
            //        orig_count++;
            //    }
            //    origCatSource.Field = builder599.ToString();
            //    tags.Add_Field(origCatSource);
            //}

            // Add the NEW cataloging source information
            if ((!String.IsNullOrEmpty(CatalogingSourceCode)) || ( Bib_Info.Record.MARC_Record_Content_Sources_Count > 0 ))
            {

                MARC_Field catSource = new MARC_Field { Tag = 40, Indicators = "  " };

                StringBuilder catSourceBuilder = new StringBuilder();
                if (Bib_Info.Record.MARC_Record_Content_Sources_Count > 0)
                {
                    bool a_added = false;
                    foreach (string thisSource in Bib_Info.Record.MARC_Record_Content_Sources)
                    {
                        if (!a_added)
                        {
                            catSourceBuilder.Append("|a " + thisSource);
                            a_added = true;
                        }
                        else
                        {
                            catSourceBuilder.Append(" |d " + thisSource);
                        }
                    }
                }
                else
                {
                    catSourceBuilder.Append("|a " + CatalogingSourceCode.Trim() + " |c " + CatalogingSourceCode.Trim());
                }

                if (BIBInfo.Record.Description_Standard.Length > 0)
                    catSourceBuilder.Append(" |e " + BIBInfo.Record.Description_Standard.ToLower());
                catSource.Control_Field_Value = catSourceBuilder.ToString();
                tags.Add_Field(catSource);
            }

            // ADD THE ABSTRACTS
            if (Bib_Info.Abstracts_Count > 0)
            {
                foreach (Abstract_Info thisAbstract in Bib_Info.Abstracts)
                {
                    tags.Add_Field(thisAbstract.to_MARC_HTML());
                }
            }

            // ADD THE MAIN TITLE
            if (Bib_Info.Main_Title.Title.Length > 0)
            {
                MARC_Field mainTitleTag = Bib_Info.Main_Title.to_MARC_HTML(245, 2, statement_of_responsibility, "[electronic resource]");
                if ((Bib_Info.hasMainEntityName) && (Bib_Info.Main_Entity_Name.Full_Name.Length > 0))
                    mainTitleTag.Indicators = "1" + mainTitleTag.Indicators[1];
                else
                    mainTitleTag.Indicators = "0" + mainTitleTag.Indicators[1];

                tags.Add_Field(mainTitleTag);
            }

            // ADD THE SERIES TITLE
            if ((Bib_Info.hasSeriesTitle) && (Bib_Info.SeriesTitle.Title.Length > 0))
            {
                tags.Add_Field(Bib_Info.SeriesTitle.to_MARC_HTML(490, 0, String.Empty, String.Empty));
            }

            // ADD ALL OTHER TITLES
            if (Bib_Info.Other_Titles_Count > 0)
            {
                foreach (Title_Info thisTitle in Bib_Info.Other_Titles)
                {
                    tags.Add_Field(thisTitle.to_MARC_HTML(-1, -1, String.Empty, String.Empty));
                }
            }

            // ADD THE EXTENT
            if (Bib_Info.Original_Description.Extent.Length > 0)
            {
                int semi_index = Bib_Info.Original_Description.Extent.IndexOf(";");
                int colon_index = Bib_Info.Original_Description.Extent.IndexOf(":");
                if ((semi_index > 0) || (colon_index > 0))
                {
                    string a_300_subfield_string;
                    string b_300_subfield_string = String.Empty;
                    string c_300_subfield_string = String.Empty;

                    if (semi_index > 0)
                    {
                        if (colon_index > 0)
                        {
                            a_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(0, colon_index);
                            b_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(colon_index + 1, semi_index - colon_index - 1);
                            c_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(semi_index + 1);

                            //tags.Add_Field("300", "  ", "|a " + this.Bib_Info.Original_Description.Extent.Substring(0, colon_index + 1) + " |b " + this.Bib_Info.Original_Description.Extent.Substring(colon_index + 1, semi_index - colon_index) + " |c " + this.Bib_Info.Original_Description.Extent.Substring(semi_index + 1));
                        }
                        else
                        {
                            a_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(0, semi_index);
                            c_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(semi_index + 1);

                            // No colon ( colon_index < 0 )
                            //tags.Add_Field("300", "  ", "|a " + this.Bib_Info.Original_Description.Extent.Substring(0, semi_index + 1) + " |c " + this.Bib_Info.Original_Description.Extent.Substring(semi_index + 1));
                        }
                    }
                    else
                    {
                        a_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(0, colon_index);
                        b_300_subfield_string = Bib_Info.Original_Description.Extent.Substring(colon_index + 1);

                        // No semi colon ( semi_index < 0 )
                        //tags.Add_Field("300", "  ", "|a " + this.Bib_Info.Original_Description.Extent.Substring(0, colon_index + 1) + " |b " + this.Bib_Info.Original_Description.Extent.Substring(colon_index + 1));
                    }

                    StringBuilder builder_300 = new StringBuilder("|a " + a_300_subfield_string, a_300_subfield_string.Length + b_300_subfield_string.Length + c_300_subfield_string.Length + 10);
                    if (b_300_subfield_string.Trim().Length > 0)
                    {
                        builder_300.Append(": |b " + b_300_subfield_string);
                    }
                    if (c_300_subfield_string.Trim().Length > 0)
                    {
                        builder_300.Append("; |c " + c_300_subfield_string);
                    }
                    tags.Add_Field(300, "  ", builder_300.ToString());
                }
                else
                {
                    tags.Add_Field(300, "  ", "|a " + Bib_Info.Original_Description.Extent);
                }
            }

            // ADD THE EDITION
            if (Bib_Info.Origin_Info.Edition.Length > 0)
            {
                if (Bib_Info.Origin_Info.Edition.IndexOf(" -- ") > 0)
                {
                    int edition_index = Bib_Info.Origin_Info.Edition.IndexOf(" -- ");
                    tags.Add_Field(250, "  ", "|a " + Bib_Info.Origin_Info.Edition.Substring(0, edition_index) + " /|b " + Bib_Info.Origin_Info.Edition.Substring(edition_index + 4));
                }
                else
                {
                    tags.Add_Field(250, "  ", "|a " + Bib_Info.Origin_Info.Edition);
                }
            }

            // ADD THE CLASSIFICATIONS
            if (Bib_Info.Classifications_Count > 0)
            {
                foreach (Classification_Info thisClassification in Bib_Info.Classifications)
                {
                    tags.Add_Field(thisClassification.to_MARC_Tag());
                }
            }

            // ADD ALL THE IDENTIFIERS
            if (Bib_Info.Identifiers_Count > 0)
            {
                foreach (Identifier_Info thisIdentifier in Bib_Info.Identifiers)
                {
                    switch (thisIdentifier.Type.ToUpper())
                    {
                        case "LCCN":
                            tags.Add_Field(10, "  ", "|a  " + thisIdentifier.Identifier);
                            break;

                        case "ISBN":
                            tags.Add_Field(20, "  ", "|a " + thisIdentifier.Identifier);
                            break;

                        case "ISSN":
                            tags.Add_Field(22, "  ", "|a " + thisIdentifier.Identifier);
                            break;

                        case "OCLC":
                            tags.Add_Field(776, "1 ", "|c Original |w (OCoLC)" + thisIdentifier.Identifier);
                            break;

                        case "NOTIS":
                            tags.Add_Field(035, "9 ", "|a " + thisIdentifier.Identifier + " |b UF");
                            break;

                        case "ALEPH":
                            tags.Add_Field(035, "9 ", "|a " + thisIdentifier.Identifier.PadLeft(9, '0') + " |b UF");
                            break;

                        default:
                            if (thisIdentifier.Type.Length > 0)
                            {
                                tags.Add_Field(024, "7 ", "|a " + thisIdentifier.Identifier + " |2 " + thisIdentifier.Type);
                            }
                            else
                            {
                                tags.Add_Field(024, "8 ", "|a " + thisIdentifier.Identifier);
                            }
                            break;
                    }
                }
            }

            // ADD THE MAIN IDENTIFIER
            if ((METS_Header.ObjectID.Length > 0) || (Bib_Info.Record.Main_Record_Identifier.Identifier.Length > 0) || ((BibID.Length > 0) && ((VID.Length > 0) || (METS_Header.RecordStatus_Enum != METS_Record_Status.BIB_LEVEL))))
            {
                if (Bib_Info.Record.Main_Record_Identifier.Identifier.Length > 0)
                {
                    tags.Add_Field(1, "  ", Bib_Info.Record.Main_Record_Identifier.Identifier);
                }
                else
                {
                    if (METS_Header.ObjectID.Length > 0)
                    {
                        tags.Add_Field(1, "  ", METS_Header.ObjectID);
                    }
                    else
                    {
                        if (METS_Header.RecordStatus_Enum != METS_Record_Status.BIB_LEVEL)
                            tags.Add_Field(1, "  ", BibID + "_" + VID);
                        else
                            tags.Add_Field(1, "  ", BibID);
                    }
                }
            }

            // ADD THE LAST MODIFIED DATE
            tags.Add_Field(5, "  ", METS_Header.Modify_Date.Year +
                                    METS_Header.Modify_Date.Month.ToString().PadLeft(2, '0') +
                                    METS_Header.Modify_Date.Day.ToString().PadLeft(2, '0') +
                                    METS_Header.Modify_Date.Hour.ToString().PadLeft(2, '0') +
                                    METS_Header.Modify_Date.Minute.ToString().PadLeft(2, '0') +
                                    METS_Header.Modify_Date.Second.ToString().PadLeft(2, '0') + ".0");

            // ADD THE SUBJECT KEYWORDS
            if (Bib_Info.Subjects_Count > 0)
            {
                foreach (Subject_Info thisSubject in Bib_Info.Subjects)
                {
                    tags.Add_Field(thisSubject.to_MARC_HTML());
                }
            }

            // ADD ANY NON-MARCGT GENRE TERMS AS 655 CODES AS WELL
            if (Bib_Info.Genres_Count > 0)
            {
                foreach (Genre_Info thisGenre in Bib_Info.Genres)
                {
                    tags.Add_Field(thisGenre.to_MARC_HTML());
                }
            }

            // ADD THE TEMPORAL SUBJECT (if the term appears nowehere in the subjects)
            if (Bib_Info.TemporalSubjects_Count > 0)
            {
                foreach (Temporal_Info thisTemporal in Bib_Info.TemporalSubjects)
                {
                    string temporal_upper = thisTemporal.TimePeriod.ToUpper();
                    string years = String.Empty;
                    if ((thisTemporal.Start_Year > 0) && (thisTemporal.End_Year > 0))
                        years = thisTemporal.Start_Year.ToString() + "-" + thisTemporal.End_Year;
                    if ((thisTemporal.Start_Year > 0) && (thisTemporal.End_Year < 0))
                        years = thisTemporal.Start_Year.ToString() + "-";
                    if ((thisTemporal.Start_Year < 0) && (thisTemporal.End_Year > 0))
                        years = "-" + thisTemporal.End_Year;
                    bool found = false;
                    if (Bib_Info.Subjects_Count > 0)
                    {
                        foreach (Subject_Info thisSubject in Bib_Info.Subjects)
                        {
                            if (thisSubject.Class_Type == Subject_Info_Type.Standard)
                            {
                                Subject_Info_Standard standSubject = (Subject_Info_Standard) thisSubject;
                                if (standSubject.Temporals_Count > 0)
                                {
                                    if (standSubject.Temporals.Any(temporal => (temporal_upper == temporal.ToUpper()) || (temporal == years)))
                                    {
                                        found = true;
                                    }
                                }
                            }

                            if (found)
                                break;
                        }
                    }

                    if (!found)
                    {
                        Subject_Info_Standard tempSubject = new Subject_Info_Standard();
                        if (years.Length > 0)
                        {
                            tempSubject.Add_Temporal(years);
                        }
                        if (thisTemporal.TimePeriod.Length > 0)
                        {
                            tempSubject.Add_Temporal(thisTemporal.TimePeriod);
                        }
                        tags.Add_Field(tempSubject.to_MARC_HTML());
                    }
                }
            }

            // ADD THE TABLE OF CONTENTS
            if (Bib_Info.TableOfContents.Length > 0)
            {
                tags.Add_Field(505, "0 ", "|a " + Bib_Info.TableOfContents);
            }

            // ADD THE RIGHTS
            if (Bib_Info.Access_Condition.Text.Length > 0)
            {
                if (String.Compare(Bib_Info.Access_Condition.Type, "use and reproduction", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if ( Bib_Info.Access_Condition.Text.IndexOf("http") == 0 )
                        tags.Add_Field(540, "  ", "|u " + Bib_Info.Access_Condition.Text);
                    else
                        tags.Add_Field(540, "  ", "|a " + Bib_Info.Access_Condition.Text);
                }
                else
                {
                    if (Bib_Info.Access_Condition.Text.IndexOf("http") == 0)
                        tags.Add_Field(506, "  ", "|u " + Bib_Info.Access_Condition.Text);
                    else
                        tags.Add_Field(506, "  ", "|a " + Bib_Info.Access_Condition.Text);
                }
            }

            // ADD THE HOLDING LOCATION
            if ((Bib_Info.hasLocationInformation) && (Bib_Info.Location.Holding_Name.Length > 0))
            {
                if (Bib_Info.Location.Holding_Name[Bib_Info.Location.Holding_Name.Length - 1] != '.')
                    tags.Add_Field(535, "1 ", "|a " + Bib_Info.Location.Holding_Name + ".");
                else
                    tags.Add_Field(535, "1 ", "|a " + Bib_Info.Location.Holding_Name);
            }

            // IF THERE IS MORE THAN ONE LANGUAGE, ADD THEM ALL IN THE 041
            if (Bib_Info.Languages_Count > 1)
            {
                StringBuilder marc_coded_languages = new StringBuilder();
                foreach (Language_Info thisLanguage in Bib_Info.Languages)
                {
                    if (thisLanguage.Language_ISO_Code.Length > 0)
                        marc_coded_languages.Append("|a " + thisLanguage.Language_ISO_Code + " ");
                }
                if (marc_coded_languages.Length > 0)
                    tags.Add_Field(041, "  ", marc_coded_languages.ToString().Trim());
            }

            // ADD THE 008 FIELD (FIXED LENGTH DATA ELEMENTS)
            MARC_Field fixedField008 = new MARC_Field {Indicators = "  ", Tag = 008};
            StringBuilder builder008 = new StringBuilder();
            builder008.Append(METS_Header.Create_Date.Year.ToString().Substring(2) + METS_Header.Create_Date.Month.ToString().PadLeft(2, '0') + METS_Header.Create_Date.Day.ToString().PadLeft(2, '0'));

            if ((Bib_Info.Origin_Info.MARC_DateIssued_Start.Length == 0) && (Bib_Info.Origin_Info.MARC_DateIssued_End.Length == 0))
            {
                builder008.Append("n        ");
            }
            else
            {
                if ((sobekcm_type != TypeOfResource_SobekCM_Enum.Newspaper) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Serial) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Multivolume))
                {
                    if ((Bib_Info.Origin_Info.MARC_DateIssued_End.Length == 0) || (Bib_Info.Origin_Info.MARC_DateIssued_End == "0000"))
                    {
                        builder008.Append("s" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "    ");
                    }
                    else
                    {
                        switch (Bib_Info.Origin_Info.MARC_DateIssued_End.ToUpper())
                        {
                            case "UUUU":
                                builder008.Append("u" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "uuuu");
                                break;

                            case "9999":
                                builder008.Append("m" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "9999");
                                break;

                            default:
                                if (Bib_Info.Origin_Info.Date_Reprinted == Bib_Info.Origin_Info.MARC_DateIssued_Start)
                                {
                                    builder008.Append("r" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + Bib_Info.Origin_Info.MARC_DateIssued_End.PadLeft(4, '0'));
                                }
                                else
                                {
                                    if (Bib_Info.Origin_Info.Date_Copyrighted == Bib_Info.Origin_Info.MARC_DateIssued_End)
                                    {
                                        builder008.Append("t" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + Bib_Info.Origin_Info.MARC_DateIssued_End.PadLeft(4, '0'));
                                    }
                                    else
                                    {
                                        builder008.Append("d" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + Bib_Info.Origin_Info.MARC_DateIssued_End.PadLeft(4, '0'));
                                    }
                                }
                                break;
                        }
                    }
                }
                else
                {
                    if (Bib_Info.Origin_Info.MARC_DateIssued_End.Length == 0)
                    {
                        builder008.Append("s" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "    ");
                    }
                    else
                    {
                        switch (Bib_Info.Origin_Info.MARC_DateIssued_End.ToUpper())
                        {
                            case "UUUU":
                                builder008.Append("u" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "uuuu");
                                break;

                            case "9999":
                                builder008.Append("c" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + "9999");
                                break;

                            default:
                                builder008.Append("d" + Bib_Info.Origin_Info.MARC_DateIssued_Start.PadLeft(4, '0') + Bib_Info.Origin_Info.MARC_DateIssued_End.PadLeft(4, '0'));
                                break;
                        }
                    }
                }
            }

            // Is there a place listed in marc country?
            string marccountry_code = "xx ";
            if (Bib_Info.Origin_Info.Places_Count > 0)
            {
                foreach (Origin_Info_Place thisPlace in Bib_Info.Origin_Info.Places)
                {
                    if (thisPlace.Place_MarcCountry.Length > 0)
                    {
                        marccountry_code = thisPlace.Place_MarcCountry.PadRight(3, ' ');
                        break;
                    }
                }
            }
            builder008.Append(marccountry_code);

            // Set the default code for the any simple flag characters
            char default_code = '|';
            if (Bib_Info.EncodingLevel.Length > 0)
                default_code = '0';

            #region Map Specific 008 Values

            // Build the Map-Specific 008 Values
            if (sobekcm_type == TypeOfResource_SobekCM_Enum.Map)
            {
                // Add the map relief information
                string map_relief_note = String.Empty;
                if (Bib_Info.Notes_Count > 0)
                {
                    foreach (Note_Info thisNote in Bib_Info.Notes)
                    {
                        if (thisNote.Note_Type == Note_Type_Enum.NONE)
                        {
                            if ((thisNote.Note.IndexOf("Relief shown") >= 0) || (thisNote.Note.IndexOf("Depths shown") >= 0) || (thisNote.Note.IndexOf("Depth shown") >= 0))
                            {
                                map_relief_note = thisNote.Note;
                            }
                        }
                    }
                }
                if (map_relief_note.Length > 0)
                {
                    string[] map_relief_note_splitter = map_relief_note.Split(".".ToCharArray());
                    int map_relief_info = 0;
                    foreach (string map_split in map_relief_note_splitter)
                    {
                        add_value((map_split.IndexOf("contours") >= 0), 'a', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("shading") >= 0), 'b', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("Relief") >= 0) && ((map_split.IndexOf("gradient") >= 0) || (map_split.IndexOf("bathymetric") >= 0)), 'c', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("hachure") >= 0), 'd', ref map_relief_info, 4, builder008);
                        add_value(((map_split.IndexOf("Depth") >= 0) && (map_split.IndexOf("soundings") > 0)) || (map_split.IndexOf("spot depth") >= 0), 'e', ref map_relief_info, 4, builder008);
                        add_value(map_split.IndexOf("form lines") >= 0, 'f', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("spot height") >= 0), 'g', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("pictorially") >= 0), 'i', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("land forms") >= 0), 'j', ref map_relief_info, 4, builder008);
                        add_value((map_split.IndexOf("isolines") >= 0), 'k', ref map_relief_info, 4, builder008);
                    }
                    for (int i = map_relief_info; i < 4; i++)
                        builder008.Append(" ");
                }
                else
                {
                    builder008.Append("    ");
                }

                // Add the projection information
                bool map_projection_handled = false;
                if (Bib_Info.Subjects_Count > 0)
                {
                    foreach (Subject_Info possibleCarto in Bib_Info.Subjects)
                    {
                        if ((possibleCarto.Authority == "marcgt") && (possibleCarto.Class_Type == Subject_Info_Type.Cartographics))
                        {
                            if (((Subject_Info_Cartographics) possibleCarto).Projection.Length == 2)
                            {
                                builder008.Append(((Subject_Info_Cartographics) possibleCarto).Projection);
                                map_projection_handled = true;
                                break;
                            }
                        }
                    }
                }
                if (!map_projection_handled)
                {
                    builder008.Append("  ");
                }

                // Undefined character position
                builder008.Append(" ");

                // Add the type of cartographic material
                int map_type = 0;
                add_value(genreHash.ContainsKey("atlas"), 'e', ref map_type, 1, builder008);
                add_value(genreHash.ContainsKey("globe"), 'd', ref map_type, 1, builder008);
                add_value(genreHash.ContainsKey("single map"), 'a', ref map_type, 1, builder008);
                add_value(genreHash.ContainsKey("map series"), 'b', ref map_type, 1, builder008);
                add_value(genreHash.ContainsKey("map serial"), 'c', ref map_type, 1, builder008);
                if (map_type == 0)
                {
                    builder008.Append(" ");
                }

                // Two undefined positions
                builder008.Append("  ");

                // Government publication?
                int map_govt_publication = 0;
                add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("federal government publication"), 'f', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("local government publication"), 'l', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication"), 'o', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref map_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref map_govt_publication, 1, builder008);
                if (map_govt_publication == 0)
                {
                    builder008.Append(" ");
                }

                // Add form of item
                builder008.Append("o");

                // Undefined position
                builder008.Append(" ");

                // Code if this includes an index
                if (genreHash.ContainsKey("indexed"))
                {
                    builder008.Append("1");
                }
                else
                {
                    builder008.Append(default_code);
                }

                // Undefined position
                builder008.Append(" ");

                // Special format characteristics
                builder008.Append("  ");
            }

            #endregion

            #region Continuing Resource Specific 008 Values

            // Build the Continuing Resource-Specific 008 Values
            if ((sobekcm_type == TypeOfResource_SobekCM_Enum.Newspaper) || (sobekcm_type == TypeOfResource_SobekCM_Enum.Serial))
            {
                // Add the frequency (008/18)
                int newspaper_frequency = 0;
                if (Bib_Info.Origin_Info.Frequencies_Count > 0)
                {
                    foreach (Origin_Info_Frequency thisFrequency in Bib_Info.Origin_Info.Frequencies)
                    {
                        if (thisFrequency.Authority == "marcfrequency")
                        {
                            add_value(thisFrequency.Term == "annual", 'a', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "bimonthly", 'b', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "semiweekly", 'c', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "daily", 'd', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "bieweekly", 'e', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "semiannual", 'f', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "biennial", 'g', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "triennial", 'h', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "three times a week", 'i', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "three times a month", 'j', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "continuously updated", 'k', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "monthly", 'm', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "quarterly", 'q', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "semimonthly", 's', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "three times a year", 't', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "weekly", 'w', ref newspaper_frequency, 1, builder008);
                            add_value(thisFrequency.Term == "other", 'z', ref newspaper_frequency, 1, builder008);
                        }
                    }
                }
                if (newspaper_frequency == 0)
                    builder008.Append(" ");

                // Add the regularity (08/19)
                int newspaper_regularity = 0;
                if (Bib_Info.Origin_Info.Frequencies_Count > 0)
                {
                    foreach (Origin_Info_Frequency thisFrequency in Bib_Info.Origin_Info.Frequencies)
                    {
                        if (thisFrequency.Authority == "marcfrequency")
                        {
                            add_value(thisFrequency.Term == "normalized irregular", 'n', ref newspaper_regularity, 1, builder008);
                            add_value(thisFrequency.Term == "regular", 'r', ref newspaper_regularity, 1, builder008);
                            add_value(thisFrequency.Term == "completely irregular", 'x', ref newspaper_regularity, 1, builder008);
                        }
                    }
                }
                if (newspaper_regularity == 0)
                    builder008.Append("u");

                // undefined (008/20)
                builder008.Append(" ");

                // Add the type of continuing resource (008/21)
                int newspaper_type = 0;
                add_value(genreHash.ContainsKey("database"), 'd', ref newspaper_type, 1, builder008);
                add_value(genreHash.ContainsKey("loose-leaf"), 'l', ref newspaper_type, 1, builder008);
                add_value(genreHash.ContainsKey("newspaper"), 'n', ref newspaper_type, 1, builder008);
                add_value(genreHash.ContainsKey("periodical"), 'p', ref newspaper_type, 1, builder008);
                add_value(genreHash.ContainsKey("series"), 's', ref newspaper_type, 1, builder008);
                add_value(genreHash.ContainsKey("web site"), 'w', ref newspaper_type, 1, builder008);
                if (newspaper_type == 0)
                    builder008.Append(" ");

                // Add original form of item and this item (electronic) (008/22-23)
                builder008.Append(sobekcm_type == TypeOfResource_SobekCM_Enum.Newspaper ? "eo" : " o");

                // Add nature of work (008/24-27)
                int newspaper_nature_of_contents = 0;
                add_value(genreHash.ContainsKey("abstract or summary"), 'a', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("bibliography"), 'b', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("catalog"), 'c', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("dictionary"), 'd', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("directory"), 'r', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("discography"), 'k', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("encyclopedia"), 'e', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("filmography"), 'q', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("handbook"), 'f', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("index"), 'i', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("law report or digest"), 'w', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("legal article"), 'g', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("legal case and case notes"), 'v', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("legislation"), 'l', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("patent"), 'j', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("programmed text"), 'p', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("review"), 'o', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("statistics"), 's', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("survey of literature"), 'n', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("technical reports"), 't', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("theses"), 'm', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("treaty"), 'z', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("offprint"), '2', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("yearbook"), 'y', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("calendar"), '5', ref newspaper_nature_of_contents, 3, builder008);
                add_value(genreHash.ContainsKey("comic/graphic novel"), '6', ref newspaper_nature_of_contents, 3, builder008);
                for (int i = newspaper_nature_of_contents; i < 4; i++)
                {
                    builder008.Append(" ");
                }

                // Code if this is a government document (008/28)
                int newspaper_govt_publication = 0;
                add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("federal government publication"), 'f', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("local government publication"), 'l', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication"), 'o', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref newspaper_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref newspaper_govt_publication, 1, builder008);
                if (newspaper_govt_publication == 0)
                {
                    builder008.Append(" ");
                }

                // Code if this is a conference publication (008/29)
                if (genreHash.ContainsKey("conference publication"))
                {
                    builder008.Append("1");
                }
                else
                {
                    builder008.Append(default_code);
                }

                // Undefined (008/30-32)
                builder008.Append("   ");

                // Code original alphebet or script of title
                builder008.Append(" ");

                // Code the entry convention
                builder008.Append("0");
            }

            #endregion

            #region Book Specific 008 Values

            if (sobekcm_type == TypeOfResource_SobekCM_Enum.Book)
            {
                if (Bib_Info.Original_Description.Extent.Length > 0)
                {
                    int book_illustration_specs = 0;
                    string extent_upper = Bib_Info.Original_Description.Extent.ToUpper();
                    add_value((extent_upper.IndexOf("ILL.") >= 0), 'a', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("MAP") >= 0), 'b', ref book_illustration_specs, 4, builder008);
                    add_value(((extent_upper.IndexOf("PORT.") >= 0) || (extent_upper.IndexOf("PORTS.") >= 0)), 'c', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("CHART") >= 0), 'd', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("PLAN") >= 0), 'e', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("PLATE") >= 0), 'f', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("MUSIC") >= 0), 'g', ref book_illustration_specs, 4, builder008);
                    add_value(((extent_upper.IndexOf("FACSIM.") >= 0) || (extent_upper.IndexOf("FACSIMS.") >= 0)), 'h', ref book_illustration_specs, 4, builder008);
                    add_value(((extent_upper.IndexOf("COAT OF ARMS") >= 0) || (extent_upper.IndexOf("COATS OF ARMS") >= 0)), 'i', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("FORM") >= 0), 'k', ref book_illustration_specs, 4, builder008);
                    add_value((extent_upper.IndexOf("SAMPLE") >= 0), 'l', ref book_illustration_specs, 4, builder008);
                    add_value(((extent_upper.IndexOf("PHOTO.") >= 0) || (extent_upper.IndexOf("PHOTOS.") >= 0)), 'o', ref book_illustration_specs, 4, builder008);

                    // Finish this off
                    if (book_illustration_specs == 0)
                    {
                        builder008.Append("    ");
                    }
                    else
                    {
                        for (int i = book_illustration_specs; i < 4; i++)
                        {
                            builder008.Append(" ");
                        }
                    }
                }
                else
                {
                    builder008.Append("||||");
                }

                // Look for target audience
                int book_target_audiences = 0;
                if (Bib_Info.Target_Audiences_Count > 0)
                {
                    foreach (TargetAudience_Info thisTarget in Bib_Info.Target_Audiences)
                    {
                        if (thisTarget.Authority == "marctarget")
                        {
                            add_value(thisTarget.Audience == "adolescent", 'd', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "adult", 'e', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "general", 'g', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "primary", 'b', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "pre-adolescent", 'c', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "juvenile", 'j', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "preschool", 'a', ref book_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "specialized", 'f', ref book_target_audiences, 1, builder008);
                        }
                    }
                }
                if (book_target_audiences == 0)
                    builder008.Append(" ");

                // Always electronic --> online (1/11/2013)
                builder008.Append("o");

                // Code nature of contents
                int book_nature_of_contents = 0;
                add_value(genreHash.ContainsKey("abstract or summary"), 'a', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("bibliography"), 'b', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("catalog"), 'c', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("dictionary"), 'd', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("directory"), 'r', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("discography"), 'k', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("encyclopedia"), 'e', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("filmography"), 'q', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("handbook"), 'f', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("index"), 'i', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("law report or digest"), 'w', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("legal article"), 'g', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("legal case and case notes"), 'v', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("legislation"), 'l', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("patent"), 'j', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("programmed text"), 'p', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("review"), 'o', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("statistics"), 's', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("survey of literature"), 'n', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("technical reports"), 't', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("theses"), 'm', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("treaty"), 'z', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("offprint"), '2', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("yearbook"), 'y', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("calendar"), '5', ref book_nature_of_contents, 4, builder008);
                add_value(genreHash.ContainsKey("comic/graphic novel"), '6', ref book_nature_of_contents, 4, builder008);

                for (int i = book_nature_of_contents; i < 4; i++)
                {
                    builder008.Append(" ");
                }

                // Code if this is a government document
                int book_govt_publication = 0;
                add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("federal government publication"), 'f', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("local government publication"), 'l', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication"), 'o', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref book_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref book_govt_publication, 1, builder008);
                if (book_govt_publication == 0)
                {
                    builder008.Append(" ");
                }

                // Code if this is a conference publication
                if (genreHash.ContainsKey("conference publication"))
                {
                    builder008.Append("1");
                }
                else
                {
                    builder008.Append(default_code);
                }

                // Code if this is a festschrift
                if (genreHash.ContainsKey("festschrift"))
                {
                    builder008.Append("1");
                }
                else
                {
                    builder008.Append(default_code);
                }

                // Code if this includes an index
                if (genreHash.ContainsKey("indexed"))
                {
                    builder008.Append("1");
                }
                else
                {
                    builder008.Append(default_code);
                }

                // Undefined character spot
                builder008.Append(" ");

                // Code the literary form
                int book_literary_form = 0;
                add_value(genreHash.ContainsKey("drama"), 'd', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("comic strip"), 'a', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("essay"), 'e', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("humor, satire"), 'h', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("letter"), 'i', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("poetry"), 'p', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("novel"), 'f', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("short story"), 'j', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("speech"), 's', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("non-fiction"), '0', ref book_literary_form, 1, builder008);
                add_value(genreHash.ContainsKey("fiction"), '1', ref book_literary_form, 1, builder008);
                if (book_literary_form == 0)
                    builder008.Append("u");

                // Code the biography value
                int book_biography_value = 0;
                add_value(genreHash.ContainsKey("autobiography"), 'a', ref book_biography_value, 1, builder008);
                add_value(genreHash.ContainsKey("individual biography"), 'b', ref book_biography_value, 1, builder008);
                add_value(genreHash.ContainsKey("collective biography"), 'c', ref book_biography_value, 1, builder008);
                if (book_biography_value == 0)
                    builder008.Append(" ");
            }

            #endregion

            #region Visual Material Specific 008 Values

            if ((sobekcm_type == TypeOfResource_SobekCM_Enum.Aerial) || (sobekcm_type == TypeOfResource_SobekCM_Enum.Photograph) || (sobekcm_type == TypeOfResource_SobekCM_Enum.Audio) || (sobekcm_type == TypeOfResource_SobekCM_Enum.Video) || (sobekcm_type == TypeOfResource_SobekCM_Enum.Artifact))
            {
                // Code running time for movies (008/18-20)
                builder008.Append("nnn");

                // Undefined (008/21)
                builder008.Append(" ");

                // Target Audience (008/22)
                int visual_target_audiences = 0;
                if (Bib_Info.Target_Audiences_Count > 0)
                {
                    foreach (TargetAudience_Info thisTarget in Bib_Info.Target_Audiences)
                    {
                        if (thisTarget.Authority == "marctarget")
                        {
                            add_value(thisTarget.Audience == "adolescent", 'd', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "adult", 'e', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "general", 'g', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "primary", 'b', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "pre-adolescent", 'c', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "juvenile", 'j', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "preschool", 'a', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "specialized", 'f', ref visual_target_audiences, 1, builder008);
                        }
                    }
                }
                if (visual_target_audiences == 0)
                    builder008.Append(" ");

                // Undefined (008/23-27)
                builder008.Append("     ");

                // Is this a government publication? (008/28)
                int visual_govt_publication = 0;
                add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("federal government publication"), 'f', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("local government publication"), 'l', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication"), 'o', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref visual_govt_publication, 1, builder008);
                if (visual_govt_publication == 0)
                {
                    builder008.Append(" ");
                }

                // What is the form of this item (always electronic) (008/29)
                builder008.Append("o");

                // Undefined (008/30-32)
                builder008.Append("   ");

                // Type of visual material (008/33)
                int visual_nature_of_contents = 0;
                add_value(genreHash.ContainsKey("art original"), 'a', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("art reproduction"), 'c', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("chart"), 'n', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("diorama"), 'd', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("filmstrip"), 'f', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("flash card"), 'o', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("graphic"), 'k', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("kit"), 'b', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("microscope slide"), 'p', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("model"), 'q', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("motion picture"), 'm', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("picture"), 'i', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("realia"), 'r', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("slide"), 's', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("technical drawing"), 'l', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("toy"), 'w', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("transparency"), 't', ref visual_nature_of_contents, 1, builder008);
                add_value(genreHash.ContainsKey("video recording"), 'v', ref visual_nature_of_contents, 1, builder008);
                if (visual_nature_of_contents == 0)
                {
                    builder008.Append(" ");
                }

                // Technique (008/34)
                builder008.Append(sobekcm_type == TypeOfResource_SobekCM_Enum.Video ? "u" : "n");
            }

            #endregion

            #region Visual Material Specific 008 Values

            if (sobekcm_type == TypeOfResource_SobekCM_Enum.Dataset)
            {
                // Undefined (008/18-21)
                builder008.Append("    ");

                // Target Audience (008/22)
                int visual_target_audiences = 0;
                if (Bib_Info.Target_Audiences_Count > 0)
                {
                    foreach (TargetAudience_Info thisTarget in Bib_Info.Target_Audiences)
                    {
                        if (thisTarget.Authority == "marctarget")
                        {
                            add_value(thisTarget.Audience == "adolescent", 'd', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "adult", 'e', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "general", 'g', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "primary", 'b', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "pre-adolescent", 'c', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "juvenile", 'j', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "preschool", 'a', ref visual_target_audiences, 1, builder008);
                            add_value(thisTarget.Audience == "specialized", 'f', ref visual_target_audiences, 1, builder008);
                        }
                    }
                }
                if (visual_target_audiences == 0)
                    builder008.Append(" ");

                // Form of item (008/23) (unknown or not specified)
                builder008.Append(" ");

                // Undefined (008/24-25)
                builder008.Append("  ");

                // Type of computer file (008/26)
                builder008.Append(" ");
                int computer_file_type = 0;
                add_value(genreHash.ContainsKey("numeric data"), 'c', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("computer program"), 'f', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("representational"), 'i', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("document"), 'l', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("bibliographic data"), 'm', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("font"), 'o', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("game"), 's', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("sound"), 'a', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("interactive multimedia"), 'm', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("online system or service"), 'o', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("combination"), 's', ref computer_file_type, 1, builder008);
                add_value(genreHash.ContainsKey("other computer file"), 'a', ref computer_file_type, 1, builder008);
                if (computer_file_type == 0)
                {
                    builder008.Append(" ");
                }

                // Undefined (008/27)
                builder008.Append(" ");

                // Is this a government publication? (008/28)
                int visual_govt_publication = 0;
                add_value(genreHash.ContainsKey("multilocal government publication"), 'c', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("federal government publication"), 'f', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("international intergovernmental publication"), 'i', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("local government publication"), 'l', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("multistate government publication"), 'm', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication"), 'o', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (state, provincial, terriorial, dependent)"), 's', ref visual_govt_publication, 1, builder008);
                add_value(genreHash.ContainsKey("government publication (autonomous or semiautonomous component)"), 'a', ref visual_govt_publication, 1, builder008);
                if (visual_govt_publication == 0)
                {
                    builder008.Append(" ");
                }

                // Undefined (008/29-34)
                builder008.Append("      ");
            }

            #endregion

            if (sobekcm_type == TypeOfResource_SobekCM_Enum.Archival)
            {
                // Treat as MIXED material
                builder008.Append("     s           ");
            }

            // For any other type, just use spaces
            if ((sobekcm_type != TypeOfResource_SobekCM_Enum.Book) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Map) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Newspaper) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Serial) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Aerial) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Photograph) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Audio) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Video) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Artifact) && (sobekcm_type != TypeOfResource_SobekCM_Enum.Archival) && ( sobekcm_type != TypeOfResource_SobekCM_Enum.Dataset ))
            {
                builder008.Append("     s           ");
            }

            // Add the language code
            string language_code = "eng";
            if (Bib_Info.Languages_Count > 0)
            {
                foreach (Language_Info thisLanguage in Bib_Info.Languages)
                {
                    if (thisLanguage.Language_ISO_Code.Length > 0)
                    {
                        language_code = thisLanguage.Language_ISO_Code;
                        break;
                    }
                }
            }
            builder008.Append(language_code);

            builder008.Append(" d");

            //if (this.Bib_Info.Record.MARC_Record_Content_Sources.Count > 0)
            //{
            //    builder008.Append("d");
            //}
            //else
            //{
            //    builder008.Append("|");
            //}

            fixedField008.Control_Field_Value = builder008.ToString();
            tags.Add_Field(fixedField008);

            // Add the system name also as a 830 (before the collections)
            if (!String.IsNullOrEmpty(SystemName))
            {
                tags.Add_Field(new MARC_Field(830, " 0", "|a " + SystemName + "."));
            }

            // Add the collection name as well ( Was getting duplicates here sometimes )
            if (Behaviors.Aggregations != null)
            {
                List<string> added_already = new List<string>();
                foreach (Aggregation_Info thisAggr in Behaviors.Aggregations)
                {
                    if (( String.Compare(thisAggr.Code,"ALL", true ) != 0 ) && (( String.IsNullOrEmpty(thisAggr.Type)) || (thisAggr.Type.IndexOf("INSTITUT", StringComparison.InvariantCultureIgnoreCase) < 0)))
                    {
                        string collection = thisAggr.Name;
                        if (String.IsNullOrEmpty(collection)) collection = thisAggr.Code;

                        if (!added_already.Contains(collection.ToUpper().Trim()))
                        {
                            if (collection.Trim().Length > 0)
                            {
                                added_already.Add(collection.ToUpper().Trim());
                                tags.Add_Field(new MARC_Field(830, " 0", "|a " + collection + "."));
                            }
                        }
                    }
                }
            }

            // Add the thumbnail link (992)
            if ((Behaviors.Main_Thumbnail.Length > 0) && (!Behaviors.Dark_Flag))
            {

                string thumbnail_link = Path.Combine(web.Source_URL, Behaviors.Main_Thumbnail);

                if (!String.IsNullOrEmpty(ThumbnailBase))
                {
                    thumbnail_link = Path.Combine(ThumbnailBase, thumbnail_link);
                }

                tags.Add_Field(new MARC_Field(992, "04", "|a " + thumbnail_link.Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://")));
            }

            // Was this born digital?  in which case this is NOT an electronic reproduction, so
            // leave out the 533 field
            bool borndigital = Bib_Info.Genres.Any(ThisGenre => (ThisGenre.Authority == "sobekcm") && (ThisGenre.Genre_Term == "born-digital"));
            if (!borndigital)
            {
                MARC_Field tag533 = new MARC_Field { Tag = 533, Indicators = "  " };
                StringBuilder builder533 = new StringBuilder(100);
                builder533.Append("|a Electronic reproduction. ");

                if ( !String.IsNullOrEmpty(ReproductionPlace))
                    builder533.Append("|b " + ReproductionPlace + " : ");

                List<string> agencies = new List<string>();
                if (!String.IsNullOrEmpty(ReproductionAgency))
                {
                    builder533.Append("|c " + ReproductionAgency + ", ");
                    agencies.Add(ReproductionAgency);
                }

                // Add the source statement as another agency possibly
                if (!String.IsNullOrEmpty(Bib_Info.Source.Statement))
                {
                    string source_statement = Bib_Info.Source.Statement;

                    // determine if this is a subset of any existing agency, or vice versa
                    bool found = false;
                    foreach (string thisAgency in agencies)
                    {
                        if ((source_statement.IndexOf(thisAgency, StringComparison.InvariantCultureIgnoreCase) >= 0) || (thisAgency.IndexOf(source_statement, StringComparison.InvariantCultureIgnoreCase) >= 0))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        builder533.Append("|c " + source_statement + ", ");
                        agencies.Add(source_statement);
                    }
                }

                // Add the source statement as another agency possibly
                if ((Bib_Info.hasLocationInformation) && (Bib_Info.Location.Holding_Code != Bib_Info.Source.Code) && (!String.IsNullOrEmpty(Bib_Info.Location.Holding_Name)))
                {
                    string holding_statement = Bib_Info.Location.Holding_Name;

                    // determine if this is a subset of any existing agency, or vice versa
                    bool found = false;
                    foreach (string thisAgency in agencies)
                    {
                        if ((holding_statement.IndexOf(thisAgency, StringComparison.InvariantCultureIgnoreCase) >= 0) || (thisAgency.IndexOf(holding_statement, StringComparison.InvariantCultureIgnoreCase) >= 0))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        builder533.Append("|c " + holding_statement + ", ");
                        agencies.Add(holding_statement);
                    }
                }

                builder533.Append("|d " + METS_Header.Create_Date.Year + ". ");
                if (!String.IsNullOrEmpty(SystemName))
                {
                    builder533.Append("|f (" + SystemName + ") ");
                }
                //foreach (string collection in Collection_Names)
                //{
                //    if (collection.Trim().Length > 0)
                //    {
                //        builder533.Append(" |f (" + collection + ")");
                //    }
                //}
                builder533.Append("|n Mode of access: World Wide Web.  |n System requirements: Internet connectivity; Web browser software.");
                tag533.Control_Field_Value = builder533.ToString();
                tags.Add_Field(tag533);
            }

            // Add the endeca only tags
            if (( !String.IsNullOrEmpty(SystemAbbreviation)) || ( !String.IsNullOrEmpty(LocationCode)))
            {
                // Add the 852
                MARC_Field tag852 = new MARC_Field { Tag = 852, Indicators = "  " };
                StringBuilder builder852 = new StringBuilder(100);

                if (!String.IsNullOrEmpty(LocationCode))
                {
                    builder852.Append("|a " + LocationCode + " ");
                    if (!String.IsNullOrEmpty(SystemAbbreviation))
                        builder852.Append("|b " + SystemAbbreviation);
                }
                else
                {
                    builder852.Append("|a " + SystemAbbreviation);
                }

                if ( !String.IsNullOrEmpty(first_aggr_name))
                    builder852.Append(" |c " + first_aggr_name);
                tag852.Control_Field_Value = builder852.ToString();
                tags.Add_Field(tag852);
            }

            // Add the collection name in the Endeca spot (997)
            if (!String.IsNullOrEmpty(first_aggr_name))
            {
                tags.Add_Field(new MARC_Field(997, "  ", "|a " + first_aggr_name));
            }

            // Now, set the leader
            tags.Leader = MARC_Leader();

            return tags;
        }
        /// <summary> Constructor for a new instance of the SobekCM_Item class, which imports values from a OAI record </summary>
        public SobekCM_Item(OAI_Repository_DublinCore_Record OAI_Record)
        {
            metsInfo = new METS_Header_Info();
            behaviorInfo = new Behaviors_Info();
            divInfo = new Division_Info();
            BIBInfo = new Bibliographic_Info();
            web = new Web_Info(behaviorInfo);
            analyzed_for_complex_content = false;
            contains_complex_content = false;
            using_complex_template = false;
            DiskSize_KB = 0;

            // Copy over all the data
            if (OAI_Record.hasCreators)
            {
                foreach (string thisCreator in OAI_Record.Creators)
                {
                    Bib_Info.Add_Named_Entity(thisCreator);
                }
            }
            if (OAI_Record.hasContributors)
            {
                foreach (string thisContributor in OAI_Record.Contributors)
                {
                    Bib_Info.Add_Named_Entity(thisContributor, "Contributor");
                }
            }
            if (OAI_Record.hasCoverages)
            {
                foreach (string thisCoverage in OAI_Record.Coverages)
                {
                    Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                    thisSubject.Add_Geographic(thisCoverage);
                    Bib_Info.Add_Subject(thisSubject);
                }
            }
            if (OAI_Record.hasDates)
            {
                foreach (string thisDate in OAI_Record.Dates)
                {
                    Bib_Info.Origin_Info.Date_Issued = thisDate;
                }
            }
            if (OAI_Record.hasDescriptions)
            {
                foreach (string thisDescription in OAI_Record.Descriptions)
                {
                    Bib_Info.Add_Note(thisDescription);
                }
            }
            if (OAI_Record.hasFormats)
            {
                foreach (string thisFormat in OAI_Record.Formats)
                {
                    Bib_Info.Original_Description.Extent = thisFormat;
                }
            }
            if (OAI_Record.hasIdentifiers)
            {
                foreach (string thisIdentifier in OAI_Record.Identifiers)
                {
                    if (thisIdentifier.IndexOf("http://") == 0)
                    {
                        Bib_Info.Location.Other_URL = thisIdentifier;
                    }
                    else
                    {
                        Bib_Info.Add_Identifier(thisIdentifier);
                    }
                }
            }
            if (OAI_Record.hasLanguages)
            {
                foreach (string thisLanguage in OAI_Record.Languages)
                {
                    Bib_Info.Add_Language(thisLanguage);
                }
            }
            if (OAI_Record.hasPublishers)
            {
                foreach (string thisPublisher in OAI_Record.Publishers)
                {
                    Bib_Info.Add_Publisher(thisPublisher);
                }
            }
            if (OAI_Record.hasRelations)
            {
                foreach (string thisRelation in OAI_Record.Relations)
                {
                    Related_Item_Info newRelatedItem = new Related_Item_Info();
                    newRelatedItem.Main_Title.Title = thisRelation;
                    Bib_Info.Add_Related_Item(newRelatedItem);
                }
            }
            if (OAI_Record.hasRights)
            {
                foreach (string thisRights in OAI_Record.Rights)
                {
                    Bib_Info.Access_Condition.Text = thisRights;
                }
            }
            //if (OAI_Record.hasSources)
            //{
            //    foreach (string thisSource in OAI_Record.Sources)
            //    {
            //        this.Bib_Info.Source.Statement = r.Value.Trim() = thisSource;
            //    }
            //}
            if (OAI_Record.hasSubjects)
            {
                foreach (string thisSubject in OAI_Record.Subjects)
                {
                    if (thisSubject.IndexOf(";") > 0)
                    {
                        string[] splitter = thisSubject.Split(";".ToCharArray());
                        foreach (string thisSplit in splitter)
                        {
                            Bib_Info.Add_Subject(thisSplit.Trim(), String.Empty);
                        }
                    }
                    else
                    {
                        Bib_Info.Add_Subject(thisSubject, String.Empty);
                    }
                }
            }
            if (OAI_Record.hasTitles)
            {
                foreach (string thistitle in OAI_Record.Titles)
                {
                    if (Bib_Info.Main_Title.ToString().Length > 0)
                    {
                        Bib_Info.Add_Other_Title(thistitle, Title_Type_Enum.Alternative);
                    }
                    else
                    {
                        Bib_Info.Main_Title.Clear();
                        Bib_Info.Main_Title.Title = thistitle;
                    }
                }
            }
            if (OAI_Record.hasTypes)
            {
                foreach (string thisType in OAI_Record.Types)
                {
                    Bib_Info.SobekCM_Type_String = thisType;
                }
            }

            // If there is a metadata configuration which calls for a metadata
            // extension module to always be used, add it now
            if (Metadata_Configuration.Metadata_Modules_To_Include.Count > 0)
            {
                foreach (Additional_Metadata_Module_Config thisConfig in Metadata_Configuration.Metadata_Modules_To_Include)
                {
                    iMetadata_Module toInclude = thisConfig.Get_Module();
                    if (toInclude != null)
                    {
                        Add_Metadata_Module(thisConfig.Key, toInclude);
                    }
                }
            }
        }
        private static void read_subject_object(XmlReader r, Bibliographic_Info thisBibInfo)
        {
            string language = String.Empty;
            string authority = String.Empty;
            string id = String.Empty;

            if (r.MoveToAttribute("ID"))
                id = r.Value;
            if (r.MoveToAttribute("lang"))
                language = r.Value;
            if (r.MoveToAttribute("authority"))
                authority = r.Value;

            // Move to the next element
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                    break;
            }

            // Determine the subject type
            Subject_Info_Type type = Subject_Info_Type.UNKNOWN;

            // What is the name of this node?
            switch (r.Name)
            {
                case "mods:topic":
                case "mods:geographic":
                case "mods:genre":
                case "mods:temporal":
                case "mods:occupation":
                case "topic":
                case "geographic":
                case "genre":
                case "temporal":
                case "occupation":
                    type = Subject_Info_Type.Standard;
                    break;

                case "mods:hierarchicalGeographic":
                case "hierarchicalGeographic":
                    type = Subject_Info_Type.Hierarchical_Spatial;
                    break;

                case "mods:cartographics":
                case "cartographics":
                    type = Subject_Info_Type.Cartographics;
                    break;

                case "mods:name":
                case "name":
                    type = Subject_Info_Type.Name;
                    break;

                case "mods:titleInfo":
                case "titleInfo":
                    type = Subject_Info_Type.TitleInfo;
                    break;
            }

            // If no type was determined, return null
            if (type == Subject_Info_Type.UNKNOWN)
                return;

            // Was this the standard subject object?
            if (type == Subject_Info_Type.Standard)
            {
                Subject_Info_Standard standardSubject = new Subject_Info_Standard();
                standardSubject.Language = language;
                standardSubject.Authority = authority;
                standardSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        if ((standardSubject.Topics_Count > 0) || (standardSubject.Geographics_Count > 0) || (standardSubject.Genres_Count > 0) ||
                            (standardSubject.Temporals_Count > 0) || (standardSubject.Occupations_Count > 0))
                        {
                            thisBibInfo.Add_Subject(standardSubject);
                        }
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Temporal(r.Value);
                                break;

                            case "mods:occupation":
                            case "occupation":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    standardSubject.Add_Occupation(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }

            // Was this the hierarchical geography subject?
            if (type == Subject_Info_Type.Hierarchical_Spatial)
            {
                Subject_Info_HierarchicalGeographic geoSubject = new Subject_Info_HierarchicalGeographic();
                geoSubject.Language = language;
                geoSubject.Authority = authority;
                geoSubject.ID = id;

                while (r.Read())
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(geoSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:continent":
                            case "continent":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Continent = r.Value;
                                break;

                            case "mods:country":
                            case "country":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Country = r.Value;
                                break;

                            case "mods:province":
                            case "province":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Province = r.Value;
                                break;

                            case "mods:region":
                            case "region":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Region = r.Value;
                                break;

                            case "mods:state":
                            case "state":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.State = r.Value;
                                break;

                            case "mods:territory":
                            case "territory":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Territory = r.Value;
                                break;

                            case "mods:county":
                            case "county":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.County = r.Value;
                                break;

                            case "mods:city":
                            case "city":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.City = r.Value;
                                break;

                            case "mods:citySection":
                            case "citySection":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.CitySection = r.Value;
                                break;

                            case "mods:island":
                            case "island":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Island = r.Value;
                                break;

                            case "mods:area":
                            case "area":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    geoSubject.Area = r.Value;
                                break;
                        }
                    }
                }
            }

            // Was this the cartographics subject?
            if (type == Subject_Info_Type.Cartographics)
            {
                Subject_Info_Cartographics mapSubject = new Subject_Info_Cartographics();
                mapSubject.Language = language;
                mapSubject.Authority = authority;
                mapSubject.ID = id;

                while (r.Read())
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        if ((mapSubject.Projection.Length > 0) || (mapSubject.Coordinates.Length > 0) || (mapSubject.Scale.Length > 0))
                        {
                            thisBibInfo.Add_Subject(mapSubject);
                        }
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:coordinates":
                            case "coordinates":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Coordinates = r.Value;
                                break;

                            case "mods:scale":
                            case "scale":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Scale = r.Value;
                                break;

                            case "mods:projection":
                            case "projection":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    mapSubject.Projection = r.Value;
                                break;
                        }
                    }
                }
            }

            // Was this the name subject?
            if (type == Subject_Info_Type.Name)
            {
                Subject_Info_Name nameSubject = new Subject_Info_Name();
                nameSubject.Language = language;
                nameSubject.Authority = authority;
                nameSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(nameSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:name":
                            case "name":
                                Name_Info nameInfo = read_name_object(r);
                                nameSubject.Set_Internal_Name(nameInfo);
                                break;

                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    nameSubject.Add_Temporal(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }

            // Was this the title subject?
            if (type == Subject_Info_Type.TitleInfo)
            {
                Subject_Info_TitleInfo titleSubject = new Subject_Info_TitleInfo();
                titleSubject.Language = language;
                titleSubject.Authority = authority;
                titleSubject.ID = id;

                do
                {
                    if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "mods:subject") || (r.Name == "subject")))
                    {
                        thisBibInfo.Add_Subject(titleSubject);
                        return;
                    }

                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "mods:titleInfo":
                            case "titleInfo":
                                Title_Info titleInfo = read_title_object(r);
                                titleSubject.Set_Internal_Title(titleInfo);
                                break;

                            case "mods:topic":
                            case "topic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Topic(r.Value);
                                break;

                            case "mods:geographic":
                            case "geographic":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Geographic(r.Value);
                                break;

                            case "mods:genre":
                            case "genre":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Genre(r.Value);
                                break;

                            case "mods:temporal":
                            case "temporal":
                                r.Read();
                                if (r.NodeType == XmlNodeType.Text)
                                    titleSubject.Add_Temporal(r.Value);
                                break;
                        }
                    }
                } while (r.Read());
            }
        }
        private static void Add_Subject(Bibliographic_Info thisBibInfo, MARC_Record record, int tag, string topical_codes, string geographic_codes, string temporal_codes, string genre_codes, string occupation_codes)
        {
            // Step through all of the subjects under this tag
            int subj_index = 1;
            string source;
            foreach (MARC_Field thisRecord in record[tag])
            {
                // Only continue if there is an id in this record
                if (thisRecord.has_Subfield('a'))
                {
                    // Was there  a source?
                    source = String.Empty;
                    if (thisRecord.has_Subfield('2'))
                    {
                        source = thisRecord['2'];
                    }
                    else if ((tag != 653))
                    {
                        switch (thisRecord.Indicator2)
                        {
                            case '0':
                                source = "lcsh";
                                break;

                            case '1':
                                source = "lcshac";
                                break;

                            case '2':
                                source = "mesh";
                                break;

                            case '3':
                                source = "nal";
                                break;

                            case '5':
                                source = "csh";
                                break;

                            case '6':
                                source = "rvm";
                                break;

                            case '9':
                                source = "local";
                                break;
                        }
                    }

                    Subject_Info_Standard obj = new Subject_Info_Standard();
                    obj.Authority = source;
                    obj.ID = "SUBJ" + tag + "_" + subj_index;
                    subj_index++;

                    // Add the topics
                    foreach (char thisTopicChar in topical_codes)
                    {
                        if (thisRecord.has_Subfield(thisTopicChar))
                        {
                            string topicString = thisRecord[thisTopicChar];
                            if (topicString.IndexOf("|") > 0)
                            {
                                string[] topicStringSplit = topicString.Split("|".ToCharArray());
                                foreach (string thisTopicString in topicStringSplit)
                                    obj.Add_Topic(Remove_Trailing_Punctuation(thisTopicString));
                            }
                            else
                            {
                                obj.Add_Topic(Remove_Trailing_Punctuation(topicString));
                            }
                        }
                    }

                    // Add the temporals
                    foreach (char thisTempChar in temporal_codes)
                    {
                        if (thisRecord.has_Subfield(thisTempChar))
                        {
                            string tempString = thisRecord[thisTempChar];
                            if (tempString.IndexOf("|") > 0)
                            {
                                string[] tempStringSplit = tempString.Split("|".ToCharArray());
                                foreach (string thisTempString in tempStringSplit)
                                    obj.Add_Temporal(Remove_Trailing_Punctuation(thisTempString));
                            }
                            else
                            {
                                obj.Add_Temporal(Remove_Trailing_Punctuation(tempString));
                            }
                        }
                    }

                    // Add the geographics
                    foreach (char thisGeoChar in geographic_codes)
                    {
                        if (thisRecord.has_Subfield(thisGeoChar))
                        {
                            string geoString = thisRecord[thisGeoChar];
                            if (geoString.IndexOf("|") > 0)
                            {
                                string[] geoStringSplit = geoString.Split("|".ToCharArray());
                                foreach (string thisGeoString in geoStringSplit)
                                    obj.Add_Geographic(Remove_Trailing_Punctuation(thisGeoString));
                            }
                            else
                            {
                                obj.Add_Geographic(Remove_Trailing_Punctuation(geoString));
                            }
                        }
                    }

                    // Add the genres
                    foreach (char thisGenreChar in genre_codes)
                    {
                        if (thisRecord.has_Subfield(thisGenreChar))
                        {
                            string genreString = thisRecord[thisGenreChar];
                            if (genreString.IndexOf("|") > 0)
                            {
                                string[] genreStringSplit = genreString.Split("|".ToCharArray());
                                foreach (string thisGenreString in genreStringSplit)
                                    obj.Add_Genre(Remove_Trailing_Punctuation(thisGenreString));
                            }
                            else
                            {
                                obj.Add_Genre(Remove_Trailing_Punctuation(genreString));
                            }
                        }
                    }

                    // Add the occupations
                    foreach (char thisOccChar in occupation_codes)
                    {
                        if (thisRecord.has_Subfield(thisOccChar))
                        {
                            string occString = thisRecord[thisOccChar].Replace("--", "|");
                            if (occString.IndexOf("|") > 0)
                            {
                                string[] occStringSplit = occString.Split("|".ToCharArray());
                                foreach (string thisOccString in occStringSplit)
                                    obj.Add_Occupation(Remove_Trailing_Punctuation(thisOccString.Trim()));
                            }
                            else
                            {
                                obj.Add_Occupation(Remove_Trailing_Punctuation(occString));
                            }
                        }
                    }

                    // Add this subject
                    thisBibInfo.Add_Subject(obj);
                }
            }
        }
        /// <summary> Add a new subject keyword and return it  </summary>
        /// <param name="Topic">Topical subject</param>
        /// <param name="Authority">Authority for this topic subject keyword</param>
        /// <returns>Newly built subject</returns>
        public Subject_Info_Standard Add_Subject(string Topic, string Authority)
        {
            if (subjects == null)
                subjects = new List<Subject_Info>();

            if (Topic.Trim().Length > 0)
            {
                Subject_Info_Standard returnValue = new Subject_Info_Standard(Topic, Authority);
                subjects.Add(returnValue);
                return returnValue;
            }
            else
            {
                return null;
            }
        }
        /// <summary> Saves the data rendered by this element to the provided bibliographic object during postback </summary>
        /// <param name="Bib"> Object into which to save the user's data, entered into the html rendered by this element </param>
        public override void Save_To_Bib(SobekCM_Item Bib)
        {
            string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
            foreach (string thisKey in getKeys)
            {
                if (thisKey.IndexOf("formsubjecttype_") == 0)
                {
                    string diff = thisKey.Replace("formsubjecttype_","");
                    string topic1 = HttpContext.Current.Request.Form["formsubjecttopic1_" + diff].Trim();
                    string topic2 = HttpContext.Current.Request.Form["formsubjecttopic2_" + diff].Trim();
                    string topic3 = HttpContext.Current.Request.Form["formsubjecttopic3_" + diff].Trim();
                    string topic4 = HttpContext.Current.Request.Form["formsubjecttopic4_" + diff].Trim();
                    string temporal1 = HttpContext.Current.Request.Form["formsubjecttemporal1_" + diff].Trim();
                    string temporal2 = HttpContext.Current.Request.Form["formsubjecttemporal2_" + diff].Trim();
                    string geographic1 = HttpContext.Current.Request.Form["formsubjectgeo1_" + diff].Trim();
                    string geographic2 = HttpContext.Current.Request.Form["formsubjectgeo2_" + diff].Trim();
                    string genre1 = HttpContext.Current.Request.Form["formsubjectgenre1_" + diff].Trim();
                    string genre2 = HttpContext.Current.Request.Form["formsubjectgenre2_" + diff].Trim();
                    string occcupation = HttpContext.Current.Request.Form["formsubjectoccup1_" + diff].Trim();
                    string authority = HttpContext.Current.Request.Form["formsubjectauthority_" + diff].Trim();
                    string language = HttpContext.Current.Request.Form["formsubjectlanguage_" + diff].Trim();
                    string marc = HttpContext.Current.Request.Form["formsubjectmap_" + diff].Trim();

                    if ((topic1.Length > 0) || (topic2.Length > 0) || (topic3.Length > 0) || (topic4.Length > 0) ||
                        (temporal1.Length > 0) || (temporal2.Length > 0) || (geographic1.Length > 0) || (geographic2.Length > 0) ||
                        (genre1.Length > 0) || (genre2.Length > 0) || (occcupation.Length > 0))
                    {
                        Subject_Info_Standard newSubject = new Subject_Info_Standard();
                        if (topic1.Length > 0) newSubject.Add_Topic(topic1);
                        if (topic2.Length > 0) newSubject.Add_Topic(topic2);
                        if (topic3.Length > 0) newSubject.Add_Topic(topic3);
                        if (topic4.Length > 0) newSubject.Add_Topic(topic4);
                        if (temporal1.Length > 0) newSubject.Add_Temporal(temporal1);
                        if (temporal2.Length > 0) newSubject.Add_Temporal(temporal2);
                        if (geographic1.Length > 0) newSubject.Add_Geographic(geographic1);
                        if (geographic2.Length > 0) newSubject.Add_Geographic(geographic2);
                        if (genre1.Length > 0) newSubject.Add_Genre(genre1);
                        if (genre2.Length > 0) newSubject.Add_Genre(genre2);
                        if (occcupation.Length > 0) newSubject.Add_Occupation(occcupation);
                        newSubject.Authority = authority;
                        newSubject.Language = language;
                        if ((marc.Length > 0) && (marc != "none"))
                        {
                            newSubject.ID = "SUBJ" + marc + "_" + diff;
                        }
                        Bib.Bib_Info.Add_Subject(newSubject);

                    }
                }
            }
        }
        /// <summary> Add a new empty subject and return it  </summary>
        /// <returns>Newly built subject</returns>
        public Subject_Info_Standard Add_Subject()
        {
            if (subjects == null)
                subjects = new List<Subject_Info>();

            Subject_Info_Standard returnValue = new Subject_Info_Standard();
            subjects.Add(returnValue);
            return returnValue;
        }
        /// <summary> Adds a bit of data to a bibliographic package using the mapping </summary>
        /// <param name="Package">Bibliographic package to receive the data</param>
        /// <param name="Data">Text of the data</param>
        /// <param name="Field">Mapped field</param>
        public static void Add_Data(SobekCM_Item Package, string Data, Mapped_Fields Field)
        {
            Data = Data.Trim();
            if (Data.Length == 0)
                return;

            // Everything depends on the field which is mapped
            switch (Field)
            {
                case Mapped_Fields.None:
                    // Do nothing, since no mapping exists
                    break;

                case Mapped_Fields.Abstract:
                    Package.Bib_Info.Add_Abstract(Data, "en");
                    break;
                case Mapped_Fields.Accession_Number:
                    Package.Bib_Info.Add_Identifier(Data, "Accession Number");
                    break;
                case Mapped_Fields.Alternate_Title:
                    Package.Bib_Info.Add_Other_Title(Data, Title_Type_Enum.alternative);
                    break;
                case Mapped_Fields.Attribution:
                    Package.Bib_Info.Add_Note(Data, Note_Type_Enum.funding);
                    break;
                case Mapped_Fields.Aggregation_Code:
                    Package.Behaviors.Add_Aggregation(Data.ToUpper());
                    break;
                case Mapped_Fields.Contributor:
                    Package.Bib_Info.Add_Named_Entity(new Name_Info(Data, "contributor"));
                    break;
                case Mapped_Fields.Creator:
                    Package.Bib_Info.Add_Named_Entity(new Name_Info(Data, "creator"));
                    break;
                case Mapped_Fields.Creator_Affiliation:
                    if (Package.Bib_Info.Names_Count > 0)
                    {
                        Package.Bib_Info.Names[0].Affiliation = Data;
                    }
                    break;
                case Mapped_Fields.Cultural_Context:
                    VRACore_Info vraCoreInfo = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo == null)
                    {
                        vraCoreInfo = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo);
                    }
                    vraCoreInfo.Add_Cultural_Context(Data);
                    break;
                case Mapped_Fields.Donor:
                    Package.Bib_Info.Donor.Full_Name = Data;
                    break;
                case Mapped_Fields.Genre:
                    Subject_Info_Standard genre = new Subject_Info_Standard();
                    genre.Add_Genre(Data);
                    Package.Bib_Info.Add_Subject(genre);
                    break;
                case Mapped_Fields.Holding_Code:
                    Package.Bib_Info.Location.Holding_Code = Data;
                    break;
                case Mapped_Fields.Holding_Statement:
                    Package.Bib_Info.Location.Holding_Name = Data;
                    break;
                case Mapped_Fields.Identifier:
                    Package.Bib_Info.Add_Identifier(Data);
                    break;
                case Mapped_Fields.Inscription:
                    VRACore_Info vraCoreInfo8 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo8 == null)
                    {
                        vraCoreInfo8 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo8);
                    }
                    vraCoreInfo8.Add_Inscription(Data);
                    break;
                case Mapped_Fields.Language:
                    Package.Bib_Info.Add_Language(Data);
                    break;
                case Mapped_Fields.Publisher:
                    Package.Bib_Info.Add_Publisher(Data);
                    break;
                case Mapped_Fields.Pub_Place:
                    Package.Bib_Info.Origin_Info.Add_Place(Data);
                    break;
                case Mapped_Fields.Source_Code:
                    Package.Bib_Info.Source.Code = Data;
                    break;
                case Mapped_Fields.Source_Statement:
                    Package.Bib_Info.Source.Statement = Data;
                    break;
                case Mapped_Fields.Subject_Keyword:
                    Package.Bib_Info.Add_Subject(Data, String.Empty);
                    break;
                case Mapped_Fields.BibID:
                    Package.Bib_Info.BibID = Data.ToUpper();
                    break;
                case Mapped_Fields.VID:
                    Package.Bib_Info.VID = Data.PadLeft(5, '0');
                    break;
                case Mapped_Fields.Date:
                    try
                    {
                        // first, try converting the string value to a date object
                        Package.Bib_Info.Origin_Info.Date_Issued = Convert.ToDateTime(Data).ToShortDateString();
                    }
                    catch
                    {
                        try
                        {
                            // second, try converting the string value to an integer
                            Package.Bib_Info.Origin_Info.Date_Issued = Convert.ToInt32(Data).ToString();
                        }
                        catch
                        {
                            Package.Bib_Info.Origin_Info.Date_Issued = Data;
                        }
                    }
                    break;
                case Mapped_Fields.Edition:
                    Package.Bib_Info.Origin_Info.Edition = Data;
                    break;
                case Mapped_Fields.Format:
                    Package.Bib_Info.Original_Description.Extent = Data;
                    break;
                case Mapped_Fields.Note:
                    Package.Bib_Info.Add_Note(Data);
                    break;
                case Mapped_Fields.Rights:
                    Package.Bib_Info.Access_Condition.Text = Data;
                    break;
                case Mapped_Fields.Series_Title:
                    Package.Bib_Info.SeriesTitle.Title = Data;
                    Package.Behaviors.GroupTitle = Data;
                    break;
                case Mapped_Fields.Type:
                    string upper_data = Data.ToUpper();
                    if (upper_data.IndexOf("NEWSPAPER") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Newspaper;
                        break;
                    }
                    if ((upper_data.IndexOf("MONOGRAPH") >= 0) || (upper_data.IndexOf("BOOK") >= 0))
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Book;
                        break;
                    }
                    if (upper_data.IndexOf("SERIAL") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Serial;
                        break;
                    }
                    if (upper_data.IndexOf("AERIAL") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Aerial;
                        if (Package.Bib_Info.Original_Description.Extent.Length == 0)
                            Package.Bib_Info.Original_Description.Extent = "Aerial Photograph";
                        break;
                    }
                    if (upper_data.IndexOf("PHOTO") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Photograph;
                        break;
                    }
                    if (upper_data.IndexOf("POSTCARD") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Photograph;
                        if (Package.Bib_Info.Original_Description.Extent.Length == 0)
                            Package.Bib_Info.Original_Description.Extent = "Postcard";
                        break;
                    }
                    if (upper_data.IndexOf("MAP") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Map;
                        break;
                    }
                    if (upper_data.IndexOf("TEXT") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Book;
                        break;
                    }
                    if (upper_data.IndexOf("AUDIO") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Audio;
                        break;
                    }
                    if (upper_data.IndexOf("VIDEO") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Video;
                        break;
                    }
                    if ((upper_data.IndexOf("ARCHIVE") >= 0) || (upper_data.IndexOf("ARCHIVAL") >= 0))
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Archival;
                        break;
                    }
                    if (upper_data.IndexOf("ARTIFACT") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Artifact;
                        break;
                    }
                    if (upper_data.IndexOf("IMAGE") >= 0)
                    {
                        Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Photograph;
                        break;
                    }

                    // if there was no match, set type to "UNDETERMINED"
                    Package.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.UNKNOWN;

                    if (Package.Bib_Info.Original_Description.Extent.Length == 0)
                        Package.Bib_Info.Original_Description.Extent = "Undetermined";
                    break;
                case Mapped_Fields.Uniform_Title:
                    Package.Bib_Info.Add_Other_Title(Data, Title_Type_Enum.uniform);
                    Package.Behaviors.GroupTitle = Data;
                    break;
                case Mapped_Fields.Title:
                    Package.Bib_Info.Main_Title.Title = Data;
                    break;
                case Mapped_Fields.Aleph:
                    Package.Bib_Info.Add_Identifier(Data, "ALEPH");
                    break;
                case Mapped_Fields.OCLC:
                    Package.Bib_Info.Add_Identifier(Data, "OCLC");
                    break;
                case Mapped_Fields.LCCN:
                    Package.Bib_Info.Add_Identifier(Data, "LCCN");
                    break;
                case Mapped_Fields.ISBN:
                    Package.Bib_Info.Add_Identifier(Data, "ISBN");
                    break;
                case Mapped_Fields.ISSN:
                    Package.Bib_Info.Add_Identifier(Data, "ISSN");
                    break;
                case Mapped_Fields.Sub_Title:
                    Package.Bib_Info.Main_Title.Subtitle = Data;
                    break;
                case Mapped_Fields.Volume:
                    Package.Bib_Info.Series_Part_Info.Enum1 = Data;
                    Package.Behaviors.Serial_Info.Add_Hierarchy(Package.Behaviors.Serial_Info.Count + 1, 1, Data);
                    break;
                case Mapped_Fields.Issue:
                    if (Package.Bib_Info.Series_Part_Info.Enum1.Length == 0)
                    {
                        Package.Bib_Info.Series_Part_Info.Enum1 = Data;
                    }
                    else
                    {
                        Package.Bib_Info.Series_Part_Info.Enum2 = Data;
                    }
                    Package.Behaviors.Serial_Info.Add_Hierarchy(Package.Behaviors.Serial_Info.Count + 1, 1, Data);
                    break;
                case Mapped_Fields.Section:
                    if (Package.Bib_Info.Series_Part_Info.Enum2.Length == 0)
                    {
                        if (Package.Bib_Info.Series_Part_Info.Enum1.Length == 0)
                            Package.Bib_Info.Series_Part_Info.Enum1 = Data;
                        else
                            Package.Bib_Info.Series_Part_Info.Enum2 = Data;
                    }
                    else
                    {
                        Package.Bib_Info.Series_Part_Info.Enum3 = Data;
                    }
                    Package.Behaviors.Serial_Info.Add_Hierarchy(Package.Behaviors.Serial_Info.Count + 1, 1, Data);
                    // Do nothing for now
                    break;

                case Mapped_Fields.Year:
                    Package.Bib_Info.Series_Part_Info.Year = Data;

                    if (Data.Length == 1)
                        year = "0" + Data;
                    else
                        year = Data;
                    build_date_string(Package);

                    break;

                case Mapped_Fields.Month:
                    Package.Bib_Info.Series_Part_Info.Month = Data;
                    month = Data;
                    build_date_string(Package);

                    break;

                case Mapped_Fields.Day:
                    Package.Bib_Info.Series_Part_Info.Day = Data;
                    day = Data;
                    build_date_string(Package);

                    break;

                case Mapped_Fields.Coordinates:
                    GeoSpatial_Information geoInfo = Package.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                    if (geoInfo == null)
                    {
                        geoInfo = new GeoSpatial_Information();
                        Package.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoInfo);
                    }
                    string[] coordinates = Data.Split(", ;".ToCharArray());
                    try
                    {
                        if (coordinates.Length == 2)
                        {
                            geoInfo.Add_Point(Convert.ToDouble(coordinates[0]), Convert.ToDouble(coordinates[1]), String.Empty);
                        }
                        else
                        {
                            coordinates = Data.Split(",;".ToCharArray());
                            if (coordinates.Length == 2)
                            {
                                geoInfo.Add_Point(Convert.ToDouble(coordinates[0]), Convert.ToDouble(coordinates[1]), String.Empty);
                            }
                        }
                    }
                    catch
                    {
                    }
                    break;

                case Mapped_Fields.Latitude:
                    GeoSpatial_Information geoInfo2 = Package.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                    if (geoInfo2 == null)
                    {
                        geoInfo2 = new GeoSpatial_Information();
                        Package.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoInfo2);
                    }
                    try
                    {
                        if (geoInfo2.Point_Count == 0)
                            geoInfo2.Add_Point(Convert.ToDouble(Data), 0, String.Empty);
                        else
                            geoInfo2.Points[0].Latitude = Convert.ToDouble(Data);
                    }
                    catch
                    {
                    }
                    break;

                case Mapped_Fields.Longitude:
                    GeoSpatial_Information geoInfo3 = Package.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                    if (geoInfo3 == null)
                    {
                        geoInfo3 = new GeoSpatial_Information();
                        Package.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, geoInfo3);
                    }
                    try
                    {
                        if (geoInfo3.Point_Count == 0)
                            geoInfo3.Add_Point(0, Convert.ToDouble(Data.Replace("°", "")), String.Empty);
                        else
                            geoInfo3.Points[0].Longitude = Convert.ToDouble(Data.Replace("°", ""));
                    }
                    catch
                    {
                    }
                    break;

                case Mapped_Fields.Projection:
                    Guarantee_Cartographics(Package).Projection = Data;
                    break;
                case Mapped_Fields.Scale:
                    Guarantee_Cartographics(Package).Scale = Data;
                    break;
                    //case Mapped_Fields.Spatial_Coverage:
                    //    Package.Bib_Info.Hierarchical_Spatials[0].Area = Data;
                    //    break;
                case Mapped_Fields.Icon_Wordmarks:
                case Mapped_Fields.Wordmark:
                    //    Package.Processing_Parameters.Icons.Add(Data, String.Empty);
                    Package.Behaviors.Add_Wordmark(Data);
                    break;
                case Mapped_Fields.Temporal_Coverage:
                    Package.Bib_Info.Add_Temporal_Subject(-1, -1, Data);
                    break;
                case Mapped_Fields.Affiliation_University:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].University = Data;
                    break;
                case Mapped_Fields.Affiliation_Campus:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Campus = Data;
                    break;
                case Mapped_Fields.Affiliation_College:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].College = Data;
                    break;
                case Mapped_Fields.Affiliation_Unit:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Unit = Data;
                    break;
                case Mapped_Fields.Affiliation_Department:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Department = Data;
                    break;
                case Mapped_Fields.Affiliation_Institute:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Institute = Data;
                    break;
                case Mapped_Fields.Affiliation_Center:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Center = Data;
                    break;
                case Mapped_Fields.Affiliation_Section:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].Section = Data;
                    break;
                case Mapped_Fields.Affiliation_Subsection:
                    Guarantee_Affiliation_Collection(Package);
                    Package.Bib_Info.Affiliations[0].SubSection = Data;
                    break;
                case Mapped_Fields.Geography_Continent:
                    Guarantee_Hierarchical_Spatial(Package).Continent = Data;
                    break;
                case Mapped_Fields.Geography_Country:
                    Guarantee_Hierarchical_Spatial(Package).Country = Data;
                    break;
                case Mapped_Fields.Geography_Province:
                    Guarantee_Hierarchical_Spatial(Package).Province = Data;
                    break;
                case Mapped_Fields.Geography_Region:
                    Guarantee_Hierarchical_Spatial(Package).Region = Data;
                    break;
                case Mapped_Fields.Geography_State:
                    Guarantee_Hierarchical_Spatial(Package).State = Data;
                    break;
                case Mapped_Fields.Geography_Territory:
                    Guarantee_Hierarchical_Spatial(Package).Territory = Data;
                    break;
                case Mapped_Fields.Geography_County:
                    Guarantee_Hierarchical_Spatial(Package).County = Data;
                    break;
                case Mapped_Fields.Geography_City:
                    Guarantee_Hierarchical_Spatial(Package).City = Data;
                    break;
                case Mapped_Fields.Geography_Island:
                    Guarantee_Hierarchical_Spatial(Package).Island = Data;
                    break;
                case Mapped_Fields.Geography_Area:
                    Guarantee_Hierarchical_Spatial(Package).Area = Data;
                    break;
                case Mapped_Fields.Copyright_Date:
                    Package.Bib_Info.Origin_Info.Date_Copyrighted = Data;
                    break;
                case Mapped_Fields.EAD_Name:
                    Package.Bib_Info.Location.EAD_Name = Data;
                    break;
                case Mapped_Fields.EAD_URL:
                    Package.Bib_Info.Location.EAD_URL = Data;
                    break;
                case Mapped_Fields.Internal_Comments:
                    Package.Tracking.Internal_Comments = Data;
                    break;
                case Mapped_Fields.Container_Box:
                    Package.Bib_Info.Add_Container("Box", Data, 1);
                    break;
                case Mapped_Fields.Container_Divider:
                    Package.Bib_Info.Add_Container("Divider", Data, 2);
                    break;
                case Mapped_Fields.Container_Folder:
                    Package.Bib_Info.Add_Container("Folder", Data, 3);
                    break;
                case Mapped_Fields.Visibility:
                    switch (Data.ToUpper())
                    {
                        case "DARK":
                            Package.Behaviors.Dark_Flag = true;
                            Package.Behaviors.IP_Restriction_Membership = -1;
                            break;

                        case "PRIVATE":
                            Package.Behaviors.Dark_Flag = false;
                            Package.Behaviors.IP_Restriction_Membership = -1;
                            break;

                        case "PUBLIC":
                            Package.Behaviors.Dark_Flag = false;
                            Package.Behaviors.IP_Restriction_Membership = 0;
                            break;

                        case "RESTRICTED":
                            Package.Behaviors.Dark_Flag = false;
                            Package.Behaviors.IP_Restriction_Membership = 1;
                            break;
                    }
                    break;

                case Mapped_Fields.Tickler:
                    Package.Behaviors.Add_Tickler(Data);
                    break;

                case Mapped_Fields.Tracking_Box:
                    Package.Tracking.Tracking_Box = Data;
                    break;

                case Mapped_Fields.Born_Digital_Flag:
                    if (Data.ToUpper().Trim() == "TRUE")
                        Package.Tracking.Born_Digital = true;
                    break;

                case Mapped_Fields.Material_Received_Date:
                    try
                    {
                        DateTime materialReceivedDate = Convert.ToDateTime(Data);
                    }
                    catch
                    {
                    }
                    break;

                case Mapped_Fields.Materials:
                    VRACore_Info vraCoreInfo2 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo2 == null)
                    {
                        vraCoreInfo2 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo2);
                    }
                    vraCoreInfo2.Add_Material(Data, "medium");
                    break;

                case Mapped_Fields.Measurements:
                    VRACore_Info vraCoreInfo3 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo3 == null)
                    {
                        vraCoreInfo3 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo3);
                    }
                    vraCoreInfo3.Add_Measurement(Data, String.Empty);
                    break;

                case Mapped_Fields.State_Edition:
                    VRACore_Info vraCoreInfo4 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo4 == null)
                    {
                        vraCoreInfo4 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo4);
                    }
                    vraCoreInfo4.Add_State_Edition(Data);
                    break;

                case Mapped_Fields.Style_Period:
                    VRACore_Info vraCoreInfo5 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo5 == null)
                    {
                        vraCoreInfo5 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo5);
                    }
                    vraCoreInfo5.Add_Style_Period(Data);
                    break;

                case Mapped_Fields.Technique:
                    VRACore_Info vraCoreInfo6 = Package.Get_Metadata_Module("VRACore") as VRACore_Info;
                    if (vraCoreInfo6 == null)
                    {
                        vraCoreInfo6 = new VRACore_Info();
                        Package.Add_Metadata_Module("VRACore", vraCoreInfo6);
                    }
                    vraCoreInfo6.Add_Technique(Data);
                    break;
            }
        }
        /// <summary> Reads the Dublin Core-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="R"> XmlTextReader from which to read the dublin core data </param>
        /// <param name="BibInfo"> Digital resource object to save the data to </param>
        /// <param name="Return_Package"> The return package, if this is reading a top-level section of dublin core </param>
        public static void Read_Simple_Dublin_Core_Info(XmlReader R, Bibliographic_Info BibInfo, SobekCM_Item Return_Package )
        {
            while (R.Read())
            {
                if ((R.NodeType == XmlNodeType.EndElement) && ((R.Name == "METS:mdWrap") || (R.Name == "mdWrap")))
                    return;

                if (R.NodeType == XmlNodeType.Element)
                {
                    switch (R.Name)
                    {
                        case "dc:contributor":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Named_Entity(R.Value.Trim(), "Contributor");
                            }
                            break;

                        case "dc:coverage":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                                thisSubject.Add_Geographic(R.Value.Trim());
                                BibInfo.Add_Subject(thisSubject);
                            }
                            break;

                        case "dc:creator":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (BibInfo.Main_Entity_Name.hasData)
                                {
                                    BibInfo.Add_Named_Entity(R.Value.Trim());
                                }
                                else
                                {
                                    BibInfo.Main_Entity_Name.Full_Name = R.Value.Trim();
                                }
                            }
                            break;

                        case "dc:date":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Origin_Info.Date_Issued = R.Value.Trim();
                            }
                            break;

                        case "dc:description":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Note(R.Value.Trim());
                            }
                            break;

                        case "dc:format":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Original_Description.Extent = R.Value.Trim();
                            }
                            break;

                        case "dc:identifier":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Identifier(R.Value.Trim());
                            }
                            break;

                        case "dc:language":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Language(R.Value.Trim());
                            }
                            break;

                        case "dc:publisher":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Publisher(R.Value.Trim());
                            }
                            break;

                        case "dc:relation":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                Related_Item_Info newRelatedItem = new Related_Item_Info();
                                newRelatedItem.Main_Title.Title = R.Value.Trim();
                                BibInfo.Add_Related_Item(newRelatedItem);
                            }
                            break;

                        case "dc:rights":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Access_Condition.Text = R.Value.Trim();
                            }
                            break;

                        case "dc:source":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Add_Note(R.Value, Note_Type_Enum.source);
                            }
                            break;

                        case "dc:subject":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (R.Value.IndexOf(";") > 0)
                                {
                                    string[] splitter = R.Value.Split(";".ToCharArray());
                                    foreach (string thisSplit in splitter)
                                    {
                                        BibInfo.Add_Subject(thisSplit.Trim(), String.Empty);
                                    }
                                }
                                else
                                {
                                    BibInfo.Add_Subject(R.Value.Trim(), String.Empty);
                                }
                            }
                            break;

                        case "dc:title":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                if (BibInfo.Main_Title.Title.Length == 0)
                                {
                                    BibInfo.Main_Title.Title = R.Value.Trim();
                                }
                                else
                                {
                                    BibInfo.Add_Other_Title(R.Value.Trim(), Title_Type_Enum.alternative);
                                }
                            }
                            break;

                        case "dc:type":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0))
                            {
                                BibInfo.Type.Add_Uncontrolled_Type(R.Value.Trim());
                            }
                            break;

                        case "thesis.degree.name":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && ( Return_Package != null ))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Degree = R.Value.Trim();
                            }
                            break;

                        case "thesis.degree.level":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                string temp = R.Value.Trim().ToLower();
                                if ((temp == "doctorate") || (temp == "doctoral"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Doctorate;
                                if ((temp == "masters") || (temp == "master's"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Masters;
                                if ((temp == "bachelors") || (temp == "bachelor's"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Bachelors;
                                if ((temp == "post-doctorate") || (temp == "post-doctoral"))
                                    thesisInfo.Degree_Level = Thesis_Dissertation_Info.Thesis_Degree_Level_Enum.Bachelors;
                            }
                            break;

                        case "thesis.degree.discipline":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Add_Degree_Discipline(R.Value.Trim());
                            }
                            break;

                        case "thesis.degree.grantor":
                            R.Read();
                            if ((R.NodeType == XmlNodeType.Text) && (R.Value.Trim().Length > 0) && (Return_Package != null))
                            {
                                // Ensure the thesis object exists and is added
                                Thesis_Dissertation_Info thesisInfo = Return_Package.Get_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY) as Thesis_Dissertation_Info;
                                if (thesisInfo == null)
                                {
                                    thesisInfo = new Thesis_Dissertation_Info();
                                    Return_Package.Add_Metadata_Module(GlobalVar.THESIS_METADATA_MODULE_KEY, thesisInfo);
                                }

                                thesisInfo.Degree_Grantor = R.Value.Trim();
                            }
                            break;
                    }
                }
            }
        }
        /// <summary> Reads the Dublin Core-compliant section of XML and stores the data in the provided digital resource </summary>
        /// <param name="r"> XmlTextReader from which to read the dublin core data </param>
        /// <param name="thisBibInfo"> Digital resource object to save the data to </param>
        public static void Read_Simple_Dublin_Core_Info(XmlReader r, Bibliographic_Info thisBibInfo)
        {
            while (r.Read())
            {
                if ((r.NodeType == XmlNodeType.EndElement) && ((r.Name == "METS:mdWrap") || (r.Name == "mdWrap")))
                    return;

                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                        case "dc:contributor":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Named_Entity(r.Value.Trim(), "Contributor");
                            }
                            break;

                        case "dc:coverage":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                Subject_Info_Standard thisSubject = new Subject_Info_Standard();
                                thisSubject.Add_Geographic(r.Value.Trim());
                                thisBibInfo.Add_Subject(thisSubject);
                            }
                            break;

                        case "dc:creator":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (thisBibInfo.Main_Entity_Name.hasData)
                                {
                                    thisBibInfo.Add_Named_Entity(r.Value.Trim());
                                }
                                else
                                {
                                    thisBibInfo.Main_Entity_Name.Full_Name = r.Value.Trim();
                                }
                            }
                            break;

                        case "dc:date":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Origin_Info.Date_Issued = r.Value.Trim();
                            }
                            break;

                        case "dc:description":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Note(r.Value.Trim());
                            }
                            break;

                        case "dc:format":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Original_Description.Extent = r.Value.Trim();
                            }
                            break;

                        case "dc:identifier":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Identifier(r.Value.Trim());
                            }
                            break;

                        case "dc:language":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Language(r.Value.Trim());
                            }
                            break;

                        case "dc:publisher":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Publisher(r.Value.Trim());
                            }
                            break;

                        case "dc:relation":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                Related_Item_Info newRelatedItem = new Related_Item_Info();
                                newRelatedItem.Main_Title.Title = r.Value.Trim();
                                thisBibInfo.Add_Related_Item(newRelatedItem);
                            }
                            break;

                        case "dc:rights":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Access_Condition.Text = r.Value.Trim();
                            }
                            break;

                        case "dc:source":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Add_Note(r.Value, Note_Type_Enum.source);
                            }
                            break;

                        case "dc:subject":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (r.Value.IndexOf(";") > 0)
                                {
                                    string[] splitter = r.Value.Split(";".ToCharArray());
                                    foreach (string thisSplit in splitter)
                                    {
                                        thisBibInfo.Add_Subject(thisSplit.Trim(), String.Empty);
                                    }
                                }
                                else
                                {
                                    thisBibInfo.Add_Subject(r.Value.Trim(), String.Empty);
                                }
                            }
                            break;

                        case "dc:title":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                if (thisBibInfo.Main_Title.Title.Length == 0)
                                {
                                    thisBibInfo.Main_Title.Title = r.Value.Trim();
                                }
                                else
                                {
                                    thisBibInfo.Add_Other_Title(r.Value.Trim(), Title_Type_Enum.alternative);
                                }
                            }
                            break;

                        case "dc:type":
                            r.Read();
                            if ((r.NodeType == XmlNodeType.Text) && (r.Value.Trim().Length > 0))
                            {
                                thisBibInfo.Type.Add_Uncontrolled_Type(r.Value.Trim());
                            }
                            break;
                    }
                }
            }
        }
        /// <summary> Adds a new spatial subject (non-hierarchical) to this item </summary>
        /// <param name="SpatialTerm"> Term for the spatial subject </param>
        /// <returns> Subject_Info_Standard object that was created and added </returns>
        public Subject_Info_Standard Add_Spatial_Subject(string SpatialTerm)
        {
            Subject_Info_Standard returnValue = new Subject_Info_Standard();
            returnValue.Add_Geographic(SpatialTerm);
            Add_Subject(returnValue);

            return returnValue;
        }