/// <summary>
    /// Method is used to get/maintain values i.e Pays Description , Bet Amount value etc of all cards 
    /// as well as bets values along with their CSS.
    /// Show the Icon Status according to the current stage of Game.
    /// Also check which Card is Winner or Dead
    /// </summary>
    /// <returns></returns>
    private void f_update_hedgeem_control_hand_panels_with_info_from_server()
    {
        log.Debug("f_update_hedgeem_control_hand_panels_with_info_from_server called");
        try
        {
            for (int hand_index = 0; hand_index < _xxxHCnumber_of_hands; hand_index++)
            {
                // call to get HedgeEmHandStageInfo for given hand index at given stage
                HedgeEmHandStageInfo my_hedgeem_hand_stage_info = f_get_hand_stage_info_object_for_stage_and_hand(_global_game_state_object.p_current_state_enum, hand_index);

                if (_global_game_state_object._hands.Count() == 0)
                {
                    p_hand_card1 = "ZZ";
                    p_hand_card2 = "ZZ";
                }

                else
                {
                    p_hand_card1 = _global_game_state_object._hands[hand_index].Substring(0, 2);

                    p_hand_card2 = _global_game_state_object._hands[hand_index].Substring(2, 2);
                }
                // Create a new HedgeEm Control that will be used to display the status of one Hand in the Web page.
                int my_num_stages = _int_number_of_betting_stages;
                int my_num_seats = f_get_number_of_seats();

                _hedgeem_hand_panels[hand_index] = new hedgeem_hand_panel(my_num_stages, my_num_seats);
                // Hand_Index
                _hedgeem_hand_panels[hand_index].p_hand_index = hand_index;

                // Card 1
                _hedgeem_hand_panels[hand_index].p_card1 = p_hand_card1;

                // Card 2 
                _hedgeem_hand_panels[hand_index].p_card2 = p_hand_card2;

                _hedgeem_hand_panels[hand_index].p_current_betting_stage = f_get_current_betting_stage();

                // xxx Need to investigate difference between .p_winning_hands and .p_is_hand_a_winner_at_this_stage;

                //_hedgeem_hand_panels[hand_index].p_is_winner = my_hedgeem_hand_stage_info.p_is_hand_a_winner_at_this_stage;
                //_hedgeem_hand_panels[hand_index].p_is_winner = my_hedgeem_hand_stage_info.p_winning_hands;
                //_hedgeem_hand_panels[hand_index].p_is_dead = my_hedgeem_hand_stage_info.p
                /*
                 * bool winning_hands = Convert.ToBoolean(f_get_object_from_json_call_to_server("get_winning_hands/" + _table_id.ToString() + "," + hand_index.ToString(), null));
                if (_game_state == enum_game_state.STATUS_RIVER)
                {
                    _hedgeem_hand_panels[hand_index].p_is_winner = winning_hands;
                    _hedgeem_hand_panels[hand_index].p_is_dead = !winning_hands;
                }*/

                /* Will show the Status_icon i.e can't lose icon, best value icon, favourite icon etc according to current stage 
                 * but except the Non_Betting_Stage */

                enum_betting_stage my_betting_stage = f_get_current_betting_stage();

                if (my_betting_stage == enum_betting_stage.NON_BETTING_STAGE)
                {
                    if (_game_state == enum_game_state.STATUS_RIVER)
                    {
                        {
                            // xxx Need to investigate difference between .p_winning_hands and .p_is_hand_a_winner_at_this_stage;

                            bool my_is_winner = _hedgeem_hand_panels[hand_index].p_is_winner = my_hedgeem_hand_stage_info.p_winning_hands;
                            bool my_is_winner2 = _hedgeem_hand_panels[hand_index].p_is_winner = my_hedgeem_hand_stage_info.p_is_hand_a_winner_at_this_stage;

                            _hedgeem_hand_panels[hand_index].p_is_winner = my_is_winner2;
                            _hedgeem_hand_panels[hand_index].p_is_dead = !my_is_winner2;
                            _hedgeem_hand_panels[hand_index].p_description = my_hedgeem_hand_stage_info.p_hand_description_short;
                        }
                    }
                    else
                    {
                        // Hand description 
                        int my_hand_number = hand_index + 1;
                        _hedgeem_hand_panels[hand_index].p_description = "Hand " + my_hand_number.ToString();
                    }

                }
                else
                {
                    //Show can't lose icon
                    bool is_this_hand_going_to_win = my_hedgeem_hand_stage_info.p_is_hand_that_cant_lose_at_this_stage;
                    _hedgeem_hand_panels[hand_index].p_is_dead_cert = is_this_hand_going_to_win;
                    p_inplay_status = my_hedgeem_hand_stage_info.p_hand_inplay_status;

                    //Show best value icon
                    //bool is_this_hand_best_value = p_recommended_hand_to_bet_on_for_best_value_odds[hand_index * xxx_HC_int_number_of_betting_stages + (int)_betting_stage];
                    bool is_this_hand_best_value = my_hedgeem_hand_stage_info.p_is_recommended_hand_to_bet_on_for_best_value_odds;
                    _hedgeem_hand_panels[hand_index].p_is_best_value = is_this_hand_best_value;

                    //Show favourite
                    bool is_this_hand_favourite = my_hedgeem_hand_stage_info.p_is_hand_that_is_favourite;
                    _hedgeem_hand_panels[hand_index].p_is_favourite = is_this_hand_favourite;

                    // Hand description 
                    _hedgeem_hand_panels[hand_index].p_description = my_hedgeem_hand_stage_info.p_hand_description_short;

                    // PAYS_Amount
                    _hedgeem_hand_panels[hand_index].p_pays_amount = (float)my_hedgeem_hand_stage_info.p_odds_margin_rounded_double;

                    string payout_string;
                    string[] new_payout_string;
                    float new_payout_value = 0;
                    if (_hedgeem_hand_panels[hand_index].p_payout_string == "")
                    {
                        new_payout_value = 0;
                    }
                    else
                    {
                        payout_string = _hedgeem_hand_panels[hand_index].p_payout_string;
                        new_payout_string = payout_string.Split('£');
                        new_payout_value = float.Parse(new_payout_string[1]);
                    }

                    // Gets value of pay out amount in session for all hands which will be used in place bet widget to show pay amount
                    Session["pays_amount_" + hand_index] = new_payout_value;
                    enum_hand_in_play_status my_hand_status = p_inplay_status;
                    if (my_hand_status == enum_hand_in_play_status.IN_PLAY_DEAD)
                    {
                        _hedgeem_hand_panels[hand_index].p_is_dead = true;
                    }
                    else
                    {
                        _hedgeem_hand_panels[hand_index].p_is_dead = false;
                    }

                }
                // Add the created control to the Webpage (HedgeEmTable.aspx) for display to the user.
                _hedgeem_hand_panels[hand_index].ID = "auto_div_hand_id" + hand_index;
                _hedgeem_hand_panels[hand_index].CssClass = "auto_div_hand_id_class";
                Place_Holder_Hand_Panel.Controls.Add(_hedgeem_hand_panels[hand_index]);
            }
        }

        catch (Exception ex)
        {
            string my_error_popup = "alert('Error in f_update_hedgeem_control_hand_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_hand_panels_with_info_from_server function " + ex.Message;
            my_log.p_method_name = "f_update_hedgeem_control_hand_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());
            // xxxeh - this error does not pop up
            throw new Exception(my_error_popup);
        }

    }
    public string[] f_update_hedgeem_control_hand_panels()
    {

        // Create a 'log event' object to audit execution
        HedgeEmLogEvent my_log_event = new HedgeEmLogEvent();
        my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString();
        my_log_event.p_message = "Method Entered.";
        my_log_event.p_player_id = p_session_player_id;
        //my_log_event.p_table_id = p_session_personal_table_id;
        log.Debug(my_log_event.ToString());


        log.Debug("f_update_hedgeem_control_hand_panels_with_info_from_server called");
        List<string> details = new List<string>();
        DC_hedgeem_game_state _global_game_state_object = new DC_hedgeem_game_state();
        int p_session_personal_table_id = 2058;



        object obj = null;
        HttpWebRequest request;
        String my_service_url = "not set";
        my_service_url = WebConfigurationManager.AppSettings["hedgeem_server_default_webservice_url"];

        request = WebRequest.Create(my_service_url + "get_game_state_object/2058") as HttpWebRequest;


        // Get response
        if (request != null)
            using (var response = request.GetResponse() as HttpWebResponse)
            {
                if (response != null)
                {
                    Stream stream = response.GetResponseStream();

                    if (stream != null)
                    {


                        var reader = new StreamReader(stream);
                        try
                        {
                            string json = reader.ReadToEnd();
                            // Check if stream is empty, if it is throw and exception
                            if (json.Length == 0)
                            {
                                String my_error_msg = String.Format("JSON string has been returned empty for URI endpoint [{0}]", request.Address);
                                throw new Exception(my_error_msg);
                            }
                            var ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
                            if (typeof(DC_hedgeem_game_state) != null)
                            {
                                var ser = new DataContractJsonSerializer(typeof(DC_hedgeem_game_state));
                                obj = ser.ReadObject(ms);
                            }
                            else
                            {
                                obj = json;
                            }
                        }

                        finally
                        {
                            reader.Close();
                        }
                    }
                }
            }


        _global_game_state_object = (DC_hedgeem_game_state)obj;



        int my_number_of_seats = _global_game_state_object.p_number_of_seats_int;
        try
        {
            string p_hand_card1 = "ZZ";
            string p_hand_card2 = "ZZ";
            //ArrayList list = new ArrayList();
            //int number_of_hands = _global_game_state_object.p_number_of_hands_int;
            int number_of_hands = 4;
            for (int hand_index = 0; hand_index < number_of_hands; hand_index++)
            {
                // call to get HedgeEmHandStageInfo for given hand index at given stage
                //  HedgeEmHandStageInfo my_hedgeem_hand_stage_info = f_get_hand_stage_info_object_for_stage_and_hand(_global_game_state_object.p_current_state_enum, hand_index);

                if (_global_game_state_object._hands.Count() == 0)
                {
                    p_hand_card1 = "ZZ";
                    p_hand_card2 = "ZZ";
                }

                else
                {
                    p_hand_card1 = _global_game_state_object._hands[hand_index].Substring(0, 2);

                    p_hand_card2 = _global_game_state_object._hands[hand_index].Substring(2, 2);
                }
                // Create a new HedgeEm Control that will be used to display the status of one Hand in the Web page.
                int _int_number_of_betting_stages = _global_game_state_object.p_number_of_betting_stages_int;
                int my_num_stages = _int_number_of_betting_stages;
                hedgeem_hand_panel[] _hedgeem_hand_panels;

                _hedgeem_hand_panels = new hedgeem_hand_panel[number_of_hands];

                _hedgeem_hand_panels[hand_index] = new hedgeem_hand_panel(my_num_stages, my_number_of_seats);
                //// Hand_Index
                _hedgeem_hand_panels[hand_index].p_hand_index = hand_index;

                // Card 1
                _hedgeem_hand_panels[hand_index].p_card1 = p_hand_card1;

                // Card 2 
                _hedgeem_hand_panels[hand_index].p_card2 = p_hand_card2;

                string st = _hedgeem_hand_panels[hand_index].p_card_image_filename_card1;
                string st1 = _hedgeem_hand_panels[hand_index].p_card_image_filename_card2;

                //string st = p_hand_card1;
                //string st1 = p_hand_card2;

                details.Add(st);
                details.Add(st1);

                //list.Add(st);
                //list.Add(st1);

                // Add the created control to the Webpage (HedgeEmTable.aspx) for display to the user.
                //_hedgeem_hand_panels[hand_index].ID = "auto_div_hand_id" + hand_index;
                //_hedgeem_hand_panels[hand_index].CssClass = "auto_div_hand_id_class";
                // Place_Holder_Hand_Panel.Controls.Add(_hedgeem_hand_panels[hand_index]);

            }

        }


        catch (Exception ex)
        {
            string my_error_popup = "alert('Error in f_update_hedgeem_control_hand_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_hand_panels_with_info_from_server function " + ex.Message;
            my_log.p_method_name = "f_update_hedgeem_control_hand_panels_with_info_from_server";
            // my_log.p_player_id = Convert.ToInt32(Session["p_session_player_id"]);
            // my_log.p_game_id = game_id;
            //       my_log.p_table_id = p_session_personal_table_id;
            log.Error(my_log.ToString());
            // xxxeh - this error does not pop up
            throw new Exception(my_error_popup);

        }
        // JavaScriptSerializer TheSerializer = new JavaScriptSerializer();
        // var TheJson = TheSerializer.Serialize(details);
        return details.ToArray();
    }