document.write('<link href=\"http://phgoffers.com/widgets/SearchWidget/css/calendar.BC.css\" type=\"text/css\" rel=\"Stylesheet\" />');
document.write('<link href=\"http://phgoffers.com/widgets/SearchWidget/css/BC-theme/jquery.BC.css\" type=\"text/css\" rel=\"Stylesheet\" />');
﻿
//first and foremost create the html elements that will hold the search
//and the extra jquery calls
(function($) {
    $.widget("ui.combobox", {
        _create: function() {
            var self = this;
            var select = this.element.hide();
            var input = $("<input>")
					.insertAfter(select)
					.autocomplete({
					    source: function(request, response) {
					        var matcher = new RegExp(request.term, "i");
					        response(select.children("option").map(function() {
					            var text = $(this).text();
					            if (!request.term || matcher.test(text))
					                return {
					                    id: $(this).val(),
					                    label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
					                    value: text
					                };
					        }));
					    },
					    delay: 0,
					    select: function(e, ui) {
					        if (!ui.item) {
					            // remove invalid value, as it didn't match anything
					            $(this).val("");
					            return false;
					        }
					        $(this).focus();
					        select.val(ui.item.id);
					        PHGInfo.hotelChange();
					        self._trigger("selected", null, {
					            item: select.find("[value='" + ui.item.id + "']")
					        });

					    },
					    minLength: 0
					})
					.val(hotelHint)
					.focusin(function(){
                                          if($(this).val() == hotelHint){
                                            $(this).val('');
                                          }
                                        })
                                        .focusout(function(){
                                          if($(this).val() == ''){
                                            $(this).val(hotelHint);
                                          }
                                        })
					.addClass("ui-widget ui-widget-content");
        }
    });

})(jQuery);
jQuery.noConflict();
jQuery(document).ready(function() {
    jQuery("#offerCode")
    .focusin(function(){
      if(jQuery(this).val() == offerHint){
        jQuery(this).val('');
      }
    })
    .focusout(function(){
      if(jQuery(this).val() == ''){
        jQuery(this).val(offerHint);
      }
    });
    jQuery("arrive").hide();
    jQuery("#arrive").datepicker({
        buttonImageOnly: true,
        showButtonPanel: true,
        numberOfMonths: 2
    })
    .focusin(function(){
      if(jQuery(this).val() == arrivalHint){
        jQuery(this).val('');
      }
    })
    .focusout(function(){
      if(jQuery(this).val() == ''){
        jQuery(this).val(arrivalHint);
      }
    });
    jQuery('#calendarImage').click(function(){
      jQuery("#arrive").focus();
    });
    jQuery(function() {
       //not yet my precious - your time will come
    jQuery("#searchHotelSelect").combobox();
       //ATTACK!
      
    });
    if(PHGInfo.currentHotelID != ""){
      jQuery('#searchButton').val('Check Availability');
    }
});





//now for the DOM
document.write("<div id=\"searchWidget\">");

//cloak on property pages
document.write("                <div id=\"searchWidgetHeader\"> </div>");
document.write("                <div class=\"searchItems\">");
document.write("                                <div class=\"searchElement\">");
document.write("                                    <select class=\"searchHotel\" id=\"searchHotelSelect\">");
document.write("                                    </select>");
document.write("                                </div>");
document.write("                                <div class=\"searchElement\">");
document.write("                                    <select class = \"searchCity\" id = \"searchCitySelect\">"); 
document.write("                                    </select>"); 
document.write("                                </div>");
document.write("                                <div class=\"searchElement\">"); 
document.write("                                    <select class = \"searchState\" id = \"searchStateSelect\" >");
document.write("                                    </select>");
document.write("                                </div>");
document.write("                                <div class=\"searchElement\">");
document.write("                                    <select class = \"searchCountry\" id = \"searchCountrySelect\"> ");
document.write("                                    </select>");
document.write("                                </div>");
document.write("                 </div>");

//hide by default
document.write("                <div id=\"checkAvailabilityImgContainer\"> </div>");

//start calendar options
document.write("                <div id=\"calendarOptions\">");

//there is a visibility setting here
document.write("                    <div class=\"arriveIntro\">Arrival<span class=\"arrivalOptional\"> (Optional)</span></div>");
document.write("                            <input type=\"text\" id=\"arrive\" class=\"arriveText\" style=\"\" value=\"MM / DD / YYYY\" />");
document.write("                            <img alt=\"\" id=\"calendarImage\" src=\"http://phgoffers.com/widgets/SearchWidget/images/calendar.jpg\" />");
document.write("                            <br />");

//rick you bastage... you used tables, now you get to set the style in css for them!
document.write("                            <table class=\"calendartable\" cellpadding=\"0\" cellspacing=\"0\">");
document.write("                                <tr>");
document.write("                                    <td class=\"numberOfNightsText\">Nights</td>");
document.write("                                    <td class=\"adultsText\">Adults</td>");
document.write("                                    <td class=\"childrenText\">Children</td>");
document.write("                                 <tr>");
document.write("                                 <tr>");
document.write("                                        <td class=\"numberofnightscell\">");
document.write("                                            <select name=\"numberOfNights\" id=\"numberOfNights\" class=\"numberOfNights\">");
document.write("                                                <option value=\"1\"></option>");
document.write("                                                <option value=\"1\" selected=\"selected\">1</option>");
document.write("                                                <option value=\"2\">2</option>");
document.write("                                                <option value=\"3\">3</option>");
document.write("                                                <option value=\"4\">4</option>");
document.write("                                                <option value=\"5\">5</option>");
document.write("                                                <option value=\"6\">6</option>");
document.write("                                                <option value=\"7\">7</option>");
document.write("                                                <option value=\"8\">8</option>");
document.write("                                                <option value=\"9\">9</option>");
document.write("                                                <option value=\"10\">10</option>");
document.write("                                                <option value=\"11\">11</option>");
document.write("                                                <option value=\"12\">12</option>");
document.write("                                                <option value=\"13\">13</option>");
document.write("                                                <option value=\"14\">14</option>");
document.write("                                                <option value=\"15\">15</option>");
document.write("                                                <option value=\"16\">16</option>");
document.write("                                                <option value=\"17\">17</option>");
document.write("                                                <option value=\"18\">18</option>");
document.write("                                                <option value=\"19\">19</option>");
document.write("                                                <option value=\"20\">20</option>");
document.write("                                            </select>");
document.write("                                        </td>");
document.write("                                        <td class=\"adultscell\">");
document.write("		                                    <select name=\"adults\" class=\"adults\" id=\"adults\">");
document.write("                                                <option value=\"1\"></option>");
document.write("        	                                    <option value=\"1\" selected=\"selected\">1</option>");
document.write("                                                <option value=\"2\">2</option>");
document.write("                                                <option value=\"3\">3</option>");
document.write("                                                <option value=\"4\">4</option>");
document.write("                                                <option value=\"5\">5</option>");
document.write("                                                <option value=\"6\">6</option>");
document.write("                                                <option value=\"7\">7</option>");
document.write("                                                <option value=\"8\">8</option>");
document.write("                                                <option value=\"9\">9</option>");
document.write("                                                <option value=\"10\">10</option>");
document.write("                                            </select>");
document.write("                                        </td>");
document.write("                                        <td class=\"childrencell\">");
document.write("                                            <select name=\"children\" class=\"children\" id=\"children\">");
document.write("                                                <option value=\"\"></option>");
document.write("                                                <option value=\"1\">1</option>");
document.write("                                                <option value=\"2\">2</option>");
document.write("                                                <option value=\"3\">3</option>");
document.write("                                                <option value=\"4\">4</option>");
document.write("                                                <option value=\"5\">5</option>");
document.write("                                            </select>");
document.write("                                        </td>");
document.write("                                    </tr>");
document.write("                                </table>");

document.write("                                <input type=\"text\" id=\"offerCode\" class=\"offerCode\" value=\"Enter Offer Code\" />");
//close calendar options div
document.write("                </div>");
document.write("                <div class=\"searchButton\">");
document.write("                     <input type=\"button\" id = \"searchButton\" value=\"Search\" />");
document.write("                </div>");

//more cloakness. we're surrounded
//document.write("                <div class=\"advancedSearch\"><a href=\"advancedSearchURL\" class=\"advancedSearchLink\">Advanced Search</a></div>");
document.write("                <div class=\"localInfoWidget\"><img src=\"http://preferredhotelgroup.com/PHG/images/point.gif\" class=\"localInfoWidgetPlaceholder\" border=\"0\" /></div>");

