private void ConfigureStaySelectorControl()
    {
        StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection];
        HotelSearchRS objAreaListHotelSearchRS = (HotelSearchRS)Session["AreaListHotelSearchRS"];
        HotelSearchRS objPropertyListHotelSearchRS = (HotelSearchRS)Session["PropertyListHotelSearchRS"];

        CountryListItem[] objCountryListItems = this.GetCountryList(objAreaListHotelSearchRS.AreaListItems);
        AreaListItem[] objAreaListItems = new AreaListItem[0];
        HotelListItem[] objHotelListItems = new HotelListItem[0];

        bool bCountrySelected = false;
        bool bAreaSelected = false;
        bool bHotelSelected = false;

        if (objStayCriteriaSelection.CountryCode != null && objStayCriteriaSelection.CountryCode != "")
            bCountrySelected = true;

        if (objStayCriteriaSelection.AreaID != null && objStayCriteriaSelection.AreaID != "")
            bAreaSelected = true;

        if (objStayCriteriaSelection.HotelCode != null && objStayCriteriaSelection.HotelCode != "")
            bHotelSelected = true;

        if (!bCountrySelected && !bAreaSelected && bHotelSelected) // can occurr from deep link page, init country and area selections
        {
            bool bHotelLocated = false;

            for (int i = 0; i < objPropertyListHotelSearchRS.HotelListItems.Length; i++)
            {
                if (objPropertyListHotelSearchRS.HotelListItems[i].HotelCode == objStayCriteriaSelection.HotelCode)
                {
                    if (objPropertyListHotelSearchRS.HotelListItems[i].AreaIDs != null && objPropertyListHotelSearchRS.HotelListItems[i].AreaIDs.Length != 0)
                    {
                        string strCountryCode = this.GetCountryCode(objPropertyListHotelSearchRS.HotelListItems[i].AreaIDs[0], objAreaListHotelSearchRS.AreaListItems);

                        if (strCountryCode != null && strCountryCode != "")
                        {
                            objStayCriteriaSelection.CountryCode = strCountryCode;
                            bCountrySelected = true;

                            objStayCriteriaSelection.AreaID = objPropertyListHotelSearchRS.HotelListItems[i].AreaIDs[0];
                            bAreaSelected = true;

                            Session[Constants.Sessions.StayCriteriaSelection] = objStayCriteriaSelection;

                            bHotelLocated = true;
                            break;
                        }

                        else
                        {
                            break;
                        }

                    }

                    else
                    {
                        break;
                    }

                }

            }

            if (!bHotelLocated)
            {
                objStayCriteriaSelection.HotelCode = "";
                Session[Constants.Sessions.StayCriteriaSelection] = objStayCriteriaSelection;
                bHotelSelected = false;
            }

        }

        if (!bCountrySelected && bAreaSelected) // can occurr from deep link page, init country selection
        {
            string strCountryCode = this.GetCountryCode(objStayCriteriaSelection.AreaID, objAreaListHotelSearchRS.AreaListItems);

            if (strCountryCode != null && strCountryCode != "")
            {
                objStayCriteriaSelection.CountryCode = strCountryCode;
                Session[Constants.Sessions.StayCriteriaSelection] = objStayCriteriaSelection;
                bCountrySelected = true;
            }

        }

        if (bCountrySelected)
        {
            objAreaListItems = this.GetCountryAreaList(objStayCriteriaSelection.CountryCode, objAreaListHotelSearchRS.AreaListItems);
        }

        if (!bCountrySelected && objCountryListItems.Length == 1) // default country selection if only 1 choice
        {
            objStayCriteriaSelection.CountryCode = objCountryListItems[0].CountryCode;
            bCountrySelected = true;

            objAreaListItems = this.GetCountryAreaList(objStayCriteriaSelection.CountryCode, objAreaListHotelSearchRS.AreaListItems);

            objStayCriteriaSelection.AreaID = "";
            bAreaSelected = false;

            objStayCriteriaSelection.HotelCode = "";
            bHotelSelected = false;
        }

        if (bCountrySelected && !bAreaSelected && objAreaListItems.Length == 1)  // default area selection if only 1 choice
        {
            objStayCriteriaSelection.AreaID = objAreaListItems[0].AreaID;
            bAreaSelected = true;

            objStayCriteriaSelection.HotelCode = "";
            bHotelSelected = false;
        }

        if (bCountrySelected && bAreaSelected)
        {
            objHotelListItems = this.GetAreaHotelList(objStayCriteriaSelection.AreaID, objPropertyListHotelSearchRS.HotelListItems);

            if (objHotelListItems.Length == 1) // default hotel selection if only 1 choice
                objStayCriteriaSelection.HotelCode = objHotelListItems[0].HotelCode;
        }

        ucStayCriteriaControl.Clear();

        ucStayCriteriaControl.ID = "StayCriteriaSelector";
        ucStayCriteriaControl.StayCriteriaSelectorType = StayCriteriaSelectorType.HotelSearch;
        ucStayCriteriaControl.StayCriteriaSelectorMode = StayCriteriaSelectorMode.New;
        ucStayCriteriaControl.CountryListItems = objCountryListItems;
        ucStayCriteriaControl.AreaListItems = objAreaListItems;
        ucStayCriteriaControl.HotelListItems = objHotelListItems;
        ucStayCriteriaControl.StayCriteriaSelection = objStayCriteriaSelection;
        ucStayCriteriaControl.HotelDescriptiveInfo = null;

        return;
    }
    private void ConfigureStaySelectorControl()
    {
        StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection];
        HotelSearchRS objAreaListHotelSearchRS = (HotelSearchRS)Session["AreaListHotelSearchRS"];
        HotelSearchRS objPropertyListHotelSearchRS = (HotelSearchRS)Session["PropertyListHotelSearchRS"];
        HotelDescriptiveInfoRS objHotelDescriptiveInfoRS = (HotelDescriptiveInfoRS)Session["HotelDescriptiveInfoRS"];

        CountryListItem[] objCountryListItems = new CountryListItem[0];
        AreaListItem[] objAreaListItems = new AreaListItem[0];
        HotelListItem[] objHotelListItems = new HotelListItem[0];

        if (ConfigurationManager.AppSettings["EnableHotelSearch"] == "1")
        {
            objCountryListItems = this.GetCountryList(objAreaListHotelSearchRS.AreaListItems);
            objAreaListItems = this.GetCountryAreaList(objStayCriteriaSelection.CountryCode, objAreaListHotelSearchRS.AreaListItems);
            objHotelListItems = this.GetAreaHotelList(objStayCriteriaSelection.AreaID, objPropertyListHotelSearchRS.HotelListItems);
        }

        else
        {
            objHotelListItems = objPropertyListHotelSearchRS.HotelListItems;
        }

        HotelDescriptiveInfo objHotelDescriptiveInfo = new HotelDescriptiveInfo();

        if (objHotelDescriptiveInfoRS.HotelDescriptiveInfos.Length != 0)
        {
            objHotelDescriptiveInfo = objHotelDescriptiveInfoRS.HotelDescriptiveInfos[0];
        }

        ucStayCriteriaControl.Clear();

        ucStayCriteriaControl.ID = "StayCriteriaSelector";

        if (ConfigurationManager.AppSettings["EnableHotelSearch"] == "1")
            ucStayCriteriaControl.StayCriteriaSelectorType = StayCriteriaSelectorType.HotelSearch;
        else
            ucStayCriteriaControl.StayCriteriaSelectorType = StayCriteriaSelectorType.HotelList;

        ucStayCriteriaControl.CountryListItems = objCountryListItems;
        ucStayCriteriaControl.AreaListItems = objAreaListItems;
        ucStayCriteriaControl.HotelListItems = objHotelListItems;
        ucStayCriteriaControl.StayCriteriaSelectorMode = StayCriteriaSelectorMode.Change;
        ucStayCriteriaControl.StayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection];
        ucStayCriteriaControl.HotelDescriptiveInfo = objHotelDescriptiveInfo;

        return;
    }
    // Other global resource related support methods
    public CountryListItem[] GetCountryList(AreaListItem[] objAreaListItems)
    {
        List<string> lCountryCodes = new List<string>();

        for (int i = 0; i < objAreaListItems.Length; i++)
        {
            if (!lCountryCodes.Contains(objAreaListItems[i].CountryCode))
                lCountryCodes.Add(objAreaListItems[i].CountryCode);
        }

        lCountryCodes.Sort();

        List<CountryListItem> lCountryListItems = new List<CountryListItem>();

        for (int i = 0; i < lCountryCodes.Count; i++)
        {
            CountryListItem liCountryListItem = new CountryListItem();
            lCountryListItems.Add(liCountryListItem);

            liCountryListItem.CountryCode = lCountryCodes[i];
            liCountryListItem.CountryName = this.GetCountryName(lCountryCodes[i]);
        }

        return lCountryListItems.ToArray();
    }
    public string GetCountryCode(string strAreaID, AreaListItem[] objAreaListItems)
    {
        for (int i = 0; i < objAreaListItems.Length; i++)
        {
            if (objAreaListItems[i].AreaID == strAreaID)
            {
                return objAreaListItems[i].CountryCode;
            }

        }

        return "";
    }
    public AreaListItem[] GetCountryAreaList(string strCountryCode, AreaListItem[] objAreaListItems)
    {
        List<AreaListItem> lAreaListItems = new List<AreaListItem>();

        for (int i = 0; i < objAreaListItems.Length; i++)
        {
            if (objAreaListItems[i].CountryCode == strCountryCode)
                lAreaListItems.Add(objAreaListItems[i]);
        }

        return lAreaListItems.ToArray();
    }
    private void ConfigureSearchHotelSelectorControl()
    {
        HotelSearchRS objHotelSearchRS = (HotelSearchRS)Session["AreaListHotelSearchRS"];
        HotelDescriptiveInfoRS objHotelDescriptiveInfoRS = (HotelDescriptiveInfoRS)Session["SearchHotelDescriptiveInfoRS"];
        HotelAvailabilityRS objSearchHotelAvailabilityCalendarRS = (HotelAvailabilityRS)Session["SearchHotelAvailabilityCalendarRS"];
        StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection];

        AreaListItem objAreaListItem = new AreaListItem();

        for (int i = 0; i < objHotelSearchRS.AreaListItems.Length; i++)
        {
            if (objHotelSearchRS.AreaListItems[i].AreaID == objStayCriteriaSelection.AreaID)
            {
                objAreaListItem = objHotelSearchRS.AreaListItems[i];
                break;
            }

        }

        if (ConfigurationManager.AppSettings["EnableRoomRateGridModel"] != "1")
        {
            string strSearchHotelSelectorItemControlPath = ConfigurationManager.AppSettings["SearchHotelSelectorItemControl.ascx"];

            ucSearchHotelSelectorControl.Clear();

            ucSearchHotelSelectorControl.ID = "SearchHotelSelectorControl";

            for (int hi = 0; hi < objHotelDescriptiveInfoRS.HotelDescriptiveInfos.Length; hi++)
            {
                AvailabilityCalendar objAvailabilityCalendar = null;

                for (int i = 0; i < objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos.Length; i++)
                {
                    if (objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos[i].HotelCode == objHotelDescriptiveInfoRS.HotelDescriptiveInfos[hi].HotelCode)
                    {
                        objAvailabilityCalendar = objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos[i].AvailabilityCalendar;
                        break;
                    }

                }

                SearchHotelSelectorItemControl ucSearchHotelSelectorItemControl = (SearchHotelSelectorItemControl)LoadControl(strSearchHotelSelectorItemControlPath);
                ucSearchHotelSelectorControl.Add(ucSearchHotelSelectorItemControl);

                ucSearchHotelSelectorItemControl.ID = "SearchHotelSelectorItem" + ((int)(hi + 1)).ToString();
                ucSearchHotelSelectorItemControl.HotelDescriptiveInfo = objHotelDescriptiveInfoRS.HotelDescriptiveInfos[hi];

                if (objAvailabilityCalendar != null)
                    ucSearchHotelSelectorItemControl.ShowSpecialRatesIndicator = objAvailabilityCalendar.RequestedRatesAvailable;
                else
                    ucSearchHotelSelectorItemControl.ShowSpecialRatesIndicator = false;
            }

        }

        else
        {
            DateTime dtRateGridStartDate = (DateTime)Session["SearchRateGridStartDate"];

            string strSearchHotelSelectorGridItemControlPath = ConfigurationManager.AppSettings["SearchHotelSelectorGridItemControl.ascx"];

            ucSearchHotelSelectorGridControl.Clear();

            ucSearchHotelSelectorGridControl.ID = "SearchHotelSelectorGridControl";
            ucSearchHotelSelectorGridControl.AreaListItem = objAreaListItem;
            ucSearchHotelSelectorGridControl.GridTodayDate = TZNet.ToLocal(WbsUiHelper.GetTimeZone(""), DateTime.UtcNow).Date;
            ucSearchHotelSelectorGridControl.GridStartDate = dtRateGridStartDate.Date;
            ucSearchHotelSelectorGridControl.GridNumberDays = this.NumberDaysInRateGrid;
            ucSearchHotelSelectorGridControl.GridSelectedStartDate = objStayCriteriaSelection.ArrivalDate;
            ucSearchHotelSelectorGridControl.GridSelectedEndDate = objStayCriteriaSelection.DepartureDate.AddDays(-1);

            for (int hi = 0; hi < objHotelDescriptiveInfoRS.HotelDescriptiveInfos.Length; hi++)
            {
                AvailabilityCalendar objAvailabilityCalendar = null;

                for (int i = 0; i < objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos.Length; i++)
                {
                    if (objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos[i].HotelCode == objHotelDescriptiveInfoRS.HotelDescriptiveInfos[hi].HotelCode)
                    {
                        objAvailabilityCalendar = objSearchHotelAvailabilityCalendarRS.HotelRoomAvailInfos[i].AvailabilityCalendar;
                        break;
                    }

                }

                if (objAvailabilityCalendar != null)
                {
                    SearchHotelSelectorGridItemControl ucSearchHotelSelectorGridItemControl = (SearchHotelSelectorGridItemControl)LoadControl(strSearchHotelSelectorGridItemControlPath);
                    ucSearchHotelSelectorGridControl.Add(ucSearchHotelSelectorGridItemControl);

                    ucSearchHotelSelectorGridItemControl.ID = "SearchHotelSelectorGridItem" + ((int)(hi + 1)).ToString();
                    ucSearchHotelSelectorGridItemControl.GridStartDate = ucSearchHotelSelectorGridControl.GridStartDate;
                    ucSearchHotelSelectorGridItemControl.GridNumberDays = ucSearchHotelSelectorGridControl.GridNumberDays;
                    ucSearchHotelSelectorGridItemControl.GridHiLoRates = objAvailabilityCalendar.HiLoRates;
                    ucSearchHotelSelectorGridItemControl.HotelDescriptiveInfo = objHotelDescriptiveInfoRS.HotelDescriptiveInfos[hi];
                    ucSearchHotelSelectorGridItemControl.ShowSpecialRatesIndicator = objAvailabilityCalendar.RequestedRatesAvailable;
                }

            }

        }

        return;
    }
    private void ConfigureStaySelectorControl()
    {
        StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection];
        HotelSearchRS objPropertyListHotelSearchRS = (HotelSearchRS)Session["PropertyListHotelSearchRS"];

        CountryListItem[] objCountryListItems = new CountryListItem[0];
        AreaListItem[] objAreaListItems = new AreaListItem[0];
        HotelListItem[] objHotelListItems = objPropertyListHotelSearchRS.HotelListItems;

        if (objHotelListItems == null)
            return;

        if (objHotelListItems.Length == 1) // default hotel selection if only 1 choice
            objStayCriteriaSelection.HotelCode = objHotelListItems[0].HotelCode;

        ucStayCriteriaControl.Clear();

        ucStayCriteriaControl.ID = "StayCriteriaSelector";
        ucStayCriteriaControl.StayCriteriaSelectorType = StayCriteriaSelectorType.HotelList;
        ucStayCriteriaControl.StayCriteriaSelectorMode = StayCriteriaSelectorMode.New;
        ucStayCriteriaControl.CountryListItems = objCountryListItems;
        ucStayCriteriaControl.AreaListItems = objAreaListItems;
        ucStayCriteriaControl.HotelListItems = objHotelListItems;
        ucStayCriteriaControl.StayCriteriaSelection = objStayCriteriaSelection;
        ucStayCriteriaControl.HotelDescriptiveInfo = null;

        return;
    }