protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (MessageTextBox.Text != "")
        {
            try
            {
                Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

                //get user
                string user = "";

                switch (Request.QueryString["Type"].ToString())
                {
                    case "E":
                        user = dat.GetData("SELECT * FROM Events E, Users U WHERE U.UserName=E.UserName " +
                     "AND E.ID=" + Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["User_ID"].ToString();
                        break;
                    case "V":
                        string temp = "CreatedByUser";
                        if (bool.Parse(Request.QueryString["Edit"].ToString()))
                        {
                            temp = "EditedByUser";
                        }
                        user = dat.GetData("SELECT "+temp+" FROM Venues V WHERE " +
                            " ID=" + Request.QueryString["ID"].ToString()).Tables[0].Rows[0][temp].ToString();
                        break;
                    case "A":
                        user = dat.GetData("SELECT * FROM Ads WHERE Ad_ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["User_ID"].ToString();
                        break;
                    case "G":
                        user = dat.GetData("SELECT * FROM Groups WHERE ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["Host"].ToString();
                        break;
                    case "GE":
                        user = dat.GetData("SELECT * FROM GroupEvents WHERE ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["UserID"].ToString();
                        break;
                    default: break;
                }

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    "user: "******", postDetails: " + Request.QueryString["Type"].ToString() + "; ID=" +
                    Request.QueryString["ID"].ToString() + ", rating value: " +
                    RatingRadioList.SelectedValue + ", message: " + MessageTextBox.Text, "Hippo Experience Rating");

                string command = "INSERT INTO SiteExperienceRatings (UserID, PostDetails, ExperienceRating, ExperienceDetails) VALUES(@p0, @p1, @p2, @p3)";
                SqlDbType[] types = { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                object[] data = { int.Parse(user),
                    "Type="+Request.QueryString["Type"].ToString()+"; ID="+Request.QueryString["ID"].ToString(), RatingRadioList.SelectedValue, MessageTextBox.Text };
                dat.ExecuteWithParemeters(command, types, data);
                //dat.SendEmail("Hippo happenings email address", "Hippo Happening", YourEmailTextBox.Text, EmailTextBox.Text + "<br/>"+Session["message"].ToString(), EmailSubjectLabel.Text);
                Encryption encrypt = new Encryption();
                MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("Thank you for your feedback!<br/><br/><br/><img onclick=\"Search('Home.aspx');\" onmouseover=\"this.src='image/DoneSonButtonSelected.png'\" onmouseout=\"this.src='image/DoneSonButton.png'\" src=\"image/DoneSonButton.png\"/>");
                MessageRadWindow.Visible = true;
                MessageRadWindowManager.VisibleOnPageLoad = true;
            }
            catch (Exception ex)
            {
                MessageRequired.Text = ex.ToString();
            }
        }
        else
        {
            if (MessageTextBox.Text == "")
                MessageRequired.Text = "*Please include a message";
        }
    }
    protected void SendItNotLoggedIn(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        string message = ConfirmEmail();
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        TextBox1.Text = dat.stripHTML(TextBox1.Text);
        TextBox2.Text = dat.stripHTML(TextBox2.Text);
        if (message == "Success")
        {
            if (TextBox1.Text != "" && TextBox2.Text != "")
            {
                try
                {

                    string command = "INSERT INTO MessagesForAdmin (Message, Subject, Type, Email) VALUES(@p0, @p1, @p2, @p3)";
                    SqlDbType[] types = { SqlDbType.NChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                    object[] data = { TextBox2.Text, TextBox1.Text, 1, EmailTextBox.Text.Trim().ToLower() };
                    dat.ExecuteWithParemeters(command, types, data);

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString()
                        , "Email: " + EmailTextBox.Text + ", has filled out a 'Contact Us' form. Here is their message: <br/><br/>" +
                        TextBox2.Text, "Contact Us Form Submitted: " + TextBox1.Text);

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                        EmailTextBox.Text.Trim().ToLower()
                        , "<br/><br/>Your contact request has been submitted to Hippo Happenings. We will reply to your " +
                        "request momentarily.", "Hippo Happenings Contact Request Submitted");

                    Encryption encrypt = new Encryption();
                    MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("<br/>Your message has been sent. We will get back to you as soon as possible.<br/><br/><button onclick=\"Search('Home.aspx');\" name=\"Ok\" title=\"Ok\">Ok</button>");
                    MessageRadWindow.Visible = true;
                    MessageRadWindowManager.VisibleOnPageLoad = true;

                }
                catch (Exception ex)
                {
                    Label2.Text = ex.ToString();
                }
            }
            else
            {
                if (TextBox1.Text.Trim() == "")
                    Label1.Text = "*Please include the subject";
                if (TextBox2.Text.Trim() == "")
                    Label2.Text = "*Please include a message";
            }
        }
        else
        {
            Label2.Text = message;
        }
    }
    protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        SubjectTextBox.Text = dat.stripHTML(SubjectTextBox.Text);
        MessageTextBox.Text = dat.stripHTML(MessageTextBox.Text);
        if (SubjectTextBox.Text != "" && MessageTextBox.Text != "")
        {
            try
            {

                string command = "INSERT INTO MessagesForAdmin (UserID, Message, Subject, Type) VALUES(@p0, @p1, @p2, @p3)";
                SqlDbType[] types = { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int };
                object[] data = { int.Parse(Session["User"].ToString()), MessageTextBox.Text, SubjectTextBox.Text, 1 };
                dat.ExecuteWithParemeters(command, types, data);

                DataSet dsUser = dat.GetData("SELECT * FROM Users WHERE User_ID="+Session["User"].ToString());

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString()
                    , "User ID: " + Session["User"].ToString() + ", UserName: "******"UserName"].ToString() +
                    " has filled out a 'Contact Us' form. Here is their message: <br/><br/>" +
                    MessageTextBox.Text, "Contact Us Form Submitted: "+SubjectTextBox.Text);

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    dsUser.Tables[0].Rows[0]["Email"].ToString()
                    , "<br/><br/>Your contact request has been submitted to Hippo Happenings. We will reply to your "+
                    "request momentarily.", "Hippo Happenings Contact Request Submitted");

                Encryption encrypt = new Encryption();
                MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("<br/>Your message has been sent. We will get back to you as soon as possible.<br/><br/><button onclick=\"Search('Home.aspx');\" name=\"Ok\" title=\"Ok\">Ok</button>");
                MessageRadWindow.Visible = true;
                MessageRadWindowManager.VisibleOnPageLoad = true;

            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            if (SubjectTextBox.Text == "")
                SubjectRequired.Text = "*Please include the subject";
            if (MessageTextBox.Text == "")
                MessageRequired.Text = "*Please include a message";
        }
    }
    protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (SubjectTextBox.Text != "" && MessageTextBox.Text != "")
        {
            try
            {
                Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
                SubjectTextBox.Text = dat.stripHTML(SubjectTextBox.Text);
                MessageTextBox.Text = dat.stripHTML(MessageTextBox.Text);

                string command = "INSERT INTO MessagesForAdmin (UserID, Message, Subject, Type) VALUES(@p0, @p1, @p2, @p3)";
                SqlDbType[] types = { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int };
                object[] data = { int.Parse(Session["User"].ToString()), MessageTextBox.Text, SubjectTextBox.Text, 3};
                dat.ExecuteWithParemeters(command, types, data);

                DataSet dsUser = dat.GetData("SELECT * FROM Users WHERE User_ID=" + Session["User"].ToString());

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    "Feedback from site. User logged in. UserID: " + Session["User"].ToString() +
                    "<br/><br/>User's Subject: " + SubjectTextBox.Text + "<br/><br/>User's Message: " + MessageTextBox.Text,
                    "Feedback from HippoHappenings[Logged in]: " + SubjectTextBox.Text);
                Encryption encrypt = new Encryption();
                MessageRadWindow.NavigateUrl = "Message.aspx?message=" +
                    encrypt.encrypt("<div style=\"height: 200px; vertical-align: middle;\">Your message has been sent<br/><br/><br/><br/><button onclick=\"Search('Home.aspx');\" name=\"Ok\" title=\"Ok\">Ok</button></div>");
                MessageRadWindow.Visible = true;
                MessageRadWindowManager.VisibleOnPageLoad = true;
            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            if (SubjectTextBox.Text == "")
                SubjectRequired.Text = "*Please include the subject";
            if (MessageTextBox.Text == "")
                MessageRequired.Text = "*Please include a message";
        }
    }
 protected void SendItNotLoggedIn(object sender, EventArgs e)
 {
     HttpCookie cookie = Request.Cookies["BrowserDate"];
     string message = ConfirmEmail();
     if (message == "Success")
     {
         if (TextBox1.Text != "" && TextBox2.Text != "")
         {
             try
             {
                 Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
                 TextBox1.Text = dat.stripHTML(TextBox1.Text);
                 TextBox2.Text = dat.stripHTML(TextBox2.Text);
                 string command = "INSERT INTO MessagesForAdmin (Message, Subject, Type, Email) VALUES(@p0, @p1, @p2, @p3)";
                 SqlDbType[] types = { SqlDbType.NChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                 object[] data = { TextBox2.Text, TextBox1.Text, 3, EmailTextBox.Text.Trim().ToLower() };
                 dat.ExecuteWithParemeters(command, types, data);
                 dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                 System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                                 System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                 "Feedback from site. User not logged in. Email: " + EmailTextBox.Text.Trim().ToLower() +
                                 "<br/><br/>User's Subject: " + TextBox1.Text + "<br/><br/>User's Message: " + TextBox2.Text,
                                 "Feedback from HippoHappenings[Not logged in]: " + TextBox1.Text);
                 Encryption encrypt = new Encryption();
                 MessageRadWindow.NavigateUrl = "Message.aspx?message=" +
                     encrypt.encrypt("<div style=\"height: 200px; vertical-align: middle;\"><br/>Your message has been sent. <br/><br/>Thank you for your feedback!<br/><br/><br/><button onclick=\"Search('Home.aspx');\" name=\"Ok\" title=\"Ok\">Ok</button></div>");
                 MessageRadWindow.Visible = true;
                 MessageRadWindowManager.VisibleOnPageLoad = true;
             }
             catch (Exception ex)
             {
                 Label2.Text = ex.ToString();
             }
         }
         else
         {
             if (TextBox1.Text.Trim() == "")
                 Label1.Text = "*Please include the subject";
             if (TextBox2.Text.Trim() == "")
                 Label2.Text = "*Please include a message";
         }
     }
     else
     {
         Label2.Text = message;
     }
 }
    protected void SendFlagEmail(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        try
        {
            if (TextBox2.Text.Trim() != "")
            {
                string EType = Session["FlagType"].ToString();
                string id = Session["FlagID"].ToString();
                string body = "<br/> Regarding EType: " + EType + ", ID: " + id;
                Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
                if (FlagTextPanel.Visible)
                {
                    SqlDbType[] types = { SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                    object[] data = { TextBox2.Text, "Flag Item", 2, FlagEmailTextBox.Text };
                    dat.ExecuteWithParemeters("INSERT INTO MessagesForAdmin (Message, Subject, Type, Email) VALUES(@p0, @p1, @p2, @p3)", types, data);
                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                                        System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                         "Anonymous user has flagged an item. EType: " + EType + ", ID: " + id + " Here is their email:" +
                                        FlagEmailTextBox.Text + " Here is their message:  <br/><br/>" + TextBox2.Text, "Hippo Website Flag: An item has been flagged.");
                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                            System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                            FlagEmailTextBox.Text
            , "Hippo Happenings has received your request to flag an item. We will investigate and take appropriate action.", "Hippo Happenings Flag Request Received");

                }
                else
                {
                    SqlDbType[] types = { SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.Int };
                    object[] data = { TextBox2.Text, Session["User"].ToString(), "Flag Item", 2 };
                    dat.ExecuteWithParemeters("INSERT INTO MessagesForAdmin (Message, UserID, Subject, Type) VALUES(@p0, @p1, @p2, @p3)", types, data);

                    DataSet dsUser = dat.GetData("SELECT * FROM Users WHERE User_ID=" + Session["User"].ToString());

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                                        System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString()
                        , "User ID: " + Session["User"].ToString() + ", UserName: "******"UserName"].ToString() +
                        " has flagged an item. EType: " + EType + ", ID: " + id + " Here is their message: <br/><br/>" +
                        TextBox2.Text, "Hippo Website Flag: An item has been flagged.");

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                                        dsUser.Tables[0].Rows[0]["Email"].ToString()
                        , "Hippo Happenings has received your request to flag an item. " +
                        "We will investigate and get back to you.", "Hippo Happenings Flag Request Received");
                }

                Label2.Text = "Your message has been sent.";
                FlagPanel.Visible = false;
                ThankYouPanel.Visible = true;
            }
            else
            {
                Label2.Text = "Please include your message.";
            }
        }
        catch (Exception ex)
        {
            Label2.Text = ex.ToString();
        }
    }
    protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];

        DateTime isn = DateTime.Now;

        if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
            isn = DateTime.Now;
        DateTime isNow = isn;
        Data dat = new Data(isn); SubjectTextBox.Text = dat.stripHTML(SubjectTextBox.Text);
        MessageTextBox.Text = dat.stripHTML(MessageTextBox.Text);
        if (SubjectTextBox.Text != "" && MessageTextBox.Text != "")
        {
            try
            {

                string command = "INSERT INTO MessagesForAdmin (UserID, Message, Subject, Type) VALUES(@p0, @p1, @p2, @p3)";
                SqlDbType[] types = { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int };
                object[] data = { int.Parse(Session["User"].ToString()), MessageTextBox.Text, SubjectTextBox.Text, 1 };
                dat.ExecuteWithParemeters(command, types, data);

                DataSet dsUser = dat.GetData("SELECT * FROM Users WHERE User_ID="+Session["User"].ToString());

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString()
                    , "User ID: " + Session["User"].ToString() + ", UserName: "******"UserName"].ToString() +
                    " has filled out a 'Contact Us' form. Here is their message: <br/><br/>" +
                    MessageTextBox.Text, "Contact Us Form Submitted: "+SubjectTextBox.Text);

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    dsUser.Tables[0].Rows[0]["Email"].ToString()
                    , "<br/><br/>Your contact request has been submitted to Hippo Happenings. We will reply to your "+
                    "request momentarily.", "Hippo Happenings Contact Request Submitted");

                Encryption encrypt = new Encryption();
                MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("<br/><br/>Thank you for your contact request. We will get back to you as soon as possible.<br/><br/><div align=\"center\">" +
        "<div style=\"width: 50px;\" onclick=\"Search('home')\">" +
        "<div class=\"topDiv\" style=\"clear: both;\">" +
          "  <img style=\"float: left;\" src=\"NewImages/ButtonLeft.png\" height=\"27px\" /> " +
           " <div class=\"NavyLink\" style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
           " OK " +
        "</div>" +
           " <img style=\"float: left;\" src=\"NewImages/ButtonRight.png\" height=\"27px\" /> " +
        "</div>" +
        "</div>" +
        "</div>");
                MessageRadWindow.Visible = true;
                MessageRadWindowManager.VisibleOnPageLoad = true;

            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            if (SubjectTextBox.Text == "")
                SubjectRequired.Text = "*Please include the subject";
            if (MessageTextBox.Text == "")
                MessageRequired.Text = "*Please include a message";
        }
    }
    protected void SendItNotLoggedIn(object sender, EventArgs e)
    {
        string message = ConfirmEmail();
        HttpCookie cookie = Request.Cookies["BrowserDate"];

        DateTime isn = DateTime.Now;

        if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
            isn = DateTime.Now;
        DateTime isNow = isn;
        Data dat = new Data(isn); TextBox1.Text = dat.stripHTML(TextBox1.Text);
        TextBox2.Text = dat.stripHTML(TextBox2.Text);
        if (message == "Success")
        {
            if (TextBox1.Text != "" && TextBox2.Text != "")
            {
                try
                {

                    string command = "INSERT INTO MessagesForAdmin (Message, Subject, Type, Email) VALUES(@p0, @p1, @p2, @p3)";
                    SqlDbType[] types = { SqlDbType.NChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                    object[] data = { TextBox2.Text, TextBox1.Text, 1, EmailTextBox.Text.Trim().ToLower() };
                    dat.ExecuteWithParemeters(command, types, data);

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString()
                        , "Email: " + EmailTextBox.Text + ", has filled out a 'Contact Us' form. Here is their message: <br/><br/>" +
                        TextBox2.Text, "Contact Us Form Submitted: " + TextBox1.Text);

                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                        EmailTextBox.Text.Trim().ToLower()
                        , "<br/><br/>Your contact request has been submitted to Hippo Happenings. We will reply to your " +
                        "request momentarily.", "Hippo Happenings Contact Request Submitted");

                    Encryption encrypt = new Encryption();
                    MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("<br/><br/>Thank you for your contact request. We will get back to you as soon as possible.<br/><br/><div align=\"center\">" +
        "<div style=\"width: 50px;\" onclick=\"Search('home')\">" +
        "<div class=\"topDiv\" style=\"clear: both;\">" +
          "  <img style=\"float: left;\" src=\"NewImages/ButtonLeft.png\" height=\"27px\" /> " +
           " <div class=\"NavyLink\" style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
           " OK " +
        "</div>" +
           " <img style=\"float: left;\" src=\"NewImages/ButtonRight.png\" height=\"27px\" /> " +
        "</div>" +
        "</div>" +
        "</div>");
                    MessageRadWindow.Visible = true;
                    MessageRadWindowManager.VisibleOnPageLoad = true;

                }
                catch (Exception ex)
                {
                    Label2.Text = ex.ToString();
                }
            }
            else
            {
                if (TextBox1.Text.Trim() == "")
                    Label1.Text = "*Please include the subject";
                if (TextBox2.Text.Trim() == "")
                    Label2.Text = "*Please include a message";
            }
        }
        else
        {
            Label2.Text = message;
        }
    }
    protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (MessageTextBox.Text != "")
        {
            try
            {
                Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

                //get user
                string user = "";

                switch (Request.QueryString["Type"].ToString())
                {
                    case "E":
                        user = dat.GetData("SELECT * FROM Events E, Users U WHERE U.UserName=E.UserName " +
                     "AND E.ID=" + Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["User_ID"].ToString();
                        break;
                    case "V":
                        string temp = "CreatedByUser";
                        if (bool.Parse(Request.QueryString["Edit"].ToString()))
                        {
                            temp = "EditedByUser";
                        }
                        user = dat.GetData("SELECT "+temp+" FROM Venues V WHERE " +
                            " ID=" + Request.QueryString["ID"].ToString()).Tables[0].Rows[0][temp].ToString();
                        break;
                    case "A":
                        user = dat.GetData("SELECT * FROM Ads WHERE Ad_ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["User_ID"].ToString();
                        break;
                    case "G":
                        user = dat.GetData("SELECT * FROM Groups WHERE ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["Host"].ToString();
                        break;
                    case "GE":
                        user = dat.GetData("SELECT * FROM GroupEvents WHERE ID=" +
                            Request.QueryString["ID"].ToString()).Tables[0].Rows[0]["UserID"].ToString();
                        break;
                    default: break;
                }

                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                    System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                    "user: "******", postDetails: " + Request.QueryString["Type"].ToString() + "; ID=" +
                    Request.QueryString["ID"].ToString() + ", rating value: " +
                    RatingRadioList.SelectedValue + ", message: " + MessageTextBox.Text, "Hippo Experience Rating");

                string command = "INSERT INTO SiteExperienceRatings (UserID, PostDetails, ExperienceRating, ExperienceDetails) VALUES(@p0, @p1, @p2, @p3)";
                SqlDbType[] types = { SqlDbType.Int, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.NVarChar };
                object[] data = { int.Parse(user),
                    "Type="+Request.QueryString["Type"].ToString()+"; ID="+Request.QueryString["ID"].ToString(), RatingRadioList.SelectedValue, MessageTextBox.Text };
                dat.ExecuteWithParemeters(command, types, data);
                //dat.SendEmail("Hippo happenings email address", "Hippo Happening", YourEmailTextBox.Text, EmailTextBox.Text + "<br/>"+Session["message"].ToString(), EmailSubjectLabel.Text);
                Encryption encrypt = new Encryption();
                MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt("Thank you for your "+
                    "feedback!<br/><br/><div align=\"center\">" +
                "<div style=\"width: 50px;\" onclick=\"Search('home')\">" +
                "<div class=\"topDiv\" style=\"clear: both;\">" +
                  "  <img style=\"float: left;\" src=\"NewImages/ButtonLeft.png\" height=\"27px\" /> " +
                   " <div class=\"NavyLink\" style=\"font-size: 12px; text-decoration: none; padding-top: 5px;padding-left: 6px; padding-right: 6px;height: 27px;float: left;background: url('NewImages/ButtonPixel.png'); background-repeat: repeat-x;\">" +
                       " OK " +
                    "</div>" +
                   " <img style=\"float: left;\" src=\"NewImages/ButtonRight.png\" height=\"27px\" /> " +
                "</div>" +
                "</div>" +
                "</div><br/>");
                MessageRadWindow.Visible = true;
                MessageRadWindowManager.VisibleOnPageLoad = true;
            }
            catch (Exception ex)
            {
                MessageRequired.Text = ex.ToString();
            }
        }
        else
        {
            if (MessageTextBox.Text == "")
                MessageRequired.Text = "*Please include a message";
        }
    }
    protected void SendIt(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        SqlDbType [] types = {SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Int, SqlDbType.Int, SqlDbType.DateTime, SqlDbType.Bit, SqlDbType.Int};

           bool isUserSelected = false;
        for (int i = 0; i < UsersListBox.Items.Count; i++)
        {
            if (UsersListBox.Items[i].Selected)
            {
                isUserSelected = true;
                object[] data = {TextInput.InnerText, "You have a communication request for event '"+
                    Session["EventName"].ToString()+"'", Session["User"].ToString(), UsersListBox.Items[i].Value, DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")), false, 3};
                dat.ExecuteWithParemeters("INSERT INTO UserMessages (MessageContent, MessageSubject, From_UserID, To_UserID, Date, [Read], Mode) " +
                    " VALUES(@p0,@p1,@p2,@p3,@p4,@p5,@p6)", types, data);

                DataSet dsFriend = dat.GetData("SELECT * FROM Users U, UserPreferences UP WHERE UP.UserID=U.User_ID AND U.User_ID=" + UsersListBox.Items[i].Value);

                string subject = "You have a communication request for event '" +
                    Session["EventName"].ToString() + "' from " + dsFriend.Tables[0].Rows[0]["UserName"].ToString();
                string body = "<div style=\"color: #cccccc;\"><br/>A new email arrived at your inbox on Hippo Happenings from " + Session["UserName"].ToString() + ". <br/><br/> Subject: " + subject + ". <br/><br/> Message: " +
                TextInput.InnerText + "<br/><br/> To view the email and reply, <a href=\"http://HippoHappenings.com/User.aspx\">" +
                "log into Hippo Happenings</a></div>";

                //only send to email if users preferences are set to do so.
                if (dsFriend.Tables[0].Rows[0]["EmailPrefs"].ToString().Contains("6"))
                {
                    dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                        System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                        dsFriend.Tables[0].Rows[0]["Email"].ToString(), body, "HippoHappenings Mail: " + subject);
                }
            }
        }

        if (!isUserSelected)
        {
            CommunicateLabel.Text = "You have not selected any participants.";
        }
        else
        {
            ThankYouPanel.Visible = true;
            MessagePanel.Visible = false;
        }
    }