document.write("                <div class=\"footerLink\">");
document.write("                     <a id=\"checkreslink\" href=\"\">Check My Reservations</a>");
document.write("                </div>");

//document.write("                <div class=\"findOtherHotelsContainer\"><input type=\"button\" id = \"findOtherHotelsButton\" value=\"Find Other Hotels\" /></div>");

//close the search widget div
document.write("</div>");


function PHGBrand(baseURL,searchpage,searchbook,hotelURL,hotelbook,checkReservation,findHotelButtonLink,loginRequired)
{
    //this.bookingEngineBaseURL = "https://indecorp.ibe.netbooker.com/web/FrontController.nb4?module=PropertySearch&execute=yes";
	this.bookingEngineBaseURL = "https://www.phgsecure.com/IBE/brandRedirect.ashx?f=b";
    this.brandbaseURL = baseURL;
   // this.searchBookURL = this.bookingEngineBaseURL + "&locale=en&operation=AreaPropertyAvailabilitySearchResult" + searchbook;
   this.searchBookURL = this.bookingEngineBaseURL + searchbook;
    this.searchPageURL = this.brandbaseURL + searchpage;
    this.hotelPageURL = this.brandbaseURL + hotelURL;
    //this.hotelBookURL = this.bookingEngineBaseURL + "&operation=SinglePropertySearchResult" + hotelbook;
	this.hotelBookURL = this.bookingEngineBaseURL + hotelbook;
    //this.checkReservationURL = "https://indecorp.ibe.netbooker.com/web/FrontController.nb4?module=Reservation&operation=RetrieveReservationRV&execute=yes&locale=en" + checkReservation;
	this.checkReservationURL = "https://www.phgsecure.com/IBE/reservationBrandRedirect.ashx?f=b" + checkReservation;
    this.findHotelURL = this.brandbaseURL + findHotelButtonLink;
	this.mustLogIn = loginRequired;

};

var PHGInfo = {};
PHGInfo.brands = new Array("PH", "BC", "WR", "XL", "PHG", "default");

PHGInfo.brands["PHG"] = new PHGBrand("http://www.preferredhotelgroup.com/PHG",
                                     "/search/search.aspx",
                                     "&brandCode=PV",
                                     "/hotels/default.ashx?fml=0",
                                     "&brandCode=PV",
                                     "&brandCode=PV","",false); //"/hotels/index.aspx?fml=0",
PHGInfo.brands["default"] = new PHGBrand("http://www.preferredhotels.com/preferred_hotel",
                                     "/search/search_results.aspx",
                                     "&brandCode=PV",
                                     "/hotels/index.aspx?fml=0",
                                     "&brandCode=PV",
                                     "&brandCode=PV","",false);
PHGInfo.brands["PH"] = new PHGBrand("http://www.preferredhotels.com",
                                     "/preferred_hotel/search/search_results.aspx",
                                     "&brandCode=PH",
                                     "/PHG/hotels/default.ashx?fml=0",
                                     "&brandCode=PH",
                                     "&brandCode=PH","",false);
PHGInfo.brands["BC"] = new PHGBrand("http://www.preferredboutique.com/preferred_boutique",
                                     "/search/search_results.aspx",
                                     "&brandCode=BC",
                                     "/hotels/index.aspx?fml=0",
                                     "&brandCode=BC",
                                     "&brandCode=BC","",false);
    
PHGInfo.brands["XL"] = new PHGBrand("http://www.summithotels.com/summit",
                                     "/search/search_results.aspx",
                                     "&brandCode=XL",
                                     "/hotels/index.aspx?fml=0",
                                     "&brandCode=XL",
                                     "&brandCode=XL","",false);

PHGInfo.brands["WR"] = new PHGBrand("http://www.sterlinghotels.com/sterling",
                                      "/search/search_results.aspx",
                                      "&brandCode=WR",
                                      "/hotels/index.aspx?fml=0",
                                      "&brandCode=WR",
                                      "&brandCode=WR","",false);

PHGInfo.brands["IP"] = new PHGBrand("http://dev.iprefer.com/IPrefer",
                                    "/search/search_results.aspx",
                                    "&brandCode=IP",
                                    "/hotels/index.aspx?fml=0",
                                   "&brandCode=IP",
                                   "&brandCode=IP","/special_offers/index.aspx",false);



PHGInfo.noCaseSort = function(a, b) {

if (a == null) 
{
    a="";
}

if (b == null) 
{
    b="";
}

var a1 = a.toLowerCase();
var b1 = b.toLowerCase(); 
return a1 == b1 ? (a == b ? 0 : a < b ? -1 : 1) : a1 < b1 ? -1 : 1;

};

PHGInfo.getHotelRecord = function(searchstring, searchtype){
    //returns the hotel json object that matches the string based on the type
    //the searchtype options are name or code
    //if any other searchtype is provided - or none at all, the search is applied to the pkid
    var toreturn;

    this.countries.each(function(acountry) {
        acountry.states.each(function(astate) {
            astate.cities.each(function(acity) {
                acity.hotels.each(function(ahotel) {
                    if (searchtype == "name") {
                        if (ahotel.name == searchstring) {
                            toreturn = ahotel;
                        }
                    }

                    if (searchtype == "code") {
                        if (ahotel.code == searchstring)
                        {
                            toreturn = ahotel;
                        }
                    }
                    //we default to the pkid
                    if (ahotel.pkid == searchstring) 
                    {
                        toreturn = ahotel;
                    }

                });
            });
        });

    });

    return toreturn

};

PHGInfo.getPegsAreaCode = function(country, state, city) {

    var areaCode = "";
   
    if (country == null || country == "") {
      
        return areaCode;
    }
    else {
        this.countries.each(function(acountry) {
           
            if (acountry.name == country) {
                if ((city == null || city == "") && (state == null || state == "")) {
                    areaCode = acountry.code;
                   
                    return;
                }
                else {
                    acountry.states.each(function(astate) {

                        if (astate.name == state) {
                            if (city == null || city == "") {
                                areaCode = astate.code;
                                return;
                            }
                            else {
                                astate.cities.each(function(acity) {
                                    if (acity.name == city) {
                                        areaCode = acity.code;
                                        return;
                                    }


                                });


                            }


                        }

                    });

                }


            }
        });
    }
    return areaCode;
};
//get states
PHGInfo.getStates = function(countryName){
    var foundstates;
    this.countries.each(function(acountry) {
        if (acountry.name == countryName) {
            foundstates = acountry.states;
        }

    });

    return foundstates;

};

//get cities
PHGInfo.getCities = function(countryName, stateName) {

    var foundcities;

    var cStates = PHGInfo.getStates(countryName);

    if (cStates) {
        cStates.each(function(astate) {
            if (astate.name == stateName) {
                foundcities = astate.cities;
            }
        });
    }

    return foundcities;
};

PHGInfo.getHotels = function(countryName, stateName, cityName) {
    var foundhotels

    var cCities = getCities(countryName, stateName)

    if (cCities) {
        cCities.each(function(acity) {
            if (acity.name = cityName) {
                foundhotels = acity.hotels;
            }
        });
    }

    return foundhotels;
};

PHGInfo.getUniqueStatesArray = function(options)
{
    var uniqueStates = new Array();
    if(!options)
    {
        options = {};
        options.country = null;
    
    }
    
    if(options.country == "")
    {
        options.country = null;
    }
    
    
    this.countries.each(function(acountry){
        //are we filtering by country?
        if(options.country)
        {
           if(options.country == acountry.name)
           {
                acountry.states.each(function(astate){
                    uniqueStates.push(astate.name);
                    
                });
           
           }
        }
        else
        {
            //we have to grab just the name of the state
            acountry.states.each(function(astate){
                uniqueStates.push(astate.name);
            
            });

        }

    });

    //dedupe, sort, and send off

    return  uniqueStates.uniq().sort();
};

PHGInfo.getUniqueCitiesArray = function(options)
{
    var uniqueCities = new Array();
    if(!options)
    {
        options = {};
        options.country = null;
        options.state = null;
    }
    
    if(options.country == "")
    {
        options.country = null;
    }

    if(options.state == "")
    {
        options.state = null;
    }

    this.countries.each(function(acountry){
        //are we filtering out by country?
        if(options.country)
        {
            if(acountry.name == options.country)
            {
                acountry.states.each(function(astate){
                
                    //are we filtering by state?
                    if(options.state)
                    {
                        if(options.state == astate.name)
                        {
                            uniqueCities = uniqueCities.concat(astate.cities);
                        }
                    }
                    //nope grab all the cities in the states
                    else
                    {
                        uniqueCities = uniqueCities.concat(astate.cities);
                    }
                });
           }
        }
        
        //no country filter, grab all the cities
        else
        {
                acountry.states.each(function(astate){
                    uniqueCities = uniqueCities.concat(astate.cities);
                });
        }


     });

    var uniqueCitiesToReturn = new Array();
    
    uniqueCities.each(function(aCity){
        uniqueCitiesToReturn.push(aCity.name);
    });
     
    return uniqueCitiesToReturn.uniq().sort();
};


