protected void AddAgendaItem(object sender, EventArgs e)
 {
     HttpCookie cookie = Request.Cookies["BrowserDate"];
     if (cookie == null)
     {
         cookie = new HttpCookie("BrowserDate");
         cookie.Value = DateTime.Now.ToString();
         cookie.Expires = DateTime.Now.AddDays(22);
         Response.Cookies.Add(cookie);
     }
     Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
     AgendaItemTextBox.Text = dat.stripHTML(AgendaItemTextBox.Text.Trim());
     AgendaDescriptionTextBox.Text = dat.stripHTML(AgendaDescriptionTextBox.Text.Trim());
     if (AgendaItemTextBox.Text.Trim() != "")
     {
         AgendaLiteral.Text += "<div style=\"padding: 0px; padding-bottom: 3px;\" class=\"AddLink\">" +
             dat.BreakUpString(AgendaItemTextBox.Text.Trim(), 44) + "</div>";
         if (AgendaDescriptionTextBox.Text.Trim() != "")
         {
             AgendaLiteral.Text += "<div style=\"padding: 0px; padding-left: 20px; padding-bottom: 3px; color: #cccccc; font-family: arial; font-size: 11px;\">" +
             dat.BreakUpString(AgendaDescriptionTextBox.Text.Trim(), 44) + "</div>";
         }
     }
     else
     {
         AgendaErrorLabel.Text = "Must include the item title.";
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     HttpCookie cookie = Request.Cookies["BrowserDate"];
     Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
     TitleLabel.Text = title;
     TitleLabel.NavigateUrl = "../" + dat.MakeNiceName(title) + "_" + eventID + "_Event";
     summary = summary.Replace("<br/>", " ");
     if (summary.Length > 70)
         summary = dat.BreakUpString(summary.Substring(0, 70), 35) + "...";
     OtherEventSummaryLabel.Text = summary;
     PresentedByLabel.Text = "presented on " + presentedBy;
 }
Esempio n. 3
0
    protected void DrawEvents(DataView dvEvents, int cutOff)
    {
        string eventID = GetEventID();
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime isNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        Literal lit = new Literal();

        int count = 0;
        DataView dvEvent;
        string contentSub = "";
        foreach (DataRowView row in dvEvents)
        {
            if (count > cutOff - 1)
            {
                break;
            }
            else
            {
                contentSub = dat.stripHTML(row["Content"].ToString().Replace("<br>",
                    "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                    "").Replace("<br />", "").Replace("<BR />", ""));
                if (dat.stripHTML(row["Content"].ToString().Replace("<br>",
                    "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                    "").Replace("<br />", "").Replace("<BR />", "")).Length > 100)
                    contentSub = dat.stripHTML(row["Content"].ToString().Replace("<br>",
                        "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                        "").Replace("<br />", "").Replace("<BR />", "")).Substring(0, 100);
                dvEvent = dat.GetDataDV("SELECT * FROM Events E, Event_Occurance EO WHERE E.ID=EO.EventID AND E.ID=" + row["EventID"].ToString());
                lit.Text += "<div class=\"SimilarSide\">";
                lit.Text += "<a class=\"Blue12Link\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                    "_" + row["EventID"].ToString() + "_Event\">" + row["Header"].ToString() +
                    "</a> at " + "<a class=\"Green12LinkNF\" href=\"" + dat.MakeNiceName(row["Name"].ToString()) +
                    "_" + row["Venue"].ToString() + "_Venue\">" + row["Name"].ToString() + "</a> on " +
                    DateTime.Parse(dvEvent[0]["DateTimeStart"].ToString()).ToShortDateString() +
                    ". " + dat.BreakUpString(contentSub, 30) +
                    "... <a class=\"Blue12Link\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                    "_" + row["EventID"].ToString() + "_Event\">Read More</a>";
                lit.Text += "</div>";
                count++;
            }
        }

        OtherEventsPanel.Controls.Add(lit);
    }
Esempio n. 4
0
    protected void DrawBulletins(DataView dvEvents, int cutOff)
    {
        string eventID = Request.QueryString["AdID"];
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime isNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        Literal lit = new Literal();

        int count = 0;
        DataView dvEvent;
        string contentSub = "";
        foreach (DataRowView row in dvEvents)
        {
            if (count > cutOff - 1)
            {
                break;
            }
            else
            {
                contentSub = dat.stripHTML(row["Content"].ToString().Replace("<br>",
                    "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                    "").Replace("<br />", "").Replace("<BR />", ""));
                if (dat.stripHTML(row["Content"].ToString().Replace("<br>",
                    "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                    "").Replace("<br />", "").Replace("<BR />", "")).Length > 100)
                    contentSub = dat.stripHTML(row["Content"].ToString().Replace("<br>",
                        "").Replace("</br>", "").Replace("<br/>", "").Replace("<BR>", "").Replace("<BR/>",
                        "").Replace("<br />", "").Replace("<BR />", "")).Substring(0, 100);

                lit.Text += "<div class=\"SimilarSide\">";
                lit.Text += "<a class=\"Green12LinkNF\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                    "_" + row["AdID"].ToString() + "_Ad\">" + row["Header"].ToString() +
                    "</a>. " + dat.BreakUpString(contentSub, 30) +
                    "... <a class=\"Blue12Link\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                    "_" + row["AdID"].ToString() + "_Ad\">Read More</a>";
                lit.Text += "</div>";
                count++;
            }
        }

        OtherAdsPanel.Controls.Add(lit);
    }
    //protected void GetAvailableUsers(DateTime startDate, bool isBig)
    //{
    //    CategoryDaysPanel.Controls.Clear();
    //    UpdatePanel Up = new UpdatePanel();
    //    Up.ChildrenAsTriggers = false;
    //    Up.ID = "Up";
    //    Up.UpdateMode = UpdatePanelUpdateMode.Conditional;
    //    Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
    //    string txtLocation = CountryDropDown.SelectedItem.Text;
    //    string state = "";
    //    if (StateDropDownPanel.Visible)
    //        state = StateDropDown.SelectedItem.Text;
    //    else
    //        state = StateTextBox.THE_TEXT;
    //    int firstDayCount = 0;
    //    int secDayCount = 0;
    //    int thirdDayCount = 0;
    //    int fourthDayCount = 0;
    //    int firstDayCountLoc = 0;
    //    int secDayCountLoc = 0;
    //    int thirdDayCountLoc = 0;
    //    int fourthDayCountLoc = 0;
    //    TotalUsers.Text = firstDayCount.ToString();
    //    string city = "";
    //    if (CityTextBox.Text.Trim() != "")
    //    {
    //        city = CityTextBox.Text.Trim();
    //    }
    //    else
    //    {
    //        city = null;
    //    }
    //    bool isNoUsers = false;
    //    string categories = "";
    //    dat.returnCategoryIDString(CategoryTree, ref categories);
    //    dat.returnCategoryIDString(RadTreeView1, ref categories);
    //    dat.returnCategoryIDString(RadTreeView2, ref categories);
    //    dat.returnCategoryIDString(RadTreeView3, ref categories);
    //    dat.CalculateUsersAdCapacity(city, state, CountryDropDown.SelectedItem.Value, categories, startDate,
    //        ref firstDayCount, ref secDayCount, ref thirdDayCount, ref fourthDayCount, ref isNoUsers, isBig, false);
    //    dat.CalculateUsersAdCapacity(city, state, CountryDropDown.SelectedItem.Value, categories, startDate,
    //        ref firstDayCountLoc, ref secDayCountLoc, ref thirdDayCountLoc, ref fourthDayCountLoc, ref isNoUsers,
    //        isBig, true);
    //    System.Drawing.Color green = System.Drawing.Color.FromArgb(98, 142, 2);
    //    string startDateReal = "";
    //    if (Session["SelectedStartDate"] == null)
    //        startDateReal = ((DateTime)StartDateTimePicker.DbSelectedDate).ToShortDateString();
    //    else
    //        startDateReal = Session["SelectedStartDate"].ToString();
    //    Literal lab = new Literal();
    //    lab.ID = "dateLiteral";
    //    lab.Text = "<div style=\"clear: both; float: right;\"><label>Selected Start Date: </label><span "+
    //        "class=\"AddGreenLinkBig\">" + startDateReal + "</span></div><div style=\"clear: both;\">";
    //    Panel topPanel = new Panel();
    //    topPanel.Width = 590;
    //    LinkButton link1 = new LinkButton();
    //    if (startDate <= DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date)
    //    {
    //        link1.Enabled = false;
    //        link1.CssClass = "AddLinkNoPaddingDisabled";
    //    }
    //    else
    //    {
    //        link1.Enabled = true;
    //        link1.CssClass = "AddLinkNoPadding";
    //    }
    //    link1.Text = "Previous 4 Days";
    //    link1.Style.Add("float", "left");
    //    link1.Click += new EventHandler(prev4Click);
    //    link1.ID = "prevLink";
    //    LinkButton link = new LinkButton();
    //    link.Text = "Next 4 Days";
    //    link.ID = "nextLink";
    //    link.CssClass = "AddLinkNoPadding";
    //    link.Style.Add("float", "right");
    //    link.Click += new EventHandler(next4Click);
    //    Literal lit2 = new Literal();
    //    lit2.Text = "</div>";
    //    topPanel.Controls.Add(lab);
    //    topPanel.Controls.Add(link1);
    //    topPanel.Controls.Add(link);
    //    topPanel.Controls.Add(lit2);
    //    Literal lit = new Literal();
    //    lit.Text = "<br/>";
    //    Up.ContentTemplateContainer.Controls.Add(topPanel);
    //    Up.ContentTemplateContainer.Controls.Add(lit);
    //    //Draw the panel
    //    Panel panelDay1 = new Panel();
    //    Label label1 = new Label();
    //    label1.Text = (startDate).Date.ToShortDateString() + "<br/>";
    //    Label label12 = new Label();
    //    label1.CssClass = "NumLabel";
    //    label12.CssClass = "NumLabel";
    //    if (startDate < DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date)
    //    {
    //        panelDay1.Enabled = false;
    //        label12.Text = "0 Users in Categories<br/>" +
    //            "0 Users in Location <br/>";
    //    }
    //    else
    //    {
    //        label12.Text = (firstDayCount).ToString() + " Users in Categories<br/>" +
    //            firstDayCountLoc.ToString() + " Users in Location <br/>";
    //    }
    //    Button button1 = new Button();
    //    button1.Text = "Select date";
    //    button1.ID = "selectDate1";
    //    button1.Click += new EventHandler(SelectDate);
    //    button1.CommandArgument = (startDate).Date.ToShortDateString();
    //    panelDay1.Height = 100;
    //    panelDay1.BorderColor = green;
    //    panelDay1.BorderStyle = BorderStyle.Solid;
    //    panelDay1.BorderWidth = 2;
    //    panelDay1.Style.Add("float", "left");
    //    panelDay1.Style.Add("padding", "5px");
    //    panelDay1.Style.Add("margin", "5px");
    //    panelDay1.Controls.Add(label1);
    //    panelDay1.Controls.Add(label12);
    //    panelDay1.Controls.Add(button1);
    //    Up.ContentTemplateContainer.Controls.Add(panelDay1);
    //    Panel panelDay2 = new Panel();
    //    Label label2 = new Label();
    //    label2.Text = (startDate).AddDays(double.Parse("1.00")).ToShortDateString() + "<br/>";
    //    Label label22 = new Label();
    //    if ((startDate).AddDays(double.Parse("1.00")) < DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date)
    //    {
    //        panelDay2.Enabled = false;
    //        label22.Text = "0 Users in Categories<br/>" +
    //            "0 Users in Location <br/>";
    //    }
    //    else
    //    {
    //        label22.Text = secDayCount.ToString() + " Users in Categories<br/>" +
    //            secDayCountLoc.ToString() + " Users in Location <br/>";
    //    }
    //    label2.CssClass = "NumLabel";
    //    label22.CssClass = "NumLabel";
    //    Button button2 = new Button();
    //    button2.Text = "Select date";
    //    button2.ID = "selectDate2";
    //    button2.Click += new EventHandler(SelectDate);
    //    button2.CommandArgument = (startDate).AddDays(double.Parse("1.00")).ToShortDateString();
    //    panelDay2.Height = 100;
    //    panelDay2.BorderColor = green;
    //    panelDay2.BorderStyle = BorderStyle.Solid;
    //    panelDay2.BorderWidth = 2;
    //    panelDay2.Style.Add("float", "left");
    //    panelDay2.Style.Add("padding", "5px");
    //    panelDay2.Style.Add("margin", "5px");
    //    panelDay2.Controls.Add(label2);
    //    panelDay2.Controls.Add(label22);
    //    panelDay2.Controls.Add(button2);
    //    Up.ContentTemplateContainer.Controls.Add(panelDay2);
    //    Panel panelDay3 = new Panel();
    //    Label label3 = new Label();
    //    label3.Text = (startDate).AddDays(double.Parse("2.00")).ToShortDateString() + "<br/>";
    //    Label label32 = new Label();
    //    if ((startDate).AddDays(double.Parse("2.00")) < DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date)
    //    {
    //        panelDay3.Enabled = false;
    //        label32.Text = "0 Users in Categories<br/>" +
    //           "0 Users in Location <br/>";
    //    }
    //    else
    //    {
    //        label32.Text = secDayCount.ToString() + " Users in Categories<br/>" +
    //            thirdDayCountLoc.ToString() + " Users in Location <br/>";
    //    }
    //    label3.CssClass = "NumLabel";
    //    label32.CssClass = "NumLabel";
    //    Button button3 = new Button();
    //    button3.Text = "Select date";
    //    button3.ID = "selectDate3";
    //    button3.Click += new EventHandler(SelectDate);
    //    button3.CommandArgument = (startDate).AddDays(double.Parse("2.00")).ToShortDateString();
    //    panelDay3.Height = 100;
    //    panelDay3.BorderColor = green;
    //    panelDay3.BorderStyle = BorderStyle.Solid;
    //    panelDay3.BorderWidth = 2;
    //    panelDay3.Style.Add("float", "left");
    //    panelDay3.Style.Add("padding", "5px");
    //    panelDay3.Style.Add("margin", "5px");
    //    panelDay3.Controls.Add(label3);
    //    panelDay3.Controls.Add(label32);
    //    panelDay3.Controls.Add(button3);
    //    Up.ContentTemplateContainer.Controls.Add(panelDay3);
    //    Panel panelDay4 = new Panel();
    //    Label label4 = new Label();
    //    label4.Text = (startDate).AddDays(double.Parse("3.00")).ToShortDateString() + "<br/>";
    //    Label label42 = new Label();
    //    if ((startDate).AddDays(double.Parse("3.00")) < DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date)
    //    {
    //        panelDay4.Enabled = false;
    //        label42.Text = "0 Users in Categories<br/>" +
    //            "0 Users in Location <br/>";
    //    }
    //    else
    //    {
    //        label42.Text = secDayCount.ToString() + " Users in Categories<br/>" +
    //            fourthDayCountLoc.ToString() + " Users in Location <br/>";
    //    }
    //    label4.CssClass = "NumLabel";
    //    label42.CssClass = "NumLabel";
    //    Button button4 = new Button();
    //    button4.Text = "Select date";
    //    button4.ID = "selectDate4";
    //    button4.Click += new EventHandler(SelectDate);
    //    button4.CommandArgument = (startDate).AddDays(double.Parse("3.00")).ToShortDateString();
    //    panelDay4.Height = 100;
    //    panelDay4.BorderColor = green;
    //    panelDay4.BorderStyle = BorderStyle.Solid;
    //    panelDay4.BorderWidth = 2;
    //    panelDay4.Style.Add("float", "left");
    //    panelDay4.Style.Add("padding", "5px");
    //    panelDay4.Style.Add("margin", "5px");
    //    panelDay4.Controls.Add(label4);
    //    panelDay4.Controls.Add(label42);
    //    panelDay4.Controls.Add(button4);
    //    Up.ContentTemplateContainer.Controls.Add(panelDay4);
    //    AsyncPostBackTrigger apt = new AsyncPostBackTrigger();
    //    apt.ControlID = link1.ClientID;
    //    apt.EventName = "Click";
    //    Up.Triggers.Add(apt);
    //    AsyncPostBackTrigger apt1 = new AsyncPostBackTrigger();
    //    apt1.ControlID = button1.ClientID;
    //    apt1.EventName = "Click";
    //    Up.Triggers.Add(apt1);
    //    AsyncPostBackTrigger apt2 = new AsyncPostBackTrigger();
    //    apt2.ControlID = link.ClientID;
    //    apt2.EventName = "Click";
    //    Up.Triggers.Add(apt2);
    //    AsyncPostBackTrigger apt3 = new AsyncPostBackTrigger();
    //    apt3.ControlID = button2.ClientID;
    //    apt3.EventName = "Click";
    //    Up.Triggers.Add(apt3);
    //    AsyncPostBackTrigger apt4 = new AsyncPostBackTrigger();
    //    apt4.ControlID = button3.ClientID;
    //    apt4.EventName = "Click";
    //    Up.Triggers.Add(apt4);
    //    AsyncPostBackTrigger apt5 = new AsyncPostBackTrigger();
    //    apt5.ControlID = button4.ClientID;
    //    apt5.EventName = "Click";
    //    Up.Triggers.Add(apt5);
    //    AsyncPostBackTrigger apt6 = new AsyncPostBackTrigger();
    //    apt6.ControlID = AdPlacementList.UniqueID;
    //    apt6.EventName = "SelectedIndexChanged";
    //    Up.Triggers.Add(apt6);
    //    Up.Update();
    //    CategoryDaysPanel.Controls.Add(Up);
    //}
    //protected void SelectDate(object sender, EventArgs e)
    //{
    //    Button b = (Button)sender;
    //    string startDateReal = b.CommandArgument;
    //    Session["SelectedStartDate"] = startDateReal;
    //    Literal lab = (Literal)CategoryDaysPanel.FindControl("dateLiteral");
    //    lab.Text = "<div style=\"clear: both; float: right;\"><label>Selected Start Date: </label><span " +
    //        "class=\"AddGreenLinkBig\">" + startDateReal + "</span></div><div style=\"clear: both;\">";
    //    UpdatePanel up = (UpdatePanel)CategoryDaysPanel.FindControl("Up");
    //    up.Update();
    //}
    //protected void next4Click(object sender, EventArgs e)
    //{
    //    //CategoryDaysPanel.Controls.Clear();
    //    Session["UserAvailableDate"] = ((DateTime)Session["UserAvailableDate"]).AddDays(4);
    //    bool isBig = false;
    //    if (AdPlacementList.SelectedValue == "0.04")
    //        isBig = true;
    //    GetAvailableUsers((DateTime)Session["UserAvailableDate"], isBig);
    //}
    //protected void prev4Click(object sender, EventArgs e)
    //{
    //    CategoryDaysPanel.Controls.Clear();
    //    Session["UserAvailableDate"] = ((DateTime)Session["UserAvailableDate"]).AddDays(-4);
    //    bool isBig = false;
    //    if (AdPlacementList.SelectedValue == "0.04")
    //        isBig = true;
    //    GetAvailableUsers((DateTime)Session["UserAvailableDate"], isBig);
    //}
    private void FillLiteral()
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        if (bool.Parse(isFeatured.Text))
        {
            FeaturedWeWouldPanel.Visible = true;
            bool isBig = false;
            if (AdPlacementList.SelectedValue == "0.04")
                isBig = true;
            FeaturedPreviewPanel.Visible = true;
            int integer = 2;
            string username = dat.GetDataDV("select * from Users where user_id=" + Session["User"].ToString())[0]["UserName"].ToString();
            string email = "";
            if (AdPictureCheckList.Items.Count == 0 || !AdMediaPanel.Visible)
                email = GetEmailString(AdNameTextBox.THE_TEXT, null,
                 null, SummaryTextBox.InnerHtml, username, isBig, ref integer);
            else
                email = GetEmailString(AdNameTextBox.THE_TEXT, AdPictureCheckList.Items[0].Value,
                 null, SummaryTextBox.InnerHtml, username, isBig, ref integer);

            if (!isBig)
                email += "</tr>";

            email = "<table>" + email + "</table>";
            FeaturedPreviewLiteral.Text = email;
        }
        else
        {
            FeaturedWeWouldPanel.Visible = false;
        }

        EventPanel.Visible = true;
        ShowHeaderName.Text = AdNameTextBox.THE_TEXT;
        ShowDescription.Text = dat.BreakUpString(DescriptionTextBox.Content, 60);

        Rotator1.Items.Clear();
        char[] delim = { '\\' };
        string[] fileArray;

        string[] finalFileArray = new string[PictureCheckList.Items.Count];

        if (System.IO.Directory.Exists(MapPath(".") + "\\UserFiles\\" +
             Session["UserName"].ToString() + "\\AdSlider\\"))
        {
            fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" +
                 Session["UserName"].ToString() + "\\AdSlider\\");

        }

        //for (int i = 0; i < PictureCheckList.Items.Count; i++)
        //{
        //    finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" +
        //        Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value;
        //}
        char[] delim2 = { '.' };
        for (int i = 0; i < PictureCheckList.Items.Count; i++)
        {
            Literal literal4 = new Literal();
            string[] tokens = PictureCheckList.Items[i].Value.ToString().Split(delim2);
            if (tokens.Length >= 2)
            {
                if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF")
                {
                    System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + PictureCheckList.Items[i].Value.ToString());

                    int width = 410;
                    int height = 250;

                    int newHeight = image.Height;
                    int newIntWidth = image.Width;

                    ////if image height is less than resize height
                    //if (height >= image.Height)
                    //{
                    //    //leave the height as is
                    //    newHeight = image.Height;

                    //    if (width >= image.Width)
                    //    {
                    //        newIntWidth = image.Width;
                    //    }
                    //    else
                    //    {
                    //        newIntWidth = width;

                    //        double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                    //        double newDoubleHeight = double.Parse(newHeight.ToString());
                    //        newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                    //        newHeight = (int)newDoubleHeight;
                    //    }
                    //}
                    ////if image height is greater than resize height...resize it
                    //else
                    //{
                    //    //make height equal to the requested height.
                    //    newHeight = height;

                    //    //get the ratio of the new height/original height and apply that to the width
                    //    double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                    //    double newDoubleWidth = double.Parse(newIntWidth.ToString());
                    //    newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                    //    newIntWidth = (int)newDoubleWidth;

                    //    //if the resized width is still to big
                    //    if (newIntWidth > width)
                    //    {
                    //        //make it equal to the requested width
                    //        newIntWidth = width;

                    //        //get the ratio of old/new width and apply it to the already resized height
                    //        theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                    //        double newDoubleHeight = double.Parse(newHeight.ToString());
                    //        newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                    //        newHeight = (int)newDoubleHeight;
                    //    }
                    //}

                    literal4.Text = "<div style=\"width: 410px; height: 250px;background-color: black;\"><img style=\"cursor: pointer; margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                        + "UserFiles/" + Session["UserName"].ToString() + "/AdSlider/" + PictureCheckList.Items[i].Value.ToString() + "\" /></div>";

                }
                else if (tokens[1].ToUpper() == "WMV")
                {
                    literal4.Text = "<object><param  name=\"wmode\" value=\"opaque\" ></param><embed wmode=\"opaque\" height=\"250px\" width=\"410px\" src=\""
                        + "UserFiles/" + Session["UserName"].ToString() + "/AdSlider/" + PictureCheckList.Items[i].Value.ToString() +
                        "\" /></object>";
                }
            }
            else
            {
                literal4.Text = "<div style=\"float:left;\"><object width=\"410\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"410\" height=\"250\"></embed></object></div>";
            }

            Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
            r4.Controls.Add(literal4);
            Rotator1.Items.Add(r4);
        }

        if (Rotator1.Items.Count == 0)
            RotatorPanel.Visible = false;
        else
            RotatorPanel.Visible = true;

        if (Rotator1.Items.Count == 1)
            RotatorPanel.CssClass = "HiddeButtons";
        else
            RotatorPanel.CssClass = "";

        //if (MainAttractionCheck.Checked)
        //{
        //    if (MainAttractionRadioList.SelectedValue == "0")
        //    {
        //        Rotator1.Items.Clear();
        //        RotatorPanel.Visible = false;
        //        if (VideoPictureRadioList.SelectedValue == "0")
        //        {
        //            if (PictureCheckList.Items.Count != 0)
        //                ShowVideoPictureLiteral.Text = "<img style=\"float: left; padding-right: 10px; padding-top: 9px;\" height=\"250px\" width=\"440px\" src=\"UserFiles/" + PictureCheckList.Items[0].Value + "\" />";
        //        }
        //        else
        //        {
        //            if (VideoRadioList.SelectedValue == "0")
        //            {
        //                //ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><embed  height=\"250px\" width=\"440px\" src=\"UserFiles/" + VideoCheckList.Items[0].Text + "\" /></div>";
        //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><object width=\"440\" height=\"250\"><param name=\"movie\" value=\"UserFiles/" + VideoCheckList.Items[0].Text + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"UserFiles/" + VideoCheckList.Items[0].Text + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"440\" height=\"250\"></embed></object></div>";
        //            }
        //            else
        //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><object width=\"440\" height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + YouTubeTextBox.Text + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/" + YouTubeTextBox.Text + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"440\" height=\"250\"></embed></object></div>";
        //        }
        //    }
        //    else
        //    {
        //        ShowVideoPictureLiteral.Text = "";
        //        if (SliderCheckList.Items.Count > 0)
        //        {
        //            char[] delim = { '\\' };
        //            string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\");

        //            string[] finalFileArray = new string[fileArray.Length];

        //            for (int i = 0; i < SliderCheckList.Items.Count; i++)
        //            {
        //                finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" +
        //                     Session["UserName"].ToString() + "/AdSlider/" + SliderCheckList.Items[i].Value;
        //            }

        //            Rotator1.DataSource = finalFileArray;
        //            Rotator1.DataBind();
        //            RotatorPanel.Visible = true;
        //        }
        //    }
        //}
    }
    protected string GetEmailString(string header, string picture, string ID, string description,
        string userName, ref int normalAdCount, string templateID)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];

        DateTime isn = DateTime.Now;

        if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
            isn = DateTime.Now;
        DateTime isNow = isn;
        Data dat = new Data(isn); string adtitle = "style=\"color: #7c7a7a;font-size: 14px;font-weight: bold;text-decoration: none;\"";
        string adbody = "style=\"color: #7c7a7a;font-size: 12px;font-weight: normal;\"";
        string readmorelink = "style=\"color: #09718F;text-decoration: none;cursor: pointer;\"";
        string email = "";

        string w = "";
        string h = "";

        if (normalAdCount % 2 == 0)
        {
            email += "<tr><td>";
        }
        else
        {
            email += "<td>";
        }
        email += "<div align=\"center\" style=\"position: relative;float: left;width: 198px; height: 262px;border: solid 1px #d9d6d6; " +
                        "margin-right: 2px; " +
            "\">";

        if (picture == null)
        {
            email += "<div style=\"padding-top: 10px; clear: both; padding-left: 1px;\">";
        }
        else
        {

            GetAdSize(out w, out h, picture, templateID);

            if (templateID == "1")
            {
                email += "<div style=\"padding-top: 10px; clear: both; padding-left: 1px;\"><div style=\"float: left;padding-right: 2px;\"><table width=\"100px\" height=\"100px\" " +
                                "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\">";
            }
            else if (templateID == "2")
            {
                email += "<div style=\"padding-top: 10px; clear: both;\"><div style=\"float: left;padding-right: 2px;\"><table width=\"198px\" height=\"140px\" " +
                                "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\"> ";
            }
            else
            {
                email += "<div style=\"clear: both;\"><div center=\"float\" style=\"float: left;\"><table width=\"198px\" height=\"262px\" " +
                                "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\"> ";
            }

            if (ID == null)
            {
                email += "<img alt=\"" + header + "\" " +
                    "name=\"" + header + "\" width='" + w + "px' height='" + h + "px' src=\"./UserFiles/" +
                    userName + "/" + picture + "\" /></td></tr></tbody></table></div>";
            }
            else
            {
                email += "<a href=\"http://HippoHappenings.com/" + dat.MakeNiceName(header) + "_" + ID + "_Ad" +
              "\" ><img style='border: 0;' alt=\"" + header + "\" " +
                    "name=\"" + header + "\" width='" + w + "px' height='" + h + "px' src=\"http://hippohappenings.com/UserFiles/" +
                    userName + "/" + picture + "\" /></a></td></tr></tbody></table></div>";
            }

        }

        if (ID == null)
        {
            if (templateID == "1")
            {
                email += "<div><a class=\"Text14\">" + dat.BreakUpString(header, 10) +
                                    "</a></div></div>" +
                        "<div align=\"center\" style=\"clear: both; padding-left: 2px; padding-right: 2px;" +
                        "padding-top: 1px;\"> " +
                        "<span class=\"Text12\">" +
                        dat.BreakUpString(description, 21) + "</span>" +

                        "</div>" +
                        "<div style=\"clear: none;\"><a class=\"ReadMoreHome2\">Read More</a>" +
                        "</div></div>";
            }
            else if (templateID == "2")
            {
                email += "</div><div style=\"padding-top: 5px; clear: both;  padding-right: 4px;padding-left: 4px;\"><a class=\"Text14\">" +
                    dat.BreakUpString(header, 21) +
                                    "</a></div>" +
                        "<div align=\"center\" style=\"clear: both; padding-left: 4px; padding-right: 4px;\"> " +
                        "<span class=\"Text12\">" +
                        dat.BreakUpString(description, 21) + "</span>" +
                        "</div>" +
                        "<div style=\"clear: none;\"><a class=\"ReadMoreHome2\">Read More</a>" +
                        "</div></div>";
            }
        }
        else
        {
            if (templateID == "1")
            {
                email += "<div><a href=\"../" + dat.MakeNiceName(header) +
                                    "_" + ID + "_Ad\" class=\"Text14\">" + dat.BreakUpString(header, 10) +
                                    "</a></div></div>" +
                        "<div align=\"center\" style=\"clear: both; padding-left: 2px; padding-right: 2px;" +
                        "padding-top: 1px;\"> " +
                        "<span class=\"Text12\">" +
                        dat.BreakUpString(description, 21) + "</span>" +

                        "</div>" +
                        "<div style=\"clear: none;\"><a class=\"ReadMoreHome2\" href=\"../" +
                        dat.MakeNiceName(header) +
                                    "_" + ID + "_Ad\">Read More</a>" +
                        "</div></div>";
            }
            else if (templateID == "2")
            {
                email += "</div><div style=\"padding-top: 5px; clear: both; padding-right: 4px;padding-left: 4px;\"><a href=\"../" +
                    dat.MakeNiceName(header) +
                                    "_" + ID + "_Ad\" class=\"Text14\">" + dat.BreakUpString(header, 21) +
                                    "</a></div>" +
                        "<div align=\"center\" style=\"clear: both; padding-left: 4px; padding-right: 4px;\"> " +
                        "<span class=\"Text12\">" +
                        dat.BreakUpString(description, 21) + "</span>" +
                        "</div>" +
                        "<div style=\"clear: none;\"><a class=\"ReadMoreHome2\" href=\"../" +
                        dat.MakeNiceName(header) +
                                    "_" + ID + "_Ad\">Read More</a>" +
                        "</div></div>";
            }
        }
        if (normalAdCount % 2 == 0)
        {
            email += "</td>";
        }
        else
        {
            email += "</td></tr>";
        }

        normalAdCount++;

        return email;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page.Trace.IsEnabled = true;
        //Page.Trace.TraceMode = TraceMode.SortByTime;

        try
        {
            HtmlMeta hm = new HtmlMeta();
            HtmlMeta kw = new HtmlMeta();

            HtmlHead head = (HtmlHead)Page.Header;

            hm.Name = "Description";
            hm.Content = "Find your local events, venues and classifieds all while " +
                     "ads from your peers, neighborhood, and community are displayed to you purely based on your interests." +
                     "Large corporations are not welcome!";
            head.Controls.AddAt(0, hm);

            HtmlMeta nMT = new HtmlMeta();
            nMT.Name = "google-site-verification";
            nMT.Content = "tw8rmOWW-DlZa-H4DZdGr201J5kC7NVLXUmk5oN8vFM";

            head.Controls.Add(nMT);

            HtmlLink lkl = new HtmlLink();
            lkl.Href = "ror.xml";
            lkl.Attributes.Add("rel", "alternate");
            lkl.Attributes.Add("type", "application/xml");
            lkl.Attributes.Add("title", "ROR");

            head.Controls.Add(lkl);

            HttpCookie cookie = Request.Cookies["BrowserDate"];
            if (cookie == null)
            {
                cookie = new HttpCookie("BrowserDate");
                cookie.Value = DateTime.Now.Date.ToString();
                cookie.Expires = DateTime.Now.AddDays(22);
                Response.Cookies.Add(cookie);
            }
            bool fillUserData = false;
            Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":").Replace("%28", "(").Replace("%29", ")")));

            kw.Name = "keywords";
            kw.Content = "events, ads, venues, post, search, find, local events, concerts, festivals, world, theatre, technology, " +
                "family, peers, neighborhood, classifieds";

            DataView dvCats = dat.GetDataDV("SELECT * FROM AdCategories");

            for (int i = 0; i < dvCats.Count; i++)
            {
                kw.Content += ", " + dvCats[i]["Name"].ToString();
            }

            dvCats = dat.GetDataDV("SELECT * FROM EventCategories");

            for (int i = 0; i < dvCats.Count; i++)
            {
                kw.Content += ", " + dvCats[i]["Name"].ToString();
            }

            dvCats = dat.GetDataDV("SELECT * FROM VenueCategories");

            for (int i = 0; i < dvCats.Count; i++)
            {
                kw.Content += ", " + dvCats[i]["Name"].ToString();
            }

            head.Controls.AddAt(0, kw);

            string cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

                //logInPanel.Visible = Session["User"] == null;
                //loggedInPanel.Visible = Session["User"] != null;

            string country = "";
            string state = "";
            string city = "";
            string countryID = "";
            string stateID = "";
            string cityID = "";
            FormsAuthenticationTicket authTicket = null;
            try
            {
                string group = "";
                if (authCookie != null)
                {
                    authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                    group = authTicket.UserData.ToString();
                }

                if (group.Contains("User"))
                {
                    Session["User"] = authTicket.Name;
                    DataSet ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE U.User_ID=" +
                        authTicket.Name + " AND U.User_ID=UP.UserID ");
                    Session["UserName"] = ds1.Tables[0].Rows[0]["UserName"].ToString();

                    country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                    countryID = country;

                    state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                    city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                    stateID = state;
                    cityID = city;

                    //DataSet ds2 = dat.RetrieveAds(Session["User"].ToString(), false);
                    //DataSet dsMain = dat.RetrieveMainAds(Session["User"].ToString());
                    //Ads1.DATA_SET = ds2;
                    //Ads1.MAIN_AD_DATA_SET = dsMain;

                    fillUserData = true;
                }
                else
                {
                    DataSet ds1 = dat.GetData("SELECT * FROM SearchIPs WHERE IP='" + dat.GetIP() + "'");

                    bool getAnotherDs1 = false;
                    if (ds1.Tables.Count > 0)
                        if (ds1.Tables[0].Rows.Count > 0)
                        {
                            country = ds1.Tables[0].Rows[0]["Country"].ToString();
                            countryID = country;
                            state = ds1.Tables[0].Rows[0]["State"].ToString();
                            city = ds1.Tables[0].Rows[0]["City"].ToString();
                            stateID = state;
                            cityID = city;
                        }
                        else
                        {
                            getAnotherDs1 = true;
                        }
                    else
                    {
                        getAnotherDs1 = true;
                    }

                    if (getAnotherDs1)
                    {
                        ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE " +
                            " U.User_ID=UP.UserID AND U.IPs LIKE '%" + dat.GetIP() + "%'");
                        if (ds1.Tables.Count > 0)
                            if (ds1.Tables[0].Rows.Count > 0)
                            {
                                country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                                countryID = country;
                                state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                                city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                                stateID = state;
                                cityID = city;
                            }
                    }

                    //if (!IsPostBack)
                    //{
                    //    Ads1.DATA_SET = dat.RetrieveAllAds(false);
                    //    Ads1.MAIN_AD_DATA_SET = dat.RetrieveAllAds(true);
                    //}
                    Button calendarLink = (Button)dat.FindControlRecursive(this, "CalendarLink");
                    calendarLink.Visible = false;

                }
            }
            catch (Exception ex)
            {

            }

            DataSet ds;

            if (!IsPostBack)
            {
                LocationLabel.Text = "";
                if (country != "")
                    country = " AND E.Country = " + country;

                int c = 0;

                if (state != "")
                {

                    c++;
                }

                if (city != "")
                {

                    c++;
                }

                SqlDbType[] types = new SqlDbType[c];
                object[] data = new object[c];

                if (state != "")
                {
                    types[0] = SqlDbType.NVarChar;
                    data[0] = state;
                    state = " AND E.State=@p0 ";
                    if (city != "")
                    {
                        types[1] = SqlDbType.NVarChar;
                        data[1] = city;
                        city = " AND E.City=@p1 ";
                    }
                }
                else
                {
                    if (city != "")
                    {
                        types[0] = SqlDbType.NVarChar;
                        data[0] = city;
                        city = " AND E.City=@p0 ";
                    }
                }

                ds = dat.GetDataWithParemeters("SELECT DISTINCT TOP 10 EO.DateTimeStart, E.Header, E.Content, EO.EventID FROM Events E, Event_Occurance EO WHERE E.ID=EO.EventID " + country + state + city + " AND EO.DateTimeStart > '" + DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date + "'", types, data);

                Session["HomeEvents"] = ds;
                LocationLabel.Text = "";
                if (country == "" && state == "" && city == "")
                {
                    LocationLabel.Text = " The World ";
                }
                else
                {
                    if (city != "")
                    {
                        LocationLabel.Text += cityID;
                        if (state != "")
                            LocationLabel.Text += ", " + stateID;
                    }
                    else
                    {
                        if (state != "")
                            LocationLabel.Text += stateID;
                    }
                }

                if (LocationLabel.Text == "")
                {
                    DataSet dsCountry = dat.GetData("SELECT * FROM Countries WHERE country_id=" + countryID);
                    LocationLabel.Text = dsCountry.Tables[0].Rows[0]["country_name"].ToString();
                }
            }
            else
            {
                EventPanel.Controls.Clear();
                LocationLabel.Text = "";
                ds = (DataSet)Session["HomeEvents"];

                if (countryID == "" && stateID == "" && cityID == "")
                {
                    LocationLabel.Text = " The World ";
                }
                else
                {
                    if (cityID != "")
                    {
                        LocationLabel.Text += cityID;
                        if (state != "")
                            LocationLabel.Text += ", " + stateID;
                    }
                    else
                    {
                        if (state != "")
                            LocationLabel.Text += stateID;
                    }
                }

                if (RadCalendar1.SelectedDate.ToShortDateString() != "1/1/0001")
                    LocationLabel.Text += " on " + RadCalendar1.SelectedDate.ToShortDateString();

            }

            ds = (DataSet)Session["HomeEvents"];

            if (ds != null)
            {

                if (ds.Tables.Count > 0)
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            DateTime date = DateTime.Parse(ds.Tables[0].Rows[i]["DateTimeStart"].ToString());
                            ASP.controls_homeevent_ascx eventH = new ASP.controls_homeevent_ascx();
                            eventH.DAY = date.DayOfWeek.ToString().Substring(0, 3);
                            eventH.DAY_NUMBER = date.Day.ToString();
                            eventH.MONTH = dat.GetMonth(date.Month.ToString()).Substring(0, 3);
                            eventH.EVENT_NAME = ds.Tables[0].Rows[i]["Header"].ToString();
                            if (ds.Tables[0].Rows[i]["Content"].ToString().Length > 150)
                                eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString().Substring(0, 150), 67) + "...";
                            else
                                eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString(), 67) + "...";
                            eventH.EVENT_ID = int.Parse(ds.Tables[0].Rows[i]["EventID"].ToString());
                            EventPanel.Controls.Add(eventH);
                        }

                    }
                    else
                    {

                        Label label = new Label();
                        label.CssClass = "EventBody";
                        label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                        EventPanel.Controls.Add(label);
                    }
                else
                {

                    Label label = new Label();
                    label.CssClass = "EventBody";
                    label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                    EventPanel.Controls.Add(label);
                }
            }
            else
            {

                Label label = new Label();
                label.CssClass = "EventBody";
                label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                EventPanel.Controls.Add(label);
            }

            #region Original Home page code
            //if (ds.Tables.Count > 0)
            //{
            //    if (ds.Tables[0].Rows.Count > 0)
            //    {

            //        ASP.controls_footer_ascx thefooter = (ASP.controls_footer_ascx)dat.FindControlRecursive(this, "TheFooter");
            //        thefooter.EVENT_ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());

            //        string ID = ds.Tables[0].Rows[0]["ID"].ToString();
            //        DataSet dsDate = dat.GetData("SELECT * FROM Event_Occurance WHERE EventID=" + ID);
            //        DataSet dsVenue = dat.GetData("SELECT * FROM Venues WHERE ID=" + ds.Tables[0].Rows[0]["Venue"]);
            //        TagCloud.THE_ID = int.Parse(ID);

            //        DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID +" ORDER BY C.BlogDate");
            //        TheComments.DATA_SET = dsComments;
            //        TheComments.DataBind2(true);

            //        if (bool.Parse(ds.Tables[0].Rows[0]["hasSongs"].ToString()))
            //        {
            //            DataSet dsSongs = dat.GetData("SELECT * FROM Event_Song_Mapping WHERE EventID=" + ID);
            //            ASP.controls_songplayer_ascx songs = new ASP.controls_songplayer_ascx();
            //            int songCount = dsSongs.Tables[0].Rows.Count;

            //            if (songCount > 2)
            //            {
            //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
            //                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
            //                songs.SONG3 = dsSongs.Tables[0].Rows[2]["SongName"].ToString();
            //            }
            //            else if (songCount > 1)
            //            {
            //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
            //                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
            //            }
            //            else
            //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();

            //            songs.USER_NAME = ds.Tables[0].Rows[0]["UserName"].ToString();

            //            SongPanel.Controls.Add(songs);
            //        }

            //        EventName.Text = ds.Tables[0].Rows[0]["Header"].ToString();
            //        Session["Subject"] = "Re: "+ds.Tables[0].Rows[0]["Header"].ToString();
            //        Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
            //        EventName.NavigateUrl = "~/Event.aspx?EventID=" + ID;
            //        Session["EventID"] = ID;
            //        VenueName.Text = dsVenue.Tables[0].Rows[0]["Name"].ToString();
            //        VenueName.NavigateUrl = "Venue.aspx?ID="+dsVenue.Tables[0].Rows[0]["ID"].ToString();
            //        DateTime date = (DateTime)dsDate.Tables[0].Rows[0]["DateTimeStart"];
            //        DateAndTimeLabel.Text = date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " + date.Day + " " + date.Hour + ":" + date.Minute;
            //        string content = ds.Tables[0].Rows[0]["Content"].ToString();
            //        SendTxtID.MESSAGE = EventName.Text + " occurs at " + VenueName.Text + " on " + DateAndTimeLabel.Text;

            //        string href = Request.Url.AbsoluteUri;
            //        SendEmailID.MESSAGE = "EventName: <a class=\"AddLink\" href=\"" + href +
            //            "\">" + EventName.Text + "</a> \n\r Venue: " + VenueName.Text +
            //            " \n\r Date: " + DateAndTimeLabel.Text + " \n\r " + content;

            //        //if (fillUserData)
            //        //{
            //        //    DataSet ds2 = dat.GetData("SELECT EEL.ExcitmentLevel AS Level FROM User_Calendar UC, Event_ExcitmentLevel EEL WHERE UC.UserID="
            //        //        + Session["User"].ToString() + " AND UC.EventID = " + ID + " AND UC.ExcitmentID=EEL.ID ");

            //        //    bool addEvent = false;

            //        //    if (ds2.Tables.Count > 0)
            //        //        if (ds2.Tables[0].Rows.Count > 0)
            //        //        {
            //        //            Label label = new Label();
            //        //            label.CssClass = "AddLinkGoing";
            //        //            label.Text = "Guess What?!: you're going to this event and you are " + ds2.Tables[0].Rows[0]["Level"].ToString();
            //        //            CalendarPanel.Controls.Add(label);
            //        //        }
            //        //        else
            //        //            addEvent = true;
            //        //    else
            //        //        addEvent = true;

            //        //    if (addEvent)
            //        //    {
            //        //        ASP.controls_addtocalendar_ascx AddTo1 = new ASP.controls_addtocalendar_ascx();
            //        //        AddTo1.ID = "AddTo1";
            //        //        AddTo1.TEXT = "Add this event to calendar";
            //        //        AddTo1.EVENT_ID = int.Parse(ID);
            //        //        CalendarPanel.Controls.Add(AddTo1);
            //        //    }

            //        //}

            //        if (content.Length > 500)
            //        {
            //            ShowDescriptionBegining.Text = content.Substring(0, 500);
            //            int j = 500;
            //            if (content[500] != ' ')
            //            {

            //                while (content[j] != ' ')
            //                {
            //                    ShowDescriptionBegining.Text += content[j];
            //                    j++;
            //                }
            //            }
            //            ShowDescriptionBegining.Text = dat.BreakUpString(ShowDescriptionBegining.Text, 65);
            //            ShowRestOfDescription.Text = dat.BreakUpString(content.Substring(j), 65);
            //        }
            //        else
            //        {
            //            ShowDescriptionBegining.Text = dat.BreakUpString(content, 65);
            //            ShowRestOfDescription.Text = "";
            //        }

            //        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
            //        int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());

            //        switch (mediaCategory)
            //        {
            //            case 0:
            //                break;
            //            case 1:
            //                ShowVideoPictureLiteral.Text = "<img style=\"float: left; padding-right: 10px; padding-top: 9px;\" height=\"250px\" width=\"440px\" src=\"UserFiles/" + ds.Tables[0].Rows[0]["Picture"].ToString() + "\" />";
            //                break;
            //            case 2:
            //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><embed  height=\"250px\" width=\"440px\" src=\"UserFiles/" + ds.Tables[0].Rows[0]["Video"].ToString() + "\" /></div>";
            //                break;
            //            case 3:
            //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><object width=\"440\" height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + ds.Tables[0].Rows[0]["YouTubeVideo"].ToString() + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/" + ds.Tables[0].Rows[0]["YouTubeVideo"].ToString() + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"440\" height=\"250\"></embed></object></div>";
            //                break;
            //            case 4:
            //                ShowVideoPictureLiteral.Text = "";
            //                DataSet dsSlider = dat.GetData("SELECT * FROM Event_Slider_Mapping WHERE EventID=" + ID);
            //                if (dsSlider.Tables.Count > 0)
            //                    if (dsSlider.Tables[0].Rows.Count > 0)
            //                    {
            //                        char[] delim = { '\\' };
            //                        string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\Slider\\");

            //                        string[] finalFileArray = new string[fileArray.Length];

            //                        for (int i = 0; i < fileArray.Length; i++)
            //                        {
            //                            int length = fileArray[i].Split(delim).Length;
            //                            finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + fileArray[i].Split(delim)[length - 1];
            //                        }
            //                        Rotator1.DataSource = finalFileArray;
            //                        Rotator1.DataBind();
            //                        RotatorPanel.Visible = true;
            //                    }
            //                break;
            //            default: break;
            //        }

            //        this.Title = EventName.Text;
            //    }
            //}
            #endregion
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string eventID = GetEventID();
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        try
        {
            Session["RedirectTo"] = Request.Url.AbsoluteUri;

            //Button button = (Button)dat.FindControlRecursive(this, "EventLink");
            //button.CssClass = "NavBarImageEventSelected";

            bool fillUserData = false;

            try
            {

                if (Session["User"] != null)
                {
                    if (Session["User"].ToString() == "1")
                        OnlyHippoPanel.Visible = true;
                    LoggedInPanel.Visible = true;
                    LoggedOutPanel.Visible = false;
                    dat.GetRecommendationIcons(eventID, ref RecomPanel);

                    RecomPanel.Width = 10 * (RecomPanel.Controls.Count);

                    DataSet ds1 = dat.GetData("SELECT UserName FROM Users WHERE User_ID=" + Session["User"].ToString());
                    Session["UserName"] = ds1.Tables[0].Rows[0]["UserName"].ToString();
                    fillUserData = true;

                    EditLink.Visible = true;
                    TopPanel.Visible = true;

                    //Query whether current owner was delinquent on approve/reject changes
                    if (dat.IsOwnerDelinquent(eventID, Request.IsLocal, "E"))
                    {
                        //make the button visable
                        TopPanel.Visible = true;
                        OwnerPanel.Visible = true;
                        Session["Message"] = "The ownership of this event is <b>open</b>. <br/>The ownership became " +
                            "open because the previous owner of this event became un-responsive to rejecting/" +
                            "approving user's changes to this event.<br/>If you would like to become " +
                            "the owner, click on the button below to go to the event's edit page. <br/><br/> " +
                            "Being the owner, you will have the privilage of having your <b>edits come though right " +
                            "away.</b> Other participants' changes to this event will have to be <b>approved by you.</b><br/><br/>" +
                            "<button style=\"cursor: pointer;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                            "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                            "no-repeat; border: 0;\" onclick=\"Search('BlogEvent.aspx?edit=true&ID=" + eventID +
                            "');\" onmouseover=\"this.style.backgroundImage='url(image/PostButtonNoPostHover.png)'\" " +
                            "onmouseout=\"this.style.backgroundImage='url(image/PostButtonNoPost.png)'\">Edit</button>" +
                            "<button style=\"cursor: pointer;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                            "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                            "no-repeat; border: 0;\" onclick=\"Search();\" " +
                            "onmouseover=\"this.style.backgroundImage='url(image/PostButtonNoPostHover.png)'\" " +
                            "onmouseout=\"this.style.backgroundImage='url(image/PostButtonNoPost.png)'\">Close</button>";
                    }
                }
                else
                {
                    LoggedOutPanel.Visible = true;
                    LoggedInPanel.Visible = false;
                    //Button calendarLink = (Button)dat.FindControlRecursive(this, "CalendarLink");
                    //calendarLink.Visible = false;
                    //EditLink.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }

            if (ReturnPanel.Visible)
            {
                if (EditLink.Visible)
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 430;
                    }
                    else
                    {
                        TopPanel.Width = 240;
                    }
                }
                else
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 300;
                    }
                    else
                    {
                        TopPanel.Width = 150;
                    }
                }
            }
            else
            {
                if (EditLink.Visible)
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 250;
                    }
                    else
                    {
                        TopPanel.Width = 80;

                    }
                    EditLink.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Edit Event";
                }
                else
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 160;
                    }
                    else
                    {
                        TopPanel.Width = 0;
                    }
                    HyperLink1.InnerHtml = "&nbsp;&nbsp;&nbsp;&nbsp;Event Ownership is Open";
                }
            }

            //Overwrite everything if the event has passed
            if (dat.HasEventPassed(eventID))
            {
                OwnerPanel.Visible = false;
                EditLink.Visible = false;
                PassedLink.Visible = true;
                if (ReturnPanel.Visible)
                {
                    TopPanel.Width = 300;
                    PassedLink.Text = "|&nbsp;&nbsp;&nbsp;&nbsp;This event has passed";
                }
                else
                {
                    TopPanel.Width = 125;
                }
            }

            if (Request.QueryString["EventID"] == null)
                Response.Redirect("~/Home.aspx");
            string ID = eventID;
            Session["EventID"] = ID;
            DataSet ds = dat.GetData("SELECT * FROM Events WHERE ID=" + ID);

            Session["FlagID"] = ID;
            Session["FlagType"] = "E";

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (bool.Parse(ds.Tables[0].Rows[0]["Live"].ToString()))
                    {

                        if(ds.Tables[0].Rows[0]["BuyAtTix"] != null)
                            if (ds.Tables[0].Rows[0]["BuyAtTix"].ToString().Trim() != "")
                            {
                                BuyAtTix.Text = "<div style=\"position: relative;\"><div class=\"AddLink\" style=\"padding-top: 5px;float: left;\">Buy Tickets at:&nbsp;&nbsp;</div><a style=\"float: left;background-image: url(http://b1.perfb.com/b1.php?ID=14235&amp;PURL=ticketsus.at/HippoHappenings); background-repeat: no-repeat; width: 110px; display: block; height: 50px; background-position: 0 -75px;\" target=\"_blank\" href=\"" +
                                    ds.Tables[0].Rows[0]["BuyAtTix"].ToString() +
                                    "\"></a></div>";
                            }
                        EventName.Text = "<a style=\"text-decoration: none; color: white;\" href=\"http://" + Request.Url.Authority + "/" +
                            dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) +
                            "_" + ID.ToString() + "_Event\">" +
                            dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "</a>";
                        Session["Subject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
                        Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
                        string UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                        DataSet dsDate = dat.GetData("SELECT * FROM Event_Occurance WHERE EventID=" + ID);
                        DataSet dsVenue = dat.GetData("SELECT * FROM Venues WHERE ID=" +
                            ds.Tables[0].Rows[0]["Venue"]);
                        TagCloud.THE_ID = int.Parse(ID);
                        NumberPeopleLabel.Text = dat.GetData("SELECT DISTINCT UserID FROM User_Calendar " +
                            "WHERE EventID=" + ID).Tables[0].Rows.Count.ToString() + " People";

                        if (Session["User"] != null)
                        {
                            DataSet dsFriends = dat.GetData("SELECT DISTINCT UC.EventID, UC.UserID FROM User_Friends UF, User_Calendar UC " +
                                "WHERE UC.EventID=" +
                                ID + " AND UC.UserID=UF.FriendID AND UF.UserID=" + Session["User"].ToString());

                            CommunicateLiteral.Text = "<img style=\"float:right;\" src=\"image/CommunicateButton.png\" onmouseover=\"this.src='image/CommunicateButtonSelected.png'\" onmouseout=\"this.src='image/CommunicateButton.png'\" onclick=\"javascript:OpenRad('" +
                                ID + "');\"/>";

                            int count = 0;
                            if (dsFriends.Tables.Count > 0)
                                if (dsFriends.Tables[0].Rows.Count > 0)
                                {
                                    count = dsFriends.Tables[0].Rows.Count;
                                }

                            NumberFriendsLabel.Text = "(" + count.ToString() + " Friends)";
                        }
                        else
                        {
                            CommunicateLiteral.Text = "</td></tr><tr><td><div style=\"float: left; clear: both; width: 450px;\">To communicate with people going to this event, please <a class=\"AddLink\" href=\"UserLogin.aspx\">log in.</a></div>";
                        }

                        if (bool.Parse(ds.Tables[0].Rows[0]["hasSongs"].ToString()))
                        {
                            DataSet dsSongs = dat.GetData("SELECT * FROM Event_Song_Mapping WHERE EventID=" + ID);
                            ASP.controls_playerxml_songplayer_ascx songs = new ASP.controls_playerxml_songplayer_ascx();
                            int songCount = dsSongs.Tables[0].Rows.Count;

                            if (songCount > 2)
                            {
                                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                                songs.SONG3 = dsSongs.Tables[0].Rows[2]["SongName"].ToString();
                                songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                                songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                                songs.SONG3_TITLE = dsSongs.Tables[0].Rows[2]["SongTitle"].ToString();
                            }
                            else if (songCount > 1)
                            {
                                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                                songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                                songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                            }
                            else if(songCount == 1)
                            {
                                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                            }

                            songs.USER_NAME = ds.Tables[0].Rows[0]["UserName"].ToString();

                            SongPanel.Controls.Add(songs);
                        }

                        VenueName.Text = dsVenue.Tables[0].Rows[0]["Name"].ToString();
                        VenueName.NavigateUrl = dat.MakeNiceName(dsVenue.Tables[0].Rows[0]["Name"].ToString()) +
                            "_" + dsVenue.Tables[0].Rows[0]["ID"].ToString() + "_Venue";

                        DateTime date;
                        DateTime endDate;
                        DateAndTimeLabel.Text = "";
                        string dateandtime = "";
                        bool dateGotten = false;
                        string moreDates = "";
                        for (int i = 0; i < dsDate.Tables[0].Rows.Count; i++)
                        {

                            date = DateTime.Parse(dsDate.Tables[0].Rows[i]["DateTimeStart"].ToString());
                            endDate = DateTime.Parse(dsDate.Tables[0].Rows[i]["DateTimeEnd"].ToString());

                            if ((endDate >= DateTime.Now && !dateGotten) || (i == dsDate.Tables[0].Rows.Count - 1 && !dateGotten))
                            {
                                dateGotten = true;
                                dateandtime += date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " +
                                    date.Day + " " + date.ToShortTimeString() + " To " +
                                    endDate.DayOfWeek.ToString() + ", " + GetMonth(endDate.Month.ToString()) + " " +
                                    endDate.Day + " " + endDate.ToShortTimeString();
                                DateAndTimeLabel.Text += date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " +
                                    date.Day + " " + date.ToShortTimeString()
                                    + " <span style=\"color: #cccccc; font-weight: bold;\">To</span> " +
                                    endDate.DayOfWeek.ToString() + ", " + GetMonth(endDate.Month.ToString()) + " " +
                                    endDate.Day + " " + endDate.ToShortTimeString();
                            }
                            else
                            {

                                if (moreDates == "")
                                    moreDates = "<div onclick=\"OpenMoreDates();\" style=\"cursor: pointer;\" class=\"AddLink\" id=\"MoreDatesName\">More Dates</div>" +
                                        "<div style=\"display: none;\" id=\"infoDiv\">" +
                                        (dsDate.Tables[0].Rows.Count * 40).ToString() +
                                        "</div><div style=\"display: none; background-color: #333333; padding: 10px;\" " +
                                        "id=\"MoreDatesDiv\"> <div class=\"AddLink\" style=\"float: right; cursor: pointer; font-style: none;\" " +
                                               "onclick=\"OpenMoreDates();\">close</div><br/><br/>";
                                moreDates += date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " +
                                    date.Day + " " + date.ToShortTimeString()
                                    + " <span style=\"color: #cccccc; font-weight: bold;\">To</span> " +
                                    endDate.DayOfWeek.ToString() + ", " + GetMonth(endDate.Month.ToString()) + " " +
                                    endDate.Day + " " + endDate.ToShortTimeString() + "<br/>";
                            }

                        }
                        if (moreDates != "")
                            moreDates += "</div>";

                        DateAndTimeLabel.Text += moreDates;

                        string content = ds.Tables[0].Rows[0]["Content"].ToString();
                        string niceName = dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString());

                        ScriptLiteral.Text = "<script type=\"text/javascript\">ReturnURL('" + niceName.Replace("_", " ") + " at " + dat.MakeNiceName(dsVenue.Tables[0].Rows[0]["Name"].ToString()).Replace("_", " ") + " Tonight http://HippoHappenings.com/" + Request.QueryString["EventID"].ToString() + "_Event');</script>";

                        if (Session["User"] != null)
                        {
                            DataSet dsComments;
                            string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                            if (commentPrefs == "1")
                            {
                                dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                            }
                            else
                            {
                                dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, C.Comment, C.BlogDate AS theDate FROM Comments C, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=C.UserID) OR (U.User_ID=" +
                                    Session["User"].ToString() + " AND U.User_ID=C.UserID)) AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                            }
                            TheComments.DATA_SET = dsComments;
                            TheComments.DataBind2(true);
                        }
                        else
                        {
                            DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                            TheComments.DATA_SET = dsComments;
                            TheComments.DataBind2(true);
                        }

                        ShowDescriptionBegining.Text = dat.BreakUpString(content, 60);

                        //Create keyword and description meta tags and title
                        HtmlMeta hm = new HtmlMeta();
                        HtmlMeta kw = new HtmlMeta();

                        HtmlHead head = (HtmlHead)Page.Header;

                        kw.Name = "keywords";
                        kw.Content = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + ", " + VenueName.Text + ", " +
                            dsVenue.Tables[0].Rows[0]["City"].ToString() + ", " +
                            dsVenue.Tables[0].Rows[0]["State"].ToString();

                        HtmlLink lk = new HtmlLink();
                        lk.Href = "http://" + Request.Url.Authority + "/" +
                            dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) +
                            "_" + ID.ToString() + "_Event";
                        lk.Attributes.Add("rel", "bookmark");
                        head.Controls.AddAt(0, lk);

                        DataView dvCats = dat.GetDataDV("SELECT DISTINCT C.ID, ECM.ID AS EID, C.Name AS CategoryName, ECM.tagSize FROM Event_Category_Mapping ECM, EventCategories C WHERE ECM.CategoryID=C.ID AND ECM.EventID=" + eventID + " ORDER BY ECM.ID");

                        string justCats = "";

                        for (int i = 0; i < dvCats.Count; i++)
                        {
                            kw.Content += ", " + dvCats[i]["CategoryName"].ToString();
                            justCats += dvCats[i]["CategoryName"].ToString()+ " ";
                        }

                        head.Controls.AddAt(0, kw);

                        hm.Name = "Description";
                        hm.Content = ShowDescriptionBegining.Text + ", " + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + ", " + VenueName.Text + ", " + kw.Content;
                        head.Controls.AddAt(0, hm);

                        this.Title = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " | " + justCats + " | HippoHappenings";

                        Session["messageText"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " occurs at " + VenueName.Text + " on " + dateandtime;
                        Session["messageEmail"] = "EventName: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) + "_" + ID + "_Event\">" +
                            dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "</a> <br/><br/> Venue: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(VenueName.Text) + "_" +
                            dsVenue.Tables[0].Rows[0]["ID"].ToString() + "_Venue\">" + VenueName.Text + "</a> <br/><br/> Date: " +
                            DateAndTimeLabel.Text + " <br/><br/> " + ShowDescriptionBegining.Text;

                        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                        Rotator1.Items.Clear();
                        int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());
                        string youtube = ds.Tables[0].Rows[0]["YouTubeVideo"].ToString();
                        switch (mediaCategory)
                        {
                            case 0:
                                break;
                            case 1:
                                ShowVideoPictureLiteral.Text = "";
                                char[] delim4 = { ';' };
                                string[] youtokens = youtube.Split(delim4);
                                if (youtube != "")
                                {
                                    for (int i = 0; i < youtokens.Length; i++)
                                    {
                                        if (youtokens[i].Trim() != "")
                                        {
                                            Literal literal3 = new Literal();
                                            //literal3.Text = "<object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ><param name=\"movie\" value=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"250\"></embed></object>";
                                            literal3.Text = "<div style=\"float:left; z-index: 1;\"><object class=\"toHidde\" width=\"400\" "+
                                                "height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                                "\"/><param  name=\"wmode2\" value=\"transparent\" /><param  name=\"wmode\" "+
                                                "value=\"opaque\" /><param name=\"allowFullScreen\" value=\"true\"/><embed "+
                                                "src=\"http://www.youtube.com/v/" +
                                                youtokens[i] + "\" wmode=\"opaque\" wmode2=\"transparent\" type=\"application/x-shockwave"+
                                                "-flash\" allowfullscreen=\"true\" width=\"400\" height=\"250\"/></object></div>";
                                            Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                            r3.Controls.Add(literal3);
                                            Rotator1.Items.Add(r3);
                                        }
                                    }
                                }
                                DataView dsSlider = dat.GetDataDV("SELECT * FROM Event_Slider_Mapping WHERE EventID=" + ID);
                                if (dsSlider.Count > 0)
                                {
                                    char[] delim = { '\\' };
                                    char[] delim3 = { '.' };
                                    string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\Events\\" + ID + "\\Slider");

                                    string[] finalFileArray = new string[fileArray.Length];

                                    for (int i = 0; i < fileArray.Length; i++)
                                    {
                                        int length = fileArray[i].Split(delim).Length;
                                        finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/Events/" +
                                            ID + "/Slider/" + fileArray[i].Split(delim)[length - 1];
                                        string[] tokens = fileArray[i].Split(delim)[length - 1].Split(delim3);

                                        dsSlider.RowFilter = "PictureName='" + tokens[0] + "." + tokens[1] + "'";
                                        if (tokens.Length >= 2 && dsSlider.Count > 0)
                                        {
                                            if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                            {
                                                System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\Events\\" + ID + "\\Slider\\" + fileArray[i].Split(delim)[length - 1].ToString());

                                                int width = 410;
                                                int height = 250;

                                                int newHeight = 0;
                                                int newIntWidth = 0;

                                                //if image height is less than resize height
                                                if (height >= image.Height)
                                                {
                                                    //leave the height as is
                                                    newHeight = image.Height;

                                                    if (width >= image.Width)
                                                    {
                                                        newIntWidth = image.Width;
                                                    }
                                                    else
                                                    {
                                                        newIntWidth = width;

                                                        double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                        double newDoubleHeight = double.Parse(newHeight.ToString());
                                                        newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                        newHeight = (int)newDoubleHeight;
                                                    }
                                                }
                                                //if image height is greater than resize height...resize it
                                                else
                                                {
                                                    //make height equal to the requested height.
                                                    newHeight = height;

                                                    //get the ratio of the new height/original height and apply that to the width
                                                    double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                    double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                    newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                    newIntWidth = (int)newDoubleWidth;

                                                    //if the resized width is still to big
                                                    if (newIntWidth > width)
                                                    {
                                                        //make it equal to the requested width
                                                        newIntWidth = width;

                                                        //get the ratio of old/new width and apply it to the already resized height
                                                        theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                        double newDoubleHeight = double.Parse(newHeight.ToString());
                                                        newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                        newHeight = (int)newDoubleHeight;
                                                    }
                                                }

                                                Literal literal4 = new Literal();
                                                literal4.Text = "<div style=\"width: 410px; height: 250px;background-color: black;\"><img style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                    + "UserFiles/Events/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" /></div>";
                                                Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                r4.Controls.Add(literal4);

                                                Rotator1.Items.Add(r4);
                                            }
                                            else if (tokens[1].ToUpper() == "WMV")
                                            {
                                                Literal literal4 = new Literal();
                                                literal4.Text = "<div style=\"width: 410px; height: 250px;\" ><OBJECT stop=\"true\" loop=\"false\" controller=\"true\" wmode2=\"opaque\" wmode=\"transparent\" autoplay=\"false\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " +
                                                "width=\"410\" height=\"250\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">" +
                                                "<param name=\"src\" value=\"UserFiles/Events/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\"></param>" +
                                                "<param name=\"autoplay\" value=\"false\"></param><param name=\"wmode\" value=\"transparent\"></param>" +
                                                "<param name=\"controller\" value=\"true\"></param>" +
                                                "<param name=\"stop\" value=\"true\" ></param>" +
                                                "<param name=\"loop\" value=\"false\"><param  name=\"wmode2\" value=\"opaque\" ></param>" +
                                                "<EMBED stop=\"true\" wmode=\"transparent\" wmode2=\"opaque\" src=\"UserFiles/Events/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" width=\"410\" height=\"250\" autoplay=\"false\" " +
                                                "controller=\"true\" loop=\"false\" bgcolor=\"#000000\" pluginspage=\"http://www.apple.com/quicktime/download/\">" +
                                                "</EMBED>" +
                                                "</OBJECT></div>";
                                                Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                r4.Controls.Add(literal4);
                                                Rotator1.Items.Add(r4);
                                            }
                                        }

                                    }
                                }
                                break;
                            default: break;
                        }

                        if (Rotator1.Items.Count == 0)
                            RotatorPanel.Visible = false;
                        else
                        {
                            RotatorPanel.Visible = true;
                            if (Rotator1.Items.Count == 1)
                            {
                                RotatorPanel.CssClass = "HiddeButtons";
                            }
                        }

                        if (fillUserData)
                        {
                            ASP.controls_addtocalendar_ascx AddTo1 = new ASP.controls_addtocalendar_ascx();
                            AddTo1.ID = "AddTo1";
                            AddTo1.EVENT_ID = int.Parse(ID);
                            AddTo1.DataBind2();

                            ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                            SendMessage1.THE_TEXT = "Share this with a friend";
                            SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                                " would like to share \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\" with you.";
                            SendMessage1.TYPE = "e";
                            SendMessage1.ID = int.Parse(ID);

                            CalendarSharePanel.Controls.Add(AddTo1);
                            CalendarSharePanel.Controls.Add(SendMessage1);

                            Session["Subject"] = "Re: " + Session["UserName"].ToString() +
                                " would like to share \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\" with you.";

                        }

                //        DiggLiteral.Text = "<table>" +
                //    "<tr>" +
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                //         "   <a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>" +
                //       " </td>" +
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                //        "    <a style=\"border: 0; padding: 0; margin: 0;\" id=\"TweeterA\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>" +
                //        "</td>" +
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                //          "  <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">" +
                //          "      <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />" +
                //          "  </a>" +
                //        "</td>" +
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\"><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                //        "href='http://digg.com/submit?phase=2&url=" + "http://" +
                //        Request.Url.Authority + "/" +
                //        niceName +
                //        "_" + ds.Tables[0].Rows[0]["ID"].ToString() + "_Event" +
                //        "' target=\"_blank\">Digg</a></td>" +
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +

                //            "<a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
                //             "   <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
                //            "</a>" +
                //        "</td>" +
                //        "<td>" +
                //          "  <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                //        "</td>" +
                //    "</tr>" +
                //"</table>";

                    }
                    else
                    {

                        EventName.Text = "This event has been disabled";
                    }
                }
                else
                {
                    //Response.Redirect("~/Home.aspx");
                }
            }
            else
            {
                //Response.Redirect("~/Home.aspx");
            }
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
            //Response.Redirect("~/Home.aspx");
        }

        DataSet dsUpdates = dat.GetData("SELECT * FROM EventUpdates WHERE EventID="+eventID);
        RadPanel1.Visible = false;
        RadPanel1.Items[0].Items[0].Text = "";
        for (int i = 0; i < dsUpdates.Tables[0].Rows.Count; i++)
        {
            RadPanel1.Visible = false;
            RadPanel1.Items[0].Items[0].Text += dsUpdates.Tables[0].Rows[i]["eventChange"].ToString() + "<br/><br/>";
        }
    }
Esempio n. 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        try
        {
            Session["RedirectTo"] = Request.Url.AbsoluteUri;

            bool fillUserData = false;
            Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

            try
            {

                if (Session["User"] != null)
                {
                    fillUserData = true;
                }
                else
                {
                    Button calendarLink = (Button)dat.FindControlRecursive(this, "CalendarLink");
                    calendarLink.Visible = false;
                }
            }
            catch (Exception ex)
            {
            }

            if (Request.QueryString["ID"] == null)
                Response.Redirect("~/Home.aspx");
            string ID = Request.QueryString["ID"].ToString();

            if (Session["User"] != null)
            {
                LoggedInPanel.Visible = true;
                LoggedOutPanel.Visible = false;
                DataSet dsComments;
                string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                if (commentPrefs == "1")
                {
                    dsComments = dat.GetData("SELECT VC.CommentDate AS theDate, * FROM Venue_Comments VC, Users U WHERE VC.UserID=U.User_ID AND VC.VenueID=" + ID + " ORDER BY VC.CommentDate ");
                }
                else
                {
                    dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, VC.Comment, VC.CommentDate AS theDate FROM Venue_Comments VC, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=VC.UserID) OR (U.User_ID=" +
                                        Session["User"].ToString() + " AND U.User_ID=VC.UserID)) AND VC.VenueID=" + ID + " ORDER BY VC.CommentDate");
                }
                TheComments.DATA_SET = dsComments;
                TheComments.DataBind2(true);

               //Show edit link if use is logged in.
                EditLink.NavigateUrl = "EnterVenue.aspx?ID=" + ID;
                EditLink.Visible = true;
                TopPanel.Visible = true;

                //Query whether current owner was delinquent on approve/reject changes
                if (dat.IsOwnerDelinquent(Request.QueryString["ID"].ToString(), Request.IsLocal, "V"))
                {
                    //make the button visable
                    TopPanel.Visible = true;
                    OwnerPanel.Visible = true;
                    Session["Message"] = "The ownership of this venue is <b>open</b>. <br/>The ownership became " +
                        "open because the previous owner of this venue became un-responsive to rejecting/" +
                        "approving user's changes to this venue.<br/>If you would like to become " +
                        "the owner, click on the button below to go to the venue's edit page. <br/><br/> " +
                        "Being the owner, you will have the privilage of having your <b>edits come though right " +
                        "away.</b> Other participants' changes to this venue will have to be <b>approved by you.</b><br/><br/>" +
                        "<button style=\"cursor: pointer;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                        "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                        "no-repeat; border: 0;\" onclick=\"Search('EnterVenue.aspx?ID=" + Request.QueryString["ID"].ToString() +
                        "');\" onmouseover=\"this.style.backgroundImage='url(image/PostButtonNoPostHover.png)'\" " +
                        "onmouseout=\"this.style.backgroundImage='url(image/PostButtonNoPost.png)'\">Edit</button>" +

                        "<button style=\"cursor: pointer;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                        "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                        "no-repeat; border: 0;\" onclick=\"Search();\" " +
                        "onmouseover=\"this.style.backgroundImage='url(image/PostButtonNoPostHover.png)'\" " +
                        "onmouseout=\"this.style.backgroundImage='url(image/PostButtonNoPost.png)'\">Close</button>";
                }

            }
            else
            {
                LoggedInPanel.Visible = false;
                LoggedOutPanel.Visible = true;
                DataSet dsComments = dat.GetData("SELECT VC.CommentDate AS theDate, * FROM Venue_Comments VC, Users U WHERE VC.UserID=U.User_ID AND VC.VenueID=" + ID + " ORDER BY VC.CommentDate ");
                TheComments.DATA_SET = dsComments;
                TheComments.DataBind2(false);
            }

            DataSet ds = dat.GetData("SELECT * FROM Venues WHERE ID=" + ID);

            Session["FlagID"] = ID;
            Session["FlagType"] = "V";

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (bool.Parse(ds.Tables[0].Rows[0]["Live"].ToString()))
                    {
                        //Get venue's categories
                        DataSet dscat = dat.GetData("SELECT DISTINCT VC.Name, VC.ID FROM Venue_Category V_C, VenueCategories VC WHERE " +
                            "V_C.Venue_ID=" + ID + " AND V_C.Category_ID=VC.ID ");

                        if (dscat.Tables.Count > 0)
                        {
                            if (dscat.Tables[0].Rows.Count > 0)
                            {
                                CategoriesLiteral.Text = "<label class=\"AddWhiteLinkSmall\">Categories:</label> ";
                                int charcount = 0;
                                bool charReached = false;
                                int currentcount = 0;
                                int leftovercount = 0;
                                for (int u = 0; u < dscat.Tables[0].Rows.Count; u++)
                                {
                                    CategoriesLiteral.Text += "<a class=\"AddLinkSmall\" href=\""+dat.MakeNiceName(dscat.Tables[0].Rows[u]["Name"].ToString())+"_Venue_Category\">" + dscat.Tables[0].Rows[u]["Name"].ToString() + "</a> ";
                                    charcount += dscat.Tables[0].Rows[u]["Name"].ToString().Length + 1;
                                    if (dscat.Tables[0].Rows[u]["Name"].ToString().ToLower().Contains("happy hour"))
                                    {
                                        CategoriesLiteral.Text += "<label class=\"AddLinkSmallUn\"> (see venue calendar) </label>";
                                        charcount += 23;

                                        if (charReached)
                                        {
                                            leftovercount += 23;
                                        }
                                    }

                                    if (!charReached)
                                    {
                                        if (charcount > 145)
                                        {
                                            charReached = true;
                                            leftovercount = dscat.Tables[0].Rows[u]["Name"].ToString().Length + 1;
                                        }
                                        else
                                        {
                                            currentcount = CategoriesLiteral.Text.Length;
                                        }
                                    }
                                    else
                                    {
                                        leftovercount += dscat.Tables[0].Rows[u]["Name"].ToString().Length + 1;
                                    }
                                }

                                //if the list is too long, add a 'more' link drop down.
                                if (charReached)
                                {
                                    string beginning = "<div>" + CategoriesLiteral.Text.Substring(0, currentcount - 1) +
                                        " <a onclick=\"OpenCatDiv();\" id=\"morelessA\" class=\"AddWhiteLinkSmall\"> more...</a></div>";

                                    int divHeight = leftovercount / 82;

                                    if (divHeight == 0)
                                        divHeight = 20;
                                    else
                                        divHeight = (divHeight + 1) * 20;

                                    string hiddenDiv = "<div style=\"display: none;\" id=\"infoDiv\">" + divHeight.ToString() +
                                        "</div><div style=\"height: 0px; border: 0; width: 420px;\" id=\"CatDiv\">" +
                                        CategoriesLiteral.Text.Substring(currentcount, CategoriesLiteral.Text.Length - currentcount) + "</div>";

                                    CategoriesLiteral.Text = beginning + hiddenDiv;
                                }

                            }
                        }

                        string theLink = "http://" + Request.Url.Authority + "/" +
                            dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14)) +
                            "_" + ID.ToString() + "_Venue";

                //        DiggLiteral.Text = " <table> "+
                //    "<tr>"+
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">"+
                //            "<a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>"+
                //        "</td>"+
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">"+
                //         "   <a style=\"border: 0; padding: 0; margin: 0;\" id=\"TweeterA\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>"+
                //        "</td>"+
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">"+
                //        "    <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">"+
                //        "        <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />"+
                //        "    </a>"+
                //        "</td>"+
                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\"><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                //        "href='http://digg.com/submit?phase=2&url=" + "http://" + Request.Url.Authority + "/" +
                //            dat.MakeNiceName(ds.Tables[0].Rows[0]["Name"].ToString()) +
                //            "_" + ID.ToString() + "_Venue" +
                //            "' target=\"_blank\">Digg</a></td> "+

                //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +

                //            "<a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
                //             "   <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
                //            "</a>" +
                //        "</td>" +
                //        "<td>" +
                //        "     <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                //        "</td>" +
                //    "</tr>" +
                //"</table>";

                        HtmlHead head = (HtmlHead)Page.Header;
                        HtmlLink lk = new HtmlLink();
                        lk.Href = theLink;
                        lk.Attributes.Add("rel", "bookmark");
                        head.Controls.AddAt(0, lk);

                        VenueName.Text = "<a style=\"text-decoration: none; color: white;\" href=\"" +
                            theLink + "\">" + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + "</a>";
                        Session["Subject"] = "Re: " + ds.Tables[0].Rows[0]["Name"].ToString();
                        Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Name"].ToString();

                        string Venue = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                        //TagCloud.THE_ID = int.Parse(ID);

                        PhoneLabel.Text = "Phone: " + ds.Tables[0].Rows[0]["Phone"].ToString() + "<br/>Email: " +
                            ds.Tables[0].Rows[0]["Email"].ToString() + "<br/>Web: <a class='AddLink' target='_blank' href='" + ds.Tables[0].Rows[0]["Web"].ToString() + "'>" +
                            ds.Tables[0].Rows[0]["Web"].ToString()+"</a>";

                        DataSet dsCountry = new DataSet();
                        string country = "";
                        if (ds.Tables[0].Rows[0]["Country"] != null)
                        {
                            dsCountry = dat.GetData("SELECT country_2_code FROM Countries WHERE country_id=" + ds.Tables[0].Rows[0]["Country"].ToString());
                            if (dsCountry.Tables[0].Rows.Count > 0)
                            {
                                country = dsCountry.Tables[0].Rows[0]["country_2_code"].ToString();
                            }
                        }
                        if (country.ToLower() == "us")
                        {
                            try
                            {
                                AddressLabel.Text = dat.GetAddress(ds.Tables[0].Rows[0]["Address"].ToString(), false);
                            }
                            catch (Exception ex1)
                            {
                                AddressLabel.Text = "";
                            }
                        }
                        else
                        {

                            AddressLabel.Text = dat.GetAddress(ds.Tables[0].Rows[0]["Address"].ToString(), true);

                        }

                        //if (ds.Tables[0].Rows[0]["Country"].ToString() == "222")
                        //{
                        //    CityState.Text = ds.Tables[0].Rows[0]["City"].ToString();
                        //}
                        //else
                        //{
                            CityState.Text = ds.Tables[0].Rows[0]["City"].ToString() + " " +
                            ds.Tables[0].Rows[0]["State"].ToString() + " " + ds.Tables[0].Rows[0]["Zip"].ToString();
                        //}

                        HttpCookie cookie2 = new HttpCookie("addressParameter");
                        HttpCookie cookiename = new HttpCookie("addressParameterName");
                        if (country.ToLower() == "uk")
                        {
                            //VenueName.Text + "@&" +
                            cookie2.Value = AddressLabel.Text + "@&" +
                                ds.Tables[0].Rows[0]["City"].ToString() + ", " +
                                ds.Tables[0].Rows[0]["Zip"].ToString() + ", " + country;

                            cookiename.Value = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                        }
                        else
                        {
                            //VenueName.Text + "@&" +
                            cookie2.Value = AddressLabel.Text + "@&" + CityState.Text + "@&" + country;
                            cookiename.Value = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                        }
                        cookie2.Expires = DateTime.Now.Add(new TimeSpan(1, 0, 0));
                        cookiename.Expires = DateTime.Now.Add(new TimeSpan(1, 0, 0));

                        Response.Cookies.Add(cookie2);
                        Response.Cookies.Add(cookiename);

                        string content = ds.Tables[0].Rows[0]["Content"].ToString();

                        Session["messageText"] = "Venue: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + ". Address: " + AddressLabel.Text + ", " + CityState.Text;
                        Session["messageEmail"] = "Venue: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + " \n\r Address: " + AddressLabel.Text + " \n\r Location: " +
                            CityState.Text + " \n\r " + content;

                        ShowDescriptionBegining.Text = dat.BreakUpString(content, 60);

                        //Create keyword and description meta tags
                        HtmlMeta hm = new HtmlMeta();
                        HtmlMeta kw = new HtmlMeta();

                        kw.Name = "keywords";
                        kw.Content = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + ", " + AddressLabel.Text;

                        DataView dvCats = dat.GetDataDV("SELECT DISTINCT C.ID, C.Name AS CategoryName, " +
                            "VC.tagSize FROM Venue_Category VC, VenueCategories C WHERE VC.CATEGORY_ID=C.ID " +
                            "AND VC.VENUE_ID=" + ID);

                        string justCats = "";

                        for (int i = 0; i < dvCats.Count; i++)
                        {
                            kw.Content += ", " + dvCats[i]["CategoryName"].ToString();
                            justCats += dvCats[i]["CategoryName"].ToString() + " ";
                        }

                        head.Controls.AddAt(0, kw);

                        hm.Name = "Description";
                        hm.Content = ShowDescriptionBegining.Text + ", " + kw.Content;
                        head.Controls.AddAt(0, hm);

                        this.Title = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + " | " + justCats + " | HippoHappenings";

                        CalendarLink.NavigateUrl = dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14)) + "_" + ID + "_Calendar";

                        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                        int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());

                        DataSet dsEvents = dat.GetData("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS [End], " +
                            "E.Header, E.ID, E.ShortDescription FROM Event_Occurance EO, Events E WHERE " +
                            "(CONVERT(NVARCHAR,DAY(EO.DateTimeStart)) + '.' + CONVERT(NVARCHAR,MONTH(EO.DateTimeStart)) + " +
                            "'.' + CONVERT(NVARCHAR,YEAR(EO.DateTimeStart))) = (CONVERT(NVARCHAR,DAY(GETDATE())) + " +
                            "'.' + CONVERT(NVARCHAR,MONTH(GETDATE())) + '.' + CONVERT(NVARCHAR,YEAR(GETDATE())))" +
                            "AND EO.EventID=E.ID AND E.Venue=" + ID + " ORDER BY Start");
                        bool noEvents = false;
                        EventsPanel.Controls.Clear();
                        if (dsEvents.Tables.Count > 0)
                            if (dsEvents.Tables[0].Rows.Count > 0)
                            {
                                int eventCount = dsEvents.Tables[0].Rows.Count;

                                for (int i = 0; i < eventCount; i++)
                                {
                                    HyperLink eventHeader = new HyperLink();
                                    eventHeader.CssClass = "CalendarHeader";
                                    eventHeader.NavigateUrl = dat.MakeNiceName(dsEvents.Tables[0].Rows[i]["Header"].ToString())+"_" + dsEvents.Tables[0].Rows[i]["ID"].ToString()+"_Event";
                                    eventHeader.Text = dsEvents.Tables[0].Rows[i]["Header"].ToString() + "<br/>";

                                    Label dateStart = new Label();
                                    dateStart.CssClass = "CalendarTime";
                                    dateStart.Text = DateTime.Parse(dsEvents.Tables[0].Rows[i]["Start"].ToString()).ToShortTimeString() + " - " +
                                        DateTime.Parse(dsEvents.Tables[0].Rows[i]["End"].ToString()).ToShortTimeString() + "<br/>";

                                    Label shortDescription = new Label();
                                    shortDescription.CssClass = "CalendarDescription";
                                    shortDescription.Text = dsEvents.Tables[0].Rows[i]["ShortDescription"].ToString() + "<br/><br/>";

                                    EventsPanel.Controls.Add(eventHeader);
                                    EventsPanel.Controls.Add(dateStart);
                                    EventsPanel.Controls.Add(shortDescription);
                                }
                            }
                            else
                            {
                                noEvents = true;
                            }
                        else
                        {
                            noEvents = true;
                        }

                        if (noEvents)
                        {
                            HyperLink eventHeader = new HyperLink();
                            eventHeader.CssClass = "CalendarHeader";
                            eventHeader.Text = "There are no events at " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + " today.";
                            EventsPanel.Controls.Add(eventHeader);
                        }

                        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                        string youtube = ds.Tables[0].Rows[0]["YouTubeVideo"].ToString();
                        Rotator1.Items.Clear();
                        switch (mediaCategory)
                        {
                            case 0:
                                break;
                            case 1:
                                ShowVideoPictureLiteral.Text = "";
                                char[] delim4 = { ';' };
                                string[] youtokens = youtube.Split(delim4);
                                if (youtube != "")
                                {
                                    for (int i = 0; i < youtokens.Length; i++)
                                    {
                                        if (youtokens[i].Trim() != "")
                                        {
                                            Literal literal3 = new Literal();
                                            literal3.Text = "<div style=\"float:left;\"><object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                                "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + youtokens[i] +
                                                "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"400\" height=\"250\"></embed></object></div>";
                                            Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                            r3.Controls.Add(literal3);
                                            Rotator1.Items.Add(r3);
                                        }
                                    }
                                }
                                DataView dsSlider = dat.GetDataDV("SELECT * FROM Venue_Slider_Mapping WHERE VenueID=" + ID);
                                if (dsSlider.Count > 0)
                                    {
                                        char[] delim = { '\\' };
                                        char[] delim3 = { '.' };
                                        string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\VenueFiles\\" + ID + "\\Slider");

                                        string[] finalFileArray = new string[fileArray.Length];

                                        for (int i = 0; i < dsSlider.Count; i++)
                                        {
                                            int length = fileArray[i].Split(delim).Length;
                                            finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/VenueFiles/" +
                                                ID + "/Slider/" + dsSlider[i]["PictureName"].ToString();
                                            string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                            //dsSlider.RowFilter = "RealPictureName='" + tokens[0] + "." + tokens[1] + "'";
                                            if (tokens.Length >= 2)
                                            {
                                                if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                                {
                                                    System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") +
                                                        "\\VenueFiles\\" + ID + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                                                    int width = 400;
                                                    int height = 250;

                                                    int newHeight = 0;
                                                    int newIntWidth = 0;

                                                    //if image height is less than resize height
                                                    if (height >= image.Height)
                                                    {
                                                        //leave the height as is
                                                        newHeight = image.Height;

                                                        if (width >= image.Width)
                                                        {
                                                            newIntWidth = image.Width;
                                                        }
                                                        else
                                                        {
                                                            newIntWidth = width;

                                                            double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                            double newDoubleHeight = double.Parse(newHeight.ToString());
                                                            newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                            newHeight = (int)newDoubleHeight;
                                                        }
                                                    }
                                                    //if image height is greater than resize height...resize it
                                                    else
                                                    {
                                                        //make height equal to the requested height.
                                                        newHeight = height;

                                                        //get the ratio of the new height/original height and apply that to the width
                                                        double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                        double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                        newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                        newIntWidth = (int)newDoubleWidth;

                                                        //if the resized width is still to big
                                                        if (newIntWidth > width)
                                                        {
                                                            //make it equal to the requested width
                                                            newIntWidth = width;

                                                            //get the ratio of old/new width and apply it to the already resized height
                                                            theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                            double newDoubleHeight = double.Parse(newHeight.ToString());
                                                            newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                            newHeight = (int)newDoubleHeight;
                                                        }
                                                    }

                                                    Literal literal4 = new Literal();
                                                    literal4.Text = "<div style=\"width: 400px; height: 250px;background-color: black;\"><img align=\"middle\" style=\"cursor: pointer; margin-left: " + ((400 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" onclick=\"OpenEventModal(" + i.ToString() + ", " + ID + ");\" height=\"" + height.ToString() + "px\" width=\"" + width.ToString() + "px\" src=\""
                                                        + "VenueFiles/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString()+ "\" /></div>";
                                                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                    r4.Controls.Add(literal4);
                                                    Rotator1.Items.Add(r4);
                                                }
                                                else if (tokens[1].ToUpper() == "WMV")
                                                {
                                                    Literal literal4 = new Literal();
                                                    literal4.Text = "<div style=\"float:left;\"><OBJECT wmode=\"transparent\"  classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' " +
                                                        "width=\"400\" height=\"250\" codebase='http://www.apple.com/qtactivex/qtplugin.cab'>" +
                                                        "<param name='src' value=\"VenueFiles/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\">" +
                                                        "<param name='autoplay' value=\"false\"><param name=\"wmode\" value=\"transparent\"/>" +
                                                        "<param name='controller' value=\"true\">" +
                                                        "<param name='loop' value=\"false\"><param  name=\"wmode2\" value=\"opaque\" ></param>" +
                                                        "<EMBED wmode=\"transparent\" wmode2=\"opaque\" src=\"VenueFiles/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" width=\"400\" height=\"250\" autoplay=\"false\" " +
                                                        "controller=\"true\" loop=\"false\" bgcolor=\"#000000\" pluginspage='http://www.apple.com/quicktime/download/'>" +
                                                        "</EMBED>" +
                                                        "</OBJECT></div> ";

                                                    //literal4.Text = "<div style=\"float:left;\"><embed  height=\"250px\" width=\"400px\" src=\""
                                                    //    + "VenueFiles/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" /></div>";
                                                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                    r4.Controls.Add(literal4);
                                                    Rotator1.Items.Add(r4);
                                                }

                                            }
                                        }
                                    }
                                break;
                            default: break;
                        }

                        if (Rotator1.Items.Count == 0)
                            RotatorPanel.Visible = false;
                        else
                        {
                            RotatorPanel.Visible = true;
                            if (Rotator1.Items.Count == 1)
                            {
                                RotatorPanel.CssClass = "HiddeButtons";
                            }
                        }
                        if (fillUserData)
                        {
                            ASP.controls_addtofavorites_ascx AddTo1 = new ASP.controls_addtofavorites_ascx();
                            AddTo1.VENUE_ID = int.Parse(ID);

                            ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                            SendMessage1.THE_TEXT = "Share this with a friend";
                            SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                                " would like to share the venue '\"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + "\"' with you.";
                            SendMessage1.TYPE = "v";
                            SendMessage1.ID = int.Parse(ID);

                            CalendarPanel.Controls.Add(AddTo1);
                            CalendarPanel.Controls.Add(SendMessage1);
                        }

                        this.Title = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                    }
                    else
                    {
                        Response.Redirect("~/Home.aspx");
                    }
                }
                else
                {
                    Response.Redirect("~/Home.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Home.aspx");
            }

            if (ReturnPanel.Visible)
            {
                if (EditLink.Visible)
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 430;
                    }
                    else
                    {
                        TopPanel.Width = 240;
                    }
                }
                else
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 300;
                    }
                    else
                    {
                        TopPanel.Width = 150;
                    }
                }
            }
            else
            {
                if (EditLink.Visible)
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 280;
                    }
                    else
                    {
                        TopPanel.Width = 80;

                    }
                    EditLink.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Edit Venue";
                }
                else
                {
                    if (OwnerPanel.Visible)
                    {
                        TopPanel.Width = 60;
                    }
                    else
                    {
                        TopPanel.Width = 0;
                    }
                    HyperLink1.InnerHtml = "&nbsp;&nbsp;&nbsp;&nbsp;Venue Ownership is Open";
                }
            }
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Page.Trace.IsEnabled = true;
        //Page.Trace.TraceMode = TraceMode.SortByTime;
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.Date.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        bool fillUserData = false;
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":").Replace("%28", "(").Replace("%29", ")")));

        if (!IsPostBack)
        {
            try
            {
                HtmlMeta hm = new HtmlMeta();
                HtmlMeta kw = new HtmlMeta();

                HtmlHead head = (HtmlHead)Page.Header;

                hm.Name = "Description";
                hm.Content = "Find your local events, venues and classifieds all while " +
                         "ads from your peers, neighborhood, and community are displayed "+
                         "to you purely based on your interests." +
                         "Large corporations are not welcome!";
                head.Controls.AddAt(0, hm);

                HtmlMeta nMT = new HtmlMeta();
                nMT.Name = "google-site-verification";
                nMT.Content = "tw8rmOWW-DlZa-H4DZdGr201J5kC7NVLXUmk5oN8vFM";

                head.Controls.Add(nMT);

                HtmlLink lkl = new HtmlLink();
                lkl.Href = "ror.xml";
                lkl.Attributes.Add("rel", "alternate");
                lkl.Attributes.Add("type", "application/xml");
                lkl.Attributes.Add("title", "ROR");

                head.Controls.Add(lkl);

                kw.Name = "keywords";
                kw.Content = "events, ads, venues, post, search, find, local events, concerts, festivals, world, theatre, technology, " +
                    "family, peers, neighborhood, classifieds";

                //DataView dvCats = dat.GetDataDV("SELECT * FROM AdCategories");

                //for (int i = 0; i < dvCats.Count; i++)
                //{
                //    kw.Content += ", " + dvCats[i]["Name"].ToString();
                //}

                //dvCats = dat.GetDataDV("SELECT * FROM EventCategories");

                //for (int i = 0; i < dvCats.Count; i++)
                //{
                //    kw.Content += ", " + dvCats[i]["Name"].ToString();
                //}

                //dvCats = dat.GetDataDV("SELECT * FROM VenueCategories");

                //for (int i = 0; i < dvCats.Count; i++)
                //{
                //    kw.Content += ", " + dvCats[i]["Name"].ToString();
                //}

                head.Controls.AddAt(0, kw);

                //logInPanel.Visible = Session["User"] == null;
                //loggedInPanel.Visible = Session["User"] != null;

                //Fill the home mission
                //if (!IsPostBack)
                //{
                //    ChangeMission(MissionTimer, new EventArgs());
                //}

                string country = "";
                string state = "";
                string city = "";
                string countryID = "";
                string stateID = "";
                string cityID = "";
                try
                {
                    if (Session["User"] != null)
                    {
                        DataSet ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE U.User_ID=" +
                            Session["User"].ToString() + " AND U.User_ID=UP.UserID ");

                        country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                        countryID = country;

                        state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                        city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                        stateID = state;
                        cityID = city;

                        //DataSet ds2 = dat.RetrieveAds(Session["User"].ToString(), false);
                        //DataSet dsMain = dat.RetrieveMainAds(Session["User"].ToString());
                        //Ads1.DATA_SET = ds2;
                        //Ads1.MAIN_AD_DATA_SET = dsMain;

                        fillUserData = true;
                    }
                    else
                    {
                        DataSet ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE " +
                                " U.User_ID=UP.UserID AND U.IPs LIKE '%" + dat.GetIP() + "%'");

                        bool getAnotherDs1 = false;
                        if (ds1.Tables.Count > 0)
                            if (ds1.Tables[0].Rows.Count > 0)
                            {
                                country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                                countryID = country;
                                state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                                city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                                stateID = state;
                                cityID = city;
                            }
                            else
                            {
                                getAnotherDs1 = true;
                            }
                        else
                        {
                            getAnotherDs1 = true;
                        }

                        if (getAnotherDs1)
                        {
                            ds1 = dat.GetData("SELECT * FROM SearchIPs WHERE IP='" + dat.GetIP() + "'");

                            if (ds1.Tables.Count > 0)
                            {
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    country = ds1.Tables[0].Rows[0]["Country"].ToString();
                                    countryID = country;
                                    state = ds1.Tables[0].Rows[0]["State"].ToString();
                                    city = ds1.Tables[0].Rows[0]["City"].ToString();
                                    stateID = state;
                                    cityID = city;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {

                }

                #region Take care of group activity

                if (country != "" && state != "")
                {
                    //Get Latest Group activity from Public groups
                    //GroupEvents
                    //    -posted on
                    //    -last edited

                    string thePlace = " AND G.Country=" + country + " AND G.State='" + state + "' ";
                    if (city != "")
                        thePlace += " AND G.City = '" + city.Replace("'", "''") + "'";

                    DataView dvTopGroupActivity = GetTheActivity(thePlace);

                    //Find the top 5 most recent
                    if (dvTopGroupActivity.Count > 0)
                    {
                        dvTopGroupActivity.Sort = "TheDate DESC";
                    }
                    int countIndex = 5;
                    if (dvTopGroupActivity.Count < 5)
                        countIndex = dvTopGroupActivity.Count;

                    string theType = "";
                    Literal theLit = new Literal();
                    GroupsPanel.Controls.Clear();
                    string userID = "";
                    string content = "";
                    DataView dvUser = new DataView();
                    DataView dv = new DataView();
                    DataView dvGroup = new DataView();
                    DataView dvG = new DataView();
                    if (dvTopGroupActivity.Count > 0)
                    {
                        for (int i = 0; i < countIndex; i++)
                        {
                            theType = dvTopGroupActivity[i]["Type"].ToString();
                            //<div style=\"width: 388px;background-repeat: repeat-y; background-image: url(images/ActCommentMiddle.png);\" class=\"topDiv\">
                            theLit.Text += "<div " +
                                "class=\"topDiv\" style=\"width: 378px;height: 143px;padding-left: 10px;padding-top: 10px; background-image: "+
                                "url(images/ActCommentTopPurple10.png); background-repeat: no-repeat; \"><div style=\"float: left;\"><img src=\"images/QuoteTop.png\" /></div><div style=\"float: left; width: 350px; padding-bottom: 5px;\">";

                            DateTime theDate = DateTime.Parse(dvTopGroupActivity[i]["TheDate"].ToString());
                            string postedText = "<div style=\"clear: both;\"><div style=\"float: left;\"><span " +
                                "style=\"font-size: 12px; font-style: italic; font-family: arial; color: #a5c13a;\">Posted " +
                                dat.GetMonth(theDate.Month.ToString()) + " " +
                                        theDate.Day.ToString() + ", " + theDate.Year.ToString() + "</span><br/>";
                            switch (theType)
                            {
                                case "GEP":
                                    dv = dat.GetDataDV("SELECT *, GEO.ID AS GEOID FROM GroupEvents GE, " +
                                        "GroupEvent_Occurance GEO WHERE GE.ID=GEO.GroupEventID AND GE.ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dv[0]["UserID"].ToString();
                                    dvGroup = dat.GetDataDV("SELECT * FROM Groups WHERE ID=" + dv[0]["GroupID"].ToString());
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dv[0]["Content"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dv[0]["Name"].ToString()) + "_" +
                                        dv[0]["GEOID"].ToString() + "_" + dvTopGroupActivity[i]["TheID"].ToString() +
                                        "_GroupEvent\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">posted by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvGroup[0]["Header"].ToString()) +
                                        "_" + dvGroup[0]["ID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvGroup[0]["Header"].ToString() + " Group</a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GEE":
                                    dv = dat.GetDataDV("SELECT *, GEO.ID AS GEOID FROM GroupEvents GE, " +
                                        "GroupEvent_Occurance GEO WHERE GE.ID=GEO.GroupEventID AND GE.ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dv[0]["UserID"].ToString();
                                    dvGroup = dat.GetDataDV("SELECT * FROM Groups WHERE ID=" + dv[0]["GroupID"].ToString());
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dv[0]["Content"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dv[0]["Name"].ToString()) + "_" +
                                        dv[0]["GEOID"].ToString() + "_" + dvTopGroupActivity[i]["TheID"].ToString() +
                                        "_GroupEvent\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">edited by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvGroup[0]["Header"].ToString()) +
                                        "_" + dvGroup[0]["ID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvGroup[0]["Header"].ToString() + " Group</a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GEM":
                                    dv = dat.GetDataDV("SELECT *, GEM.UserID AS TheUser, GEO.ID AS GEOID, GE.ID AS EID, GEM.Content AS TheContent FROM GroupEvents GE, " +
                                        "GroupEvent_Occurance GEO, GroupEventMessages GEM WHERE GEM.GroupEventID=GE.ID AND " +
                                        "GE.ID=GEO.GroupEventID AND GEM.ID=" + dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dv[0]["TheUser"].ToString();
                                    dvGroup = dat.GetDataDV("SELECT * FROM Groups WHERE ID=" + dv[0]["GroupID"].ToString());
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dv[0]["TheContent"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dv[0]["Name"].ToString()) + "_" +
                                        dv[0]["GEOID"].ToString() + "_" + dv[0]["EID"].ToString() +
                                        "_GroupEvent\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">posted by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvGroup[0]["Header"].ToString()) +
                                        "_" + dvGroup[0]["ID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvGroup[0]["Header"].ToString() + " Group</a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GP":
                                    dvG = dat.GetDataDV("SELECT *  FROM Groups G WHERE ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dvG[0]["Host"].ToString();
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dvG[0]["Content"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp;<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dvG[0]["Header"].ToString()) + "_" +
                                        dvTopGroupActivity[i]["TheID"].ToString() +
                                        "_Group\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">posted by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvG[0]["Header"].ToString()) +
                                        "_" + dvG[0]["ID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvG[0]["Header"].ToString() + " Group </a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GE":

                                    dvG = dat.GetDataDV("SELECT *  FROM Groups G WHERE ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dvG[0]["Host"].ToString();
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dvG[0]["Content"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp;<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dvG[0]["Header"].ToString()) + "_" +
                                        dvTopGroupActivity[i]["TheID"].ToString() +
                                        "_Group\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">edited by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvG[0]["Header"].ToString()) +
                                        "_" + dvG[0]["ID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvG[0]["Header"].ToString() + " Group </a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GT":
                                    dvG = dat.GetDataDV("SELECT *, G.ID AS GID FROM Groups G, GroupThreads GT WHERE G.ID=GT.GroupID AND GT.ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dvG[0]["StartedBy"].ToString();
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML("Thread added to the group: " + dvG[0]["ThreadName"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp;<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dvG[0]["Header"].ToString()) + "_" +
                                        dvG[0]["GID"].ToString() +
                                        "_Group\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">added by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvG[0]["Header"].ToString()) +
                                        "_" + dvG[0]["GID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvG[0]["Header"].ToString() + " Group </a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GTC":
                                    dvG = dat.GetDataDV("SELECT *, GTC.Content AS TheContent, G.ID AS GID FROM Groups G, " +
                                        "GroupThreads GT, GroupThreads_Comments GTC " +
                                        "WHERE GTC.ThreadID=GT.ID AND G.ID=GT.GroupID AND GTC.ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dvG[0]["UserID"].ToString();
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dvG[0]["TheContent"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp;<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dvG[0]["Header"].ToString()) + "_" +
                                        dvG[0]["GID"].ToString() +
                                        "_Group\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">comment by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvG[0]["Header"].ToString()) +
                                        "_" + dvG[0]["GID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvG[0]["Header"].ToString() + " Group </a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                case "GM":
                                    dvG = dat.GetDataDV("SELECT *, G.ID AS GID, GM.Content AS TheContent FROM GroupMessages GM, Groups G WHERE G.ID=GM.GroupID AND GM.ID=" +
                                        dvTopGroupActivity[i]["TheID"].ToString());
                                    userID = dvG[0]["UserID"].ToString();
                                    dvUser = dat.GetDataDV("SELECT * FROM UserPreferences UP, Users U " +
                                        "WHERE UP.UserID=U.User_ID AND UP.UserID=" + userID);

                                    theLit.Text += "<div style=\"float: left; padding-right: 10px; padding-left: " +
                                        "10px; padding-bottom: 5px; padding-top: 5px;\">" + getUserProfile(userID) + "</div>";

                                    content = dat.stripHTML(dvG[0]["TheContent"].ToString());
                                    if (content.Length > 170)
                                        content = content.Substring(0, 170) + "...";

                                    theLit.Text += "<div style=\"padding-top: 5px;font-family: Arial; font-size: 12px; color: " +
                                        "#cccccc; font-style: italic;\">" + content + "&nbsp;<a style=\"text-decoration: none;\" href=\"" +
                                        dat.MakeNiceName(dvG[0]["Header"].ToString()) + "_" +
                                        dvG[0]["GID"].ToString() +
                                        "_Group\"><span class=\"AddPurpleLink\">Read More</span></a></div>";
                                    theLit.Text += postedText;
                                    theLit.Text += "<span style=\"font-size: 12px; font-family: arial; color: #cccccc;\">message by <a href=\"" + dvUser[0]["UserName"].ToString() +
                                        "_Friend\" class=\"AddLink\">" + dvUser[0]["UserName"].ToString() +
                                        "</a></span> <br/>";
                                    theLit.Text += "<a href=\"" + dat.MakeNiceName(dvG[0]["Header"].ToString()) +
                                        "_" + dvG[0]["GID"].ToString() + "_Group\" class=\"AddPurpleLink\">" +
                                        dvG[0]["Header"].ToString() + " Group </a></div><div style=\"float: right;\"><img src=\"images/QuoteBottom.png\" /></div></div>";
                                    break;
                                default: break;
                            }

                            theLit.Text += "</div></div>";
                        }
                        GroupsPanel.Controls.Add(theLit);
                    }
                    else
                    {
                        Label lab = new Label();
                        lab.Text = "There are no groups in your area. To post some <a class=\"AddLink\" href=\"EnterGroup.aspx\">go here</a>";
                        GroupsLabel.Controls.Add(lab);
                    }
                }

                #endregion

                DataSet ds;

                if (!IsPostBack)
                {
                    LocationLabel.Text = "";
                    if (country != "")
                        country = " AND E.Country = " + country;

                    int c = 0;

                    if (state != "")
                    {

                        c++;
                    }

                    if (city != "")
                    {

                        c++;
                    }

                    SqlDbType[] types = new SqlDbType[c];
                    object[] data = new object[c];

                    if (state != "")
                    {
                        types[0] = SqlDbType.NVarChar;
                        data[0] = state;
                        state = " AND E.State=@p0 ";
                        if (city != "")
                        {
                            types[1] = SqlDbType.NVarChar;
                            data[1] = city;
                            city = " AND E.City=@p1 ";
                        }
                    }
                    else
                    {
                        if (city != "")
                        {
                            types[0] = SqlDbType.NVarChar;
                            data[0] = city;
                            city = " AND E.City=@p0 ";
                        }
                    }

                    ds = dat.GetDataWithParemeters("SELECT DISTINCT TOP 10 EO.DateTimeStart, E.Header, E.Content, EO.EventID FROM Events E, Event_Occurance EO WHERE E.LIVE='True' AND E.ID=EO.EventID " + country + state + city + " AND EO.DateTimeStart > '" + DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date + "' ORDER BY EO.DateTimeStart", types, data);

                    Session["HomeEvents"] = ds;
                    LocationLabel.Text = "";
                    if (country == "" && state == "" && city == "")
                    {
                        LocationLabel.Text = " The World ";
                    }
                    else
                    {
                        if (city != "")
                        {
                            LocationLabel.Text += cityID;
                            if (state != "")
                                LocationLabel.Text += ", " + stateID;
                        }
                        else
                        {
                            if (state != "")
                                LocationLabel.Text += stateID;
                        }
                    }

                    if (LocationLabel.Text == "")
                    {
                        DataSet dsCountry = dat.GetData("SELECT * FROM Countries WHERE country_id=" + countryID);
                        LocationLabel.Text = dsCountry.Tables[0].Rows[0]["country_name"].ToString();
                    }
                }
                else
                {
                    EventPanel.Controls.Clear();
                    LocationLabel.Text = "";
                    ds = (DataSet)Session["HomeEvents"];

                    if (countryID == "" && stateID == "" && cityID == "")
                    {
                        LocationLabel.Text = " The World ";
                    }
                    else
                    {
                        if (cityID != "")
                        {
                            LocationLabel.Text += cityID;
                            if (state != "")
                                LocationLabel.Text += ", " + stateID;
                        }
                        else
                        {
                            if (state != "")
                                LocationLabel.Text += stateID;
                        }
                    }

                    //if (RadCalendar1.SelectedDate.ToShortDateString() != "1/1/0001")
                    //    LocationLabel.Text += " on " + RadCalendar1.SelectedDate.ToShortDateString();

                }

                ds = (DataSet)Session["HomeEvents"];

                if (ds != null)
                {

                    if (ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DateTime date = DateTime.Parse(ds.Tables[0].Rows[i]["DateTimeStart"].ToString());
                                ASP.controls_homeevent_ascx eventH = new ASP.controls_homeevent_ascx();
                                eventH.DAY = date.DayOfWeek.ToString().Substring(0, 3);
                                eventH.DAY_NUMBER = date.Day.ToString();
                                eventH.MONTH = dat.GetMonth(date.Month.ToString()).Substring(0, 3);
                                eventH.EVENT_NAME = ds.Tables[0].Rows[i]["Header"].ToString();
                                if (ds.Tables[0].Rows[i]["Content"].ToString().Length > 150)
                                    eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString().Substring(0, 150).Replace("<br/>", " "), 67) + "...";
                                else
                                    eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString().Replace("<br/>", " "), 67) + "...";
                                eventH.EVENT_ID = int.Parse(ds.Tables[0].Rows[i]["EventID"].ToString());
                                EventPanel.Controls.Add(eventH);
                            }

                        }
                        else
                        {

                            Label label = new Label();
                            label.CssClass = "EventBody";
                            label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                            EventPanel.Controls.Add(label);
                        }
                    else
                    {

                        Label label = new Label();
                        label.CssClass = "EventBody";
                        label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                        EventPanel.Controls.Add(label);
                    }
                }
                else
                {

                    Label label = new Label();
                    label.CssClass = "EventBody";
                    label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"BlogEvent.aspx\">Enter Events</a>.";
                    EventPanel.Controls.Add(label);
                }

                #region Original Home page code
                //if (ds.Tables.Count > 0)
                //{
                //    if (ds.Tables[0].Rows.Count > 0)
                //    {

                //        ASP.controls_footer_ascx thefooter = (ASP.controls_footer_ascx)dat.FindControlRecursive(this, "TheFooter");
                //        thefooter.EVENT_ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());

                //        string ID = ds.Tables[0].Rows[0]["ID"].ToString();
                //        DataSet dsDate = dat.GetData("SELECT * FROM Event_Occurance WHERE EventID=" + ID);
                //        DataSet dsVenue = dat.GetData("SELECT * FROM Venues WHERE ID=" + ds.Tables[0].Rows[0]["Venue"]);
                //        TagCloud.THE_ID = int.Parse(ID);

                //        DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID +" ORDER BY C.BlogDate");
                //        TheComments.DATA_SET = dsComments;
                //        TheComments.DataBind2(true);

                //        if (bool.Parse(ds.Tables[0].Rows[0]["hasSongs"].ToString()))
                //        {
                //            DataSet dsSongs = dat.GetData("SELECT * FROM Event_Song_Mapping WHERE EventID=" + ID);
                //            ASP.controls_songplayer_ascx songs = new ASP.controls_songplayer_ascx();
                //            int songCount = dsSongs.Tables[0].Rows.Count;

                //            if (songCount > 2)
                //            {
                //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                //                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                //                songs.SONG3 = dsSongs.Tables[0].Rows[2]["SongName"].ToString();
                //            }
                //            else if (songCount > 1)
                //            {
                //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                //                songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                //            }
                //            else
                //                songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();

                //            songs.USER_NAME = ds.Tables[0].Rows[0]["UserName"].ToString();

                //            SongPanel.Controls.Add(songs);
                //        }

                //        EventName.Text = ds.Tables[0].Rows[0]["Header"].ToString();
                //        Session["Subject"] = "Re: "+ds.Tables[0].Rows[0]["Header"].ToString();
                //        Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
                //        EventName.NavigateUrl = "~/Event.aspx?EventID=" + ID;
                //        Session["EventID"] = ID;
                //        VenueName.Text = dsVenue.Tables[0].Rows[0]["Name"].ToString();
                //        VenueName.NavigateUrl = "Venue.aspx?ID="+dsVenue.Tables[0].Rows[0]["ID"].ToString();
                //        DateTime date = (DateTime)dsDate.Tables[0].Rows[0]["DateTimeStart"];
                //        DateAndTimeLabel.Text = date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " + date.Day + " " + date.Hour + ":" + date.Minute;
                //        string content = ds.Tables[0].Rows[0]["Content"].ToString();
                //        SendTxtID.MESSAGE = EventName.Text + " occurs at " + VenueName.Text + " on " + DateAndTimeLabel.Text;

                //        string href = Request.Url.AbsoluteUri;
                //        SendEmailID.MESSAGE = "EventName: <a class=\"AddLink\" href=\"" + href +
                //            "\">" + EventName.Text + "</a> \n\r Venue: " + VenueName.Text +
                //            " \n\r Date: " + DateAndTimeLabel.Text + " \n\r " + content;

                //        //if (fillUserData)
                //        //{
                //        //    DataSet ds2 = dat.GetData("SELECT EEL.ExcitmentLevel AS Level FROM User_Calendar UC, Event_ExcitmentLevel EEL WHERE UC.UserID="
                //        //        + Session["User"].ToString() + " AND UC.EventID = " + ID + " AND UC.ExcitmentID=EEL.ID ");

                //        //    bool addEvent = false;

                //        //    if (ds2.Tables.Count > 0)
                //        //        if (ds2.Tables[0].Rows.Count > 0)
                //        //        {
                //        //            Label label = new Label();
                //        //            label.CssClass = "AddLinkGoing";
                //        //            label.Text = "Guess What?!: you're going to this event and you are " + ds2.Tables[0].Rows[0]["Level"].ToString();
                //        //            CalendarPanel.Controls.Add(label);
                //        //        }
                //        //        else
                //        //            addEvent = true;
                //        //    else
                //        //        addEvent = true;

                //        //    if (addEvent)
                //        //    {
                //        //        ASP.controls_addtocalendar_ascx AddTo1 = new ASP.controls_addtocalendar_ascx();
                //        //        AddTo1.ID = "AddTo1";
                //        //        AddTo1.TEXT = "Add this event to calendar";
                //        //        AddTo1.EVENT_ID = int.Parse(ID);
                //        //        CalendarPanel.Controls.Add(AddTo1);
                //        //    }

                //        //}

                //        if (content.Length > 500)
                //        {
                //            ShowDescriptionBegining.Text = content.Substring(0, 500);
                //            int j = 500;
                //            if (content[500] != ' ')
                //            {

                //                while (content[j] != ' ')
                //                {
                //                    ShowDescriptionBegining.Text += content[j];
                //                    j++;
                //                }
                //            }
                //            ShowDescriptionBegining.Text = dat.BreakUpString(ShowDescriptionBegining.Text, 65);
                //            ShowRestOfDescription.Text = dat.BreakUpString(content.Substring(j), 65);
                //        }
                //        else
                //        {
                //            ShowDescriptionBegining.Text = dat.BreakUpString(content, 65);
                //            ShowRestOfDescription.Text = "";
                //        }

                //        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                //        int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());

                //        switch (mediaCategory)
                //        {
                //            case 0:
                //                break;
                //            case 1:
                //                ShowVideoPictureLiteral.Text = "<img style=\"float: left; padding-right: 10px; padding-top: 9px;\" height=\"250px\" width=\"440px\" src=\"UserFiles/" + ds.Tables[0].Rows[0]["Picture"].ToString() + "\" />";
                //                break;
                //            case 2:
                //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><embed  height=\"250px\" width=\"440px\" src=\"UserFiles/" + ds.Tables[0].Rows[0]["Video"].ToString() + "\" /></div>";
                //                break;
                //            case 3:
                //                ShowVideoPictureLiteral.Text = "<div style=\"float:left; padding-top: 9px; padding-right: 10px;\"><object width=\"440\" height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + ds.Tables[0].Rows[0]["YouTubeVideo"].ToString() + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/" + ds.Tables[0].Rows[0]["YouTubeVideo"].ToString() + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"440\" height=\"250\"></embed></object></div>";
                //                break;
                //            case 4:
                //                ShowVideoPictureLiteral.Text = "";
                //                DataSet dsSlider = dat.GetData("SELECT * FROM Event_Slider_Mapping WHERE EventID=" + ID);
                //                if (dsSlider.Tables.Count > 0)
                //                    if (dsSlider.Tables[0].Rows.Count > 0)
                //                    {
                //                        char[] delim = { '\\' };
                //                        string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\Slider\\");

                //                        string[] finalFileArray = new string[fileArray.Length];

                //                        for (int i = 0; i < fileArray.Length; i++)
                //                        {
                //                            int length = fileArray[i].Split(delim).Length;
                //                            finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + fileArray[i].Split(delim)[length - 1];
                //                        }
                //                        Rotator1.DataSource = finalFileArray;
                //                        Rotator1.DataBind();
                //                        RotatorPanel.Visible = true;
                //                    }
                //                break;
                //            default: break;
                //        }

                //        this.Title = EventName.Text;
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        try
        {
            Session["RedirectTo"] = Request.Url.AbsoluteUri;

            bool fillUserData = false;
            Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

            try
            {
                if (Session["User"] != null)
                {
                    fillUserData = true;
                }
            }
            catch (Exception ex)
            {
            }

            GetOtherVenues();
            DoHours(false);
            DoHours(true);

            if (Request.QueryString["ID"] == null)
                Response.Redirect("~/home");
            string ID = Request.QueryString["ID"].ToString();

            TagCloud.THE_ID = int.Parse(ID);

            if (Session["User"] != null)
            {
                LoggedInPanel.Visible = true;
                LoggedOutPanel.Visible = false;
                DataSet dsComments;
                string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                if (commentPrefs == "1")
                {
                    dsComments = dat.GetData("SELECT VC.CommentDate AS theDate, * FROM Venue_Comments VC, Users U WHERE VC.UserID=U.User_ID AND VC.ID=" + ID + " ORDER BY VC.CommentDate ");
                }
                else
                {
                    dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, VC.Comment, VC.CommentDate AS theDate FROM Venue_Comments VC, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=VC.UserID) OR (U.User_ID=" +
                                        Session["User"].ToString() + " AND U.User_ID=VC.UserID)) AND VC.ID=" + ID + " ORDER BY VC.CommentDate");
                }
                TheComments.DATA_SET = dsComments;
                TheComments.DataBind2(true);

               //Show edit link if use is logged in.
                EditLink.Visible = true;

                //Query whether current owner was delinquent on approve/reject changes
                //if (dat.IsOwnerDelinquent(Request.QueryString["ID"].ToString(), Request.IsLocal, "V"))
                //{
                //    //make the button visable
                //    OwnerPanel.Visible = true;
                //    Session["Message"] = "The ownership of this venue is <b>open</b>. <br/>The ownership became " +
                //        "open because the previous owner of this venue became un-responsive to rejecting/" +
                //        "approving user's changes to this venue.<br/>If you would like to become " +
                //        "the owner, click on the button below to go to the venue's edit page. <br/><br/> " +
                //        "Being the owner, you will have the privilage of having your <b>edits come though right " +
                //        "away.</b> Other participants' changes to this venue will have to be <b>approved by you.</b><br/><br/>" +
                //        "<div align=\"center\" style=\"padding-left: 110px;\"><div align=\"center\"><div style=\"cursor: pointer;cursor: pointer; float: left;padding-right: 10px;\">" +
                //            "<div class=\"topDiv\" style=\"float:left;\">" +
                //            "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonLeft.png\" height=\"27px\" />" +
                //            "<div style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('http://hippohappenings.com/NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
                //            "<a class=\"NavyLink\" onclick=\"Search('enter-locale?ID=" + Request.QueryString["ID"] +
                //            "');\">Edit</a></div>" +
                //            "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonRight.png\" height=\"27px\" />" +
                //            "</div>" +
                //            "</div>" +
                //            "</div>" +
                //            "<div align=\"center\"><div style=\"cursor: pointer;\">" +
                //            "<div class=\"topDiv\" style=\"float:left;\">" +
                //            "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonLeft.png\" height=\"27px\" />" +
                //            "<div style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('http://hippohappenings.com/NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
                //            "<a class=\"NavyLink\" onclick=\"Search();\">Close</a></div>" +
                //            "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonRight.png\" height=\"27px\" />" +
                //            "</div>" +
                //            "</div>" +
                //            "</div></div>";
                //}

                DataSet ds2 = dat.GetData("SELECT * FROM Venues WHERE ID=" + ID);

                DataView dv = new DataView(ds2.Tables[0], "", "", DataViewRowState.CurrentRows);

                if (Session["User"] != null)
                {
                    if (dv[0]["Owner"].ToString() == Session["User"].ToString())
                    {
                        EditLink.Visible = true;
                        ContactOwnerLink.Visible = false;
                    }
                    else
                    {
                        if (dv[0]["Owner"] != null && dv[0]["Owner"].ToString() != "")
                        {
                            DataView dvU = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dv[0]["Owner"].ToString());
                            EditLink.Visible = false;
                            ContactOwnerLink.Visible = true;
                            ContactOwnerLink.HRef = dvU[0]["UserName"].ToString() + "_friend";
                        }
                        else
                        {
                            ContactOwnerLink.Visible = false;
                            EditLink.Visible = true;
                        }
                    }
                }
                else
                {
                    EditLink.Visible = false;
                    ContactOwnerLink.Visible = false;
                }
            }
            else
            {
                LoggedInPanel.Visible = false;
                LoggedOutPanel.Visible = true;
                DataSet dsComments = dat.GetData("SELECT VC.CommentDate AS theDate, * FROM Venue_Comments VC, Users U WHERE VC.UserID=U.User_ID AND VC.ID=" + ID + " ORDER BY VC.CommentDate ");
                TheComments.DATA_SET = dsComments;
                TheComments.DataBind2(false);
            }

            DataSet ds = dat.GetData("SELECT * FROM Venues WHERE ID=" + ID);

            Session["FlagID"] = ID;
            Session["FlagType"] = "V";

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (bool.Parse(ds.Tables[0].Rows[0]["Live"].ToString()))
                    {
                        //Get venue's categories
                        DataSet dscat = dat.GetData("SELECT DISTINCT VC.Name, VC.ID FROM Venue_Category V_C, VenueCategories VC WHERE " +
                            "V_C.Venue_ID=" + ID + " AND V_C.Category_ID=VC.ID ");

                        #region SEO
                        topTopLiteral.Text = "<a class=\"NavyLink12UD\" href=\"#" + dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Name"].ToString()) + "\">" +
                        dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Name"].ToString()).Replace("-", " ") + " From The Top</a>";

                        string theLink = "http://" + Request.Url.Authority + "/" +
                            dat.MakeNiceName(ds.Tables[0].Rows[0]["Name"].ToString()) +
                            "_" + ID.ToString() + "_Venue";

                        HtmlHead head = (HtmlHead)Page.Header;
                        HtmlLink lk = new HtmlLink();
                        lk.Href = theLink;
                        lk.Attributes.Add("rel", "bookmark");
                        head.Controls.AddAt(0, lk);

                        //Create keyword and description meta tags
                        HtmlMeta hm = new HtmlMeta();
                        HtmlMeta kw = new HtmlMeta();
                        HtmlMeta lg = new HtmlMeta();
                        HtmlLink cn = new HtmlLink();

                        cn.Attributes.Add("rel", "canonical");
                        cn.Href = theLink;
                        head.Controls.AddAt(0, cn);

                        kw.Name = "keywords";
                        hm.Name = "Description";
                        lg.Name = "language";
                        lg.Content = "English";
                        head.Controls.AddAt(0, lg);
                        char[] delimeter = { ' ' };

                        string[] keywords = dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Name"].ToString()).Replace("-", " ").Split(delimeter, StringSplitOptions.RemoveEmptyEntries);
                        int count = 0;
                        foreach (string token in keywords)
                        {
                            if (count < 16)
                            {
                                if (kw.Content != "")
                                    kw.Content += " ";
                                kw.Content += token;

                                count++;
                            }
                        }
                        head.Controls.AddAt(0, kw);

                        hm.Content = dat.MakeNiceNameFull(dat.stripHTML(ds.Tables[0].Rows[0]["Content"].ToString()).Replace("   ", " ").Replace("  ", " ")).Replace("-", " ");
                        if (hm.Content.Length > 200)
                            hm.Content = hm.Content.Substring(0, 197) + "...";

                        head.Controls.AddAt(0, hm);

                        this.Title = kw.Content;

                        #endregion

                        VenueName.Text = "<a id=\"" + dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Name"].ToString()) + "\" class=\"aboutLink\" href=\"" +
                            theLink + "\"><h1>" + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 50) + "</h1></a>";
                        Session["Subject"] = "Re: " + ds.Tables[0].Rows[0]["Name"].ToString();
                        Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Name"].ToString();

                        string Venue = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);

                        string url = ds.Tables[0].Rows[0]["Web"].ToString();
                        if (url.Length > 8)
                        {
                            if (url.ToLower().Substring(0, 7) != "http://" && url.ToLower().Substring(0, 8) != "https://")
                                url = "http://" + url;
                        }

                        PhoneLabel.Text = "Phone: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Phone"].ToString(), 15) + "<br/>Email: " +
                            dat.BreakUpString(ds.Tables[0].Rows[0]["Email"].ToString(), 15) + "<br/>Web: <a class='AddLink' target='_blank' href='" + url + "'>" +
                            dat.BreakUpString(ds.Tables[0].Rows[0]["Web"].ToString(), 17) + "</a>";

                        DataSet dsCountry = new DataSet();
                        string country = "";
                        if (ds.Tables[0].Rows[0]["Country"] != null)
                        {
                            dsCountry = dat.GetData("SELECT country_2_code FROM Countries WHERE country_id=" + ds.Tables[0].Rows[0]["Country"].ToString());
                            if (dsCountry.Tables[0].Rows.Count > 0)
                            {
                                country = dsCountry.Tables[0].Rows[0]["country_2_code"].ToString();
                            }
                        }
                        if (country.ToLower() == "us")
                        {
                            try
                            {
                                AddressLabel.Text = dat.GetAddress(ds.Tables[0].Rows[0]["Address"].ToString(), false);
                            }
                            catch (Exception ex1)
                            {
                                AddressLabel.Text = "";
                            }
                        }
                        else
                        {

                            AddressLabel.Text = dat.GetAddress(ds.Tables[0].Rows[0]["Address"].ToString(), true);

                        }

                        //if (ds.Tables[0].Rows[0]["Country"].ToString() == "222")
                        //{
                        //    CityState.Text = ds.Tables[0].Rows[0]["City"].ToString();
                        //}
                        //else
                        //{
                            CityState.Text = ds.Tables[0].Rows[0]["City"].ToString() + " " +
                            ds.Tables[0].Rows[0]["State"].ToString() + " " + ds.Tables[0].Rows[0]["Zip"].ToString();
                        //}

                        HttpCookie cookie2 = new HttpCookie("addressParameter");
                        HttpCookie cookiename = new HttpCookie("addressParameterName");
                        if (country.ToLower() == "uk")
                        {
                            //VenueName.Text + "@&" +
                            cookie2.Value = AddressLabel.Text + "@&" +
                                ds.Tables[0].Rows[0]["City"].ToString() + ", " +
                                ds.Tables[0].Rows[0]["Zip"].ToString() + ", " + country;

                            cookiename.Value = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                        }
                        else
                        {
                            //VenueName.Text + "@&" +
                            cookie2.Value = AddressLabel.Text + "@&" + CityState.Text + "@&" + country;
                            cookiename.Value = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                        }
                        cookie2.Expires = DateTime.Now.Add(new TimeSpan(1, 0, 0));
                        cookiename.Expires = DateTime.Now.Add(new TimeSpan(1, 0, 0));

                        Response.Cookies.Add(cookie2);
                        Response.Cookies.Add(cookiename);

                        string content = ds.Tables[0].Rows[0]["Content"].ToString();

                        Session["messageText"] = "Venue: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + ". Address: " + AddressLabel.Text + ", " + CityState.Text;
                        Session["messageEmail"] = "Venue: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + " \n\r Address: " + AddressLabel.Text + " \n\r Location: " +
                            CityState.Text + " \n\r " + content;

                        ShowDescriptionBegining.Text = dat.BreakUpString(content, 60);

                        CalendarLink.NavigateUrl = dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14)) + "_" + ID + "_Calendar";

                        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                        int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());

                        DataSet dsEvents = dat.GetData("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS [End], " +
                            "E.Header, E.ID, E.ShortDescription FROM Event_Occurance EO, Events E WHERE " +
                            "(CONVERT(NVARCHAR,DAY(EO.DateTimeStart)) + '.' + CONVERT(NVARCHAR,MONTH(EO.DateTimeStart)) + " +
                            "'.' + CONVERT(NVARCHAR,YEAR(EO.DateTimeStart))) = (CONVERT(NVARCHAR,DAY(GETDATE())) + " +
                            "'.' + CONVERT(NVARCHAR,MONTH(GETDATE())) + '.' + CONVERT(NVARCHAR,YEAR(GETDATE())))" +
                            "AND EO.EventID=E.ID AND E.Venue=" + ID + " ORDER BY Start");
                        bool noEvents = false;
                        EventsPanel.Controls.Clear();
                        if (dsEvents.Tables.Count > 0)
                            if (dsEvents.Tables[0].Rows.Count > 0)
                            {
                                int eventCount = dsEvents.Tables[0].Rows.Count;

                                for (int i = 0; i < eventCount; i++)
                                {
                                    HyperLink eventHeader = new HyperLink();
                                    eventHeader.CssClass = "NavyLink16UD";
                                    eventHeader.NavigateUrl = dat.MakeNiceName(dsEvents.Tables[0].Rows[i]["Header"].ToString())+"_" + dsEvents.Tables[0].Rows[i]["ID"].ToString()+"_Event";
                                    eventHeader.Text = dsEvents.Tables[0].Rows[i]["Header"].ToString() + "<br/>";

                                    Label dateStart = new Label();
                                    dateStart.CssClass = "Text12UDPd";
                                    dateStart.Text = DateTime.Parse(dsEvents.Tables[0].Rows[i]["Start"].ToString()).ToShortTimeString() + " - " +
                                        DateTime.Parse(dsEvents.Tables[0].Rows[i]["End"].ToString()).ToShortTimeString() + "<br/>";

                                    Label shortDescription = new Label();
                                    shortDescription.CssClass = "Text12Pd";
                                    shortDescription.Text = dsEvents.Tables[0].Rows[i]["ShortDescription"].ToString() + "<br/>";

                                    EventsPanel.Controls.Add(eventHeader);
                                    EventsPanel.Controls.Add(dateStart);
                                    EventsPanel.Controls.Add(shortDescription);
                                }
                            }
                            else
                            {
                                noEvents = true;
                            }
                        else
                        {
                            noEvents = true;
                        }

                        if (noEvents)
                        {
                            Label eventHeader = new Label();
                            eventHeader.Text = "There are no events at " + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + " today.";
                            EventsPanel.Controls.Add(eventHeader);
                        }

                        //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                        string youtube = ds.Tables[0].Rows[0]["YouTubeVideo"].ToString();
                        Rotator1.Items.Clear();
                        switch (mediaCategory)
                        {
                            case 0:
                                break;
                            case 1:
                                char[] delim4 = { ';' };
                                string[] youtokens = youtube.Split(delim4);
                                if (youtube != "")
                                {
                                    for (int i = 0; i < youtokens.Length; i++)
                                    {
                                        if (youtokens[i].Trim() != "")
                                        {
                                            Literal literal3 = new Literal();
                                            literal3.Text = "<div class=\"FloatLeft\"><object width=\"412\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                                "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + youtokens[i] +
                                                "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"412\" height=\"250\"></embed></object></div>";
                                            Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                            r3.Controls.Add(literal3);
                                            Rotator1.Items.Add(r3);
                                        }
                                    }
                                }

                                DataView dsSlider = dat.GetDataDV("SELECT * FROM Venue_Slider_Mapping WHERE VenueID=" + ID);
                                if (dsSlider.Count > 0)
                                    {
                                        char[] delim = { '\\' };
                                        char[] delim3 = { '.' };

                                        for (int i = 0; i < dsSlider.Count; i++)
                                        {
                                            string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                            //dsSlider.RowFilter = "RealPictureName='" + tokens[0] + "." + tokens[1] + "'";
                                            if (tokens.Length >= 2)
                                            {
                                                if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                                {
                                                    try
                                                    {
                                                        System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") +
                                                            "\\VenueFiles\\" + ID + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                                                        int width = 410;
                                                        int height = 250;

                                                        int newHeight = 0;
                                                        int newIntWidth = 0;

                                                        //if image height is less than resize height
                                                        if (height >= image.Height)
                                                        {
                                                            //leave the height as is
                                                            newHeight = image.Height;

                                                            if (width >= image.Width)
                                                            {
                                                                newIntWidth = image.Width;
                                                            }
                                                            else
                                                            {
                                                                newIntWidth = width;

                                                                double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                                newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                                newHeight = (int)newDoubleHeight;
                                                            }
                                                        }
                                                        //if image height is greater than resize height...resize it
                                                        else
                                                        {
                                                            //make height equal to the requested height.
                                                            newHeight = height;

                                                            //get the ratio of the new height/original height and apply that to the width
                                                            double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                            double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                            newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                            newIntWidth = (int)newDoubleWidth;

                                                            //if the resized width is still to big
                                                            if (newIntWidth > width)
                                                            {
                                                                //make it equal to the requested width
                                                                newIntWidth = width;

                                                                //get the ratio of old/new width and apply it to the already resized height
                                                                theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                                newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                                newHeight = (int)newDoubleHeight;
                                                            }
                                                        }

                                                        Literal literal4 = new Literal();
                                                        string[] nameTokens = dsSlider[i]["RealPictureName"].ToString().Split(delim3);
                                                        string realName = dat.MakeNiceName(nameTokens[0]).Replace("_", " ");
                                                        literal4.Text = "<div class=\"RotatorImage\"><img alt=\"" + realName +
                                                            "\" style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                        + "VenueFiles/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString() + "\" /></div>";
                                                        Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                        r4.Controls.Add(literal4);
                                                        Rotator1.Items.Add(r4);
                                                    }
                                                    catch (Exception ex)
                                                    {

                                                    }
                                                }
                                                else if (tokens[1].ToUpper() == "WMV")
                                                {
                                                    Literal literal4 = new Literal();
                                                    literal4.Text = "<div style=\"width: 410px; height: 250px;\" ><OBJECT stop=\"true\" loop=\"false\" controller=\"true\" wmode2=\"opaque\" wmode=\"transparent\" autoplay=\"false\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " +
                                                        "width=\"410\" height=\"250\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">" +
                                                        "<param name=\"src\" value=\"UserFiles/Events/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString() + "\"></param>" +
                                                        "<param name=\"autoplay\" value=\"false\"></param><param name=\"wmode\" value=\"transparent\"></param>" +
                                                        "<param name=\"controller\" value=\"true\"></param>" +
                                                        "<param name=\"stop\" value=\"true\" ></param>" +
                                                        "<param name=\"loop\" value=\"false\"><param  name=\"wmode2\" value=\"opaque\" ></param>" +
                                                        "<EMBED stop=\"true\" wmode=\"transparent\" wmode2=\"opaque\" src=\"UserFiles/Events/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString() + "\" width=\"410\" height=\"250\" autoplay=\"false\" " +
                                                        "controller=\"true\" loop=\"false\" bgcolor=\"#000000\" pluginspage=\"http://www.apple.com/quicktime/download/\">" +
                                                        "</EMBED>" +
                                                        "</OBJECT></div>";

                                                    //literal4.Text = "<div style=\"float:left;\"><embed  height=\"250px\" width=\"400px\" src=\""
                                                    //    + "VenueFiles/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" /></div>";
                                                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                    r4.Controls.Add(literal4);
                                                    Rotator1.Items.Add(r4);
                                                }

                                            }
                                        }
                                    }
                                break;
                            default: break;
                        }

                        if (Rotator1.Items.Count == 0)
                            RotatorPanel.Visible = false;
                        else
                        {
                            RotatorPanel.Visible = true;
                            if (Rotator1.Items.Count == 1)
                            {
                                RotatorPanel.CssClass = "HiddeButtons";
                            }
                        }
                        if (fillUserData)
                        {
                            ASP.controls_addtofavorites_ascx AddTo1 = new ASP.controls_addtofavorites_ascx();
                            AddTo1.VENUE_ID = int.Parse(ID);

                            ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                            SendMessage1.THE_TEXT = "Share on Hippo";
                            SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                                " would like to share the venue '\"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14) + "\"' with you.";
                            SendMessage1.TYPE = "v";
                            SendMessage1.ID = int.Parse(ID);

                            CalendarPanel.Controls.Add(AddTo1);
                            CalendarPanel.Controls.Add(SendMessage1);
                        }

                        this.Title = dat.BreakUpString(ds.Tables[0].Rows[0]["Name"].ToString(), 14);
                    }
                    else
                    {
                        Response.Redirect("~/home");
                    }
                }
                else
                {
                    Response.Redirect("~/home");
                }
            }
            else
            {
                Response.Redirect("~/home");
            }

        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }
    protected void GetChart()
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        ConsumerRadChart.Series.Clear();
        ConsumerRadChart.Clear();
        ConsumerRadChart.PlotArea.Chart.Series.Clear();
        ConsumerRadChart.PlotArea.XAxis.Clear();
        ConsumerRadChart.PlotArea.YAxis.Clear();

        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        string adID = AdDropDown.SelectedItem.Value;
        DataView dvAd = dat.GetDataDV("SELECT * FROM Ads WHERE Ad_ID=" + adID);
        DataView dvAdCategories = dat.GetDataDV("SELECT DISTINCT  AC.Name, ACM.CategoryID FROM "+
            "Ad_Category_Mapping ACM, AdCategories AC WHERE AC.ID=ACM.CategoryID AND ACM.AdID=" + adID);
        TitleLabel.Text = "<span style=\"font-size: 30px;color: white;\">Statistics For Ad: <a href=\"" +
            "http://" + Request.Url.Authority + "/" +
                    dat.MakeNiceName(dat.BreakUpString(dvAd[0]["Header"].ToString(), 14)) +
                    "_" + adID + "_Ad\" style=\"color: #1fb6e7; text-decoration: none;\">" +
            dvAd[0]["Header"].ToString() + "</a></span><hr>";

        TitleLabel.Text += "<table cellspacing=\"20px\"><tr valign=\"top\"><td>";

        if (bool.Parse(dvAd[0]["BigAd"].ToString()))
            TitleLabel.Text += "<br/><b>Ad Type: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Big Ad</span>";
        else
            TitleLabel.Text += "<br/><b>Ad Type: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Normal Ad</span>";

        int totalViews = int.Parse(dvAd[0]["NumViews"].ToString());
        int currentViews = int.Parse(dvAd[0]["NumCurrentViews"].ToString());

        DataView dvAdStatistics = dat.GetDataDV("SELECT CASE WHEN UserID IS NULL THEN IP "+
            "ELSE CONVERT(NVARCHAR,UserID) END AS theID, Reason, LocationOnly, Date, WasEmail "+
            "FROM AdStatistics WHERE AdID=" + adID + " ORDER BY [Date] DESC");
        DataView dvAdStatisticsCovert = dat.GetDataDV("SELECT CASE WHEN LocationOnly = 'True' THEN 'Location Only' " +
            "WHEN WasEmail = 'True' THEN 'Email View' WHEN Reason = 'NonAssigned' THEN 'Non-Assigned User' " +
            "ELSE dbo.GetCategories(Reason) END AS 'Reason', CASE WHEN LocationOnly = 'True' THEN 'Location Only' " +
            "WHEN WasEmail = 'True' THEN 'Email View' WHEN Reason = 'NonAssigned' THEN 'Non-Assigned User' " +
            "ELSE dbo.GetCategories(Reason) END AS 'Reason For View [Location Only, " +
            "Non-Assigned User or list of Categories]', Date " +
            "FROM AdStatistics WHERE AdID=" + adID + " GROUP BY [Date], UserID, IP, LocationOnly, WasEmail, Reason ORDER BY [Date] DESC");

        string lastDayDay = "";
        if (dvAdStatistics.Count > 0)
            lastDayDay = DateTime.Parse(dvAdStatistics[0]["Date"].ToString()).Date.ToShortDateString();

        dvAdStatistics.RowFilter = "WasEmail = 1";
        int wasEmailCount = dvAdStatistics.Count;
        int notEmailCount = currentViews - wasEmailCount;
        dvAdStatistics.RowFilter = "";
        if (currentViews < totalViews)
        {
            TitleLabel.Text += "<br/><b>Status: </b><span style=\"color: #1fb6e7; font-weight: bold;\">Ad is still running</span>";
            TitleLabel.Text += "<br/><b>Number of Views Needed: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + totalViews.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Number of Current Views: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + currentViews.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views by Email: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + wasEmailCount.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views on Site: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + notEmailCount.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Display To All: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["DisplayToAll"].ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Display To Non-Users: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["NonUsersAllowed"].ToString() + "</span>";
            TitleLabel.Text += "</td></tr></table>";
        }
        else
        {
            TitleLabel.Text += "<br/><b>Ad has finished running on:</b> <span style=\"color: #1fb6e7; font-weight: bold;\">" + lastDayDay + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Views by Email: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + wasEmailCount.ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Views on Site: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + notEmailCount.ToString() + "</span>";
            TitleLabel.Text += "</td><td>";
            TitleLabel.Text += "<br/><b>Display To All: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["DisplayToAll"].ToString() + "</span>";
            TitleLabel.Text += "<br/><b>Display To Non-Users: </b><span style=\"color: #1fb6e7; font-weight: bold;\">" + dvAd[0]["NonUsersAllowed"].ToString() + "</span>";
            TitleLabel.Text += "</td></tr></table>";
        }

        //Construct the chart
        //for each entry in AdStatistics table for this particular ad
            //get the number of different categories it was in
                //One of the categories will be the location
            //increment each category if exists in AdStatistics entry
            //each category will have it's own series

        ArrayList listOfCategories = new ArrayList(dvAdCategories.Count);
        Hashtable hashOfCategories = new Hashtable();

        char[] delim = { ';' };
        string[] tokens;

        //Get the hash of the count of all the categories of the reason why the ad was seen.
        Literal ListofUsersLiteral = new Literal();
        //ListofUsersLiteral.Text = "<table cellpadding=\"10px\" style=\"font-size: 12px;border: solid 1px #1fb6e7; background-color: #1b1b1b;\"><tr><td>" +
        //    "<span style=\"font-size: 14px; font-weight: bold;\"></span>"+
        //    "</td><td><span style=\"font-size: 14px; font-weight: bold;\">";

        //LinkButton linkButt = new LinkButton();
        //linkButt.Text = "Reason For View [Location Only, Non-Assigned User or list of Categories]";
        //linkButt.Click += new EventHandler(SortReason);
        //PanelofUsers.Controls.Add(linkButt);

        //ListofUsersLiteral = new Literal();
        //ListofUsersLiteral.Text = "</span>" +
        //    "</td><td><span style=\"font-size: 14px; font-weight: bold;\">";
        //PanelofUsers.Controls.Add(ListofUsersLiteral);

        //linkButt = new LinkButton();
        //linkButt.Text = "Date";
        //linkButt.Click += new EventHandler(SortDate);
        //PanelofUsers.Controls.Add(linkButt);

        //ListofUsersLiteral = new Literal();
        //ListofUsersLiteral.Text = "</span></td></tr>";
        //PanelofUsers.Controls.Add(ListofUsersLiteral);

        for (int i = 0; i < dvAdStatisticsCovert.Count; i++)
        {
            ListofUsersLiteral.Text += "<tr><td>" + (i + 1).ToString() + "</td><td>";
            //ListofUsersLiteral.Text += dvAdStatisticsCovert[i]["Reason"].ToString();
            if (bool.Parse(dvAdStatistics[i]["LocationOnly"].ToString()))
            {
                ListofUsersLiteral.Text += "Location Only";
                if (hashOfCategories.ContainsKey("-1"))
                {
                    hashOfCategories["-1"] = int.Parse(hashOfCategories["-1"].ToString()) + 1;
                }
                else
                {
                    hashOfCategories["-1"] = 1;
                }
            }
            else
            {
                if (dvAdStatistics[i]["Reason"].ToString().Trim() != "NonAssigned")
                {
                    tokens = dvAdStatistics[i]["Reason"].ToString().Split(delim);

                    for (int j = 0; j < tokens.Length; j++)
                    {
                        if (tokens[j].Trim() != "")
                        {
                            dvAdCategories.RowFilter = "CategoryID = " + tokens[j];
                            if (dvAdCategories.Count > 0)
                                ListofUsersLiteral.Text += dvAdCategories[0]["Name"].ToString() + ", ";
                            if (hashOfCategories.ContainsKey(tokens[j].Trim()))
                            {
                                hashOfCategories[tokens[j].Trim()] =
                                    int.Parse(hashOfCategories[tokens[j].Trim()].ToString()) + 1;
                            }
                            else
                            {
                                hashOfCategories.Add(tokens[j].Trim(), 1);
                            }
                        }
                    }
                    if (ListofUsersLiteral.Text.Substring(ListofUsersLiteral.Text.Length - 2, 2) == ", ")
                        ListofUsersLiteral.Text = ListofUsersLiteral.Text.Substring(0, ListofUsersLiteral.Text.Length - 2);
                }
                else
                {
                    ListofUsersLiteral.Text += "Non-Assigned User";
                    if (hashOfCategories.ContainsKey("-2"))
                    {
                        hashOfCategories["-2"] = int.Parse(hashOfCategories["-2"].ToString()) + 1;
                    }
                    else
                    {
                        hashOfCategories["-2"] = 1;
                    }
                }
            }
            ListofUsersLiteral.Text += "</td><td>" +
                DateTime.Parse(dvAdStatistics[i]["Date"].ToString()).ToShortDateString() + "</td>"+
                "<td>" + dvAdStatistics[i]["WasEmail"].ToString() + "</td>" +
                "</tr>";
        }

        dvAdCategories.RowFilter = "";
        //ListofUsersLiteral.Text += "</table>";

        PanelofUsers.Controls.Add(ListofUsersLiteral);

        System.Drawing.Color level4Colora = System.Drawing.Color.FromArgb(51, 51, 51);
        System.Drawing.Color level4Colorb = System.Drawing.Color.FromArgb(134, 175, 200);
        System.Drawing.Color level3Colora = System.Drawing.Color.FromArgb(33, 65, 11);
        System.Drawing.Color level3Colorb = System.Drawing.Color.FromArgb(115, 148, 77);
        System.Drawing.Color level2Colora = System.Drawing.Color.FromArgb(213, 79, 2);
        System.Drawing.Color level2Colorb = System.Drawing.Color.FromArgb(244, 189, 67);
        System.Drawing.Color level1Colora = System.Drawing.Color.FromArgb(192, 140, 8);
        System.Drawing.Color level1Colorb = System.Drawing.Color.FromArgb(227, 201, 70);

        ConsumerRadChart.Chart.Series.Clear();

        ConsumerRadChart.Chart.ChartTitle.TextBlock.Text = "Ad Statistics for '" + dvAd[0]["Header"].ToString() + "'. Date: " + lastDayDay.Trim();
        ConsumerRadChart.Chart.ChartTitle.TextBlock.Appearance.AutoTextWrap = Telerik.Charting.Styles.AutoTextWrap.True;

        //Put the UserCount into the DV so that we can easily bind it to the chart
        DataTable dt = dvAdCategories.ToTable();
        DataColumn dc = new DataColumn("UserCount");
        DataColumn dc2 = new DataColumn("XCount");
        dt.Columns.Add(dc);
        dt.Columns.Add(dc2);
        DataRow row;
        int colcount = 0;
        for (int i = 0; i < dvAdCategories.Count; i++)
        {
            if (hashOfCategories.ContainsKey(dvAdCategories[i]["CategoryID"].ToString()))
            {
                dt.Rows[i]["UserCount"] = int.Parse(hashOfCategories[dvAdCategories[i]["CategoryID"].ToString()].ToString());
                dt.Rows[i]["XCount"] = colcount;
                colcount++;
            }
        }

        if (hashOfCategories.ContainsKey("-1"))
        {
            row = dt.NewRow();
            row["UserCount"] = hashOfCategories["-1"].ToString();
            row["Name"] = "Location Only";
            row["CategoryID"] = "-1";
            row["XCount"] = colcount;
            dt.Rows.Add(row);
        }

        if (hashOfCategories.ContainsKey("-2"))
        {
            row = dt.NewRow();
            row["UserCount"] = hashOfCategories["-2"].ToString();
            row["Name"] = "Non-Assigned User";
            row["CategoryID"] = "-2";
            row["XCount"] = colcount + 1;
            dt.Rows.Add(row);
        }

        dvAdCategories = new DataView(dt, "", "", DataViewRowState.CurrentRows);

        dvAdCategories.RowFilter = "Isnull(UserCount,'Null Column') <> 'Null Column'";

        ChartSeries salesSeries1;
        int itemsCount = 0;
        ConsumerRadChart.DataGroupColumn = "Name";
        ConsumerRadChart.DataSource = dvAdCategories;

        int maxYCount = 0;
        ConsumerRadChart.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Between;
        ConsumerRadChart.PlotArea.XAxis.AutoShrink = true;
        ConsumerRadChart.SeriesOrientation = Telerik.Charting.ChartSeriesOrientation.Vertical;
        ConsumerRadChart.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
        for (int i = 0; i < dvAdCategories.Count; i++)
        {
            if (hashOfCategories.ContainsKey(dvAdCategories[i]["CategoryID"].ToString()))
            {

                //TitleLabel.Text += "<br/><br/>"+i.ToString()+": "+dvAdCategories[i]["Name"].ToString()+", userCount" +
                //dvAdCategories[i]["UserCount"].ToString() + ", XCount: "+dvAdCategories[i]["XCount"].ToString() +
                //", catID: " + dvAdCategories[i]["CategoryID"].ToString();

                salesSeries1 = new ChartSeries(dvAdCategories[i]["Name"].ToString(), ChartSeriesType.Bar);
                //salesSeries1.Appearance.LabelAppearance.Visible = false;
                for (int j = 0; j < itemsCount; j++)
                {
                    ChartSeriesItem chartSI = new ChartSeriesItem(true);
                    chartSI.Visible = false;
                    salesSeries1.Items.Add(chartSI);
                }
                salesSeries1.DataYColumn = "UserCount";
                salesSeries1.DataXColumn = "XCount";
                salesSeries1.DataLabelsColumn = "UserCount";
                ConsumerRadChart.AddChartSeries(salesSeries1);
                salesSeries1.Items.Add(new ChartSeriesItem(double.Parse(dvAdCategories[i]["UserCount"].ToString()),
                    dvAdCategories[i]["UserCount"].ToString()));
                salesSeries1.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 45;
                ConsumerRadChart.PlotArea.XAxis.AddItem(dvAdCategories[i]["Name"].ToString());
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Text = dvAdCategories[i]["Name"].ToString();
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].Appearance.RotationAngle = 45;
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Bottom;

                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.Y = float.Parse("-30.00");
                //ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Bottom;
                ConsumerRadChart.PlotArea.XAxis.Items[itemsCount].TextBlock.Appearance.Position.Auto = true;

                itemsCount++;

                if (int.Parse(dvAdCategories[i]["UserCount"].ToString()) > maxYCount)
                    maxYCount = int.Parse(dvAdCategories[i]["UserCount"].ToString());
            }
        }

        //if (hashOfCategories.ContainsKey("Location Only"))
        //{
        //    ConsumerRadChart.PlotArea.XAxis.AddItem("Location Only");
        //    ConsumerRadChart.PlotArea.XAxis.Items[ConsumerRadChart.PlotArea.XAxis.Items.Count - 1].TextBlock.Text = "Location Only";
        //    salesSeries1 = new ChartSeries("Location Only", ChartSeriesType.Bar);
        //    salesSeries1.Items.Clear();
        //    ChartSeriesItem item = new ChartSeriesItem(int.Parse(hashOfCategories["Location Only"].ToString()),
        //        "Location Only");
        //    item.YValue = itemsCount;
        //    salesSeries1.AddItem(item);
        //    ConsumerRadChart.AddChartSeries(salesSeries1);
        //    ConsumerRadChart.DataBind();
        //    if (int.Parse(hashOfCategories["Location Only"].ToString()) > maxYCount)
        //        maxYCount = int.Parse(hashOfCategories["Location Only"].ToString());
        //}
        //else
        //{
        //    //ChartSeriesItem item = new ChartSeriesItem(0, "Location Only");
        //    //item.XValue = ConsumerRadChart.PlotArea.XAxis.Items.Count;

        //    //salesSeries1.Items.Add(item);
        //}

        ConsumerRadChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Categories";
        ConsumerRadChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Number of Views";
        ConsumerRadChart.Chart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Categories";
        ConsumerRadChart.Chart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Number of Views";
        ConsumerRadChart.Chart.PlotArea.XAxis.AxisLabel.Appearance.Dimensions.Height = 200;
        ConsumerRadChart.Chart.PlotArea.YAxis.LabelStep = 1;
        ConsumerRadChart.Chart.PlotArea.XAxis.LabelStep = 1;
        ConsumerRadChart.Chart.PlotArea.YAxis.AutoScale = false;
        ConsumerRadChart.Chart.PlotArea.YAxis.AxisMode = ChartYAxisMode.Normal;
        ConsumerRadChart.Chart.PlotArea.YAxis.MaxValue = maxYCount + 2;
        ConsumerRadChart.Chart.PlotArea.YAxis.Step = 1;
        ConsumerRadChart.Chart.PlotArea.Appearance.Dimensions.Margins.Right = 200;
        ConsumerRadChart.Chart.PlotArea.XAxis.AutoScale = false;

        //ConsumerRadChart.Chart.PlotArea.XAxis.MaxValue = dvAdCategories.Count + 2;
        //ConsumerRadChart.Chart.PlotArea.XAxis.Step = 1;
        //ConsumerRadChart.DataBind();

        ChartPanel.Visible = true;
    }
Esempio n. 13
0
    protected void DrawAd(int nextAdIndex, DataView dvAds)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        DataView dvAd = dat.GetDataDV("SELECT * FROM Ads WHERE Ad_ID = " + dvAds[nextAdIndex]["Ad_ID"].ToString());
        DataView dvUser = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dvAd[0]["User_ID"].ToString());
        string templateID = dvAd[0]["Template"].ToString();

        string w = "0";
        string h = "0";

        if (templateID == "1")
        {
            Template1Panel.Visible = true;
            Template2Panel.Visible = false;
            CustomerImage.AlternateText = dvAds[nextAdIndex]["Header"].ToString();
            if (dvAds[nextAdIndex]["FeaturedPicture"].ToString() == "" || dvAds[nextAdIndex]["FeaturedPicture"] == null)
            {
                CustomerImage.Visible = false;
                TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 21);
            }
            else
            {
                CustomerImage.Visible = true;
                GetAdSize(out w, out h, dvUser[0]["UserName"].ToString() + "\\" +
            dvAds[nextAdIndex]["FeaturedPicture"].ToString(), templateID);
                CustomerImage.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() +
                    "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString();
                CustomerImage.Width = int.Parse(w);
                CustomerImage.Height = int.Parse(h);
                TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 10);
            }

            TitleLabel.Text = dvAds[nextAdIndex]["Header"].ToString();

            if (windowT)
            {
                TitleLabel.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');");
                ReadMoreLink.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');");
                A1.HRef = "javascript:CloseWindow('../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad');";
            }
            else
            {
                TitleLabel.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                ReadMoreLink.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                A1.HRef = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
            }

            BodyLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["FeaturedSummary"].ToString(), 21);
        }
        else
        {
            Template1Panel.Visible = false;
            Template2Panel.Visible = true;
            Image1.AlternateText = dvAds[nextAdIndex]["Header"].ToString();
            if (dvAds[nextAdIndex]["FeaturedPicture"].ToString() == "" || dvAds[nextAdIndex]["FeaturedPicture"] == null)
            {
                Image1.Visible = false;
            }
            else
            {
                GetAdSize(out w, out h, dvUser[0]["UserName"].ToString() + "\\" +
            dvAds[nextAdIndex]["FeaturedPicture"].ToString(), templateID);
                Image1.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() +
                    "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString();
                Image1.Width = int.Parse(w);
                Image1.Height = int.Parse(h);
            }

            if (windowT)
            {
                Image1.Attributes.Add("onclick", "CloseWindow('" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "');");
            }
            else
            {
                Image1.Attributes.Add("onclick", "window.location = '" + "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad" + "'");
            }
        }

        if (Request.Url.AbsolutePath.ToLower() == "/group.aspx")
        {
            dat.CountGroupAds(int.Parse(dvAds[nextAdIndex]["Ad_ID"].ToString()));
        }
        else
        {
            if (Session["User"] != null)
            {
                dat.CountAd(true, dvAds);
            }
            else
            {
                dat.CountAdAnonymous(true, dvAds);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Literal lit = new Literal();
        lit.Text = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAjjoxQtYNtdn3Tc17U5-jbBR2Kk_H7gXZZZniNQ8L14X1BLzkNhQjgZq1k-Pxm8FxVhUy3rfc6L9O4g\" type=\"text/javascript\"></script>";
        Master.HEAD_TAG.Controls.Add(lit);
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        string command = "";
        try
        {
            DataView dvGroup = dat.GetDataDV("SELECT * FROM GroupEvents WHERE ID=" + Request.QueryString["ID"].ToString());
            DataView dvRealGroup = dat.GetDataDV("SELECT * FROM Groups WHERE ID=" +
                dvGroup[0]["GroupID"].ToString());

            string groupID = dvRealGroup[0]["ID"].ToString();

            #region Take Care of Style
            ColorAa_1.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_1.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_1.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorAa_2.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_2.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_2.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorAa_3.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_3.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_3.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorBa_1.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBb_1.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBa_1.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            //ColorBa_2.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            //ColorBb_2.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            //ColorBa_2.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            ColorBa_3.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBb_3.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBa_3.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            ColorBa_4.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBb_4.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBa_4.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            MapLabels.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString() + " !important");
            #endregion

            command = "SELECT * FROM GroupEvent_Occurance WHERE ID=" + Request.QueryString["O"].ToString();
            DataView dvEvent = dat.GetDataDV(command);

            if (dvEvent.Count == 0)
            {
                command = "SELECT * FROM GroupEvent_Occurance WHERE GroupEventID=" +
                    Request.QueryString["ID"].ToString();
                dvEvent = dat.GetDataDV(command);
                if (dvEvent.Count > 0)
                {
                    Response.Redirect(dat.MakeNiceName(dvGroup[0]["Name"].ToString()) + "_" + dvEvent[0]["ID"].ToString() + "_" + Request.QueryString["ID"].ToString() + "_GroupEvent");
                }
                else
                {
                    Response.Redirect(dat.MakeNiceName(dvRealGroup[0]["Name"].ToString()) +
                        "_" + dvRealGroup[0]["ID"].ToString() + "_Group");
                }
            }

            DateAndTimeLabel.Text = dvEvent[0]["DateTimeStart"].ToString() + " -- " + dvEvent[0]["DateTimeEnd"].ToString();

            GroupLabel.Text = dvRealGroup[0]["Header"].ToString();
            GroupLabel.NavigateUrl = dat.MakeNiceName(dvRealGroup[0]["Header"].ToString()) + "_" + dvRealGroup[0]["ID"].ToString() + "_Group";
            Page.Title = dvGroup[0]["Name"].ToString() + " | Hippo Group Event";

            if (!IsPostBack)
            {
                Session["RedirectTo"] = Request.Url.AbsoluteUri;
            }

            string country = dat.GetDataDV("SELECT * FROM Countries WHERE country_id=" + dvEvent[0]["Country"].ToString())[0]["country_name"].ToString();

            Literal liter = new Literal();
            liter.Text = "<link type=\"text/css\" href=\"Rads.css\" rel=\"stylesheet\" />";
            Page.Header.Controls.Add(liter);

            bool isMember = false;
            #region Take care of user types
            if (Session["User"] != null)
            {
                #region Take care of Share with friends and Share though email and Flag
                LoggedInPanel.Visible = true;

                ShareFriends.THE_TEXT = "Share this with a friend";
                ShareFriends.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                    " would like to share the group event '\"" + dat.BreakUpString(dvGroup[0]["Name"].ToString(), 14) +
                    "\"' with you.";
                ShareFriends.TYPE = "ge";
                ShareFriends.ID = int.Parse(Request.QueryString["ID"].ToString());

                string descrip = dvGroup[0]["Content"].ToString();
                if (descrip.Length > 200)
                    descrip = descrip.Substring(0, 200) + "...";

                Session["messageEmail"] = "Group Event Name: <a href=\"http://hippohappenings.com/" +
                    dat.MakeNiceName(dat.BreakUpString(dvGroup[0]["Name"].ToString(), 14)) + "_" +
                    Request.QueryString["O"].ToString() + "_" +
                    Request.QueryString["ID"].ToString() + "_GroupEvent\">" +
                            dat.BreakUpString(dvGroup[0]["Name"].ToString(), 14) + "</a><br/><br/> " +
                            descrip;
                Session["FlagID"] = Request.QueryString["ID"].ToString();
                Session["FlagType"] = "GE";
                Session["ReOccurID"] = Request.QueryString["O"].ToString();

                DataView dvMember = dat.GetDataDV("SELECT * FROM Group_Members WHERE GroupID=" +
                    dvGroup[0]["GroupID"].ToString() + " AND MemberID=" + Session["User"].ToString());
                PostMessageID.Attributes.Add("onclick", "OpenMess('" + Request.QueryString["ID"].ToString() +
                    "', '" + Request.QueryString["O"].ToString() + "')");
                #endregion

                switch (dvGroup[0]["EventType"].ToString())
                {
                    case "1":
                        PrivateLabel.Text = "Public Event";
                        break;
                    case "2":
                        PrivateLabel.Text = "Private Event";
                        break;
                    case "3":
                        PrivateLabel.Text = "Exclusive Event";
                        break;
                    default: break;
                }

                DataView dvGoingMember = dat.GetDataDV("SELECT * FROM GroupEvent_Members WHERE GroupEventID=" +
                        Request.QueryString["ID"].ToString() + " AND Accepted='True' AND ReoccurrID=" +
                        Request.QueryString["O"].ToString());
                dvGoingMember.RowFilter = "UserID=" + Session["User"].ToString();

                //if it's a public event
                if(dvGroup[0]["EventType"].ToString() == "1")
                    dvGoingMember = dat.GetDataDV("SELECT * FROM User_GroupEvent_Calendar WHERE GroupEventID=" +
                        Request.QueryString["ID"].ToString() + " AND ReoccurrID=" +
                        Request.QueryString["O"].ToString());

                dvGoingMember.RowFilter = "UserID=" + Session["User"].ToString();

                AreGoingPanel.Visible = false;
                RegistrationEndedPanel.Visible = false;
                GoingPanel.Visible = true;

                if (dvGoingMember.Count > 0)
                {
                    AreGoingPanel.Visible = true;
                    RegistrationEndedPanel.Visible = false;
                    GoingPanel.Visible = false;
                }
                else
                {
                    dvGoingMember.RowFilter = "";
                    if (dvGroup[0]["RegType"].ToString() == "2")
                    {
                        if (dvGroup[0]["RegNum"] != null)
                        {
                            if (dvGroup[0]["RegNum"].ToString().Trim() != "")
                            {
                                if (dvGoingMember.Count >= int.Parse(dvGroup[0]["RegNum"].ToString()))
                                {
                                    AreGoingPanel.Visible = false;
                                    RegistrationEndedPanel.Visible = true;
                                    GoingPanel.Visible = false;
                                }
                                else
                                {
                                    AreGoingPanel.Visible = false;
                                    RegistrationEndedPanel.Visible = false;
                                    GoingPanel.Visible = true;
                                }
                            }

                            if (dvGroup[0]["RegDeadline"] != null)
                            {
                                if (dvGroup[0]["RegDeadline"].ToString().Trim() != "")
                                {
                                    if (DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")) >
                                        DateTime.Parse(dvGroup[0]["RegDeadline"].ToString()))
                                    {
                                        AreGoingPanel.Visible = false;
                                        RegistrationEndedPanel.Visible = true;
                                        GoingPanel.Visible = false;
                                    }
                                }
                            }
                        }

                        if (dvGroup[0]["RegDeadline"] != null)
                        {
                            if (dvGroup[0]["RegDeadline"].ToString().Trim() != "")
                            {
                                if (DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")) >
                                    DateTime.Parse(dvGroup[0]["RegDeadline"].ToString()))
                                {
                                    AreGoingPanel.Visible = false;
                                    RegistrationEndedPanel.Visible = true;
                                    GoingPanel.Visible = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        DataView dvInvitedMember = dat.GetDataDV("SELECT * FROM GroupEvent_Members WHERE GroupEventID=" +
                        Request.QueryString["ID"].ToString() + " AND ReoccurrID=" +Request.QueryString["O"].ToString());

                        DataView dvMember2 = dat.GetDataDV("SELECT * FROM Group_Members WHERE GroupID=" +
                            groupID + " AND MemberID=" + Session["User"].ToString());

                        if (dvGroup[0]["EventType"].ToString() == "2")
                        {
                            if (dvMember2.Count > 0)
                            {
                                AreGoingPanel.Visible = false;
                                RegistrationEndedPanel.Visible = false;
                                GoingPanel.Visible = true;
                            }
                            else
                            {
                                AreGoingPanel.Visible = false;
                                RegistrationEndedPanel.Visible = false;
                                GoingPanel.Visible = false;
                            }
                        }
                        else if (dvGroup[0]["EventType"].ToString() == "3")
                        {
                            dvInvitedMember.RowFilter = "UserID=" + Session["User"].ToString();
                            if (dvInvitedMember.Count > 0)
                            {
                                AreGoingPanel.Visible = false;
                                RegistrationEndedPanel.Visible = false;
                                GoingPanel.Visible = true;
                            }
                            else
                            {
                                AreGoingPanel.Visible = false;
                                RegistrationEndedPanel.Visible = false;
                                GoingPanel.Visible = false;
                            }
                        }
                        else
                        {
                            AreGoingPanel.Visible = false;
                            RegistrationEndedPanel.Visible = false;
                            GoingPanel.Visible = true;
                        }

                    }
                }

                if (dvMember.Count > 0)
                {
                    isMember = true;
                    if (bool.Parse(dvMember[0]["SharedHosting"].ToString()))
                    {
                        Session["isHost"] = true;
                        HostHeaderPanel.Visible = true;
                        MemberHeaderPanel.Visible = false;
                        //if is host, take care of host options
                        LinkButton1.Attributes.Add("onclick", "window.location='EnterGroupEvent.aspx?ID=" + Request.QueryString["ID"].ToString() + "&GroupID=" + dvGroup[0]["GroupID"].ToString() + "&O=" + Request.QueryString["O"].ToString() + "';");
                        LinkButton2.Attributes.Add("onclick", "window.location='EnterGroupEvent.aspx?copy=true&ID=" + Request.QueryString["ID"].ToString()  + "&GroupID=" + dvGroup[0]["GroupID"].ToString() + "';");
                        Label1.Attributes.Add("onclick", "OpenSendMess('" + Request.QueryString["ID"].ToString() + "')");
                        Label3.Attributes.Add("onclick", "OpenParticipants('" + Request.QueryString["ID"].ToString() +
                            "', '" + Request.QueryString["O"].ToString() + "')");
                        Label2.Attributes.Add("onclick", "OpenGroupEventDelete('" + Request.QueryString["ID"].ToString() +
                            "', '" + Request.QueryString["O"].ToString() + "')");
                    }
                    else
                    {
                        Session["isHost"] = false;
                        Session["isMember"] = true;
                        HostHeaderPanel.Visible = false;
                        MemberHeaderPanel.Visible = true;
                    }
                    PostMessagePanel.Visible = true;
                }
                else
                {
                    Session["isHost"] = false;
                    Session["isMember"] = false;
                    HostHeaderPanel.Visible = false;
                    MemberHeaderPanel.Visible = false;
                    PostMessagePanel.Visible = false;
                }
            }
            else
            {
                Session["isHost"] = false;
                Session["isMember"] = false;
                HostHeaderPanel.Visible = false;
                MemberHeaderPanel.Visible = false;
                PostMessagePanel.Visible = false;
            }
            #endregion

            #region Members
            string members = "";
            string friendImg = "";
            string strFill = "";
            string title = "";
            string description = "";
            string mem = "";
            FillMembers();
            #endregion

            #region Stuff we need
            DataView dvStuff = dat.GetDataDV("SELECT * FROM GroupEvent_StuffNeeded WHERE GroupEventID=" +
                Request.QueryString["ID"].ToString());
            if (dvStuff.Count > 0)
                StuffsPanel.Visible = true;
            CheckBox check;
            DataView dvUserID;
            bool userNotGrabbed = false;

            bool isStuffCheckable = bool.Parse(dvGroup[0]["StuffNeededCheckable"].ToString());

            foreach (DataRowView row in dvStuff)
            {
                userNotGrabbed = false;
                if (row["UserID"] == null)
                {
                    userNotGrabbed = true;
                }
                else
                {
                    if (row["UserID"].ToString() == "")
                        userNotGrabbed = true;
                    else
                    {
                        //if (isMember)
                        //{
                        if (isStuffCheckable)
                        {
                            dvUserID = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + row["UserID"].ToString());
                            string addthis = "";

                            if (Session["User"] != null)
                            {
                                if (row["UserID"].ToString() == Session["User"].ToString())
                                {
                                    addthis = "<div style=\"float: left;\"><img style=\"cursor: pointer;\" name=\"remove the user\" src=\"image/X.png\" onclick=\"RemoveStuffUser('" + row["ID"].ToString() +
                                    "');\" onmouseout=\"this.src = 'image/X.png';\" " +
                                    "onmouseover=\"this.src = 'image/XSelected.png';\" /></div>";
                                }
                            }
                            lit = new Literal();
                            lit.ID = "lit" + row["ID"].ToString();
                            lit.Text = "<div class=\"topDiv\" width=\"400px\" style=\"padding-top: 5px;\"><div style=\"float: left;\"><ul style=\"font-weight: bold;padding: 0; margin: 0; color: #" + dvGroup[0]["TextA"].ToString() + " !important;padding-left: 22px;\"><li><span style=\"color: #" + dvGroup[0]["TextA"].ToString() + " !important; font-size: 14px;\"><div style=\"float: left;\">" + row["StuffNeeded"].ToString() +
                                " -- </div><div style=\"float: left;padding-left: 5px;\"><div style=\"float: left;\"><div style=\"height: 19px; background-position: left; background-repeat: no-repeat; background-image: url(images/UserNameLeft.png); " +
                                "padding-left: 4px;\"><div style=\"height: 19px; background-repeat: no-repeat; background-position: right; " +
                                "background-image: url(images/UserNameRight.png); " +
                                "padding-right: 4px;\"><div style=\"height: 19px; background-repeat: repeat-x; " +
                                "background-image: url(images/UserNameMiddle.png);\"><a style=\"float: left;padding-bottom: 0px;\" href=\"" + dvUserID[0]["UserName"].ToString() + "_Friend\" class=\"AddLink\">" +
                                    dvUserID[0]["UserName"].ToString() + "</a></div></div></div></div></div></span></li></ul></div>" + addthis + "</div>";
                            StuffWeNeedPanel.Controls.Add(lit);
                        }
                        else
                        {
                            lit = new Literal();
                            lit.ID = "lit" + row["ID"].ToString();
                            lit.Text = "<div class=\"topDiv\" width=\"400px\" style=\"padding-top: 5px;\">"+
                                "<div style=\"float: left;\"><ul style=\"font-weight: bold;padding: 0; margin: 0; "+
                                "color: #" + dvGroup[0]["TextA"].ToString() + " !important;padding-left: 22px;\">"+
                                "<li><span style=\"color: #" + dvGroup[0]["TextA"].ToString() + " !important; "+
                                "font-size: 14px;\"><div style=\"float: left;\">" + row["StuffNeeded"].ToString() +
                                "</div></span></li></ul></div></div>";
                            StuffWeNeedPanel.Controls.Add(lit);
                        }
                        //}
                    }
                }

                if (isMember)
                {
                    if (userNotGrabbed)
                    {
                        if (isStuffCheckable)
                        {
                            check = new CheckBox();
                            check.ID = "check" + row["ID"].ToString();
                            check.Text = row["StuffNeeded"].ToString();
                            check.AutoPostBack = true;
                            check.CheckedChanged += new EventHandler(StuffGrabbed);
                            check.ForeColor = System.Drawing.ColorTranslator.FromHtml("#" + dvGroup[0]["TextB"].ToString());
                            check.Font.Size = 14;

                            lit = new Literal();
                            lit.Text = "<div width=\"400px\">";

                            StuffWeNeedPanel.Controls.Add(lit);
                            StuffWeNeedPanel.Controls.Add(check);

                            lit = new Literal();
                            lit.Text = "</div>";
                            StuffWeNeedPanel.Controls.Add(lit);
                        }
                        else
                        {
                            lit = new Literal();
                            lit.Text = "<div width=\"400px\" style=\"padding-top: 5px;\"><ul style=\"font-weight: bold;padding: 0; margin: 0; color: #" +
                                dvGroup[0]["TextB"].ToString() + " !important;padding-left: 22px;\"><li><span style=\" color: #" +
                                dvGroup[0]["TextB"].ToString() + " !important; font-size: 14px;\">" + row["StuffNeeded"].ToString() +
                                "</span></li></ul></div>";
                            StuffWeNeedPanel.Controls.Add(lit);
                        }
                    }
                }
                else
                {
                    if (userNotGrabbed)
                    {
                        lit = new Literal();
                        lit.Text = "<div width=\"400px\" style=\"padding-top: 5px;\"><ul style=\"font-weight: bold;padding: 0; margin: 0; color: #" +
                            dvGroup[0]["TextB"].ToString() + " !important;padding-left: 22px;\"><li><span style=\" color: #" +
                            dvGroup[0]["TextB"].ToString() + " !important; font-size: 14px;\">" + row["StuffNeeded"].ToString() +
                            "</span></li></ul></div>";
                        StuffWeNeedPanel.Controls.Add(lit);
                    }
                }
            }
            #endregion

            DataView dvUser = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dvGroup[0]["UserID"].ToString());

            HostLabel.Text = dvUser[0]["UserName"].ToString();
            HostLabel.NavigateUrl = HostLabel.Text + "_Friend";
            EventName.Text = dvGroup[0]["Name"].ToString();

            #region Event Message Board
            DataView dvMessages = dat.GetDataDV("SELECT *, GM.ID AS MessageID FROM GroupEventMessages GM, Users U WHERE GM.GroupEventID=" +
                Request.QueryString["ID"].ToString() + " AND GM.UserID=U.User_ID");
            DataView dvSticky = dat.GetDataDV("SELECT *, GM.ID AS MessageID FROM GroupEventMessages GM, Group_Members M, Users U WHERE GM.GroupEventID=" +
                Request.QueryString["ID"].ToString() + " AND GM.UserID=U.User_ID and M.GroupID=" +
                dvGroup[0]["GroupID"].ToString() + " AND M.MemberID=U.User_ID AND M.SharedHosting='True' AND GM.isSticky='True'");
            members = "";
            friendImg = "";
            strFill = "";
            description = "";

            string stickyID = "";

            if (dvSticky.Count > 0)
            {
                dvSticky.Sort = "DatePosted DESC";

                stickyID = dvSticky[0]["MessageID"].ToString();

                if (System.IO.File.Exists(Server.MapPath(".") + "\\UserFiles\\" + dvSticky[0]["UserName"].ToString() +
                            "\\Profile\\" + dvSticky[0]["ProfilePicture"].ToString()))
                {
                    friendImg = "UserFiles/" + dvSticky[0]["UserName"].ToString() + "/Profile/" + dvSticky[0]["ProfilePicture"].ToString();
                    strFill = "";
                }
                else
                {
                    friendImg = "image/noAvatar_50x50_small.png";
                    strFill = "onmouseover=\"this.src='NewImages/noAvatar_50x50_smallhover.png'\"" +
                        "onmouseout=\"this.src='image/noAvatar_50x50_small.png'\" ";
                }
                string imgLit = "";
                if (Session["User"] != null)
                {
                    if (Session["User"].ToString() == dvSticky[0]["User_ID"].ToString())
                    {
                        imgLit = "<div style=\"float: right;\"><img style=\"cursor: pointer;\" name=\"remove stickyness\" src=\"image/X.png\" onclick=\"OpenRemoveSticky('" + Request.QueryString["ID"].ToString() +
                            "', '" + stickyID + "', '"+Request.QueryString["O"].ToString()+"');\" onmouseout=\"this.src = 'image/X.png';\" " +
                            "onmouseover=\"this.src = 'image/XSelected.png';\" /></div>";
                    }
                }

                members = imgLit + "<div style=\"border-bottom: solid 1px #1b1b1b;float: left; clear: both; padding-left: 3px; padding-top: 5px;\"><a target='_blank' href=\"" + dvSticky[0]["UserName"].ToString() + "_Friend\"><img " + strFill +
                    " style=\" border: 0;float: left;padding-right: 7px; padding-bottom: 2px;\" " +
                                "src=\"" + friendImg + "\" width=\"50px\" height=\"50px\" /></a><div style=\"float: left;\"><div style=\"height: 19px; background-position: left; background-repeat: no-repeat; background-image: url(images/UserNameLeft.png); " +
                                "padding-left: 4px;\"><div style=\"height: 19px; background-repeat: no-repeat; background-position: right; " +
                                "background-image: url(images/UserNameRight.png); " +
                                "padding-right: 4px;\"><div style=\"height: 19px; background-repeat: repeat-x; " +
                                "background-image: url(images/UserNameMiddle.png);\"><a style=\"float: left;padding-bottom: 0px;\" href=\"" + dvSticky[0]["UserName"].ToString() + "_Friend\" class=\"AddLink\">" +
                                dvSticky[0]["UserName"].ToString() +
                                "</a></div></div></div></div><span class=\"MemberTitle\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;-&nbsp;Posted On: " +
                                dvSticky[0]["DatePosted"].ToString().Trim() +
                                "</span> - <span style=\"color: #ff6b09; font-size: 30px;font: bold;\">!</span>" +
                                "<span class=\"MemberDescription\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;&nbsp;" + dvSticky[0]["Content"].ToString() +
                                "</span><span style=\"font: bold;color: #ff6b09; font-size: 30px;\">!</span></div>";

                StickyMessageLiteral.Text = members;
            }

            members = "";

            if (stickyID != "")
            {
                dvMessages.RowFilter = "MessageID <> " + stickyID;
            }

            if (dvMessages.Count == 0)
            {
                lit = new Literal();
                lit.Text = "<div class=\"EventMemberDescription\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">No messages have been posted for this group.</div>";
                MessagesPanel.Controls.Add(lit);
            }
            else
            {
                dvMessages.Sort = "DatePosted DESC";
                foreach (DataRowView row in dvMessages)
                {
                    if (System.IO.File.Exists(Server.MapPath(".") + "\\UserFiles\\" + row["UserName"].ToString() +
                                "\\Profile\\" + row["ProfilePicture"].ToString()))
                    {
                        friendImg = "UserFiles/" + row["UserName"].ToString() + "/Profile/" + row["ProfilePicture"].ToString();
                        strFill = "";
                    }
                    else
                    {
                        friendImg = "image/noAvatar_50x50_small.png";
                        strFill = "onmouseover=\"this.src='NewImages/noAvatar_50x50_smallhover.png'\"" +
                            "onmouseout=\"this.src='image/noAvatar_50x50_small.png'\" ";
                    }

                    description = "<span class=\"MemberDescription\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;&nbsp;" + row["Content"].ToString().Trim() + "</span>";

                    members += "<div style=\"float: left; clear: both; padding-left: 3px; padding-top: 5px;\"><a target='_blank' href=\"" + row["UserName"].ToString() + "_Friend\"><img " + strFill +
                        " style=\" border: 0;float: left;padding-right: 7px; padding-bottom: 2px;\" " +
                                    "src=\"" + friendImg + "\" width=\"50px\" height=\"50px\" /></a><div style=\"float: left;\"><div style=\"height: 19px; background-position: left; background-repeat: no-repeat; background-image: url(images/UserNameLeft.png); " +
                                "padding-left: 4px;\"><div style=\"height: 19px; background-repeat: no-repeat; background-position: right; " +
                                "background-image: url(images/UserNameRight.png); " +
                                "padding-right: 4px;\"><div style=\"height: 19px; background-repeat: repeat-x; " +
                                "background-image: url(images/UserNameMiddle.png);\"><a style=\"float: left;padding-bottom: 0px;\" href=\"" + row["UserName"].ToString() + "_Friend\" class=\"AddLink\">" +
                                    row["UserName"].ToString() + "</a></div></div></div></div><span class=\"MemberTitle\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;-&nbsp;Posted On: " + row["DatePosted"].ToString().Trim() + "</span> - " + description + "</div>";
                }

                lit = new Literal();
                lit.Text = members;
                MessagesPanel.Controls.Add(lit);
            }
            #endregion

            #region Take care of Groupings
            DataView dvGroupings = dat.GetDataDV("SELECT * FROM GroupEvent_Groupings WHERE GroupEventID=" + Request.QueryString["ID"].ToString());
            DataView dvGroupingMembers = dat.GetDataDV("SELECT * FROM GroupEvent_UserGroupings GG, Users U "+
                "WHERE GG.UserID=U.User_ID AND GG.GroupEventID=" + Request.QueryString["ID"].ToString());

            if (dvGroupings.Count > 0)
            {
                string headerStr = "";
                string usersStr = "";
                GroupingLabel.Text = "Groupings";
                Telerik.Web.UI.RadToolTip tip;
                foreach (DataRowView row in dvGroupings)
                {
                    lit = new Literal();
                    lit.Text = "<div style=\"float: left; padding-bottom: 10px;\">";
                    GroupingPanel.Controls.Add(lit);

                    Label lab = new Label();
                    lab.Text = row["GroupingName"].ToString();
                    lab.CssClass = "AddWhiteLink";
                    lab.ID = "tooltip" + row["ID"].ToString();

                    GroupingPanel.Controls.Add(lab);

                    tip = new RadToolTip();
                    tip.Text = "<div class=\"EventDiv\"><label>" + row["GroupingDescription"].ToString() + "</label></div>";
                    tip.TargetControlID = lab.ClientID;
                    tip.IsClientID = true;
                    tip.ManualClose = true;
                    tip.Position = ToolTipPosition.MiddleRight;
                    tip.RelativeTo = ToolTipRelativeDisplay.Element;
                    tip.Skin = "Black";
                    tip.Width = 200;
                    tip.ShowEvent = ToolTipShowEvent.OnClick;
                    GroupingPanel.Controls.Add(tip);

                    lit = new Literal();
                    lit.Text = "<br/>";
                    GroupingPanel.Controls.Add(lit);

                    dvGroupingMembers.RowFilter = "GroupingID=" + row["ID"].ToString();

                    headerStr = "";
                    foreach (DataRowView row2 in dvGroupingMembers)
                    {
                        friendImg = "";
                        strFill = "";
                        if (System.IO.File.Exists(Server.MapPath(".") + "\\UserFiles\\" + row2["UserName"].ToString() +
                                    "\\Profile\\" + row2["ProfilePicture"].ToString()))
                        {
                            friendImg = "UserFiles/" + row2["UserName"].ToString() + "/Profile/" +
                                row2["ProfilePicture"].ToString();
                            strFill = "";
                        }
                        else
                        {
                            friendImg = "image/noAvatar_50x50_small.png";
                            strFill = "onmouseover=\"this.src='NewImages/noAvatar_50x50_smallhover.png'\"" +
                                "onmouseout=\"this.src='image/noAvatar_50x50_small.png'\" ";
                        }

                        headerStr += "<div style=\"float: left; clear: both; padding-left: 3px; padding-top: 5px;\"><a target='_blank' href=\"" + row2["UserName"].ToString() + "_Friend\"><img " + strFill +
                            " style=\" border: 0;float: left;padding-right: 7px; padding-bottom: 2px;\" " +
                                        "src=\"" + friendImg + "\" title=\"" + row2["UserName"].ToString() +
                                        "\" name=\"" + row2["UserName"].ToString() +
                                        "\" width=\"50px\" height=\"50px\" /></a></div><br/>";
                    }
                    headerStr += "</div>";

                    lit = new Literal();
                    lit.Text = headerStr;
                    GroupingPanel.Controls.Add(lit);
                }
            }
            else
            {
                MembersPanel.Width = 435;
            }
            #endregion

            //other details

            DescriptionLiteral.Text = "<div style=\"color: White; font-size: 18px;padding-bottom: 3px;border-bottom: solid 1px #" + dvGroup[0]["ColorA"].ToString() + ";\" " +
                    ">Our Event Details</div>";

            if (dvGroup[0]["Agenda"] != null)
            {
                if (dvGroup[0]["Agenda"].ToString().Trim() != "")
                {
                    AgendaLiteral.Text = MakeAgenda(dvGroup[0]["Agenda"].ToString()).Replace("color: #cccccc;", "color: #" + dvGroup[0]["TextB"].ToString() + ";");
                    AgendaPanel.Visible = true;
                }
                else
                    AgendaPanel.Visible = false;
            }
            else
            {
                AgendaPanel.Visible = false;
            }

            //TagCloud.THE_ID = int.Parse(Request.QueryString["ID"].ToString());

            GroupDescriptionLabel.Text = dvGroup[0]["Content"].ToString();

            HostLabel.Text = dvUser[0]["UserName"].ToString();

            #region Take care of map
            HttpCookie cookie2 = new HttpCookie("addressParameterName");
            cookie2.Value = dvGroup[0]["Name"].ToString();
            cookie2.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie2);
            bool isVenue = false;
            string address = "";

            if (dvEvent[0]["VenueID"] != null)
            {
                if (dvEvent[0]["VenueID"].ToString().Trim() != "")
                {
                    DataView dvVenue = dat.GetDataDV("SELECT * FROM Venues WHERE ID=" + dvEvent[0]["VenueID"].ToString());
                    NameOfPlaceLabel.Text = dvVenue[0]["Name"].ToString() + "<br />";
                    address = dat.GetAddress(dvVenue[0]["Address"].ToString(), dvVenue[0]["Country"].ToString() != "223");
                    isVenue = true;

                    Address1Label.Text = address;

                    Address2Label.Visible = false;

                    CityStateZipLabel.Text = dvVenue[0]["City"].ToString() + ", " +
                    dvVenue[0]["State"].ToString() + " " + dvVenue[0]["Zip"].ToString();
                }
                else
                    NameOfPlaceLabel.Visible = false;

            }
            else
                NameOfPlaceLabel.Visible = false;

            if (!isVenue)
            {
                if (dvEvent[0]["Country"].ToString() == "223")
                {
                    address = dvEvent[0]["StreetNumber"].ToString() + " " + dvEvent[0]["StreetName"].ToString() +
                        " " + dvEvent[0]["StreetDrop"].ToString();
                }
                else
                {
                    address = dvEvent[0]["Location"].ToString();
                }
            }

            cookie2 = new HttpCookie("addressParameter");
            cookie2.Value = address + " " + dvEvent[0]["City"].ToString() + " " + dvEvent[0]["State"].ToString() +
                " " + dvEvent[0]["Zip"].ToString() + " " + country;
            cookie2.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie2);

            lit = new Literal();
            lit.Text = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAjjoxQtYNtdn3Tc17U5-jbBR2Kk_H7gXZZZniNQ8L14X1BLzkNhQjgZq1k-Pxm8FxVhUy3rfc6L9O4g\" type=\"text/javascript\"></script>";
            Page.Header.Controls.Add(lit);

            Master.BodyTag.Attributes.Add("onload", "initialize();");
            Master.BodyTag.Attributes.Add("onunload", "GUnload()");

            if (!isVenue)
            {
                if (dvEvent[0]["Country"].ToString() == "223")
                    Address1Label.Text = dvEvent[0]["StreetNumber"].ToString() + " " +
                        dvEvent[0]["StreetName"].ToString() + " " + dvEvent[0]["StreetDrop"].ToString();
                else
                    Address1Label.Text = dvEvent[0]["Location"].ToString();

                if (dvEvent[0]["AptName"].ToString().Trim() != "")
                {
                    Address2Label.Text = dvEvent[0]["AptName"].ToString() + " " +
                        dvEvent[0]["AptNo"].ToString() + "<br/>";
                }
                else
                    Address2Label.Visible = false;

                CityStateZipLabel.Text = dvEvent[0]["City"].ToString() + ", " +
                    dvEvent[0]["State"].ToString() + " " + dvEvent[0]["Zip"].ToString();
            }

            #endregion

            #region Take care of images and youtube
            char[] delim4 = { ';' };

            DataView dsSlider = dat.GetDataDV("SELECT * FROM GroupEvent_Slider_Mapping WHERE GroupEventID=" + Request.QueryString["ID"].ToString());
            if (dsSlider.Count > 0)
            {
                char[] delim = { '\\' };
                char[] delim3 = { '.' };

                for (int i = 0; i < dsSlider.Count; i++)
                {
                    string caption = "";
                    if (dsSlider[i]["Caption"] != null)
                    {
                        if (dsSlider[i]["Caption"].ToString().Trim() != "")
                        {
                            caption = "<div class=\"CaptionText\">" + dsSlider[i]["Caption"].ToString().Trim() + "</div>";
                        }
                    }
                    string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                    //dsSlider.RowFilter = "RealPictureName='" + tokens[0] + "." + tokens[1] + "'";
                    if (tokens.Length >= 2)
                    {
                        if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                        {
                            System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") +
                                "\\GroupEventFiles\\" + Request.QueryString["ID"].ToString() + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                            int width = 400;
                            int height = 250;

                            int newHeight = 0;
                            int newIntWidth = 0;

                            //if image height is less than resize height
                            if (height >= image.Height)
                            {
                                //leave the height as is
                                newHeight = image.Height;

                                if (width >= image.Width)
                                {
                                    newIntWidth = image.Width;
                                }
                                else
                                {
                                    newIntWidth = width;

                                    double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                    newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                    newHeight = (int)newDoubleHeight;
                                }
                            }
                            //if image height is greater than resize height...resize it
                            else
                            {
                                //make height equal to the requested height.
                                newHeight = height;

                                //get the ratio of the new height/original height and apply that to the width
                                double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                newIntWidth = (int)newDoubleWidth;

                                //if the resized width is still to big
                                if (newIntWidth > width)
                                {
                                    //make it equal to the requested width
                                    newIntWidth = width;

                                    //get the ratio of old/new width and apply it to the already resized height
                                    theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                    newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                    newHeight = (int)newDoubleHeight;
                                }
                            }

                            Literal literal4 = new Literal();
                            literal4.Text = "<div style=\"width: 400px; height: 250px;background-color: black;\">" +
                                "<img align=\"middle\" style=\"cursor: default; margin-left: " +
                                ((400 - newIntWidth) / 2).ToString() + "px; margin-top: " +
                                ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight +
                                "px\" width=\"" + newIntWidth + "px\" height=\"" + height.ToString() + "px\" width=\"" + width.ToString() +
                                "px\" src=\"" + "GroupEventFiles/" + Request.QueryString["ID"].ToString() + "/Slider/" + dsSlider[i]["PictureName"].ToString() +
                                "\" /></div>" + caption;
                            Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                            r4.Controls.Add(literal4);
                            Rotator1.Items.Add(r4);
                        }
                    }
                    else
                    {
                        Literal literal3 = new Literal();
                        literal3.Text = "<div class=\"topDiv\"><div style=\"float:left;background-color: black;\"><object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + dsSlider[i]["PictureName"].ToString() +
                            "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + dsSlider[i]["PictureName"].ToString() +
                            "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"400\" height=\"250\"></embed></object></div>" + caption + "</div>";
                        Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                        r3.Controls.Add(literal3);
                        Rotator1.Items.Add(r3);
                    }
                }
            }

            if (Rotator1.Items.Count == 0)
                RotatorPanel.Visible = false;
            else
            {
                RotatorPanel.Visible = true;
                if (Rotator1.Items.Count == 1)
                {
                    RotatorPanel.CssClass = "HiddeButtons";
                }
            }
            #endregion

            //Digg
            DiggLiteral.Text = "<table style=\"padding-top: 5px;\"> " +
                           " <tr>" +
                               " <td valign=\"bottom\" style=\"padding-right: 0px;\">" +
                                 "   <a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>" +
                                "</td>" +
                                "<td valign=\"bottom\" style=\"padding-right: 0px;\">" +
                                "    <a style=\"border: 0; padding: 0; margin: 0;\" id=\"TweeterA\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>" +
                                "</td>" +
                                "<td valign=\"bottom\">" +
                                  "  <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">" +
                                       " <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />" +
                                  "  </a>" +
                                "</td>" +
                                "<td><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                            "href='http://digg.com/submit?phase=2&url=" + "http://" +
                            Request.Url.Authority + "/" +
                            dat.MakeNiceName(dvGroup[0]["Name"].ToString()) +
                            "_" + Request.QueryString["ID"].ToString() + "_GroupEvent" +
                            "' target=\"_blank\">Digg</a> </td>" +
                                "<td>" +
                                   " <a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
                                   "     <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
                                   " </a>" +
                                "</td>" +
                               " <td>" +
                               "      <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                               " </td>" +
                           " </tr>" +
                        "</table>";
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString() + "<br/>" + command;
        }
    }
Esempio n. 15
0
    protected void DoAds()
    {
        string message = "";
        try
        {

            Rotator2.Width = theWidth;
            HttpCookie cookie = Request.Cookies["BrowserDate"];
            if (cookie == null)
            {
                cookie = new HttpCookie("BrowserDate");
                cookie.Value = DateTime.Now.Date.ToString();
                cookie.Expires = DateTime.Now.AddDays(22);
                Response.Cookies.Add(cookie);
            }

            DateTime isn = DateTime.Now;

            if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
                isn = DateTime.Now;
            DateTime isNow = isn;
            Data dat = new Data(isn);
            string timeFrame = " AND DatesOfAd LIKE '%;" +
                isNow.Month.ToString() + "/" + isNow.Day.ToString() + "/" + isNow.Year.ToString() + ";%' ";

            string country = Session["LocCountry"].ToString().Trim();
            string state = Session["LocState"].ToString().Trim();
            string zip = "";
            string city = "";
            GetMajorLocation(out zip, out city, out state, out country);

            if (Session["SeenNum"] == null)
                Session["SeenNum"] = 0;
            else
            {
                Session["SeenNum"] = int.Parse(Session["SeenNum"].ToString()) + 1;
            }

            DataView dvAds = dat.GetDataDV("SELECT DISTINCT *, ROW_NUMBER() OVER(ORDER BY DateAdded ASC) AS Row FROM Ads A, Users U WHERE " +
                "A.User_ID=U.User_ID AND A.Featured='True' AND A.CatCountry = " +
                country + " AND A.CatState = '" + state +
                "' AND A.CatCity = '" + city +
                "'" + timeFrame +" ORDER BY DateAdded ASC");

            Telerik.Web.UI.RadRotatorItem item;
            Literal lit;
            string w = "0";
            string h = "0";
            Rotator2.Items.Clear();

            int numAds = 4;
            if (isDouble)
                numAds = 2;

            int startIndex = int.Parse(Session["SeenNum"].ToString()) * numAds;

            if (startIndex > dvAds.Count - 1)
            {
                Session["SeenNum"] = 0;
                startIndex = 0;
            }

            int cutOff = 20;
            int count = 0;
            int indexToUse = startIndex;

            if (dvAds.Count == 0)
            {
                UpdatePanel1.Visible = false;
            }
            else
            {
                UpdatePanel1.Visible = true;
                for (int i = 0; i < dvAds.Count; i++)
                {
                    if (count < cutOff)
                    {
                        count++;
                        lit = new Literal();
                        lit.Text = "";

                        indexToUse = i + startIndex;
                        if (indexToUse > dvAds.Count - 1)
                        {
                            indexToUse = 0;
                            startIndex = -i;
                        }

                        if (dvAds[indexToUse]["Template"].ToString() == "1" || dvAds[indexToUse]["Template"].ToString() == "")
                        {
                            lit.Text = "<div align=\"center\" class=\"AdTemplate1\"><div align=\"center\" class=\"AdTemplate1Wrapper\">";

                            if (dvAds[indexToUse]["FeaturedPicture"] != null)
                            {
                                if (dvAds[indexToUse]["FeaturedPicture"].ToString().Trim() != "")
                                {
                                    GetAdSize(ref w, ref h, dvAds[indexToUse]["UserName"].ToString() + "\\" +
                                        dvAds[indexToUse]["FeaturedPicture"].ToString(), "1");

                                    lit.Text += "<div class=\"AdTemplate1Inner\"><table width=\"100px\" height=\"100px\" " +
                                        "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\"> " +
                                        "<img alt=\"" + dat.MakeNiceNameFull(dvAds[indexToUse]["Header"].ToString()).Replace("-", " ") + "\" onclick=\"window.location = '../" + dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad'\" class=\"AdImage\" width=\"" + w +
                                            "px\" Height=\"" + h + "px\" src=\"UserFiles/" + dvAds[indexToUse]["UserName"].ToString() +
                                            "/" + dvAds[indexToUse]["FeaturedPicture"].ToString() + "\" /> " +
                                        "</td></tr></tbody></table></div>";
                                }
                            }

                            string headerStr = dat.BreakUpString(dvAds[indexToUse]["Header"].ToString(), 10);

                            lit.Text += "<div><h1 class=\"Text14\"><a class=\"AdsTitle\" href=\"../" + dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad\">" + headerStr +
                                            "</a></h1></div></div>" +
                                "<div align=\"center\" class=\"AdTemplate1InnerInner\"> " +
                                "<span class=\"Text12\">" +
                                dat.BreakUpString(dvAds[indexToUse]["FeaturedSummary"].ToString(), 21) + "</span>" +

                                "</div>" +
                                "<div><a class=\"ReadMoreHome\" href=\"../" +
                                dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad\">Read More</a>" +
                                "</div></div>";
                        }
                        else if (dvAds[indexToUse]["Template"].ToString() == "2")
                        {
                            lit.Text = "<div align=\"center\" class=\"AdTemplate1\"><div class=\"AdTemplate2Wrapper\">";

                            if (dvAds[indexToUse]["FeaturedPicture"] != null)
                            {
                                if (dvAds[indexToUse]["FeaturedPicture"].ToString().Trim() != "")
                                {
                                    GetAdSize(ref w, ref h, dvAds[indexToUse]["UserName"].ToString() + "\\" +
                                        dvAds[indexToUse]["FeaturedPicture"].ToString(), "2");
                                    lit.Text += "<div class=\"AdTemplate1Inner\"><table width=\"198px\" height=\"140px\" " +
                                        "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\"> " +
                                        "<img alt=\"" + dat.MakeNiceNameFull(dvAds[indexToUse]["Header"].ToString()).Replace("-", " ") + "\" onclick=\"window.location = '../" + dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad'\" class=\"AdImage\" width=\"" + w +
                                            "px\" Height=\"" + h + "px\" src=\"UserFiles/" + dvAds[indexToUse]["UserName"].ToString() +
                                            "/" + dvAds[indexToUse]["FeaturedPicture"].ToString() + "\" runat=\"server\" /> " +
                                        "</td></tr></tbody></table></div>";
                                }
                            }

                            string headerStr = dat.BreakUpString(dvAds[indexToUse]["Header"].ToString(), 21);

                            lit.Text += "</div><div class=\"AdTemplate2Inner\"><h1 class=\"Text14\"><a class=\"AdsTitle\" href=\"../" + dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad\" class=\"Text14\">" + headerStr +
                                            "</a></h1></div>" +
                                "<div align=\"center\" class=\"AdTemplate2InnerInner\"> " +
                                "<span class=\"Text12\">" +
                                dat.BreakUpString(dvAds[indexToUse]["FeaturedSummary"].ToString(), 21) + "</span>" +
                                "</div>" +
                                "<div><a class=\"ReadMoreHome\" href=\"../" +
                                dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad\">Read More</a>" +
                                "</div></div>";
                        }
                        else if (dvAds[indexToUse]["Template"].ToString() == "3")
                        {
                            lit.Text = "<div class=\"AdTemplate1\"><div>";

                            if (dvAds[indexToUse]["FeaturedPicture"] != null)
                            {
                                if (dvAds[indexToUse]["FeaturedPicture"].ToString().Trim() != "")
                                {
                                    GetAdSize(ref w, ref h, dvAds[indexToUse]["UserName"].ToString() + "\\" +
                                        dvAds[indexToUse]["FeaturedPicture"].ToString(), "3");

                                    lit.Text += "<div center=\"float\" class=\"FloatLeft\"><table width=\"198px\" height=\"262px\" " +
                                        "cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\"> " +
                                        "<img alt=\"" + dat.MakeNiceNameFull(dvAds[indexToUse]["Header"].ToString()).Replace("-", " ") + "\" onclick=\"window.location = '../" + dat.MakeNiceName(dvAds[indexToUse]["Header"].ToString()) +
                                            "_" + dvAds[indexToUse]["Ad_ID"].ToString() + "_Ad'\" class=\"AdImage\" width=\"" + w +
                                            "px\" Height=\"" + h + "px\" src=\"UserFiles/" + dvAds[indexToUse]["UserName"].ToString() +
                                            "/" + dvAds[indexToUse]["FeaturedPicture"].ToString() + "\" runat=\"server\" /> " +
                                        "</td></tr></tbody></table></div>";
                                }
                            }

                            lit.Text += "</div>";
                        }

                        item = new Telerik.Web.UI.RadRotatorItem();
                        item.Controls.Add(lit);
                        Rotator2.Items.Add(item);
                    }
                }

                string border = "";

                if (dvAds.Count < 4)
                {

                    if (dvAds.Count == 0)
                    {
                        lit = new Literal();
                        lit.Text = "<div class=\"Text12 AdEmpty\">" +
                            "<div class=\"AdEmptyInner\">There are no bulletins posted " +
                            "in your location today. Be the first to feature a bulletin in your location and have it viewed by visitors throughout the site. " +
                            "<br/><a class=\"NavyLinkSmall\" href=\"post-bulletin\"><br/>+Add Bulletin</a></div></div>";

                        item = new Telerik.Web.UI.RadRotatorItem();
                        item.Controls.Add(lit);

                        Rotator2.Items.Add(item);

                        if (!isDouble)
                        {
                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdEmptyInnerInner\">" +
                                "</div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);

                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdEmptyInnerInner\">" +
                                "</div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);
                        }

                        lit = new Literal();
                        lit.Text = "<div class=\"Text12 AdEmptyInnerInnerInner\">" +
                            "</div>";
                        item = new Telerik.Web.UI.RadRotatorItem();
                        item.Controls.Add(lit);

                        Rotator2.Items.Add(item);
                    }
                    else if (dvAds.Count == 1)
                    {
                        if (isDouble)
                            border = "AdEmptyTop";
                        else
                            border = "AdEmptyTop2";
                        lit = new Literal();
                        lit.Text = "<div class=\"Text12 " + border + "\">" +
                            "<div class=\"AdEmptyInner\">There aren't many bulletins posted " +
                            "in your location today. Be the first to feature a bulletin in your location and have it viewed by visitors throughout the site. " +
                            "<br/><a class=\"NavyLinkSmall\" href=\"post-bulletin\"><br/>+Add Bulletin</a></div></div>";

                        item = new Telerik.Web.UI.RadRotatorItem();
                        item.Controls.Add(lit);

                        Rotator2.Items.Add(item);

                        if (!isDouble)
                        {
                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdEmptyInnerInner\">" +
                                "</div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);

                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdEmptyInnerInnerInner\">" +
                                "</div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);
                        }
                    }
                    else if (dvAds.Count == 2)
                    {
                        if (!isDouble)
                        {
                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdEmpty\">" +
                                "<div class=\"AdEmptyInner\">There aren't many bulletins posted " +
                            "in your location today. Be the first to feature a bulletin in your location and have it viewed by visitors throughout the site. " +
                            "<br/><a class=\"NavyLinkSmall\" href=\"post-bulletin\"><br/>+Add Bulletin</a></div></div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);

                            lit = new Literal();
                            lit.Text = "<div class=\"AdEmptyInnerInnerInner\">" +
                                "</div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);
                        }
                    }
                    else if (dvAds.Count == 3)
                    {
                        if (!isDouble)
                        {
                            lit = new Literal();
                            lit.Text = "<div class=\"Text12 AdTopInner\">" +
                                "<div class=\"AdEmptyInner\">There aren't many bulletins posted " +
                            "in your location today. Be the first to feature a bulletin in your location and have it viewed by visitors throughout the site. " +
                            "<br/><a class=\"NavyLinkSmall\" href=\"post-bulletin\"><br/>+Add Bulletin</a></div></div>";
                            item = new Telerik.Web.UI.RadRotatorItem();
                            item.Controls.Add(lit);

                            Rotator2.Items.Add(item);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {

        }
    }
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        string venueID = Request.QueryString["ID"].ToString();

        char[] delim = { ';' };
        string[] tokens = e.Appointment.ID.ToString().Split(delim);

        string aptmntID = tokens[0];
        string reOcurrID = tokens[2];
        string switchOn = tokens[1];

        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        DateTime dateNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));

        DataSet ds = dat.GetData("SELECT DATEADD(minute,450,EO.DateTimeStart)  AS Start, DATEADD(minute,450,EO.DateTimeEnd)  AS [End], E.Header, " +
            "E.ID, E.Address, V.Name FROM Venues V, Events E, Event_Occurance EO WHERE E.Venue=V.ID AND " +
            "EO.EventID=E.ID AND V.ID=" + venueID);
        DataView dv = new DataView(ds.Tables[0], "ID=" + aptmntID, "", DataViewRowState.CurrentRows);

        e.Appointment.ToolTip = "";
        RadToolTip newToolTip = new RadToolTip();
        string address = "";

        DateTime date = e.Appointment.Start;

        newToolTip.Text = "<div width=\"250px\" id=\"divE" + aptmntID + "\"><a href=\"" +
            dat.MakeNiceName(e.Appointment.Subject) + "_" +
                    aptmntID + "_Event\" class=\"NavyLink12\">" +
                    dat.BreakUpString(e.Appointment.Subject, 20) + "</a>" +
                    "<br/>" + date.ToShortTimeString();

        if (Session["User"] != null)
        {
            DataView dvUser = dat.GetDataDV("SELECT * FROM User_Calendar WHERE UserID=" +
                Session["User"].ToString() + " AND EventID=" + aptmntID);

            newToolTip.Text += "<br/><a href=\"javascript:OpenRad2('divE" + aptmntID + "','" +
                aptmntID + "', 'E', " + reOcurrID + ");\"><img title=\"Send info to friends\" alt=\"Send info to " +
                "friends\" style=\"border: none;\" " +
                "src=\"image/Envelope.png\" /></a>";
            string addText = "";
            if (dvUser.Count > 0)
            {
                e.Appointment.BackColor = System.Drawing.Color.Yellow;
                newToolTip.Text = "<span style=\"color: orange;\">Event is in your calendar</span>" +
                    newToolTip.Text + "</div>";
            }
            else
            {

                newToolTip.Text += "<a style=\"text-decoration: none;\" " +
                    "href=\"javascript:AddToCalendar('divE" + aptmntID + "','" +
                aptmntID + "', 'E');\"><img style=\"padding-bottom: 4px; border: 0;\" " +
                "title=\"Add to Calendar\" alt=\"Add to Calendar\" " +
                "src=\"image/CalendarIcon.png\" /></a></div>";
            }
        }
        else
            newToolTip.Text += "</div>";

        newToolTip.TargetControlID = e.Appointment.ClientID;
        newToolTip.IsClientID = true;
        newToolTip.ManualClose = true;
        newToolTip.HideEvent = ToolTipHideEvent.ManualClose;
        newToolTip.Animation = ToolTipAnimation.None;
        newToolTip.AutoCloseDelay = 100000000;
        newToolTip.HideDelay = 1000000;
        newToolTip.ShowEvent = ToolTipShowEvent.OnClick;
        newToolTip.Position = ToolTipPosition.MiddleRight;
        newToolTip.Width = 250;
        newToolTip.Skin = "Sunset";
        ToolTipPanel.Controls.Add(newToolTip);
    }
Esempio n. 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }

        Session["RedirectTo"] = Request.Url.AbsoluteUri;
        bool fillUserData = false;
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        try
        {
            if (Session["User"] != null)
            {
                fillUserData = true;
                DataSet dsAd = dat.GetData("SELECT User_ID FROM Ads WHERE Ad_ID=" + Request.QueryString["AdID"].ToString());
                if (dsAd.Tables[0].Rows[0]["User_ID"].ToString() == Session["User"].ToString())
                {
                    EditAdLink.Visible = true;
                }
                else
                    EditAdLink.Visible = false;

                LoggedInPanel.Visible = true;
                LoggedOutPanel.Visible = false;
            }
            else
            {
                Button calendarLink = (Button)dat.FindControlRecursive(this, "CalendarLink");
                LoggedOutPanel.Visible = true;
                LoggedInPanel.Visible = false;
            }

            GetFeaturedBulletins();
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }

        int ID = int.Parse(Request.QueryString["AdID"].ToString());

        Session["FlagID"] = ID;
        Session["FlagType"] = "A";
        DataSet ds = dat.GetData("SELECT * FROM Ads A, Users U WHERE U.User_ID=A.User_ID AND A.Ad_ID=" + ID);
        Cache.Remove(Server.MapPath("Controls/PlayList.xml"));
        if (ds.Tables.Count > 0)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                TagCloud.THE_ID = ID;
                ShowHeaderName.Text = "<a id=\""+dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString())+"\" class=\"aboutLink\" href=\"http://" + Request.Url.Authority + "/" +
                    dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                    "_" + ID.ToString() + "_Ad\"><h1>" +
                    dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 50)+"</h1></a>";
                ShowDescription.Text = dat.BreakUpString(ds.Tables[0].Rows[0]["Description"].ToString(), 60);

                #region SEO
                //Create keyword and description meta tags
                topTopLiteral.Text = "<a class=\"NavyLink12UD\" href=\"#" + dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()) + "\">" +
                    dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()).Replace("-", " ") + " From The Top</a>";

                HtmlMeta hm = new HtmlMeta();
                HtmlMeta kw = new HtmlMeta();
                HtmlMeta lg = new HtmlMeta();
                HtmlLink cn = new HtmlLink();
                HtmlHead head = (HtmlHead)Page.Header;

                cn.Attributes.Add("rel", "canonical");
                cn.Href = "http://" + Request.Url.Authority + "/" +
                    dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                    "_" + ID.ToString() + "_Ad";
                head.Controls.AddAt(0, cn);

                kw.Name = "keywords";
                hm.Name = "Description";

                lg.Name = "language";
                lg.Content = "English";
                head.Controls.AddAt(0, lg);

                char [] delimeter = {' '};
                string[] keywords = dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()).Replace("-", " ").Split(delimeter, StringSplitOptions.RemoveEmptyEntries);
                int count = 0;
                foreach (string token in keywords)
                {
                    if (count < 16)
                    {
                        if (kw.Content != "")
                            kw.Content += " ";
                        kw.Content += token;

                        count++;
                    }
                }
                head.Controls.AddAt(0, kw);

                hm.Content = dat.MakeNiceNameFull(dat.stripHTML(ds.Tables[0].Rows[0]["Description"].ToString()).Replace("   ", " ").Replace("  ", " ")).Replace("-", " ");
                if (hm.Content.Length > 200)
                    hm.Content = hm.Content.Substring(0, 197) + "...";

                head.Controls.AddAt(0, hm);

                this.Title = kw.Content;

                HtmlLink lk = new HtmlLink();
                lk.Href = "http://" + Request.Url.Authority + "/" + dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) + "_" + ID.ToString() + "_Ad";
                lk.Attributes.Add("rel", "bookmark");
                head.Controls.AddAt(0, lk);
                #endregion

                DataView dvCats = dat.GetDataDV("SELECT DISTINCT C.ID, ACM.ID AS AID, C.Name AS CategoryName, ACM.tagSize FROM Ad_Category_Mapping ACM, AdCategories C WHERE ACM.CategoryID=C.ID AND ACM.AdID=" + ID + " ORDER BY ACM.ID");

                string justCats = "";

                for (int i = 0; i < dvCats.Count; i++)
                {
                    //kw.Content += ", " + dvCats[i]["CategoryName"].ToString();
                    justCats += dvCats[i]["CategoryName"].ToString() + " ";
                }

               // DiggLiteral.Text = " <table> " +
               //     "<tr>" +
               //       "  <td valign=\"bottom\" style=\"padding-right: 10px;\">" +
               //        "     <a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>" +
               //        " </td>" +
               //        " <td valign=\"bottom\" style=\"padding-right: 10px;\">" +
               //        "     <a style=\"border: 0; padding: 0; margin: 0;\" id=\"TweeterA\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>" +
               //        " </td>" +
               //        " <td valign=\"bottom\" style=\"padding-right: 10px;\">" +
               //        "     <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">" +
               //        "         <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />" +
               //        "     </a>" +
               //        " </td>" +
               //        "  <td valign=\"bottom\" style=\"padding-right: 10px;\"><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
               //         "href='http://digg.com/submit?phase=2&url=" + "http://" + Request.Url.Authority +
               //         "/" + dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) + "_" + ID.ToString() + "_Ad" +
               //         "' target=\"_blank\">Digg</a></td>" +
               //       "  <td valign=\"bottom\" style=\"padding-right: 10px;\">" +

               //        "     <a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
               //        "         <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
               //         "    </a>" +
               //        "</td>" +
               //        " <td>" +
               //         "     <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
               //        " </td>" +
               //    " </tr>" +
               //" </table>";

                Session["Subject"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14);
                Session["messageText"] = "Bulletin: " +
                    dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + ".";

                Session["messageEmail"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " \n\r " + ShowDescription.Text;
                Session["EmailMessage"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " \n\r " + ShowDescription.Text;

                if (bool.Parse(ds.Tables[0].Rows[0]["hasSongs"].ToString()))
                {
                    DataSet dsSongs = dat.GetData("SELECT * FROM Ad_Song_Mapping WHERE AdID=" + ID);
                    ASP.controls_playerxml_songplayer_ascx songs = new ASP.controls_playerxml_songplayer_ascx();
                    int songCount = dsSongs.Tables[0].Rows.Count;

                    if (songCount > 2)
                    {
                        songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                        songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                        songs.SONG3 = dsSongs.Tables[0].Rows[2]["SongName"].ToString();
                        songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                        songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                        songs.SONG3_TITLE = dsSongs.Tables[0].Rows[2]["SongTitle"].ToString();
                    }
                    else if (songCount > 1)
                    {
                        songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                        songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                        songs.SONG3 = "";
                        songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                        songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                    }
                    else
                    {
                        songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                        songs.SONG2 = "";
                        songs.SONG3 = "";
                        songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                    }
                    songs.USER_NAME = ds.Tables[0].Rows[0]["UserName"].ToString();

                    SongPanel.Controls.Add(songs);

                    //XmlDocument xmldoc = new XmlDocument();
                    //xmldoc.Load(Server.MapPath("Controls/PlayList.xml"));

                    //Cache.Insert(Server.MapPath("Controls/PlayList.xml"), fil);

                }

                string youtube = ds.Tables[0].Rows[0]["YouTubeVideo"].ToString();
                int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());
                //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                Rotator1.Items.Clear();
                switch (mediaCategory)
                {
                    case 0:
                        break;
                    case 1:
                        RotatorPanel.Visible = true;
                        char[] delim4 = { ';' };
                        string[] youtokens = youtube.Split(delim4);
                        if (youtube != "")
                        {
                            for (int i = 0; i < youtokens.Length; i++)
                            {
                                if (youtokens[i].Trim() != "")
                                {
                                    Literal literal3 = new Literal();
                                    //literal3.Text = "<object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ><param name=\"movie\" value=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"250\"></embed></object>";
                                    literal3.Text = "<div class=\"FloatLeft\"><object class=\"toHidde\" width=\"412\" height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                        "\"></param><param  name=\"wmode2\" value=\"transparent\" ></param><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/" +
                                        youtokens[i] + "\" wmode=\"opaque\" wmode2=\"transparent\' type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"412\" height=\"250\"></embed></object></div>";
                                    Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                    r3.Controls.Add(literal3);
                                    Rotator1.Items.Add(r3);
                                }
                            }
                        }
                        DataView dsSlider = dat.GetDataDV("SELECT * FROM Ad_Slider_Mapping WHERE AdID=" + ID);
                        DataSet dsUser = dat.GetData("SELECT * FROM Ads A, Users U WHERE A.Ad_ID=" + ID + " AND A.User_ID=U.User_ID");
                        string userName = dsUser.Tables[0].Rows[0]["UserName"].ToString();
                        if (dsSlider.Count > 0)
                        {
                            char[] delim = { '\\' };
                            char[] delim3 = { '.' };
                            string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" +
                                userName + "\\AdSlider\\" + ID);

                            string[] finalFileArray = new string[fileArray.Length];

                            for (int i = 0; i < dsSlider.Count; i++)
                            {
                                int length = fileArray[i].Split(delim).Length;
                                finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" + userName +
                                    "/AdSlider/" + ID + "/" + dsSlider[i]["PictureName"].ToString();
                                string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                if (tokens.Length >= 2)
                                {
                                    if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                    {
                                        System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\" +
                                userName + "\\AdSlider\\" + ID + "\\" + dsSlider[i]["PictureName"].ToString());

                                        int width = 410;
                                        int height = 250;

                                        int newHeight = 0;
                                        int newIntWidth = 0;

                                        //if image height is less than resize height
                                        if (height >= image.Height)
                                        {
                                            //leave the height as is
                                            newHeight = image.Height;

                                            if (width >= image.Width)
                                            {
                                                newIntWidth = image.Width;
                                            }
                                            else
                                            {
                                                newIntWidth = width;

                                                double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                newHeight = (int)newDoubleHeight;
                                            }
                                        }
                                        //if image height is greater than resize height...resize it
                                        else
                                        {
                                            //make height equal to the requested height.
                                            newHeight = height;

                                            //get the ratio of the new height/original height and apply that to the width
                                            double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                            double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                            newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                            newIntWidth = (int)newDoubleWidth;

                                            //if the resized width is still to big
                                            if (newIntWidth > width)
                                            {
                                                //make it equal to the requested width
                                                newIntWidth = width;

                                                //get the ratio of old/new width and apply it to the already resized height
                                                theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                newHeight = (int)newDoubleHeight;
                                            }
                                        }

                                        Literal literal4 = new Literal();
                                        string[] nameTokens = dsSlider[i]["RealPictureName"].ToString().Split(delim3);
                                        string realName = dat.MakeNiceName(nameTokens[0]).Replace("-", " ");
                                        literal4.Text = "<div class=\"RotatorImage\"><img alt=\"" + realName +
                                            "\" style=\"cursor: pointer; margin-left: " + ((412 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" onclick=\"OpenEventModal(" + i.ToString() + ", " + ID + ");\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                            + "UserFiles/" + userName + "/AdSlider/" + ID + "/" +
                                            dsSlider[i]["PictureName"].ToString() + "\" /></div>";
                                        Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                        r4.Controls.Add(literal4);

                                        Rotator1.Items.Add(r4);
                                    }
                                    else if (tokens[1].ToUpper() == "WMV")
                                    {
                                        Literal literal4 = new Literal();
                                        literal4.Text = "<div style=\"width: 410px; height: 250px;\" ><OBJECT stop=\"true\" loop=\"false\" controller=\"true\" wmode2=\"opaque\" wmode=\"transparent\" autoplay=\"false\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " +
                                        "width=\"410\" height=\"250\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">" +
                                        "<param name=\"src\" value=\"UserFiles/" +
                                userName + "/AdSlider/" + ID + "/" + fileArray[i].Split(delim)[length - 1].ToString() + "\"></param>" +
                                        "<param name=\"autoplay\" value=\"false\"></param><param name=\"wmode\" value=\"transparent\"></param>" +
                                        "<param name=\"controller\" value=\"true\"></param>" +
                                        "<param name=\"stop\" value=\"true\" ></param>" +
                                        "<param name=\"loop\" value=\"false\"><param  name=\"wmode2\" value=\"opaque\" ></param>" +
                                        "<EMBED stop=\"true\" wmode=\"transparent\" wmode2=\"opaque\" src=\"UserFiles/" +
                                userName + "/AdSlider/" + ID + "/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" width=\"410\" height=\"250\" autoplay=\"false\" " +
                                        "controller=\"true\" loop=\"false\" bgcolor=\"#000000\" pluginspage=\"http://www.apple.com/quicktime/download/\">" +
                                        "</EMBED>" +
                                        "</OBJECT></div>";
                                        Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                        r4.Controls.Add(literal4);
                                        Rotator1.Items.Add(r4);
                                    }

                                }
                            }
                        }
                        break;
                    default: break;

                }

                if (fillUserData)
                {
                    ASP.controls_contactad_ascx SendMessage1 = new ASP.controls_contactad_ascx();
                    SendMessage1.THE_TEXT = "Reply to Bulletin";
                    SendMessage1.RE_LABEL = "Re: " + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14);
                    SendMessage1.TYPE = "Connect";
                    SendMessage1.ID = ID;

                    ContactPanel.Controls.Add(SendMessage1);

                    ASP.controls_sendmessage_ascx SendMessage33 = new ASP.controls_sendmessage_ascx();
                    SendMessage33.THE_TEXT = "Share this with a friend";
                    SendMessage33.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                            " would like inquire about your ad \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\".";
                    SendMessage33.TYPE = "a";
                    SendMessage33.ID = ID;
                    ContactPanel.Controls.Add(SendMessage33);

                    Session["Subject"] = "Re: " + Session["UserName"].ToString() +
                            " would like inquire about your ad \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\".";
                }
                else
                {
                    Literal literal = new Literal();
                    literal.Text = "<label class=\"AddGreenLink\">You must be <a class=\"AddLink\" href=\"login\">logged in</a> to contact this person.</label>";

                    ContactPanel.Controls.Add(literal);
                }
                //}
                //else
                //{
                //    Response.Redirect("~/home");
                //}
            }
            else
            {
                Response.Redirect("~/home");
            }
        }
        else
        {
            Response.Redirect("~/home");
        }
        if (Rotator1.Items.Count == 0)
            RotatorPanel.Visible = false;
        else
        {
            RotatorPanel.Visible = true;
            if (Rotator1.Items.Count == 1)
            {
                RotatorPanel.CssClass = "HiddeButtons";
            }
        }
    }
    protected void InsertRevision(ref Telerik.Web.UI.RadPanelItem item2, DataSet dsChanges, int n, 
        string tempstr, ref int count, DataSet ds, int i)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        if (dsChanges.Tables[0].Rows[0][n + 3].ToString().Trim() != "")
        {

            Label theLab = new Label();
            if (count != 1)
                theLab.Text = tempstr;

            string content = "";

            string str = "venue";
            if (ds.Tables[0].Rows[i]["Mode"].ToString() == "4")
                str = "event";

            bool isVenue = false;
            if (str == "venue")
                isVenue = true;

            string colName = dsChanges.Tables[0].Columns[n + 3].ColumnName.ToLower();

            if (!isVenue && (colName == "zip" || colName == "state" || colName == "city" || colName == "country"))
            {

            }
            else
            {
                if (dsChanges.Tables[0].Columns[n + 3].ColumnName.ToLower() == "address")
                {
                    DataView dvV = dat.GetDataDV("SELECT * FROM Venues WHERE ID=" +
                        dsChanges.Tables[0].Rows[0]["VenueID"].ToString());
                    if (dvV[0]["Country"].ToString() == "223")
                        content = dat.GetAddress(dsChanges.Tables[0].Rows[0][n + 3].ToString(), false);
                    else
                        content = dat.GetAddress(dsChanges.Tables[0].Rows[0][n + 3].ToString(), true);
                }
                else if (dsChanges.Tables[0].Columns[n + 3].ColumnName.ToLower() == "venue")
                {
                    DataView dvV = dat.GetDataDV("SELECT * FROM Venues WHERE ID=" + dsChanges.Tables[0].Rows[0][n + 3].ToString());
                    content = "<a class=\"AddLink\" target=\"_blank\" href=\"" +
                        dat.MakeNiceName(dvV[0]["Name"].ToString()) + "_" +
                        dsChanges.Tables[0].Rows[0][n + 3].ToString() +
                        "_Venue\">" + dvV[0]["Name"].ToString() + "</a>";
                }
                else
                {
                    content = dsChanges.Tables[0].Rows[0][n + 3].ToString();
                }

                theLab.Text += count + ". " + dsChanges.Tables[0].Columns[n + 3].ColumnName + " Change Request To: <br/><br/>" +
                    dat.BreakUpString(content, 30) + "<br/>";
                count++;
                item2.Controls.Add(theLab);

                bool notSeen = dat.isNotSeen(dsChanges, n);
                bool isApproved = dat.isApproved(dsChanges, n);

                bool changeHasBeenMade = true;

                if (notSeen && changeHasBeenMade)
                {
                    HtmlButton img = new HtmlButton();
                    img.Attributes.Add("commArg", str);
                    img.Attributes.Add("commandargument", dsChanges.Tables[0].Rows[0]["ID"].ToString() +
                        "accept" + (n + 3).ToString());
                    img.ID = dsChanges.Tables[0].Rows[0]["ID"].ToString() + "accept" + (n + 3).ToString();
                    img.Style.Value = "cursor: pointer;float: right;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                    "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                    "no-repeat; border: 0;";
                    img.ServerClick += new EventHandler(ServerAcceptChange);
                    img.Attributes.Add("onmouseover", "this.style.backgroundImage = 'url(image/PostButtonNoPostHover.png)';");
                    img.Attributes.Add("onmouseout", "this.style.backgroundImage = 'url(image/PostButtonNoPost.png)';");
                    img.Attributes.Add("onclick", "this.innerHTML = 'Working...';this.disabled=true;this.style.backgroundImage = 'url(image/PostButtonNoPostHover.png)';");

                    img.InnerText = "Accept";

                    item2.Controls.Add(img);

                    img = new HtmlButton();
                    img.Attributes.Add("commArg", str);
                    img.Attributes.Add("commandargument", dsChanges.Tables[0].Rows[0]["ID"].ToString() + "reject" +
                        (n + 3).ToString());
                    img.ID = dsChanges.Tables[0].Rows[0]["ID"].ToString() + "reject" + (n + 3).ToString();
                    img.Style.Value = "cursor: pointer;float: right;font-size: 11px;font-weight: bold;margin-top: 20px; padding-bottom: 4px;height: 30px; width: 112px;background-color: transparent; " +
                    "color: White; background-image: url('image/PostButtonNoPost.png'); background-repeat: " +
                    "no-repeat; border: 0;";
                    img.ServerClick += new EventHandler(ServerRejectChange);
                    img.Attributes.Add("onmouseover", "this.style.backgroundImage = 'url(image/PostButtonNoPostHover.png)';");
                    img.Attributes.Add("onmouseout", "this.style.backgroundImage = 'url(image/PostButtonNoPost.png)';");
                    img.Attributes.Add("onclick", "this.innerHTML = 'Working...';this.disabled=true;this.style.backgroundImage = 'url(image/PostButtonNoPostHover.png)';");

                    img.InnerText = "Reject";

                    item2.Controls.Add(img);
                }
                else
                {

                    theLab = new Label();
                    Label lab2 = new Label();
                    if (isApproved)
                    {

                        theLab.Text = "<br/><br/><span  class=\"AddGreenLink FloatRight\">You have accepted this change.</span>";

                    }
                    else
                    {
                        theLab.Text = "<br/><br/><span  class=\"AddGreenLink FloatRight\">You have rejected this change.</span>";
                    }

                    item2.Controls.Add(lab2);
                    item2.Controls.Add(theLab);
                }
                Literal theLit = new Literal();
                theLit.Text = "</td></tr><tr><td>";

                item2.Controls.Add(theLit);

            }
        }
    }
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        char[] delim = { ';' };
        string[] tokens = e.Appointment.ID.ToString().Split(delim);

        string aptmntID = tokens[0];
        string reOcurrID = tokens[1];
        string switchOn = tokens[2];

        DataView dv = new DataView();

        switch (switchOn)
        {
            case "1":
                dv = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " +
                "[End], E.Header, E.ID, E.Address, V.Name FROM Venues V, User_Calendar UC, Events E, " +
                "Event_Occurance EO WHERE E.Venue=V.ID AND EO.EventID=E.ID AND UC.EventID=E.ID AND UC.UserID=" +
                Session["UserToUse"].ToString() + " AND E.ID=" + aptmntID + " AND EO.ID=" + reOcurrID);
                break;
            case "2":
                dv = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " +
                "[End], E.Name, E.ID, EO.City + ' ' +EO.State + ' '+EO.Zip AS Address, E.Content FROM GroupEvent_Members UC, GroupEvents E, " +
                "GroupEvent_Occurance EO WHERE EO.GroupEventID=E.ID AND UC.GroupEventID=E.ID AND UC.UserID=" +
                Session["UserToUse"].ToString() + " AND E.ID=" + aptmntID + " AND EO.ID=" + reOcurrID);
                break;
            case "3":
                dv = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " +
                "[End], E.Name, E.ID, EO.City + ' ' +EO.State + ' '+EO.Zip AS Address, E.Content FROM User_GroupEvent_Calendar UC, GroupEvents E, " +
                "GroupEvent_Occurance EO WHERE EO.GroupEventID=E.ID AND UC.GroupEventID=E.ID AND UC.UserID=" +
                Session["UserToUse"].ToString() + " AND E.ID=" + aptmntID + " AND EO.ID=" + reOcurrID);
                break;
            default: break;
        }

        if (dv.Count > 0)
        {
            e.Appointment.ToolTip = "";
            RadToolTip newToolTip = new RadToolTip();

            string addThis = "";
            string content = "";
            if (Session["UserToUse"].ToString() == Session["User"].ToString() && switchOn == "1")
            {
                addThis = "<a href=\"javascript:OpenRad('div" + aptmntID + "', '" +
                aptmntID + "', '" + switchOn + "', 'na');\"><img title=\"Send info to friends\" alt=\"Send info to friends\" style=\"border: none;padding-right: 5px;\" " +
                "src=\"NewImages/Envelope.png\" /></a><a href=\"javascript:OpenCommunication('div" + aptmntID + "', '" +
                aptmntID + "');\"><img style=\"border: none;padding-right: 5px;\" title=\"Set communication on/off for this event.\" alt=\"Set communication on/off for this event.\" src=\"NewImages/EventComment.png\" /></a>" +
                "<a href=\"javascript:OpenRadDelete('div" + aptmntID + "', '" +
                aptmntID + "', '" + switchOn + "', 'na');\"><img style=\"border: none;padding-right: 5px;\" title=\"Delete event from your calendar\" alt=\"Delete event from your calendar\" " +
                "src=\"NewImages/DeleteCircle.png\" /></a><a href=\"javascript:OpenAlarm('div" + aptmntID + "', '" +
                aptmntID + "', '" + reOcurrID + "');\"><img style=\"border: none;\" title=\"Set Reminder for this event\" alt=\"Set Reminder for this event\" " +
                "src=\"NewImages/Alarm.png\" /></a>";
            }

            if (Session["UserToUse"].ToString() == Session["User"].ToString() && switchOn != "1")
            {
                addThis = "<a href=\"javascript:OpenRad('divG" + aptmntID + "', '" +
                aptmntID + "', '" + switchOn + "', '" + reOcurrID + "');\"><img title=\"Send info to friends\" " +
                "alt=\"Send info to friends\" style=\"border: none;padding-right: 5px;\" " +
                "src=\"NewImages/Envelope.png\" /></a>" +
                "<a href=\"javascript:OpenRadDelete('divG" + aptmntID + "', '" +
                aptmntID + "', '" + switchOn + "', '" + reOcurrID + "');\"><img style=\"border: none;\" title=\"Delete " +
                "event from your calendar\" alt=\"Delete event from your calendar\" " +
                "src=\"NewImages/DeleteCircle.png\" /></a>";
            }

            if (switchOn == "1")
            {
                newToolTip.Text = "<div style=\"padding: 10px;display: block; width: 200px;\" id=\"div" + aptmntID +
                    "\"><a href=\"" + dat.MakeNiceName(dv[0]["Header"].ToString()) + "_" +
                    aptmntID + "_Event\" class=\"AddLink\">" +
                    dat.BreakUpString(dv[0]["Header"].ToString(), 20) + "</a>" +
                    "<br/><br/>" + dv[0]["Name"].ToString() +
                    "<br/>" + e.Appointment.Start.ToShortTimeString() +
                    "<br/>" + dv[0]["Address"].ToString() +
                    "<br/><br/><br/>" + addThis + "</div>";
            }

            newToolTip.TargetControlID = e.Appointment.ClientID;
            newToolTip.IsClientID = true;
            newToolTip.HideEvent = ToolTipHideEvent.ManualClose;
            newToolTip.Animation = ToolTipAnimation.None;
            newToolTip.Position = ToolTipPosition.MiddleRight;
            newToolTip.ShowEvent = ToolTipShowEvent.OnClick;
            newToolTip.Skin = "Sunset";
            ToolTipPanel.Controls.Add(newToolTip);
        }
    }
Esempio n. 20
0
    protected void DrawTemplateAd(string AdTemplate, DataView dvUser, DataView dvAds, int nextAdIndex)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        string w = "0";
        string h = "0";

        BodyLabel.Text = "template ID=" + AdTemplate;

        GetAdSize(ref w, ref h, dvUser[0]["UserName"].ToString() + "\\" +
            dvAds[nextAdIndex]["FeaturedPicture"].ToString(), AdTemplate);

        switch (AdTemplate)
        {
            case "1":
                Template1Panel.Visible = true;
                Template2Panel.Visible = false;
                Template3Panel.Visible = false;

                CustomerImage.Width = int.Parse(w);
                CustomerImage.Height = int.Parse(h);

                if (CustomerImage.Width == 0)
                    CustomerImage.Width = 100;
                if (CustomerImage.Height == 0)
                    CustomerImage.Height = 100;

                CustomerImage.AlternateText = dvAds[nextAdIndex]["Header"].ToString();
                CustomerImage.Attributes.Add("onclick", "window.location = '../" +
                    dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad'");
                ImagePanel.Visible = true;
                CustomerImage.Visible = true;
                CustomerImage.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() +
                    "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString();
                TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 10);
                TitleLabel.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                BodyLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["FeaturedSummary"].ToString(), 21);
                ReadMoreLink.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";

                break;
            case "2":
                Template1Panel.Visible = false;
                Template2Panel.Visible = true;
                Template3Panel.Visible = false;
                Image1.Width = int.Parse(w);
                Image1.Height = int.Parse(h);

                if (Image1.Width == 0)
                    Image1.Width = 200;
                if (Image1.Height == 0)
                    Image1.Height = 140;

                Image1.AlternateText = dvAds[nextAdIndex]["Header"].ToString();

                Image1.Visible = true;
                Image1.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() +
                    "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString();

                Image1.Attributes.Add("onclick", "window.location = '../" +
                    dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad'");

                HyperLink1.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 10);

                HyperLink1.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 21);
                HyperLink1.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                Label1.Text = dat.BreakUpString(dvAds[nextAdIndex]["FeaturedSummary"].ToString(), 21);
                HyperLink2.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                break;
            case "3":
                Template1Panel.Visible = false;
                Template2Panel.Visible = false;
                Template3Panel.Visible = true;

                Image2.Width = int.Parse(w);
                Image2.Height = int.Parse(h);

                if (Image2.Width == 0)
                    Image2.Width = 200;
                if (Image2.Height == 0)
                    Image2.Height = 250;

                Image2.AlternateText = dvAds[nextAdIndex]["Header"].ToString();
                Image2.Attributes.Add("onclick", "window.location = '../" +
                    dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad'");
                Image2.Visible = true;
                Image2.ImageUrl = "../UserFiles/" + dvUser[0]["UserName"].ToString() +
                    "/" + dvAds[nextAdIndex]["FeaturedPicture"].ToString();
                break;
            default: break;

        }
    }
    protected void GoToSearch(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        string cookieName = FormsAuthentication.FormsCookieName;
        HttpCookie authCookie = Context.Request.Cookies[cookieName];

        string country = "";
        string state = "";
        string city = "";

        FormsAuthenticationTicket authTicket = null;

        string group = "";
        if (authCookie != null)
        {
            authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            group = authTicket.UserData.ToString();
        }

        if (group.Contains("User"))
        {
            DataSet ds1 = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE U.User_ID=" +
                authTicket.Name + " AND U.User_ID=UP.UserID ");

            if(ds1.Tables.Count > 0)
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    country = ds1.Tables[0].Rows[0]["CatCountry"].ToString();
                    state = ds1.Tables[0].Rows[0]["CatState"].ToString();
                    city = ds1.Tables[0].Rows[0]["CatCity"].ToString();
                }
        }
        else
        {
            DataSet ds1 = dat.GetData("SELECT * FROM SearchIPs WHERE IP='" + dat.GetIP() + "'");

            if(ds1.Tables.Count > 0)
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    country = ds1.Tables[0].Rows[0]["Country"].ToString();
                    state = ds1.Tables[0].Rows[0]["State"].ToString();
                    city = ds1.Tables[0].Rows[0]["City"].ToString();
                }

        }

        if (country != "")
            country = " AND E.Country = " + country;

        int c = 0;

        if (state != "")
        {

            c++;
        }

        if (city != "")
        {

            c++;
        }

        SqlDbType[] types = new SqlDbType[c];
        object[] data = new object[c];

        if (state != "")
        {
            types[0] = SqlDbType.NVarChar;
            data[0] = state;
            state = " AND E.State=@p0 ";
            if (city != "")
            {
                types[1] = SqlDbType.NVarChar;
                data[1] = city;
                city = " AND E.City=@p1 ";
            }
        }
        else
        {
            if (city != "")
            {
                types[0] = SqlDbType.NVarChar;
                data[0] = city;
                city = " AND E.City=@p0 ";
            }
        }

        DataSet ds = dat.GetDataWithParemeters("SELECT DISTINCT TOP 10 EO.DateTimeStart, E.Header, E.Content, EO.EventID FROM Events E, Event_Occurance EO WHERE E.ID=EO.EventID " + country + state + city + " AND CONVERT(NVARCHAR, MONTH(EO.DateTimeStart)) + '/' + CONVERT(NVARCHAR, DAY(EO.DateTimeStart)) + '/' + CONVERT(NVARCHAR, YEAR(EO.DateTimeStart)) = '" + RadCalendar1.SelectedDate.ToShortDateString() + "'", types, data);

        EventPanel.Controls.Clear();
        if (ds.Tables.Count > 0)
            if (ds.Tables[0].Rows.Count > 0)
            {

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    DateTime date = DateTime.Parse(ds.Tables[0].Rows[i]["DateTimeStart"].ToString());
                    ASP.controls_homeevent_ascx eventH = new ASP.controls_homeevent_ascx();
                    eventH.DAY = date.DayOfWeek.ToString().Substring(0, 3);
                    eventH.DAY_NUMBER = date.Day.ToString();
                    eventH.MONTH = dat.GetMonth(date.Month.ToString()).Substring(0, 3);
                    eventH.EVENT_NAME = ds.Tables[0].Rows[i]["Header"].ToString();
                    if (ds.Tables[0].Rows[i]["Content"].ToString().Length > 150)
                        eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString().Substring(0, 150), 67) + "...";
                    else
                        eventH.SUMMARY = dat.BreakUpString(ds.Tables[0].Rows[i]["Content"].ToString(), 67) + "...";
                    eventH.EVENT_ID = int.Parse(ds.Tables[0].Rows[i]["EventID"].ToString());
                    EventPanel.Controls.Add(eventH);

                }
            }
            else
            {
                Label label = new Label();
                label.CssClass = "EventBody";
                label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"EnterEvent.aspx\">Enter Events</a>.";
                EventPanel.Controls.Add(label);
            }
        else
        {
            Label label = new Label();
            label.CssClass = "EventBody";
            label.Text = "No events are listed for this date. Sorry. But perhaps you could enter one... <a class=\"AddLink\" href=\"EnterEvent.aspx\">Enter Events</a>.";
            EventPanel.Controls.Add(label);
        }

        Session["HomeEvents"] = ds;
    }
Esempio n. 22
0
    protected void DrawAd(int nextAdIndex, DataView dvAds)
    {
        try
        {
            HttpCookie cookie = Request.Cookies["BrowserDate"];
            Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
            DataView dvUser = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dvAds[nextAdIndex]["User_ID"].ToString());

            string templateID = dat.GetDataDV("SELECT * FROM Ads WHERE Ad_ID=" + dvAds[nextAdIndex]["Ad_ID"].ToString())[0]["Template"].ToString();

            if (dvAds[nextAdIndex]["FeaturedPicture"] != null)
            {
                if (dvAds[nextAdIndex]["FeaturedPicture"].ToString().Trim() != "")
                {
                    DrawTemplateAd(templateID, dvUser, dvAds, nextAdIndex);
                }
            }
            if (dvAds[nextAdIndex]["FeaturedPicture"].ToString() == "" || dvAds[nextAdIndex]["FeaturedPicture"] == null)
            {
                CustomerImage.Visible = false;
                ImagePanel.Visible = false;
                Template1Panel.Visible = true;
                Template2Panel.Visible = false;
                Template3Panel.Visible = false;
                TitleLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["Header"].ToString(), 21);
                TitleLabel.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
                BodyLabel.Text = dat.BreakUpString(dvAds[nextAdIndex]["FeaturedSummary"].ToString(), 21);
                ReadMoreLink.NavigateUrl = "../" + dat.MakeNiceName(dvAds[nextAdIndex]["Header"].ToString()) +
                    "_" + dvAds[nextAdIndex]["Ad_ID"].ToString() + "_Ad";
            }
        }
        catch (Exception ex)
        {
            BodyLabel.Text = ex.ToString();
        }
    }
Esempio n. 23
0
    protected void PostEvents(DataSet ds)
    {
        try
        {
            HttpCookie cookie = Request.Cookies["BrowserDate"];
            if (cookie == null)
            {
                cookie = new HttpCookie("BrowserDate");
                cookie.Value = DateTime.Now.Date.ToString();
                cookie.Expires = DateTime.Now.AddDays(22);
                Response.Cookies.Add(cookie);
            }
            bool fillUserData = false;

            DateTime isn = DateTime.Now;

            if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
                isn = DateTime.Now;
            DateTime isNow = isn;
            Data dat = new Data(isn);
            Rotator1.Items.Clear();
            DataView dv = new DataView(ds.Tables[0], "", "", DataViewRowState.CurrentRows);

            string content = "";
            bool isPathAbsolute = false;
            string imagePath = "";
            if (dv.Count > 0)
            {
                foreach (DataRowView row in dv)
                {
                    Telerik.Web.UI.RadRotatorItem item = new Telerik.Web.UI.RadRotatorItem();
                    Literal lit = new Literal();
                    if (row["Type"].ToString() == "E")
                    {
                        DataView dsSlider = dat.GetDataDV("SELECT * FROM Event_Slider_Mapping WHERE EventID=" +
                            row["EventID"].ToString());

                        string imageStr = "";

                        bool doImage = false;
                        if (dsSlider.Count > 0)
                        {
                            doImage = true;
                            isPathAbsolute = bool.Parse(dsSlider[0]["ImgPathAbsolute"].ToString());
                            if (isPathAbsolute)
                            {
                                imagePath = dsSlider[0]["PictureName"].ToString();
                            }
                            else
                            {
                                imagePath = "UserFiles/Events/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString();

                                if (!System.IO.File.Exists(MapPath(".")+imagePath))
                                {
                                    doImage = true;
                                }
                            }
                        }

                        if (doImage)
                        {
                            if (isPathAbsolute)
                            {
                                imagePath = dsSlider[0]["PictureName"].ToString();
                            }
                            else
                            {
                                imagePath = "UserFiles/Events/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString();
                            }
                            imageStr = "<div align=\"center\" style=\"vertical-align: middle;position: absolute; height: 240px; width: 240px;\"><table width='240px' cellpadding='0' cellspacing='0' height='238px' bgcolor='black'><tr><td valign='center'><a width='240px' href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Event\"" +
                                "\"><img  alt=\"" + dat.MakeNiceName(row["Header"].ToString()).Replace("-", " ") + "\" src=\""
                                + imagePath + "\" /></a></td></tr></table><div style=\"font-weight: bold;color: white;position: absolute;bottom: 0;width: 240px; height: 50px; z-index: 1000;\"><table cellpadding='0' cellspacing='0' height='50px'><tr><td valign='center'><div align='center'>" +
                                row["Header"].ToString() + "</div></td></tr></table></div>" +
                                "<div style=\"vertical-align: middle;color: white;position: absolute; bottom: 0;width: 240px; " +
                                "background-color: black; opacity: .7; filter: alpha(opacity=70);height: 50px;\"></div>" +
                                "</div>";
                            lit.Text = imageStr;
                        }
                        else
                        {

                            DataView dvTime = dat.GetDataDV("SELECT * FROM Event_Occurance WHERE EventID=" +
                                row["EventID"].ToString() + " ORDER BY DateTimeStart DESC");
                            DateTime itEvent = new DateTime();
                            itEvent = DateTime.Parse(dvTime[0]["DateTimeStart"].ToString());
                            string timeStr = GetTimeStr(itEvent);

                            lit.Text = "<div class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">" +
                                "<h2 class=\"Event\"><a class=\"HomeEventTitle\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Event\">";

                            string headerStr = row["Header"].ToString();

                            if (headerStr.Length > 49)
                            {
                                headerStr = headerStr.Substring(0, 46) + "...";
                            }

                            lit.Text += dat.BreakUpString(headerStr, 20) + "</a></h2></div><div class=\"FooterBottom\">" +
                                imageStr + "<div class=\"Text12 Home44\">";

                            int contentLimit = 105;
                            if (imageStr == "")
                                contentLimit = 281;
                            content = dat.stripHTML(row["Content"].ToString());
                            if (content.Length > contentLimit)
                            {
                                content = content.Substring(0, contentLimit) + "...";
                            }

                            lit.Text += timeStr + "<br/>" +
                                dat.BreakUpString(content.Replace("<br/>", " ").Replace("<br>",
                                " ").Replace("<br />", " ").Replace("<BR>", " ").Replace("<BR />",
                                " ").Replace("<BR/>", " "), 13);

                            lit.Text += "</div><div class=\"ReadMoreHome\"><a class=\"ReadMoreHome\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Event\">Read More</a></div></div></div></div>";
                        }

                        item.Controls.Add(lit);
                        RadRotator1.Items.Add(item);
                    }
                    else if (row["Type"].ToString() == "T")
                    {
                        DataView dsSlider = dat.GetDataDV("SELECT * FROM Trip_Slider_Mapping WHERE TripID=" +
                            row["EventID"].ToString());

                        string imageStr = "";
                        bool isImage = false;
                        if (dsSlider.Count > 0)
                        {
                            isImage = true;
                            if (!System.IO.File.Exists(MapPath(".") + "/Trips/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString()))
                            {
                                isImage = false;
                            }
                        }

                        if (isImage)
                        {
                            imageStr = "<div align=\"center\" style=\"vertical-align: middle; width: 240px; height: 240px;\"><table width='240px' cellpadding='0' cellspacing='0' height='238px' bgcolor='black'><tr><td valign='center'><a width='240px' href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Trip\"" +
                                "\"><img  alt=\"" + dat.MakeNiceName(row["Header"].ToString()).Replace("-", " ") + "\" src=\""
                                + "Trips/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString() + "\" /></a></td></tr></table>" +
                                "<div style=\"font-weight: bold;color: white;position: absolute;bottom: 0;width: 240px; height: 50px; z-index: 1000;\"><table cellpadding='0' cellspacing='0' height='50px'><tr><td valign='center'><div align='center'>" +
                                row["Header"].ToString() + "</div></td></tr></table></div>" +
                                "<div style=\"vertical-align: middle;color: white;position: absolute; bottom: 0;width: 240px; " +
                                "background-color: black; opacity: .7; filter: alpha(opacity=70);height: 50px;\"></div>" +
                                "</div>";
                            lit.Text = imageStr;
                        }
                        else
                        {

                            lit.Text = "<div class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">" +
                                "<h2 class=\"Event\"><a class=\"HomeEventTitle\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Trip\">";

                            string headerStr = row["Header"].ToString();

                            if (headerStr.Length > 49)
                            {
                                headerStr = headerStr.Substring(0, 46) + "...";
                            }

                            lit.Text += dat.BreakUpString(headerStr, 20) + "</a></h2></div><div class=\"FooterBottom\">" +
                                imageStr + "<div  class=\"Home44\" class=\"Text12\">";

                            string timeStr = "";
                            DateTime itEvent = new DateTime();
                            itEvent = DateTime.Parse(row["StartTime"].ToString());
                            timeStr = "<span class='HomeTime'>" + GetHourStr(itEvent) + "</span>";
                            itEvent = DateTime.Parse(row["EndTime"].ToString());
                            timeStr += "<span class='HomeTime'> to " + GetHourStr(itEvent) + "</span><span class=\"MoreTimes\"> + more times</span>";

                            int contentLimit = 105;
                            if (imageStr == "")
                                contentLimit = 281;
                            content = dat.stripHTML(row["Content"].ToString());
                            if (content.Length > contentLimit)
                            {
                                content = content.Substring(0, contentLimit) + "...";
                            }

                            lit.Text += timeStr + "<br/>" +
                                dat.BreakUpString(content.Replace("<br/>", " ").Replace("<br>",
                                " ").Replace("<br />", " ").Replace("<BR>", " ").Replace("<BR />",
                                " ").Replace("<BR/>", " "), 13);

                            lit.Text += "</div><div  class=\"ReadMoreHome\"><a class=\"ReadMoreHome\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Trip\">Read More</a></div></div></div></div>";
                        }
                        item.Controls.Add(lit);
                        RadRotator2.Items.Add(item);
                    }
                    else
                    {
                        DataView dsSlider = dat.GetDataDV("SELECT * FROM Venue_Slider_Mapping WHERE VenueID=" +
                                row["EventID"].ToString());

                        string imageStr = "";
                        bool isImage = false;
                        if (dsSlider.Count > 0)
                        {
                            isImage = true;
                            if (!System.IO.File.Exists(MapPath(".") + "VenueFiles/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString()))
                            {
                                isImage = false;
                            }
                        }
                        if (isImage)
                        {
                            imageStr = "<div align=\"center\" style=\"vertical-align: middle; width: 240px; height: 240px;\"><table width='240px' cellpadding='0' cellspacing='0' height='238px' bgcolor='black'><tr><td valign='center'><a width='240px' href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Venue\"" +
                                "\"><img  alt=\"" + dat.MakeNiceName(row["Header"].ToString()).Replace("-", " ") + "\" src=\""
                                + "VenueFiles/" + row["EventID"].ToString() + "/Slider/" + dsSlider[0]["PictureName"].ToString() + "\" /></a></td></tr></table>"+
                                "<div style=\"font-weight: bold;color: white;position: absolute;bottom: 0;width: 240px; height: 50px; z-index: 1000;\"><table cellpadding='0' cellspacing='0' height='50px'><tr><td valign='center'><div align='center'>" +
                                row["Header"].ToString() + "</div></td></tr></table></div>" +
                                "<div style=\"vertical-align: middle;color: white;position: absolute; bottom: 0;width: 240px; " +
                                "background-color: black; opacity: .7; filter: alpha(opacity=70);height: 50px;\"></div>" +
                                "</div>";
                            lit.Text = imageStr;
                        }
                        else
                        {
                            string timeStr = "";
                            DateTime itEvent = new DateTime();
                            itEvent = DateTime.Parse(row["StartTime"].ToString());
                            timeStr = "<span class='HomeTime'>" + GetHourStr(itEvent) + "</span>";
                            itEvent = DateTime.Parse(row["EndTime"].ToString());
                            timeStr += "<span class='HomeTime'> to " + GetHourStr(itEvent) + "</span><span class=\"MoreTimes\"> + more times</span>";

                            lit.Text = "<div  class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">" +
                                "<h2 class=\"Event\"><a class=\"HomeEventTitle\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Venue\">";

                            string headerStr = row["Header"].ToString();

                            if (headerStr.Length > 49)
                            {
                                headerStr = headerStr.Substring(0, 46) + "...";
                            }

                            lit.Text += dat.BreakUpString(headerStr, 20) + "</a></h2></div><div class=\"FooterBottom\">" +
                                imageStr + "<div  class=\"Home44\" class=\"Text12\">";

                            int contentLimit = 105;
                            if (imageStr == "")
                                contentLimit = 281;
                            content = dat.stripHTML(row["Content"].ToString());
                            if (content.Length > contentLimit)
                            {
                                content = content.Substring(0, contentLimit) + "...";
                            }

                            lit.Text += timeStr + "<br/>" +
                                dat.BreakUpString(content.Replace("<br/>", " ").Replace("<br>",
                                " ").Replace("<br />", " ").Replace("<BR>", " ").Replace("<BR />",
                                " ").Replace("<BR/>", " "), 13);

                            lit.Text += "</div><div  class=\"ReadMoreHome\"><a class=\"ReadMoreHome\" href=\"" + dat.MakeNiceName(row["Header"].ToString()) +
                                "_" + row["EventID"].ToString() + "_Venue\">Read More</a></div></div></div></div>";

                        }
                        item.Controls.Add(lit);
                        Rotator1.Items.Add(item);

                    }

                }

                if (RadRotator2.Controls.Count == 0)
                {
                    Literal lit = new Literal();
                    lit.Text = "<div class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">";

                    string headerStr = "<div style=\"padding-top: 55px;\">There are currently no adventures "+
                        "posted in your location. But you can add them! <a class=\"NavyLinkSmall\" "+
                        "href=\"enter-trip\"><br/>+Add Adventure</a></div>";

                    lit.Text += dat.BreakUpString(headerStr, 20) + "</div><div class=\"FooterBottom\"><div "+
                        "class=\"Home44\" class=\"Text12\">";

                    lit.Text += "</div></div></div></div>";

                    RadRotatorItem item = new RadRotatorItem();
                    item.Controls.Add(lit);
                    RadRotator2.Items.Add(item);
                }

                if (RadRotator1.Controls.Count == 0)
                {
                    Literal lit = new Literal();
                    lit.Text = "<div class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">";

                    string headerStr = "<div style=\"padding-top: 55px;\">There are currently no events " +
                        "posted in your location. But you can add them! <a class=\"NavyLinkSmall\" "+
                        "href=\"blog-event\"><br/>+Add Event</a></div>";

                    lit.Text += dat.BreakUpString(headerStr, 20) + "</div><div class=\"FooterBottom\"><div " +
                        "class=\"Home44\" class=\"Text12\">";

                    lit.Text += "</div></div></div></div>";

                    RadRotatorItem item = new RadRotatorItem();
                    item.Controls.Add(lit);
                    RadRotator1.Items.Add(item);
                }

                if (Rotator1.Controls.Count == 0)
                {
                    Literal lit = new Literal();
                    lit.Text = "<div class=\"Home42\"><div class=\"Home43\"><div align=\"center\" class=\"FooterBottom\">";

                    string headerStr = "<div style=\"padding-top: 55px;\">There are currently no locales " +
                        "posted in your location. But you can add them! <a class=\"NavyLinkSmall\" "+
                        "href=\"enter-locale\"><br/>+Add Locale</a></div>";

                    lit.Text += dat.BreakUpString(headerStr, 20) + "</div><div class=\"FooterBottom\"><div " +
                        "class=\"Home44\" class=\"Text12\">";

                    lit.Text += "</div></div></div></div>";

                    RadRotatorItem item = new RadRotatorItem();
                    item.Controls.Add(lit);
                    Rotator1.Items.Add(item);
                }

                //if (ds.Tables[0].Rows.Count < 4)
                //{
                //    if (ds.Tables[0].Rows.Count == 1)
                //    {

                //        Literal lit = new Literal();
                //        lit.Text = "<div class=\"Text12 Home45\">" +
                //            "<div  class=\"AdEmptyInner\">There aren't many events posted " +
                //            "in your location for this time frame. Be the first to post an event and have it featured on our home page. " +
                //            "<br/><a class=\"NavyLinkSmall\" href=\"blog-event\"><br/>+Add Event</a><a class=\"NavyLinkSmall\" href=\"enter-locale\"><br/>+Add Locale</a>" +
                //            "<a class=\"NavyLinkSmall\" href=\"enter-trip\"><br/>+Add Adventure</a></div></div>";
                //        Telerik.Web.UI.RadRotatorItem item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);

                //        lit = new Literal();
                //        lit.Text = "<div class=\"Text12 Home46\">" +
                //            "</div>";
                //        item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);

                //        lit = new Literal();
                //        lit.Text = "<div class=\"Text12 Home47\">" +
                //            "</div>";
                //        item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);
                //    }
                //    else if (ds.Tables[0].Rows.Count == 2)
                //    {
                //        Literal lit = new Literal();
                //        lit.Text = "<div class=\"Text12 Home45\">" +
                //            "<div  class=\"AdEmptyInner\">There aren't many events posted in your location for this time frame. Be the first to post an event and have " +
                //            "it featured on our home page. " +
                //            "<br/><a class=\"NavyLinkSmall\" href=\"blog-event\"><br/>+Add Event</a>" +
                //            "<a class=\"NavyLinkSmall\" href=\"enter-locale\"><br/>+Add Locale</a>" +
                //            "<a class=\"NavyLinkSmall\" href=\"enter-trip\"><br/>+Add Adventure</a></div></div>";
                //        Telerik.Web.UI.RadRotatorItem item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);

                //        lit = new Literal();
                //        lit.Text = "<div class=\"Home47\">" +
                //            "</div>";
                //        item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);
                //    }
                //    else if (ds.Tables[0].Rows.Count == 3)
                //    {
                //        Literal lit = new Literal();
                //        lit.Text = "<div class=\"Text12 Home48\">" +
                //            "<div  class=\"AdEmptyInner\">There aren't many events posted in your location for this time frame. Be the first to post an event and have it featured on our home page. " +
                //            "<br/><a class=\"NavyLinkSmall\" href=\"blog-event\"><br/>+Add Event</a>" +
                //            "<a class=\"NavyLinkSmall\" href=\"enter-locale\"><br/>+Add Locale</a>" +
                //            "<a class=\"NavyLinkSmall\" href=\"enter-trip\"><br/>+Add Adventure</a></div></div>";
                //        Telerik.Web.UI.RadRotatorItem item = new Telerik.Web.UI.RadRotatorItem();
                //        item.Controls.Add(lit);

                //        Rotator1.Items.Add(item);
                //        RadRotator1.Items.Add(item);
                //        RadRotator2.Items.Add(item);
                //    }
                //}
            }
            else
            {

                Literal lit = new Literal();
                lit.Text = "<div class=\"Text12 Home45\">" +
                    "<div  class=\"AdEmptyInner\">There are no posted events in your location for this time frame. Be the first to post an event and have it featured on our home page. " +
                            "<br/><a class=\"NavyLinkSmall\" href=\"blog-event\"><br/>+Add Event</a>" +
                            "<a class=\"NavyLinkSmall\" href=\"enter-locale\"><br/>+Add Locale</a>" +
                            "<a class=\"NavyLinkSmall\" href=\"enter-trip\"><br/>+Add Adventure</a></div></div>";
                Telerik.Web.UI.RadRotatorItem item = new Telerik.Web.UI.RadRotatorItem();
                item.Controls.Add(lit);

                Rotator1.Items.Add(item);
                RadRotator1.Items.Add(item);
                RadRotator2.Items.Add(item);

                lit = new Literal();
                lit.Text = "<div  class=\"Home49\">" +
                    "</div>";
                item = new Telerik.Web.UI.RadRotatorItem();
                item.Controls.Add(lit);

                Rotator1.Items.Add(item);
                RadRotator1.Items.Add(item);
                RadRotator2.Items.Add(item);

                lit = new Literal();
                lit.Text = "<div  class=\"Home49\">" +
                    "</div>";
                item = new Telerik.Web.UI.RadRotatorItem();
                item.Controls.Add(lit);

                Rotator1.Items.Add(item);
                RadRotator1.Items.Add(item);
                RadRotator2.Items.Add(item);

                lit = new Literal();
                lit.Text = "<div class=\"Home50\">" +
                    "</div>";
                item = new Telerik.Web.UI.RadRotatorItem();
                item.Controls.Add(lit);

                Rotator1.Items.Add(item);
                RadRotator1.Items.Add(item);
                RadRotator2.Items.Add(item);
            }
        }
        catch (Exception ex)
        {
            TimeFrameLabel.Text += ex.ToString();
        }
    }
Esempio n. 24
0
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        DateTime timeEvent = DateTime.Parse(e.Appointment.ID.ToString());

        string dateStart = timeEvent.Month.ToString() + "/" + timeEvent.Day.ToString() + "/" + timeEvent.Year.ToString();

        DataView dv = dat.GetDataDV("SELECT *, GEO.ID AS GEOID FROM GroupEvents GE, GroupEvent_Occurance " +
            "GEO WHERE GE.ID=GEO.GroupEventID AND CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
            "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
            "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart)) = '" + dateStart + "' AND GE.GroupID=" + Request.QueryString["ID"].ToString());

        RadToolTip newToolTip = new RadToolTip();
        DateTime dt = new DateTime();
        string replaceIt = "";
        string content = "";
        newToolTip.Text = "<div style=\"display: block; width: 500px; color: #cccccc;\">";
        foreach (DataRowView row in dv)
        {
            dt = DateTime.Parse(row["DateTimeStart"].ToString());
            content = row["Content"].ToString();

            if (content.Length > 400)
            {
                content = content.Substring(0, 400) + "... <a href=\"" + dat.MakeNiceName(row["Name"].ToString()) +
                    "_" + row["GEOID"].ToString() + "_" +
                 row["GroupEventID"].ToString() + "_GroupEvent\" class=\"AddUnderLink\">Read More</a>";
            }

            replaceIt = dt.Month.ToString() + "/" + dt.Day.ToString() + "/" + dt.Year.ToString();
            newToolTip.Text += "<a href=\"" + dat.MakeNiceName(row["Name"].ToString()) + "_" +
                row["GEOID"].ToString() + "_" +
                 row["GroupEventID"].ToString() + "_GroupEvent\" class=\"AddUnderLink\" >" +
                dat.BreakUpString(row["Name"].ToString(), 50) + "</a>" +
                "<br/>" + row["DateTimeStart"].ToString().Replace(replaceIt, "") + " - " +
                row["DateTimeEnd"].ToString().Replace(replaceIt, "") + "<br/>" + content + "<br/><br/>";
        }
        newToolTip.Text += "</div>";
        newToolTip.TargetControlID = e.Appointment.ClientID;
        newToolTip.IsClientID = true;
        newToolTip.HideEvent = ToolTipHideEvent.ManualClose;
        newToolTip.Animation = ToolTipAnimation.None;
        newToolTip.Position = ToolTipPosition.MiddleLeft;
        newToolTip.ShowEvent = ToolTipShowEvent.OnClick;
        newToolTip.Skin = "Black";
        newToolTip.Width = 520;
        ToolTipPanel.Controls.Add(newToolTip);
    }
    private void FillLiteral()
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];

        DateTime isn = DateTime.Now;

        if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
            isn = DateTime.Now;
        DateTime isNow = isn;
        Data dat = new Data(isn);

        if (FeaturePanel.Visible)
        {
            string templateID = "";

            templateID = TemplateRadioList.SelectedValue;

            FeaturedPreviewPanel.Visible = true;
            int integer = 2;
            string username = dat.GetDataDV("select * from Users where user_id=" + Session["User"].ToString())[0]["UserName"].ToString();
            string email = "";
            if (AdPictureCheckList.Items.Count == 0 || !AdMediaPanel.Visible)
                email = GetEmailString(AdNameTextBox.Text, null,
                 null, SummaryTextBox.InnerHtml, username, ref integer, templateID);
            else
                email = GetEmailString(AdNameTextBox.Text, AdPictureCheckList.Items[0].Value,
                 null, SummaryTextBox.InnerHtml, username, ref integer, templateID);

                email += "</tr>";

            email = "<table>" + email + "</table>";
            FeaturedPreviewLiteral.Text = email;
        }

        EventPanel.Visible = true;
        ShowHeaderName.Text = AdNameTextBox.Text;
        ShowDescription.Text = dat.BreakUpString(DescriptionTextBox.Content, 60);

        Rotator1.Items.Clear();
        char[] delim = { '\\' };
        string[] fileArray;

        string[] finalFileArray = new string[PictureCheckList.Items.Count];

        if (System.IO.Directory.Exists(MapPath(".") + "\\UserFiles\\" +
             Session["UserName"].ToString() + "\\AdSlider\\"))
        {
            fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" +
                 Session["UserName"].ToString() + "\\AdSlider\\");

        }

        char[] delim2 = { '.' };
        for (int i = 0; i < PictureCheckList.Items.Count; i++)
        {
            Literal literal4 = new Literal();
            string[] tokens = PictureCheckList.Items[i].Value.ToString().Split(delim2);
            string toUse = "";
            if (tokens.Length >= 2)
            {
                if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                {
                    System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + PictureCheckList.Items[i].Value.ToString());
                    toUse = "/UserFiles/" + Session["UserName"].ToString() + "/AdSlider/" + PictureCheckList.Items[i].Value.ToString();

                    int width = 412;
                    int height = 250;

                    int newHeight = image.Height;
                    int newIntWidth = image.Width;

                    literal4.Text = "<div style=\"width: 412px; height: 250px;\"><img style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                    + toUse + "\" /></div>";

                }
                else if (tokens[1].ToUpper() == "WMV")
                {
                    literal4.Text = "<object><param  name=\"wmode\" value=\"opaque\" ></param><embed wmode=\"opaque\" height=\"250px\" width=\"410px\" src=\""
                        + "UserFiles/" + Session["UserName"].ToString() + "/AdSlider/" + PictureCheckList.Items[i].Value.ToString() +
                        "\" /></object>";
                }
            }
            else
            {
                literal4.Text = "<div style=\"float:left;\"><object width=\"412\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"412\" height=\"250\"></embed></object></div>";
            }

            Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
            r4.Controls.Add(literal4);
            Rotator1.Items.Add(r4);
        }

        if (Rotator1.Items.Count == 0)
            RotatorPanel.Visible = false;
        else
            RotatorPanel.Visible = true;

        if (Rotator1.Items.Count == 1)
            RotatorPanel.CssClass = "HiddeButtons";
        else
            RotatorPanel.CssClass = "";
    }
Esempio n. 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        DateTime dateNow = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
        Data dat = new Data(dateNow);
        Literal lit = new Literal();
        lit.Text = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAjjoxQtYNtdn3Tc17U5-jbBR2Kk_H7gXZZZniNQ8L14X1BLzkNhQjgZq1k-Pxm8FxVhUy3rfc6L9O4g\" type=\"text/javascript\"></script>";
        Master.HEAD_TAG.Controls.Add(lit);
        try
        {
            DataView dvGroup = dat.GetDataDV("SELECT * FROM Groups WHERE ID=" + Request.QueryString["ID"].ToString());
            Page.Title = dvGroup[0]["Header"].ToString() + " | Hippo Group";

            #region Take Care of Style
            ColorAa_1.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_1.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_1.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorAa_2.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_2.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_2.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorAa_3.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAb_3.Style.Add("background-color", "#" + dvGroup[0]["ColorA"].ToString());
            ColorAa_3.Style.Add("color", "#" + dvGroup[0]["TextA"].ToString());

            ColorBa_1.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBb_1.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBa_1.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            ColorBa_2.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBb_2.Style.Add("background-color", "#" + dvGroup[0]["ColorB"].ToString());
            ColorBa_2.Style.Add("color", "#" + dvGroup[0]["TextB"].ToString());

            RadScheduler1.BorderColor = System.Drawing.ColorTranslator.FromHtml("#" + dvGroup[0]["ColorB"].ToString());
            ScriptLiteral.Text = "<style type=\"text/css\">.RadScheduler .rsTodayCell {border: solid 1px #" +
                dvGroup[0]["ColorA"].ToString() + " !important;}</style>";
            #endregion

            if (!IsPostBack)
            {
                Session["RedirectTo"] = Request.Url.AbsoluteUri;
            }

            string country = dat.GetDataDV("SELECT * FROM Countries WHERE country_id=" + dvGroup[0]["Country"].ToString())[0]["country_name"].ToString();

            Literal liter = new Literal();
            liter.Text = "<link type=\"text/css\" href=\"Rads_Groups.css\" rel=\"stylesheet\" />"+
                "<style type=\"text/css\">.RadTabStrip_Telerik{border-bottom:1px solid #666666;}</style>";
            Page.Header.Controls.AddAt(0, liter);

            bool isMember = false;

            #region Take care of user types
            if (Session["User"] != null)
            {
                //Take care of Share with friends and Share though email and Flag
                LoggedInPanel.Visible = true;

                ShareFriends.THE_TEXT = "Share this with a friend";
                ShareFriends.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                    " would like to share the group '\"" + dat.BreakUpString(dvGroup[0]["Header"].ToString(), 14) +
                    "\"' with you.";
                ShareFriends.TYPE = "g";
                ShareFriends.ID = int.Parse(Request.QueryString["ID"].ToString());

                string descrip = dvGroup[0]["Content"].ToString();
                if(descrip.Length > 200)
                    descrip = descrip.Substring(0, 200) + "...";

                Session["messageEmail"] = "Group Name: <a href=\"http://hippohappenings.com/" +
                    dat.MakeNiceName(dat.BreakUpString(dvGroup[0]["Header"].ToString(), 14)) + "_" +
                    Request.QueryString["ID"].ToString() + "_Group\">" +
                            dat.BreakUpString(dvGroup[0]["Header"].ToString(), 14) + "</a>  <br/><br/> " +
                            descrip;
                Session["FlagID"] = Request.QueryString["ID"].ToString();
                Session["FlagType"] = "G";

                if (bool.Parse(dvGroup[0]["isPrivate"].ToString()))
                    PrivateLabel.Text = "Private Group";
                else
                    PrivateLabel.Text = "Public Group";

                DataView dvMember = dat.GetDataDV("SELECT * FROM Group_Members WHERE GroupID=" +
                    Request.QueryString["ID"].ToString() + " AND Accepted='True' AND MemberID=" + Session["User"].ToString());
                PostMessageID.Attributes.Add("onclick", "OpenMess('" + Request.QueryString["ID"].ToString() + "')");
                if (dvMember.Count > 0)
                {
                    if (bool.Parse(dvMember[0]["SharedHosting"].ToString()))
                    {
                        isMember = true;
                        Session["isHost"] = true;
                        HostHeaderPanel.Visible = true;
                        AddEventButton2.Visible = true;
                        MemberHeaderPanel.Visible = false;
                        //if is host, take care of host options
                        LinkButton1.Attributes.Add("onclick", "OpenInvite('" + Request.QueryString["ID"].ToString() + "')");
                        LinkButton2.Attributes.Add("onclick", "OpenPrefs('" + Request.QueryString["ID"].ToString() + "')");
                        LinkButton3.PostBackUrl = "EnterGroup.aspx?ID=" + Request.QueryString["ID"].ToString();
                        LinkButton4.PostBackUrl = "EnterGroupEvent.aspx?GroupID=" + Request.QueryString["ID"].ToString();
                        AddEventButton2.PostBackUrl = "EnterGroupEvent.aspx?GroupID=" + Request.QueryString["ID"].ToString();
                        LinkButton8.Attributes.Add("onclick", "OpenThread('" + Request.QueryString["ID"].ToString() + "')");
                        Label1.Attributes.Add("onclick", "OpenSendMess('" + Request.QueryString["ID"].ToString() + "')");
                    }
                    else
                    {
                        isMember = true;
                        Session["isHost"] = false;
                        Session["isMember"] = true;
                        HostHeaderPanel.Visible = false;
                        AddEventButton2.Visible = false;
                        MemberHeaderPanel.Visible = true;
                        Label2.Attributes.Add("onclick", "OpenThread('" + Request.QueryString["ID"].ToString() + "')");
                    }
                    PostMessagePanel.Visible = true;
                    Button2.Visible = false;
                }
                else
                {
                    Session["isHost"] = false;
                    Session["isMember"] = false;
                    HostHeaderPanel.Visible = false;
                    AddEventButton2.Visible = false;
                    MemberHeaderPanel.Visible = false;
                    PostMessagePanel.Visible = false;
                    Button2.Attributes.Add("onclick", "OpenJoin('" + Request.QueryString["ID"].ToString() + "')");
                }
            }
            else
            {
                Session["isHost"] = false;
                Session["isMember"] = false;
                HostHeaderPanel.Visible = false;
                AddEventButton2.Visible = false;
                MemberHeaderPanel.Visible = false;
                PostMessagePanel.Visible = false;
                Button2.Attributes.Add("onclick", "OpenJoin('" + Request.QueryString["ID"].ToString() + "')");
            }
            #endregion

            #region Contact Info
            CityStateZipLabel.Text = dvGroup[0]["City"].ToString() + ", " + dvGroup[0]["State"].ToString() + " " + dvGroup[0]["Zip"].ToString();

            if (dvGroup[0]["Phone"].ToString().Trim() != "")
            {
                PhoneLabel.Text = "Phone: " + dvGroup[0]["Phone"].ToString() + "<br/>";
                GroupContactInfoLabel.Visible = true;
            }

            if (dvGroup[0]["Email"].ToString().Trim() != "")
            {
                EmailLabel.Text = "Email: " + dvGroup[0]["Email"].ToString() + "<br/>";
                GroupContactInfoLabel.Visible = true;
            }

            if (dvGroup[0]["Web"].ToString().Trim() != "")
            {
                WebLabel.Text = "Web: " + dvGroup[0]["Web"].ToString();
                GroupContactInfoLabel.Visible = true;
            }

            if (dvGroup[0]["HostInstructions"].ToString() != null)
            {
                if (dvGroup[0]["HostInstructions"].ToString().Trim() != "")
                {
                    HostTitleInstructionsLabel.Visible = true;
                    HostInstructionsLabel.Text = dvGroup[0]["HostInstructions"].ToString().Trim();
                }
            }
            #endregion

            #region Members
            DataView dvMainHost = dat.GetDataDV("SELECT * FROM Groups G, Group_Members GM, Users U "+
                "WHERE GM.MemberID=U.User_ID AND GM.GroupID=G.ID AND G.ID=" +
                Request.QueryString["ID"].ToString() + " AND G.Host=U.User_ID");
            DataView dvHosts = dat.GetDataDV("SELECT * FROM Group_Members GM, Users U WHERE GM.GroupID=" +
                Request.QueryString["ID"].ToString() + " AND GM.MemberID=U.User_ID AND GM.Accepted='True' " +
                "AND GM.SharedHosting='True' AND GM.MemberID <> " + dvMainHost[0]["User_ID"].ToString());
            DataView dvMembers = dat.GetDataDV("SELECT * FROM Group_Members GM, Users U WHERE GM.GroupID=" +
                Request.QueryString["ID"].ToString() + " AND GM.MemberID=U.User_ID AND GM.Accepted='True' "+
                "AND GM.SharedHosting='False' ORDER BY U.UserName");

            string members = "";
            string friendImg = "";
            string strFill = "";
            string title = "";
            string description = "";

            foreach (DataRowView row in dvMainHost)
            {
                GetMemberString(ref members, row, dvGroup);
            }

            foreach (DataRowView row in dvHosts)
            {
                GetMemberString(ref members, row, dvGroup);
            }

            foreach (DataRowView row in dvMembers)
            {
                GetMemberString(ref members, row, dvGroup);
            }

            if (dvMembers.Count + dvMainHost.Count + dvHosts.Count > 6)
            {
                lit = new Literal();
                lit.Text = members;
                MembersPanel.Controls.Add(lit);
                MembersPanel.Visible = true;
            }
            else
            {
                MembersLiteral.Text = members;
            }

            #endregion

            DataView dvUser = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dvGroup[0]["Host"].ToString());
            EventName.Text = dvGroup[0]["Header"].ToString();

            #region Group Message Board
            DataView dvMessages = dat.GetDataDV("SELECT *, GM.ID AS MessageID FROM GroupMessages GM, Users U WHERE GM.GroupID=" +
                Request.QueryString["ID"].ToString() + " AND GM.UserID=U.User_ID");
            DataView dvSticky = dat.GetDataDV("SELECT *, GM.ID AS MessageID FROM GroupMessages GM, Group_Members M, Users U WHERE GM.GroupID=" +
                Request.QueryString["ID"].ToString() + " AND GM.UserID=U.User_ID and M.GroupID=" +
                Request.QueryString["ID"].ToString() + " AND M.MemberID=U.User_ID AND M.SharedHosting='True' AND GM.isSticky='True'");
            members = "";
            friendImg = "";
            strFill = "";
            description = "";

            string stickyID = "";

            if (dvSticky.Count > 0)
            {
                dvSticky.Sort = "DatePosted DESC";

                stickyID = dvSticky[0]["MessageID"].ToString();

                if (System.IO.File.Exists(Server.MapPath(".") + "\\UserFiles\\" + dvSticky[0]["UserName"].ToString() +
                            "\\Profile\\" + dvSticky[0]["ProfilePicture"].ToString()))
                {
                    friendImg = "UserFiles/" + dvSticky[0]["UserName"].ToString() + "/Profile/" + dvSticky[0]["ProfilePicture"].ToString();
                    strFill = "";
                }
                else
                {
                    friendImg = "image/noAvatar_50x50_small.png";
                    strFill = "onmouseover=\"this.src='NewImages/noAvatar_50x50_smallhover.png'\"" +
                        "onmouseout=\"this.src='image/noAvatar_50x50_small.png'\" ";
                }
                string imgLit = "";
                if (Session["User"] != null)
                {
                    if (Session["User"].ToString() == dvSticky[0]["User_ID"].ToString())
                    {
                        imgLit = "<div style=\"float: right;\"><img style=\"cursor: pointer;\" name=\"remove stickyness\" src=\"image/X.png\" onclick=\"OpenRemoveSticky('" + Request.QueryString["ID"].ToString() +
                            "');\" onmouseout=\"this.src = 'image/X.png';\" " +
                            "onmouseover=\"this.src = 'image/XSelected.png';\" /></div>";
                    }
                }

                members = "<div style=\"border-bottom: solid 1px #1b1b1b;float: left; clear: both; padding-left: 3px; padding-top: 5px;\">" + imgLit +
                    "<a target='_blank' href=\"" + dvSticky[0]["UserName"].ToString() + "_Friend\"><img " + strFill +
                    " style=\" border: 0;float: left;padding-right: 7px; padding-bottom: 2px;\" " +
                                "src=\"" + friendImg + "\" width=\"50px\" height=\"50px\" /></a>"+
                                "<div style=\"float: left;\"><div style=\"height: 19px; background-position: left; background-repeat: no-repeat; background-image: url(images/UserNameLeft.png); "+
                                "padding-left: 4px;\"><div style=\"height: 19px; background-repeat: no-repeat; background-position: right; "+
                                "background-image: url(images/UserNameRight.png); "+
                                "padding-right: 4px;\"><div style=\"height: 19px; background-repeat: repeat-x; " +
                                "background-image: url(images/UserNameMiddle.png);\"><a style=\"float: left;\" href=\"" +
                                dvSticky[0]["UserName"].ToString() + "_Friend\" " +
                                "class=\"MemberName\">" +
                                dvSticky[0]["UserName"].ToString() +
                                "</a></div></div></div></div><span class=\"MemberTitle\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;-&nbsp;Posted On: " +
                                dvSticky[0]["DatePosted"].ToString().Trim() +
                                "</span> - <span style=\"color: #ff6b09; font-size: 30px;font: bold;\">!</span>" +
                                "<span class=\"MemberDescription\"  style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;&nbsp;" + dvSticky[0]["Content"].ToString() +
                                "</span><span style=\"font: bold;color: #ff6b09; font-size: 30px;\">!</span></div>";

                StickyMessageLiteral.Text = members;
            }

            members = "";

            if (stickyID != "")
            {
                dvMessages.RowFilter = "MessageID <> " + stickyID;
            }

            if (dvMessages.Count == 0)
            {
                lit = new Literal();
                lit.Text = "<div class=\"MemberDescription\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">No messages have been posted for this group.</div>";
                MessagesPanel.Controls.Add(lit);
            }
            else
            {
                dvMessages.Sort = "DatePosted DESC";
                foreach (DataRowView row in dvMessages)
                {
                    if (System.IO.File.Exists(Server.MapPath(".") + "\\UserFiles\\" + row["UserName"].ToString() +
                                "\\Profile\\" + row["ProfilePicture"].ToString()))
                    {
                        friendImg = "UserFiles/" + row["UserName"].ToString() + "/Profile/" + row["ProfilePicture"].ToString();
                        strFill = "";
                    }
                    else
                    {
                        friendImg = "image/noAvatar_50x50_small.png";
                        strFill = "onmouseover=\"this.src='NewImages/noAvatar_50x50_smallhover.png'\"" +
                            "onmouseout=\"this.src='image/noAvatar_50x50_small.png'\" ";
                    }

                    description = "<span class=\"MemberDescription\" style=\"color: #" + dvGroup[0]["TextB"].ToString() + " !important;\">&nbsp;&nbsp;" + row["Content"].ToString().Trim() + "</span>";

                    members += "<div style=\"float: left; clear: both; padding-left: 3px; padding-top: 5px;\"><a target='_blank' href=\"" + row["UserName"].ToString() + "_Friend\"><img " + strFill +
                        " style=\" border: 0;float: left;padding-right: 7px; padding-bottom: 2px;\" " +
                                    "src=\"" + friendImg + "\" width=\"50px\" height=\"50px\" /></a>"+
                                    "<div style=\"float: left;\"><div style=\"height: 19px; background-position: left; background-repeat: no-repeat; background-image: url(images/UserNameLeft.png); " +
                                "padding-left: 4px;\"><div style=\"height: 19px; background-repeat: no-repeat; background-position: right; " +
                                "background-image: url(images/UserNameRight.png); " +
                                "padding-right: 4px;\"><div style=\"height: 19px; background-repeat: repeat-x; " +
                                "background-image: url(images/UserNameMiddle.png);\"><a style=\"float: left;\" href=\"" + row["UserName"].ToString() + "_Friend\" class=\"MemberName\">" +
                                    row["UserName"].ToString() + "</a></div></div></div></div><span class=\"MemberTitle\" style=\"color: #" + dvGroup[0]["TextB"].ToString() +
                                    " !important;\">&nbsp;-&nbsp;Posted On: " + row["DatePosted"].ToString().Trim() + "</span> - " + description + "</div>";
                }

                lit = new Literal();
                lit.Text = members;
                MessagesPanel.Controls.Add(lit);
            }
            #endregion

            #region Take care of images and youtube
            char[] delim4 = { ';' };

            DataView dsSlider = dat.GetDataDV("SELECT * FROM Group_Slider_Mapping WHERE GroupID=" + Request.QueryString["ID"].ToString());
            if (dsSlider.Count > 0)
            {
                char[] delim = { '\\' };
                char[] delim3 = { '.' };

                for (int i = 0; i < dsSlider.Count; i++)
                {
                    string caption = "";
                    if (dsSlider[i]["Caption"] != null)
                    {
                        if (dsSlider[i]["Caption"].ToString().Trim() != "")
                        {
                            caption = "<div class=\"CaptionText\">" + dsSlider[i]["Caption"].ToString().Trim() + "</div>";
                        }
                    }
                    string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                    //dsSlider.RowFilter = "RealPictureName='" + tokens[0] + "." + tokens[1] + "'";
                    if (tokens.Length >= 2)
                    {
                        if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                        {
                            System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") +
                                "\\GroupFiles\\" + Request.QueryString["ID"].ToString() + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                            int width = 400;
                            int height = 250;

                            int newHeight = 0;
                            int newIntWidth = 0;

                            //if image height is less than resize height
                            if (height >= image.Height)
                            {
                                //leave the height as is
                                newHeight = image.Height;

                                if (width >= image.Width)
                                {
                                    newIntWidth = image.Width;
                                }
                                else
                                {
                                    newIntWidth = width;

                                    double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                    newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                    newHeight = (int)newDoubleHeight;
                                }
                            }
                            //if image height is greater than resize height...resize it
                            else
                            {
                                //make height equal to the requested height.
                                newHeight = height;

                                //get the ratio of the new height/original height and apply that to the width
                                double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                newIntWidth = (int)newDoubleWidth;

                                //if the resized width is still to big
                                if (newIntWidth > width)
                                {
                                    //make it equal to the requested width
                                    newIntWidth = width;

                                    //get the ratio of old/new width and apply it to the already resized height
                                    theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                    newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                    newHeight = (int)newDoubleHeight;
                                }
                            }

                            Literal literal4 = new Literal();
                            literal4.Text = "<div style=\"width: 400px; height: 250px;background-color: black;\">" +
                                "<img align=\"middle\" style=\"cursor: pointer; margin-left: " +
                                ((400 - newIntWidth) / 2).ToString() + "px; margin-top: " +
                                ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight +
                                "px\" width=\"" + newIntWidth + "px\" height=\"" + height.ToString() + "px\" width=\"" + width.ToString() +
                                "px\" src=\"" + "GroupFiles/" + Request.QueryString["ID"].ToString() + "/Slider/" + dsSlider[i]["PictureName"].ToString() +
                                "\" /></div>" + caption;
                            Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                            r4.Controls.Add(literal4);
                            Rotator1.Items.Add(r4);
                        }
                    }
                    else
                    {
                        Literal literal3 = new Literal();
                        literal3.Text = "<div class=\"topDiv\"><div style=\"float:left;background-color: black;\"><object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + dsSlider[i]["PictureName"].ToString() +
                            "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + dsSlider[i]["PictureName"].ToString() +
                            "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"400\" height=\"250\"></embed></object></div>" + caption + "</div>";
                        Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                        r3.Controls.Add(literal3);
                        Rotator1.Items.Add(r3);
                    }
                }
            }

            if (Rotator1.Items.Count == 0)
                RotatorPanel.Visible = false;
            else
            {
                RotatorPanel.Visible = true;
                if (Rotator1.Items.Count == 1)
                {
                    RotatorPanel.CssClass = "HiddeButtons";
                }
            }
            #endregion

            #region Take care of events
            //RadScheduler1.DataSource = dat.GetData("SELECT GEO.DateTimeStart, SUBSTRING(GE.Name, 0, 8) + ' ...' AS Name , GEO.DateTimeEnd, CONVERT(NVARCHAR,GE.ID) + ';'+CONVERT(NVARCHAR,GEO.ID) AS ID FROM GroupEvent_Occurance GEO, GroupEvents GE WHERE GEO.GroupEventID=GE.ID AND GE.GroupID=" + Request.QueryString["ID"].ToString());
            if (!IsPostBack)
            {
                if (isMember)
                {
                    RadScheduler1.DataSource = dat.GetData("SELECT CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart)) + ' 12:00:00' AS DateStart, " +
                        "CONVERT(NVARCHAR,COUNT(CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart)))) + CASE WHEN COUNT(CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart))) > 1 THEN ' events' ELSE ' event' END AS Name FROM " +
                        "GroupEvent_Occurance GEO, GroupEvents GE WHERE GE.LIVE='True' AND GEO.GroupEventID=GE.ID " +
                        "AND GE.GroupID=" + Request.QueryString["ID"].ToString() +
                        " GROUP BY CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart))");
                }
                else
                {
                    RadScheduler1.DataSource = dat.GetData("SELECT CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart)) + ' 12:00:00' AS DateStart, " +
                        "CONVERT(NVARCHAR,COUNT(CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart)))) + CASE WHEN COUNT(CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart))) > 1 THEN ' events' ELSE ' event' END AS Name FROM " +
                        "GroupEvent_Occurance GEO, GroupEvents GE WHERE GE.LIVE='True' AND GE.EventType=1 AND GEO.GroupEventID=GE.ID " +
                        "AND GE.GroupID=" + Request.QueryString["ID"].ToString() +
                        " GROUP BY CONVERT(NVARCHAR,MONTH(GEO.DateTimeStart)) + '/' + " +
                        "CONVERT(NVARCHAR,DAY(GEO.DateTimeStart)) + '/' +" +
                        "CONVERT(NVARCHAR,YEAR(GEO.DateTimeStart))");
                }
                RadScheduler1.DataBind();
                RadScheduler1.SelectedDate = DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"));
                //RadScheduler1.SelectedDate = DateTime.Parse("8/9/2010 23:13:00");
                MonthLabel.Text = dat.GetMonth(RadScheduler1.SelectedDate.Month.ToString());
                //MonthLabel.Text += " "+RadScheduler1.SelectedDate.ToString();
            }
            #endregion

            //Do this before unread threads are marked as read
            if (Session["User"] != null)
            {
                DataView ThreadsRead = dat.GetDataDV("SELECT * FROM ThreadRead TH, GroupThreads GT WHERE TH.UserID=" +
                    Session["User"].ToString() + " AND TH.[Read] = 'False' AND GT.GroupID=" + Request.QueryString["ID"].ToString() +
                    " AND GT.ID=TH.ThreadID ");

                if (ThreadsRead.Count > 0)
                    RadTabStrip1.Tabs[1].Text = "<div id=\"BiggerNewDiv\" style=\"float: left;display: block;font-weight: bold;color: #ff6b09;font-size: 12px;" +
                                "\"><div style=\"float: left;\">(</div><div style=\"float: left\"  id=\"NewThreadDiv\">" +
                                ThreadsRead.Count.ToString() +
                                "</div>&nbsp;unread)</div>&nbsp;&nbsp;<span onclick='HideSocial()'>Stuff We Talk About</span>";
            }

            #region Take care of threads
            SortDropDown.Items[1].Attributes.Add("onclick", "ShowLoading();");
            SortDropDown.Items[2].Attributes.Add("onclick", "ShowLoading();");
            SortDropDown.Items[3].Attributes.Add("onclick", "ShowLoading();");
            SortThreads(SortDropDown, new EventArgs());
            #endregion

            //other details

            //TagCloud.THE_ID = int.Parse(Request.QueryString["ID"].ToString());
            GroupDescriptionLabel.Text = dvGroup[0]["Content"].ToString();

            //Fix calendar timezone
            RadScheduler1.TimeZoneOffset = -(DateTime.UtcNow.Subtract(dateNow));

            HostLabel.Text = dvUser[0]["UserName"].ToString();
            HostLabel.NavigateUrl = HostLabel.Text + "_Friend";

            #region Take care of map
            HttpCookie cookie2 = new HttpCookie("addressParameterName");
            cookie2.Value = dvGroup[0]["Header"].ToString();
            cookie2.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie2);

            string address = "";
            if (dvGroup[0]["Address"] != null)
            {
                if (dvGroup[0]["Address"].ToString() != "")
                {
                    address = dat.GetAddress(dvGroup[0]["Address"].ToString(), dvGroup[0]["Country"].ToString() != "223");

                }
            }

            cookie2 = new HttpCookie("addressParameter");
            cookie2.Value = address + " " + dvGroup[0]["City"].ToString() + " " + dvGroup[0]["State"].ToString() +
                " " + dvGroup[0]["Zip"].ToString() + " " + country;
            cookie2.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie2);

            Literal lit2 = new Literal();
            lit2.Text = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAjjoxQtYNtdn3Tc17U5-jbBR2Kk_H7gXZZZniNQ8L14X1BLzkNhQjgZq1k-Pxm8FxVhUy3rfc6L9O4g\" type=\"text/javascript\"></script>";
            Page.Header.Controls.Add(lit2);

            Master.BodyTag.Attributes.Add("onload", "initialize();");
            Master.BodyTag.Attributes.Add("onunload", "GUnload()");
            #endregion

            #region Take care of main image
            bool doVertical = false;
            if (dvGroup[0]["MainPicture"] != null)
            {
                if (dvGroup[0]["MainPicture"].ToString().Trim() != "")
                {
                    ImageLiteral.Text = "<div style=\"width: 200px;\"><div";
                    GroupMainImage.ImageUrl = "GroupFiles/" + dvGroup[0]["ID"].ToString() + "/Slider/" + dvGroup[0]["MainPicture"].ToString().Trim();
                    System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("GroupFiles/" + dvGroup[0]["ID"].ToString() + "/Slider/" + dvGroup[0]["MainPicture"].ToString().Trim()));

                    if (img.Height < 200)
                    {
                        string toDivide = ((200 - img.Height) / 2).ToString();
                        ImageLiteral.Text += " style=\" padding-top: 10px; " + "\" ";

                        if (img.Width < 200)
                        {
                            string toDivide2 = ((200 - img.Width) / 2).ToString();
                            ImageLiteral.Text += " padding-left: " + toDivide2 + "px;" + "\" ";
                        }
                    }
                    else if (img.Width < 200)
                    {
                        string toDivide2 = ((200 - img.Width) / 2).ToString();
                        ImageLiteral.Text += " style=\" padding-left: " + toDivide2 + "px;" + "\" ";
                    }

                    ImageLiteral.Text += ">";
                    ImageLiteralBottom.Text = "</div></div>";

                    //Digg
                    DiggLiteral.Text = "<table style=\"padding-top: 5px;\">" +
                                   " <tr> " +
                                     "  <td valign=\"bottom\" style=\"padding-right: 0px;\">" +
                                       "     <a name=\"fb_share\" type=\"button\" " +
                                       "href=\"http://www.facebook.com/sharer.php\">Share</a>" +
                                       "<script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\"" +
                                       " type=\"text/javascript\"></script>" +
                                       " </td> " +
                                       " <td valign=\"bottom\" style=\"padding-right: 0px;\"> " +
                                        "    <a style=\"border: 0; padding: 0; margin: 0;\" " +
                                        "id=\"TweeterA\" title=\"Click to send this page to Twitter!\" " +
                                        "target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; " +
                                        "padding: 0; margin: 0;\" " +
                                        "src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" " +
                                        "alt=\"Share on Twitter\"/></a> " +
                                        "</td> " +
                                        "<td valign=\"bottom\">" +
                                         "   <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\"> " +
                                        "        <img style=\"position: relative; top: 2px\" " +
                                        "src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" " +
                                        "border=\"0\" alt=\"Share on MySpace\" /> " +
                                         "   </a> " +
                                        "</td> " +
                                    "</tr> " +
                                   " <tr> " +
                                      "  <td valign=\"bottom\" colspan=\"3\" align=\"center\"> " +
                                        "    <table cellpadding=\"5px\"> " +
                                         "       <tr> " +
                                          "          <td><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                                    "href='http://digg.com/submit?phase=2&url=" + "http://" +
                                    Request.Url.Authority + "/" +
                                    dat.MakeNiceName(dvGroup[0]["Header"].ToString()) +
                                    "_" + Request.QueryString["ID"].ToString() + "_Group" +
                                    "' target=\"_blank\">Digg</a>" +
                                                    "</td>" +
                                                    "<td>" +
                           "<a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\"> " +
                           "<img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" /> " +
                                                  "  </a> " +

                                                   " </td> " +
                                                    "<td> " +
                                                     "<script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                                                    "</td>" +
                                                "</tr>" +
                                            "</table>" +
                                        "</td>" +
                                        "<td></td>" +
                                   " </tr>" +
                               " </table>";

                    SocialsVertical.Visible = false;
                    SocialsHorizontal.Visible = true;

                }
                else
                {
                    doVertical = true;
                    GroupMainImage.Visible = false;
                }
            }
            else
            {
                doVertical = true;
                GroupMainImage.Visible = false;
            }

            if (doVertical)
            {
                //Digg
                DiggLiteralVertical.Text = "<table style=\"padding-top: 50px; padding-left: 70px;\">" +
                                        "<tr> " +
                                            "<td valign=\"bottom\" style=\"padding-right: 0px;\">" +
                                             "   <a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>" +
                                            "</td>" +
                                        "</tr>" +
                                       " <tr>" +
                                         "   <td valign=\"bottom\" style=\"padding-right: 0px;\">" +
                                         "       <a style=\"border: 0; padding: 0; margin: 0;\" id=\"A1\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>" +
                                         "   </td>" +
                                        "</tr>" +
                                        "<tr>" +
                                         "   <td valign=\"bottom\">" +
                                         "       <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">" +
                                          "          <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />" +
                                           "     </a>" +
                                           " </td>" +
                                       " </tr>" +
                                       " <tr>" +
                                         "   <td valign=\"bottom\"> <a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                                "href='http://digg.com/submit?phase=2&url=" + "http://" +
                                Request.Url.Authority + "/" +
                                dat.MakeNiceName(dvGroup[0]["Header"].ToString()) +
                                "_" + Request.QueryString["ID"].ToString() + "_Group" +
                                "' target=\"_blank\">Digg</a> " +
                                              "  <a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
                                                  "  <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
                                                "</a>" +
                                               "  <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                                            " </td>" +
                                        " </tr>" +

                                   "  </table>";
                SocialsHorizontal.Visible = false;
                SocialsVertical.Visible = true;
            }
            #endregion
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }
    protected string GetEmailString(string header, string picture, string ID, string description, 
        string userName, bool isBig, ref int normalAdCount)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        string adtitle = "style=\"color: White;font-weight: bold;font-family: Arial;font-size: 14px;margin-top: 10px;text-decoration: none;\"";
        string adbody = "style=\"color: #cccccc;font-family: Arial;font-size: 12px;line-height: 20px;\"";
        string readmorelink = "style=\"font-family: Arial; font-weight: bold;color: #1fb6e7; font-size: 12px;text-decoration: none;\"";
        string email = "";
        if (isBig)
        {

            email += "<tr><td colspan=\"2\"><div style=\"float: left;width: 419px;margin: 10px;  height: 206px; background-color: #686868;\">" +
            "<div class=\"topDiv\"  style=\"padding-top: 5px; clear: both; padding-left: 5px; background-color: #686868;\">";
            if (picture == null)
            {
                email += "</div>" +

                 "<div style=\"float: left;padding-top: 5px; padding-left: 3px;\">";
            }
            else
            {
                email += "<div style=\"float: left;\"><table width='212px' height='190px' " +
                    "bgcolor=\"black\" cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr>" +
                    "<td valign=\"middle\"><img alt=\"" +
                    header + "\" " + "name=\"" + header + "\" src=\"./UserFiles/" + userName + "/" +
                picture + "\" /></td></tr></tbody></table></div>" + "" +

                 "<div style=\"text-align: center; padding-top: 5px; padding-left: 3px;\">";

            }

            if (ID == null)
            {
                email += "<a " + adtitle + ">" + dat.BreakUpString(header, 21) + "</a><br/>";
            }
            else
            {
                email += "<a href=\"http://HippoHappenings.com/" + dat.MakeNiceName(header) + "_" + ID + "_Ad" +
                  "\" " + adtitle + ">" + dat.BreakUpString(header, 10) + "</a><br/>";
            }

            email += "<label " + adbody + ">" + description + "</label>";

            if (ID == null)
            {
                email += "<div style=\"float: right; padding-right: 8px; height: 50px; width: 80px; padding-top: 10px;\">" +
                             "<div style=\"float: left;padding-top: 5px; clear: none;\"><img src=\"http://HippoHappenings.com/image/ReadMoreArrow.png\" /></div>" +
                             "<div style=\"float: right;clear: none;\"><a " + readmorelink + ">Read More</a>";
            }
            else
            {
                email += "<div style=\"float: right; padding-right: 8px; height: 50px; width: 80px; padding-top: 10px;\">" +
                             "<div style=\"float: left;padding-top: 5px; clear: none;\"><img src=\"http://HippoHappenings.com/image/ReadMoreArrow.png\" /></div>" +
                             "<div style=\"float: right;clear: none;\"><a " + readmorelink + " href=\"http://HippoHappenings.com/" + dat.MakeNiceName(header) + "_" + ID + "_Ad\">Read More</a>";

            }

            email += "</div></div>" +
             "</div>" +
             "</div>" +
          "</div></td></tr>";
        }
        else
        {
            if (normalAdCount % 2 == 0)
            {
                email += "<tr><td>";
            }
            else
            {
                email += "<td>";
            }
            email += "<div style=\"float: left;margin: 10px; width: 214px; height: 268px; "+
                "background-color: #686868;\">" +
        "<div style=\"float: left;width: 214px; height: 268px; background-color: #686868;\">" +
            "<div class=\"topDiv\" style=\";padding-top: 10px; clear: both; padding-left: 10px;\">";

            if (picture == null)
            {
                email += "";
            }
            else
            {
                string w = "";
                string h = "";
                GetAdSize(out w, out h, picture);

                email += "<div style=\"float: left;\"><table width=\"100px\" height=\"100px\" " +
                    "bgcolor=\"black\"  cellpadding=\"0\" cellspacing=\"0\"><tbody align=\"center\"><tr><td valign=\"middle\">" +
                    "<img alt=\"" + header + "\" " +
                    "name=\"" + header + "\" width='" + w + "px' height='" + h + "px' src=\"./UserFiles/" +
                    userName + "/" + picture + "\" /></td></tr></tbody></table></div>";
            }

            if (ID == null)
            {
                email += "<div style=\"text-align: center; padding-left: 3px;\"><a " + adtitle + ">" +
                    dat.BreakUpString(header, 10) + "</a><br/>" +
                "</div>" +
            "</div>" +
            "<div align=\"left\" style=\"clear: both; padding-left: 12px; padding-right: 8px;\">" +
            "<label " + adbody + ">" + description + "</label>" +
            "</div>" +
            "<div style=\"float: right; padding-right: 8px; height: 50px; width: 80px; padding-top: 10px;\">" +
                "<div style=\"float: left;padding-top: 5px; clear: none;\"><img src=\"http://HippoHappenings.com/image/ReadMoreArrow.png\" /></div>" +
                "<div style=\"float: right;clear: none;\"><a " + readmorelink + " >Read More</a>" +
                "</div></div></div></div>";
            }
            else
            {
                email += "<div><a href=\"http://HippoHappenings.com/" + dat.MakeNiceName(header) +
                    "_" + ID + "_Ad\" " + adtitle + ">" + dat.BreakUpString(header, 10) + "</a><br/>" +
                "</div>" +
            "</div>" +
            "<div align=\"left\" style=\"clear: both; padding-left: 12px; padding-right: 8px;\">" +
            "<label " + adbody + ">" + description + "</label>" +
            "</div>" +
            "<div style=\"float: right; padding-right: 8px; height: 50px; width: 80px; padding-top: 10px;\">" +
                "<div style=\"float: left;padding-top: 5px; clear: none;\"><img src=\"http://HippoHappenings.com/image/ReadMoreArrow.png\" /></div>" +
                "<div style=\"float: right;clear: none;\"><a " + readmorelink + " href=\"http://HippoHappenings.com/" + dat.MakeNiceName(header) + "_" + ID + "_Ad\">Read More</a>" +
                "</div></div></div></div>";
            }
            if (normalAdCount % 2 == 0)
            {
                email += "</td>";
            }
            else
            {
                email += "</td></tr>";
            }

            normalAdCount++;
        }
            return email;
    }
Esempio n. 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string eventID = GetEventID();
        string message = "";
        bool isCl = false;
        if (Request.QueryString["cl"] != null)
            if (bool.Parse(Request.QueryString["cl"]))
            {
                isCl = true;
                eventID = eventID.Replace("_", "/");
            }

        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        try
        {
            Session["RedirectTo"] = Request.Url.AbsoluteUri;

            bool fillUserData = false;

            try
            {
                if (Session["User"] != null)
                {
                    LoggedInPanel.Visible = true;
                    LoggedOutPanel.Visible = false;

                    DataSet ds1 = dat.GetData("SELECT UserName FROM Users WHERE User_ID=" + Session["User"].ToString());
                    fillUserData = true;

                    if (!isCl)
                        EditLink.Visible = true;

                    ////Query whether current owner was delinquent on approve/reject changes
                    //if (dat.IsOwnerDelinquent(eventID, Request.IsLocal, "E"))
                    //{
                    //    //make the button visable
                    //    OwnerPanel.Visible = true;
                    //    Session["Message"] = "The ownership of this event is <b>open</b>. <br/>The ownership became " +
                    //        "open because the previous owner of this event became un-responsive to rejecting/" +
                    //        "approving user's changes to this event.<br/>If you would like to become " +
                    //        "the owner, click on the button below to go to the event's edit page. <br/><br/> " +
                    //        "Being the owner, you will have the privilage of having your <b>edits come though right " +
                    //        "away.</b> Other participants' changes to this event will have to be <b>approved by you.</b><br/><br/>" +
                    //        "<div align=\"center\" style=\"padding-left: 110px;\"><div align=\"center\"><div style=\"cursor: pointer;cursor: pointer; float: left;padding-right: 10px;\">" +
                    //        "<div class=\"topDiv\" style=\"float:left;\">"+
                    //        "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonLeft.png\" height=\"27px\" />"+
                    //        "<div style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('http://hippohappenings.com/NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">"+
                    //        "<a class=\"NavyLink\" onclick=\"Search('blog-event?edit=true&ID=" + eventID +
                    //        "');\">Edit</a></div>" +
                    //        "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonRight.png\" height=\"27px\" />"+
                    //        "</div>"+
                    //        "</div>"+
                    //        "</div>"+
                    //        "<div align=\"center\"><div style=\"cursor: pointer;\">" +
                    //        "<div class=\"topDiv\" style=\"float:left;\">" +
                    //        "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonLeft.png\" height=\"27px\" />" +
                    //        "<div style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('http://hippohappenings.com/NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
                    //        "<a class=\"NavyLink\" onclick=\"Search();\">Close</a></div>" +
                    //        "<img style=\"float: left;\" src=\"http://hippohappenings.com/NewImages/ButtonRight.png\" height=\"27px\" />" +
                    //        "</div>" +
                    //        "</div>" +
                    //        "</div></div>";
                    //}
                }
                else
                {
                    LoggedOutPanel.Visible = true;
                    LoggedInPanel.Visible = false;
                    //Button calendarLink = (Button)dat.FindControlRecursive(this, "CalendarLink");
                    //calendarLink.Visible = false;
                    //EditLink.Visible = false;
                }

                if (!isCl)
                    GetOtherEvents();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text += ex.ToString();
            }

            if (Request.QueryString["EventID"] == null)
                Response.Redirect("~/home");
            string ID = eventID;
            Session["EventID"] = ID;

            if (isCl)
            {
                HippoRating1.Visible = false;
                OwnerPanel.Visible = false;
                EditLink.Visible = false;
                PassedLink.Visible = false;
                PricePanel.Visible = false;
                RatingPanel.Visible = false;
                Flag1.Visible = false;
                ContactOwnerLink.Visible = false;
                ClGoingPanel.Visible = true;

                DateAndTimeLabel.Text = "";

                string URL = "http://newyork.craigslist.org" + eventID + ".html";
                message = URL;
                WebClient myClient = new WebClient();
                string webPageString = myClient.DownloadString(URL).Replace("\r", "").Replace("\n", "");

                HtmlAgilityPack.HtmlDocument a = new HtmlAgilityPack.HtmlDocument();
                a.LoadHtml(webPageString);

                string date = "";
                string link = "";
                string header = "";
                string email = "";

                #region Header
                IEnumerable<HtmlAgilityPack.HtmlNode> pNodes = a.DocumentNode.SelectNodes("//h2");
                foreach (HtmlAgilityPack.HtmlNode node in pNodes)
                {
                    header = node.InnerHtml;
                    break;
                }
                Session["ClHeader"] = header;
                #endregion

                #region Date
                DateTime DateTimeStart = new DateTime();
                DateTime DateTimeEnd = new DateTime();
                bool isEnd = false;
                dat.GetStartAndEndDate(out DateTimeStart, out DateTimeEnd, ref header, out isEnd);

                #endregion

                #region Description
                pNodes = a.DocumentNode.SelectNodes("//div[@id='userbody']");

                string description = "";

                foreach (HtmlAgilityPack.HtmlNode node in pNodes)
                {
                    description += node.OuterHtml;
                    break;
                }

                //Remove images
                description = dat.RemoveImages(description).Replace("<!-- START CLTAGS -->",
                    "").Replace("<!-- END CLTAGS -->", "").Replace("<a ", "<a class='NavyLink12UD' ");

                ShowDescriptionBegining.Text = description;
                Session["ClDescription"] = description;
                #endregion

                #region Email
                IEnumerable<HtmlAgilityPack.HtmlNode> nds = a.DocumentNode.ChildNodes[1].ChildNodes[1].Elements("a");
                foreach (HtmlAgilityPack.HtmlNode nd in nds)
                {
                    //if (nd.Name.ToLower() == "a")
                    //{
                    email = "<div style='clear: both;'><b>Email: " + nd.OuterHtml.Replace("<a", "<a target=\"_blank\" class=\"NavyLink12UD\"") + "</b></div>";
                    break;
                    //}
                }
                ClEmailLiteral.Text += "<b>craigslist event: <a class=\"NavyLink12UD\" target=\"_blank\" href='" + URL + "'>" + dat.BreakUpString(header, 14) + "</a></b><br/>" + email;
                #endregion

                #region Do Calendar Link
                string monthStart = DateTimeStart.Month.ToString();
                if (monthStart.Length == 1)
                    monthStart = "0" + monthStart;
                string dayStart = DateTimeStart.Day.ToString();
                if (dayStart.Length == 1)
                    dayStart = "0" + dayStart;

                string monthEnd = "";
                string dayEnd = "";
                string yearEnd = "";
                if (isEnd)
                {
                    monthEnd = DateTimeEnd.Month.ToString();
                    if (monthEnd.Length == 1)
                        monthEnd = "0" + monthEnd;
                    dayEnd = DateTimeEnd.Day.ToString();
                    if (dayEnd.Length == 1)
                        dayEnd = "0" + dayEnd;

                    yearEnd = DateTimeEnd.Year.ToString();
                }
                else
                {
                    monthEnd = monthStart;
                    dayEnd = dayStart;
                    yearEnd = DateTimeStart.Year.ToString();
                }

                string shortDesc = dat.stripHTML(description).Replace(" ", "+");

                if (shortDesc.Length > 1400)
                    shortDesc = shortDesc.Substring(0, 1400) + "...";

                string googleCalendarLink = "https://www.google.com/calendar/render?action=TEMPLATE&" +
                    "dates=" + DateTimeStart.Year.ToString() + monthStart + dayStart +
                        "T120000Z/" + yearEnd + monthEnd + dayEnd + "T130000Z" +
                    "&sprop=" +
                    "website:http://hippohappenings.com/" + dat.MakeNiceName(header) + "_CLHH" + GetEventID() + "_ClEvent" +
                    "&text=" +
                    header.Replace("/", "%2f").Replace(" ", "+") +
                    "&location=" +
                    "Location" +
                    "&sprop=name:" +
                    header.Replace("/", "%2f").Replace(" ", "+") +
                    "&details=" +
                    "craigslist+ad+http://hippohappenings.com/" + dat.MakeNiceName(header) +
                    "_CLHH" + GetEventID() + "_ClEvent+" + shortDesc +
                    "&gsessionid=OK&sf=true&output=xml";
                CalendarLiteral.Text = "<a target=\"_blank\" class=\"NavyLink12UD\" href=\"" + googleCalendarLink +
                    "\" title=\"Add this Meetup to your Google calendar\">" +
                    "<span class=\"calOpt google\"></span>Add To Google Calendar</a>";
                //DateAndTimeLabel.Text = googleCalendarLink;\
                #endregion

                #region Images
                pNodes = a.DocumentNode.SelectNodes("//img");

                Rotator1.Items.Clear();

                foreach (HtmlAgilityPack.HtmlNode node in pNodes)
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(node.Attributes["src"].Value);
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    Stream receiveStream = response.GetResponseStream();
                    // read the stream
                    System.Drawing.Image image = System.Drawing.Image.FromStream(receiveStream);
                    receiveStream.Close();
                    response.Close();

                    int width = 410;
                    int height = 250;

                    int newHeight = 0;
                    int newIntWidth = 0;

                    //if image height is less than resize height
                    if (height >= image.Height)
                    {
                        //leave the height as is
                        newHeight = image.Height;

                        if (width >= image.Width)
                        {
                            newIntWidth = image.Width;
                        }
                        else
                        {
                            newIntWidth = width;

                            double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                            double newDoubleHeight = double.Parse(newHeight.ToString());
                            newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                            newHeight = (int)newDoubleHeight;
                        }
                    }
                    //if image height is greater than resize height...resize it
                    else
                    {
                        //make height equal to the requested height.
                        newHeight = height;

                        //get the ratio of the new height/original height and apply that to the width
                        double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                        double newDoubleWidth = double.Parse(newIntWidth.ToString());
                        newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                        newIntWidth = (int)newDoubleWidth;

                        //if the resized width is still to big
                        if (newIntWidth > width)
                        {
                            //make it equal to the requested width
                            newIntWidth = width;

                            //get the ratio of old/new width and apply it to the already resized height
                            theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                            double newDoubleHeight = double.Parse(newHeight.ToString());
                            newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                            newHeight = (int)newDoubleHeight;
                        }
                    }

                    string alt = "";
                    if (node.Attributes.Contains("alt"))
                    {
                        alt = node.Attributes["alt"].Value;
                    }
                    else
                    {
                        alt = dat.MakeNiceNameFull(header);
                    }

                    Literal literal4 = new Literal();
                    literal4.Text = "<div class=\"RotatorImage\"><img alt=\"" + alt +
                "\" style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                        + node.Attributes["src"].Value + "\" /></div>";
                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                    r4.Controls.Add(literal4);

                    Rotator1.Items.Add(r4);
                }

                if (Rotator1.Items.Count == 0)
                    RotatorPanel.Visible = false;
                else
                {
                    RotatorPanel.Visible = true;
                    if (Rotator1.Items.Count == 1)
                    {
                        RotatorPanel.CssClass = "HiddeButtons";
                    }
                }
                #endregion

                #region Going
                DataView dvGoing = dat.GetDataDV("SELECT * FROM ClEventGoing WHERE ClEventID = '" + GetEventID() + "'");
                if (dvGoing.Count > 0)
                    NumberPeopleLabel.Text = dvGoing.Count.ToString();
                else
                    GoingPanel.Visible = false;

                if (Session["User"] != null)
                {
                    DataView dvGoingUser = dat.GetDataDV("SELECT * FROM ClEventGoing WHERE UserID = " + Session["User"].ToString() + " AND ClEventID = '" + GetEventID() + "'");
                    if (dvGoingUser.Count > 0)
                    {
                        ImGoingPanel.Visible = true;
                        AreUGoingPanel.Visible = false;
                    }
                    else
                    {
                        AreUGoingPanel.Visible = true;
                        ImGoingPanel.Visible = false;
                    }
                }
                else
                {
                    AreUGoingPanel.Visible = false;
                    ImGoingPanel.Visible = false;
                }

                #endregion

                EventName.Text = "<a id=\"" + dat.MakeNiceNameFull(header) + "\" class=\"aboutLink\" href=\"http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(header) +
                                "_CLHH" + GetEventID() + "_ClEvent\"><h1>" +
                                dat.BreakUpString(header, 50) + "</h1></a>";

                Session["Subject"] = "Re: " + header;
                Session["CommentSubject"] = "Re: " + header;

                #region Communicate
                if (Session["User"] != null)
                {
                    DataSet dsFriends = dat.GetData("SELECT DISTINCT UC.CLEventID, UC.UserID FROM User_Friends UF, ClEventGoing UC " +
                        "WHERE UC.CLEventID='" + GetEventID() + "' AND UC.UserID=UF.FriendID AND UF.UserID=" + Session["User"].ToString());

                    ASP.controls_smallbutton_ascx blueButton = new ASP.controls_smallbutton_ascx();
                    blueButton.CLIENT_LINK_CLICK = "OpenRad('" + eventID + "&cl=true');";
                    blueButton.BUTTON_TEXT = "Communicate with them";

                    int count = 0;
                    if (dsFriends.Tables.Count > 0)
                        if (dsFriends.Tables[0].Rows.Count > 0)
                        {
                            count = dsFriends.Tables[0].Rows.Count;
                        }

                    dvGoing = dat.GetDataDV("SELECT * FROM ClEventGoing WHERE ClEventID = '" + GetEventID() + "' AND UserID <> " + Session["User"].ToString());

                    if (dvGoing.Count > 0)
                        CommunicatePanel.Controls.Add(blueButton);

                    if (count > 0)
                    {
                        NumberFriendsLabel.Text = "(" + count.ToString() + " Friends)";
                    }
                }
                else
                {
                    Literal CommunicateLiteral = new Literal();
                    CommunicateLiteral.Text = "<div class=\"CommunicateWith\">To " +
                        "communicate with them, <a class=\"NavyLink aboutLink\" " +
                        "href=\"login\">log in</a>.</div>";
                    CommunicatePanel.Controls.Add(CommunicateLiteral);
                }
                #endregion

                #region Comments
                if (Session["User"] != null)
                {
                    DataSet dsComments;
                    string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                    if (commentPrefs == "1")
                    {
                        dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM ClEventComments C, Users U WHERE U.User_ID=C.UserID AND C.ClEventID='" + GetEventID() + "' ORDER BY C.BlogDate");
                    }
                    else
                    {
                        dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, C.Comment, C.BlogDate AS theDate FROM ClEventComments C, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=C.UserID) OR (U.User_ID=" +
                            Session["User"].ToString() + " AND U.User_ID=C.UserID)) AND C.ClEventID='" + GetEventID() + "' ORDER BY C.BlogDate");
                    }
                    TheComments.DATA_SET = dsComments;
                    TheComments.DataBind2(true);
                }
                else
                {
                    DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM ClEventComments C, Users U WHERE U.User_ID=C.UserID AND C.ClEventID='" + GetEventID() + "' ORDER BY C.BlogDate");
                    TheComments.DATA_SET = dsComments;
                    TheComments.DataBind2(true);
                }
                #endregion

                #region SEO
                //Create keyword and description meta tags and title
                topTopLiteral.Text = "<a class=\"NavyLink12UD\" href=\"#" + dat.MakeNiceNameFull(header) + "\">" +
                    dat.MakeNiceNameFull(header).Replace("-", " ") + " From The Top</a>";

                HtmlMeta hm = new HtmlMeta();
                HtmlMeta kw = new HtmlMeta();
                HtmlMeta lg = new HtmlMeta();
                HtmlHead head = (HtmlHead)Page.Header;
                HtmlLink cn = new HtmlLink();

                cn.Attributes.Add("rel", "canonical");
                cn.Href = "http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(header) +
                                "_CLHH" + GetEventID() + "_ClEvent";
                head.Controls.AddAt(0, cn);

                hm.Name = "Description";
                kw.Name = "keywords";
                lg.Name = "language";
                lg.Content = "English";
                head.Controls.AddAt(0, lg);

                char[] delimeter = { ' ' };
                string[] keywords = dat.MakeNiceNameFull(header).Replace("-",
                    " ").Split(delimeter, StringSplitOptions.RemoveEmptyEntries);
                int count2 = 0;
                foreach (string token in keywords)
                {
                    if (count2 < 16)
                    {
                        if (kw.Content != "")
                            kw.Content += " ";
                        kw.Content += token;

                        count2++;
                    }
                }
                head.Controls.AddAt(0, kw);

                hm.Content = dat.MakeNiceNameFull(dat.stripHTML(description).Replace("   ", " ").Replace("  ", " ")).Replace("-", " ");
                if (hm.Content.Length > 200)
                    hm.Content = hm.Content.Substring(0, 197) + "...";

                head.Controls.AddAt(0, hm);

                this.Title = kw.Content;

                HtmlLink lk = new HtmlLink();
                lk.Href = "http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(header) +
                                "_CLHH" + GetEventID() + "_ClEvent";
                lk.Attributes.Add("rel", "bookmark");
                head.Controls.AddAt(0, lk);
                #endregion

                Session["messageText"] = dat.BreakUpString(header, 14);
                Session["messageEmail"] = "EventName: <a href=\"http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(header) +
                                "_CLHH" + GetEventID() + "_ClEvent\">" +
                    dat.BreakUpString(header, 14) + "</a> <br/><br/>" + ShowDescriptionBegining.Text;

                if (fillUserData)
                {
                    ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                    SendMessage1.THE_TEXT = "Share on Hippo";
                    SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                        " would like to share \"" + dat.BreakUpString(header, 14) + "\" with you.";
                    SendMessage1.TYPE = "cl";
                    //SendMessage1.ID = int.Parse(ID);
                    SendMessage1.CL_ID = eventID;
                    CalendarSharePanel.Controls.Add(SendMessage1);

                    Session["Subject"] = "Re: " + Session["UserName"].ToString() +
                        " would like to share \"" + dat.BreakUpString(header, 14) + "\" with you.";

                }
            }
            else
            {
                if (Session["User"] != null)
                    dat.GetRecommendationIcons(eventID, ref RecomPanel);

                RecomPanel.Width = 10 * (RecomPanel.Controls.Count);

                DataSet ds = dat.GetData("SELECT * FROM Events WHERE ID=" + ID);

                DataView dv = new DataView(ds.Tables[0], "", "", DataViewRowState.CurrentRows);
                if (Session["User"] != null)
                {
                    if (dv[0]["Owner"].ToString() == Session["User"].ToString())
                    {
                        EditLink.Visible = true;
                        ContactOwnerLink.Visible = false;
                    }
                    else
                    {
                        if (dv[0]["Owner"] != null && dv[0]["Owner"].ToString() != "")
                        {
                            DataView dvU = dat.GetDataDV("SELECT * FROM Users WHERE User_ID=" + dv[0]["Owner"].ToString());
                            EditLink.Visible = false;
                            ContactOwnerLink.Visible = true;
                            ContactOwnerLink.HRef = dvU[0]["UserName"].ToString() + "_friend";
                        }
                        else
                        {
                            ContactOwnerLink.Visible = false;
                            EditLink.Visible = true;
                        }
                    }
                }
                else
                {
                    EditLink.Visible = false;
                    ContactOwnerLink.Visible = false;
                }

                //Overwrite everything if the event has passed
                if (dat.HasEventPassed(eventID))
                {
                    OwnerPanel.Visible = false;
                    EditLink.Visible = false;
                    PassedLink.Visible = true;
                }

                Session["FlagID"] = ID;
                Session["FlagType"] = "E";

                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (bool.Parse(ds.Tables[0].Rows[0]["Live"].ToString()))
                        {
                            PricePanel.Visible = false;
                            if (ds.Tables[0].Rows[0]["MaxPrice"] != null)
                            {
                                if (ds.Tables[0].Rows[0]["MaxPrice"].ToString() != "")
                                {
                                    MinPrice.Text = ds.Tables[0].Rows[0]["MinPrice"].ToString().Replace(".00", "");
                                    MaxPrice.Text = ds.Tables[0].Rows[0]["MaxPrice"].ToString().Replace(".00", "");
                                    PricePanel.Visible = true;
                                }
                            }

                            EventName.Text = "<a id=\"" + dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()) + "\" class=\"aboutLink\" href=\"http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                                "_" + ID.ToString() + "_Event\"><h1>" +
                                dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 50) + "</h1></a>";
                            Session["Subject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
                            Session["CommentSubject"] = "Re: " + ds.Tables[0].Rows[0]["Header"].ToString();
                            string UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                            DataSet dsDate = dat.GetData("SELECT * FROM Event_Occurance WHERE EventID=" + ID);

                            TagCloud.THE_ID = int.Parse(ID);
                            NumberPeopleLabel.Text = dat.GetData("SELECT DISTINCT UserID FROM User_Calendar " +
                                "WHERE EventID=" + ID).Tables[0].Rows.Count.ToString();

                            if (Session["User"] != null)
                            {
                                DataSet dsFriends = dat.GetData("SELECT DISTINCT UC.EventID, UC.UserID FROM User_Friends UF, User_Calendar UC " +
                                    "WHERE UC.EventID=" +
                                    ID + " AND UC.UserID=UF.FriendID AND UF.UserID=" + Session["User"].ToString());

                                ASP.controls_smallbutton_ascx blueButton = new ASP.controls_smallbutton_ascx();
                                blueButton.CLIENT_LINK_CLICK = "OpenRad('" + ID + "');";
                                blueButton.BUTTON_TEXT = "Communicate with them";

                                CommunicatePanel.Controls.Add(blueButton);

                                int count = 0;
                                if (dsFriends.Tables.Count > 0)
                                    if (dsFriends.Tables[0].Rows.Count > 0)
                                    {
                                        count = dsFriends.Tables[0].Rows.Count;
                                    }

                                NumberFriendsLabel.Text = "(" + count.ToString() + " Friends)";
                            }
                            else
                            {
                                Literal CommunicateLiteral = new Literal();
                                CommunicateLiteral.Text = "<div class=\"CommunicateWith\">To " +
                                    "communicate with them, <a class=\"NavyLink aboutLink\" " +
                                    "href=\"login\">log in</a>.</div>";
                                CommunicatePanel.Controls.Add(CommunicateLiteral);
                            }

                            if (bool.Parse(ds.Tables[0].Rows[0]["hasSongs"].ToString()))
                            {
                                DataSet dsSongs = dat.GetData("SELECT * FROM Event_Song_Mapping WHERE EventID=" + ID);
                                ASP.controls_playerxml_songplayer_ascx songs = new ASP.controls_playerxml_songplayer_ascx();
                                int songCount = dsSongs.Tables[0].Rows.Count;

                                if (songCount > 2)
                                {
                                    songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                    songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                                    songs.SONG3 = dsSongs.Tables[0].Rows[2]["SongName"].ToString();
                                    songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                                    songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                                    songs.SONG3_TITLE = dsSongs.Tables[0].Rows[2]["SongTitle"].ToString();
                                }
                                else if (songCount > 1)
                                {
                                    songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                    songs.SONG2 = dsSongs.Tables[0].Rows[1]["SongName"].ToString();
                                    songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                                    songs.SONG2_TITLE = dsSongs.Tables[0].Rows[1]["SongTitle"].ToString();
                                }
                                else if (songCount == 1)
                                {
                                    songs.SONG1 = dsSongs.Tables[0].Rows[0]["SongName"].ToString();
                                    songs.SONG1_TITLE = dsSongs.Tables[0].Rows[0]["SongTitle"].ToString();
                                }

                                songs.USER_NAME = ds.Tables[0].Rows[0]["UserName"].ToString();

                                SongPanel.Controls.Add(songs);
                            }

                            DateTime date;
                            DateTime endDate;
                            DateAndTimeLabel.Text = "";
                            string dateandtime = "";
                            bool dateGotten = false;
                            string moreDates = "";
                            DateTime DateTimeStart = DateTime.Parse(dsDate.Tables[0].Rows[0]["DateTimeStart"].ToString());
                            DateTime DateTimeEnd = DateTime.Parse(dsDate.Tables[0].Rows[0]["DateTimeEnd"].ToString());
                            bool isEnd = true;
                            for (int i = 0; i < dsDate.Tables[0].Rows.Count; i++)
                            {
                                date = DateTime.Parse(dsDate.Tables[0].Rows[i]["DateTimeStart"].ToString());
                                endDate = DateTime.Parse(dsDate.Tables[0].Rows[i]["DateTimeEnd"].ToString());

                                if ((endDate >= DateTime.Now && !dateGotten) || (i == dsDate.Tables[0].Rows.Count - 1 && !dateGotten))
                                {
                                    dateGotten = true;
                                    dateandtime += date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " +
                                        date.Day + " " + date.ToShortTimeString() + " To " +
                                        endDate.DayOfWeek.ToString() + ", " + GetMonth(endDate.Month.ToString()) + " " +
                                        endDate.Day + " " + endDate.ToShortTimeString();
                                    DateAndTimeLabel.Text += GetMonth(date.Month.ToString()).Substring(0, 3) + ". " +
                                        date.Day + " at " + date.ToShortTimeString().Replace(":00", "").Replace("PM", "p").Replace("AM", "a");
                                }
                                else
                                {

                                    if (moreDates == "")
                                        moreDates = "<div onclick=\"OpenMoreDates();\" class=\"NavyLink\" id=\"MoreDatesName\">More Dates</div>" +
                                            "<div class=\"MoreNo\" id=\"infoDiv\">" +
                                            (dsDate.Tables[0].Rows.Count * 40).ToString() +
                                            "</div><div class=\"MoreNo\" " +
                                            "id=\"MoreDatesDiv\"> <div class=\"NavyLink InnerMore\" " +
                                                   "onclick=\"OpenMoreDates();\">close</div><br/><br/>";
                                    moreDates += date.DayOfWeek.ToString() + ", " + GetMonth(date.Month.ToString()) + " " +
                                        date.Day + " " + date.ToShortTimeString()
                                        + " <span class=\"ToSpan\">To</span> " +
                                        endDate.DayOfWeek.ToString() + ", " + GetMonth(endDate.Month.ToString()) + " " +
                                        endDate.Day + " " + endDate.ToShortTimeString() + "<br/>";
                                }

                            }
                            if (moreDates != "")
                                moreDates += "</div>";

                            DateAndTimeLabel.Text += moreDates;

                            string content = ds.Tables[0].Rows[0]["Content"].ToString();
                            string niceName = dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString());

                            if (bool.Parse(ds.Tables[0].Rows[0]["Private"].ToString()))
                            {
                                VenueName.Text = ds.Tables[0].Rows[0]["Address"].ToString() + "<br/>" +
                                    ds.Tables[0].Rows[0]["City"].ToString() + ", " + ds.Tables[0].Rows[0]["State"].ToString() +
                                    " " + ds.Tables[0].Rows[0]["Zip"].ToString();

                                Session["messageText"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " occurs at " + ds.Tables[0].Rows[0]["Address"].ToString() + " on " + dateandtime;
                                Session["messageEmail"] = "EventName: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) + "_" + ID + "_Event\">" +
                                    dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "</a> <br/><br/> Venue: " + ds.Tables[0].Rows[0]["Address"].ToString() + " <br/><br/> Date: " +
                                    DateAndTimeLabel.Text + " <br/><br/> " + ShowDescriptionBegining.Text;
                            }
                            else
                            {
                                DataSet dsVenue = dat.GetData("SELECT * FROM Venues WHERE ID=" +
                                ds.Tables[0].Rows[0]["Venue"]);
                                VenueName.Text = dsVenue.Tables[0].Rows[0]["Name"].ToString();
                                VenueName.NavigateUrl = dat.MakeNiceName(dsVenue.Tables[0].Rows[0]["Name"].ToString()) +
                                    "_" + dsVenue.Tables[0].Rows[0]["ID"].ToString() + "_Venue";

                                Session["messageText"] = dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + " occurs at " + VenueName.Text + " on " + dateandtime;
                                Session["messageEmail"] = "EventName: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14)) + "_" + ID + "_Event\">" +
                                    dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "</a> <br/><br/> Venue: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(VenueName.Text) + "_" +
                                    dsVenue.Tables[0].Rows[0]["ID"].ToString() + "_Venue\">" + VenueName.Text + "</a> <br/><br/> Date: " +
                                    DateAndTimeLabel.Text + " <br/><br/> " + ShowDescriptionBegining.Text;
                            }

                            //ScriptLiteral.Text = "<script type=\"text/javascript\">ReturnURL('" + niceName.Replace("_", " ") + " at " + dat.MakeNiceName(dsVenue.Tables[0].Rows[0]["Name"].ToString()).Replace("_", " ") + " Tonight http://HippoHappenings.com/" + Request.QueryString["EventID"].ToString() + "_Event');</script>";

                            if (Session["User"] != null)
                            {
                                DataSet dsComments;
                                string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                                if (commentPrefs == "1")
                                {
                                    dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                                }
                                else
                                {
                                    dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, C.Comment, C.BlogDate AS theDate FROM Comments C, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=C.UserID) OR (U.User_ID=" +
                                        Session["User"].ToString() + " AND U.User_ID=C.UserID)) AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                                }
                                TheComments.DATA_SET = dsComments;
                                TheComments.DataBind2(true);
                            }
                            else
                            {
                                DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM Comments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                                TheComments.DATA_SET = dsComments;
                                TheComments.DataBind2(true);
                            }

                            ShowDescriptionBegining.Text = dat.BreakUpString(content, 20);

                            #region SEO
                            //Create keyword and description meta tags and title
                            topTopLiteral.Text = "<a class=\"NavyLink12UD\" href=\"#" + dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()) + "\">" +
                                dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()).Replace("-", " ") + " From The Top</a>";

                            HtmlMeta hm = new HtmlMeta();
                            HtmlMeta kw = new HtmlMeta();
                            HtmlMeta lg = new HtmlMeta();
                            HtmlHead head = (HtmlHead)Page.Header;
                            HtmlLink cn = new HtmlLink();

                            cn.Attributes.Add("rel", "canonical");
                            cn.Href = "http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                                "_" + ID.ToString() + "_Event";
                            head.Controls.AddAt(0, cn);

                            hm.Name = "Description";
                            kw.Name = "keywords";
                            lg.Name = "language";
                            lg.Content = "English";
                            head.Controls.AddAt(0, lg);

                            char[] delimeter = { ' ' };
                            string[] keywords = dat.MakeNiceNameFull(ds.Tables[0].Rows[0]["Header"].ToString()).Replace("-", " ").Split(delimeter, StringSplitOptions.RemoveEmptyEntries);
                            int count2 = 0;
                            foreach (string token in keywords)
                            {
                                if (count2 < 16)
                                {
                                    if (kw.Content != "")
                                        kw.Content += " ";
                                    kw.Content += token;

                                    count2++;
                                }
                            }
                            head.Controls.AddAt(0, kw);

                            hm.Content = dat.MakeNiceNameFull(dat.stripHTML(ds.Tables[0].Rows[0]["Content"].ToString()).Replace("   ", " ").Replace("  ", " ")).Replace("-", " ");
                            if (hm.Content.Length > 200)
                                hm.Content = hm.Content.Substring(0, 197) + "...";

                            head.Controls.AddAt(0, hm);

                            this.Title = kw.Content;

                            HtmlLink lk = new HtmlLink();
                            lk.Href = "http://" + Request.Url.Authority + "/" +
                                dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                                "_" + ID.ToString() + "_Event";
                            lk.Attributes.Add("rel", "bookmark");
                            head.Controls.AddAt(0, lk);
                            #endregion

                            DataView dvCats = dat.GetDataDV("SELECT DISTINCT C.ID, ECM.ID AS EID, C.Name AS CategoryName, ECM.tagSize FROM Event_Category_Mapping ECM, EventCategories C WHERE ECM.CategoryID=C.ID AND ECM.EventID=" + eventID + " ORDER BY ECM.ID");

                            string justCats = "";

                            for (int i = 0; i < dvCats.Count; i++)
                            {
                                //kw.Content += ", " + dvCats[i]["CategoryName"].ToString();
                                justCats += dvCats[i]["CategoryName"].ToString() + " ";
                            }

                            //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                            Rotator1.Items.Clear();
                            int mediaCategory = int.Parse(ds.Tables[0].Rows[0]["mediaCategory"].ToString());
                            string youtube = ds.Tables[0].Rows[0]["YouTubeVideo"].ToString();
                            switch (mediaCategory)
                            {
                                case 0:
                                    break;
                                case 1:
                                    char[] delim4 = { ';' };
                                    string[] youtokens = youtube.Split(delim4);
                                    if (youtube != "")
                                    {
                                        for (int i = 0; i < youtokens.Length; i++)
                                        {
                                            if (youtokens[i].Trim() != "")
                                            {
                                                Literal literal3 = new Literal();
                                                //literal3.Text = "<object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ><param name=\"movie\" value=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"250\"></embed></object>";
                                                literal3.Text = "<div class=\"YouTubeWrapper\"><object class=\"toHidde\" width=\"412\" " +
                                                    "height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                                    "\"/><param  name=\"wmode2\" value=\"transparent\" /><param  name=\"wmode\" " +
                                                    "value=\"opaque\" /><param name=\"allowFullScreen\" value=\"true\"/><embed " +
                                                    "src=\"http://www.youtube.com/v/" +
                                                    youtokens[i] + "\" wmode=\"opaque\" wmode2=\"transparent\" type=\"application/x-shockwave" +
                                                    "-flash\" allowfullscreen=\"true\" width=\"412\" height=\"250\"/></object></div>";
                                                Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                                r3.Controls.Add(literal3);
                                                Rotator1.Items.Add(r3);
                                            }
                                        }
                                    }
                                    DataView dsSlider = dat.GetDataDV("SELECT * FROM Event_Slider_Mapping WHERE EventID=" + ID);
                                    if (dsSlider.Count > 0)
                                    {
                                        char[] delim = { '\\' };
                                        char[] delim3 = { '.' };
                                        //string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\Events\\" + ID + "\\Slider");

                                        //string[] finalFileArray = new string[fileArray.Length];

                                        for (int i = 0; i < dsSlider.Count; i++)
                                        {
                                            //int length = fileArray[i].Split(delim).Length;
                                            //finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/Events/" +
                                            //    ID + "/Slider/" + fileArray[i].Split(delim)[length - 1];
                                            if (bool.Parse(dsSlider[i]["ImgPathAbsolute"].ToString()))
                                            {
                                                string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(dsSlider[i]["PictureName"].ToString());
                                                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                                                Stream receiveStream = response.GetResponseStream();
                                                // read the stream
                                                System.Drawing.Image image = System.Drawing.Image.FromStream(receiveStream);
                                                receiveStream.Close();
                                                response.Close();

                                                    int width = 410;
                                                    int height = 250;

                                                    int newHeight = 0;
                                                    int newIntWidth = 0;

                                                    //if image height is less than resize height
                                                    if (height >= image.Height)
                                                    {
                                                        //leave the height as is
                                                        newHeight = image.Height;

                                                        if (width >= image.Width)
                                                        {
                                                            newIntWidth = image.Width;
                                                        }
                                                        else
                                                        {
                                                            newIntWidth = width;

                                                            double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                            double newDoubleHeight = double.Parse(newHeight.ToString());
                                                            newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                            newHeight = (int)newDoubleHeight;
                                                        }
                                                    }
                                                    //if image height is greater than resize height...resize it
                                                    else
                                                    {
                                                        //make height equal to the requested height.
                                                        newHeight = height;

                                                        //get the ratio of the new height/original height and apply that to the width
                                                        double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                        double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                        newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                        newIntWidth = (int)newDoubleWidth;

                                                        //if the resized width is still to big
                                                        if (newIntWidth > width)
                                                        {
                                                            //make it equal to the requested width
                                                            newIntWidth = width;

                                                            //get the ratio of old/new width and apply it to the already resized height
                                                            theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                            double newDoubleHeight = double.Parse(newHeight.ToString());
                                                            newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                            newHeight = (int)newDoubleHeight;
                                                        }
                                                    }

                                                    Literal literal4 = new Literal();
                                                    string[] nameTokens = dsSlider[i]["RealPictureName"].ToString().Split(delim3);
                                                    string realName = dat.MakeNiceName(nameTokens[0]).Replace("_", " ");
                                                    literal4.Text = "<div class=\"RotatorImage\"><img alt=\"" + realName +
                                                        "\" style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                        + dsSlider[i]["PictureName"].ToString() + "\" /></div>";
                                                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                    r4.Controls.Add(literal4);

                                                    Rotator1.Items.Add(r4);
                                            }
                                            else
                                            {
                                                string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                                //dsSlider.RowFilter = "PictureName='" + tokens[0] + "." + tokens[1] + "'";
                                                if (tokens.Length >= 2 && dsSlider.Count > 0)
                                                {
                                                    if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                                    {
                                                        System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") +
                                                            "\\UserFiles\\Events\\" + ID + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                                                        int width = 410;
                                                        int height = 250;

                                                        int newHeight = 0;
                                                        int newIntWidth = 0;

                                                        //if image height is less than resize height
                                                        if (height >= image.Height)
                                                        {
                                                            //leave the height as is
                                                            newHeight = image.Height;

                                                            if (width >= image.Width)
                                                            {
                                                                newIntWidth = image.Width;
                                                            }
                                                            else
                                                            {
                                                                newIntWidth = width;

                                                                double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                                newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                                newHeight = (int)newDoubleHeight;
                                                            }
                                                        }
                                                        //if image height is greater than resize height...resize it
                                                        else
                                                        {
                                                            //make height equal to the requested height.
                                                            newHeight = height;

                                                            //get the ratio of the new height/original height and apply that to the width
                                                            double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                            double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                            newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                            newIntWidth = (int)newDoubleWidth;

                                                            //if the resized width is still to big
                                                            if (newIntWidth > width)
                                                            {
                                                                //make it equal to the requested width
                                                                newIntWidth = width;

                                                                //get the ratio of old/new width and apply it to the already resized height
                                                                theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                                double newDoubleHeight = double.Parse(newHeight.ToString());
                                                                newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                                newHeight = (int)newDoubleHeight;
                                                            }
                                                        }

                                                        Literal literal4 = new Literal();
                                                        string[] nameTokens = dsSlider[i]["RealPictureName"].ToString().Split(delim3);
                                                        string realName = dat.MakeNiceName(nameTokens[0]).Replace("_", " ");
                                                        literal4.Text = "<div class=\"RotatorImage\"><img alt=\"" + realName +
                                                    "\" style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                            + "UserFiles/Events/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString() + "\" /></div>";
                                                        Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                        r4.Controls.Add(literal4);

                                                        Rotator1.Items.Add(r4);
                                                    }
                                                    //else if (tokens[1].ToUpper() == "WMV")
                                                    //{
                                                    //    Literal literal4 = new Literal();
                                                    //    literal4.Text = "<div style=\"width: 410px; height: 250px;\" ><OBJECT stop=\"true\" loop=\"false\" controller=\"true\" wmode2=\"opaque\" wmode=\"transparent\" autoplay=\"false\" classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " +
                                                    //    "width=\"410\" height=\"250\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">" +
                                                    //    "<param name=\"src\" value=\"UserFiles/Events/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\"></param>" +
                                                    //    "<param name=\"autoplay\" value=\"false\"></param><param name=\"wmode\" value=\"transparent\"></param>" +
                                                    //    "<param name=\"controller\" value=\"true\"></param>" +
                                                    //    "<param name=\"stop\" value=\"true\" ></param>" +
                                                    //    "<param name=\"loop\" value=\"false\"><param  name=\"wmode2\" value=\"opaque\" ></param>" +
                                                    //    "<EMBED stop=\"true\" wmode=\"transparent\" wmode2=\"opaque\" src=\"UserFiles/Events/" + ID + "/Slider/" + fileArray[i].Split(delim)[length - 1].ToString() + "\" width=\"410\" height=\"250\" autoplay=\"false\" " +
                                                    //    "controller=\"true\" loop=\"false\" bgcolor=\"#000000\" pluginspage=\"http://www.apple.com/quicktime/download/\">" +
                                                    //    "</EMBED>" +
                                                    //    "</OBJECT></div>";
                                                    //    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                                    //    r4.Controls.Add(literal4);
                                                    //    Rotator1.Items.Add(r4);
                                                    //}
                                                }
                                            }

                                        }
                                    }
                                    break;
                                default: break;
                            }

                            if (Rotator1.Items.Count == 0)
                                RotatorPanel.Visible = false;
                            else
                            {
                                RotatorPanel.Visible = true;
                                if (Rotator1.Items.Count == 1)
                                {
                                    RotatorPanel.CssClass = "HiddeButtons";
                                }
                            }

                            if (fillUserData)
                            {
                                //ASP.controls_addtocalendar_ascx AddTo1 = new ASP.controls_addtocalendar_ascx();
                                //AddTo1.ID = "AddTo1";
                                //AddTo1.EVENT_ID = int.Parse(ID);
                                //AddTo1.DataBind2();

                                #region Do Calendar Link
                                string monthStart = DateTimeStart.Month.ToString();
                                if (monthStart.Length == 1)
                                    monthStart = "0" + monthStart;
                                string dayStart = DateTimeStart.Day.ToString();
                                if (dayStart.Length == 1)
                                    dayStart = "0" + dayStart;

                                string monthEnd = "";
                                string dayEnd = "";
                                string yearEnd = "";
                                if (isEnd)
                                {
                                    monthEnd = DateTimeEnd.Month.ToString();
                                    if (monthEnd.Length == 1)
                                        monthEnd = "0" + monthEnd;
                                    dayEnd = DateTimeEnd.Day.ToString();
                                    if (dayEnd.Length == 1)
                                        dayEnd = "0" + dayEnd;

                                    yearEnd = DateTimeEnd.Year.ToString();
                                }
                                else
                                {
                                    monthEnd = monthStart;
                                    dayEnd = dayStart;
                                    yearEnd = DateTimeStart.Year.ToString();
                                }

                                string shortDesc = dat.stripHTML(ShowDescriptionBegining.Text).Replace(" ", "+");

                                if (shortDesc.Length > 1400)
                                    shortDesc = shortDesc.Substring(0, 1400) + "...";

                                string googleCalendarLink = "https://www.google.com/calendar/render?action=TEMPLATE&" +
                                    "dates=" + DateTimeStart.Year.ToString() + monthStart + dayStart +
                                        "T120000Z/" + yearEnd + monthEnd + dayEnd + "T130000Z" +
                                    "&sprop=" +
                                    "website:http://hippohappenings.com/" + dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) + "_CLHH" + GetEventID() + "_ClEvent" +
                                    "&text=" +
                                    ds.Tables[0].Rows[0]["Header"].ToString().Replace("/", "%2f").Replace(" ", "+") +
                                    "&location=" +
                                    "Location" +
                                    "&sprop=name:" +
                                    ds.Tables[0].Rows[0]["Header"].ToString().Replace("/", "%2f").Replace(" ", "+") +
                                    "&details=" +
                                    "craigslist+ad+http://hippohappenings.com/" + dat.MakeNiceName(ds.Tables[0].Rows[0]["Header"].ToString()) +
                                    "_" + GetEventID() + "_Event+" + shortDesc +
                                    "&gsessionid=OK&sf=true&output=xml";
                                CalendarLiteral.Text = "<a target=\"_blank\" class=\"NavyLink12UD\" href=\"" + googleCalendarLink +
                                    "\" title=\"Add this Meetup to your Google calendar\">" +
                                    "<span class=\"calOpt google\"></span>Add To Google Calendar</a>";
                                //DateAndTimeLabel.Text = googleCalendarLink;\
                                #endregion

                                ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                                SendMessage1.THE_TEXT = "Share on Hippo";
                                SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                                    " would like to share \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\" with you.";
                                SendMessage1.TYPE = "e";
                                SendMessage1.ID = int.Parse(ID);

                                //CalendarSharePanel.Controls.Add(AddTo1);
                                CalendarSharePanel.Controls.Add(SendMessage1);

                                Session["Subject"] = "Re: " + Session["UserName"].ToString() +
                                    " would like to share \"" + dat.BreakUpString(ds.Tables[0].Rows[0]["Header"].ToString(), 14) + "\" with you.";

                            }

                            //        DiggLiteral.Text = "<table>" +
                            //    "<tr>" +
                            //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                            //         "   <a name=\"fb_share\" type=\"button\" href=\"http://www.facebook.com/sharer.php\">Share</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>" +
                            //       " </td>" +
                            //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                            //        "    <a style=\"border: 0; padding: 0; margin: 0;\" id=\"TweeterA\" title=\"Click to send this page to Twitter!\" target=\"_blank\" rel=\"nofollow\"><img style=\"border: 0; padding: 0; margin: 0;\" src=\"http://twitter-badges.s3.amazonaws.com/twitter-a.png\" alt=\"Share on Twitter\"/></a>" +
                            //        "</td>" +
                            //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +
                            //          "  <a href=\"javascript:void(window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())\">" +
                            //          "      <img src=\"http://cms.myspacecdn.com/cms/ShareOnMySpace/small.png\" border=\"0\" alt=\"Share on MySpace\" />" +
                            //          "  </a>" +
                            //        "</td>" +
                            //        "<td valign=\"bottom\" style=\"padding-right: 10px;\"><a alt=\"Digg it!\" class=\"DiggThisButton DiggIcon\" id=\"dibbButt\"" +
                            //        "href='http://digg.com/submit?phase=2&url=" + "http://" +
                            //        Request.Url.Authority + "/" +
                            //        niceName +
                            //        "_" + ds.Tables[0].Rows[0]["ID"].ToString() + "_Event" +
                            //        "' target=\"_blank\">Digg</a></td>" +
                            //        "<td valign=\"bottom\" style=\"padding-right: 10px;\">" +

                            //            "<a href=\"http://delicious.com/save\" onclick=\"window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;\">" +
                            //             "   <img border=\"0\" src=\"http://static.delicious.com/img/delicious.small.gif\" height=\"10\" width=\"10\" alt=\"Delicious\" />" +
                            //            "</a>" +
                            //        "</td>" +
                            //        "<td>" +
                            //          "  <script src=\"http://www.stumbleupon.com/hostedbadge.php?s=4\"></script>" +
                            //        "</td>" +
                            //    "</tr>" +
                            //"</table>";

                        }
                        else
                        {

                            EventName.Text = "This event has been disabled";
                        }

                    }
                    else
                    {
                        //Response.Redirect("~/home");
                    }
                }
                else
                {
                    //Response.Redirect("~/home");
                }
            }
        }
        catch (Exception ex)
        {
            ErrorLabel.Text += ex.ToString() + "<br/><br/>" + message;
            //Response.Redirect("~/home");
        }
    }
    protected void FillLiteral()
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];

        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        EventPanel.Visible = true;
        ShowEventName.Text = VenueNameTextBox.THE_TEXT;

        //if (DescriptionTextBox.Content.Length > 500)
        //{
        ShowDescriptionBegining.Text = dat.BreakUpString(DescriptionTextBox.Content, 60);
        //int j = 500;
        //if (DescriptionTextBox.Content[500] != ' ')
        //{

        //    while (DescriptionTextBox.Content[j] != ' ')
        //    {
        //        ShowDescriptionBegining.Text += DescriptionTextBox.Content[j];
        //        j++;

        //        if (j >= DescriptionTextBox.Content.Length)
        //            break;
        //    }
        //}
        //ShowDescriptionBegining.Text = dat.BreakUpString(ShowDescriptionBegining.Text, 65);
        //ShowRestOfDescription.Text = dat.BreakUpString(DescriptionTextBox.Content.Substring(j), 65);
        //}
        //else
        //{
        //    ShowDescriptionBegining.Text = dat.BreakUpString(DescriptionTextBox.Content, 65);
        //    ShowRestOfDescription.Text = "";
        //}

        if (MainAttractionCheck.Checked)
        {
            ShowVideoPictureLiteral.Text = "";
            if (PictureCheckList.Items.Count > 0)
            {
                Rotator1.Items.Clear();
                char[] delim = { '\\' };

                string[] finalFileArray = new string[PictureCheckList.Items.Count];

                //for (int i = 0; i < PictureCheckList.Items.Count; i++)
                //{
                //    finalFileArray[i] = "http://" + Request.Url.Authority + "/HippoHappenings/UserFiles/" +
                //        Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value;
                //}
                char[] delim2 = { '.' };
                bool isEdit = false;

                if (Request.QueryString["ID"] != null)
                    isEdit = true;
                for (int i = 0; i < PictureCheckList.Items.Count; i++)
                {
                    Literal literal4 = new Literal();
                    string toUse = "";
                    string[] tokens = PictureCheckList.Items[i].Value.ToString().Split(delim2);
                    //if (PictureCheckList.Items[i].Enabled)
                    //{
                    RotatorPanel.Visible = true;
                    if (tokens.Length >= 2)
                    {
                        if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                        {
                            System.Drawing.Image image;
                            if (isEdit)
                            {
                                if (System.IO.File.Exists(MapPath(".") + "\\VenueFiles\\" + Request.QueryString["ID"].ToString() + "\\Slider\\" + PictureCheckList.Items[i].Value.ToString()))
                                {
                                    image = System.Drawing.Image.FromFile(MapPath(".") + "\\VenueFiles\\" + Request.QueryString["ID"].ToString() + "\\Slider\\" + PictureCheckList.Items[i].Value.ToString());
                                    toUse = "/VenueFiles/" + Request.QueryString["ID"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value.ToString();
                                }
                                else
                                {
                                    image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\Slider\\" + PictureCheckList.Items[i].Value.ToString());
                                    toUse = "/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value.ToString();
                                }
                            }
                            else
                            {
                                image = System.Drawing.Image.FromFile(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\Slider\\" + PictureCheckList.Items[i].Value.ToString());
                                toUse = "/UserFiles/" + Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value.ToString();
                            }

                            int width = 410;
                            int height = 250;

                            int newHeight = image.Height;
                            int newIntWidth = image.Width;

                            ////if image height is less than resize height
                            //if (height >= image.Height)
                            //{
                            //    //leave the height as is
                            //    newHeight = image.Height;

                            //    if (width >= image.Width)
                            //    {
                            //        newIntWidth = image.Width;
                            //    }
                            //    else
                            //    {
                            //        newIntWidth = width;

                            //        double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                            //        double newDoubleHeight = double.Parse(newHeight.ToString());
                            //        newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                            //        newHeight = (int)newDoubleHeight;
                            //    }
                            //}
                            ////if image height is greater than resize height...resize it
                            //else
                            //{
                            //    //make height equal to the requested height.
                            //    newHeight = height;

                            //    //get the ratio of the new height/original height and apply that to the width
                            //    double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                            //    double newDoubleWidth = double.Parse(newIntWidth.ToString());
                            //    newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                            //    newIntWidth = (int)newDoubleWidth;

                            //    //if the resized width is still to big
                            //    if (newIntWidth > width)
                            //    {
                            //        //make it equal to the requested width
                            //        newIntWidth = width;

                            //        //get the ratio of old/new width and apply it to the already resized height
                            //        theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                            //        double newDoubleHeight = double.Parse(newHeight.ToString());
                            //        newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                            //        newHeight = (int)newDoubleHeight;
                            //    }
                            //}

                            literal4.Text = "<div style=\"width: 410px; height: 250px;background-color: black;\"><img style=\"cursor: pointer; margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                + toUse +
                                "\" /></div>";
                        }
                        else if (tokens[1].ToUpper() == "WMV")
                        {
                            literal4.Text = "<embed  height=\"250px\" width=\"410px\" src=\""
                                + "UserFiles/" + Session["UserName"].ToString() + "/Slider/" + PictureCheckList.Items[i].Value.ToString() +
                                "\" />";
                        }
                    }
                    else
                    {
                        literal4.Text = "<div style=\"float:left;\"><object width=\"410\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ></param><param name=\"movie\" value=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/v/" + PictureCheckList.Items[i].Value.ToString() + "\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"410\" height=\"250\"></embed></object></div>";
                    }

                    Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                    r4.Controls.Add(literal4);
                    Rotator1.Items.Add(r4);
                    //}
                }
                if (Rotator1.Items.Count == 0)
                    RotatorPanel.Visible = false;
                else
                    RotatorPanel.Visible = true;

                if (Rotator1.Items.Count == 1)
                    RotatorPanel.CssClass = "HiddeButtons";
                else
                    RotatorPanel.CssClass = "";

            }

        }
    }
Esempio n. 30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string eventID = Request.QueryString["ID"].ToString();
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        try
        {
            Session["RedirectTo"] = Request.Url.AbsoluteUri;

            bool fillUserData = false;

            try
            {
                if (Session["User"] != null)
                {
                    LoggedInPanel.Visible = true;
                    LoggedOutPanel.Visible = false;

                    fillUserData = true;

                }
                else
                {
                    LoggedOutPanel.Visible = true;
                    LoggedInPanel.Visible = false;
                }

                GetOtherEvents();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }

            if (Request.QueryString["ID"] == null)
                Response.Redirect("~/home");

            string ID = eventID;
            Session["TripID"] = ID;
            DataView dv = dat.GetDataDV("SELECT * FROM Trips WHERE ID=" + ID);

            Session["FlagID"] = ID;
            Session["FlagType"] = "T";

            #region SEO
            //Create keyword and description meta tags and title
            topTopLiteral.Text = "<a class=\"NavyLink12UD\" href=\"#" + dat.MakeNiceNameFull(dv[0]["Header"].ToString()) + "\">" +
            dat.MakeNiceNameFull(dv[0]["Header"].ToString()).Replace("-", " ") + " From The Top</a>";

            HtmlMeta hm = new HtmlMeta();
            HtmlMeta kw = new HtmlMeta();
            HtmlMeta lg = new HtmlMeta();
            HtmlLink cn = new HtmlLink();
            HtmlHead head = (HtmlHead)Page.Header;

            cn.Attributes.Add("rel", "canonical");
            cn.Href = "http://" + Request.Url.Authority + "/" +
                dat.MakeNiceName(dv[0]["Header"].ToString()) +
                "_" + eventID + "_Trip";
            head.Controls.AddAt(0, cn);

            kw.Name = "keywords";
            hm.Name = "Description";
            lg.Name = "language";
            lg.Content = "English";
            head.Controls.AddAt(0, lg);

            char[] delimeter = { ' ' };
            string[] keywords = dat.MakeNiceNameFull(dv[0]["Header"].ToString()).Replace("-", " ").Split(delimeter, StringSplitOptions.RemoveEmptyEntries);
            int count2 = 0;
            foreach (string token in keywords)
            {
                if (count2 < 16)
                {
                    if (kw.Content != "")
                        kw.Content += " ";
                    kw.Content += token;

                    count2++;
                }
            }
            head.Controls.AddAt(0, kw);

            hm.Content = dat.MakeNiceNameFull(dat.stripHTML(dv[0]["Content"].ToString()).Replace("   ", " ").Replace("  ", " ")).Replace("-", " ");
            if (hm.Content.Length > 200)
                hm.Content = hm.Content.Substring(0, 197) + "...";

            head.Controls.AddAt(0, hm);

            this.Title = kw.Content;

            HtmlLink lk = new HtmlLink();
            lk.Href = "http://" + Request.Url.Authority + "/" +
                dat.MakeNiceName(dat.BreakUpString(dv[0]["Header"].ToString(), 14)) +
                "_" + ID.ToString() + "_Trip";
            lk.Attributes.Add("rel", "bookmark");
            head.Controls.AddAt(0, lk);
            #endregion

            fbLiteral.Text = "<fb:like href=\"" + Request.Url.AbsoluteUri + "\" send=\"true\" layout=\"button_count\" width=\"100\" show_faces=\"true\" font=\"\"></fb:like>";

            Literal lit = new Literal();
            lit.Text = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAjjoxQtYNtdn3Tc17U5-jbBR2Kk_H7gXZZZniNQ8L14X1BLzkNhQjgZq1k-Pxm8FxVhUy3rfc6L9O4g\" type=\"text/javascript\"></script>";
            head.Controls.Add(lit);

            if (bool.Parse(dv[0]["Live"].ToString()))
            {
                if (Session["User"] != null)
                {
                    if (dv[0]["UserName"].ToString() == Session["UserName"].ToString())
                        EditLink.Visible = true;
                    else
                        EditLink.Visible = false;
                }
                else
                {
                    EditLink.Visible = false;
                }

                ASP.controls_contactad_ascx contact = new ASP.controls_contactad_ascx();
                contact.THE_TEXT = "Contact Adventure Poster";
                contact.RE_LABEL = "Re: " + dat.BreakUpString(dv[0]["Header"].ToString(), 14);
                contact.TYPE = "ConnectTrip";
                contact.ID = int.Parse(eventID);

                ContactPanel.Controls.Add(contact);

                PricePanel.Visible = false;
                if (dv[0]["MaxPrice"] != null)
                {
                    if (dv[0]["MaxPrice"].ToString() != "")
                    {
                        MinPrice.Text = dv[0]["MinPrice"].ToString().Replace(".00", "");
                        MaxPrice.Text = dv[0]["MaxPrice"].ToString().Replace(".00", "");
                        PricePanel.Visible = true;
                    }
                }

                DurationLabel.Text = "<b>Duration:</b> " + dat.GetDuration(dv[0]["Duration"].ToString());

                char[] del = { ';' };

                DataView daysToGo = dat.GetDataDV("SELECT * FROM TripDays WHERE TripID=" + eventID);

                foreach (DataRowView row in daysToGo)
                {
                    DaysLabel.Text += dat.GetHours(row["Days"].ToString()) + " " +
                        row["StartTime"].ToString() + " - " + row["EndTime"].ToString() + "<br/>";
                }

                DataView monthsToGo = dat.GetDataDV("SELECT * FROM TripMonths WHERE TripID=" + eventID);

                foreach (DataRowView row in monthsToGo)
                {
                    MonthsLabel.Text += dat.GetMonths(row["MonthStart"].ToString()) + ", " +
                        row["DayStart"].ToString() + " - " + dat.GetMonths(row["MonthEnd"].ToString()) +
                        ", " + row["DayEnd"].ToString() + "<br/>";
                }

                ObtainLabel.Text = dv[0]["WhatObtain"].ToString();

                DressLabel.Text = dv[0]["HowDress"].ToString();

                foreach (ListItem item in MeansCheckList.Items)
                {
                    if (dv[0]["Means"].ToString().Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in MeansCheckList2.Items)
                {
                    if (dv[0]["Means"].ToString().Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                foreach (ListItem item in MeansCheckList3.Items)
                {
                    if (dv[0]["Means"].ToString().Contains(item.Value))
                    {
                        item.Selected = true;
                    }
                }

                DataView dvBring = dat.GetDataDV("SELECT * FROM Trips_WhatToBring WHERE TripID=" + eventID);

                int count = 1;
                foreach (DataRowView row in dvBring)
                {
                    BringLabel.Text += count.ToString() + ". " + row["WhatToBring"].ToString() + "<br/>";
                    count++;
                }

                dvBring = dat.GetDataDV("SELECT * FROM TripDirections WHERE TripID=" + eventID);

                count = 1;
                string dirFunc = "function PlotMapDirections(){var address; var address2; \r\n";
                string prevAddrs = "";
                string thisAddress = "";
                int mapCount = 0;
                string walking = "";
                if (dvBring.Count == 1)
                {
                    Directions.Text += count.ToString() + ". " + dvBring[0]["Directions"].ToString();
                    MapLiteral.Text = "<div id=\"map_canvas\" class=\"TripMapCanvas\"></div>";
                    thisAddress = dat.GetAddress(dvBring[0]["Address"].ToString(),
                        dvBring[0]["Country"].ToString() != "223") + " " + dvBring[0]["City"].ToString() + " " + dvBring[0]["State"].ToString() +
                        " " + dvBring[0]["Zip"].ToString() + " " + dvBring[0]["Country"].ToString();

                    dirFunc += "map = new GMap2(document.getElementById(\"map_canvas\")); map.setUIToDefault(); " +
                                "address = '" +
                                thisAddress.Replace("'", "''") + "'; createMarker(address, '" + dv[0]["Header"].ToString().Replace("'", "''") +
                                "','<div class=\"MapHeader\"><h2>" + dv[0]["Header"].ToString().Replace("'", "''") + ":</h2> <br/>" + dvBring[0]["Directions"].ToString().Replace("'", "''") + "</div>');}";
                }
                else
                {
                    string firstAddress = "";
                    foreach (DataRowView row in dvBring)
                    {
                        Directions.Text += count.ToString() + ". " + row["Directions"].ToString() + "<br/>";
                        count++;
                        thisAddress = dat.GetAddress(row["Address"].ToString(),
                                row["Country"].ToString() != "223") + " " + row["City"].ToString() + " " + row["State"].ToString() +
                                " " + row["Zip"].ToString() + " " + row["Country"].ToString();
                        if (prevAddrs != "")
                        {
                            if ((bool)row["Walking"])
                                walking = "{travelMode:G_TRAVEL_MODE_WALKING}";
                            else
                                walking = "{travelMode:G_TRAVEL_MODE_DRIVING}";
                            dirFunc += "map = new GMap2(document.getElementById(\"map_canvas" +
                                mapCount.ToString() + "\")); \r\n map.setUIToDefault();\r\n directionsPanel = document.getElementById(\"my_textual_div" +
                                mapCount.ToString() + "\"); \r\n directions = " +
                                "new GDirections(map, directionsPanel);directions.load(\"from: " + prevAddrs.Replace("'", "''") +
                                " to: " + thisAddress.Replace("'", "''") + "\", " + walking + ");\r\n ";
                            GoogleDirectionsLiteral.Text += "<div id=\"my_textual_div" + mapCount.ToString() + "\"></div>";
                            MapLiteral.Text += "<div class=\"MapLiteral2\" id=\"map_canvas" + mapCount.ToString() + "\"></div>";
                            mapCount++;
                        }
                        else
                        {
                            firstAddress = thisAddress;
                        }
                        prevAddrs = thisAddress;
                    }
                    MapLiteral.Text += "<h1 class=\"SideColumn\">Map: <a onclick=\"createMarker('" + firstAddress.Replace("'", "''") + "', 'Beginning', '<h2>Beginning:</h2> <br/>" +
                        dvBring[0]["Directions"].ToString().Replace("'", "''") + "');\" class=\"NavyLinkUD\">Beginning</a> " +
                        "and <a class=\"NavyLinkUD\" onclick=\"createMarker('" + prevAddrs.Replace("'", "''") + "', 'Destination', '<h2>Destination:</h2> <br/>" +
                        dvBring[dvBring.Count - 1]["Directions"].ToString() + "');\">Destination</a></h1><div class=\"topDiv MapLiteral3\" id=\"map_canvas\" " +
                        "></div>";
                    dirFunc += "\r\n map = new GMap(document.getElementById(\"map_canvas\"));" +
                        "map.addControl(new GSmallMapControl());map.setCenter(new GLatLng(0,0), 0);\r\n " +
                        "createMarker('" + firstAddress.Replace("'", "''") + "', \"Beginning\", '<div class=\"MapHeader\"><h2>Beginning:</h2> <br/>" +
                        dvBring[0]["Directions"].ToString().Replace("'", "''") + "</div>');\r\n";
                    dirFunc += "}\r\n";
                }

                DirectionsLiteral.Text = "<script type=\"text/javascript\">" + dirFunc + "</script>";

                Master.BodyTag.Attributes.Add("onload", "initialize();");
                Master.BodyTag.Attributes.Add("onunload", "GUnload()");

                EventName.Text = "<a id=\"" + dat.MakeNiceNameFull(dv[0]["Header"].ToString()) + "\" class=\"aboutLink\" href=\"http://" + Request.Url.Authority +
                    "/" +
                    dat.MakeNiceName(dv[0]["Header"].ToString()) +
                    "_" + ID.ToString() + "_Trip\"><h1>" +
                    dat.BreakUpString(dv[0]["Header"].ToString(), 50) + "</h1></a>";
                Session["Subject"] = "Re: " + dv[0]["Header"].ToString();
                Session["CommentSubject"] = "Re: " + dv[0]["Header"].ToString();
                string UserName = dv[0]["UserName"].ToString();

                TagCloud.THE_ID = int.Parse(ID);

                string content = dv[0]["Content"].ToString();
                string niceName = dat.MakeNiceName(dv[0]["Header"].ToString());

                //ScriptLiteral.Text = "<script type=\"text/javascript\">ReturnURL('" + niceName.Replace("_", " ") + " http://HippoHappenings.com/" + Request.QueryString["ID"].ToString() + "_Trip');</script>";

                if (Session["User"] != null)
                {
                    DataSet dsComments;
                    string commentPrefs = dat.GetData("SELECT * FROM UserPreferences WHERE UserID=" + Session["User"].ToString()).Tables[0].Rows[0]["CommentsPreferences"].ToString();
                    if (commentPrefs == "1")
                    {
                        dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM TripComments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                    }
                    else
                    {
                        dsComments = dat.GetData("SELECT DISTINCT U.ProfilePicture, U.User_ID, U.UserName, C.Comment, C.BlogDate AS theDate FROM TripComments C, Users U, User_Friends UF WHERE ((UF.UserID=" + Session["User"].ToString() + " AND UF.FriendID=U.User_ID AND U.User_ID=C.UserID) OR (U.User_ID=" +
                            Session["User"].ToString() + " AND U.User_ID=C.UserID)) AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                    }
                    TheComments.DATA_SET = dsComments;
                    TheComments.DataBind2(true);
                }
                else
                {
                    DataSet dsComments = dat.GetData("SELECT C.BlogDate AS theDate, * FROM TripComments C, Users U WHERE U.User_ID=C.UserID AND C.BlogID=" + ID + " ORDER BY C.BlogDate");
                    TheComments.DATA_SET = dsComments;
                    TheComments.DataBind2(true);
                }

                ShowDescriptionBegining.Text = dat.BreakUpString(content, 20);

                Session["messageText"] = dat.BreakUpString(dv[0]["Header"].ToString(), 14);
                Session["messageEmail"] = "Adventure Name: <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(dat.BreakUpString(dv[0]["Header"].ToString(), 14)) + "_" + ID + "_Trip\">" +
                    dat.BreakUpString(dv[0]["Header"].ToString(), 14) + "</a> <br/><br/> "+ ShowDescriptionBegining.Text;

                //Media Categories: NONE: 0, Picture: 1, Video: 2, YouTubeVideo: 3, Slider: 4
                Rotator1.Items.Clear();
                int mediaCategory = int.Parse(dv[0]["mediaCategory"].ToString());
                string youtube = dv[0]["YouTubeVideo"].ToString();
                switch (mediaCategory)
                {
                    case 0:
                        break;
                    case 1:
                        char[] delim4 = { ';' };
                        string[] youtokens = youtube.Split(delim4);
                        if (youtube != "")
                        {
                            for (int i = 0; i < youtokens.Length; i++)
                            {
                                if (youtokens[i].Trim() != "")
                                {
                                    Literal literal3 = new Literal();
                                    //literal3.Text = "<object width=\"400\" height=\"250\"><param  name=\"wmode\" value=\"opaque\" ><param name=\"movie\" value=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\"></param><embed wmode=\"opaque\" src=\"http://www.youtube.com/cp/vjVQa1PpcFOFUjhw1qTHaE09Z1e9QYKk9y1JrWf5VAc=\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"250\"></embed></object>";
                                    literal3.Text = "<div class=\"YouTubeWrapper\"><object class=\"toHidde\" width=\"412\" " +
                                        "height=\"250\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + youtokens[i] +
                                        "\"/><param  name=\"wmode2\" value=\"transparent\" /><param  name=\"wmode\" " +
                                        "value=\"opaque\" /><param name=\"allowFullScreen\" value=\"true\"/><embed " +
                                        "src=\"http://www.youtube.com/v/" +
                                        youtokens[i] + "\" wmode=\"opaque\" wmode2=\"transparent\" type=\"application/x-shockwave" +
                                        "-flash\" allowfullscreen=\"true\" width=\"412\" height=\"250\"/></object></div>";
                                    Telerik.Web.UI.RadRotatorItem r3 = new Telerik.Web.UI.RadRotatorItem();
                                    r3.Controls.Add(literal3);
                                    Rotator1.Items.Add(r3);
                                }
                            }
                        }
                        DataView dsSlider = dat.GetDataDV("SELECT * FROM Trip_Slider_Mapping WHERE TripID=" + ID);
                        if (dsSlider.Count > 0)
                        {
                            try
                            {
                                char[] delim = { '\\' };
                                char[] delim3 = { '.' };
                                string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\Trips\\" + ID + "\\Slider");

                                string[] finalFileArray = new string[fileArray.Length];

                                for (int i = 0; i < dsSlider.Count; i++)
                                {

                                    string[] tokens = dsSlider[i]["PictureName"].ToString().Split(delim3);

                                    //dsSlider.RowFilter = "PictureName='" + tokens[0] + "." + tokens[1] + "'";
                                    if (tokens.Length >= 2 && dsSlider.Count > 0)
                                    {
                                        if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF" || tokens[1].ToUpper() == "PNG")
                                        {
                                            System.Drawing.Image image = System.Drawing.Image.FromFile(MapPath(".") + "\\Trips\\" +
                                                ID + "\\Slider\\" + dsSlider[i]["PictureName"].ToString());

                                            int width = 410;
                                            int height = 250;

                                            int newHeight = 0;
                                            int newIntWidth = 0;

                                            //if image height is less than resize height
                                            if (height >= image.Height)
                                            {
                                                //leave the height as is
                                                newHeight = image.Height;

                                                if (width >= image.Width)
                                                {
                                                    newIntWidth = image.Width;
                                                }
                                                else
                                                {
                                                    newIntWidth = width;

                                                    double theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                                    newDoubleHeight = double.Parse(height.ToString()) / theDivider;
                                                    newHeight = (int)newDoubleHeight;
                                                }
                                            }
                                            //if image height is greater than resize height...resize it
                                            else
                                            {
                                                //make height equal to the requested height.
                                                newHeight = height;

                                                //get the ratio of the new height/original height and apply that to the width
                                                double theDivider = double.Parse(image.Height.ToString()) / double.Parse(newHeight.ToString());
                                                double newDoubleWidth = double.Parse(newIntWidth.ToString());
                                                newDoubleWidth = double.Parse(image.Width.ToString()) / theDivider;
                                                newIntWidth = (int)newDoubleWidth;

                                                //if the resized width is still to big
                                                if (newIntWidth > width)
                                                {
                                                    //make it equal to the requested width
                                                    newIntWidth = width;

                                                    //get the ratio of old/new width and apply it to the already resized height
                                                    theDivider = double.Parse(image.Width.ToString()) / double.Parse(newIntWidth.ToString());
                                                    double newDoubleHeight = double.Parse(newHeight.ToString());
                                                    newDoubleHeight = double.Parse(image.Height.ToString()) / theDivider;
                                                    newHeight = (int)newDoubleHeight;
                                                }
                                            }

                                            Literal literal4 = new Literal();
                                            string[] nameTokens = dsSlider[i]["RealPictureName"].ToString().Split(delim3);
                                            string realName = dat.MakeNiceName(nameTokens[0]).Replace("_", " ");
                                            literal4.Text = "<div class=\"RotatorImage\"><img  alt=\"" + realName +
                                                "\" style=\" margin-left: " + ((410 - newIntWidth) / 2).ToString() + "px; margin-top: " + ((250 - newHeight) / 2).ToString() + "px;\" height=\"" + newHeight + "px\" width=\"" + newIntWidth + "px\" src=\""
                                                + "Trips/" + ID + "/Slider/" + dsSlider[i]["PictureName"].ToString() + "\" /></div>";
                                            Telerik.Web.UI.RadRotatorItem r4 = new Telerik.Web.UI.RadRotatorItem();
                                            r4.Controls.Add(literal4);

                                            Rotator1.Items.Add(r4);
                                        }
                                    }

                                }
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                        break;
                    default: break;
                }

                if (Rotator1.Items.Count == 0)
                    RotatorPanel.Visible = false;
                else
                {
                    RotatorPanel.Visible = true;
                    if (Rotator1.Items.Count == 1)
                    {
                        RotatorPanel.CssClass = "HiddeButtons";
                    }
                }

                if (fillUserData)
                {
                    ASP.controls_sendmessage_ascx SendMessage1 = new ASP.controls_sendmessage_ascx();
                    SendMessage1.THE_TEXT = "Share on Hippo";
                    SendMessage1.RE_LABEL = "Re: " + Session["UserName"].ToString() +
                        " would like to share \"" + dat.BreakUpString(dv[0]["Header"].ToString(), 14) + "\" with you.";
                    SendMessage1.TYPE = "t";
                    SendMessage1.ID = int.Parse(ID);

                    CalendarSharePanel.Controls.Add(SendMessage1);

                    Session["Subject"] = "Re: " + Session["UserName"].ToString() +
                        " would like to share \"" + dat.BreakUpString(dv[0]["Header"].ToString(), 14) + "\" with you.";
                }
            }
            else
            {

                EventName.Text = "This adventure has been disabled";
            }

        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
            //Response.Redirect("~/home");
        }
    }