function setOmnitureSearchParams() {

} 
var hotelExplorer = {
  requestURL: "/ajax/property_filter_json.jsp?removeAll=true",
  returnCriteria: "",
  lastQueryUrl: "",
  trackedFirstResults:false,
  hotels: [],
  filteredResult: [],
  filterParams: {
    WebRegion: "",
    CountryName: "",
    StateName: "",
    City: "",
    DestinationCategory: "",
    arrivalDate: "",
    departureDate: "",
    Amenities: {}
  },
  localeCode: null,
  request: null,
  displayMethod: "name",
  dateFormatString: "",
  thumbsArray: [],
  arrivalDate:"",
  departureDate:"",
  settings: {
        minLoadTime:1,
        amenityToolTipTopOffset:175
  },
  initialize: function () {
//    var debugLogger = new YAHOO.widget.LogReader();
    yuiDom.get("inpRegion").config = {category: "WebRegion", top: null, bottom: yuiDom.get("inpCountry")};
    yuiDom.get("inpCountry").config = {category: "CountryName", top: yuiDom.get("inpRegion"), bottom: yuiDom.get("inpState")};
    yuiDom.get("inpState").config = {category: "StateName", top: yuiDom.get("inpCountry"), bottom: yuiDom.get("inpCity"), skip: true};
    yuiDom.get("inpCity").config = {category: "City", top: yuiDom.get("inpState"), bottom: null};
    hotelExplorer.location.resetRegionSelect();
    hotelExplorer.location.currentSelect = yuiDom.get("inpRegion");
        if(hotelExplorer.brandCode) {
            hotelExplorer.requestURL = hotelExplorer.requestURL + "&brandCode="+hotelExplorer.brandCode;
        }
    yuiEvent.addListener(
      yuiDom.get("inpRegion"),
      "change",
      hotelExplorer.location.setFilter,
      {
        input: yuiDom.get("inpRegion"),
        reset: [{input:yuiDom.get("inpCountry")},{input: yuiDom.get("inpState")},{input: yuiDom.get("inpCity")}]
      }
    );
    yuiEvent.addListener(
      yuiDom.get("inpCountry"),
      "change",
      hotelExplorer.location.setFilter,
      {
        input: yuiDom.get("inpCountry"),
        reset: [{input: yuiDom.get("inpState")},{input: yuiDom.get("inpCity")}]
      }
    );
    yuiEvent.addListener(
      yuiDom.get("inpState"),
      "change",
      hotelExplorer.location.setFilter,
      {
        input: yuiDom.get("inpState"),
        reset: [{input: yuiDom.get("inpCity")}]
      }
    );
    yuiEvent.addListener(
      yuiDom.get("inpCity"),
      "change",
      hotelExplorer.location.setFilter,
      {
        input: yuiDom.get("inpCity")
      }
    );

    yuiEvent.addListener(
      yuiDom.get("inpPopularDestination"),
      "change",
      hotelExplorer.location.setDestinationFilter,
      yuiDom.get("inpPopularDestination")
    );
    yuiEvent.addListener(
      yuiDom.get("inpTopRegionalDestination"),
      "change",
      hotelExplorer.location.setDestinationFilter,
      yuiDom.get("inpTopRegionalDestination")
    );

    yuiEvent.addListener(
      yuiDom.get("inpAmenityCombo"),
      "click",
      hotelExplorer.amenity.setComboFilter
    );

    var amenityArray = hotelExplorer.amenity.getElements("amenity");
    amenityArray.forEach(function(amenityElement) {
            yuiEvent.addListener(amenityElement, "click", hotelExplorer.amenity.toggleSetFilter, amenityElement);
    });
    hotelExplorer.requestURL += "&localeCode="+hotelExplorer.localeCode;

    hotelExplorer.dateFormatString = dateFormatString;
    hotelExplorer.arrivalDate = arrivalDate;
    hotelExplorer.departureDate = departureDate;
    // preload cal images
/*
    moLeftArrow = new Image();
    moLeftArrow.src = "/preferredguest/images/icons/spg_calendar_leftarrow.gif";
    moRightArrow = new Image();
    moRightArrow.src = "/preferredguest/images/icons/spg_calendar_rightarrow.gif";
    moCloseX = new Image();
    moCloseX.src = "/preferredguest/images/icons/spg_calendar_closeX.gif";
*/

      yuiDom.get('inpArrivalDate').value = hotelExplorer.arrivalDate;
      yuiDom.get('inpDepartureDate').value = hotelExplorer.departureDate;
    hotelExplorer.availability.createCalendar();
    yuiEvent.addListener(yuiDom.get("calendarButton"),"click",hotelExplorer.availability.toggleCalendar);
    yuiEvent.addListener(yuiDom.get("datesDisplay"),'click',hotelExplorer.availability.toggleCalendar);

    hotelExplorer.availability.setArrivalFilter();
    hotelExplorer.availability.setDepartureFilter();

    yuiEvent.addListener(yuiDom.get('inpArrivalDate'),"change",hotelExplorer.availability.setFilters);
    yuiEvent.addListener(yuiDom.get('inpDepartureDate'),"change",hotelExplorer.availability.setFilters);

    yuiEvent.addListener(yuiDom.get("nameViewLink"),"click",hotelExplorer.display.select);
    yuiEvent.addListener(yuiDom.get("photoViewLink"),"click",hotelExplorer.display.select);
    yuiEvent.addListener(yuiDom.get("inpSort"),"change",hotelExplorer.sort.select);

    yuiEvent.addListener(yuiDom.get("clearLocationLink"),"click",hotelExplorer.location.reset);
    yuiEvent.addListener(yuiDom.get("clearAmenitiesLink"),"click",hotelExplorer.amenity.reset);
     // setReturnCriteria
   // yuiEvent.addListener(window,"load",hotelExplorer.setReturnCriteria);
    hotelExplorer.setReturnCriteria();
    if(!hotelExplorer.lastQueryUrl){
        s.t();   
    }

    if(hotelExplorer.setPopularDestinationFilter) {
      hotelExplorer.location.setDestinationFilter(null,yuiDom.get("inpPopularDestination"))
    }
    return true;
  },
  setState: function(params){
      if(params){
         document.location.href = "#"+params;
      }else{
         document.location.href = "#";
      }
  },
  setReturnCriteria: function(){
     var currentUrl = document.location.href;
     if(currentUrl){
        var query = currentUrl.split("#");
        if(query.length > 1){
           hotelExplorer.returnCriteria = query[1];
           hotelExplorer.lastQueryUrl = hotelExplorer.requestURL+hotelExplorer.returnCriteria;

           var ampersandPairs = hotelExplorer.returnCriteria.split("&")
           var splitPairs = [];
           for (var zI=0; zI<ampersandPairs.length; zI++) {
              splitPairs = ampersandPairs[zI].split('=');
               // check for dates and re-populate
              if (splitPairs.length == 2) {
                 if(splitPairs[0] == "arrivalDate"){
                    hotelExplorer.filterParams.arrivalDate = splitPairs[1];
                    yuiDom.get("inpArrivalDate").value = splitPairs[1];
                 }else if(splitPairs[0] == "departureDate"){
                    hotelExplorer.filterParams.departureDate = splitPairs[1];
                    yuiDom.get("inpDepartureDate").value = splitPairs[1];
                 }
              }
           }
           yuiEvent.addListener(yuiDom.get("reloadlink"),"click",hotelExplorer.showCriteriaInputs);

           hotelExplorer.hideCriteriaInputs();
           hotelExplorer.results.get();
        }
     }
      return true;
  },
  hideCriteriaInputs: function(){
     yuiDom.addClass(yuiDom.get("whatSectionOutterContainer"), "hiddenSection");
        if (yuiDom.get("andOrLabel")) {
            yuiDom.addClass(yuiDom.get("andOrLabel"), "hiddenSection");
        }
     yuiDom.addClass(yuiDom.get("whereSection"), "hideAll");
     yuiDom.addClass(yuiDom.get("whereSection"), "showIcon");
//        yuiDom.get("whereSection").style.height = '120px';
     yuiDom.get("reloadMessageDiv").style.display = "block";
   },
   showCriteriaInputs: function(){
     hotelExplorer.lastQueryUrl = "";
     hotelExplorer.location.reset(this);
     yuiDom.get("reloadMessageDiv").style.display = "none";
     yuiDom.removeClass(yuiDom.get("whereSection"), "hideAll");
     yuiDom.removeClass(yuiDom.get("whereSection"), "showIcon");
//        yuiDom.get("whereSection").style.height = '155px';
     yuiDom.removeClass(yuiDom.get("whatSectionOutterContainer"), "hiddenSection");
        if (yuiDom.get("andOrLabel")) {
            yuiDom.removeClass(yuiDom.get("andOrLabel"), "hiddenSection");
        }

   },
   setNewParams: function(url, param, val){
      var allPairs = [];
      var curPairs = url.split("&");
      if (curPairs.length > 1) {
        curPairs.forEach(function (paramPair) {
           if(paramPair){
               var paramParts = paramPair.split("=");
               if (paramParts[0] != param) {
                  allPairs.push(paramParts[0] + "=" + (typeof paramParts[1] != "undefined" ? paramParts[1] : ""));
               }
           }
        });
      }
      allPairs.push(param + "=" + val);
      return "&"+allPairs.join("&");
  },
  location: {
    setFilter: function(e,inputParams) {
      if(inputParams.input.selectedIndex>0) {
        yuiDom.get("inpPopularDestination").selectedIndex = 0;
        hotelExplorer.filterParams.DestinationCategory = "";
        hotelExplorer.filterParams[inputParams.input.config.category] = inputParams.input.value;
        hotelExplorer.location.currentSelect = inputParams.input;
        if(inputParams.reset) {
          inputParams.reset.forEach(function (resetParam) {
            hotelExplorer.location.resetSelect(resetParam.input);
            hotelExplorer.filterParams[resetParam.input.config.category] = "";
          });
        }
        hotelExplorer.results.get();
      }
    },
    setDestinationFilter: function (e,destinationSelect) {
      hotelExplorer.location.currentSelect = destinationSelect;
      var popularDestinationParse = destinationSelect.value.split(".");
      var category = "City";
      if(popularDestinationParse.length>1) {
        category = popularDestinationParse[0];
        destination = popularDestinationParse[1];
      }
      else {
        destination = popularDestinationParse[0];
      }
     var popularDestination = category+"::"+destination;
      if(destinationSelect.selectedIndex>0) {
        hotelExplorer.filterParams.WebRegion = "";
        hotelExplorer.filterParams.CountryName = "";
        hotelExplorer.filterParams.StateName = "";
        hotelExplorer.filterParams.City = "";
        hotelExplorer.filterParams[category] = destination;
        hotelExplorer.filterParams.DestinationCategory = category;
        hotelExplorer.results.get();
      }
    },
    populateSelect: function (selectBox,optionsObject,selectedValue,isSelected) {
      hotelExplorer.location.resetSelect(selectBox);
      for(var option in optionsObject) {
          if(isSelected && selectedValue == option){
              selectBox.options[selectBox.options.length] = new Option(option, option,'', isSelected);
          }else{
              selectBox.options[selectBox.options.length] = new Option(option, option);
          }
      }
      if(selectBox.options.length>1)
        selectBox.disabled = false;
    },
    populateRegionSelect: function (isSelected, selectedValue) {
      var regionSelect = yuiDom.get("inpRegion");
      hotelExplorer.location.resetSelect(regionSelect);
      hotelExplorer.regionOptions.forEach(function (regionOption) {
           if(hotelExplorer.filteredResult.availableFilters.WebRegion&&hotelExplorer.filteredResult.availableFilters.WebRegion[regionOption.value])
           if(isSelected && selectedValue == regionOption.value){
               regionSelect.options[regionSelect.options.length] = new Option(regionOption.displayName, regionOption.value,'',isSelected);
           }else{
               regionSelect.options[regionSelect.options.length] = new Option(regionOption.displayName, regionOption.value);
           }
      });

      regionSelect.disabled=false;
      if(regionSelect.options.length==2)
        regionSelect.selectedIndex = 1;
    },
    populateTopRegionalDestination: function(){
      var regionSelect = yuiDom.get("inpRegion");
      var topRegionalDestinationSelect = yuiDom.get("inpTopRegionalDestination");
      topRegionalDestinationSelect.options.length = 0;
      topRegionalDestinationSelect.options[topRegionalDestinationSelect.options.length] = new Option(hotelExplorer.text.topRegionalDest+ " " + regionSelect.options[regionSelect.selectedIndex].text);
      hotelExplorer.topRegionalDestination[regionSelect.options[regionSelect.selectedIndex].value].forEach(function(topRegionDestination) {
        topRegionalDestinationSelect.options[topRegionalDestinationSelect.options.length] = new Option(topRegionDestination.displayName,topRegionDestination.value);
      });
      topRegionalDestinationSelect.selectedIndex = 0;
    },
    resetSelect: function (selectBox) {
      selectBox.disabled = true;
      selectBox.selectedIndex = 0;
      selectBox.options[selectBox.selectedIndex].selected = true;
      selectBox.options.length = 1;
      hotelExplorer.filterParams[selectBox.config.category] = "";
    },
    resetRegionSelect: function () {
      var regionSelect = yuiDom.get("inpRegion");
      hotelExplorer.location.resetSelect(regionSelect);
      hotelExplorer.regionOptions.forEach(function (regionOption) {
        regionSelect.options[regionSelect.options.length] = new Option(regionOption.displayName, regionOption.value);
      });
      regionSelect.disabled=false;
    },
    configure: function () {
      var currentSelect = hotelExplorer.location.currentSelect;
      var regionSelect = yuiDom.get("inpRegion")
      if(currentSelect.config) {
        var selectToPopulate = null, selectToDisable = null;
        if(currentSelect.config.bottom) {
          if(currentSelect.selectedIndex>0)
            selectToPopulate = currentSelect.config.bottom;
          else
            selectToPopulate = currentSelect;
          if(selectToPopulate.config.bottom)
              selectToDisable = selectToPopulate.config.bottom;
        }

        if(selectToPopulate) {
          if(selectToPopulate != regionSelect)
            hotelExplorer.location.populateSelect(selectToPopulate,hotelExplorer.filteredResult.availableFilters[selectToPopulate.config.category]);
          else
            hotelExplorer.location.populateRegionSelect();
          if(selectToPopulate.disabled&&selectToPopulate.config.skip) {
            selectToPopulate = selectToPopulate.config.bottom;
            hotelExplorer.location.populateSelect(selectToPopulate, hotelExplorer.filteredResult.availableFilters[selectToPopulate.config.category]);
            selectToDisable = null;
          }
          if(selectToPopulate.config.top)
            hotelExplorer.location.enableTopSelects(selectToPopulate.config.top)
        }
        else {
          hotelExplorer.location.enableTopSelects(currentSelect)
        }
        if(selectToDisable)
          hotelExplorer.location.disableBottomSelects(selectToDisable);
      }
      if(currentSelect == yuiDom.get("inpTopRegionalDestination") || currentSelect == yuiDom.get("inpPopularDestination"))
        regionSelect.disabled = false;
      if(currentSelect == yuiDom.get("inpPopularDestination"))
        regionSelect.selectedIndex = 0;
      if(currentSelect == regionSelect&&currentSelect.selectedIndex) {
        yuiDom.removeClass(yuiDom.get("topRegionalDestinationSelect"),"hiddenSection");
        hotelExplorer.location.populateTopRegionalDestination();
      }
      else {
        if(currentSelect == yuiDom.get("inpPopularDestination")&&!yuiDom.hasClass(yuiDom.get("topRegionalDestinationSelect"),"hiddenSection")) {
          yuiDom.addClass(yuiDom.get("topRegionalDestinationSelect"),"hiddenSection");
        }
      }
      yuiDom.get("inpPopularDestination").disabled = false;
      yuiDom.get("inpTopRegionalDestination").disabled = false;
    },
    enable: function(selectBox) {
      selectBox.disabled = false;
    },
    enableTopSelects: function(topSelect) {
      if(topSelect.options.length>1)
        hotelExplorer.location.enable(topSelect);
      if(topSelect.config.top)
        hotelExplorer.location.enableTopSelects(topSelect.config.top);
      return;
    },
    disable: function(selectBox) {
      selectBox.disabled = true;
      selectBox.selectedIndex = 0;
      hotelExplorer.filterParams[selectBox.config.category] = "";
    },
    disableBottomSelects: function(bottomSelect) {
      hotelExplorer.location.disable(bottomSelect);
      if(bottomSelect.config.bottom!=null)
        hotelExplorer.location.disableBottomSelects(bottomSelect.config.bottom);
      return;
    },
    disableAll: function () {
      yuiDom.get("inpRegion").disabled = true;
      yuiDom.get("inpCountry").disabled = true;
      yuiDom.get("inpState").disabled = true;
      yuiDom.get("inpCity").disabled = true;
      yuiDom.get("inpPopularDestination").disabled = true;
      yuiDom.get("inpTopRegionalDestination").disabled = true;
    },
    reset: function() {
      hotelExplorer.location.resetRegionSelect();
      hotelExplorer.location.currentSelect = yuiDom.get("inpRegion");
      hotelExplorer.location.resetSelect(yuiDom.get("inpCountry"));
      hotelExplorer.location.resetSelect(yuiDom.get("inpState"));
      hotelExplorer.location.resetSelect(yuiDom.get("inpCity"));
      yuiDom.addClass(yuiDom.get("topRegionalDestinationSelect"),"hiddenSection");
      yuiDom.get("inpPopularDestination").selectedIndex = 0;
      hotelExplorer.filterParams.DestinationCategory = "";
      hotelExplorer.reset = true;
      if(arguments.length != 1){
          hotelExplorer.results.get();
      }else{
          yuiDom.addClass(yuiDom.get("displaySectionOutterContainer"), "hiddenSection");
          hotelExplorer.setState();
          hotelExplorer.amenity.enableAll(false);
          yuiDom.get("inpArrivalDate").value = hotelExplorer.dateFormatString;
          hotelExplorer.filterParams.arrivalDate = "";
          yuiDom.get("inpDepartureDate").value = hotelExplorer.dateFormatString;
          hotelExplorer.filterParams.departureDate = "";
      }
    }
  },
  amenity: {
    enable: function(amenityElement, addToFilter) {
      var amenityLink = yuiDom.get(amenityElement.id+"Link");
      amenityElement.setAttribute("selectable","Y");
      yuiDom.removeClass(amenityLink,"disabled");
      yuiEvent.addListener(amenityElement,"click",hotelExplorer.amenity.toggleSetFilter,amenityElement);
      if(addToFilter) {
        if(!hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")])
          hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")] = true;
      }
    },
    enableAll: function(addToFilter) {
      var amenities = hotelExplorer.amenity.getElements("amenity");
      amenities.forEach(function(amenityElement) {
        hotelExplorer.amenity.enable(amenityElement,addToFilter);
      });
    },
    disable: function(amenityElement,removeFromFilter) {
      var amenityLink = yuiDom.get(amenityElement.id+"Link");
      yuiDom.addClass(amenityLink,"disabled");
      yuiDom.removeClass(amenityLink,"selected");
      amenityElement.setAttribute("selectable","N");
      amenityElement.setAttribute("selected","N");
      yuiEvent.removeListener(amenityElement,"click",hotelExplorer.amenity.toggleSetFilter);
      if(removeFromFilter) {
        if(hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")])
          hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")] = false;
      }
    },
    disableAll: function (removeFromFilter) {
      var amenities = hotelExplorer.amenity.getElements("amenity");
      amenities.forEach(function(amenityElement) {
        hotelExplorer.amenity.disable(amenityElement, removeFromFilter);
      });
      yuiDom.addClass(yuiDom.get("comboTrigger"),"disabled");
    },
    select: function(amenityElement) {
      var amenityLink = yuiDom.get(amenityElement.id+"Link");
      yuiDom.addClass(amenityLink,"selected");
      amenityElement.setAttribute("selected","Y");
      if(!hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")])
        hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")] = true;
    },
    deselect: function(amenityElement) {
      var amenityLink = yuiDom.get(amenityElement.id+"Link");
      amenityElement.setAttribute("selected","N");
      if(yuiDom.hasClass(amenityLink,"selected"))
        yuiDom.removeClass(amenityLink,"selected");
      if(hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")])
        hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")] = false;
    },
    toggleSetFilter: function (e, amenityElement) {
      var amenityLink = yuiDom.get(amenityElement.id+"Link");
      if(amenityElement.getAttribute("selectable") == "Y") {
        if(amenityElement.getAttribute("selected") != "Y") {
          hotelExplorer.amenity.select(amenityElement);
        }
        else {
          hotelExplorer.amenity.deselect(amenityElement);
        }
      }
      yuiDom.get("comboTrigger").innerHTML = hotelExplorer.text.triggerText;
      hotelExplorer.results.get();
    },
    setComboFilter: function(e) {

      var amenityComboSelect = yuiEvent.getTarget(e);
//      var amenityComboSelect = yuiDom.get("inpAmenityCombo");
      var combo = amenityComboSelect.getAttribute("combo").split("+");

      if(combo.length>1) {
        hotelExplorer.amenity.disableAll(true);
        hotelExplorer.amenity.enableAll(false);
        hotelExplorer.amenity.select(yuiDom.get(combo[0]));
        hotelExplorer.amenity.select(yuiDom.get(combo[1]));
        yuiDom.get("comboTrigger").innerHTML = amenityComboSelect.innerHTML;
        hotelExplorer.results.get();
      }
    },
    configure: function () {
      var amenities = hotelExplorer.amenity.getElements("amenity");
      amenities.forEach(function(amenityElement){
        yuiEvent.removeListener(amenityElement,"click",hotelExplorer.amenity.toggleSetFilter);  // remove all listeners that calls toggleSetFilter incase it starts stacking
        if(hotelExplorer.filteredResult.availableFilters.Amenity[amenityElement.getAttribute("amenity")]&&hotelExplorer.filteredResult.availableFilters.Amenity[amenityElement.getAttribute("amenity")]>0) {
          hotelExplorer.amenity.enable(amenityElement);
        }
        else if (hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")]) {  // previously selected amenity
          hotelExplorer.amenity.enable(amenityElement);
          hotelExplorer.amenity.select(amenityElement);
        }
        else {
          hotelExplorer.amenity.disable(amenityElement);
          hotelExplorer.filterParams.Amenities[amenityElement.getAttribute("amenity")] = false;
        }
      });
    },
    reset: function () {
      hotelExplorer.amenity.disableAll(true); // clear classes and filter params
      hotelExplorer.amenity.enableAll(false); // re-enable all amenities
      hotelExplorer.reset = true;
      hotelExplorer.results.get(); // get new results based on any existing filters
      yuiDom.get("comboTrigger").innerHTML = hotelExplorer.text.triggerText;
//      hotelExplorer.location.reset();
    },
    getElements: function(attr) {
      return yuiDom.getElementsBy(function(element) {
        if(element.getAttribute(attr) != null)
          return true;
        return false;
      },"li",yuiDom.get("hotelAmenities"));
    }
  },
  availability: {
    createCalendar: function() {
      hotelExplorer.calendar = new multiDisplayCalendar("hotelExplorerCalendar", hotelExplorer.availability.getArrivalDate, hotelExplorer.availability.getDepartureDate, hotelExplorer.availability.setDates);
    },
    getArrivalDate: function() {
      return setDateFromString(hotelExplorer.localeCode.split("_")[0],yuiDom.get("inpArrivalDate").value);
    },
    getDepartureDate: function() {
      return setDateFromString(hotelExplorer.localeCode.split("_")[0],yuiDom.get("inpDepartureDate").value);
    },
    setDates: function(arrivalDate, departureDate) {
      yuiDom.get("inpArrivalDate").value = getFormatedDate(hotelExplorer.localeCode.split("_")[0], arrivalDate);
      yuiDom.get("inpDepartureDate").value = getFormatedDate(hotelExplorer.localeCode.split("_")[0], departureDate);
//      hotelExplorer.sort[yuiDom.get("inpSort").value]();
      hotelExplorer.availability.setFilters();
    },
    toggleCalendar: function(e) {
      hotelExplorer.calendar.show(yuiDom.get("calendarButton"),"bottomLeft");
    },
    setFilters: function () {
        var errorMessages = new Array();
        var checkIn = new validDate(yuiDom.get("inpArrivalDate"));
        var checkOut = new validDate(yuiDom.get("inpDepartureDate"));
        /* ERROR CHECKING */
        if (checkIn.valid ) {
            checkIn.setField();
            if (checkOut.valid) {
                before = (checkIn.diffDate(checkOut.d) <= 0);
            }
            if ((!(checkOut.valid)) || before) {
                checkOut.setD(checkIn.d);
                checkOut.nextDay();
                checkOut.setField();
            }
        }
         else {
          yuiDom.get("inpArrivalDate").value = hotelExplorer.dateFormatString;
        }

        if (checkOut.valid) {
             checkOut.setField();
        } else {
             yuiDom.get("inpDepartureDate").value = hotelExplorer.dateFormatString;
        }

        if (!checkIn.valid && !checkOut.valid) {
           errorMessages.push(moLanguageObjCiCo.errorArray[5]);
        } else if (!checkIn.valid) {
          // errorMessages.push("Check in date is invalid");
            return;
        } else if (!checkOut.valid) {
           errorMessages.push(moLanguageObjCiCo.errorArray[6]);
        } else if (checkIn.valid & checkOut.valid) {
            var datesDelta = checkIn.diffDate(checkOut.d);
            var nowDelta = checkIn.diffDate(new Date);
            if (nowDelta > 0) {
                errorMessages.push(moLanguageObjCiCo.errorArray[6]);
            } else if (nowDelta < -561) {
               errorMessages.push(moLanguageObjCiCo.errorArray[1]);
            } else if (datesDelta > 31) {
                errorMessages.push(moLanguageObjCiCo.errorArray[0]);
            }
        }

        yuiDom.get("errorMessageContainer").innerHTML = "";

        if(errorMessages.length > 0) {
           yuiDom.get("errorMessageContainer").innerHTML = errorMessages.join('/n');
           yuiDom.addClass(yuiDom.get("errorMessageContainer"),"display");
           return false;
        }else{
           // execute
           if(hotelExplorer.availability.setArrivalFilter() && hotelExplorer.availability.setDepartureFilter()) {
              hotelExplorer.results.get();
           }
        }
    },
    setArrivalFilter: function () {
      if(yuiDom.get("inpArrivalDate").value != hotelExplorer.dateFormatString) {
        hotelExplorer.filterParams.arrivalDate = yuiDom.get("inpArrivalDate").value;
        return formatDates(yuiDom.get("inpArrivalDate").value,hotelExplorer.dateFormatString);
        //return true;
      }
      return false
    },
    setDepartureFilter: function () {
      if(yuiDom.get("inpDepartureDate").value != hotelExplorer.dateFormatString) {
        hotelExplorer.filterParams.departureDate = yuiDom.get("inpDepartureDate").value;
        return formatDates(yuiDom.get("inpDepartureDate").value,hotelExplorer.dateFormatString);
        //return true;
      }
      return false;
    }
  },
  results: {
    get: function () {
      yuiDom.removeClass(yuiDom.get("loadingMessageContainer"), "hiddenSection");
      yuiDom.addClass(yuiDom.get("displaySectionOutterContainer"), "hiddenSection");
            yuiDom.addClass(yuiDom.get("frmHotelExplorer"), "loading");
      yuiDom.get("resultsMessage").innerHTML = "";
      yuiDom.get("displayInstructions").innerHTML = "";
      yuiDom.get("resultsSection").innerHTML = "";
      if(!yuiDom.hasClass(yuiDom.get("viewSortSelect"),"hiddenSection"))yuiDom.addClass(yuiDom.get("viewSortSelect"),"hiddenSection");
      if(!yuiDom.hasClass(yuiDom.get("availabilitySelection"),"hiddenSection"))yuiDom.addClass(yuiDom.get("availabilitySelection"),"hiddenSection");

      hotelExplorer.hotels = [];

      if(!hotelExplorer.lastQueryUrl){
          // ajax call here
          var filters = "";
          var webRegionFilter = ""
          var countryNameFilter = "";
          var stateNameFilter = "";
          var cityNameFilter = "";
          var amenityFilter = "";
          var arrivalDate = "";
          var departureDate = "";
          if(hotelExplorer.filterParams.DestinationCategory != "") {
            cityNameFilter = hotelExplorer.filterParams.DestinationCategory+"::"+hotelExplorer.filterParams[hotelExplorer.filterParams.DestinationCategory];
          }
          else {
            if(hotelExplorer.filterParams.WebRegion != "") {
              webRegionFilter = "WebRegion::"+hotelExplorer.filterParams.WebRegion;
            }
            if(hotelExplorer.filterParams.CountryName != "") {
              countryNameFilter = "CountryName::"+hotelExplorer.filterParams.CountryName;
            }
            if(hotelExplorer.filterParams.StateName != "") {
              stateNameFilter = "StateName::"+hotelExplorer.filterParams.StateName;
            }
            if(hotelExplorer.filterParams.City != "") {
              cityNameFilter = "City::"+hotelExplorer.filterParams.City;
            }
          }
          for(var amenity in hotelExplorer.filterParams.Amenities) {
            if(hotelExplorer.filterParams.Amenities[amenity]) {
              amenityFilter+=amenity+","
            }
          }
          if(amenityFilter!="") {
            amenityFilter = "Amenity::"+amenityFilter;
          }
          filters = "&set="
                    + (webRegionFilter != "" ? webRegionFilter+"|" : "")
                    + (countryNameFilter != "" ? countryNameFilter+"|" : "")
                    + (stateNameFilter != "" ? stateNameFilter+"|" : "")
                    + (cityNameFilter != "" ? cityNameFilter+"|" : "")
                    + (amenityFilter != "" ? amenityFilter : "");
          if(hotelExplorer.filterParams.arrivalDate != "" && hotelExplorer.filterParams.departureDate != "") {
            arrivalDate = "arrivalDate="+hotelExplorer.filterParams.arrivalDate;
            departureDate = "departureDate="+hotelExplorer.filterParams.departureDate;
            filters += "&"+arrivalDate+"&"+departureDate;
          }
      }
      else{
        if(hotelExplorer.filterParams.arrivalDate != "" && hotelExplorer.filterParams.departureDate != "") {
            arrivalDate =  hotelExplorer.filterParams.arrivalDate;
            departureDate = hotelExplorer.filterParams.departureDate;
        }
        filters = hotelExplorer.returnCriteria;
      }

      hotelExplorer.location.disableAll();
      hotelExplorer.amenity.disableAll();
      yuiEvent.removeListener(yuiDom.get("clearLocationLink"),"click",hotelExplorer.location.reset);
      yuiEvent.removeListener(yuiDom.get("clearAmenitiesLink"),"click",hotelExplorer.amenity.reset);

      if(yuiDom.hasClass(yuiDom.get("errorMessageContainer"),"display")){
        yuiDom.removeClass(yuiDom.get("errorMessageContainer"),"display");
        // Clean up error messages
        yuiDom.get("errorMessageContainer").innerHTML = "";
      }

      if(!yuiDom.hasClass(yuiDom.get("compareLinkContainer"),"hiddenSection"))
        yuiDom.addClass(yuiDom.get("compareLinkContainer"),"hiddenSection");
        if(!hotelExplorer.lastQueryUrl){
            hotelExplorer.setState(filters);
        }
        var startTime = new Date();
        var ajaxUrl = hotelExplorer.requestURL+filters;

        if(hotelExplorer.lastQueryUrl){
            var updateParams = filters;
            ajaxUrl = hotelExplorer.lastQueryUrl;  
            if(arrivalDate){
                    ajaxUrl = SW.tools.setUrlParameter(ajaxUrl, "arrivalDate", hotelExplorer.filterParams.arrivalDate);
                updateParams = hotelExplorer.setNewParams(updateParams, "arrivalDate", hotelExplorer.filterParams.arrivalDate);
            }
            if(departureDate){
                    ajaxUrl = SW.tools.setUrlParameter(ajaxUrl, "departureDate", hotelExplorer.filterParams.departureDate);
                updateParams = hotelExplorer.setNewParams(updateParams, "departureDate", hotelExplorer.filterParams.departureDate);
            }
            if(arrivalDate && departureDate){
                hotelExplorer.setState(updateParams);
            }
        }

      // encodeURI is needed to avoid errors in IE - no real explaination why this works
        ajaxUrl = encodeURI(ajaxUrl);
  
        hotelExplorer.request = yuiConnect.asyncRequest("GET",ajaxUrl,{success: hotelExplorer.results.set, argument: {startTime:startTime}})
    },
    set: function(xhr) {
      var delay = new Date() - xhr.argument.startTime;
      function setDelay(){
          hotelExplorer.filteredResult = eval("("+xhr.responseText+")");
          yuiDom.addClass(yuiDom.get("loadingMessageContainer"), "hiddenSection");
                yuiDom.removeClass(yuiDom.get("frmHotelExplorer"), "loading");
          yuiDom.removeClass(yuiDom.get("displaySectionOutterContainer"), "hiddenSection");

          if(hotelExplorer.filteredResult.properties.length>0) {
            hotelExplorer.hotels = hotelExplorer.filteredResult.properties;
            hotelExplorer.thumbsArray = [];
            hotelExplorer.hotels.forEach(function(hotel, index){
    //          YAHOO.log(index)
              var thumb = new Image(85,57);
              thumb.src = hotel.thumbnailURL;
              hotelExplorer.thumbsArray[index]=thumb;
            });
          }
          hotelExplorer.location.configure();
          yuiDom.removeClass(yuiDom.get("comboTrigger"),"disabled");
          if(hotelExplorer.filteredResult.availableFilters.Amenity) {
            hotelExplorer.amenity.configure();
          }
          hotelExplorer.sort.select();

          yuiEvent.addListener(yuiDom.get("clearLocationLink"),"click",hotelExplorer.location.reset);
          yuiEvent.addListener(yuiDom.get("clearAmenitiesLink"),"click",hotelExplorer.amenity.reset);
      }
      if(delay >= (hotelExplorer.settings.minLoadTime * 1000)){
        setDelay();
      }else{
        setTimeout(setDelay,(hotelExplorer.settings.minLoadTime * 1000)-delay);
      }
    }

  },
  display: {
    select: function() {
      if(hotelExplorer.displayMethod!=this.getAttribute("view")) {
                yuiDom.removeClass(yuiDom.get(hotelExplorer.displayMethod + "ViewLinkContainer"), "selected");
        hotelExplorer.displayMethod = this.getAttribute("view");
                yuiDom.addClass(this.id+"Container", "selected");
        hotelExplorer.display[hotelExplorer.displayMethod]();
      }
    },
    name: function () {
      var resultsContainer = yuiDom.get("resultsSection");
      yuiDom.get("resultsMessage").innerHTML = "> " + hotelExplorer.hotels.length + " " + hotelExplorer.text.matchingHotels;
      resultsContainer.innerHTML = "";

      if(hotelExplorer.hotels.length>0 && hotelExplorer.hotels.length <= 60) {
        yuiDom.get("displayInstructions").innerHTML = hotelExplorer.text.nameViewInstr;
        yuiDom.removeClass(yuiDom.get("viewSortSelect"),"hiddenSection");
        if(hotelExplorer.filteredResult.rateSearch) {
          yuiDom.removeClass(yuiDom.get("sortSelectContainer"),"hiddenSection");
        }
        yuiDom.removeClass(yuiDom.get("availabilitySelection"),"hiddenSection");
        var output = [];
        var number = 0;

        hotelExplorer.hotels.forEach(function(hotel){
          number++;
          output.push('<div class="hotel"><div class="number">'+number+'.</div>'+hotelExplorer.display.getHotelHTML(hotel)+'</div>');
        });
        resultsContainer.innerHTML = output.join("\n");
//        var t1 = new Date();
        SW.domWidget.update(resultsContainer);
//        alert((new Date() - t1));
        yuiDom.removeClass(resultsContainer,"hiddenSection");
      }
      else {
        if(!yuiDom.hasClass(yuiDom.get("resultsSection"),"hiddenSection")) yuiDom.addClass(yuiDom.get("resultsSection"),"hiddenSection");
        if(!yuiDom.hasClass(yuiDom.get("viewSortSelect"),"hiddenSection")) yuiDom.addClass(yuiDom.get("viewSortSelect"),"hiddenSection");
        if(!yuiDom.hasClass(yuiDom.get("sortSelectContainer"),"hiddenSection")) yuiDom.addClass(yuiDom.get("sortSelectContainer"),"hiddenSection");
        if(!yuiDom.hasClass(yuiDom.get("availabilitySelection"),"hiddenSection")) yuiDom.addClass(yuiDom.get("availabilitySelection"),"hiddenSection");
        yuiDom.get("displayInstructions").innerHTML = hotelExplorer.text.refineSearch;
      }
      yuiDom.removeClass(yuiDom.get("displayInstructions"),"hiddenSection");
    },
    getHotelHTML: function(hotel) {
      return '<div class="hotelNameDisplay">'
            + '<div class="hotelInformation">'
                + ' <div class="hotelName"><a href="/'+SW.tools.getSkinName()+'/property/overview/index.html?propertyID=' + hotel.propertyId + '">' + hotel.name + '</a></div>'
            + ' <div class="hotelLocation">'+hotel.city.name+', '+hotel.country.name+'</div>'
            + (!hotel.inFavorites && hotelExplorer.filteredResult.loggedIn ? '<a href="/manageFavorite.qq?propertyID='+hotel.propertyId+'" class="favoriteLink addFavorite">'+hotelExplorer.text.addToFavorites+'</a>' : '')
            + '</div>'
            + ' <div class="hotelAvailability">'
                + ((hotelExplorer.filteredResult.rateSearch) ? ((hotel.available) ? '<span class="hotelRates"> ' + hotelExplorer.text.from + ' ' + hotel.currency + parseInt(hotel.rate).toFixed(2) + hotelExplorer.text.perNight + '</span> <div class="buttonLink"><a href="/'+SW.tools.getSkinName()+'/search' + hotel.bookingURL + '">' + hotelExplorer.text.book + '</a></div>' : '(' + hotelExplorer.text.unavailable + ')') : '<a href="javascript:void(0);" onclick="hotelExplorer.availability.toggleCalendar();">' + hotelExplorer.text.checkAvailability + '</a>')
            + ' </div>'
            + '</div>';
    },
    photo: function () {
      var resultsContainer = yuiDom.get("resultsSection");
      yuiDom.get("resultsMessage").innerHTML = "> " + hotelExplorer.hotels.length + " " + hotelExplorer.text.matchingHotels;
      resultsContainer.innerHTML = "";
      if(hotelExplorer.hotels.length>0 && hotelExplorer.hotels.length <= 60) {
        yuiDom.get("displayInstructions").innerHTML = hotelExplorer.text.photoViewInstr;
        yuiDom.removeClass(yuiDom.get("viewSortSelect"),"hiddenSection");
        yuiDom.removeClass(yuiDom.get("availabilitySelection"),"hiddenSection");


//        setTimeout(function () {
        hotelExplorer.hotels.forEach(function(hotel,index){
          var container = document.createElement("div");
          resultsContainer.appendChild(container);
          yuiDom.addClass(container,"hotelPhotoDisplay");
          var hotelImage = document.createElement("img");
//          hotelImage.setAttribute("src",thumb.src);
          hotelImage.src = hotel.thumbnailURL;
          hotelImage.setAttribute("zoomsrc",hotel.imageURL);
          hotelImage.setAttribute("hotel","hotelExplorer.hotels["+index+"]");
          hotelImage.setAttribute("alt",hotel.name);
                    var hotelLocation = document.createElement("span");
                    hotelLocation.innerHTML = hotel.city.name;
          container.appendChild(hotelImage);
                    container.appendChild(hotelLocation);
        });
//      },0);
/*
        hotelExplorer.hotels.forEach(function(hotel,index){
          var container = document.createElement("div");
          resultsContainer.appendChild(container);
          yuiDom.addClass(container,"hotelPhotoDisplay");
          var hotelImage = document.createElement("img");
          hotelImage.src = hotel.thumbnailURL;
          hotelImage.setAttribute("zoomsrc",hotelExplorer.hotels[index].imageURL);
          hotelImage.setAttribute("hotel","hotelExplorer.hotels["+index+"]");
          hotelImage.setAttribute("alt",hotelExplorer.hotels[index].name);
          container.appendChild(hotelImage);
        });
*/

        yuiDom.removeClass(yuiDom.get("resultsSection"),"hiddenSection");
        function zoomInit () {
          hotelExplorer.display.zoom.init(resultsContainer);
        }
        setTimeout(zoomInit,0);
      }
      else {
        if(!yuiDom.hasClass(yuiDom.get("resultsSection"),"hiddenSection")) yuiDom.addClass(yuiDom.get("resultsSection"),"hiddenSection");
        if(!yuiDom.hasClass(yuiDom.get("viewSortSelect"),"hiddenSection")) yuiDom.addClass(yuiDom.get("viewSortSelect"),"hiddenSection");
        if(!yuiDom.hasClass(yuiDom.get("availabilitySelection"),"hiddenSection")) yuiDom.addClass(yuiDom.get("availabilitySelection"),"hiddenSection");
        yuiDom.get("displayInstructions").innerHTML = hotelExplorer.text.refineSearch;
      }
      yuiDom.removeClass(yuiDom.get("displayInstructions"),"hiddenSection");

    },
    showCompareLink: function (){
      yuiDom.removeClass(yuiDom.get("compareLinkContainer"),"hiddenSection");
      var webRegionFilter = ""
      var countryNameFilter = "";
      var stateNameFilter = "";
      var cityNameFilter = "";
      var amenityFilter = "";
      var arrivalDate = "";
      var departureDate = "";
      if(hotelExplorer.filterParams.DestinationCategory != "") {
        var destinationCategory;
        switch(hotelExplorer.filterParams.DestinationCategory) {
          case "CountryName":
            cityNameFilter = "countryCode="+hotelExplorer.hotels[0].country.code;
            break;
          case "StateName":
            cityNameFilter = "countryCode="+hotelExplorer.hotels[0].country.code+"&stateCode="+hotelExplorer.hotels[0].state.code;
            break;
          default:
            cityNameFilter = "countryCode="+hotelExplorer.hotels[0].country.code
                +(hotelExplorer.hotels[0].state ? "&stateCode="+hotelExplorer.hotels[0].state.code : "")
                +"&city="+hotelExplorer.hotels[0].city.name;
        }
      }
      else {
        if(hotelExplorer.filterParams.CountryName != "" && hotelExplorer.hotels[0].country) {
          countryNameFilter = "countryCode="+hotelExplorer.hotels[0].country.code;
        }
        if(hotelExplorer.filterParams.StateName != "" && hotelExplorer.hotels[0].state) {
          stateNameFilter = "stateCode="+hotelExplorer.hotels[0].state.code;
        }
        if(hotelExplorer.filterParams.City != "" && hotelExplorer.hotels[0].city) {
          cityNameFilter = "city="+hotelExplorer.hotels[0].city.name;
        }
      }
      for(var amenity in hotelExplorer.filterParams.Amenities) {
        if(hotelExplorer.filterParams.Amenities[amenity] && yuiDom.get(amenity).getAttribute("compareValue")!=null) {
          amenityFilter += yuiDom.get(amenity).getAttribute("compareValue")+"|";
        }
        else if(hotelExplorer.filterParams.Amenities[amenity]) {
          amenityFilter+=amenity+"|"
        }
      }
      if(amenityFilter!="") {
        amenityFilter = "selectedAmenities="+amenityFilter;
      }
            yuiDom.get("compareLink").href = "/"+SW.tools.getSkinName()+"/search/results/standard.html?localeCode=" + hotelExplorer.localeCode + "&"
          + (countryNameFilter != "" ? countryNameFilter+"&" : "")
          + (stateNameFilter != "" ? stateNameFilter+"&" : "")
          + (cityNameFilter != "" ? cityNameFilter+"&" : "")
          + (amenityFilter != "" ? amenityFilter : "");
      if(hotelExplorer.filterParams.arrivalDate != "" && hotelExplorer.filterParams.departureDate != "") {
        arrivalDate = "arrivalDate="+hotelExplorer.filterParams.arrivalDate;
        departureDate = "departureDate="+hotelExplorer.filterParams.departureDate;
        yuiDom.get("compareLink").href += "&"+arrivalDate+"&"+departureDate;
      }
    }
  },
  sort: {
    select: function() {
      if(hotelExplorer.hotels.length>0 && hotelExplorer.hotels.length<=60) {
        hotelExplorer.trackResults();
        if(hotelExplorer.filteredResult.rateSearch) {
          hotelExplorer.sort.nameOnly();
          hotelExplorer.sort[yuiDom.get("inpSort").value]();
//          hotelExplorer.sort.nameOnly();
        }
        else {
          hotelExplorer.sort.nameOnly();
        }
      }
      hotelExplorer.display[hotelExplorer.displayMethod]();
    },
    priceLowHigh: function () {
      hotelExplorer.hotels.sort(function(a,b) {
//        if(!a.available){ return 1; }
//        if(!b.available){ return 0; }
        if(a.available&&b.available)
          return (parseInt(a.rate) > parseInt(b.rate))-(parseInt(b.rate) > parseInt(a.rate));
        return (a.available<b.available)-(b.available<a.available);
      });
    },
    priceHighLow: function() {
      hotelExplorer.hotels.sort(function(a,b) {
//        if(!a.available){ return 1; }
//        if(!b.available){ return 0; }
        if(a.available&&b.available)
          return (parseInt(a.rate) < parseInt(b.rate))-(parseInt(b.rate) < parseInt(a.rate));
        return (a.available<b.available)-(b.available<a.available);
      });
    },
    nameOnly: function () {
      hotelExplorer.hotels.sort(function(a,b) {
        return ((a.name>b.name) - (b.name>a.name));
      });
    }
  },
  trackResults:function(){
      if(hotelExplorer.trackedFirstResults){ return; }
      hotelExplorer.trackedFirstResults = true;
      
      s.events = "event9";
      setOmnitureSearchParams(hotelExplorer.hotels);
      s.prop29 = "Successful Hotel List Search - Hotel Explorer";
      s.prop30 = s.eVar21 = delimit(createParams(hotelExplorer.filterParams.WebRegion,hotelExplorer.filterParams.CountryName,hotelExplorer.filterParams.StateName,hotelExplorer.filterParams.City));
      setOmniVars(s.charSet, s.server, s.channel, s.prop2, s.prop3, s.prop1, "", s.prop9, "Results", "Explorer");
      s.t();
  }
};

hotelExplorer.display.zoom = {
  containter:null,
  showDelay:0.01,
  hideDelay:0.1,
  showDuration:0.3,
  hideDuration:0.2,
  showCount: 0,
  showTransition:YAHOO.util.Easing.easeIn,
  hideTransition:YAHOO.util.Easing.easeIn,
  showAttributes:{
    opacity:{to:1}
  },
  hideAttributes:{
    opacity:{to:0}
  },
  init:function(startNode){
    hotelExplorer.display.zoom.container = document.getElementsByTagName("body")[0];
    var imageZooms = yuiDom.getElementsBy(function(image){
      var zoomSrc = image.getAttribute("zoomsrc");
      return (zoomSrc!=null && zoomSrc!="");
    },"img",startNode);
    imageZooms.forEach(function(thumb){
      if(!thumb.zoomConfig){
        hotelExplorer.display.zoom.initThumb(thumb);
      }
    });
  },
  initThumb:function(thumb){
    var img,animIn,animOut,propertyId;
    propertyId = thumb.getAttribute("propertyid");
    var zoomContent = document.createElement("div");
    img = document.createElement("img");
    zoomContent.appendChild(img);
    var hotel = eval(thumb.getAttribute("hotel"));
    if(hotel) {
      var hotelInfoContainer = document.createElement("div");
      hotelInfoContainer.innerHTML = hotelExplorer.display.getHotelHTML(hotel);
      zoomContent.appendChild(hotelInfoContainer);
      SW.domWidget.update(zoomContent);
    }
//    yuiDom.addClass(img,"zoomImage");
    yuiDom.addClass(zoomContent,"zoomImage");
    yuiDom.addClass(thumb,"zoomThumb");
//    animIn = new yuiAnim(img,hotelExplorer.display.zoom.showAttributes,hotelExplorer.display.zoom.showDuration,hotelExplorer.display.zoom.showTransition);
    animIn = new yuiAnim(zoomContent,hotelExplorer.display.zoom.showAttributes,hotelExplorer.display.zoom.showDuration,hotelExplorer.display.zoom.showTransition);
    animIn.onStart.subscribe(function(){
/*
      yuiDom.setStyle(img,"opacity",0);
      yuiDom.addClass(img,"zoomImageShowing");
*/
      yuiDom.setStyle(zoomContent,"opacity",0);
      yuiDom.addClass(zoomContent,"zoomImageShowing");
    });
//    animOut = new yuiAnim(img,hotelExplorer.display.zoom.hideAttributes,hotelExplorer.display.zoom.hideDuration,hotelExplorer.display.zoom.hideTransition);
    animOut = new yuiAnim(zoomContent,hotelExplorer.display.zoom.hideAttributes,hotelExplorer.display.zoom.hideDuration,hotelExplorer.display.zoom.hideTransition);
    animOut.onComplete.subscribe(function(){
//      yuiDom.removeClass(img,"zoomImageShowing");
      yuiDom.removeClass(zoomContent,"zoomImageShowing");
    });
//    hotelExplorer.display.zoom.container.appendChild(img);
    hotelExplorer.display.zoom.container.appendChild(zoomContent);
    yuiEvent.addListener(zoomContent,"mouseover",hotelExplorer.display.zoom.setShow);
    yuiEvent.addListener(zoomContent,"mouseout",hotelExplorer.display.zoom.setHide);
    yuiEvent.addListener(thumb,"mouseover",hotelExplorer.display.zoom.setShow);
    yuiEvent.addListener(thumb,"mouseout",hotelExplorer.display.zoom.setHide);
/*
    yuiEvent.addListener(img,"mouseover",hotelExplorer.display.zoom.clearHide);
    yuiEvent.addListener(img,"mouseout",hotelExplorer.display.zoom.setHide);
*/
    yuiEvent.addListener(img,"click",hotelExplorer.display.zoom.openHighightAndHide);
    yuiEvent.addListener(img,"mouseover",hotelExplorer.display.zoom.clearHide);
//    yuiEvent.addListener(img,"mouseout",hotelExplorer.display.zoom.setHide);
    yuiEvent.addListener(hotelInfoContainer,"mouseover",hotelExplorer.display.zoom.clearHide);
//    yuiEvent.addListener(hotelInfoContainer,"mouseout",hotelExplorer.display.zoom.setHide);
//    yuiEvent.addListener(zoomContent,"click",hotelExplorer.display.zoom.openHighightAndHide);
    var zoomConfig = {
      src:thumb.getAttribute("zoomsrc"),
      thumb:thumb,
      contentContainer: zoomContent,
      image:img,
      propertyId:propertyId,
      highlight:yuiDom.get("highlight_"+propertyId),
      isShowing:false,
      isOver:false,
      animIn:animIn,
      animOut:animOut,
      showTimeout:null,
      hideTimeout:null,
      x:0,
      y:0
    };
    zoomContent.zoomConfig = zoomConfig;
    thumb.zoomConfig = zoomConfig;
    img.zoomConfig = zoomConfig;
    hotelInfoContainer.zoomConfig = zoomConfig;
  },
  show:function(){
    hotelExplorer.display.zoom.showCount++;
    if(this.zoomConfig.highlight && yuiDom.hasClass(this.zoomConfig.highlight,"detailsHighlightOpen")){
      return;
    }
    if(this.zoomConfig.isOver && !this.zoomConfig.isShowing){
      this.zoomConfig.isShowing = true;
      yuiDom.setStyle(this.zoomConfig.contentContainer,"top",this.zoomConfig.y +"px");
      yuiDom.setStyle(this.zoomConfig.contentContainer,"left",this.zoomConfig.x +"px");

      this.zoomConfig.animIn.animate();
    }
  },
  hide:function(){
    hotelExplorer.display.zoom.showCount--;
    if(navigator.platform.indexOf("Mac") > -1 && navigator.userAgent.indexOf("Firefox") >-1 && hotelExplorer.display.zoom.showCount<1){
      yuiDom.removeClass(yuiDom.get("resultsSection"),"noOverFlow");
    }
    this.zoomConfig.isShowing = false;
    this.zoomConfig.animOut.animate();
  },
  setShow:function(e){
    var self = this;
    this.zoomConfig.isOver = true;
    hotelExplorer.display.zoom.clearHide.apply(this);
    if(this.zoomConfig.image.src == ""){
      this.zoomConfig.image.src = this.zoomConfig.src;
    }
    if(!this.zoomConfig.isShowing){
      var coords = yuiEvent.getXY(e); // mouse coords
      this.zoomConfig.x = coords[0];
      this.zoomConfig.y = coords[1]+10;
      if(this.zoomConfig.x>700) {
        this.zoomConfig.x -= 350;
      }
      else {
        if(navigator.platform.indexOf("Mac") > -1 && navigator.userAgent.indexOf("Firefox") > -1){
          yuiDom.addClass(yuiDom.get("resultsSection"),"noOverFlow");
        }
      }
      this.zoomConfig.showTimeout = setTimeout(function(){
        hotelExplorer.display.zoom.show.apply(self);
      },hotelExplorer.display.zoom.showDelay*1000);
    }

  },
  setHide:function(e){
    var self = this;
    this.zoomConfig.isOver = false;
    if(this.zoomConfig.isShowing){
      clearTimeout(this.zoomConfig.showTimeout);

      this.zoomConfig.showTimeout = null;
      this.zoomConfig.hideTimeout = setTimeout(function(){
        hotelExplorer.display.zoom.hide.apply(self);
      },hotelExplorer.display.zoom.hideDelay*1000);
    }
    else {
      if(navigator.platform.indexOf("Mac") > -1 && navigator.userAgent.indexOf("Firefox") >-1){
        yuiDom.removeClass(yuiDom.get("resultsSection"),"noOverFlow");
      }
    }
  },
  clearHide:function(e){
    if(this.zoomConfig.hideTimeout){
      clearTimeout(this.zoomConfig.hideTimeout);
      this.zoomConfig.hideTimeout = null;
    }
  },
  openHighightAndHide:function(e){
    hotelExplorer.display.zoom.hide.apply(this);
    if(this.zoomConfig.highlight && !yuiDom.hasClass(this.zoomConfig.highlight,"detailsHighlightOpen")){
      highlight.show(this.zoomConfig.propertyId);
    }
  }
};
yuiEvent.onDOMReady(hotelExplorer.initialize);
////////////////////////////////////////////////////////////////////////////////////////////
function formatDates(dateParam,dateFormatString) {
	//var field;
	//var d;

	//field = _field;

	//_s  = field.value;
	var d = getDateFromField(dateParam, dateFormatString);
    //this.valid = true;
	if ( isNaN(d.getDate() ) ) {  // Basically, this allows the functions to gracefully return to the format string instead of putting a date in the field.
			return false;
	}
    return true;
}

//--------------------------------------------------------
//Get the Date from a form field - Based on Internationalization Variables
//--------------------------------------------------------
          /*
function getDateFromField(dateParam, dateFormat) {
	// formField is a reference to a text field
	// dateFormat is a string describing the local date format
	//	Current options for dateFormat:
	//		mm/dd/yyyy - English
	//		dd/mm/yyyy - Non-English, Non-Japanese
	//		yyyy/mm/dd - Japanese, Chinese
    //		dd.mm.yyyy - German

    var date = new Date(); // Default the date to today ready to be overwritten.
	var currDate = new Date(); // Today's date and time for comparison's sake.

	dateFormat = dateFormat.toLowerCase();
	var fieldString;
    var hasSlashOrDash = false;
    if (typeof dateParam == "object") {
        fieldString = dateParam.value;
    } else {
        fieldString = dateParam;
    }
   // fieldString = dateParam;
	if (fieldString.search("/") > 0) { // check if we have / to delimit
		var dateValues = fieldString.split("/");
        hasSlashOrDash = true;
    } else if (fieldString.search("-") > 0) { // They used - instead of /
		var dateValues = fieldString.split("-");
        hasSlashOrDash = true;
    } else if (fieldString.indexOf(".") >= 0) { // They used . instead of /
		var dateValues = fieldString.split(".");
	}else if (fieldString != "") {  // Assume there are no delimiters, assume one number
		var dateValues = new Array(fieldString);
	} else if (fieldString == "") {  // If there's not data there, assume it was deleted, and throw back a validDate object compatible invalid date.
		date.setTime(Date.parse(dateFormatString));
		return date;
	}

	if (fieldString.toLowerCase() == dateFormatString) {
		date.setTime(Date.parse(fieldString));
		return date;
	}

	var year;
	var month;
	var day;

	switch(dateFormat) {
		case 'mm/dd/yyyy':
			if (dateValues[0]) month = dateValues[0];
			if (dateValues[1]) day = dateValues[1];
			if (dateValues[2]) year = dateValues[2];
			break;
		case 'dd/mm/aaaa':
        case 'jj/mm/aaaa':
        case 'gg/mm/aaaa':
        case 'tt.mm.jjjj':
            if (dateValues[0]) day = dateValues[0];
			if (dateValues[1]) month = dateValues[1];
			if (dateValues[2]) year = dateValues[2];
			break;
		case 'yyyy/mm/dd':
			if (dateValues[0]) year = dateValues[0];
			if (dateValues[1]) month = dateValues[1];
			if (dateValues[2]) day = dateValues[2];
			break;
		case 'yyyy/dd/mm':
			if (dateValues[0]) year = dateValues[0];
			if (dateValues[1]) day = dateValues[1];
			if (dateValues[2]) month = dateValues[2];
			break;
        case "yy\u5E74mm\u6708dd\u65E5":
            if(!hasSlashOrDash) {
                //dateValues = fieldString.split(" ");
                year = fieldString.substr(0,2);
                month = fieldString.substr(3,2);
                day = fieldString.substr(6,2);
            } else {
                if (dateValues[0]) year = dateValues[0];
			    if (dateValues[1]) month = dateValues[1];
			    if (dateValues[2]) day = dateValues[2];
            }
            break;
        default:  // Default to mm/dd/yyyy
            if (dateValues[0]) month = dateValues[0];
			if (dateValues[1]) day = dateValues[1];
			if (dateValues[2]) year = dateValues[2];
			break;
	}

	if (year) {
		if (year.length == 2) { year = "20" + year; } // Try to make the year 4 digits
		if (year.length == 4) { // If it's not 4 digits, just fall back to using the current year
			date.setFullYear(year);
		}
	}
    date.setDate(1);
	if (month) date.setMonth(month - 1); // setMonth uses a zero-based number
	if (day) date.setDate(day);
	if (date.getTime() < currDate.getTime()) date.setYear(currDate.getFullYear() + 1); // For dates in the past, set to next year.
	//writeDateToField(formField, date, dateFormat);
    return date;

}
  */