PHGInfo.getUniqueHotelsArray = function(options) {
    var uniqueHotels = new Array();

    if (!options) {
        options = {};
        options.country = null;
        options.state = null;
        options.city = null;
    }

    if (options.country == "") {
        options.country = null;
    }

    if (options.state == "") {
        options.state = null;
    }

    if (options.city == "") {
        options.city = null;
    }

    this.countries.each(function(acountry) {
        //country filtering?
        if (options.country) {
            if (acountry.name == options.country) {
                acountry.states.each(function(astate) {

                    //state filtering?
                    if (options.state) {
                        if (astate.name == options.state) {
                            astate.cities.each(function(acity) {

                                //city filtering?
                                if (options.city) {

                                    if (options.city == acity.name) {
                                        acity.hotels.each(function(ahotel) {
                                            uniqueHotels.push(ahotel.name);
                                        });

                                    }
                                }
                                else {
                                    acity.hotels.each(function(ahotel) {
                                        uniqueHotels.push(ahotel.name);
                                    });
                                }
                            });
                        }
                    }
                    else {


                        astate.cities.each(function(acity) {
                            if (options.city) {
                                if (options.city == acity.name) {
                                    acity.hotels.each(function(ahotel) {
                                        uniqueHotels.push(ahotel.name);
                                    });
                                }

                            }
                            else {
                                acity.hotels.each(function(ahotel) {
                                    uniqueHotels.push(ahotel.name);
                                });
                            }

                        });


                    }
                });
            }
        }
        else {
            acountry.states.each(function(astate) {
                astate.cities.each(function(acity) {
                    acity.hotels.each(function(ahotel) {
                        uniqueHotels.push(ahotel.name);
                    });
                });
            });
        }
    });
    //do a case agnostic sort
    return uniqueHotels.uniq().sort(PHGInfo.noCaseSort);

};

PHGInfo.getCityStateAndCountry = function(somehotel) {
    //what does {} mean?
    var results = {};

    this.countries.each(function(acountry) {
        //stop!
        if (results.country) return;

        acountry.states.each(function(astate) {

            //stop again!
            if (results.country) return;

            astate.cities.each(function(acity) {

                //i said stop
                if (results.country) return;

                //new
                acity.hotels.each(function(ahotel) {

                    //sigh
                    if (results.country) return;

                    if (ahotel.name == somehotel) {
                        results.country = acountry.name;
                        results.countryCode = acountry.code;
                        results.state = astate.name;
                        results.stateCode = astate.code;
                        results.city = acity.name;
                        results.cityCode = acity.code;

                        return;
                    }
                });

            });
        });
    });

    if (results.country == null || Object.isUndefined(results.country)) {
        results.country = "";
        results.countryCode = "";
    }
    if (results.state == null || Object.isUndefined(results.state)) {
        results.state = "";
        results.stateCode = "";
    }
    //new
    if (results.city == null || Object.isUndefined(results.city)) {
        results.city = "";
        results.cityCode = "";
    }

    return results;
};


PHGInfo.getStateCountry = function(someState)
{
    var thecountry = null;

    this.countries.each(function(acountry){

        if(thecountry) return;
        acountry.states.each(function(astate){
        
            if(astate.name == someState)
            {
                thecountry = acountry.name;
            }
        });
    
    });

    return thecountry;
};


PHGInfo.getCityState = function(someCity) {

    var results = {};

    this.countries.each(function(acountry) {

        if (results.country) return;

        acountry.states.each(function(astate) {

            if (results.country) return;
            astate.cities.each(function(acity) {

                if (results.country) return;


                if (acity.name == someCity) {
                    results.country = acountry.name;
                    results.state = astate.name;
                    results.countryCode = acountry.code
                    results.stateCode = astate.code;

                    return;

                }
            });
        });
    });


    if (results.country == null || Object.isUndefined(results.country)) {
        results.country = "";
        results.countryCode = "";
    }
    if (results.state == null || Object.isUndefined(results.state)) {
        results.state = "";
        results.stateCode = "";
    }

    return results;
};

PHGInfo.PHGHotel = function(hotelpkid) {
    var hotelinfo = PHGInfo.getHotelRecord(hotelpkid);
    //find the hotel record


    if (hotelinfo) {
        //set up the basic hotel info
        this.pkid = hotelpkid;
        this.name = hotelinfo.name;
        this.brand = PHGInfo.brands[hotelinfo.brand];
        this.code = hotelinfo.code;

    }

    //defunct
    this.getBookingLink = function() {
        return this.brand.hotelBookURL + "&propertyCode=" + this.code;

    };

    this.getPropertyLink = function() {
        return this.brand.hotelPageURL + "&id=" + this.pkid;

    };

};



//build selects
PHGInfo.setSelected = function(selectId, newValue) {
    var found = false;
    var selectedOptions = $A($(selectId).options);
    var newIndex = -1;


    selectedOptions.each(function(anoption, theIndex) {
        //I hate IE.  We have to check the actual text too

        if (anoption.value == newValue || anoption.text == newValue) {

            newIndex = theIndex;
            found = true;

            return;
        }

    });

    $(selectId).selectedIndex = newIndex;

}

PHGInfo.loadSelects = function(selectId, newOptions) {
    $(selectId).options.length = 0; //clear any options

    newOptions.each(function(anewoption) {

        var newValue;


        //add the All option

        //new hotel select
        if (selectId == "searchHotelSelect") {
            //charles, what do these trues do?
            $(selectId).options[0] = new Option("All Hotels", "", true, true);
        }

        if (selectId == "searchCitySelect") {
            $(selectId).options[0] = new Option("All Cities", "", true, true);

        }
        if (selectId == "searchStateSelect") {
            $(selectId).options[0] = new Option("All States / Provinces", "", true, true);
        }
        //does this thing have a name?
        if (anewoption && !Object.isUndefined(anewoption.name) && anewoption.name != null) {
            newValue = anewoption.name
        }
        else {
            if (Object.isString(anewoption)) {
                newValue = anewoption;
            }
            else {
                newValue = "";
            }
        }

        if (newValue != "" && anewoption != "undefined") {
            $(selectId).options[$(selectId).options.length] = new Option(newValue, newValue);
        }


    });

}


PHGInfo.initializeSearchOptions = function() {
    //load the initial countries
    //add the empty state
    $("searchCountrySelect").options[0] = new Option("All Countries...", "", true, true);

    PHGInfo.countries.each(function(acountry) {
        if (acountry.name) {
            $("searchCountrySelect").options[$("searchCountrySelect").options.length] = new Option(acountry.name);
        }
    });

    $("searchCountrySelect").observe('change', PHGInfo.countryChange);
    $("searchStateSelect").observe('change', PHGInfo.stateChange);
    $("searchCitySelect").observe('change', PHGInfo.cityChange);

    //new hotelthing
    $("searchHotelSelect").observe('change', PHGInfo.hotelChange);

    //setup the link
    $("searchButton").observe('click', PHGInfo.sendoff);

   //new: load hotels

    PHGInfo.loadSelects("searchHotelSelect", PHGInfo.getUniqueHotelsArray());
    //please work :(    
    //load all the citiess

    PHGInfo.loadSelects("searchCitySelect", PHGInfo.getUniqueCitiesArray());
   //load all the states

    PHGInfo.loadSelects("searchStateSelect",PHGInfo.getUniqueStatesArray());

}

PHGInfo.loadStates = function(event) {
    //get the states for the country
    //var foundstates = PHGInfo.getStates($F("searchCountrySelect"));
    var foundstates = PHGInfo.getUniqueStatesArray({ country: $F("searchCountrySelect") });

    if (foundstates) {
        PHGInfo.loadSelects("searchStateSelect", foundstates);

    }
    PHGInfo.loadCities();

}

