private DC_hedgeem_game_state f_sit_at_anonymous_table(enum_theme a_enum_theme )
    {
        HedgeEmLogEvent my_log_event = new HedgeEmLogEvent();
        DC_hedgeem_game_state my_game_state = new DC_hedgeem_game_state();
        my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString();
        my_log_event.p_message = "f_sit_at_anonymous_table";
        log.Debug(_xxx_log_event.ToString());
        string my_endpoint = "Not Set";
        try
        {
            try
            {
    
                // Creates (registers) a new user (HedgeEmPlayer) in the HedgeEm Server.
                // Note this also creates a Personal Table for them (which the HedgeEmTable is returned in the Player object 'p_personal_table_id
                enum_authentication_method my_authentication_method = enum_authentication_method.FACEBOOK;
            my_endpoint = String.Format("{0}/ws_sit_at_anonymous_table/{1},{2},{3},{4}/",
                                                p_current_json_webservice_url_base,
                                                "anon_session_id_123",
                                                83,
                                                a_enum_theme.ToString(),
                                                "FASTPLAY_FLOP");

            my_game_state = (DC_hedgeem_game_state)f_get_object_from_json_call_to_server(my_endpoint, typeof(DC_hedgeem_game_state));
                if (my_game_state.p_error_message != null)
                {
                    if (my_game_state.p_error_message != "")
                    {
                        string my_error_msg = string.Format("Failed trying call 'sit anonymously' to server, Error returned [{0}], Endpoint targeted [{1}]",my_game_state.p_error_message,my_endpoint);
                        throw new Exception(my_error_msg);
                    }
                }

                // If we got here we assume Player was created successfully so store Player ID and continue
                //p_session_player_id = my_game_state.p_player_id;


                // login to the game
                /*Session["p_session_username"] = txt_username.Text;
                Session["password"] = txt_password.Text;
                Session["display_name"] = txt_full_name.Text;
                Session["p_session_personal_table_id"] = my_game_state.p_personal_table_id;
                Session["p_session_username"] = my_game_state.p_username;
                Session["p_session_password"] = txt_password.Text;
                Session["p_session_display_name"] = my_game_state.p_display_name;


                ScriptManager.RegisterStartupScript(Page, GetType(), "OnLoad", "alert('Thank you for registering,your facebook account with HedgeEm. A confirmation mail is sent to your email Id '); if(alert){ window.location='frm_facebook_canvas.aspx';}", true);
                */
                //Page.RegisterStartupScript("OnLoad", "<script>alert('Thank you for registering, you are now logged in an can start to play HedgeEm'); if(alert){ window.location='frm_facebook_canvas.aspx';}</script>");
            }
            catch (Exception ex)
            {
                string my_error_msg_summary = String.Format("Fatal error trying to sit at table anonymously");
                string my_error_msg_detail = String.Format("Error in {0} Reason [{1}]", 
                    my_log_event.p_method_name, 
                    ex.Message.ToString());

                my_log_event.p_message = my_error_msg_detail;

                log.Error(my_log_event.ToString());

                HedgeemerrorPopup my_popup_messageError = new HedgeemerrorPopup();
                my_popup_messageError.p_user_message_str = my_error_msg_summary;
                my_popup_messageError.p_detailed_message_str = my_error_msg_detail;
                my_popup_messageError.p_is_visible = true;

                Place_Holder_Popup_Message.Controls.Add(my_popup_messageError);

                my_popup_messageError.Dispose();

                //newuser.Visible = false;



            }
        }
        catch (Exception ex)
        {
            string my_error_popup = "Error in f_get_free_anonymous_player suald - " + ex.Message.ToString();
       //     ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true);
            log.Error("Error in f_get_free_anonymous_player xxxaawe", new Exception(ex.Message));

            HedgeemerrorPopup my_popup_message = new HedgeemerrorPopup();
            my_popup_message.p_detailed_message_str = "";
            my_popup_message.p_detailed_message_str = my_error_popup;
            my_popup_message.p_is_visible = true;

            //newuser.Visible = false;

            Place_Holder_Popup_Message.Controls.Add(my_popup_message);

            my_popup_message.Dispose();

        }

        return my_game_state;
        
    }
    protected void f_play_anon(enum_theme a_enum_theme)
    {

        // Log that the user has clicked the 'Play now' button.
        HedgeEmLogEvent my_log_event = new HedgeEmLogEvent();
        my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString();
        my_log_event.p_table_id = p_session_personal_table_id;
        my_log_event.p_server_id = p_session_server_id;
        my_log_event.p_message = String.Format("User [{0}] click 'Play Now", p_session_username);
        log.Info(my_log_event.ToString());

        // This fucntion should not be able to be played if the player as not logged in, so test if they have 
        // a 'HedgeEm Session' has been established,  If not exit this fucntion. 
        /*if (!p_valid_session_exists)
        {
            my_log_event.p_message = String.Format("User informed the session is invalide.");
            log.Debug(my_log_event.ToString());

            //ScriptManager.RegisterStartupScript(Page, GetType(), "Alert Message", "alert('You must be logged in to Play this game.');", true);
            ScriptManager.RegisterStartupScript(Page, GetType(), "Alert Message", "document.getElementById('alertmessage').style.display = 'block';", true);
            return;
        }*/


        // xxx Consider uncommenting the following after aslo considering consequence (if you do this when user clicks leave table 
        // they will leave there personal table which you may not want currently as the code currently (Dec 2014) assumes you are sitting at
        // personal table all the time.
        HedgeEmPlayer my_hedgeem_player;
        //my_hedgeem_player = f_get_free_anonymous_player();
        DC_hedgeem_game_state my_game_state = f_sit_at_anonymous_table(a_enum_theme);
        //f_login_anonymously(1201);
        if (my_game_state.p_error_message != null)
        {
            if (my_game_state.p_error_message != "")
            {
                throw new Exception(my_game_state.p_error_message);
            }
        }


        Session["p_session_username"] = my_game_state._seats[0].p_player_name;
        Session["p_session_personal_table_id"] = my_game_state.p_table_id;
        Session["p_session_current_table_id"] = my_game_state.p_table_id;
        Session["p_session_player_id"] = my_game_state._seats[0].p_player_id;
        Session["theme"] = a_enum_theme.ToString();
        Session["role"] = "BASIC_USER";

            f_goto_table(my_game_state.p_table_id);

        // If code reaches here we asssume Table ID and PlayerID is known so sit the person at this table


    }
    //  This function is used to maintain the value of bet placed on each time page is refreshed.
    protected void f_update_hedgeem_control_betting_panels_with_info_from_server()
    {
        /* Get value of Selected_Hand_Panel for bet from textbox and save it in a variable */
        try
        {
            log.Debug("f_update_hedgeem_control_betting_panels_with_info_from_server called");
            // xxxHC value of theme
            my_default_theme = enum_theme.ONLINE;
            if (my_default_theme == enum_theme.ONLINE)
            {
                // Do not show the betting panels 
                // return;
            }
            else
            {
                // Update the display
                string best_odds_token = "";
                //For each betting stage and each hand
                for (enum_betting_stage stage_index = enum_betting_stage.HOLE_BETS; stage_index <= enum_betting_stage.TURN_BETS; stage_index++)
                {

                    for (int hand_index = 0; hand_index < _xxxHCnumber_of_hands; hand_index++)
                    {
                        // xxx should really use Doubles here 
                        _hedgeem_betting_panels[(int)stage_index, hand_index] = new BETTING_PANEL(f_get_number_of_seats());
                        if (_global_game_state_object._hands.Count() != 0)
                        {
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_enum_betting_stage = stage_index;
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odds_percent_draw = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_percent_draw_string;
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odds_percent_win_or_draw = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_percent_win_or_draw_string;
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odds_actual = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_actual_string;
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odds_margin = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_margin_double.ToString();
                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odds_percent_win = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_percent_win_string;
                            if (_global_game_state_object.p_hand_stage_info_list[hand_index].p_is_recommended_hand_to_bet_on_for_best_value_odds == true)
                            {
                                best_odds_token = " *";
                            }
                            else
                            {
                                best_odds_token = "";
                            }
                            double offered_odds = _global_game_state_object.p_hand_stage_info_list[hand_index].p_odds_margin_rounded_double;

                            _hedgeem_betting_panels[(int)stage_index, hand_index].p_odd_margin_rounded = offered_odds;
                            String prefix;
                            if (offered_odds < 0)
                            {
                                prefix = "1/";
                                offered_odds = offered_odds * -1;
                            }
                            else
                            {
                                prefix = "";
                            }
                            if (offered_odds == 0)
                            {

                            }
                            else
                            {

                            }
                        }

                        //// #####################################
                        //// Display the chips for each player seated at the table (where bets have been placed)
                        for (int seat_index = 0; seat_index < f_get_number_of_seats(); seat_index++)
                        {
                            if (_global_game_state_object._seats.Count() == 0)
                            {
                                string chip_icon_resource_name = "chip_icon_seat_" + seat_index.ToString();
                            }
                            // if a bet has been place (i.e. recorded bets for stage, seat and hand combination is > 0)
                            // make the chip icon for the relevant seat visible and update the chip value to match the bet placed
                            //if (my_hedgeem_table._bets[(int)stage_index, seat_index, hand_index] > 0)
                            // xxx hardcode to always execute
                            try
                            {
                                if (true)
                                {
                                    if (_global_game_state_object._recorded_bets.Count() != 0)
                                    {
                                        // Update bet value on 'chip' and show it.  eg. set to 5 for $5 bet
                                        double bet_value_double = _global_game_state_object._recorded_bets[seat_index].p_bet_amount;
                                        _hedgeem_betting_panels[(int)stage_index, hand_index].p_players_bets[seat_index] = bet_value_double;
                                        Place_Holder_Betting_Panel.Controls.Add(_hedgeem_betting_panels[(int)stage_index, hand_index]);
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                string my_error_popup = "alert('Error in f_update_hedgeem_control_betting_panels_with_info_from_server " + e.Message.ToString() + "');";
                                ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true);
                                HedgeEmLogEvent my_log = new HedgeEmLogEvent();
                                my_log.p_message = "Exception caught in f_update_hedgeem_control_betting_panels_with_info_from_server function " + e.Message;
                                my_log.p_method_name = "f_update_hedgeem_control_betting_panels_with_info_from_server";
                                my_log.p_player_id = f_get_player_id();
                                my_log.p_game_id = game_id;
                                my_log.p_table_id = _table_id;
                                log.Error(my_log.ToString());
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            string my_error_popup = "alert('Error in f_update_hedgeem_control_betting_panels_with_info_from_server" + ex.Message.ToString() + "');";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true);
            HedgeEmLogEvent my_log = new HedgeEmLogEvent();
            my_log.p_message = "Exception caught in f_update_hedgeem_control_betting_panels_with_info_from_server function " + ex.Message;
            my_log.p_method_name = "f_update_hedgeem_control_betting_panels_with_info_from_server";
            my_log.p_player_id = f_get_player_id();
            my_log.p_game_id = game_id;
            my_log.p_table_id = _table_id;
            log.Error(my_log.ToString());
        }
    }