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();
        }
    }
示例#2
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();
        }
    }
    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;
        }
    }