PHGInfo.loadCities = function(event)
//changed because it's not the end of the chain anymore right?
{
    //var foundcities = PHGInfo.getCities($F("searchCountrySelect"), $F("searchStateSelect"));
    var foundcities = PHGInfo.getUniqueCitiesArray({ country: $F("searchCountrySelect"), state: $F("searchStateSelect") });

    if (foundcities) {
        PHGInfo.loadSelects("searchCitySelect", foundcities);
    }
    PHGInfo.loadHotels();


}


PHGInfo.loadHotels = function(event) {
    var options = {};
    options.country = $F("searchCountrySelect");
    options.state = $F("searchStateSelect");
    options.city = $F("searchCitySelect");
    foundhotels = PHGInfo.getUniqueHotelsArray(options);


    if (foundhotels) {
        PHGInfo.loadSelects("searchHotelSelect", foundhotels);
    }

}


PHGInfo.hotelChange = function(event) {
    if ($F("searchHotelSelect") == "" || $F("searchHotelSelect") == null || $F("searchHotelSelect") == "All") {
        PHGInfo.initializeSearchOptions();
    }
    else {
        var info = PHGInfo.getCityStateAndCountry($F("searchHotelSelect"));
        var selectedHotel = $F("searchHotelSelect");

        PHGInfo.setSelected("searchCountrySelect", info.country);

        PHGInfo.loadStates();
        PHGInfo.setSelected("searchStateSelect", info.state);

        PHGInfo.loadCities();
        PHGInfo.setSelected("searchCitySelect", info.city);

        PHGInfo.loadHotels();
        PHGInfo.setSelected("searchHotelSelect", selectedHotel);
    }
}

PHGInfo.cityChange = function(event) {
    if ($F("searchCitySelect") == "" || $F("searchCitySelect") == null || $F("searchCitySelect") == "All") {
        PHGInfo.initializeSearchOptions();
    }
    else {
        var info = PHGInfo.getCityState($F("searchCitySelect"));
        var selectedCity = $F("searchCitySelect");
        PHGInfo.setSelected("searchCountrySelect", info.country);
        PHGInfo.loadStates();
        PHGInfo.setSelected("searchStateSelect", info.state);
        PHGInfo.loadCities();
        PHGInfo.setSelected("searchCitySelect", selectedCity);
        PHGInfo.loadHotels();
    }
}

PHGInfo.stateChange = function(event) {
    if ($F("searchStateSelect") == "" || $F("searchStateSelect") == null || $F("searchStateSelect") == "All") {
        PHGInfo.initializeSearchOptions();
    }
    else {
        //set the country to the current state's country
        PHGInfo.setSelected("searchCountrySelect", PHGInfo.getStateCountry($F("searchStateSelect")));

        //so you need a function that sets the state to the current city's state, if applicable.. getCityState.

        //load the cities for that state
        PHGInfo.loadCities();
        PHGInfo.loadHotels();
    }
}

PHGInfo.countryChange = function(event) {
    //if we select an empty country value (All), then reinitialize
    if ($F("searchCountrySelect") == "" || $F("searchCountrySelect") == null || $F("searchCountrySelect") == "All") {
        //start over
        PHGInfo.initializeSearchOptions();
        // alert("Starting Over");
    }
    else {
        //otherwise just filter the states (cities will propogate through the loadStates function
        PHGInfo.loadStates();
    }


}

PHGInfo.sendoff = function(event) {
    var theCountry = $F("searchCountrySelect");
    var theState = $F("searchStateSelect");
    var theCity = $F("searchCitySelect");
    var theHotel = $F("searchHotelSelect");
    var arrive = $F("arrive");
    var numberOfNights = $F("numberOfNights");
    var adults = $F("adults");
    var children = $F("children");
    var offerCode = $F("offerCode");

    var foundHotel;


    var newURL = "";

    //remove the "Offer Code" value in offer code if it exists
    if (offerCode == offerHint) {
        offerCode = "";
    }
    //if we were passed a hotel initially then load it instead
    if (PHGInfo.currentHotelID != '') {
        theHotel = PHGInfo.currentHotelID;
    }
    //find out what exactly we are going to do..
    //first, is there an arrival date?
    if (arrive && arrive != "" && Object.isString(arrive) && arrive != "MM%20/%20DD%20/%20YYYY" && arrive != "MM / DD / YYYY") {

        //we have an arrival date, do we have a hotel?
        if (theHotel && theHotel != "" && Object.isString(theHotel)) {

            //we have an arrival date and a hotel - send them to the booking link for that hotel
            //do we have an I Prefer membership number?
            if (typeof (PHG_IPreferID) != "undefined" && PHG_IPreferID != "") {
                //logged in send to booking engine
				

					window.location = PHGInfo.craftDirectBookLink(PHGInfo.getHotelRecord(theHotel, "name").code, arrive, numberOfNights, adults, children, offerCode) + "&guestNumber=" + PHG_IPreferID;
				

            }
            else {
                //not logged in, show the popup
				if(PHGInfo.currentBrand.mustLogIn == false)
				{
					window.location = PHGInfo.craftDirectBookLink(PHGInfo.getHotelRecord(theHotel, "name").code, arrive, numberOfNights, adults, children, offerCode)
				}
				else
				{
					memberLoginJump('../members/index.aspx?reqURL=' + escape(PHGInfo.craftDirectBookLink(PHGInfo.getHotelRecord(theHotel, "name").code, arrive, numberOfNights, adults, children, offerCode)));
				}
            }

        }
        else {
            //no hotel -- send them to the booking engine search
            if (typeof (PHG_IPreferID) != "undefined" && PHG_IPreferID != "") {
                //logged in - send to booking engine
                window.location = PHGInfo.craftCRSSearchLink(arrive, numberOfNights, adults, children, offerCode, theCountry, theState, theCity) + "&guestNumber=" + PHG_IPreferID;

            }
            else {
			
				if(PHGInfo.currentBrand.mustLogIn == false)
				{
					window.location = PHGInfo.craftCRSSearchLink(arrive, numberOfNights, adults, children, offerCode, theCountry, theState, theCity);
				}
				else
				{
                memberLoginJump('../members/index.aspx?reqURL=' + escape(PHGInfo.craftCRSSearchLink(arrive, numberOfNights, adults, children, offerCode, theCountry, theState, theCity)));
				}
            }


        }



    }
    //no arrival date - we either send them to the hotel page or to the web search page
    else {
        //do we have a selected hotel?
        if (theHotel && theHotel != "" && Object.isString(theHotel)) {
            //create a hotel object to get the hotel's page
            var hotelURL = PHGInfo.currentBrand.hotelPageURL;
            hotelURL += "&id=" + PHGInfo.getHotelRecord(theHotel, "name").pkid;
            //do we have an IATA?
            if (PHGInfo.passedParams.IATA && PHGInfo.passedParams.IATA != '' && PHGInfo.passedParams.IATA != null) {
                hotelURL += "&IATA=" + PHGInfo.passedParams.IATA;
            }

            //how about an offer code?
            if (offerCode && offerCode != '' && offerCode != null) {
                hotelURL += "&rateCode=" + encodeURIComponent(offerCode);
            }

            window.location = hotelURL;



        }
        else //no hotel, send them to the search page
        {
            //we have to populate the hidden search form
            $('city').value = theCity;
            $('state').value = theState;
            $('country').value = theCountry;
            $('hiddensearchform').submit();
        }
    }
};

PHGInfo.craftDirectBookLink = function(hotelcode, arrivalDate, nights, adults, children, offerCode) {

    var newURL = "";
    newURL = PHGInfo.currentBrand.hotelBookURL;

    //split the arrival date into its parts
    //var dateParts = arrivalDate.split('/');


    //month
    //newURL += "&arriveMonth=" + encodeURIComponent(dateParts[0]);
    //day
    //newURL += "&arriveDate=" + encodeURIComponent(dateParts[1]);
    //year
    //newURL += "&arriveYear=" + encodeURIComponent(dateParts[2]);

    //newURL += "&arrive=" + encodeURIComponent(arrivalDate);
	newURL += "&arrivalDate=" + encodeURIComponent(arrivalDate);
    newURL += "&numberOfNights=" + encodeURIComponent(nights);
    newURL += "&numberOfAdults=" + encodeURIComponent(adults);
    newURL += "&numberOfChildren=" + encodeURIComponent(children);
    newURL += "&propertyCode=" + encodeURIComponent(hotelcode);

    if (offerCode && offerCode != '' && offerCode != null) {
        newURL += "&rateCode=" + encodeURIComponent(offerCode);
    }

    //do we have an IATA?
    if (PHGInfo.passedParams.IATA && PHGInfo.passedParams.IATA != '' && PHGInfo.passedParams.IATA != null) {
        newURL += "&iataNumber=" + PHGInfo.passedParams.IATA;
    }

    return newURL;

};

