protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request["PID"]))
            {
                Session["ProgramID"] = Request["PID"].ToString();
            }
            if (!IsPostBack)
            {
                if (Session["ProgramID"] == null)
                {
                    try
                    {
                        int PID = Programs.GetDefaultProgramID();
                        Session["ProgramID"] = PID.ToString();
                    }
                    catch
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                }
            }

            TranslateStrings(this);

            eventBackLink.NavigateUrl = "~/Events/";

            DAL.Event evnt = null;
            int eventId = 0;
            string displayEvent = Request.QueryString["EventId"];
            if (!string.IsNullOrEmpty(displayEvent)
               && int.TryParse(displayEvent.ToString(), out eventId))
            {
                evnt = DAL.Event.GetEvent(eventId);
                if (evnt != null && evnt.HiddenFromPublic)
                {
                    evnt = null;
                }
                if (evnt != null)
                {
                    SchemaOrgLibrary mdLib = new SchemaOrgLibrary();
                    SchemaOrgEvent mvEvt = new SchemaOrgEvent
                    {
                        Name = evnt.EventTitle,
                        StartDate = evnt.EventDate
                    };

                    eventTitle.Text = evnt.EventTitle;
                    this.Title = string.Format("Event Details: {0}", eventTitle.Text);

                    eventWhen.Text = DAL.Event.DisplayEventDateTime(evnt);

                    eventWhere.Visible = false;
                    eventWhereLink.Visible = false;
                    atLabel.Visible = false;

                    if (evnt.BranchID > 0)
                    {
                        var codeObject = DAL.Codes.FetchObject(evnt.BranchID);
                        if (codeObject != null)
                        {
                            eventWhere.Text
                                = mdLib.Name
                                = codeObject.Description;
                            eventWhereLink.Text = string.Format("{0} <span class=\"glyphicon glyphicon-new-window hidden-print\"></span>",
                                codeObject.Description);

                            eventWhere.Visible = true;
                            atLabel.Visible = true;
                            eventWhereLink.Visible = false;
                        }
                        var crosswalk = DAL.LibraryCrosswalk.FetchObjectByLibraryID(evnt.BranchID);
                        if (crosswalk != null)
                        {
                            if (!string.IsNullOrEmpty(eventWhere.Text)
                                && !string.IsNullOrEmpty(crosswalk.BranchAddress))
                            {
                                eventWhereMapLink.Visible = true;
                                eventWhereMapLink.NavigateUrl = string.Format(WebTools.BranchMapLinkStub,
                                    crosswalk.BranchAddress);
                            }

                            if (!string.IsNullOrEmpty(eventWhere.Text)
                               && !string.IsNullOrEmpty(crosswalk.BranchLink))
                            {
                                eventWhereLink.NavigateUrl = crosswalk.BranchLink;
                                eventWhere.Visible = false;
                                eventWhereLink.Visible = true;
                                atLabel.Visible = true;
                            }

                            mdLib.Address = crosswalk.BranchAddress;
                            mdLib.Telephone = crosswalk.BranchTelephone;
                            mdLib.Url = crosswalk.BranchLink;
                        }
                    }

                    if (string.IsNullOrEmpty(mdLib.Name))
                    {
                        this.MetaDescription = string.Format("Details about the event: {0} - {1}",
                            mdLib.Name,
                            GetResourceString("system-name"));
                    }
                    else
                    {
                        this.MetaDescription = string.Format("Details about the event: {0} at {1} - {2}",
                            eventTitle.Text,
                            eventWhere.Text,
                            GetResourceString("system-name"));
                    }

                    if (!string.IsNullOrWhiteSpace(evnt.ExternalLinkToEvent))
                    {
                        eventLinkPanel.Visible = true;
                        ExternalLink.NavigateUrl = evnt.ExternalLinkToEvent;
                        ExternalLink.Text = string.Format(eventTitle.Text);
                    }
                    else
                    {
                        eventLinkPanel.Visible = false;
                    }
                    eventDescription.Text = Server.HtmlDecode(evnt.HTML);
                    var cf = DAL.CustomEventFields.FetchObject();
                    if (!string.IsNullOrWhiteSpace(evnt.Custom1)
                       && !string.IsNullOrWhiteSpace(cf.Label1))
                    {
                        eventCustom1Panel.Visible = true;
                        eventCustomLabel1.Text = cf.Label1;
                        eventCustomValue1.Text = evnt.Custom1;
                    }
                    else
                    {
                        eventCustom1Panel.Visible = false;
                    }
                    if (!string.IsNullOrWhiteSpace(evnt.Custom2)
                       && !string.IsNullOrWhiteSpace(cf.Label2))
                    {
                        eventCustom2Panel.Visible = true;
                        eventCustomLabel2.Text = cf.Label2;
                        eventCustomValue2.Text = evnt.Custom2;
                    }
                    else
                    {
                        eventCustom2Panel.Visible = false;
                    }
                    if (!string.IsNullOrWhiteSpace(evnt.Custom3)
                       && !string.IsNullOrWhiteSpace(cf.Label3))
                    {
                        eventCustom3Panel.Visible = true;
                        eventCustomLabel3.Text = cf.Label3;
                        eventCustomValue3.Text = evnt.Custom3;
                    }
                    else
                    {
                        eventCustom3Panel.Visible = false;
                    }
                    eventDetails.Visible = true;

                    mvEvt.Location = mdLib;
                    try
                    {
                        Microdata.Text = new WebTools().BuildEventJsonld(mvEvt);
                    }
                    catch (Exception ex)
                    {
                        this.Log().Error("Problem creating microdata in event detail for {0}: {1} - {2}",
                            evnt.EID,
                            ex.Message,
                            ex.StackTrace);
                    }

                    // begin social
                    var wt = new WebTools();

                    var systemName = StringResources.getStringOrNull("system-name");
                    var fbDescription = StringResources.getStringOrNull("facebook-description");
                    var hashtags = StringResources.getStringOrNull("socialmedia-hashtags");

                    var title = string.Format("{0} event: {1}",
                        systemName,
                        evnt.EventTitle);
                    string description = string.Format("I'm thinking about attending this {0} event: {1}!",
                        systemName,
                        evnt.EventTitle);
                    string twitDescrip = string.Format("Check out this {0} event: {1}!",
                        systemName,
                        evnt.EventTitle);
                    if (twitDescrip.Length > 118)
                    {
                        // if it's longer than this it won't fit with the url, shorten it
                        twitDescrip = string.Format("Check this out: {0}!",
                            evnt.EventTitle);
                    }

                    var baseUrl = WebTools.GetBaseUrl(Request);
                    var eventDetailsUrl = string.Format("{0}/Events/Details.aspx?EventId={1}",
                        baseUrl,
                        evnt.EID);
                    string bannerPath = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                        Session,
                        Server);

                    wt.AddOgMetadata(Metadata,
                        title,
                        wt.BuildFacebookDescription(description, hashtags, fbDescription),
                        bannerPath,
                        eventDetailsUrl,
                        facebookApp: GetResourceString("facebook-appid"));

                    wt.AddTwitterMetadata(Metadata,
                        title,
                        description,
                        bannerPath,
                        twitterUsername: GetResourceString("twitter-username"));

                    TwitterShare.NavigateUrl = wt.GetTwitterLink(twitDescrip,
                        Server.UrlEncode(eventDetailsUrl),
                        hashtags);
                    TwitterShare.Visible = true;
                    FacebookShare.NavigateUrl
                        = wt.GetFacebookLink(Server.UrlEncode(eventDetailsUrl));
                    FacebookShare.Visible = true;
                    //end social
                }
            }

            if (evnt == null)
            {
                eventDetails.Visible = false;
                var cph = Page.Master.FindControl("HeaderContent") as ContentPlaceHolder;
                if (cph != null)
                {
                    cph.Controls.Add(new HtmlMeta
                    {
                        Name = "robots",
                        Content = "noindex"
                    });
                }
                Session[SessionKey.PatronMessage] = "Could not find details on that event.";
                Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning;
                Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign";

            }
        }
        protected void LookupChallenge(int blid)
        {
            var bl = BookList.FetchObject(blid);

            if (bl == null)
            {
                challengeDetails.Visible = false;
                new SessionTools(Session).AlertPatron("Could not find details on that Challenge.",
                    PatronMessageLevels.Warning,
                    "exclamation-sign");
            }
            else
            {
                int patronId = -1;
                var p = Session[SessionKey.Patron] as Patron;
                if (p != null)
                {
                    patronId = p.PID;
                }

                // see if this is bound to a specific program
                if (bl.ProgID != 0)
                {
                    // no user is logged in, don't show it
                    if (p == null)
                    {
                        var prog = DAL.Programs.FetchObject(bl.ProgID);
                        challengeDetails.Visible = false;
                        new SessionTools(Session).AlertPatron(
                            string.Format("You must be registered in the <strong>{0}</strong> program to view this Challenge.",
                                prog.TabName),
                            PatronMessageLevels.Warning,
                            "exclamation-sign");
                    }

                    // user is registered under another program
                    if (p != null && bl.ProgID != p.ProgID)
                    {
                        var prog = DAL.Programs.FetchObject(bl.ProgID);
                        challengeDetails.Visible = false;
                        new SessionTools(Session).AlertPatron(
                            string.Format("That Challenge is only available to people in the <strong>{0}</strong> program.",
                                prog.TabName),
                            PatronMessageLevels.Warning,
                            "exclamation-sign");
                    }
                }

                if (challengeDetails.Visible)
                {
                    Badge badge = null;

                    challengeTitle.Text = bl.ListName;
                    this.Title = string.Format("Challenge: {0}", challengeTitle.Text);
                    lblDesc.Text = string.Format("<p>{0}</p>", Server.HtmlDecode(bl.Description));

                    string award = null;

                    if (bl.AwardPoints > 0)
                    {
                        award = string.Format("Completing <strong>{0} task{1}</strong> will earn: <strong>{2} point{3}</strong>",
                            bl.NumBooksToComplete,
                            bl.NumBooksToComplete > 1 ? "s" : string.Empty,
                            bl.AwardPoints,
                            bl.AwardPoints > 1 ? "s" : string.Empty);
                    }

                    if (bl.AwardBadgeID > 0)
                    {
                        badge = DAL.Badge.FetchObject(bl.AwardBadgeID);
                        if (badge != null)
                        {
                            if (badge.HiddenFromPublic != true)
                            {
                                if (string.IsNullOrWhiteSpace(award))
                                {
                                    award = string.Format("Completing {0} task{1} will earn: <strong>a badge</strong>.",
                                        bl.NumBooksToComplete,
                                        bl.NumBooksToComplete > 1 ? "s" : string.Empty);
                                }
                                else
                                {
                                    award += " and <strong>a badge</strong>.";
                                }

                                BadgeImage.Text = string.Format("<img class=\"thumbnail disabled\" src=\"/images/badges/sm_{0}.png\" />", bl.AwardBadgeID);
                            }
                            else
                            {
                                badge = null;
                                if (string.IsNullOrWhiteSpace(award))
                                {
                                    award = string.Format("Completing {0} task{1} will earn: <strong>a secret badge</strong>.",
                                        bl.NumBooksToComplete,
                                        bl.NumBooksToComplete > 1 ? "s" : string.Empty);
                                }
                                else
                                {
                                    award += " and <strong>a secret badge</strong>.";
                                }
                                BadgeImage.Text = string.Empty;
                            }
                        }
                    }
                    else
                    {
                        BadgeImage.Text = string.Empty;
                        award += ".";
                    }

                    BadgeImage.Visible = !string.IsNullOrEmpty(BadgeImage.Text);

                    if (!string.IsNullOrWhiteSpace(award))
                    {
                        lblPoints.Text = award;
                        lblPoints.Visible = true;
                    }

                    var ds = BookListBooks.GetForDisplay(bl.BLID, patronId);

                    //Eval("NumBooksCompleted"), Eval("NumBooksToComplete")
                    if(ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        int completed = 0;
                        foreach(DataRow row in ds.Tables[0].Rows) {
                            if ((bool?)row["HasRead"] == true)
                            {
                                completed++;
                                if(completed >= bl.NumBooksToComplete)
                                {
                                    ChallengeCompleted = true;
                                    break;
                                }
                            }
                        }
                    }

                    rptr.DataSource = ds;
                    rptr.DataBind();

                    // begin social
                    var wt = new WebTools();

                    string systemName = StringResources.getStringOrNull("system-name");
                    var fbDescription = StringResources.getStringOrNull("facebook-description");
                    var hashtags = StringResources.getStringOrNull("socialmedia-hashtags");

                    string title = string.Format("{0} challenge: {1}",
                        systemName,
                        bl.ListName);

                    string description = string.Format("Check out this {0} challenge: {1}!",
                        systemName,
                        bl.ListName);

                    string twitDescrip = description;
                    if (twitDescrip.Length > 118)
                    {
                        // if it's longer than this it won't fit with the url, shorten it
                        twitDescrip = string.Format("Check this out: {0}!",
                            bl.ListName);
                    }

                    var baseUrl = WebTools.GetBaseUrl(Request);
                    var challengeUrl = string.Format("{0}/Challenges/Details.aspx?ChallengeId={1}",
                        baseUrl,
                        bl.BLID);

                    string imagePath = null;
                    if (badge != null)
                    {
                        string potentialBadgePath = string.Format("~/Images/Badges/{0}.png",
                                          badge.BID);
                        if (System.IO.File.Exists(Server.MapPath(potentialBadgePath)))
                        {
                            imagePath = string.Format("{0}{1}",
                                baseUrl,
                                VirtualPathUtility.ToAbsolute(potentialBadgePath));
                        }
                    }

                    if (string.IsNullOrEmpty(imagePath))
                    {
                        imagePath = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                            Session,
                            Server);
                    }

                    wt.AddOgMetadata(Metadata,
                        title,
                        wt.BuildFacebookDescription(description, hashtags, fbDescription),
                        imagePath,
                        challengeUrl,
                        facebookApp: GetResourceString("facebook-appid"));

                    wt.AddTwitterMetadata(Metadata,
                        title,
                        description,
                        imagePath,
                        twitterUsername: GetResourceString("twitter-username"));

                    TwitterShare.NavigateUrl = wt.GetTwitterLink(description,
                        Server.UrlEncode(challengeUrl),
                        hashtags);
                    TwitterShare.Visible = true;
                    FacebookShare.NavigateUrl = wt.GetFacebookLink(Server.UrlEncode(challengeUrl));
                    FacebookShare.Visible = true;
                    // end social

                    this.ShowModal = true;
                }
            }
        }
        protected void LookupChallenge(int blid)
        {
            var bl = BookList.FetchObject(blid);

            if (bl == null)
            {
                challengeDetails.Visible = false;
                new SessionTools(Session).AlertPatron("Could not find details on that Challenge.",
                                                      PatronMessageLevels.Warning,
                                                      "exclamation-sign");
            }
            else
            {
                int patronId = -1;
                var p        = Session[SessionKey.Patron] as Patron;
                if (p != null)
                {
                    patronId = p.PID;
                }

                // see if this is bound to a specific program
                if (bl.ProgID != 0)
                {
                    // no user is logged in, don't show it
                    if (p == null)
                    {
                        var prog = DAL.Programs.FetchObject(bl.ProgID);
                        challengeDetails.Visible = false;
                        new SessionTools(Session).AlertPatron(
                            string.Format("You must be registered in the <strong>{0}</strong> program to view this Challenge.",
                                          prog.TabName),
                            PatronMessageLevels.Warning,
                            "exclamation-sign");
                    }

                    // user is registered under another program
                    if (p != null && bl.ProgID != p.ProgID)
                    {
                        var prog = DAL.Programs.FetchObject(bl.ProgID);
                        challengeDetails.Visible = false;
                        new SessionTools(Session).AlertPatron(
                            string.Format("That Challenge is only available to people in the <strong>{0}</strong> program.",
                                          prog.TabName),
                            PatronMessageLevels.Warning,
                            "exclamation-sign");
                    }
                }

                if (challengeDetails.Visible)
                {
                    Badge badge = null;

                    challengeTitle.Text = bl.ListName;
                    this.Title          = string.Format("Challenge: {0}", challengeTitle.Text);
                    lblDesc.Text        = string.Format("<p>{0}</p>", Server.HtmlDecode(bl.Description));

                    string award = null;

                    if (bl.AwardPoints > 0)
                    {
                        award = string.Format("Completing <strong>{0} task{1}</strong> will earn: <strong>{2} point{3}</strong>",
                                              bl.NumBooksToComplete,
                                              bl.NumBooksToComplete > 1 ? "s" : string.Empty,
                                              bl.AwardPoints,
                                              bl.AwardPoints > 1 ? "s" : string.Empty);
                    }

                    if (bl.AwardBadgeID > 0)
                    {
                        badge = DAL.Badge.FetchObject(bl.AwardBadgeID);
                        if (badge != null)
                        {
                            if (badge.HiddenFromPublic != true)
                            {
                                if (string.IsNullOrWhiteSpace(award))
                                {
                                    award = string.Format("Completing {0} task{1} will earn: <strong>a badge</strong>.",
                                                          bl.NumBooksToComplete,
                                                          bl.NumBooksToComplete > 1 ? "s" : string.Empty);
                                }
                                else
                                {
                                    award += " and <strong>a badge</strong>.";
                                }

                                BadgeImage.Text = string.Format("<img class=\"thumbnail disabled\" src=\"/images/badges/sm_{0}.png\" />", bl.AwardBadgeID);
                            }
                            else
                            {
                                badge = null;
                                if (string.IsNullOrWhiteSpace(award))
                                {
                                    award = string.Format("Completing {0} task{1} will earn: <strong>a secret badge</strong>.",
                                                          bl.NumBooksToComplete,
                                                          bl.NumBooksToComplete > 1 ? "s" : string.Empty);
                                }
                                else
                                {
                                    award += " and <strong>a secret badge</strong>.";
                                }
                                BadgeImage.Text = string.Empty;
                            }
                        }
                    }
                    else
                    {
                        BadgeImage.Text = string.Empty;
                        award          += ".";
                    }

                    BadgeImage.Visible = !string.IsNullOrEmpty(BadgeImage.Text);

                    if (!string.IsNullOrWhiteSpace(award))
                    {
                        lblPoints.Text    = award;
                        lblPoints.Visible = true;
                    }

                    var ds = BookListBooks.GetForDisplay(bl.BLID, patronId);

                    //Eval("NumBooksCompleted"), Eval("NumBooksToComplete")
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        int completed = 0;
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            if ((bool?)row["HasRead"] == true)
                            {
                                completed++;
                                if (completed >= bl.NumBooksToComplete)
                                {
                                    ChallengeCompleted = true;
                                    break;
                                }
                            }
                        }
                    }

                    rptr.DataSource = ds;
                    rptr.DataBind();

                    // begin social
                    var wt = new WebTools();

                    string systemName    = StringResources.getStringOrNull("system-name");
                    var    fbDescription = StringResources.getStringOrNull("facebook-description");
                    var    hashtags      = StringResources.getStringOrNull("socialmedia-hashtags");

                    string title = string.Format("{0} challenge: {1}",
                                                 systemName,
                                                 bl.ListName);

                    string description = string.Format("Check out this {0} challenge: {1}!",
                                                       systemName,
                                                       bl.ListName);

                    string twitDescrip = description;
                    if (twitDescrip.Length > 118)
                    {
                        // if it's longer than this it won't fit with the url, shorten it
                        twitDescrip = string.Format("Check this out: {0}!",
                                                    bl.ListName);
                    }

                    var baseUrl      = WebTools.GetBaseUrl(Request);
                    var challengeUrl = string.Format("{0}/Challenges/Details.aspx?ChallengeId={1}",
                                                     baseUrl,
                                                     bl.BLID);

                    string imagePath = null;
                    if (badge != null)
                    {
                        string potentialBadgePath = string.Format("~/Images/Badges/{0}.png",
                                                                  badge.BID);
                        if (System.IO.File.Exists(Server.MapPath(potentialBadgePath)))
                        {
                            imagePath = string.Format("{0}{1}",
                                                      baseUrl,
                                                      VirtualPathUtility.ToAbsolute(potentialBadgePath));
                        }
                    }

                    if (string.IsNullOrEmpty(imagePath))
                    {
                        imagePath = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                                                                                  Session,
                                                                                  Server);
                    }

                    wt.AddOgMetadata(Metadata,
                                     title,
                                     wt.BuildFacebookDescription(description, hashtags, fbDescription),
                                     imagePath,
                                     challengeUrl,
                                     facebookApp: GetResourceString("facebook-appid"));

                    wt.AddTwitterMetadata(Metadata,
                                          title,
                                          description,
                                          imagePath,
                                          twitterUsername: GetResourceString("twitter-username"));

                    TwitterShare.NavigateUrl = wt.GetTwitterLink(description,
                                                                 Server.UrlEncode(challengeUrl),
                                                                 hashtags);
                    TwitterShare.Visible      = true;
                    FacebookShare.NavigateUrl = wt.GetFacebookLink(Server.UrlEncode(challengeUrl));
                    FacebookShare.Visible     = true;
                    // end social

                    this.ShowModal = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (((BaseSRPPage)Page).IsLoggedIn)
            {
                Server.Transfer("~/Dashboard.aspx");
            }
            if (!String.IsNullOrEmpty(Request["PID"]))
            {
                Session["ProgramID"] = Request["PID"].ToString();
            }
            if (!IsPostBack)
            {
                if (Session["ProgramID"] == null)
                {
                    try
                    {
                        int PID = Programs.GetDefaultProgramID();
                        Session["ProgramID"] = PID.ToString();
                    }
                    catch
                    {
                        Response.Redirect("~/ControlRoom/Configure.aspx");
                    }
                    // pgmID.Text = Session["ProgramID"].ToString();
                }
                else
                {
                    //pgmID.Text = Session["ProgramID"].ToString();
                }

                var systemName = GetResourceString("system-name");
                var description = GetResourceString("frontpage-description");
                var wt = new WebTools();
                var baseUrl = WebTools.GetBaseUrl(Request);
                var bannerPath = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                    Session,
                    Server);

                // open graph & facebook

                wt.AddOgMetadata(Metadata,
                    systemName,
                    description,
                    bannerPath,
                    baseUrl,
                    facebookApp: GetResourceString("facebook-appid"));

                // dublin core
                Metadata.Controls.Add(new HtmlMeta { Name = "DC.Title", Content = systemName });
                Metadata.Controls.Add(new HtmlMeta
                {
                    Name = "DC.Description",
                    Content = description
                });
                Metadata.Controls.Add(new HtmlMeta { Name = "DC.Source", Content = baseUrl });
                Metadata.Controls.Add(new HtmlMeta
                {
                    Name = "DC.Type",
                    Content = "InteractiveResource"
                });

                //twitter
                wt.AddTwitterMetadata(Metadata,
                    systemName,
                    GetResourceString("twitter-description"),
                    bannerPath,
                    "summary_large_image",
                    GetResourceString("twitter-username"));
            }
            TranslateStrings(this);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request["PID"]))
            {
                Session["ProgramID"] = Request["PID"].ToString();
            }
            if (!IsPostBack)
            {
                if (Session["ProgramID"] == null)
                {
                    try
                    {
                        int PID = Programs.GetDefaultProgramID();
                        Session["ProgramID"] = PID.ToString();
                    }
                    catch
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                }
            }

            TranslateStrings(this);

            eventBackLink.NavigateUrl = "~/Events/";

            DAL.Event evnt         = null;
            int       eventId      = 0;
            string    displayEvent = Request.QueryString["EventId"];

            if (!string.IsNullOrEmpty(displayEvent) &&
                int.TryParse(displayEvent.ToString(), out eventId))
            {
                evnt = DAL.Event.GetEvent(eventId);
                if (evnt != null && evnt.HiddenFromPublic)
                {
                    evnt = null;
                }
                if (evnt != null)
                {
                    SchemaOrgLibrary mdLib = new SchemaOrgLibrary();
                    SchemaOrgEvent   mvEvt = new SchemaOrgEvent
                    {
                        Name      = evnt.EventTitle,
                        StartDate = evnt.EventDate
                    };

                    eventTitle.Text = evnt.EventTitle;
                    this.Title      = string.Format("Event Details: {0}", eventTitle.Text);

                    eventWhen.Text = DAL.Event.DisplayEventDateTime(evnt);

                    eventWhere.Visible     = false;
                    eventWhereLink.Visible = false;
                    atLabel.Visible        = false;

                    if (evnt.BranchID > 0)
                    {
                        var codeObject = DAL.Codes.FetchObject(evnt.BranchID);
                        if (codeObject != null)
                        {
                            eventWhere.Text
                                  = mdLib.Name
                                  = codeObject.Description;
                            eventWhereLink.Text = string.Format("{0} <span class=\"glyphicon glyphicon-new-window hidden-print\"></span>",
                                                                codeObject.Description);

                            eventWhere.Visible     = true;
                            atLabel.Visible        = true;
                            eventWhereLink.Visible = false;
                        }
                        var crosswalk = DAL.LibraryCrosswalk.FetchObjectByLibraryID(evnt.BranchID);
                        if (crosswalk != null)
                        {
                            if (!string.IsNullOrEmpty(eventWhere.Text) &&
                                !string.IsNullOrEmpty(crosswalk.BranchAddress))
                            {
                                eventWhereMapLink.Visible     = true;
                                eventWhereMapLink.NavigateUrl = string.Format(WebTools.BranchMapLinkStub,
                                                                              crosswalk.BranchAddress);
                            }

                            if (!string.IsNullOrEmpty(eventWhere.Text) &&
                                !string.IsNullOrEmpty(crosswalk.BranchLink))
                            {
                                eventWhereLink.NavigateUrl = crosswalk.BranchLink;
                                eventWhere.Visible         = false;
                                eventWhereLink.Visible     = true;
                                atLabel.Visible            = true;
                            }

                            mdLib.Address   = crosswalk.BranchAddress;
                            mdLib.Telephone = crosswalk.BranchTelephone;
                            mdLib.Url       = crosswalk.BranchLink;
                        }
                    }

                    if (string.IsNullOrEmpty(mdLib.Name))
                    {
                        this.MetaDescription = string.Format("Details about the event: {0} - {1}",
                                                             mdLib.Name,
                                                             GetResourceString("system-name"));
                    }
                    else
                    {
                        this.MetaDescription = string.Format("Details about the event: {0} at {1} - {2}",
                                                             eventTitle.Text,
                                                             eventWhere.Text,
                                                             GetResourceString("system-name"));
                    }

                    if (!string.IsNullOrWhiteSpace(evnt.ExternalLinkToEvent))
                    {
                        eventLinkPanel.Visible   = true;
                        ExternalLink.NavigateUrl = evnt.ExternalLinkToEvent;
                        ExternalLink.Text        = string.Format(eventTitle.Text);
                    }
                    else
                    {
                        eventLinkPanel.Visible = false;
                    }
                    eventDescription.Text = Server.HtmlDecode(evnt.HTML);
                    var cf = DAL.CustomEventFields.FetchObject();
                    if (!string.IsNullOrWhiteSpace(evnt.Custom1) &&
                        !string.IsNullOrWhiteSpace(cf.Label1))
                    {
                        eventCustom1Panel.Visible = true;
                        eventCustomLabel1.Text    = cf.Label1;
                        eventCustomValue1.Text    = evnt.Custom1;
                    }
                    else
                    {
                        eventCustom1Panel.Visible = false;
                    }
                    if (!string.IsNullOrWhiteSpace(evnt.Custom2) &&
                        !string.IsNullOrWhiteSpace(cf.Label2))
                    {
                        eventCustom2Panel.Visible = true;
                        eventCustomLabel2.Text    = cf.Label2;
                        eventCustomValue2.Text    = evnt.Custom2;
                    }
                    else
                    {
                        eventCustom2Panel.Visible = false;
                    }
                    if (!string.IsNullOrWhiteSpace(evnt.Custom3) &&
                        !string.IsNullOrWhiteSpace(cf.Label3))
                    {
                        eventCustom3Panel.Visible = true;
                        eventCustomLabel3.Text    = cf.Label3;
                        eventCustomValue3.Text    = evnt.Custom3;
                    }
                    else
                    {
                        eventCustom3Panel.Visible = false;
                    }
                    eventDetails.Visible = true;

                    mvEvt.Location = mdLib;
                    try
                    {
                        Microdata.Text = new WebTools().BuildEventJsonld(mvEvt);
                    }
                    catch (Exception ex)
                    {
                        this.Log().Error("Problem creating microdata in event detail for {0}: {1} - {2}",
                                         evnt.EID,
                                         ex.Message,
                                         ex.StackTrace);
                    }

                    // begin social
                    var wt = new WebTools();

                    var systemName    = StringResources.getStringOrNull("system-name");
                    var fbDescription = StringResources.getStringOrNull("facebook-description");
                    var hashtags      = StringResources.getStringOrNull("socialmedia-hashtags");

                    var title = string.Format("{0} event: {1}",
                                              systemName,
                                              evnt.EventTitle);
                    string description = string.Format("I'm thinking about attending this {0} event: {1}!",
                                                       systemName,
                                                       evnt.EventTitle);
                    string twitDescrip = string.Format("Check out this {0} event: {1}!",
                                                       systemName,
                                                       evnt.EventTitle);
                    if (twitDescrip.Length > 118)
                    {
                        // if it's longer than this it won't fit with the url, shorten it
                        twitDescrip = string.Format("Check this out: {0}!",
                                                    evnt.EventTitle);
                    }

                    var baseUrl         = WebTools.GetBaseUrl(Request);
                    var eventDetailsUrl = string.Format("{0}/Events/Details.aspx?EventId={1}",
                                                        baseUrl,
                                                        evnt.EID);
                    string bannerPath = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                                                                                      Session,
                                                                                      Server);

                    wt.AddOgMetadata(Metadata,
                                     title,
                                     wt.BuildFacebookDescription(description, hashtags, fbDescription),
                                     bannerPath,
                                     eventDetailsUrl,
                                     facebookApp: GetResourceString("facebook-appid"));

                    wt.AddTwitterMetadata(Metadata,
                                          title,
                                          description,
                                          bannerPath,
                                          twitterUsername: GetResourceString("twitter-username"));

                    TwitterShare.NavigateUrl = wt.GetTwitterLink(twitDescrip,
                                                                 Server.UrlEncode(eventDetailsUrl),
                                                                 hashtags);
                    TwitterShare.Visible = true;
                    FacebookShare.NavigateUrl
                        = wt.GetFacebookLink(Server.UrlEncode(eventDetailsUrl));
                    FacebookShare.Visible = true;
                    //end social
                }
            }

            if (evnt == null)
            {
                eventDetails.Visible = false;
                var cph = Page.Master.FindControl("HeaderContent") as ContentPlaceHolder;
                if (cph != null)
                {
                    cph.Controls.Add(new HtmlMeta
                    {
                        Name    = "robots",
                        Content = "noindex"
                    });
                }
                Session[SessionKey.PatronMessage]          = "Could not find details on that event.";
                Session[SessionKey.PatronMessageLevel]     = PatronMessageLevels.Warning;
                Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (((BaseSRPPage)Page).IsLoggedIn)
            {
                Server.Transfer("~/Dashboard.aspx");
            }
            if (!String.IsNullOrEmpty(Request["PID"]))
            {
                Session["ProgramID"] = Request["PID"].ToString();
            }
            if (!IsPostBack)
            {
                if (Session["ProgramID"] == null)
                {
                    try
                    {
                        int PID = Programs.GetDefaultProgramID();
                        Session["ProgramID"] = PID.ToString();
                    }
                    catch
                    {
                        Response.Redirect("~/ControlRoom/Configure.aspx");
                    }
                    // pgmID.Text = Session["ProgramID"].ToString();
                }
                else
                {
                    //pgmID.Text = Session["ProgramID"].ToString();
                }

                var systemName  = GetResourceString("system-name");
                var description = GetResourceString("frontpage-description");
                var wt          = new WebTools();
                var baseUrl     = WebTools.GetBaseUrl(Request);
                var bannerPath  = new GRA.Logic.Banner().FullMetadataBannerPath(baseUrl,
                                                                                Session,
                                                                                Server);

                // open graph & facebook

                wt.AddOgMetadata(Metadata,
                                 systemName,
                                 description,
                                 bannerPath,
                                 baseUrl,
                                 facebookApp: GetResourceString("facebook-appid"));

                // dublin core
                Metadata.Controls.Add(new HtmlMeta {
                    Name = "DC.Title", Content = systemName
                });
                Metadata.Controls.Add(new HtmlMeta
                {
                    Name    = "DC.Description",
                    Content = description
                });
                Metadata.Controls.Add(new HtmlMeta {
                    Name = "DC.Source", Content = baseUrl
                });
                Metadata.Controls.Add(new HtmlMeta
                {
                    Name    = "DC.Type",
                    Content = "InteractiveResource"
                });

                //twitter
                wt.AddTwitterMetadata(Metadata,
                                      systemName,
                                      GetResourceString("twitter-description"),
                                      bannerPath,
                                      "summary_large_image",
                                      GetResourceString("twitter-username"));
            }
            TranslateStrings(this);
        }