protected void doFacebookSignup()
    {
        var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
        var me = (IDictionary<string, object>)fbwc.Get("me");
        string fbName = (string)me["first_name"] + " " + (string)me["last_name"];
        string UserName = fbName.ToLower().Replace(" ", "_").Replace("'", "");/*+
            "_"+_FacebookUid.ToString()*/

        string fql = "Select current_location,pic_square,email from user where uid = " + (string)me["id"];
        JsonArray me2 = (JsonArray)fbwc.Query(fql);
        var mm = (IDictionary<string, object>)me2[0];

        Nullable<int> state = null;
        Nullable<int> country = null;
        string _UserImage = "images/bg_ProfilePhoto.gif";

        if (!string.IsNullOrEmpty((string)mm["pic_square"]))
        {
            _UserImage = (string)mm["pic_square"]; // get user image
        }
        string city = "";
        JsonObject hl = (JsonObject)mm["current_location"];
        if ((string)hl[0] != null)
        {
            city = (string)hl[0];
            UserManager usrmngr = new UserManager();
            object[] param = { (string)hl[2],(string)hl[1] };
            if (usrmngr.GetstateIdByName(param) > 0)
            {
                state = usrmngr.GetstateIdByName(param);
            }
            if (usrmngr.GetCountryIdByName((string)hl[2]) > 0)
            {
                country = usrmngr.GetCountryIdByName((string)hl[2]);
            }

        }

        string password_ = string.Empty;
        string email_ = string.Empty;  //user.proxied_email;
        string result = (string)mm["email"];
        if (!string.IsNullOrEmpty(result))
        {
            email_ = result;
            password_ = RandomPassword.Generate(8, 10);
            password_ = TributePortalSecurity.Security.EncryptSymmetric(password_);

        }
        UserRegistration objUserReg = new UserRegistration();
        TributesPortal.BusinessEntities.Users objUsers =
            new TributesPortal.BusinessEntities.Users(
             UserName, password_,
             (string)me["first_name"], (string)me["last_name"], email_,
             "", false,
             city, state, country, 1, _FacebookUid);
        objUsers.UserImage = _UserImage;
        objUserReg.Users = objUsers;

        /*System.Decimal identity = (System.Decimal)*/
        UserInfoManager umgr = new UserInfoManager();
        umgr.SavePersonalAccount(objUserReg);

        if (objUserReg.CustomError != null)
        {
            messageText.Text=string.Format("<h2>Sorry, {0}.</h2>" +
                "<h3>Those Facebook credentials are already used in some other Your Tribute Account</h3>",
                fbName);
        }
        else
        {
            SessionValue _objSessionValue = new SessionValue(objUserReg.Users.UserId,
                                                             objUserReg.Users.UserName,
                                                             objUserReg.Users.FirstName,
                                                             objUserReg.Users.LastName,
                                                             objUserReg.Users.Email,
                                                             objUserReg.UserBusiness == null ? 1 : 2,
                                                             "Basic",
                                                             objUserReg.Users.IsUsernameVisiable);
            TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance;
            stateManager.Add("objSessionvalue", _objSessionValue, TributesPortal.Utilities.StateManager.State.Session);

            SaveSessionInDB();
            Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID));
            Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain;

            showDialog.Text = "false";
            refreshPage.Text = "true";
        }
    }