PHGInfo.craftCRSSearchLink = function(arrivalDate, nights, adults, children, offerCode, country, state, city) {

    var newURL = "";
    newURL = PHGInfo.currentBrand.searchBookURL;
    //split the arrival date into its parts
    //var dateParts = arrivalDate.split('/');


    //month
    //newURL += "&arriveMonth=" + encodeURIComponent(dateParts[0]);
    //day
    //newURL += "&arriveDay=" + encodeURIComponent(dateParts[1]);
    //year
    //newURL += "&arriveYear=" + encodeURIComponent(dateParts[2]);
	newURL += "&arrivalDate=" + encodeURIComponent(arrivalDate);
    newURL += "&numberOfNights=" + encodeURIComponent(nights);
    newURL += "&numberOfAdults=" + encodeURIComponent(adults);
	newURL += "&numberOfChildren=" + encodeURIComponent(children);

    if (offerCode && offerCode != '' && offerCode != null) {
        newURL += "&rateCode=" + encodeURIComponent(offerCode);
    }

    //add area

    newURL += "&areaCode=" + PHGInfo.getPegsAreaCode(country, state, city);
    //newURL += "&areaname=" + country + " " + state + " " + city;

    //do we have an IATA?
    if (PHGInfo.passedParams.IATA && PHGInfo.passedParams.IATA != '' && PHGInfo.passedParams.IATA != null) {
        newURL += "&iataNumber=" + PHGInfo.passedParams.IATA;
    }


    return newURL;

};





PHGInfo.initiate = function() {

    //grab the query string parameters passed in.
    PHGInfo.passedParams = location.search.parseQuery();

    //create the hidden form
    document.body.appendChild(new Element('form', {
        action: PHGInfo.currentBrand.searchPageURL + "?fml=0" + (PHGInfo.passedParams.IATA ? ("&IATA=" + PHGInfo.passedParams.IATA) : '') + (PHGInfo.passedParams.rateCode ? ("&rateCode=" + PHGInfo.passedParams.rateCode) : ''),
        method: "post",
        id: "hiddensearchform"
    })
            );

    //now load the hidden inputs
    $('hiddensearchform').insert({
        top: new Element('input', { type: "hidden", name: "city", id: "city" })
    });

    $('hiddensearchform').insert({
        top: new Element('input', { type: "hidden", name: "state", id: "state" })
    });
    $('hiddensearchform').insert({
        top: new Element('input', { type: "hidden", name: "country", id: "country" })
    });

    //set up the checkreslink link
    $('checkreslink').writeAttribute("href", PHGInfo.currentBrand.checkReservationURL);

    //set up the findhotels button
    //$('findOtherHotelsButton').observe('click', function() { window.location = PHGInfo.currentBrand.findHotelURL; });

    //grab the query string parameters passed in.
    PHGInfo.passedParams = location.search.parseQuery();

    //did we get a rate code?
    if (PHGInfo.passedParams.rateCode && PHGInfo.passedParams.rateCode != '' && PHGInfo.passedParams.rateCode != null) {
        //update the offer code field
        $('offerCode').value = PHGInfo.passedParams.rateCode;
    }

    //load the search options
    PHGInfo.initializeSearchOptions();

};

var hotelHint = 'Hotel or Resort Name';
var offerHint = 'Enter Offer Code';
var arrivalHint = 'MM / DD / YYYY';

