/// <summary>
        /// Handles the note list click. --> Grabbing the record which may or may note bopened later
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// E.
        /// </param>
        void HandleNoteListClick(object sender, EventArgs e)
        {
            switch (Mode)
            {
            case Modes.NOTES: blurb.Text = ""; break;

            case Modes.LAYOUTS:
                if (list.SelectedItem != null)
                {
                    MasterOfLayouts.NameAndGuid record = (MasterOfLayouts.NameAndGuid) this.list.SelectedItem;
                    blurb.Text = (record.Blurb);
                }
                break;

            case Modes.LAYOUTSONCURRENTLAYOUT:
                //NewMessage.Show ("notes on other click");
                break;
            }
        }
        /// <summary>
        /// Handles the list box double click.
        ///
        /// Will go to the note (if in OnLayout mode) or open a new note
        ///
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// E.
        /// </param>
        void HandleListBoxDoubleClick(object sender, EventArgs e)
        {
            if (this.list.SelectedItem != null)
            {
                if (Modes.NOTES == _mode)
                {
                    NoteDataInterface note = (NoteDataInterface)this.list.SelectedItem;

                    if (note != null)
                    {
                        Layout.GoToNote(note);
                    }
                    else
                    {
                        lg.Instance.Line("LayoutPanel->HandleTabButtonClick", ProblemType.WARNING, String.Format("Note with guid = {0} not found", note.GuidForNote));
                    }
                }
                else
                if (Modes.LAYOUTS == _mode)
                {
                    MasterOfLayouts.NameAndGuid record = (MasterOfLayouts.NameAndGuid) this.list.SelectedItem;
                    LayoutDetails.Instance.LoadLayout(record.Guid);
                }
                else
                if (Modes.LAYOUTSONCURRENTLAYOUT == _mode)
                {
                    if (LayoutDetails.Instance.CurrentLayout != null)
                    {
                        NoteDataInterface note = (NoteDataInterface)this.list.SelectedItem;
                        if (note != null)
                        {
                            LayoutDetails.Instance.CurrentLayout.GoToNote(note);
                        }
                        else
                        {
                            lg.Instance.Line("LayoutPanel->HandleTabButtonClick", ProblemType.WARNING, String.Format("Note with guid = {0} not found", note.GuidForNote));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Generate_s the cover letter.
        /// 
        /// Looks for a text note named "cover letter"
        /// 
        /// Fills in the appropriate details
        /// MARKET details
        /// [MarketName]
        //        [Address]
        //        [City], [Province]
        //        [PostalCode]
        //        [Country]
        //      [Editor]
        //
        // PROJECT DETAILS
        // [Page]
        // [Words]
        /// </summary>
        void Generate_CoverLetter()
        {
            if (ListOfSubs.SelectedItem != null && ProjectGUID != Constants.BLANK && LayoutDetails.Instance.CurrentLayout != null) {
                // find the cover to use and get text from it

                string covernote = Constants.BLANK;
                NoteDataXML_RichText TextNote = (NoteDataXML_RichText)LayoutDetails.Instance.CurrentLayout.FindNoteByName("Cover Letter");
                if (TextNote != null)
                {
                covernote = TextNote.GetRichTextBox().Rtf;

                TransactionSubmission Submission = (TransactionSubmission)ListOfSubs.SelectedItem;
                string marketguid = Submission.MarketGuid;

                Market market = GetMarketByGUID(marketguid);
                if (market != null)
                {
                MasterOfLayouts.NameAndGuid project = new MasterOfLayouts.NameAndGuid ();
                project.Guid = ProjectGUID;
                    project.Caption = MasterOfLayouts.GetNameFromGuid(ProjectGUID);
                project.Words = MasterOfLayouts.GetWordsFromGuid(ProjectGUID);

                if (market != null) {
                    try {
                        // load it into a temporary richtext that we destroy
                        // copy it and paste it into the rich edit?
                                string sOutput = TextUtils.RegExternalStr_ObjectLookup (covernote,  market,project, null);
                        // sOutput = DocGen.RegExternalStr_ObjectLookup(sOutput, market);
                        //sOutput = DocGen.RegExternalStr_ObjectLookup(sOutput, info);

                        try {
                            //	richText.Rtf = temp.Rtf;
                                    GenericTextForm Report = LayoutDetails.Instance.GetTextFormToUse();
                                    Report.GetRichTextBox().Rtf = sOutput;
                                    Report.ShowDialog();
                            /*temp.SelectAll();
                                temp.Copy();
                                richText.ReadOnly = false;
                                richText.Focus();
                                // richText.Rtf = richText.Rtf + "\n";
                                richText.Paste();*/
                        } catch (Exception ex) {
                            NewMessage.Show (ex.ToString ());
                        }
                    } catch (Exception ex) {
                            NewMessage.Show (ex.ToString());
                        // if user info has not had valid data entered for USERINFO then
                        // we can't output a letter
                        //richText.Text = Loc.Instance.GetString ("error");
                    }
                } else {
                    lg.Instance.Line ("ViewProjectSubmissions->GenerateCoverLetter", ProblemType.WARNING, "error generating cover letter");
                }
                    }	// market not null
                }
                else
                {
                    NewMessage.Show (Loc.Instance.GetString ("You cannot generate a cover letter unless you have a text note named Cover Letter on this layout."));
                }
            }
        }