document.write('<link href=\"http://phgoffers.com/widgets/SearchWidget/css/calendar.XL.css\" type=\"text/css\" rel=\"Stylesheet\" />');
document.write('<link href=\"http://phgoffers.com/widgets/SearchWidget/css/XL-theme/jquery.XL.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":"Austria","code":"1AT","states":[{"name":"","cities":[{"name":"Lochau","aliases":["Lochau"],"code":"LOCHA","hotels":[{"name":"Seehotel Am Kaiserstrand","brand":"XL","code":"ZRHSA","pkid":"76970"}]}],"code":null}]},{"name":"Belgium","code":"1BE","states":[{"name":"","cities":[{"name":"Brussels","aliases":["Brussels"],"code":"BRUAD","hotels":[{"name":"Hotel Metropole","brand":"XL","code":"BRUHM","pkid":"47216"}]}],"code":null}]},{"name":"Bolivia","code":"1BO","states":[{"name":"","cities":[{"name":"La Paz","aliases":["La Paz"],"code":"LAPAA","hotels":[{"name":"Hotel Europa","brand":"XL","code":"LPBEH","pkid":"41706"}]}],"code":null}]},{"name":"Brazil","code":"1BR","states":[{"name":"","cities":[{"name":"Belo Horizonte","aliases":["Belo Horizonte"],"code":"BELAG","hotels":[{"name":"Ouro Minas Palace Hotel","brand":"XL","code":"PLUOM","pkid":"41402"}]}],"code":null}]},{"name":"Cambodia","code":"1KH","states":[{"name":"","cities":[{"name":"Siem Reap","aliases":["Siem Reap"],"code":"REP","hotels":[{"name":"Angkor Palace Resort & Spa","brand":"XL","code":"REPAP","pkid":"71289"}]}],"code":null},{"name":"","cities":[],"code":null}]},{"name":"Canada","code":"1CA","states":[{"name":"British Columbia","cities":[{"name":"Vancouver","aliases":["Vancouver"],"code":"VANAA","hotels":[{"name":"The Hotel at Terminal City Club","brand":"XL","code":"YVRTC","pkid":"74234"}]}],"code":"2BC"},{"name":"Ontario","cities":[{"name":"Toronto","aliases":["Toronto"],"code":"YYZ","hotels":[{"name":"Metropolitan Hotel Toronto","brand":"XL","code":"YYZME","pkid":"50218"}]}],"code":"2ON"},{"name":"Ontario","cities":[],"code":"2ON"}]},{"name":"China","code":"1CN","states":[{"name":"","cities":[{"name":"Chengdu","aliases":["Chengdu"],"code":"CTUAA","hotels":[{"name":"Regal Master Hotel","brand":"XL","code":"CTURM","pkid":"74253"}]},{"name":"Guangzhou","aliases":["Guangzhou"],"code":"GUAAC","hotels":[{"name":"DongFang Hotel","brand":"XL","code":"CANDF","pkid":"62948"}]},{"name":"Shanghai","aliases":["Shanghai"],"code":"SHAAA","hotels":[{"name":"Parkyard Hotel Shanghai","brand":"XL","code":"SHAPH","pkid":"63575"},{"name":"Regal International East Asia Hotel","brand":"XL","code":"SHARI","pkid":"59376"}]},{"name":"Shenzhen","aliases":["Shenzhen"],"code":"SZXAA","hotels":[{"name":"The Panglin Hotel","brand":"XL","code":"SZXPH","pkid":"60896"}]}],"code":null}]},{"name":"Colombia","code":"1CO","states":[{"name":"","cities":[{"name":"Bogota","aliases":["Bogota"],"code":"BOGAA","hotels":[{"name":"Bogotá Plaza Summit Hotel","brand":"XL","code":"BOGPH","pkid":"41668"}]}],"code":null}]},{"name":"Cyprus","code":"1CY","states":[{"name":"","cities":[{"name":"Paralimni","aliases":["Paralimni"],"code":"PARAB","hotels":[{"name":"Grecian Park Hotel","brand":"XL","code":"LCAGP","pkid":"42656"}]}],"code":null}]},{"name":"Czech Republic","code":"1CZ","states":[{"name":"","cities":[{"name":"Karlovy Vary","aliases":["Karlovy Vary"],"code":"KARAD","hotels":[{"name":"Grandhotel Pupp","brand":"XL","code":"PRGGP","pkid":"42257"}]},{"name":"Prague","aliases":["Prague"],"code":"PRAAA","hotels":[{"name":"andel's hotel & Suites Prague","brand":"XL","code":"PRGAH","pkid":"52346"}]}],"code":null}]},{"name":"Dominican Republic","code":"1DO","states":[{"name":"","cities":[{"name":"Punta Cana","aliases":["Punta Cana"],"code":"PUJAA","hotels":[{"name":"Dreams Punta Cana Resort & Spa","brand":"XL","code":"PUJTB","pkid":"55766"}]}],"code":null}]},{"name":"Estonia","code":"1EE","states":[{"name":"","cities":[{"name":"Tallinn","aliases":["St. Petersburg"],"code":"TALAA","hotels":[{"name":"Hotel St. Petersbourg","brand":"XL","code":"TLLSP","pkid":"43036"}]}],"code":null}]},{"name":"France","code":"1FR","states":[{"name":"","cities":[{"name":"Cannes","aliases":["Cannes"],"code":"CANAC","hotels":[{"name":"Hôtel Gray d'Albion","brand":"XL","code":"JCAGD","pkid":"40908"}]},{"name":"Nice","aliases":["Nice"],"code":"NICE","hotels":[{"name":"Beau Rivage Hôtel et Plage","brand":"XL","code":"NCEBR","pkid":"61922"}]},{"name":"Paris","aliases":["Paris"],"code":"PARAE","hotels":[{"name":"Hotel François 1er","brand":"XL","code":"PARFR","pkid":"41136"},{"name":"Hotel Napoleon Paris","brand":"XL","code":"PARNA","pkid":"40946"}]}],"code":null}]},{"name":"Germany","code":"1DE","states":[{"name":"","cities":[{"name":"Berlin","aliases":["Berlin"],"code":"BERAE","hotels":[{"name":"andel's Hotel Berlin","brand":"XL","code":"BERAH","pkid":"71422"}]},{"name":"Hamburg","aliases":["Hamburg"],"code":"HAMAB","hotels":[{"name":"Empire Riverside Hotel","brand":"XL","code":"HAMER","pkid":"63385"}]},{"name":"Lindau (Lake Constance)","aliases":["Lindau (Lake Constance)"],"code":"LINDA","hotels":[{"name":"Hotel Bad Schachen","brand":"XL","code":"ZRNBS","pkid":"41592"}]},{"name":"Munich","aliases":["Munich"],"code":"MUNAA","hotels":[{"name":"Hotel Excelsior","brand":"XL","code":"MUCEH","pkid":"42998"}]}],"code":null}]},{"name":"Greece","code":"1GR","states":[{"name":"","cities":[{"name":"Santorini","aliases":["Santorini"],"code":"JTRAA","hotels":[{"name":"9 Muses Santorini Resort","brand":"XL","code":"JTR9M","pkid":"73360"}]}],"code":null}]},{"name":"Guatemala","code":"1GT","states":[{"name":"","cities":[{"name":"La Antigua","aliases":["La Antigua"],"code":"LAAN","hotels":[{"name":"Porta Hotel Antigua","brand":"XL","code":"GUAPA","pkid":"70662"}]}],"code":null}]},{"name":"Hong Kong","code":"1HK","states":[{"name":"","cities":[{"name":"Hong Kong","aliases":["Chek Lap Kok","Hong Kong"],"code":"HONAA","hotels":[{"name":"East","brand":"XL","code":"HKGEH","pkid":"72809"},{"name":"Harbour Grand Hong Kong","brand":"XL","code":"HKGHG","pkid":"73132"},{"name":"Regal Airport Hotel Meeting & Conference Center","brand":"XL","code":"HKGRA","pkid":"59338"},{"name":"Regal Hongkong Hotel","brand":"XL","code":"HKGRH","pkid":"59357"}]}],"code":null}]},{"name":"India","code":"1IN","states":[{"name":"","cities":[{"name":"Bangalore","aliases":["Bangalore"],"code":"BLR","hotels":[{"name":"Ista Bangalore","brand":"XL","code":"BLRIB","pkid":"71175"},{"name":"The Zuri Whitefield Bengaluru","brand":"XL","code":"BLRTZ","pkid":"70719"}]},{"name":"Cochin","aliases":["Cochin"],"code":"COCHI","hotels":[{"name":"Dream Cochin","brand":"XL","code":"COKDC","pkid":"73075"}]},{"name":"Goa","aliases":["Goa"],"code":"GOIAA","hotels":[{"name":"The Zuri White Sands Resort & Casino, Goa","brand":"XL","code":"GOITZ","pkid":"74044"}]},{"name":"New Delhi","aliases":["New Delhi"],"code":"DELH","hotels":[{"name":"The Suryaa, New Delhi","brand":"XL","code":"DELTS","pkid":"77103"}]}],"code":null}]},{"name":"Indonesia","code":"1ID","states":[{"name":"","cities":[{"name":"Bali","aliases":["Bali"],"code":"BALAB","hotels":[{"name":"Le Grande Bali","brand":"XL","code":"DPSLG","pkid":"74633"}]}],"code":null}]},{"name":"Ireland","code":"1IE","states":[{"name":"","cities":[{"name":"Dublin","aliases":["Dublin"],"code":"DUBAA","hotels":[{"name":"The Gibson Hotel","brand":"XL","code":"DUBGH","pkid":"76286"}]}],"code":null}]},{"name":"Italy","code":"1IT","states":[{"name":"","cities":[{"name":"Como","aliases":["Como"],"code":"QCMAA","hotels":[{"name":"Grand Hotel di Como","brand":"XL","code":"LUGHC","pkid":"73569"}]},{"name":"Florence","aliases":["Florence"],"code":"FLOAB","hotels":[{"name":"Grand Hotel Baglioni","brand":"XL","code":"FLRGB","pkid":"53182"},{"name":"Grand Hotel Minerva","brand":"XL","code":"FLRGM","pkid":"42466"},{"name":"Hotel Albani","brand":"XL","code":"FLRAF","pkid":"43245"},{"name":"Hotel Brunelleschi","brand":"XL","code":"FLRGH","pkid":"43169"},{"name":"Plaza Hotel Lucchesi","brand":"XL","code":"FLRPL","pkid":"42200"}]},{"name":"Milan","aliases":["Milan"],"code":"MILAA","hotels":[{"name":"Brunelleschi Hotel Milano","brand":"XL","code":"LINBR","pkid":"43112"},{"name":"Enterprise Hotel","brand":"XL","code":"LINEH","pkid":"51529"},{"name":"Hotel De La Ville","brand":"XL","code":"LINVH","pkid":"43302"}]},{"name":"Milan Assago","aliases":["Milan"],"code":"MILAG","hotels":[{"name":"Royal Garden Hotel","brand":"XL","code":"LINRG","pkid":"43264"}]},{"name":"Naples","aliases":["Naples"],"code":"NAPAB","hotels":[{"name":"Grand Hotel Santa Lucia","brand":"XL","code":"ACKGH","pkid":"43321"}]},{"name":"Palermo","aliases":["Palermo"],"code":"PALAB","hotels":[{"name":"Hotel Plaza Opéra","brand":"XL","code":"PMOPO","pkid":"62872"}]},{"name":"Parma","aliases":["Parma"],"code":"PARAG","hotels":[{"name":"Hotel Palace Maria Luigia","brand":"XL","code":"PMFPM","pkid":"60402"}]},{"name":"Positano","aliases":["Positano"],"code":"POSAA","hotels":[{"name":"Covo Dei Saraceni","brand":"XL","code":"NAPCD","pkid":"43340"}]},{"name":"Riva del Garda","aliases":["Riva del Garda"],"code":"RIVA","hotels":[{"name":"Du Lac et Du Parc Grand Resort","brand":"XL","code":"VRNDD","pkid":"63556"}]},{"name":"Rome","aliases":["Rome"],"code":"ROM","hotels":[{"name":"Hotel Bernini Bristol","brand":"XL","code":"FCOBB","pkid":"42428"}]},{"name":"Sorrento","aliases":["Sorrento"],"code":"RRO","hotels":[{"name":"Hotel Parco dei Principi","brand":"XL","code":"RROPP","pkid":"64050"}]},{"name":"Venice","aliases":["Venice"],"code":"VENAA","hotels":[{"name":"Hotel Monaco & Grand Canal","brand":"XL","code":"VCEMG","pkid":"42960"},{"name":"Metropole Hotel","brand":"XL","code":"VCEMH","pkid":"42770"},{"name":"Palace Bonvecchiati","brand":"XL","code":"VCEPB","pkid":"55253"}]},{"name":"Vietri Sul Mare","aliases":["Amalfi Coast"],"code":"VIETR","hotels":[{"name":"Hotel Raito","brand":"XL","code":"NAPHR","pkid":"61865"}]}],"code":null}]},{"name":"Japan","code":"1JP","states":[{"name":"","cities":[{"name":"Tokyo","aliases":["Tokyo"],"code":"TOKAA","hotels":[{"name":"Grand Pacific LE DAIBA","brand":"XL","code":"TYOGP","pkid":"63879"},{"name":"Hotel Pacific Tokyo","brand":"XL","code":"TYOHP","pkid":"63822"},{"name":"Keio Plaza Hotel Tokyo","brand":"XL","code":"TYOKP","pkid":"54341"},{"name":"Royal Park Hotel","brand":"XL","code":"NRTRP","pkid":"40699"}]},{"name":"Yokohama","aliases":["Yokohama"],"code":"YOKAA","hotels":[{"name":"Yokohama Royal Park Hotel","brand":"XL","code":"NRTYR","pkid":"40737"}]}],"code":null}]},{"name":"Kenya","code":"1KE","states":[{"name":"","cities":[{"name":"Nairobi","aliases":["Nairobi"],"code":"NAIAB","hotels":[{"name":"The Sarova Stanley","brand":"XL","code":"NBOSH","pkid":"42105"}]}],"code":null}]},{"name":"Korea","code":"1KR","states":[{"name":"","cities":[{"name":"Seoul","aliases":["Seoul"],"code":"SEOAA","hotels":[{"name":"Imperial Palace, Seoul","brand":"XL","code":"SELIP","pkid":"58559"}]}],"code":null}]},{"name":"Madagascar","code":"1MG","states":[{"name":"","cities":[{"name":"Antananarivo","aliases":["Antananarivo"],"code":"TNR","hotels":[{"name":"Hotel Carlton","brand":"XL","code":"TNRCM","pkid":"70301"}]}],"code":null}]},{"name":"Mexico","code":"1MX","states":[{"name":"","cities":[{"name":"Mexico City","aliases":["Mexico City"],"code":"MCTY","hotels":[{"name":"Meliá México Reforma","brand":"XL","code":"MEXMM","pkid":"76951"}]}],"code":null},{"name":"Baja California Sur","cities":[{"name":"Los Cabos","aliases":["Los Cabos"],"code":"LOSLC","hotels":[{"name":"Meliá Cabo Real","brand":"XL","code":"SJDMC","pkid":"76989"}]}],"code":"2BCS"},{"name":"Guerrero","cities":[{"name":"Acapulco","aliases":["Acapulco"],"code":"ACAAA","hotels":[{"name":"Emporio Acapulco","brand":"XL","code":"ACAEA","pkid":"70852"}]},{"name":"Ixtapa-Zihuatanejo","aliases":["Ixtapa-Zihuatanejo"],"code":"ZIH","hotels":[{"name":"Emporio Ixtapa","brand":"XL","code":"ZIHEI","pkid":"70871"}]}],"code":"2GRO"},{"name":"Oaxaca","cities":[{"name":"Huatulco","aliases":["Huatulco"],"code":"HUAAB","hotels":[{"name":"Las Brisas Huatulco","brand":"XL","code":"HUXLB","pkid":"76457"}]}],"code":"2OAX"},{"name":"Oaxaca","cities":[],"code":"2OAX"}]},{"name":"Mongolia","code":"1MN","states":[{"name":"","cities":[{"name":"Ulaanbaatar","aliases":["Ulaanbaatar"],"code":"ULNAA","hotels":[{"name":"Chinggis Khaan Hotel","brand":"XL","code":"ULNCK","pkid":"77008"}]}],"code":null}]},{"name":"Morocco","code":"1MA","states":[{"name":"","cities":[{"name":"Marrakech","aliases":["Marrakech"],"code":"RAKAA","hotels":[{"name":"Es Saadi Hotel","brand":"XL","code":"RAKES","pkid":"52536"},{"name":"Kenzi Menara Palace","brand":"XL","code":"RAKKM","pkid":"76001"}]}],"code":null}]},{"name":"Netherlands","code":"1NL","states":[{"name":"","cities":[{"name":"Amsterdam","aliases":["Amsterdam"],"code":"AMS","hotels":[{"name":"Eden Amsterdam American Hotel","brand":"XL","code":"AMSAH","pkid":"56165"},{"name":"Eden Rembrandt Square Hotel","brand":"XL","code":"AMSER","pkid":"59414"}]},{"name":"Den Haag","aliases":[""],"code":"DENAA","hotels":[{"name":"Eden Babylon Hotel Den Haag","brand":"XL","code":"HAGEH","pkid":"62663"}]},{"name":"Maastricht","aliases":["Maastricht"],"code":"MSTAA","hotels":[{"name":"Eden Designhotel Maastricht","brand":"XL","code":"MSTLB","pkid":"63689"}]}],"code":null}]},{"name":"Panama","code":"1PA","states":[{"name":"","cities":[{"name":"Panama City","aliases":["Panama City"],"code":"PANAA","hotels":[{"name":"El Panama Hotel","brand":"XL","code":"PFNEP","pkid":"41364"}]}],"code":null}]},{"name":"Peru","code":"1PE","states":[{"name":"","cities":[{"name":"Cusco","aliases":["Cusco"],"code":"CUSAA","hotels":[{"name":"Libertador Palacio del Inka, Cusco","brand":"XL","code":"CUZLC","pkid":"42599"}]},{"name":"Lima","aliases":["Lima"],"code":"LIMAB","hotels":[{"name":"Casa Andina Private Collection - Miraflores","brand":"XL","code":"LIMCA","pkid":"65000"},{"name":"Delfines Hotel & Casino","brand":"XL","code":"LIMLD","pkid":"41687"}]}],"code":null}]},{"name":"Philippines","code":"1PH","states":[{"name":"","cities":[{"name":"Cebu","aliases":["Cebu"],"code":"CEBAA","hotels":[{"name":"Imperial Palace Waterpark Resort & Spa","brand":"XL","code":"CEBIP","pkid":"73284"}]}],"code":null}]},{"name":"Poland","code":"1PL","states":[{"name":"","cities":[{"name":"Lodz","aliases":["Lodz"],"code":"LCJAA","hotels":[{"name":"andel's Hotel Lodz","brand":"XL","code":"LCJAH","pkid":"71403"}]}],"code":null}]},{"name":"Puerto Rico","code":"1PR","states":[{"name":"","cities":[{"name":"San Juan","aliases":["San Juan, Isla Verde Carolina"],"code":"SJUAA","hotels":[{"name":"Verdanza Hotel, San Juan","brand":"XL","code":"SJUVH","pkid":"73436"}]}],"code":null}]},{"name":"Singapore","code":"1SG","states":[{"name":"","cities":[{"name":"Singapore","aliases":["Singapore"],"code":"SINAB","hotels":[{"name":"Royal Plaza on Scotts","brand":"XL","code":"SINRP","pkid":"40775"}]}],"code":null}]},{"name":"Slovakia","code":"1SK","states":[{"name":"","cities":[{"name":"Bratislava","aliases":["Bratislava"],"code":"BTSAA","hotels":[{"name":"Hotel Gate One","brand":"XL","code":"BTSGO","pkid":"74424"}]}],"code":null}]},{"name":"South Africa","code":"1ZA","states":[{"name":"","cities":[{"name":"Cape Town","aliases":["Cape Town"],"code":"CAPAA","hotels":[{"name":"The Peninsula All-Suite Hotel","brand":"XL","code":"CPTPA","pkid":"40870"}]},{"name":"Somerset West","aliases":["Cape Town"],"code":"SOMER","hotels":[{"name":"Erinvale Estate Hotel & Spa","brand":"XL","code":"CPTEE","pkid":"74405"}]},{"name":"Stellenbosch","aliases":["Stellenbosch"],"code":"STELL","hotels":[{"name":"The Devon Valley Hotel","brand":"XL","code":"CPTDV","pkid":"74386"}]}],"code":null}]},{"name":"Spain","code":"1ES","states":[{"name":"","cities":[{"name":"Barcelona","aliases":["Barcelona"],"code":"BARAA","hotels":[{"name":"Hotel Fira Palace","brand":"XL","code":"BCNFP","pkid":"41459"}]},{"name":"Madrid","aliases":["Madrid"],"code":"MADAD","hotels":[{"name":"Hotel Wellington","brand":"XL","code":"MADWH","pkid":"43093"}]},{"name":"Valencia","aliases":["Valencia"],"code":"VALAA","hotels":[{"name":"Ayre Hotel Astoria Palace","brand":"XL","code":"VLCAP","pkid":"42580"}]}],"code":null}]},{"name":"Switzerland","code":"1CH","states":[{"name":"","cities":[{"name":"Basel","aliases":["Basel"],"code":"BASAA","hotels":[{"name":"Hotel Euler","brand":"XL","code":"BSLEH","pkid":"41744"}]},{"name":"Lausanne-Ouchy","aliases":["Lausanne-Ouchy"],"code":"LAUAB","hotels":[{"name":"Hotel Angleterre and Residence","brand":"XL","code":"GVALE","pkid":"42542"}]},{"name":"Lugano","aliases":["Lugano"],"code":"LUGAA","hotels":[{"name":"Grand Hotel Eden","brand":"XL","code":"LUGGH","pkid":"42751"}]},{"name":"St. Moritz","aliases":["St. Moritz"],"code":"STMAA","hotels":[{"name":"Hotel Monopol","brand":"XL","code":"ZRHHM","pkid":"62169"}]},{"name":"Zurich","aliases":["Zurich","Zürich"],"code":"ZURAA","hotels":[{"name":"Hotel Ascot","brand":"XL","code":"ZRHHA","pkid":"51719"},{"name":"Hotel St. Gotthard","brand":"XL","code":"ZRHSG","pkid":"41630"},{"name":"Hotel zum Storchen","brand":"XL","code":"ZRHZS","pkid":"41307"}]}],"code":null}]},{"name":"Thailand","code":"1TH","states":[{"name":"","cities":[{"name":"Bangkok","aliases":["Bangkok"],"code":"BANAD","hotels":[{"name":"The Landmark Bangkok","brand":"XL","code":"BKKLB","pkid":"40490"}]},{"name":"Khao Lak","aliases":["Khao Lak"],"code":"KHAOA","hotels":[{"name":"La Flora Resort & Spa Khao Lak","brand":"XL","code":"HKTFK","pkid":"73949"}]},{"name":"Koh Samui, Surat Thani","aliases":["Koh Samui, Surat Thani"],"code":"SAMAB","hotels":[{"name":"The Tongsai Bay","brand":"XL","code":"USMTB","pkid":"41269"}]},{"name":"Phuket","aliases":["Phuket"],"code":"PHUAA","hotels":[{"name":"La Flora Resort Patong","brand":"XL","code":"HKTFR","pkid":"72790"}]}],"code":null}]},{"name":"Turkey","code":"1TR","states":[{"name":"","cities":[{"name":"Ankara","aliases":["Ankara"],"code":"ANKAA","hotels":[{"name":"Ankara Hotel Midi","brand":"XL","code":"ANKHM","pkid":"58597"},{"name":"Divan Ankara","brand":"XL","code":"ANKDA","pkid":"76894"}]},{"name":"Antalya","aliases":["Antalya"],"code":"AYTAA","hotels":[{"name":"Divan Antalya","brand":"XL","code":"AYTDA","pkid":"76780"}]}],"code":null}]},{"name":"United Arab Emirates","code":"1AE","states":[{"name":"","cities":[{"name":"Abu Dhabi","aliases":["Abu Dhabi"],"code":"ABUAA","hotels":[{"name":"Cristal Hotel Salam","brand":"XL","code":"AUHCS","pkid":"77236"}]}],"code":null}]},{"name":"United Kingdom","code":"1UK","states":[{"name":"","cities":[{"name":"Leeds","aliases":["Leeds"],"code":"LBAAA","hotels":[{"name":"42 The Calls","brand":"XL","code":"LBA42","pkid":"70966"},{"name":"Quebecs","brand":"XL","code":"LBAQS","pkid":"51814"}]},{"name":"London","aliases":["London"],"code":"LON3","hotels":[{"name":"Lancaster London","brand":"XL","code":"LONLL","pkid":"74861"},{"name":"myhotel Bloomsbury","brand":"XL","code":"LONMB","pkid":"64202"},{"name":"myhotel Chelsea","brand":"XL","code":"LONMC","pkid":"64183"},{"name":"The Academy","brand":"XL","code":"LONAY","pkid":"51776"},{"name":"The Colonnade, London","brand":"XL","code":"LONCE","pkid":"51795"},{"name":"The Mandeville Hotel","brand":"XL","code":"LONMH","pkid":"63651"}]}],"code":null},{"name":"","cities":[],"code":null}]},{"name":"United States","code":"1US","states":[{"name":"Alabama","cities":[{"name":"Birmingham","aliases":["Birmingham"],"code":"BHM","hotels":[{"name":"The Wynfrey Hotel at Riverchase Galleria","brand":"XL","code":"BHMWH","pkid":"47368"}]}],"code":"2AL"},{"name":"Arizona","cities":[{"name":"Tucson","aliases":[""],"code":"TUCAA","hotels":[{"name":"Hacienda del Sol Guest Ranch Resort","brand":"XL","code":"TUSHS","pkid":"70833"}]}],"code":"2AZ"},{"name":"California","cities":[{"name":"Los Angeles","aliases":["Los Angeles"],"code":"LOSAA","hotels":[{"name":"The Orlando","brand":"XL","code":"LAXTO","pkid":"57818"}]},{"name":"Napa","aliases":["Napa"],"code":"NAAPA","hotels":[{"name":"The Meritage Resort and Spa","brand":"XL","code":"APCMH","pkid":"58027"}]},{"name":"Westlake Village/Los Angeles","aliases":["Los Angeles"],"code":"WESTL","hotels":[{"name":"Westlake Village Inn","brand":"XL","code":"LAXWV","pkid":"64411"}]}],"code":"2CA"},{"name":"Colorado","cities":[{"name":"Crested Butte","aliases":["Crested Butte"],"code":"CSE","hotels":[{"name":"Elevation Hotel & Spa","brand":"XL","code":"CSEEH","pkid":"70016"},{"name":"The Lodge at Mountaineer Square","brand":"XL","code":"CSELM","pkid":"70035"}]},{"name":"Keystone","aliases":["Keystone"],"code":"QKS","hotels":[{"name":"Keystone Lodge & Spa","brand":"XL","code":"KEYKL","pkid":"48090"}]}],"code":"2CO"},{"name":"Florida","cities":[{"name":"Fort Lauderdale","aliases":["Fort Lauderdale"],"code":"FORAC","hotels":[{"name":"il Lugano Suite Hotel","brand":"XL","code":"FLLIL","pkid":"63803"}]},{"name":"Jupiter Beach","aliases":["Jupiter"],"code":"JUPIT","hotels":[{"name":"Jupiter Beach Resort and Spa","brand":"XL","code":"PBIJB","pkid":"75089"}]},{"name":"Miami","aliases":["Miami"],"code":"MIAAB","hotels":[{"name":"The Mutiny Hotel","brand":"XL","code":"MIAMU","pkid":"55652"}]}],"code":"2FL"},{"name":"Hawaii","cities":[{"name":"Honolulu","aliases":["Honolulu"],"code":"HNL","hotels":[{"name":"Waikiki Parc Hotel","brand":"XL","code":"HNLWP","pkid":"63024"}]}],"code":"2HI"},{"name":"Idaho","cities":[{"name":"Boise","aliases":["Boise"],"code":"BOIAA","hotels":[{"name":"The Grove Hotel","brand":"XL","code":"BOIGH","pkid":"71479"}]}],"code":"2ID"},{"name":"Illinois","cities":[{"name":"Glenview","aliases":["Chicago"],"code":"GLENV","hotels":[{"name":"The Glen Club","brand":"XL","code":"CHIGC","pkid":"74139"}]}],"code":"2IL"},{"name":"Indiana","cities":[{"name":"French Lick","aliases":["French Lick"],"code":"FRHL","hotels":[{"name":"French Lick Springs Hotel","brand":"XL","code":"SDFFR","pkid":"70548"}]},{"name":"New Harmony","aliases":["New Harmony"],"code":"EVVAA","hotels":[{"name":"New Harmony Inn","brand":"XL","code":"EVVNH","pkid":"71080"}]}],"code":"2IN"},{"name":"Iowa","cities":[{"name":"Davenport","aliases":["Davenport"],"code":"DVNAA","hotels":[{"name":"Hotel Blackhawk","brand":"XL","code":"DVNHB","pkid":"74272"}]}],"code":"2IA"},{"name":"Louisiana","cities":[{"name":"New Orleans","aliases":["New Orleans"],"code":"MSYAA","hotels":[{"name":"Bienville House","brand":"XL","code":"MSYBH","pkid":"60839"}]}],"code":"2LA"},{"name":"Maine","cities":[{"name":"Rockport","aliases":["Rockport"],"code":"RKDAA","hotels":[{"name":"Samoset Resort","brand":"XL","code":"RKDSR","pkid":"75108"}]}],"code":"2ME"},{"name":"Maryland","cities":[{"name":"Baltimore","aliases":["Baltimore"],"code":"BWI","hotels":[{"name":"Pier 5 Hotel","brand":"XL","code":"BWIP5","pkid":"74975"}]},{"name":"Rockville","aliases":["Washington/Rockville"],"code":"ROCKV","hotels":[{"name":"The Legacy Hotel","brand":"XL","code":"WASLH","pkid":"63214"}]}],"code":"2MD"},{"name":"Massachusetts","cities":[{"name":"Boston","aliases":["Boston"],"code":"BOSAA","hotels":[{"name":"Colonnade Boston Copley Square Back Bay","brand":"XL","code":"BOSCO","pkid":"40452"},{"name":"Seaport Hotel & World Trade Center","brand":"XL","code":"BOSSH","pkid":"43948"}]}],"code":"2MA"},{"name":"Michigan","cities":[{"name":"Detroit","aliases":["Detroit"],"code":"DETAA","hotels":[{"name":"Atheneum Suite Hotel","brand":"XL","code":"DTWAS","pkid":"40376"}]}],"code":"2MI"},{"name":"Minnesota","cities":[{"name":"Nisswa","aliases":["Nisswa"],"code":"BRDAA","hotels":[{"name":"Grand View Lodge","brand":"XL","code":"BRDGL","pkid":"71118"}]}],"code":"2MN"},{"name":"New Jersey","cities":[{"name":"Summit","aliases":["Summit"],"code":"SUMMT","hotels":[{"name":"The Grand Summit Hotel","brand":"XL","code":"EWRGS","pkid":"41041"}]}],"code":"2NJ"},{"name":"New Mexico","cities":[{"name":"Albuquerque","aliases":["Albuquerque"],"code":"ABQ","hotels":[{"name":"Hotel Albuquerque at Old Town","brand":"XL","code":"ABQHA","pkid":"61523"}]},{"name":"Santa Fe","aliases":["Santa Fe"],"code":"SAF","hotels":[{"name":"Hotel St. Francis","brand":"XL","code":"SAFHS","pkid":"72334"}]}],"code":"2NM"},{"name":"New York","cities":[{"name":"New York","aliases":["New York"],"code":"NYC","hotels":[{"name":"The Kitano New York","brand":"XL","code":"NYCKN","pkid":"41098"}]}],"code":"2NY"},{"name":"North Carolina","cities":[{"name":"Chapel Hill","aliases":["Chapel Hill/Raleigh-Durham"],"code":"CHAAD","hotels":[{"name":"The Siena Hotel","brand":"XL","code":"RDUSH","pkid":"40509"}]}],"code":"2NC"},{"name":"Ohio","cities":[{"name":"Columbus","aliases":["Columbus"],"code":"CMHAA","hotels":[{"name":"The Blackwell","brand":"XL","code":"CMHTB","pkid":"54493"}]}],"code":"2OH"},{"name":"Oklahoma","cities":[{"name":"Tulsa","aliases":["Tulsa"],"code":"TULAA","hotels":[{"name":"The Mayo Hotel and Residences","brand":"XL","code":"TULMH","pkid":"72752"}]}],"code":"2OK"},{"name":"Rhode Island","cities":[{"name":"Newport","aliases":["Newport"],"code":"NPTAA","hotels":[{"name":"Vanderbilt Hall Hotel","brand":"XL","code":"NPTVH","pkid":"57039"}]}],"code":"2RI"},{"name":"Utah","cities":[{"name":"Park City","aliases":["Park City"],"code":"PARK","hotels":[{"name":"The Chateaux at Silver Lake","brand":"XL","code":"SLCTC","pkid":"76020"}]}],"code":"2UT"},{"name":"Washington","cities":[{"name":"Bellingham","aliases":["Bellingham"],"code":"BLI","hotels":[{"name":"Hotel Bellwether","brand":"XL","code":"BLIHB","pkid":"64126"}]},{"name":"Seattle/Tulalip","aliases":["Seattle/Tulalip"],"code":"PAE","hotels":[{"name":"Tulalip Resort Casino","brand":"XL","code":"PAETR","pkid":"69902"}]}],"code":"2WA"}]}];
PHGInfo.currentHotelID = "";

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