//add the onload function to initialize the search options
Event.observe(window, 'load', PHGInfo.initiate);
PHGInfo.countries = [{"states":[{"name":null,"cities":[{"name":null,"aliases":[null],"code":null,"hotels":[{"name":null,"brand":null,"code":null,"pkid":null}]}],"code":null},{"name":null,"cities":[],"code":null}]},{"name":"Argentina","code":"1AR","states":[{"name":"","cities":[{"name":"Bariloche","aliases":["Bariloche"],"code":"BARIL","hotels":[{"name":"El Casco Art Hotel","brand":"BC","code":"BRCEC","pkid":"77274"}]}],"code":null},{"name":"","cities":[],"code":null}]},{"name":"Australia","code":"1AU","states":[{"name":"Victoria","cities":[{"name":"Melbourne","aliases":["Melbourne"],"code":"MELAB","hotels":[{"name":"The Lyall Hotel","brand":"BC","code":"MELLH","pkid":"72562"}]}],"code":"2VIC"},{"name":"Western Australia","cities":[{"name":"Perth","aliases":["Perth"],"code":"PERAD","hotels":[{"name":"The Richardson Hotel & Spa","brand":"BC","code":"PERRH","pkid":"72619"}]}],"code":"2WT"},{"name":"Western Australia","cities":[],"code":"2WT"}]},{"name":"Austria","code":"1AT","states":[{"name":"","cities":[{"name":"Lienz","aliases":["Lienz"],"code":"LIENZ","hotels":[{"name":"Grandhotel Lienz","brand":"BC","code":"KLUGL","pkid":"76343"}]},{"name":"Pörtschach am Wörthersee","aliases":["Lake Wörth"],"code":"KLUAA","hotels":[{"name":"Lake’s – my lake hotel","brand":"BC","code":"KLULM","pkid":"74576"}]},{"name":"Vienna","aliases":["Vienna"],"code":"VIEAA","hotels":[{"name":"The Ring, Vienna's Casual Luxury Hotel","brand":"BC","code":"VIETR","pkid":"62834"}]}],"code":null}]},{"name":"Bahamas","code":"1BS","states":[{"name":"","cities":[{"name":"Grand Bahama Island","aliases":["Grand Bahama Island"],"code":"FPO","hotels":[{"name":"Old Bahama Bay","brand":"BC","code":"FPOOB","pkid":"70149"}]}],"code":null}]},{"name":"Belize","code":"1BZ","states":[{"name":"","cities":[{"name":"Ambergris Caye","aliases":["Ambergris Caye"],"code":"SPRAA","hotels":[{"name":"Las Terrazas Resort","brand":"BC","code":"SPRLT","pkid":"71593"}]}],"code":null}]},{"name":"British Virgin Islands","code":"1VG","states":[{"name":"","cities":[{"name":"Tortola","aliases":["Road Town, Tortola"],"code":"TORTL","hotels":[{"name":"Peter Island Resort","brand":"BC","code":"BRIIP","pkid":"60630"}]}],"code":null}]},{"name":"Cambodia","code":"1KH","states":[{"name":"","cities":[{"name":"Siem Reap","aliases":["Siem Reap"],"code":"REP","hotels":[{"name":"The Sothea","brand":"BC","code":"REPSC","pkid":"69522"}]}],"code":null},{"name":"","cities":[],"code":null}]},{"name":"Canada","code":"1CA","states":[{"name":"Ontario","cities":[{"name":"Niagara Falls","aliases":["Niagara Falls"],"code":"IAG","hotels":[{"name":"Sterling Inn & Spa","brand":"BC","code":"IAGSI","pkid":"74918"}]}],"code":"2ON"},{"name":"Ontario","cities":[],"code":"2ON"}]},{"name":"China","code":"1CN","states":[{"name":"","cities":[{"name":"Beijing","aliases":["Beijing"],"code":"BEIAA","hotels":[{"name":"The Opposite House","brand":"BC","code":"PEKHO","pkid":"70339"}]},{"name":"Sanya","aliases":["Sanya"],"code":"SYXAA","hotels":[{"name":"Aegean Conifer Suites Resort","brand":"BC","code":"SYXAC","pkid":"70187"}]}],"code":null}]},{"name":"Czech Republic","code":"1CZ","states":[{"name":"","cities":[{"name":"Prague","aliases":["Prague"],"code":"PRAAA","hotels":[{"name":"Alchymist Grand Hotel & Spa","brand":"BC","code":"PRGTA","pkid":"61903"},{"name":"The Iron Gate Hotel & Suites","brand":"BC","code":"PRGIG","pkid":"55899"}]}],"code":null}]},{"name":"Dominican Republic","code":"1DO","states":[{"name":"","cities":[{"name":"Punta Cana","aliases":["Punta Cana"],"code":"PUJAA","hotels":[{"name":"Zoetry Agua Punta Cana","brand":"BC","code":"PUJZA","pkid":"75678"}]}],"code":null}]},{"name":"France","code":"1FR","states":[{"name":"","cities":[{"name":"Paris","aliases":["Paris"],"code":"PARAE","hotels":[{"name":"Hotel de Vigny","brand":"BC","code":"PARDV","pkid":"74842"},{"name":"Hotel Keppler","brand":"BC","code":"PARHK","pkid":"61751"},{"name":"Montalembert","brand":"BC","code":"PARHM","pkid":"49230"}]},{"name":"Saint-Jean-Cap-Ferrat","aliases":["Cote d'Azur"],"code":"SJCF","hotels":[{"name":"La Voile d'Or","brand":"BC","code":"NCELV","pkid":"60668"}]}],"code":null}]},{"name":"French Polynesia","code":"1PF","states":[{"name":"","cities":[{"name":"Moorea","aliases":["Moorea"],"code":"MOORE","hotels":[{"name":"Legends Resort®","brand":"BC","code":"MOZLR","pkid":"73094"}]},{"name":"Papeete/Tahiti","aliases":["Papeete/Tahiti"],"code":"PPTAA","hotels":[{"name":"Nomade Yachting Bora Bora","brand":"BC","code":"BOBBB","pkid":"63955"}]}],"code":null}]},{"name":"French West Indies","code":"1WI","states":[{"name":"","cities":[{"name":"Gustavia, St. Barthélémy","aliases":["Gustavia"],"code":"GUSAA","hotels":[{"name":"Hotel Carl Gustaf & Spa","brand":"BC","code":"CCECA","pkid":"58464"}]}],"code":null}]},{"name":"Germany","code":"1DE","states":[{"name":"","cities":[{"name":"Storkow","aliases":["Storkow"],"code":"STORK","hotels":[{"name":"Schloss Hubertushöhe","brand":"BC","code":"BERSH","pkid":"74443"}]}],"code":null}]},{"name":"Greece","code":"1GR","states":[{"name":"","cities":[{"name":"Mykonos","aliases":["Mykonos"],"code":"MYKON","hotels":[{"name":"Cavo Tagoo Mykonos","brand":"BC","code":"JMKCT","pkid":"76647"}]},{"name":"Santorini","aliases":["Santorini"],"code":"JTRAA","hotels":[{"name":"ICONS","brand":"BC","code":"JTRIH","pkid":"73379"}]}],"code":null}]},{"name":"Hong Kong","code":"1HK","states":[{"name":"","cities":[{"name":"Hong Kong","aliases":["Hong Kong"],"code":"HONAA","hotels":[{"name":"The Upper House","brand":"BC","code":"HKGHU","pkid":"72277"}]}],"code":null}]},{"name":"India","code":"1IN","states":[{"name":"","cities":[{"name":"Bharatpur","aliases":["Bharatpur"],"code":"BHARA","hotels":[{"name":"The Bagh","brand":"BC","code":"AGRTB","pkid":"61941"}]},{"name":"Jaipur","aliases":["Jaipur"],"code":"JAIP","hotels":[{"name":"Devi Ratn","brand":"BC","code":"JAIDR","pkid":"76191"}]},{"name":"Udaipur","aliases":["Udaipur"],"code":"UDAAA","hotels":[{"name":"Devi Garh","brand":"BC","code":"UDRDG","pkid":"60953"}]}],"code":null}]},{"name":"Ireland","code":"1IE","states":[{"name":"","cities":[{"name":"Dublin","aliases":["Dublin","Dublin 4"],"code":"DUBAA","hotels":[{"name":"Dylan","brand":"BC","code":"DUBDH","pkid":"60554"},{"name":"Morrison","brand":"BC","code":"DUBMH","pkid":"61295"}]}],"code":null}]},{"name":"Italy","code":"1IT","states":[{"name":"","cities":[{"name":"Capri","aliases":["Capri"],"code":"PRJ","hotels":[{"name":"Capri Tiberio Palace Hotel & Spa","brand":"BC","code":"PRJCT","pkid":"74614"}]},{"name":"Civitella Paganico","aliases":["Civitella Paganico"],"code":"CIVIT","hotels":[{"name":"Petriolo SPA Resort","brand":"BC","code":"SAYPS","pkid":"75925"}]},{"name":"Fiano","aliases":["Fiano"],"code":"FIANO","hotels":[{"name":"Relais Bella Rosina","brand":"BC","code":"TRNBR","pkid":"74766"}]},{"name":"Florence","aliases":["Florence"],"code":"FLOAB","hotels":[{"name":"Montebello Splendid","brand":"BC","code":"FLRMS","pkid":"76039"},{"name":"Palazzo Vecchietti","brand":"BC","code":"FLRPV","pkid":"73816"}]},{"name":"Milan","aliases":["Milan"],"code":"MILAA","hotels":[{"name":"Town House 8","brand":"BC","code":"MILTH","pkid":"72638"}]},{"name":"Monforte d'Alba","aliases":["Monforte d'Alba"],"code":"MONF","hotels":[{"name":"Relais Monforte","brand":"BC","code":"TRNRM","pkid":"71916"}]},{"name":"Riva del Garda","aliases":["Riva del Garda"],"code":"RIVA","hotels":[{"name":"Murialdo Suites","brand":"BC","code":"VRNMS","pkid":"75887"}]},{"name":"Rome","aliases":["Rome"],"code":"ROM","hotels":[{"name":"Hotel Fortyseven","brand":"BC","code":"FCOSF","pkid":"60649"}]},{"name":"Taormina","aliases":["Taormina"],"code":"TAOAA","hotels":[{"name":"Hotel Imperiale","brand":"BC","code":"CTAHI","pkid":"71574"},{"name":"La Plage Resort","brand":"BC","code":"CTALP","pkid":"64392"}]}],"code":null}]},{"name":"Lithuania","code":"1LT","states":[{"name":"","cities":[{"name":"Vilnius","aliases":["Vilnius"],"code":"VILN","hotels":[{"name":"Narutis Hotel","brand":"BC","code":"VNOHN","pkid":"53201"}]}],"code":null}]},{"name":"Malaysia","code":"1MY","states":[{"name":"","cities":[{"name":"Kota Kinabalu","aliases":["Borneo"],"code":"KOTA","hotels":[{"name":"Bunga Raya Island Resort & Spa","brand":"BC","code":"BKIBR","pkid":"72201"},{"name":"Gayana Eco Resort","brand":"BC","code":"BKIGR","pkid":"71099"}]}],"code":null}]},{"name":"Mexico","code":"1MX","states":[{"name":"","cities":[{"name":"Mexico City","aliases":["Mexico City"],"code":"MCTY","hotels":[{"name":"Hotel Brick","brand":"BC","code":"MEXHB","pkid":"74709"},{"name":"Plaza Suites Mexico City","brand":"BC","code":"MEXPS","pkid":"76267"}]}],"code":null},{"name":"Baja California Sur","cities":[{"name":"Los Cabos","aliases":["Los Cabos"],"code":"LOSLC","hotels":[{"name":"Zoetry Casa del Mar Los Cabos","brand":"BC","code":"SJDZC","pkid":"75374"}]}],"code":"2BCS"},{"name":"Guanajuato","cities":[{"name":"San Miguel de Allende","aliases":["San Miguel de Allende"],"code":"SANMG","hotels":[{"name":"La Puertecita Boutique Hotel","brand":"BC","code":"BJXLP","pkid":"69940"}]}],"code":"2GTO"},{"name":"Jalisco","cities":[{"name":"Puerto Vallarta","aliases":["Puerto Vallarta"],"code":"PVR","hotels":[{"name":"Villa Premiere Hotel & Spa","brand":"BC","code":"PVRVP","pkid":"61162"}]}],"code":"2JAL"},{"name":"Quintana Roo","cities":[{"name":"Cancun/Riviera Maya","aliases":["Cancun/Riviera Maya"],"code":"CUN","hotels":[{"name":"Ceiba Del Mar Spa Resort","brand":"BC","code":"CUNCD","pkid":"60060"}]},{"name":"Cozumel","aliases":["Cozumel"],"code":"CZM","hotels":[{"name":"Aura Cozumel Resort Wyndham Grand Bay","brand":"BC","code":"CZMAR","pkid":"62131"}]}],"code":"2QR"},{"name":"Quintana Roo","cities":[],"code":"2QR"}]},{"name":"Morocco","code":"1MA","states":[{"name":"","cities":[{"name":"Agadir","aliases":["Agadir"],"code":"AGAD","hotels":[{"name":"Tikida Golf Palace","brand":"BC","code":"AGATG","pkid":"72524"}]},{"name":"Marrakech","aliases":["Marrakech"],"code":"RAKAA","hotels":[{"name":"Jnane Tamsna","brand":"BC","code":"RAKJT","pkid":"74348"},{"name":"Pavillon du Golf","brand":"BC","code":"RAKLP","pkid":"63917"}]}],"code":null}]},{"name":"Netherlands","code":"1NL","states":[{"name":"","cities":[{"name":"Amsterdam","aliases":["Amsterdam"],"code":"AMS","hotels":[{"name":"The College Hotel","brand":"BC","code":"AMSCH","pkid":"71783"}]}],"code":null}]},{"name":"New Zealand","code":"1NZ","states":[{"name":"","cities":[{"name":"Lake Okareka/Rotorua","aliases":["Lake Okareka/Rotorua"],"code":"ROT","hotels":[{"name":"Lake Okareka Lodge","brand":"BC","code":"ROTLO","pkid":"70529"}]},{"name":"Queenstown","aliases":["Queenstown"],"code":"ZQNAA","hotels":[{"name":"Azur","brand":"BC","code":"ZQNAZ","pkid":"58521"}]}],"code":null}]},{"name":"Poland","code":"1PL","states":[{"name":"","cities":[{"name":"Warsaw","aliases":["Warsaw"],"code":"WAWAA","hotels":[{"name":"Hotel Rialto","brand":"BC","code":"WAWHR","pkid":"58236"}]}],"code":null}]},{"name":"Portugal","code":"1PT","states":[{"name":"","cities":[{"name":"Lisbon","aliases":["Lisbon"],"code":"LIS","hotels":[{"name":"Altis Avenida Hotel","brand":"BC","code":"LISAA","pkid":"76837"},{"name":"Altis Belém Hotel & Spa","brand":"BC","code":"LISAB","pkid":"74880"}]},{"name":"Sintra","aliases":["Lisbon"],"code":"SINTR","hotels":[{"name":"Tivoli Palacio de Seteais","brand":"BC","code":"LISTP","pkid":"71745"}]}],"code":null}]},{"name":"Rwanda","code":"1RW","states":[{"name":"","cities":[{"name":"Gisakura/Nyungwe","aliases":["Gisakura/Nyungwe"],"code":"GISAK","hotels":[{"name":"Nyungwe Forest Lodge","brand":"BC","code":"BKYNF","pkid":"75640"}]},{"name":"Kinigi/Runhengeri","aliases":["Kinigi/Runhengeri"],"code":"KINIG","hotels":[{"name":"Gorilla Nest Lodge","brand":"BC","code":"GOMGN","pkid":"75621"}]}],"code":null}]},{"name":"Saint Lucia","code":"1LC","states":[{"name":"","cities":[{"name":"Gros Islet","aliases":["Saint Lucia"],"code":"GROS","hotels":[{"name":"Cap Maison Resort & Spa","brand":"BC","code":"SLUCM","pkid":"70073"}]}],"code":null}]},{"name":"South Africa","code":"1ZA","states":[{"name":"","cities":[{"name":"Badplaas","aliases":["Badplaas"],"code":"BADPL","hotels":[{"name":"Nkomazi Game Reserve","brand":"BC","code":"MQPNG","pkid":"75279"}]},{"name":"Cape Town/Bishopscourt","aliases":["Bishopscourt"],"code":"BISHO","hotels":[{"name":"Last Word Bishopscourt","brand":"BC","code":"CPTTB","pkid":"75450"}]},{"name":"Cape Town/Constantia","aliases":["Cape Town/Constantia"],"code":"CONST","hotels":[{"name":"The Last Word Constantia","brand":"BC","code":"CPTTC","pkid":"75431"}]},{"name":"Cape Town/Franschhoek","aliases":["Franschhoek"],"code":"FRANS","hotels":[{"name":"The Last Word Franschhoek","brand":"BC","code":"CPTTF","pkid":"75469"}]},{"name":"Cape Town/Kommetjie","aliases":["Cape Town/Kommetjie"],"code":"KOMME","hotels":[{"name":"The Last Word Long Beach","brand":"BC","code":"CPTTL","pkid":"75412"}]},{"name":"Cape Town/Paarl","aliases":["Cape Town/Paarl"],"code":"PAARL","hotels":[{"name":"Grande Roche Hotel & Restaurant","brand":"BC","code":"CPTGR","pkid":"75526"}]},{"name":"George/Wilderness","aliases":["George/Wilderness"],"code":"GRJAA","hotels":[{"name":"Views Boutique Hotel & Spa","brand":"BC","code":"GRJVB","pkid":"75545"}]},{"name":"Knysna","aliases":["Knysna"],"code":"KNYSN","hotels":[{"name":"Pezula Resort Hotel & Spa","brand":"BC","code":"GRJPR","pkid":"77198"}]},{"name":"Montagu/Barrydale","aliases":["Montagu/Barrydale"],"code":"MONTA","hotels":[{"name":"Sanbona Wildlife Reserve","brand":"BC","code":"CPTSW","pkid":"75298"}]},{"name":"Nelspruit/Mpumalanga","aliases":["Nelspruit/Mpumalanga"],"code":"LLEAA","hotels":[{"name":"Jock Safari Lodge","brand":"BC","code":"LLEJS","pkid":"75260"}]},{"name":"Port Alfred/Rietrivier","aliases":["Port Alfred/Rietrivier"],"code":"WILDE","hotels":[{"name":"Oceana Beach & Wildlife Reserve","brand":"BC","code":"AFDOB","pkid":"75507"}]},{"name":"Port Elizabeth","aliases":["Port Elizabeth"],"code":"PLZAA","hotels":[{"name":"Shamwari Townhouse","brand":"BC","code":"PLZST","pkid":"75488"}]},{"name":"Port Elizabeth/Paterson","aliases":["Port Elizabeth/Paterson"],"code":"PATER","hotels":[{"name":"Shamwari Game Reserve","brand":"BC","code":"CPTSG","pkid":"75602"}]}],"code":null}]},{"name":"Spain","code":"1ES","states":[{"name":"","cities":[{"name":"Barcelona","aliases":["Barcelona"],"code":"BARAA","hotels":[{"name":"Hotel Miramar Barcelona","brand":"BC","code":"BCNMM","pkid":"74063"},{"name":"Hotel Murmuri","brand":"BC","code":"BCNMU","pkid":"64069"},{"name":"Rafaelhoteles by Casanova","brand":"BC","code":"BCNHC","pkid":"72448"}]},{"name":"Ibiza","aliases":["Ibiza"],"code":"IBIZA","hotels":[{"name":"Hotel Hacienda Na Xamena","brand":"BC","code":"IBZHN","pkid":"69826"}]}],"code":null}]},{"name":"Switzerland","code":"1CH","states":[{"name":"","cities":[{"name":"Lugano","aliases":["Lugano"],"code":"LUGAA","hotels":[{"name":"Swiss Diamond Hotel Olivella","brand":"BC","code":"LUGSD","pkid":"54037"}]},{"name":"Zurich","aliases":["Zürich"],"code":"ZURAA","hotels":[{"name":"ALDEN Hotel Splügenschloss","brand":"BC","code":"ZRHAH","pkid":"70130"}]}],"code":null}]},{"name":"Thailand","code":"1TH","states":[{"name":"","cities":[{"name":"Bangkok","aliases":["Bangkok"],"code":"BANAD","hotels":[{"name":"Dream Bangkok","brand":"BC","code":"BKKDB","pkid":"60934"}]},{"name":"Chiang Mai","aliases":["Chiang Mai"],"code":"CNXAA","hotels":[{"name":"RatiLanna Riverside Spa Resort","brand":"BC","code":"CNXRA","pkid":"70700"}]},{"name":"Phuket","aliases":["Phuket"],"code":"PHUAA","hotels":[{"name":"Andara Resort & Villas","brand":"BC","code":"HKTAR","pkid":"74823"}]}],"code":null}]},{"name":"Turkey","code":"1TR","states":[{"name":"","cities":[{"name":"Ankara","aliases":["Ankara"],"code":"ANKAA","hotels":[{"name":"Divan Çukurhan","brand":"BC","code":"ANKDC","pkid":"76799"}]},{"name":"Bodrum","aliases":["Bodrum"],"code":"BXNAA","hotels":[{"name":"Divan Bodrum","brand":"BC","code":"BXNDB","pkid":"76761"}]}],"code":null}]},{"name":"United Kingdom","code":"1UK","states":[{"name":"","cities":[{"name":"Brighton","aliases":["Brighton"],"code":"BSH","hotels":[{"name":"myhotel Brighton","brand":"BC","code":"BSHMB","pkid":"70111"}]},{"name":"Edinburgh","aliases":["Edinburgh"],"code":"EDI","hotels":[{"name":"The Glasshouse","brand":"BC","code":"EDIGE","pkid":"52384"}]},{"name":"London","aliases":["London"],"code":"LON3","hotels":[{"name":"41","brand":"BC","code":"LON41","pkid":"59091"},{"name":"Draycott Hotel","brand":"BC","code":"LONDH","pkid":"75944"},{"name":"Egerton House Hotel","brand":"BC","code":"LONEH","pkid":"61352"},{"name":"The Hempel","brand":"BC","code":"LONTH","pkid":"50522"},{"name":"Threadneedles, The City's Boutique Hotel","brand":"BC","code":"LONTN","pkid":"41022"}]}],"code":null},{"name":"","cities":[],"code":null}]},{"name":"United States","code":"1US","states":[{"name":"Arkansas","cities":[{"name":"Little Rock","aliases":["Little Rock"],"code":"LROAA","hotels":[{"name":"Capital Hotel","brand":"BC","code":"LITCH","pkid":"73664"}]}],"code":"2AR"},{"name":"California","cities":[{"name":"Beverly Hills","aliases":["Los Angeles"],"code":"BEV","hotels":[{"name":"The Mosaic Hotel Beverly Hills","brand":"BC","code":"LAXTM","pkid":"58293"}]},{"name":"Big Sur","aliases":["Big Sur"],"code":"BIGSU","hotels":[{"name":"Post Ranch Inn","brand":"BC","code":"MRYPR","pkid":"72315"}]},{"name":"Los Angeles","aliases":["Hollywood"],"code":"LOSAA","hotels":[{"name":"The Redbury @ Hollywood and Vine","brand":"BC","code":"LAXTR","pkid":"77084"}]},{"name":"San Diego/Coronado","aliases":["San Diego/Coronado"],"code":"CORO","hotels":[{"name":"Beach Village at The Del","brand":"BC","code":"SANBV","pkid":"69921"}]},{"name":"San Diego/Rancho Santa Fe","aliases":["San Diego/Rancho Santa Fe"],"code":"RANCH","hotels":[{"name":"The Inn at Rancho Santa Fe","brand":"BC","code":"SANIR","pkid":"77331"}]},{"name":"San Luis Obispo/Shell Beach","aliases":["San Luis Obispo/Shell Beach"],"code":"SBPAA","hotels":[{"name":"Dolphin Bay Resort & Spa","brand":"BC","code":"SBPDB","pkid":"72296"}]}],"code":"2CA"},{"name":"Colorado","cities":[{"name":"Beaver Creek","aliases":["Beaver Creek"],"code":"ZBV","hotels":[{"name":"Beaver Creek Lodge","brand":"BC","code":"EGEBC","pkid":"59775"}]},{"name":"Dolores","aliases":["Dolores"],"code":"TEXAA","hotels":[{"name":"Dunton Hot Springs","brand":"BC","code":"TEXDH","pkid":"77141"}]}],"code":"2CO"},{"name":"Florida","cities":[{"name":"Holmes Beach","aliases":["Holmes Beach"],"code":"HOLMB","hotels":[{"name":"Tidemark Lodge and Beach Resort","brand":"BC","code":"SRQTL","pkid":"62245"}]},{"name":"Lakeland","aliases":["Lakeland"],"code":"LAL","hotels":[{"name":"The Terrace Hotel","brand":"BC","code":"LALTH","pkid":"69959"}]},{"name":"Miami Beach","aliases":["Miami"],"code":"MIAAA","hotels":[{"name":"Dream South Beach","brand":"BC","code":"MIADS","pkid":"72372"}]},{"name":"St. Petersburg","aliases":["St. Petersburg"],"code":"STPET","hotels":[{"name":"The Hotel Zamora","brand":"BC","code":"PIEVC","pkid":"70643"}]}],"code":"2FL"},{"name":"Georgia","cities":[{"name":"Adairsville","aliases":["Atlanta/Adairsville"],"code":"ADAIR","hotels":[{"name":"Barnsley Gardens Resort","brand":"BC","code":"ATLBG","pkid":"63157"}]},{"name":"Atlanta","aliases":["Atlanta"],"code":"ATLAA","hotels":[{"name":"TWELVE Atlantic Station","brand":"BC","code":"ATL12","pkid":"59984"},{"name":"TWELVE Centennial Park","brand":"BC","code":"ATLTC","pkid":"62549"}]}],"code":"2GA"},{"name":"Hawaii","cities":[{"name":"Hana","aliases":["Hana"],"code":"HNMAA","hotels":[{"name":"Hotel Hana-Maui and Honua Spa","brand":"BC","code":"HNMHM","pkid":"72258"}]}],"code":"2HI"},{"name":"Massachusetts","cities":[{"name":"Boston","aliases":["Boston"],"code":"BOSAA","hotels":[{"name":"Fifteen Beacon","brand":"BC","code":"BOSXV","pkid":"48945"}]}],"code":"2MA"},{"name":"New York","cities":[{"name":"New York","aliases":["New York"],"code":"NYC","hotels":[{"name":"The Sherry-Netherland","brand":"BC","code":"NYCSN","pkid":"61333"}]}],"code":"2NY"},{"name":"North Carolina","cities":[{"name":"Highlands","aliases":["Highlands"],"code":"HIGHL","hotels":[{"name":"Old Edwards Inn and Spa","brand":"BC","code":"AVLOE","pkid":"59851"}]}],"code":"2NC"},{"name":"Oregon","cities":[{"name":"Newberg","aliases":["Newberg"],"code":"NEWB","hotels":[{"name":"The Allison Inn & Spa","brand":"BC","code":"PDXAI","pkid":"71840"}]}],"code":"2OR"},{"name":"Rhode Island","cities":[{"name":"Newport","aliases":["Newport"],"code":"NPTAA","hotels":[{"name":"The Chanler at Cliff Walk","brand":"BC","code":"NPTTC","pkid":"77065"}]},{"name":"Watch Hill","aliases":["Watch Hill"],"code":"WSTAA","hotels":[{"name":"Ocean House","brand":"BC","code":"WSTOH","pkid":"73797"}]}],"code":"2RI"},{"name":"South Carolina","cities":[{"name":"Charleston/Summerville","aliases":["Charleston/Summerville"],"code":"SUMME","hotels":[{"name":"Woodlands Inn","brand":"BC","code":"CHSWI","pkid":"72239"}]}],"code":"2SC"},{"name":"Tennessee","cities":[{"name":"Memphis","aliases":["Memphis"],"code":"MEM","hotels":[{"name":"River Inn of Harbor Town","brand":"BC","code":"MEMRI","pkid":"70738"}]}],"code":"2TN"},{"name":"Texas","cities":[{"name":"Austin","aliases":["Austin"],"code":"AUSAA","hotels":[{"name":"The Crossings","brand":"BC","code":"AUSTC","pkid":"75203"}]}],"code":"2TX"},{"name":"Utah","cities":[{"name":"Sundance","aliases":["Sundance"],"code":"SUND","hotels":[{"name":"Sundance Resort","brand":"BC","code":"SLCSR","pkid":"63100"}]}],"code":"2UT"},{"name":"Vermont","cities":[{"name":"Stowe","aliases":["Stowe"],"code":"MVL","hotels":[{"name":"Topnotch Resort and Spa","brand":"BC","code":"BTVTN","pkid":"47501"}]}],"code":"2VT"},{"name":"Virginia","cities":[{"name":"Abingdon","aliases":["Abingdon"],"code":"VJIAA","hotels":[{"name":"The Martha Washington Hotel & Spa","brand":"BC","code":"VJIMW","pkid":"73683"}]}],"code":"2VA"},{"name":"Wisconsin","cities":[{"name":"Delafield/Milwaukee","aliases":["Delafield/Milwaukee"],"code":"DELA","hotels":[{"name":"The Delafield Hotel","brand":"BC","code":"MKEDH","pkid":"72220"}]}],"code":"2WI"},{"name":"Wyoming","cities":[{"name":"Jackson","aliases":["Jackson"],"code":"JACAA","hotels":[{"name":"The Wort Hotel","brand":"BC","code":"JACWH","pkid":"66577"}]},{"name":"Savery","aliases":["Savery"],"code":"HDNAA","hotels":[{"name":"Three Forks Ranch Lodge & Spa","brand":"BC","code":"HDNTF","pkid":"62815"}]}],"code":"2WY"}]}];
PHGInfo.currentHotelID = "";

PHGInfo.currentBrand = PHGInfo.brands["BC"];
