protected void PostIt(object sender, EventArgs e)
    {
        object appSeshCountry;
        object appSeshState;
        object appSeshCity;
        object appSeshZip;
        object appSeshRadius;
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (AgreeCheckBox.Checked)
        {
            Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
            conn.Open();

            bool isEdit = false;

            if (Request.QueryString["edit"] != null)
            {
                isEdit = bool.Parse(Request.QueryString["edit"].ToString());
            }

            string mediaCat = "0";
            if (PictureCheckList.Items.Count > 0)
                mediaCat = "1";

            string command = "";

            DataSet dsEvent;
            int numViews = 0;
            if (isEdit)
            {
                dsEvent = dat.GetData("SELECT * FROM Ads WHERE Ad_ID="+adID.Text);
                numViews = int.Parse(dsEvent.Tables[0].Rows[0]["NumViews"].ToString());

                string rad = "";

                if (RadiusPanel.Visible)
                    rad = ", Radius=@radius ";

                command = "UPDATE Ads SET hasSongs=@songs, User_ID=@userID, FeaturedSummary=@featuredSummary , " +
                    "Description=@description, Header=@header, CountShown=@countShown,  mediaCategory=" + mediaCat + ", " +
                    "FeaturedPicture=@featuredPicture, FeaturedPictureName=@featuredPictureName, CatCountry=@catCountry, CatState=@catState, CatCity=@catCity, " +
                    "CatZip=@catZip" + rad + ", DisplayToAll=@displayAll, NumViews=@num WHERE Ad_ID=" + adID.Text;
            }
            else
            {
                string rad = "";
                string radEnd = "";
                if (RadiusPanel.Visible)
                {
                    rad = ", Radius ";
                    radEnd = ", @radius ";
                }

                command = "INSERT INTO Ads (hasSongs, User_ID, FeaturedSummary ,Description, Header, "+
                    "CountShown, Featured, mediaCategory, FeaturedPicture, FeaturedPictureName, CatCountry, CatState, CatCity, "+
                    "CatZip" + rad + ", DisplayToAll, NumViews, NumCurrentViews, BigAd, DateAdded) "
                    + " VALUES(@songs, @userID, @featuredSummary, @description, @header, @countShown, "+
                    "@featured, " + mediaCat + ", @featuredPicture, @featuredPictureName, @catCountry, @catState, @catCity, @catZip" + radEnd + ", @displayAll, @num, 0, @big, '" +
                    DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).ToString() + "')";
            }

            SqlCommand cmd = new SqlCommand(command, conn);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@num", SqlDbType.Int).Value = int.Parse(UsersTextBox.Text) + numViews;
            cmd.Parameters.Add("@description", SqlDbType.NVarChar).Value = DescriptionTextBox.Content;
            cmd.Parameters.Add("@userID", SqlDbType.Int).Value = int.Parse(Session["User"].ToString());
            cmd.Parameters.Add("@featured", SqlDbType.Bit).Value = bool.Parse(isFeatured.Text);

            cmd.Parameters.Add("@songs", SqlDbType.Bit).Value = MusicCheckBox.Checked;

            if (bool.Parse(isFeatured.Text))
                cmd.Parameters.Add("@featuredSummary", SqlDbType.NVarChar).Value = SummaryTextBox.InnerHtml;
            else
                cmd.Parameters.Add("@featuredSummary", SqlDbType.NVarChar).Value = DBNull.Value;

            cmd.Parameters.Add("@header", SqlDbType.NVarChar).Value = AdNameTextBox.THE_TEXT;
            cmd.Parameters.Add("@countShown", SqlDbType.Int).Value = 0;

            if (AdPlacementList.SelectedValue == "0.01")
                cmd.Parameters.Add("@big", SqlDbType.Bit).Value = false;
            else
                cmd.Parameters.Add("@big", SqlDbType.Bit).Value = true;

            if (bool.Parse(isFeatured.Text))
                if (AdPictureCheckList.Items.Count > 0 && AdMediaPanel.Visible)
                {
                    cmd.Parameters.Add("@featuredPicture", SqlDbType.NVarChar).Value = AdPictureCheckList.Items[0].Value;
                    cmd.Parameters.Add("@featuredPictureName", SqlDbType.NVarChar).Value = AdPictureCheckList.Items[0].Text;
                }
                else
                {
                    cmd.Parameters.Add("@featuredPicture", SqlDbType.NVarChar).Value = DBNull.Value;
                    cmd.Parameters.Add("@featuredPictureName", SqlDbType.NVarChar).Value = DBNull.Value;
                }
            else
            {
                cmd.Parameters.Add("@featuredPicture", SqlDbType.NVarChar).Value = DBNull.Value;
                cmd.Parameters.Add("@featuredPictureName", SqlDbType.NVarChar).Value = DBNull.Value;
            }

            if (CountryDropDown.SelectedIndex != -1)
            {
                appSeshCountry = CountryDropDown.SelectedValue;
                cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = CountryDropDown.SelectedValue;

                string state = "";
                if (StateDropDownPanel.Visible)
                {
                    if (StateDropDown.SelectedIndex != -1)
                        state = StateDropDown.SelectedItem.Text;
                }
                else
                    state = StateTextBox.THE_TEXT;

                appSeshState = state;

                if (state != "")
                    cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = state;
                else
                    cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = DBNull.Value;

                if (CityTextBox.Text.Trim() != "")
                {
                    appSeshCity = CityTextBox.Text.Trim();
                    cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = CityTextBox.Text.Trim();
                }
                else
                    cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = DBNull.Value;

                if (ZipTextBox.Text.Trim() != "")
                {
                    appSeshZip = ZipTextBox.Text.Trim();
                    appSeshRadius = RadiusDropDown.SelectedValue;
                    cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value =
                        dat.GetAllZipsInRadius(RadiusDropDown.SelectedValue, ZipTextBox.Text.Trim(), true);
                }
                else
                    cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;

                if(CountryDropDown.SelectedValue == "223")
                    cmd.Parameters.Add("@radius", SqlDbType.Int).Value = RadiusDropDown.SelectedValue;
            }
            else
            {
                cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = DBNull.Value;
                cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = DBNull.Value;
                cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = DBNull.Value;
                cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;
                cmd.Parameters.Add("@radius", SqlDbType.Int).Value = DBNull.Value;
            }
            cmd.Parameters.Add("@displayAll", SqlDbType.Bit).Value = DisplayCheckList.Items[0].Selected;
            //Media Categories: NONE: 0, Slider: 1.
            bool isSlider = false;
            if (PictureCheckList.Items.Count > 0)
                isSlider = true;

            cmd.ExecuteNonQuery();

            cmd = new SqlCommand("SELECT @@IDENTITY AS ID", conn);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd);
            DataSet ds3 = new DataSet();
            da2.Fill(ds3);

            string ID = ds3.Tables[0].Rows[0]["ID"].ToString();

            if (isEdit)
            {
                dat.Execute("DELETE FROM Ad_Calendar WHERE AdID="+adID.Text);

                if (bool.Parse(isFeatured.Text))
                {
                    cmd = new SqlCommand("INSERT INTO Ad_Calendar (AdID, DateTimeStart, DateTimeEnd) VALUES(@id, @start, @end)", conn);
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = adID.Text;
                    cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = Session["SelectedStartDate"].ToString();
                    cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = DateTime.Parse(Session["SelectedStartDate"].ToString()).AddDays(double.Parse(DaysDropDown.SelectedValue));
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    cmd = new SqlCommand("INSERT INTO Ad_Calendar (AdID, DateTimeStart, DateTimeEnd) VALUES(@id, @start, @end)", conn);
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = adID.Text;
                    cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = StartDateTimePicker.DbSelectedDate;
                    cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = DateTime.Parse(StartDateTimePicker.DbSelectedDate.ToString()).AddDays(double.Parse(DaysDropDown.SelectedValue));
                    cmd.ExecuteNonQuery();
                }
            }
            else
            {
                cmd = new SqlCommand("INSERT INTO Ad_Calendar (AdID, DateTimeStart, DateTimeEnd) VALUES(@id, @start, @end)", conn);
                cmd.Parameters.Add("@id", SqlDbType.Int).Value = ID;
                if (bool.Parse(isFeatured.Text))
                {
                    cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = Session["SelectedStartDate"].ToString();
                    cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = DateTime.Parse(Session["SelectedStartDate"].ToString()).AddDays(double.Parse(DaysDropDown.SelectedValue));
                }
                else
                {
                    cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = DateTime.Parse(StartDateTimePicker.DbSelectedDate.ToString());
                    cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = DateTime.Parse(StartDateTimePicker.DbSelectedDate.ToString()).AddDays(double.Parse(DaysDropDown.SelectedValue));
                }

                    cmd.ExecuteNonQuery();
            }

            string theID = ID;
            if (isEdit)
            {
                theID = adID.Text;
            }
            if (MusicCheckBox.Checked)
            {

                if (isEdit)
                {

                    dat.Execute("DELETE FROM Ad_Song_Mapping WHERE AdID="+theID);
                }

                for (int i = 0; i < SongCheckList.Items.Count; i++)
                {
                        cmd = new SqlCommand("INSERT INTO Ad_Song_Mapping (AdID, SongName, SongTitle) "+
                            "VALUES(@eventID, @songName, @songTitle)", conn);
                        cmd.Parameters.Add("@eventID", SqlDbType.Int).Value = int.Parse(theID);
                        cmd.Parameters.Add("@songName", SqlDbType.NVarChar).Value = SongCheckList.Items[i].Value.ToString();
                        cmd.Parameters.Add("@songTitle", SqlDbType.NVarChar).Value = SongCheckList.Items[i].Text;
                        cmd.ExecuteNonQuery();

                        dat.Execute("UPDATE Ads SET hasSongs=1 WHERE Ad_ID="+theID);
                }
            }

            if (isEdit)
            {
                dat.Execute("DELETE FROM Ad_Slider_Mapping WHERE AdID=" + theID);
            }

            if (MainAttractionCheck.Checked)
            {

                if (isSlider)
                {

                    char[] delim2 = { '\\' };
                    string[] fileArray = System.IO.Directory.GetFiles(MapPath(".") + "\\UserFiles\\" +
                        Session["UserName"].ToString() + "\\AdSlider\\");

                    if (!System.IO.Directory.Exists(MapPath(".") + "\\UserFiles"))
                    {
                        System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles");
                        System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\");
                        System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider");
                        System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + theID);
                    }
                    else
                    {
                        if (!System.IO.Directory.Exists(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\"))
                        {
                            System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\");
                            System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider");
                            System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\" + theID);
                        }
                        else
                        {
                            if (!System.IO.Directory.Exists(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider"))
                            {
                                System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider");
                                System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + theID);
                            }
                            else
                            {
                                if (!System.IO.Directory.Exists(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + theID))
                                {
                                    System.IO.Directory.CreateDirectory(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() + "\\AdSlider\\" + theID);
                                }
                            }
                        }
                    }

                    string YouTubeStr = "";
                    char[] delim3 = { '.' };
                    for (int i = 0; i < PictureCheckList.Items.Count; i++)
                    {
                        int length = fileArray[i].Split(delim2).Length;
                        string[] tokens = PictureCheckList.Items[i].Value.ToString().Split(delim3);

                        if (tokens.Length >= 2)
                        {
                            if (tokens[1].ToUpper() == "JPG" || tokens[1].ToUpper() == "JPEG" || tokens[1].ToUpper() == "GIF")
                            {
                                if (!System.IO.File.Exists(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() +
                                    "\\AdSlider\\" + theID + "\\" + PictureCheckList.Items[i].Value))
                                {
                                    System.IO.File.Copy(MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() +
                                                            "\\AdSlider\\" + PictureCheckList.Items[i].Value,
                                                            MapPath(".") + "\\UserFiles\\" + Session["UserName"].ToString() +
                                    "\\AdSlider\\" + theID + "\\" +
                                                            PictureCheckList.Items[i].Value);
                                }

                                cmd = new SqlCommand("INSERT INTO Ad_Slider_Mapping (AdID, PictureName, RealPictureName) " +
                                    "VALUES (@eventID, @picName, @realName)", conn);
                                cmd.Parameters.Add("@eventID", SqlDbType.Int).Value = theID;
                                cmd.Parameters.Add("@picName", SqlDbType.NVarChar).Value = PictureCheckList.Items[i].Value;
                                cmd.Parameters.Add("@realName", SqlDbType.NVarChar).Value = PictureCheckList.Items[i].Text;
                                cmd.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            YouTubeStr += PictureCheckList.Items[i].Value + ";";
                        }

                    }

                    //if (YouTubeStr != "")
                    //{
                        dat.Execute("UPDATE Ads SET YouTubeVideo='" + YouTubeStr + "' WHERE Ad_ID=" + theID);
                    //}

                }
            }
            else
            {

            }

            if (isEdit)
            {
                dat.Execute("DELETE FROM Ad_Category_Mapping WHERE AdID="+theID);
            }

            CreateCategories(theID);

            string views = dat.GetDataDV("SELECT NumViews - NumCurrentViews AS Views FROM Ads WHERE Ad_ID=" +
                theID)[0]["Views"].ToString();

            if (bool.Parse(isFeatured.Text) && int.Parse(views) != 0)
                EmailSavedSearches(theID, views);

            //if (CategoriesCheckBoxes.Items.Count > 0)
            //{
            //    int catCount = CategoriesCheckBoxes.Items.Count;

            //    for (int i = 0; i < catCount; i++)
            //    {
            //        cmd = new SqlCommand("INSERT INTO Ad_Category_Mapping (AdID, CategoryID) VALUES (@adID, @catID)", conn);
            //        cmd.Parameters.Add("@adID", SqlDbType.Int).Value = ID;
            //        cmd.Parameters.Add("@catID", SqlDbType.Int).Value = int.Parse(CategoriesCheckBoxes.Items[i].Value);
            //        cmd.ExecuteNonQuery();
            //    }
            //}

            string adFeatured = "";
            string adFeaturedEmail = "";
            if (bool.Parse(isFeatured.Text))
            {
                adFeatured += "<br/><br/>Since you selected to have your ad Featured, you can view the progress of your ad on the <a class=\"AddLink\" onclick=\"Search('AdStatistics.aspx?Ad="+theID+"');\">Ad Statistics</a> page, which is also linkable from your user page.";
                adFeaturedEmail += "<br/><br/>Since you selected to have your ad Featured, you can view the progress of your ad on the <a href=\"http://hippohappenings.com/AdStatistics.aspx?Ad="+theID+"\">Ad Statistics</a> page, which is also linkable from your user page.";
            }
            DataSet dsUser = dat.GetData("SELECT Email, UserName FROM USERS WHERE User_ID=" +
                    Session["User"].ToString());
            string emailBody = "<br/><br/>Dear " + dsUser.Tables[0].Rows[0]["UserName"].ToString() + ", <br/><br/> you have successfully posted the ad \"" + AdNameTextBox.THE_TEXT +
        "\". <br/><br/> You can find this ad <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(AdNameTextBox.THE_TEXT)+"_" + theID + "_Ad\">here</a>. " + adFeaturedEmail +
        "<br/><br/> To rate your experience posting this ad <a href=\"http://hippohappenings.com/RateExperience.aspx?Type=A&ID=" + theID + "\">please include your feedback here.</a>" +
        "<br/><br/><br/>Have a Hippo Happening Day!<br/><br/>";

            if (isEdit)
            {
                emailBody = "<br/><br/>Dear " + dsUser.Tables[0].Rows[0]["UserName"].ToString() + ", <br/><br/> you have successfully edited the ad \"" + AdNameTextBox.THE_TEXT +
        "\". <br/><br/> You can find this ad <a href=\"http://hippohappenings.com/" + dat.MakeNiceName(AdNameTextBox.THE_TEXT) + "_" + theID + "_Ad\">here</a>. " + adFeaturedEmail +
        "<br/><br/> To rate your experience editing this ad <a href=\"http://hippohappenings.com/RateExperience.aspx?Type=A&ID=" + theID + "\">please include your feedback here.</a>" +
        "<br/><br/><br/>Have a Hippo Happening Day!<br/><br/>";
            }

            if (!Request.IsLocal)
            {
                dat.SendEmail(System.Configuration.ConfigurationManager.AppSettings["emailemail"].ToString(),
                            System.Configuration.ConfigurationManager.AppSettings["emailName"].ToString(),
                            dsUser.Tables[0].Rows[0]["Email"].ToString(), emailBody, "You have successfully posted the ad: " +
                            AdNameTextBox.THE_TEXT);
            }
            conn.Close();

            dat.SendFriendPostedAdNotification(Session["User"].ToString(), theID);

            Session["Message"] = "Your ad has been posted successfully!<br/> Here are your next steps: <br/>";

            if (isEdit)
            {
                Session["Message"] = "Your ad has been edited successfully!<br/> Here are your next steps: <br/>";
            }

            CheckAllUsers(AdPlacementList.SelectedValue != "0.01", theID);

            //Clear cache so that the PlayerList.xml can be grabbed by the browser again.
            ClearCache();

            Session["Message"] += "<br/>" + "Go to <a class=\"AddLink\" onclick=\"Search('" + dat.MakeNiceName(AdNameTextBox.THE_TEXT) + "_" + theID + "_Ad');\">your ad's</a> home page." + adFeatured + "<br/><br/> -<a class=\"AddLink\" onclick=\"Search('RateExperience.aspx?Type=A&ID=" + theID + "');\" >Rate </a>your user experience posting this venue.<br/>";
            //MessageLiteral.Text = "<script type=\"text/javascript\">alert('" + message + "');</script>";
            Encryption encrypt = new Encryption();
            MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(Session["Message"].ToString() +
                "<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;

            Session["categorySession"] = null;
        }
        else
        {
            MessagePanel.Visible = true;
            YourMessagesLabel.Text += "<br/><br/>You must agree to the terms and conditions.";
        }
    }
    protected void Save(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        Data d = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

        bool hasState = false;
        if (StateDropDown.Visible && StateDropDown.SelectedValue != "-1")
            hasState = true;

        if (!StateDropDown.Visible && StateTextBox.THE_TEXT.Trim() != "")
            hasState = true;

        bool hasCity = false;
        if (CityTextBox.THE_TEXT.Trim() != "")
            hasCity = true;

        if (hasState && hasCity)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
            conn.Open();
            string ID = Request.QueryString["ID"].Trim();

            string radius = "";
            if (RadiusPanel.Visible)
            {
                radius = ", Radius=" + RadiusDropDown.SelectedValue;
            }

            SqlCommand cmd = new SqlCommand("UPDATE UserPreferences SET  " +
                " CatCountry=@catCountry, CatState=@catState, CatCity=@catCity, CatZip=@catZip" + radius +
                " WHERE UserID=@id ", conn);
            cmd.Parameters.Add("@id", SqlDbType.Int).Value = ID;
            cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = CityTextBox.THE_TEXT;

            if (CatZipTextBox.THE_TEXT.Trim() != "")
                cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = d.GetAllZipsInRadius(RadiusDropDown.SelectedValue,
                            CatZipTextBox.THE_TEXT.Trim(), true);
            else
                cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;

            cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = CountryDropDown.SelectedValue;
            Session["UserCountry"] = CountryDropDown.SelectedValue;
            string state = "";
            if (StateDropDownPanel.Visible)
                state = StateDropDown.SelectedItem.Text;
            else
                state = StateTextBox.THE_TEXT;

            cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = state;

            Session["UserState"] = state;
            Session["UserCity"] = CityTextBox;
            Session["UserCity"] = CatZipTextBox.THE_TEXT.Trim();

            cmd.ExecuteNonQuery();
            conn.Close();

            LocationPanel.Visible = false;
            DonePanel.Visible = true;
        }
        else
        {
            MessageLabel.Text = "Please Include City and State.";
        }
    }
    protected void MakeItSo(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));
        try
        {
            bool hasState = false;
            if (StateDropDown.Visible && StateDropDown.SelectedValue != "-1")
                hasState = true;

            if (!StateDropDown.Visible && StateTextBox.THE_TEXT.Trim() != "")
                hasState = true;

            bool hasCity = false;
            if (CityTextBox.THE_TEXT.Trim() != "")
                hasCity = true;

            bool hasHeadr = false;
            if (HowHeardTextBox.THE_TEXT.Trim() != "")
                hasHeadr = true;

            UserNameTextBox.THE_TEXT = UserNameTextBox.THE_TEXT.Trim().Replace(" ", "");
            //ReferringUserName.Text = ReferringUserName.Text.Trim().Replace(" ", "");

            //if (!dat.TrapKey(ReferringUserName.Text, 1))
            //{
            //    MessageLabel.Text = "The Referring User Name cannot contain any illegal characters.";
            //    return;
            //}
            //else
            //{
            //    DataView dv = dat.GetDataDV("SELECT * FROM Users WHERE UserName='******'");
            //    if (dv.Count == 0)
            //    {
            //        MessageLabel.Text = "The Referring User Name you have provided does not exist in our system.";
            //        return;
            //    }
            //}

            MessageLabel.Text = "";
            if (hasCity && hasState && hasHeadr && UserNameTextBox.THE_TEXT != "" && PasswordTextBox.Text != "" &&
                ConfirmPasswordTextBox.Text != "" && ((FirstNameTextBox.THE_TEXT.Trim() != ""
                && LastNameTextBox.THE_TEXT.Trim() != "" && dat.TrapKey(FirstNameTextBox.THE_TEXT.Trim(), 1)
                && dat.TrapKey(LastNameTextBox.THE_TEXT.Trim(), 1))|| (FirstNameTextBox.THE_TEXT.Trim() == "" &&
                LastNameTextBox.THE_TEXT.Trim() == "")))
            {

                bool safeToGo = false;
                if (dat.TrapKey(UserNameTextBox.THE_TEXT, 1))
                {
                    DataSet ds = dat.GetData("SELECT * FROM Users WHERE UserName='******'");

                    string message = "";
                    if (ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            message = "*This User Name already exists in the database. Choose a different User Name.";

                        }
                        else
                            safeToGo = true;
                    else
                        safeToGo = true;

                    ds = dat.GetData("SELECT * FROM Users WHERE Email='"+EmailLabel.Text+"'");

                    if (ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            message += " This Email is already used by another user. You might have already completed this step. In that case, all you need to do is <a href=\"UserLogin.aspx\">Login</a>";
                            safeToGo = false;
                        }

                    if (safeToGo)
                    {
                        if (dat.TrapKey(PasswordTextBox.Text, 1))
                        {
                            safeToGo = true;
                        }
                        else
                        {
                            MessageLabel.Text = "*The Password can contain only letters and numbers.";
                            safeToGo = false;
                        }

                        if (safeToGo)
                        {
                            if (PasswordTextBox.Text == ConfirmPasswordTextBox.Text)
                                safeToGo = true;
                            else
                            {
                                safeToGo = false;
                                MessageLabel.Text = "*The Confirm Password must match the Password.";
                            }

                            if (safeToGo)
                            {
                                //if (CheckImageButton.ImageUrl == "image/CheckSelected.png")
                                //    safeToGo = true;
                                //else
                                //{
                                //    safeToGo = false;
                                //    MessageLabel.Text = "*Read and agree to the Terms And Conditions in order to sign up.";
                                //}

                                if (safeToGo)
                                {
                                    Encryption encrypt = new Encryption();
                                    string namesStart = "";
                                    string namesEnd = "";
                                    if (FirstNameTextBox.THE_TEXT.Trim() != "")
                                    {
                                        namesStart = ", FirstName, LastName";
                                        namesEnd = ", '" +
                                        dat.stripHTML(FirstNameTextBox.THE_TEXT.Trim().Replace("'", "''")) + "', '" +
                                        dat.stripHTML(LastNameTextBox.THE_TEXT.Trim().Replace("'", "''")) + "'";
                                    }
                                    dat.Execute("INSERT INTO Users (HowHeard, UserName, Email, Password, IPs" + namesStart + ", DateCreated) VALUES('" +
                                        HowHeardTextBox.THE_TEXT.Trim().Replace("'", "").Replace("\"", "") + "','" +
                                        UserNameTextBox.THE_TEXT + "', '" + EmailLabel.Text + "', '" +
                                        encrypt.encrypt(PasswordTextBox.Text) + "', ';" + dat.GetIP() + ";'" + namesEnd + ", GETDATE())");
                                    DataSet dsID = dat.GetData("SELECT User_ID FROM Users WHERE UserName='******'");
                                    string ID = dsID.Tables[0].Rows[0]["User_ID"].ToString();
                                    string message2 = "Welcome to Hippo Happenings! <br/> It is now your place for Events, "
                                    + "Venues, Classifieds and connecting with people in your area. <br/> To start, select your preferences"
                                    + " for filtering your content on the site by going to <a class=\"AddLink\" href=\"UserPreferences.aspx\">My Preferences</a>. ";
                                    dat.Execute("INSERT INTO UserPreferences (UserID, EventsAttended, CalendarPrivacyMode, CommunicationPrefs, CommentsPreferences, PollPreferences, CatCountry, EmailPrefs, RecommendationPrefs) VALUES (" + ID + ", 0, 1, 1, 1, 1, 223, '123456789C', 3)");
                                    dat.Execute("INSERT INTO UserMessages (MessageContent, MessageSubject, "
                                        + "From_UserID, To_UserID, Date, [Read], Mode, Live) VALUES('" + message2 +
                                        "', 'Hippo Happenings Welcome!', 6, " + ID + ", '" + DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).ToString() + "', 'False', 1, 'True')");

                                    ds = dat.GetData("SELECT U.Password, U.User_ID, UP.CatCountry, UP.CatState, UP.CatCity, U.UserName FROM Users U, UserPreferences UP WHERE U.User_ID=UP.UserID AND U.UserName='******'");
                                    Session["UserName"] = UserNameTextBox.THE_TEXT.Trim();
                                    Session["User"] = ID;

                                    //insert all ad categories
                                    DataView dvCats = dat.GetDataDV("SELECT * FROM AdCategories WHERE isParent = 'True'");

                                    for (int i = 0; i < dvCats.Count; i++)
                                    {
                                        dat.Execute("INSERT INTO UserCategories (UserID, CategoryID) VALUES(" + ID + ", " + dvCats[i]["ID"].ToString() + ")");
                                    }

                                    string radius = "";
                                    if (RadiusPanel.Visible)
                                    {
                                        radius = ", Radius=" + RadiusDropDown.SelectedValue;
                                    }
                                    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());

                                    if (conn.State != ConnectionState.Open)
                                        conn.Open();
                                    SqlCommand cmd = new SqlCommand("UPDATE UserPreferences SET  " +
                                        " CatCountry=@catCountry, CatState=@catState, CatCity=@catCity, CatZip=@catZip" +
                                        radius +
                                        " WHERE UserID=@id ", conn);
                                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = ID;
                                    cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = CityTextBox.THE_TEXT;

                                    if (CatZipTextBox.THE_TEXT.Trim() != "")
                                        cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value =
                                            dat.GetAllZipsInRadius(RadiusDropDown.SelectedValue,
                                                    CatZipTextBox.THE_TEXT.Trim(), true);
                                    else
                                        cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;

                                    cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = CountryDropDown.SelectedValue;
                                    Session["UserCountry"] = CountryDropDown.SelectedValue;
                                    string state = "";
                                    if (StateDropDownPanel.Visible)
                                        state = StateDropDown.SelectedItem.Text;
                                    else
                                        state = StateTextBox.THE_TEXT;

                                    cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = state;

                                    Session["UserState"] = state;
                                    Session["UserCity"] = CityTextBox;
                                    Session["UserCity"] = CatZipTextBox.THE_TEXT.Trim();

                                    cmd.ExecuteNonQuery();
                                    conn.Close();

                                    string groups = "User, Admin";
                                    //FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
                                    FormsAuthenticationTicket authTicket =
                                        new FormsAuthenticationTicket(1, ds.Tables[0].Rows[0]["User_ID"].ToString(),
                                                      DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")),
                                                      DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).AddMinutes(60),
                                                      false, groups);

                                    // Now encrypt the ticket.
                                    string encryptedTicket =
                                      FormsAuthentication.Encrypt(authTicket);
                                    // Create a cookie and add the encrypted ticket to the
                                    // cookie as data.
                                    HttpCookie authCookie =
                                                 new HttpCookie(FormsAuthentication.FormsCookieName,
                                                                encryptedTicket);

                                    // Add the cookie to the outgoing cookies collection.
                                    Response.Cookies.Add(authCookie);
                                    dat.WhatHappensOnUserLogin(ds);

                                    //Send out welcome email
                                    dat.SendWelcome();

                                    Response.Redirect("User.aspx");

                                }
                            }

                        }

                    }
                    else
                    {
                        MessageLabel.Text = message;
                    }
                }
                else
                    MessageLabel.Text = "User Name can only contain letter and numbers.";
            }
            else
                MessageLabel.Text = "All fields with * must be filled in. If you include First and Last name, these cannot have any special keys, only letters. If you include one of the names, you must include the other.";
        }
        catch (Exception ex)
        {
            MessageLabel.Text = ex.ToString();
        }
    }
    protected void Save(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        try
        {
            Data d = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")));

            if (d.ValidateEmail(EmailTextBox.Text))
            {
                //This is a flag to check whether the ads on the site need to be reset.
                //They will need to be reset if the user changed the location or ad categories
                bool resetAds = false;

                string USER_ID = Session["User"].ToString();
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
                conn.Open();
                SqlCommand cmd;

                string nameStart = "";
                string nameEnd = "";
                if (LastNameTextBox.THE_TEXT.Trim() != "")
                    nameStart = ", LastName='" + LastNameTextBox.THE_TEXT.Trim().Replace("'", "''") + "' ";

                if(FirstNameTextBox.THE_TEXT.Trim() != "")
                    nameEnd =  ", FirstName='" + FirstNameTextBox.THE_TEXT.Trim().Replace("'", "''") + "' ";

                cmd = new SqlCommand("UPDATE Users SET ProfilePicture=@pic, Email=@email, PhoneNumber=@phone " +
                    ", PhoneProvider=@provider " + nameStart + nameEnd + "WHERE User_ID=@id ", conn);
                if (Session["ProfilePicture"] != null)
                    cmd.Parameters.Add("@pic", SqlDbType.NVarChar).Value = Session["ProfilePicture"].ToString();
                else
                    cmd.Parameters.Add("@pic", SqlDbType.NVarChar).Value = DBNull.Value;
                cmd.Parameters.Add("@email", SqlDbType.NVarChar).Value = EmailTextBox.Text;
                cmd.Parameters.Add("@phone", SqlDbType.NVarChar).Value = d.RemoveNoneNumbers(PhoneTextBox.THE_TEXT);
                cmd.Parameters.Add("@provider", SqlDbType.Int).Value = ProviderDropDown.SelectedValue;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value = USER_ID;
                cmd.ExecuteNonQuery();

                string prefs = "0";

                if (TextingCheckBoxList.Items[0].Selected)
                    prefs += "1";
                if (TextingCheckBoxList.Items[1].Selected)
                    prefs += "2";
                if (TextingCheckBoxList.Items[2].Selected)
                    prefs += "3";

                string emailPrefs = "0";

                if (EmailCheckList.Items[0].Selected)
                    emailPrefs += "1";
                if (EmailCheckList.Items[1].Selected)
                    emailPrefs += "2";
                if (EmailCheckList.Items[2].Selected)
                    emailPrefs += "3";

                if (EmailCheckList3.Items[0].Selected)
                    emailPrefs += "C";

                if (EmailUserCheckList1.Items[0].Selected)
                    emailPrefs += EmailUserCheckList1.Items[0].Value;
                if (EmailUserCheckList1.Items[1].Selected)
                    emailPrefs += EmailUserCheckList1.Items[1].Value;
                if (EmailUserCheckList1.Items[2].Selected)
                    emailPrefs += EmailUserCheckList1.Items[2].Value;

                if (EmailUserCheckList2.Items[0].Selected)
                    emailPrefs += EmailUserCheckList2.Items[0].Value;
                if (EmailUserCheckList2.Items[1].Selected)
                    emailPrefs += EmailUserCheckList2.Items[1].Value;
                if (EmailUserCheckList2.Items[2].Selected)
                    emailPrefs += EmailUserCheckList2.Items[2].Value;

                string calendarPrefs = "";
                if (PublicPrivateCheckList.SelectedValue != null)
                    if (PublicPrivateCheckList.SelectedValue != "")
                        calendarPrefs = PublicPrivateCheckList.SelectedValue;

                string commPrefs = "";
                if (CommunicationPrefsRadioList.SelectedValue != null)
                    if (CommunicationPrefsRadioList.SelectedValue != "")
                        commPrefs = CommunicationPrefsRadioList.SelectedValue;

                string commentsPrefs = "";
                if (CommentsRadioList.SelectedValue != null)
                    if (CommentsRadioList.SelectedValue != "")
                        commentsPrefs = CommentsRadioList.SelectedValue;

                string pollPrefs = "";
                //if (PollRadioList.SelectedValue != null)
                //    if (PollRadioList.SelectedValue != "")
                //        pollPrefs = PollRadioList.SelectedValue;

                string onoff = "";
                RadioButtonList CategoriesOnOffRadioList = (RadioButtonList)AdCategoryRadPanel.Items[0].Items[0].FindControl("CategoriesOnOffRadioList");
                Telerik.Web.UI.RadTreeView CategoryTree = (Telerik.Web.UI.RadTreeView)AdCategoryRadPanel.Items[0].Items[0].FindControl("CategoryTree");
                Telerik.Web.UI.RadTreeView RadTreeView2 = (Telerik.Web.UI.RadTreeView)AdCategoryRadPanel.Items[0].Items[0].FindControl("RadTreeView2");

                if (CategoriesOnOffRadioList.SelectedValue != null)
                    if (CategoriesOnOffRadioList.SelectedValue != "")
                        onoff = CategoriesOnOffRadioList.SelectedValue;

                string recommendPrefs = "";
                if (RecommendationsCheckList.Items[0].Selected)
                    recommendPrefs += "1";
                if (RecommendationsCheckList.Items[1].Selected)
                    recommendPrefs += "2";
                if (RecommendationsCheckList.Items[2].Selected)
                    recommendPrefs += "3";

                DataView usersPrevPrefs = d.GetDataDV("SELECT * FROM UserPreferences WHERE UserID="+Session["User"].ToString());

                string radius = "";
                if (RadiusPanel.Visible)
                {
                    radius = ", Radius="+RadiusDropDown.SelectedValue;
                }

                cmd = new SqlCommand("UPDATE UserPreferences SET Sex=@sex, Location=@location, CalendarPrivacyMode=@calendarmode " +
                    ", CommunicationPrefs=@commPrefs, TextingPrefs=@textprefs, EmailPrefs=@email, Address=@address, City=@city, " +
                    " CommentsPreferences=@comments, PollPreferences=@poll, CategoriesOnOff=@onoff, State=@state, ZIP=@zip, Country=@country, " +
                    " CatCountry=@catCountry" + radius + ", CatState=@catState, CatCity=@catCity, RecommendationPrefs=@rPrefs, CatZip=@catZip WHERE UserID=@id ", conn);
                //cmd.Parameters.Add("@age", SqlDbType.NVarChar).Value = AgeTextBox.Text;
                cmd.Parameters.Add("@sex", SqlDbType.NVarChar).Value = SexTextBox.Text;
                cmd.Parameters.Add("@location", SqlDbType.NVarChar).Value = LocationTextBox.Text;
                if (recommendPrefs != "")
                    cmd.Parameters.Add("@rPrefs", SqlDbType.Int).Value = recommendPrefs;
                else
                    cmd.Parameters.Add("@rPrefs", SqlDbType.Int).Value = DBNull.Value;
                if (onoff != "")
                    cmd.Parameters.Add("@onoff", SqlDbType.Int).Value = onoff;
                else
                    cmd.Parameters.Add("@onoff", SqlDbType.Int).Value = DBNull.Value;
                if (calendarPrefs != "")
                    cmd.Parameters.Add("@calendarmode", SqlDbType.Int).Value = calendarPrefs;
                else
                    cmd.Parameters.Add("@calendarmode", SqlDbType.Int).Value = DBNull.Value;
                if (commPrefs != "")
                    cmd.Parameters.Add("@commPrefs", SqlDbType.Int).Value = commPrefs;
                else
                    cmd.Parameters.Add("@commPrefs", SqlDbType.Int).Value = DBNull.Value;
                if (commentsPrefs != "")
                    cmd.Parameters.Add("@comments", SqlDbType.Int).Value = commentsPrefs;
                else
                    cmd.Parameters.Add("@comments", SqlDbType.Int).Value = DBNull.Value;
                if (pollPrefs != "")
                    cmd.Parameters.Add("@poll", SqlDbType.Int).Value = pollPrefs;
                else
                    cmd.Parameters.Add("@poll", SqlDbType.Int).Value = DBNull.Value;
                cmd.Parameters.Add("@address", SqlDbType.NVarChar).Value = AddressTextBox.THE_TEXT;
                cmd.Parameters.Add("@city", SqlDbType.NVarChar).Value = BillCityTextBox.THE_TEXT;

                if (BillCountryDropDown.SelectedValue != "-1")
                {
                    cmd.Parameters.Add("@country", SqlDbType.Int).Value = BillCountryDropDown.SelectedValue;

                    string state = "";
                    if (BillStateDropPanel.Visible)
                        state = BillStateDropDown.SelectedItem.Text;
                    else
                        state = BillStateTextBox.THE_TEXT;

                    cmd.Parameters.Add("@state", SqlDbType.NVarChar).Value = state;
                }
                else
                {
                    cmd.Parameters.Add("@country", SqlDbType.Int).Value = DBNull.Value;
                    cmd.Parameters.Add("@state", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (CountryDropDown.SelectedValue != "-1")
                {
                    cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = CountryDropDown.SelectedValue;
                    Session["UserCountry"] = CountryDropDown.SelectedValue;

                    string state = "";
                    if (StateDropDownPanel.Visible)
                        state = StateDropDown.SelectedItem.Text;
                    else
                        state = StateTextBox.THE_TEXT;

                    if (state != "")
                    {
                        cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = state;

                    }
                    else
                        cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = DBNull.Value;
                    Session["UserState"] = state;
                    if (CityTextBox.THE_TEXT != "")
                    {
                        cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = CityTextBox.THE_TEXT.Trim();

                    }
                    else
                        cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = DBNull.Value;
                    Session["UserCity"] = CityTextBox.THE_TEXT.Trim();

                    if (CatZipTextBox.THE_TEXT.Trim() != "")
                    {
                        cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = d.GetAllZipsInRadius(RadiusDropDown.SelectedValue,
                            CatZipTextBox.THE_TEXT.Trim(), true);

                    }
                    else
                        cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;
                    Session["UserZip"] = CatZipTextBox.THE_TEXT.Trim();
                    Session["UserRadius"] = RadiusDropDown.SelectedValue;

                    if (CityTextBox.THE_TEXT.Trim() != usersPrevPrefs[0]["CatCity"].ToString() ||
                    state != usersPrevPrefs[0]["CatState"].ToString() ||
                    CountryDropDown.SelectedValue != usersPrevPrefs[0]["CatCountry"].ToString() ||
                    CatZipTextBox.THE_TEXT.Trim() != usersPrevPrefs[0]["CatZip"].ToString() ||
                    RadiusDropDown.SelectedValue != usersPrevPrefs[0]["Radius"].ToString())
                    {
                        resetAds = true;
                    }

                }
                else
                {
                    cmd.Parameters.Add("@catCountry", SqlDbType.Int).Value = DBNull.Value;
                    cmd.Parameters.Add("@catState", SqlDbType.NVarChar).Value = DBNull.Value;
                    cmd.Parameters.Add("@catCity", SqlDbType.NVarChar).Value = DBNull.Value;
                    cmd.Parameters.Add("@catZip", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                cmd.Parameters.Add("@zip", SqlDbType.NVarChar).Value = ZipTextBox.THE_TEXT;
                cmd.Parameters.Add("@textprefs", SqlDbType.Int).Value = prefs;
                cmd.Parameters.Add("@email", SqlDbType.NVarChar).Value = emailPrefs;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value = USER_ID;
                cmd.ExecuteNonQuery();

                CreateCategories(ref resetAds);

                cmd = new SqlCommand("DELETE FROM UserVenues WHERE UserID=@user", conn);
                cmd.Parameters.Add("@user", SqlDbType.Int).Value = USER_ID;
                cmd.ExecuteNonQuery();

                CheckBoxList VenueCheckBoxes = (CheckBoxList)VenuesRadPanel.Items[0].Items[0].FindControl("VenueCheckBoxes");

                if (VenueCheckBoxes != null)
                {
                    for (int i = 0; i < VenueCheckBoxes.Items.Count; i++)
                    {
                        if (VenueCheckBoxes.Items[i].Selected)
                        {
                            cmd = new SqlCommand("INSERT INTO UserVenues (UserID, VenueID) VALUES(@user, @cat)", conn);
                            cmd.Parameters.Add("@user", SqlDbType.Int).Value = USER_ID;
                            cmd.Parameters.Add("@cat", SqlDbType.Int).Value = VenueCheckBoxes.Items[i].Value;
                            cmd.ExecuteNonQuery();
                        }
                    }
                }

                //If reset is set, reset the user ads
                if (resetAds)
                {
                    //DataView dvprevads = d.GetDataDV("SELECT * FROM UserAds WHERE UserID=" + Session["User"].ToString() +
                    //    " AND [DATE]= '" + DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date.ToShortDateString() + "'");

                    //if (dvprevads.Count != 0)
                    //{
                        d.Execute("DELETE FROM UserAds WHERE UserID=" + Session["User"].ToString() +
                            " AND BigAd='True' AND [Date] = '" + DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":")).Date.ToString() + "'");
                    //}
                }

                conn.Close();
                Encryption encrypt = new Encryption();
                Session["Message"] = "Your profile has been updated!";

                //MessageLiteral.Text = "<script type=\"text/javascript\">alert('" + message + "');</script>";

                //MessageRadWindow.NavigateUrl = "Message.aspx?message=" +
                //    encrypt.encrypt(Session["Message"].ToString() +
                //    "<br/><br/><br/><img onclick=\"Search('User.aspx');\" onmouseover=\"this.src='image/DoneSonButtonSelected.png'\" onmouseout=\"this.src='image/DoneSonButton.png'\" src=\"image/DoneSonButton.png\"/>");
                //MessageRadWindow.Visible = true;
                //MessageRadWindowManager.VisibleOnPageLoad = true;

            }
            else
            {
                ErrorLabel.Text = "Email is invalid";
                Encryption encrypt = new Encryption();
                Session["Message"] = "Email is invalid";

                //MessageLiteral.Text = "<script type=\"text/javascript\">alert('" + message + "');</script>";

                //MessageRadWindow.Title = "Invalid Email";
                //MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(Session["Message"].ToString() + "<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)
        {
            ErrorLabel.Text = ex.ToString();
        }

        //RecomUpdate.Update();
    }