function SoilType () { MultiSelectCriterion.call(this,"SoilType",{'propertyTypes':[VACANTLAND,FARMRANCH], 'entityType':LISTING}); } function SpaceSize () { Criterion.call(this,"SpaceSize",{'leaseOrSale':FOR_LEASE, 'entityType':COMPARABLE}); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } } function CashFlow () { Criterion.call(this,"CashFlow",{'leaseOrSale':FOR_SALE, 'propertyTypes':[BIZ_OPP], 'entityType':LISTING, 'notForOffMarket':true}); } function OverheadCranes () { Criterion.call(this,"OverheadCranes",{'propertyTypes':[INDUSTRIAL], 'entityType':LISTING}); } function PropertyCondition () { MultiSelectCriterion.call(this,"PropertyCondition",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,HOSPITALITY,RETAIL,SPECIAL_PURPOSE], 'entityType':LISTING}); } function Clientele () { MultiSelectCriterion.call(this,"Clientele", {'propertyTypes':[HOSPITALITY,RETAIL,RETAIL_COMMERCIAL], 'entityType':LISTING}); } function SalePricePerUnit () { Criterion.call(this,"SalePricePerUnit",{'leaseOrSale':FOR_SALE, 'entityType':COMPARABLE}); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } } function Transportation () { MultiSelectCriterion.call(this,"Transportation",{'propertyTypes':[INDUSTRIAL,VACANTLAND,SPECIAL_PURPOSE], 'entityType':LISTING}); } function Size () { Criterion.call(this,"Size"); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } } function PendingTransaction () { Criterion.call(this,"PendingTransaction", {'entityType':LISTING, 'notForOffMarket':true}); } function LeaseTerm () { Criterion.call(this,"LeaseTerm",{'leaseOrSale':FOR_LEASE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL], 'entityType':LISTING, 'notForOffMarket':true}); } function SizeGross () { Criterion.call(this,"SizeGross",{'propertyTypes':[SPECIAL_PURPOSE], 'entityType':LISTING}); } function OfficeClass () { MultiSelectCriterion.call(this,"OfficeClass",{'propertyTypes':[OFFICE], 'entityType':LISTING}); } function AvailableSpace () { Criterion.call(this,"AvailableSpace", {'leaseOrSale':FOR_LEASE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL], 'entityType':LISTING, 'notForOffMarket':true}); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } this.isInCriteria = function(criteria) { var foundNames = false; var parent; if (this.parentElement) { parent = this.parentElement; } else { parent = $("#module-"+this.name.toUnTitleCase()).find('li'); } $(parent).find("input:text").each(function(i) { if (criteria[this.name]) { foundNames = true; } }); return foundNames; } } function GrossRentMultiplier () { Criterion.call(this,"GrossRentMultiplier",{'leaseOrSale':FOR_SALE, 'propertyTypes':[SPECIAL_PURPOSE], 'entityType':LISTING, 'notForOffMarket':true}); } function CeilingHeight () { Criterion.call(this,"CeilingHeight", {'propertyTypes':[INDUSTRIAL]}); } function Location() { Criterion.call(this,"Location"); this.locationItems = new Array(); this.setParsedLocationData = function(locationData) { this.locationItems = new Array(); this.addLocationData(locationData); } this.addLocationData = function(locationData) { var changed = false; for (var i = 0; i < locationData.length; i++) { var locationItem = new LocationItem(locationData[i]); if (this._addLocationItem(locationItem)) { changed = true; } } if (changed) { this.updateDisplay(); } return changed; } this._addLocationItem = function(locationItem) { var changed = false; if (locationItem.locationType && !this.contains(locationItem)) { // if a state has already been added, and I'm adding a location in that state, that location should replace the state. if (locationItem.locationType != 'state') { for (var j = 0; j < this.locationItems.length; j++) { if (this.locationItems[j].locationType == 'state' && this.locationItems[j].state == locationItem.state) { this.locationItems.splice(j, 1); break; } } } // if a county has already been added, and I'm adding a submarket in that county, the submarket should replace the county. if (locationItem.locationType == 'submarket') { for (var j = 0; j < this.locationItems.length; j++) { if (this.locationItems[j].locationType == 'county' && this.locationItems[j].state == locationItem.state && this.locationItems[j].county == locationItem.county) { this.locationItems.splice(j, 1); break; } } } this.locationItems.push(locationItem); changed = true; } return changed; } this.addPolygonAsCriteria = function(pPolygon) { for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].locationType == 'polygon') { this.locationItems.splice(i, 1); break; } } var locationData = [{polygon:pPolygon}]; this.addLocationData(locationData); this.doSearch(); } this.addMapAsCriteria = function() { var map = new MapManager().getMap(); var bounds = map.getBounds(); var ne = bounds.getNorthEast(); var sw = bounds.getSouthWest(); var polygon = new Polygon(ne, new GLatLng(sw.lat(),ne.lng()), sw, new GLatLng(ne.lat(),sw.lng())); polygon.close(); new MapManager().setPolygon(polygon); this.addPolygonAsCriteria(polygon); this.doSearch(); } this.contains = function(locationItem) { for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].equals(locationItem)) { return true; } else if (locationItem.locationType == 'state' && locationItem.state == this.locationItems[i].state) { // don't add 'IL' if 'Chicago, IL' already has been added. return true; } else if (locationItem.locationType == 'county' && locationItem.state == this.locationItems[i].state && locationItem.county == this.locationItems[i].county) { // don't add a county if a submarket from that county already has been added. return true; } } return false; } this.clear = function() { this._clear(); for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].locationType == 'polygon') { new MapManager().getMap().clearUserShape(); break; } } this.locationItems = new Array(); } function putArrayedValue(key, value, valueMap) { var values = valueMap[key]; if (!values) { values = new Array(); valueMap[key] = values; } values.push(value); } this.serialize = function() { var serialized = '['; for (var i = 0; i < this.locationItems.length; i++) { if (i > 0) serialized += ","; serialized += this.locationItems[i].toLocationData(); } serialized += ']'; return serialized; } this.deserialize = function(serialized) { this.addLocationData(eval(serialized)); } this.getCriterionValues = function() { var valueMap = new Array(); valueMap["search2"] = ["true"]; for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].locationType == "postalCode") { putArrayedValue("postalCode", this.locationItems[i].postalCode, valueMap); } else if (this.locationItems[i].locationType == "city") { putArrayedValue("city", this.locationItems[i].country + "|" + this.locationItems[i].state + "|" + this.locationItems[i].city, valueMap); } else if (this.locationItems[i].locationType == "msa") { putArrayedValue("msa", this.locationItems[i].country + "|" + this.locationItems[i].state + "|" + this.locationItems[i].msa, valueMap); } else if (this.locationItems[i].locationType == "submarket") { putArrayedValue("submarket", this.locationItems[i].country + "|" + this.locationItems[i].state + "|" + this.locationItems[i].county + "|" + this.locationItems[i].submarket, valueMap); } else if (this.locationItems[i].locationType == "county") { putArrayedValue("county", this.locationItems[i].country + "|" + this.locationItems[i].state + "|" + this.locationItems[i].county, valueMap); } else if (this.locationItems[i].locationType == "state") { putArrayedValue("state", this.locationItems[i].country + "|" + this.locationItems[i].state, valueMap); } else if (this.locationItems[i].locationType == "country") { putArrayedValue("country", this.locationItems[i].country, valueMap); } else if (this.locationItems[i].locationType == "polygon") { valueMap = new Array(); valueMap["search2"] = ["true"]; var coords = new Array(); var polygon = this.locationItems[i].polygon; for (var j=0;j 0) { var hasMapCriterion = false; for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].locationType == "polygon") { hasMapCriterion = true; break; } } var itemTemplate = '
' + '' + '{2}' + '{3}' + '
'; for (var i = 0; i < this.locationItems.length; i++) { var disabled = (hasMapCriterion && this.locationItems[i].locationType != "polygon"); displayValue += itemTemplate.format(i, disabled ? ' disabled' : '', this.locationItems[i].getDisplayableType(), this.locationItems[i].toString()); } } else { displayValue = "All Locations"; } var self = this; if ($(parentEl).find(".criteria")) { $(parentEl).find(".criteria").html(displayValue).find(".location-item .x").click(function() { var idx = $(this).attr("rel"); if (self.locationItems[eval(idx)].locationType.toLowerCase() == "polygon") { //remove the polygon new MapManager().getMap().clearUserShape(); } self.locationItems.splice(idx, 1); self.updateDisplay(); self.doSearch(); }); } var ex = $(parentEl).find(".ex"); var self = this; ex.unbind(); ex.click(function(){ $("#location-options").toggleClass("hidden").toggleClass("visible"); $("body").addClass("thick"); hidePageSelects(); $("#thickbox-mimic").unbind().click(function() { $("#location-options").addClass("hidden").removeClass("visible"); $("body").removeClass("thick"); }); if ($("#location-options:visible").length == 1) { self.loadDomesticForm(); } }); $("#location-options-apply").unbind(); $("#location-options-apply").click(function() { self.applyOptionsForm(); $("#location-options").toggleClass("hidden").toggleClass("visible"); $("body").removeClass("thick"); showPageSelects(); }); $("#location-map-apply").unbind(); $("#location-map-apply").click(function() { //self.applyOptionsForm(); self.addMapAsCriteria(); $("#location-options").toggleClass("hidden").toggleClass("visible"); $("body").removeClass("thick"); showPageSelects(); }); } } this.enableAdditionalListings = function(locationData) { if (!IS_NATIONAL && IS_LOGGED_IN && ENTITY_MODE == LISTING) { // Check to see if some locations are outside of this org's jurisdiction, if so, let's search nationally if (locationData) { if (locationData.nonPriority) { this._enableAdditionalListings(); } } else { if (this.locationItems && this.locationItems.length > 0) { for (var i = 0; i < this.locationItems.length; i++) { if (this.locationItems[i].nonPriority) { this._enableAdditionalListings(); } } } } } } this._enableAdditionalListings = function() { var addlListings = new CriteriaManager().getCurrentCriterionByName("AdditionalListings"); if (!addlListings) { addlListings = new CriteriaManager().addCurrentCriterionByName("AdditionalListings"); } if (!addlListings.shouldIncludeNationalListings()) { addlListings.doIncludeNationalListings(); } } this.applyOptionsForm = function() { var usedStates = ''; var select = document.getElementById("citySelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; var locationItem = new LocationItem(); locationItem.locationType = "city"; locationItem["country"] = select.options[i].country; locationItem["state"] = select.options[i].state; locationItem["city"] = select.options[i].city; if (this._addLocationItem(locationItem)) { usedStates += locationItem.country + '|' + locationItem.state + ","; } } select = document.getElementById("msaSelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; var locationItem = new LocationItem(); locationItem.locationType = "msa"; locationItem["country"] = select.options[i].country; locationItem["state"] = select.options[i].state; locationItem["msa"] = select.options[i].msa; if (this._addLocationItem(locationItem)) { usedStates += locationItem.country + '|' + locationItem.state + ","; } } var usedCounties = ""; select = document.getElementById("submarketSelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; var locationItem = new LocationItem(); locationItem.locationType = "submarket"; locationItem["country"] = select.options[i].country; locationItem["state"] = select.options[i].state; locationItem["county"] = select.options[i].county; locationItem["submarket"] = select.options[i].submarket; if (this._addLocationItem(locationItem)) { usedCounties += locationItem.state + "+" + locationItem.county + "|"; usedStates += locationItem.country + '|' + locationItem.state + ","; } } select = document.getElementById("countySelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; var locationItem = new LocationItem(); locationItem.locationType = "county"; locationItem["country"] = select.options[i].country; locationItem["state"] = select.options[i].state; locationItem["county"] = select.options[i].county; // only add counties which aren't being used to drill down into // submarkets if (usedCounties.indexOf(locationItem.state + "+" + locationItem.county) == -1) { if (this._addLocationItem(locationItem)) { usedStates += locationItem.country + '|' + locationItem.state + ","; } } } var postals = document.getElementById("postalCodeSelect").value; if (postals) { var postalCodes = document.getElementById("postalCodeSelect").postalCodes; postals = postals.replace(/\s/g,"").split(","); for (var i = 0; i < postals.length; i++) { if (postals[i] == "") continue; var locationItem = new LocationItem(); locationItem.locationType = "postalCode"; locationItem["postalCode"] = postals[i]; for (var j = 0; j < postalCodes.length; j++) { if (postalCodes[j].postalCode == postals[i]) { locationItem["state"] = postalCodes[j].state; break; } } if (this._addLocationItem(locationItem)) { usedStates += locationItem.country + '|' + locationItem.state + ","; } } document.getElementById("postalCodeSelect").value = ""; } select = document.getElementById("stateSelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; // only add states which aren't being used to drill down into // more specific location criteria if (usedStates.indexOf(select.options[i].value) == -1) { var locationItem = new LocationItem(); if (select.options[i].state) { locationItem.locationType = "state"; locationItem["state"] = select.options[i].state; locationItem["stateName"] = select.options[i].stateName; } else { locationItem.locationType = "country"; } locationItem["country"] = select.options[i].country; locationItem["countryName"] = select.options[i].countryName; this._addLocationItem(locationItem); } } this.updateDisplay(); this.doSearch(); } this.currentLocationController = null; this.loadDomesticForm = function() { $('#domestic-tab').addClass('active'); $('#international-tab').removeClass('active'); $('#location-options .domestic-only').removeClass('hidden'); this.loadOptionsForm(new StatesController()); } this.loadInternationalForm = function() { $('#domestic-tab').removeClass('active'); $('#international-tab').addClass('active'); $('#location-options .domestic-only').addClass('hidden'); this.loadOptionsForm(new InternationalLocationsController()); } this.loadOptionsForm = function(locationController) { $("#drilldown-items-container").addClass("hidden"); this.clearForms(); drilldown.collapseAllItems(); var includeNational = shouldIncludeNationalListings(); if (locationController == this.currentLocationController && includeNational == locationController.includeNationalListings) { return; } lastKnownSelected = null; var stateSelect = document.getElementById("stateSelect"); var postalCodeSelect = document.getElementById("postalCodeSelect"); stateSelect.length = 0; stateSelect[0] = new Option("Loading, please wait..."); locationController.requestLocationData(function(data) { stateSelect.length = 0; for (var i = 0; i < data.length; i++) { var display = data[i].name; if (!data[i].code) { display = data[i].countryName; } var opt = new Option(display, data[i].countryCode + '|' + data[i].code); opt.state = data[i].code; opt.stateName = data[i].name; opt.country = data[i].countryCode; opt.countryName = data[i].countryName; stateSelect[stateSelect.length] = opt; } }); } this.clearForms = function() { $("#location-options").find("input:text").each(function() { this.value = ""; }); $("#location-options").find("input:checkbox").each(function() { this.checked = false; }); $("#location-options").find("select").each(function() { this.length = 0; }); } this.setStateFromCriteriaValues = function(criteria) { // saved search parsing will be done on the server-side and using the setParsedLocationData() function // so this only needs to handle the criteria that this guy spits out //TODO: maybe this should be done server side, too? ... we need state name and country name and postal code state var locationData = new Array(); for (var key in criteria) { var vals = criteria[key]; for (var i = 0; i < vals.length; i++) { var split = vals[i].split('|'); if (key == "postalCode") { locationData.push({'postalCode':vals[i]}); } else if (key == "city") { locationData.push({'country':split[0], 'state':split[1], 'city':split[2]}); } else if (key == "msa") { locationData.push({'country':split[0], 'state':split[1], 'msa':split[2]}); } else if (key == "submarket") { locationData.push({'country':split[0], 'state':split[1], 'county':split[2], 'submarket':split[3]}); } else if (key == "county") { locationData.push({'country':split[0], 'state':split[1], 'county':split[2]}); } else if (key == "state") { locationData.push({'country':split[0], 'state':split[1], 'stateName':split[1]}); } else if (key == "country") { locationData.push({'country':split[0],'countryName':split[0]}); } else if (key == "international") { // TODO: phase out international if (split[2]) { locationData.push({'postalCode':split[2]}); } if (split[1]) { locationData.push({'country':split[0], 'city':split[1]}); } else if (split[0]) { locationData.push({'country':split[0],'countryName':split[0]}); } } } } this.addLocationData(locationData); } this.isInCriteria = function(criteria) { var foundNames = false; foundNames = criteria["postalCode"] || criteria["city"] || criteria["msa"] || criteria["submarket"] || criteria["county"] || criteria["state"] || criteria["country"] || criteria["international"] || // TODO: phase out international criteria["polygon"] || criteria["locationData"]; // legacy support for searches saved from the old search foundNames = foundNames || criteria["area"] || criteria["area2"] || criteria["areaCounty"] || criteria["zipCode"] || criteria["locationSearchType"]; return foundNames; } } function selectOption(selectID, optionValue) { var select = document.getElementById(selectID); for (var i = 0; i < select.options.length; i++) { if (select.options[i].value == optionValue) { select.options[i].selected = true; break; } } } function LocationItem(locationData) { this.locationType = null; if (locationData) { if (locationData.postalCode) { this.locationType = "postalCode"; this["country"] = locationData.country; this["state"] = locationData.state; this["postalCode"] = locationData.postalCode; } else if (locationData.city) { this.locationType = "city"; this["country"] = locationData.country; this["state"] = locationData.state; this["city"] = locationData.city; } else if (locationData.msa) { this.locationType = "msa"; this["country"] = locationData.country; this["state"] = locationData.state; this["msa"] = locationData.msa; } else if (locationData.submarket) { this.locationType = "submarket"; this["country"] = locationData.country; this["state"] = locationData.state; this["county"] = locationData.county; this["submarket"] = locationData.submarket; } else if (locationData.county) { this.locationType = "county"; this["country"] = locationData.country; this["state"] = locationData.state; this["county"] = locationData.county; } else if (locationData.stateName) { this.locationType = "state"; this["country"] = locationData.country; this["state"] = locationData.state; this["stateName"] = locationData.stateName; } else if (locationData.countryName) { this.locationType = "country"; this["country"] = locationData.country; this["countryName"] = locationData.countryName; } else if (locationData.polygon) { this.locationType = "polygon"; if (locationData.polygon.addPoint) { //this is a polygon object this.polygon = locationData.polygon; } else { //this is an array of coordinates var coords = locationData.polygon; var polygon = new Polygon(); for (var i=0;i 1) { var html = ''; for (var i = 0; i < locationData.length; i++) { html += '' + new LocationItem(locationData[i]).toString() + ''; } var selectDiv = $('#search-filters .location-criteria .add-criteria .multiple-location-select'); selectDiv.find('.locations').html(html); for (var i = 0; i < locationData.length; i++) { document.getElementById('selLoc' + i)['location'] = locationData[i]; } selectDiv.find('.x').unbind(); selectDiv.find('.x').click(function() { selectDiv.hide(); }); selectDiv.find('a').click(function() { txt.val(''); addLocation(this.location); selectDiv.hide(); return false; }); selectDiv.show(); } else if (locationData.length == 1) { txt.val(''); addLocation(locationData[0]); } else { txt.addClass("invalid"); } }); } function LocationParseController() { if (!LocationParseController.instance) { LocationParseController.instance = this; } else { return LocationParseController.instance; } this.ajaxCaller = new AJAXMethodCaller('com.catylist.ajax.LocationSearchProvider', 'parse', handleRequest); this.requestParsedLocations = function(locationBlob, handler) { if (handler) { this.handleParsedLocations = handler; } this.ajaxCaller.clearParameters(); this.ajaxCaller.addParameter('java.lang.String', locationBlob); this.ajaxCaller.call(); } this.handleParsedLocations = function(locationData) { } function handleRequest() { var req = LocationParseController.instance.ajaxCaller.ajax.requestor; if (req.readyState == AJAX.READY_STATE_COMPLETE && (!req.status || req.status == 200)) { var parsedData = eval(req.responseXML.documentElement.childNodes[0].childNodes[0].nodeValue); LocationParseController.instance.handleParsedLocations(parsedData); } } } function shouldIncludeNationalListings() { var natlListings = false; var addlListings = new CriteriaManager().getCurrentCriterionByName("AdditionalListings"); if (addlListings && addlListings.shouldIncludeNationalListings()) { natlListings = true; } return natlListings; } //get international countries in jurisdiction function InternationalLocationsController() { if (!InternationalLocationsController.instance) { InternationalLocationsController.instance = this; } else { return InternationalLocationsController.instance; } this.includeNationalListings = false; this.countriesCache; this.handleUpdate = function() {}; this.ajaxCaller = new AJAXMethodCaller('com.catylist.ajax.StateDataProvider', 'populateInternationalCountriesJSON'); this.ajaxCaller.setSuccessfulResponseXMLHandler(function(xml) { var countriesData = eval(xml.documentElement.childNodes[0].nodeValue); InternationalLocationsController.instance.countriesCache = countriesData; InternationalLocationsController.instance.handleUpdate(countriesData); }); this.requestLocationData = function(handler) { if (handler) { this.handleUpdate = handler; } var natlListings = shouldIncludeNationalListings(); if (this.includeNationalListings != natlListings) { this.countriesCache = null; this.includeNationalListings = natlListings; } if (this.countriesCache) { this.handleUpdate(this.countriesCache); } else { this.ajaxCaller.clearParameters(); this.ajaxCaller.addParameter("java.lang.Boolean", this.includeNationalListings ? "true" : "false"); this.ajaxCaller.call(); } } } // get states in jurisdiction function StatesController() { if (!StatesController.instance) { StatesController.instance = this; } else { return StatesController.instance; } this.includeNationalListings; this.statesCache; this.handleUpdate = function() {}; this.ajaxCaller = new AJAXMethodCaller('com.catylist.ajax.StateDataProvider', 'populateStatesJSON'); this.ajaxCaller.setSuccessfulResponseXMLHandler(function(xml) { var statesData = eval(xml.documentElement.childNodes[0].nodeValue); StatesController.instance.statesCache = statesData; StatesController.instance.handleUpdate(statesData); }); this.requestLocationData = function(handler) { if (handler) { this.handleUpdate = handler; } var natlListings = shouldIncludeNationalListings(); if (this.includeNationalListings != natlListings) { this.statesCache = null; this.includeNationalListings = natlListings; } if (this.statesCache) { this.handleUpdate(this.statesCache); } else { this.ajaxCaller.clearParameters(); this.ajaxCaller.addParameter("java.lang.Boolean", this.includeNationalListings ? "true" : "false"); this.ajaxCaller.call(); } } } // lookup and cache state drilldown data function StateDataController() { if (!StateDataController.instance) { StateDataController.instance = this; } else { return StateDataController.instance; } this.includeNationalListings = false; this.stateDataCache = new Object(); this.statesRequested = new Array(); this.ajaxCaller = new AJAXMethodCaller('com.catylist.ajax.StateDataProvider', 'populateStatesJSON', handleRequest); this.requestStateData = function(states, handler) { if (handler) { this.handleUpdate = handler; } this.statesRequested = states; if (states && states.length > 0) { var natlListings = shouldIncludeNationalListings(); if (this.includeNationalListings != natlListings) { this.stateDataCache = new Object(); this.includeNationalListings = natlListings; } var statesToGet = new Array(); for (var i = 0; i < states.length; i++) { if (!this.stateDataCache[states[i]]) { statesToGet.push(states[i]); } } if (statesToGet.length > 0) { this.ajaxCaller.clearParameters(); this.ajaxCaller.addParameter(AJAXMethodCaller.STRING_ARRAY_TYPE, statesToGet); this.ajaxCaller.addParameter("java.lang.Boolean", this.includeNationalListings ? "true" : "false"); this.ajaxCaller.call(); } else { this.fireUpdate(); } } } this.updateCache = function(statesData) { for (var i = 0; i < statesData.length; i++) { this.stateDataCache[statesData[i].countryCode + "|" + statesData[i].code] = statesData[i]; } } this.fireUpdate = function() { var requestedData = new Array(); for (var i = 0; i < this.statesRequested.length; i++) { requestedData.push(this.stateDataCache[this.statesRequested[i]]); } this.handleUpdate(requestedData); } this.handleUpdate = function(statesData) {} function handleRequest() { var req = StateDataController.instance.ajaxCaller.ajax.requestor; if (req.readyState == AJAX.READY_STATE_COMPLETE && (!req.status || req.status == 200)) { var statesData = eval(req.responseXML.documentElement.childNodes[0].nodeValue); StateDataController.instance.updateCache(statesData); StateDataController.instance.fireUpdate(); } } } function populateDrilldownData(statesData) { drilldown.collapseAllItems(); var citySelect = document.getElementById('citySelect'); var countySelect = document.getElementById('countySelect'); var msaSelect = document.getElementById('msaSelect'); var postalCodeSelect = document.getElementById('postalCodeSelect'); postalCodeSelect['postalCodes'] = new Array(); postalCodeSelect.value = ''; citySelect.length = 0; countySelect.length = 0; msaSelect.length = 0; for (var i = 0; i < statesData.length; i++) { for (var j = 0; j < statesData[i].cities.length; j++) { var display = statesData[i].cities[j]; if (statesData.length > 1) { if (statesData[i].code) { display = statesData[i].code + " - " + display; } else { display = statesData[i].countryCode + " - " + display; } } var cityOpt = new Option(display, statesData[i].countryCode + "|" + statesData[i].code + "|" + statesData[i].cities[j]); cityOpt['country'] = statesData[i].countryCode; cityOpt['state'] = statesData[i].code; cityOpt['city'] = statesData[i].cities[j]; citySelect[citySelect.length] = cityOpt; } for (var j = 0; j < statesData[i].msas.length; j++) { var display = statesData[i].msas[j]; if (statesData.length > 1) { display = statesData[i].code + " - " + display; } var msaOpt = new Option(display, statesData[i].countryCode + "|" + statesData[i].code + "|" + statesData[i].msas[j]); msaOpt['country'] = statesData[i].countryCode; msaOpt['state'] = statesData[i].code; msaOpt['msa'] = statesData[i].msas[j]; msaSelect[msaSelect.length] = msaOpt; } for (var j = 0; j < statesData[i].counties.length; j++) { var display = statesData[i].counties[j].name; if (statesData.length > 1) { display = statesData[i].code + " - " + display; } var countyOpt = new Option(display, statesData[i].countryCode + "|" + statesData[i].code + "|" + statesData[i].counties[j].name); countyOpt['country'] = statesData[i].countryCode; countyOpt['state'] = statesData[i].code; countyOpt['county'] = statesData[i].counties[j].name; countyOpt['submarkets'] = statesData[i].counties[j].submarkets; countySelect[countySelect.length] = countyOpt; } for (var j = 0; j < statesData[i].postals.length; j++) { postalCodeSelect['postalCodes'].push({'country':statesData[i].countryCode, 'state':statesData[i].code, 'postalCode':statesData[i].postals[j]}); } } // restore any previously selected elements var selectsToReselect = ["citySelect", "countySelect", "msaSelect"]; for (var i = 0; i < selectsToReselect.length; i++) { for (var j = 0; j < lastKnownSelected[selectsToReselect[i]].length; j++) { selectOption(selectsToReselect[i], lastKnownSelected[selectsToReselect[i]][j]); } } if (lastKnownSelected.countySelect.length > 0) { loadSubmarketsForSelectedCounties(); for (var i = 0; i < lastKnownSelected.submarketSelect.length; i++) { selectOption("submarketSelect", lastKnownSelected.submarketSelect[i]); } } var postalsInSelectedStates = new Array(); for (var i = 0; i < lastKnownSelected.postalCodeSelect.length; i++) { for (var j = 0; j < postalCodeSelect.postalCodes.length; j++) { if (postalCodeSelect.postalCodes[j].postalCode == lastKnownSelected.postalCodeSelect[i]) { postalsInSelectedStates.push(lastKnownSelected.postalCodeSelect[i]); break; } } } postalCodeSelect.value = postalsInSelectedStates.toString(); if (document.getElementById("citySelect").selectedIndex > -1) { drilldown.getDrilldownItem("city").expand(); } if (postalCodeSelect.value) { drilldown.getDrilldownItem("postalCode").expand(); } if (document.getElementById("countySelect").selectedIndex > -1) { drilldown.getDrilldownItem("county").expand(); } if (document.getElementById("msaSelect").selectedIndex > -1) { drilldown.getDrilldownItem("msa").expand(); } }; var lastKnownSelected; function loadDrilldownDataForSelectedStates(postPopulateHandler) { var states = new Array(); var stateSelect = document.getElementById("stateSelect"); for (var i = 0; i < stateSelect.options.length; i++) { if (stateSelect.options[i].selected) { states.push(stateSelect.options[i].value); } } lastKnownSelected = { "submarketSelect":new Array(), "postalCodeSelect":new Array(), "citySelect":new Array(), "countySelect":new Array(), "msaSelect":new Array() } var select = document.getElementById("submarketSelect"); while (select.selectedIndex != -1) { var i = select.selectedIndex; select.options[i].selected = false; lastKnownSelected.submarketSelect.push(select.options[i].value); } select.length = 0; lastKnownSelected.postalCodeSelect = document.getElementById("postalCodeSelect").value.replace(/\s/g,"").split(","); var selectsToClear = ["citySelect", "countySelect", "msaSelect"]; if (states.length > 0) { $("#drilldown-items-container").removeClass("hidden"); for (var i = 0; i < selectsToClear.length; i++) { var select = document.getElementById(selectsToClear[i]); while (select.selectedIndex != -1) { var j = select.selectedIndex; select.options[j].selected = false; lastKnownSelected[selectsToClear[i]].push(select.options[j].value); } select.length = 0; select[0] = new Option("Loading...", ""); } var dataHandler; if (postPopulateHandler) { dataHandler = function(statesData) { populateDrilldownData(statesData); postPopulateHandler(statesData); }; } else { dataHandler = populateDrilldownData; } new StateDataController().requestStateData(states, dataHandler); } else { $("#drilldown-items-container").addClass("hidden"); for (var i = 0; i < selectsToClear.length; i++) { var select = document.getElementById(selectsToClear[i]); select.length = 0; select[0] = new Option("Please select a location on the left", ""); } } } function loadSubmarketsForSelectedCounties() { var countySelect = document.getElementById("countySelect"); var submarketSelect = document.getElementById("submarketSelect"); submarketSelect.length = 0; var selectedCounties = new Array(); for (var i = 0; i < countySelect.options.length; i++) { if (countySelect.options[i].selected) { selectedCounties.push(countySelect.options[i]); } } for (var i = 0; i < selectedCounties.length; i++) { var submarkets = selectedCounties[i].submarkets; for (var j = 0; j < submarkets.length; j++) { var display = submarkets[j]; if (selectedCounties.length > 1) { display = selectedCounties[i].text + " - " + display; } var submarketOpt = new Option(display, selectedCounties[i].country + "|" + selectedCounties[i].state + "|" + selectedCounties[i].county + "|" + submarkets[j]); submarketOpt['country'] = selectedCounties[i].country; submarketOpt['state'] = selectedCounties[i].state; submarketOpt['county'] = selectedCounties[i].county; submarketOpt['submarket'] = submarkets[j]; submarketSelect[submarketSelect.length] = submarketOpt; } } } function Drilldown() { if (!Drilldown.instance) { Drilldown.instance = this; } else { return Drilldown.instance; } this.drilldownController = null; this.drilldownItems = new Array(); this.collapseAllItems = function() { for (var i = 0; i < this.drilldownItems.length; i++) { this.drilldownItems[i].collapse(); } } this.getDrilldownItem = function(locationType) { var toggleID; if (locationType == "postalCode") { toggleID = "includePostals"; } else if (locationType == "city") { toggleID = "includeCities"; } else if (locationType == "msa") { toggleID = "includeMSAs"; } else if (locationType == "submarket") { toggleID = "includeCounties"; } else if (locationType == "county") { toggleID = "includeCounties"; } if (toggleID) { for (var i = 0; i < this.drilldownItems.length; i++) { if ($(this.drilldownItems[i].toggler).attr("id") == toggleID) { return this.drilldownItems[i]; } } } return null; } } function DrilldownItem() { this.container = null; this.toggler = null; this.toggleTarget = null; this.resizables = new Array(); this.collapse = function() { this.toggler.checked = false; $(this.toggleTarget).hide(); } this.expand = function() { this.toggler.checked = true; $(this.toggleTarget).show(); } } var drilldown = new Drilldown(); function resizeDrilldownItems() { // note: offsetHeight is considerably faster than jquery's height() var totalHeight = drilldown.drilldownController.offsetHeight; var availableHeight = totalHeight; var resizableItems = 0; for (var i = 0; i < drilldown.drilldownItems.length; i++) { availableHeight -= drilldown.drilldownItems[i].container.offsetHeight; // if we have multiple resizable guys in a drilldown-item, let's assume // that they are side-by-side and ought to be the same height var maxH = 0; for (var j = 0; j < drilldown.drilldownItems[i].resizables.length; j++) { var h = drilldown.drilldownItems[i].resizables[j].offsetHeight; if (h > maxH) { maxH = h; } } if (maxH > 0) { availableHeight += maxH; resizableItems++; } } for (var i = 0; i < drilldown.drilldownItems.length; i++) { for (var j = 0; j < drilldown.drilldownItems[i].resizables.length; j++) { $(drilldown.drilldownItems[i].resizables[j]).height((availableHeight / resizableItems) + 'px'); } } } function showInternational() { var location = new CriteriaManager().getCurrentCriterionByName("Location"); location.loadInternationalForm(); } function showDomestic() { var location = new CriteriaManager().getCurrentCriterionByName("Location"); location.loadDomesticForm(); } $(document).ready(function() { $("#location-options .x").click(function() { $("#location-options").toggleClass("hidden").toggleClass("visible"); $("body").removeClass("thick"); showPageSelects(); }); $('#stateSelect').change(function() { loadDrilldownDataForSelectedStates(); }); $('#countySelect').change(function() { loadSubmarketsForSelectedCounties(); }); drilldown.drilldownController = $('#location-options').find('.drilldown-controller').get(0); $('#location-options').find('.drilldown-item').each(function(i) { var item = new DrilldownItem(); item.container = this; item.toggler = $(this).find('.toggler').get(0); item.toggleTarget = document.getElementById($(item.toggler).attr('rel')); $(this).find('.resizable').each(function(i) { item.resizables.push(this); }); drilldown.drilldownItems.push(item); item.collapse(); item.toggler['toggleTarget'] = item.toggleTarget; $(item.toggler).click(function() { if (this.checked) { $(this.toggleTarget).show(); } else { $(this.toggleTarget).hide(); $(this.toggleTarget).find('input').each(function(i) { this.value = ''; }); $(this.toggleTarget).find('select').each(function(i) { this.selectedIndex = -1; }); } resizeDrilldownItems(); }); }); // postal code auto-complete var getPostalCodes = function(query) { var matches = new Array(); var postals = document.getElementById('postalCodeSelect').postalCodes; for (var i = 0; i < postals.length; i++) { if (postals[i].postalCode.indexOf(query) == 0) { matches.push([postals[i].postalCode]); } } return matches; }; getPostalCodes.maxCacheEntries = 0; var postalCodeAutoComp = new YAHOO.widget.AutoComplete( "postalCodeSelect", "postalCodeAutocompleteContainer", new YAHOO.widget.DS_JSFunction(getPostalCodes) ); postalCodeAutoComp.delimChar = ","; postalCodeAutoComp.maxResultsDisplayed = 20; postalCodeAutoComp.allowBrowserAutocomplete = false; postalCodeAutoComp.useShadow = true; postalCodeAutoComp.minQueryLength = 0; }); function Price () { Criterion.call(this,"Price",{'notForOffMarket':true}); this.updateDisplay = function() { this._updateDisplay(); var cmgr = new CriteriaManager(); var unitsEnabled = cmgr.isPropertyTypeSelected(VACANTLAND) && cmgr.isLeaseOnly() && (ENTITY_MODE == LISTING); var priceUnits = $(this.parentElement).find("select[name='price_units']"); if (unitsEnabled) { priceUnits.removeClass("hidden"); } else { priceUnits.addClass("hidden"); } } this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); if ($(this.parentElement).find("select[name='price_units']:visible").length == 0) { map['price_units'] = new Array(); } } return map; } } function GrossLandSize () { Criterion.call(this,"GrossLandSize", {'leaseOrSale':FOR_SALE, 'entityType':COMPARABLE}); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } } function Keyword () { Criterion.call(this,"Keyword"); } function LeasePrice () { Criterion.call(this,"LeasePrice",{'leaseOrSale':FOR_LEASE,'entityType':LISTING,'notForOffMarket':true}); this.updateDisplay = function() { this._updateDisplay(); var vacantLandSelected = false; var propType = new CriteriaManager().getCurrentCriterionByName("PropertyType"); if (propType) { vacantLandSelected = propType.isSelected(VACANTLAND); } var perAcreOption = $(this.parentElement).find("select[name='leasePrice_units'] option=[value='5601']"); var psfOption = $(this.parentElement).find("select[name='leasePrice_units'] option=[value='5602']"); if (vacantLandSelected) { perAcreOption.removeClass("hidden"); } else { perAcreOption.addClass("hidden"); // this ensures that "Per Acre" isn't selected when it's not // available in the (visible) list if (perAcreOption[0].selected) { psfOption[0].selected = true; } } } this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); if ($(this.parentElement).find("select[name='leasePrice_units']:visible").length == 0) { map['leasePrice_units'] = []; } } return map; } } function AssociateComps () { Criterion.call(this,"AssociateComps", {'entityType':COMPARABLE, 'notForOffMarket':true}); } function Tenancy () { Criterion.call(this,"Tenancy",{'leaseOrSale':FOR_SALE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL], 'entityType':LISTING, 'notForOffMarket':true}); } function SizeRentable () { Criterion.call(this,"SizeRentable",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE]}); } function AmenitiesCommunity () { MultiSelectCriterion.call(this,"AmenitiesCommunity", {'propertyTypes':[MULTIFAMILY], 'entityType':LISTING}); } function RailAccess () { Criterion.call(this,"RailAccess",{'propertyTypes':[INDUSTRIAL,VACANTLAND,FARMRANCH], 'entityType':LISTING}); } function SubmarketType () { MultiSelectCriterion.call(this,"SubmarketType",{'entityType':LISTING}); } function DateAvailable () { Criterion.call(this,"DateAvailable", {'leaseOrSale':FOR_LEASE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL], 'entityType':LISTING, 'notForOffMarket':true}); } function Occupation () { Criterion.call(this,"Occupation",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,HOSPITALITY,RETAIL], 'entityType':LISTING}); } function Associate () { Criterion.call(this,"Associate",{'entityType':LISTING, 'notForOffMarket':true}); } function LoadingDocks () { Criterion.call(this,"LoadingDocks",{'propertyTypes':[INDUSTRIAL]}); } function AgentID () { Criterion.call(this,"AgentID",{'entityType':LISTING, 'notForOffMarket':true}); this.updateDisplay = function() { this._updateDisplay(); $(this.parentElement).find('.agent-name').html($(this.parentElement).find("input:hidden[name='agentName']").val()); } } function ClosingDate () { Criterion.call(this,"ClosingDate", {'leaseOrSale':FOR_SALE, 'entityType':COMPARABLE}); } function LeaseAgreementSigned () { Criterion.call(this,"LeaseAgreementSigned",{'leaseOrSale':FOR_LEASE, 'entityType':COMPARABLE}); } function RoadType () { MultiSelectCriterion.call(this,"RoadType",{'propertyTypes':[INDUSTRIAL,VACANTLAND,FARMRANCH], 'entityType':LISTING}); } function ConstructionSiding () { MultiSelectCriterion.call(this,"ConstructionSiding", {'propertyTypes':[MULTIFAMILY,INDUSTRIAL,RETAIL,RETAIL_COMMERCIAL], 'entityType':LISTING}); } function Utilities () { MultiSelectCriterion.call(this,"Utilities",{'propertyTypes':[FARMRANCH], 'entityType':LISTING}); } function Amps () { Criterion.call(this,"Amps", {'propertyTypes':[INDUSTRIAL], 'entityType':LISTING}); } function LeedCertified () { Criterion.call(this,"LeedCertified",{'entityType':LISTING}); } function MediaFiles () { Criterion.call(this,"MediaFiles",{'entityType':LISTING}); } function ConstructionStatus () { MultiSelectCriterion.call(this,"ConstructionStatus", {'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING}); } function LandSize () { Criterion.call(this,"LandSize",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,VACANTLAND,OFFICE,HOSPITALITY,RETAIL,FARMRANCH,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING}); this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); } return map; } } function Setting () { MultiSelectCriterion.call(this,"Setting",{'propertyTypes':[FARMRANCH,SPECIAL_PURPOSE], 'entityType':LISTING}); } function SpaceType () { MultiSelectCriterion.call(this,"SpaceType",{'leaseOrSale':FOR_LEASE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL], 'notForOffMarket':true}); } var typesForSale = [OFFICE,RETAIL,INDUSTRIAL,MULTIFAMILY,VACANTLAND,HOSPITALITY,FARMRANCH,RETAIL_COMMERCIAL,SPECIAL_PURPOSE,BIZ_OPP]; var typesForLease = [OFFICE,RETAIL,INDUSTRIAL,VACANTLAND,RETAIL_COMMERCIAL]; function SaleLease () { Criterion.call(this,"SaleLease",{'entityType':LISTING, 'defaultFilter':true}); this.getCriterionValues = function() { var newValMap = new Array(); var valMap = this._getCriterionValues(); if (valMap.forLease && !valMap.forSale) { newValMap['leaseOnly'] = ['1']; } else if (valMap.forSale && !valMap.forLease) { newValMap['saleOnly'] = ['1']; } if (valMap.offMarket) { newValMap['listedOffMarket'] = [(valMap.forLease || valMap.forSale) ? 'both' : 'properties']; } else { newValMap['listedOffMarket'] = ['listings']; } return newValMap; } this.isInCriteria = function(criteria) { return ENTITY_MODE == LISTING && (criteria.leaseOnly || criteria.saleOnly || criteria.listedOffMarket); } this.setStateFromCriteriaValues = function(values) { if (this.parentElement && values) { $(this.parentElement).find("input:checkbox").each(function(i) { if (this.name == 'forSale') { this.checked = !values.leaseOnly && (!values.listedOffMarket || values.listedOffMarket == 'both' || values.listedOffMarket == 'listings'); } else if (this.name == 'forLease') { this.checked = !values.saleOnly && (!values.listedOffMarket || values.listedOffMarket == 'both' || values.listedOffMarket == 'listings'); } else if (this.name == 'offMarket') { this.checked = values.listedOffMarket == 'properties' || values.listedOffMarket == 'both'; } }); } } this.closed = function() { new CriteriaView().updateDisplay(); } this.updateDisplay = function() { this._updateDisplay(); var me = this; $(this.parentElement).find("input:checkbox").unbind().click(function() { var mgr = new CriteriaManager(); // if the user is switching from sale <-> lease and has the // price field for the old mode active, but not the new mode, // let's go ahead and add the new price field for them. if (this.name == 'forSale' && this.value == '1') { if (mgr.getCurrentCriterionByName('SalePrice') == null && mgr.getCurrentCriterionByName('LeasePrice') != null) { mgr.addCurrentCriterionByName('SalePrice'); } for (var i = 0; i < SaleLease.CRITERIA_TO_ADD_ON_SALE_CHANGE.length; i++) { var criterionName = SaleLease.CRITERIA_TO_ADD_ON_SALE_CHANGE[i]; if (mgr.getCurrentCriterionByName(criterionName) == null) { mgr.addCurrentCriterionByName(criterionName); } } } if (this.name == 'forLease' && this.value == '1') { if (mgr.getCurrentCriterionByName('LeasePrice') == null && mgr.getCurrentCriterionByName('SalePrice') != null) { mgr.addCurrentCriterionByName('LeasePrice'); } for (var i = 0; i < SaleLease.CRITERIA_TO_ADD_ON_LEASE_CHANGE.length; i++) { var criterionName = SaleLease.CRITERIA_TO_ADD_ON_LEASE_CHANGE[i]; if (mgr.getCurrentCriterionByName(criterionName) == null) { mgr.addCurrentCriterionByName(criterionName); } } } new CriteriaView().updateDisplay(); me.doSearch(); }); } this.isSaleOnly = function() { return this.getCriterionValues().saleOnly; } this.isLeaseOnly = function() { return this.getCriterionValues().leaseOnly; } this.isOffMarketOnly = function() { return this.getCriterionValues().listedOffMarket == 'properties'; } } SaleLease.CRITERIA_TO_ADD_ON_SALE_CHANGE = new Array(); SaleLease.CRITERIA_TO_ADD_ON_LEASE_CHANGE = new Array(); function Company () { Criterion.call(this,"Company", {'notForOffMarket':true}); } function DateUpdated () { Criterion.call(this,"DateUpdated", {'entityType':LISTING, 'notForOffMarket':true}); } function Topography () { MultiSelectCriterion.call(this,"Topography",{'propertyTypes':[VACANTLAND,FARMRANCH], 'entityType':LISTING}); } function DevelopmentName () { Criterion.call(this,"DevelopmentName", {'propertyTypes':[VACANTLAND], 'entityType':LISTING}); } function DateAdded () { Criterion.call(this,"DateAdded", {'entityType':LISTING,'notForOffMarket':true}); } function CapRateActual () { Criterion.call(this,"CapRateActual", {'leaseOrSale':FOR_SALE, 'entityType':COMPARABLE}); } function PriceReduced () { Criterion.call(this,"PriceReduced",{'entityType':LISTING}); } function Volts () { Criterion.call(this,"Volts",{'propertyTypes':[INDUSTRIAL], 'entityType':LISTING}); } function ParkingType () { MultiSelectCriterion.call(this,"ParkingType",{'propertyTypes':[RETAIL_COMMERCIAL], 'entityType':LISTING}); } function Distressed () { Criterion.call(this,"Distressed",{'leaseOrSale':FOR_SALE, 'entityType':LISTING}); } function TotalUnits () { Criterion.call(this,"TotalUnits",{'propertyTypes':[HOSPITALITY], 'entityType':LISTING}); } function OfficeSpace () { Criterion.call(this,"OfficeSpace",{'propertyTypes':[INDUSTRIAL]}); } function DriveInBays () { Criterion.call(this,"DriveInBays", {'propertyTypes':[INDUSTRIAL]}); } function CashOnCash () { Criterion.call(this,"CashOnCash", {'leaseOrSale':FOR_SALE, 'propertyTypes':[SPECIAL_PURPOSE], 'entityType':LISTING, 'notForOffMarket':true}); } function CapRate () { Criterion.call(this,"CapRate", {'leaseOrSale':FOR_SALE, 'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,HOSPITALITY,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING, 'defaultFilter':true, 'notForOffMarket':true}); } function NetOperatingIncome () { Criterion.call(this,"NetOperatingIncome",{'leaseOrSale':FOR_SALE, 'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,HOSPITALITY,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING, 'notForOffMarket':true}); } function StreetAddress () { Criterion.call(this,"StreetAddress"); } function NumberOfBuildings () { Criterion.call(this,"NumberOfBuildings",{'propertyTypes':[MULTIFAMILY], 'entityType':LISTING}); } function Franchise () { Criterion.call(this,"Franchise", {'leaseOrSale':FOR_SALE, 'propertyTypes':[HOSPITALITY,BIZ_OPP], 'entityType':LISTING, 'notForOffMarket':true}); } var typesForSale = [OFFICE,RETAIL,INDUSTRIAL,MULTIFAMILY,VACANTLAND,HOSPITALITY,FARMRANCH,RETAIL_COMMERCIAL,SPECIAL_PURPOSE,BIZ_OPP]; var typesForLease = [OFFICE,RETAIL,INDUSTRIAL,VACANTLAND,RETAIL_COMMERCIAL]; function SaleLeaseComps () { Criterion.call(this,"SaleLeaseComps",{'entityType':COMPARABLE, 'defaultFilter':true}); this.getCriterionValues = function() { var newValMap = new Array(); var valMap = this._getCriterionValues(); if (valMap.leaseSale) { var val = valMap.leaseSale[0]||""; if (val.indexOf('sale') > -1) { newValMap['saleOnly'] = ['1']; } else if (val.indexOf('lease') > -1) { newValMap['leaseOnly'] = ['1']; } if (val.indexOf('Expired') > -1) { newValMap['searchFilter_include_expired'] = ['1']; } if (val.indexOf('Withdrawn') > -1) { newValMap['searchFilter_include_withdrawn'] = ['1']; } } return newValMap; } this.isInCriteria = function(criteria) { return ENTITY_MODE == COMPARABLE && (criteria.leaseOnly || criteria.saleOnly || criteria['search_lease_comps_submit'] || criteria['search_sale_comps_submit'] || criteria['searchFilter_include_expired'] || criteria['searchFilter_include_withdrawn']); } this.setStateFromCriteriaValues = function(values) { if (this.parentElement && values) { $(this.parentElement).find("select").each(function(i) { var sale = (values['saleOnly'] || values['search_sale_comps_submit']); var lease = (values['leaseOnly'] || values['search_lease_comps_submit']); var expired = values['searchFilter_include_expired']; var withdrawn = values['searchFilter_include_withdrawn']; if (sale && !expired && !withdrawn) { this.value = 'sale'; } else if (lease && !expired && !withdrawn) { this.value= 'lease'; } else if (sale && expired && !withdrawn) { this.value= 'saleExpired'; } else if (lease && expired && !withdrawn) { this.value= 'leaseExpired'; } else if (sale && !expired && withdrawn) { this.value= 'saleWithdrawn'; } else if (lease && !expired && withdrawn) { this.value= 'leaseWithdrawn'; } }); } } this.closed = function() { me._disable('ExpirationDate'); new CriteriaView().updateDisplay(); } this._enable = function(name) { var mgr = new CriteriaManager(); var criterion = mgr.getCurrentCriterionByName(name); if (!criterion) { mgr.addCurrentCriterionByName(name); } else { criterion.setEnabled(true); } } this._disable = function(name) { var mgr = new CriteriaManager(); var criterion = mgr.getCurrentCriterionByName(name); if (criterion) { criterion.setEnabled(false); } } this.updateDisplay = function() { this._updateDisplay(); var me = this; $(this.parentElement).find("select").unbind().change(function() { if (this.name == 'leaseSale') { new CriteriaView().updateDisplay(); if (this.value == 'lease') { me._enable('LeaseAgreementSigned'); } else if (this.value == 'sale') { me._enable('ClosingDate'); } else { me._disable('LeaseAgreementSigned'); me._disable('ClosingDate'); } if (this.value.indexOf('Expired') > -1) { me._enable('ExpirationDate'); } else { me._disable('ExpirationDate'); } } me.doSearch(); }); } this.isSaleOnly = function() { return this.getCriterionValues().saleOnly; } this.isLeaseOnly = function() { return this.getCriterionValues().leaseOnly; } } function LoadingDoors () { Criterion.call(this,"LoadingDoors",{'propertyTypes': [INDUSTRIAL]}); } function ExpirationDate () { Criterion.call(this,"ExpirationDate", {'entityType':COMPARABLE}); } function YearBuilt () { Criterion.call(this,"YearBuilt",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,OFFICE,HOSPITALITY,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING}); } function Visibility () { MultiSelectCriterion.call(this,"Visibility",{'propertyTypes':[VACANTLAND,RETAIL,SPECIAL_PURPOSE], 'entityType':LISTING}); } function YearRenovated () { Criterion.call(this,"YearRenovated",{'propertyTypes':[INDUSTRIAL], 'entityType':LISTING}); } function SalePrice () { Criterion.call(this,"SalePrice", {'leaseOrSale':FOR_SALE, 'entityType':LISTING, 'notForOffMarket':true}); } function Zoning () { Criterion.call(this,"Zoning",{'entityType':LISTING}); } function NumberOfUnits () { Criterion.call(this,"NumberOfUnits",{'propertyTypes':[MULTIFAMILY, HOSPITALITY]}); } function LeasedPrice () { Criterion.call(this,"LeasedPrice",{'leaseOrSale':FOR_LEASE,'entityType':COMPARABLE}); this.updateDisplay = function() { this._updateDisplay(); var vacantLandSelected = false; var propType = new CriteriaManager().getCurrentCriterionByName("PropertyType"); if (propType) { vacantLandSelected = propType.isSelected(VACANTLAND); } var perAcreOption = $(this.parentElement).find("select[name='leasePrice_units'] option=[value='5601']"); var psfOption = $(this.parentElement).find("select[name='leasePrice_units'] option=[value='5602']"); if (vacantLandSelected) { perAcreOption.removeClass("hidden"); } else { perAcreOption.addClass("hidden"); // this ensures that "Per Acre" isn't selected when it's not // available in the (visible) list if (perAcreOption[0].selected) { psfOption[0].selected = true; } } } this.getCriterionValues = function() { var hasValue = false; $(this.parentElement).find("input:text").each(function(i) { if (this.value) { hasValue = true; } }); var map = new Array(); if (hasValue) { map = this._getCriterionValues(); if ($(this.parentElement).find("select[name='leasePrice_units']:visible").length == 0) { map['leasePrice_units'] = []; } } return map; } } function TaxID () { Criterion.call(this,"TaxID",{'leaseOrSale':FOR_SALE, 'propertyTypes':[MULTIFAMILY,INDUSTRIAL,VACANTLAND,OFFICE,HOSPITALITY,RETAIL,FARMRANCH,RETAIL_COMMERCIAL], 'entityType':LISTING, 'notForOffMarket':true}); } function SalePriceComps () { Criterion.call(this,"SalePriceComps", {'leaseOrSale':FOR_SALE, 'entityType':COMPARABLE}); } function ParkingRatio () { Criterion.call(this,"ParkingRatio",{'propertyTypes':[INDUSTRIAL], 'entityType':LISTING}); } function PropertyType () { Criterion.call(this,"PropertyType"); this.types = new Array(); this.propertyTypeTree = null; this.addPropertyType = function(type) { this.types.push(new SinglePropertyType(type)); } this.addPropertyTypes = function(types) { for (var i=0;i 0) { subtypesButton.removeClass("hidden"); } applyBottomButton.addClass("hidden"); applyTopButton.addClass("hidden"); if (!PropertyType.APPLY_ON_TYPE_SELECT) { options.slideUp(); } } applyButton.unbind().click(function() { apply(); }); this.propertyTypeTree = new PropertyTypeTree(parentElement); if (PropertyType.APPLY_ON_TYPE_SELECT) { $(parentElement).find("input.type-indicator").click(function() { apply(); }); } } this.updateDisplay = function() { var parentEl = this.getParentElement(); if (parentEl) { if ($(parentEl).find(".criteria")) { var displayValue; var displayValues = mapFunction(function(x){return x.toString()}, this.types); if (displayValues.length > 0) { displayValue = displayValues.join(", "); } else { displayValue = "All Types"; } $(parentEl).find(".criteria").html(displayValue); } var subtypesButton = $(parentEl).find("button.type-options-subtypes"); if (this.types.length > 0) { subtypesButton.removeClass("hidden"); } else { subtypesButton.addClass("hidden"); } } } this.getCriterionValues = function() { //returns a hash of key/value pairs where the value is an array var map = new Array(); //map["propertyType"] = mapFunction(function(x){return x.id},this.types); map["propertyType"] = new Array(); map["subtype"] = new Array(); for (var i=0;i 0) { propType.addSubtypes(subtypes); } this.types.push(propType); } else { // across types for (var name in criteria) { if (name.indexOf("_subtype") > 0) { var propType = new SinglePropertyType(name.split("_", 1)[0]); propType.addSubtypes(criteria[name]); this.types.push(propType); } } } this._updateTree(); } this._updateTree = function() { for (var i=0;i 0) { branch.select(this.types[i].subtypes); } else { branch.selectAll(true); } } } } this.isInCriteria = function(criteria) { var found = false; var searchType = criteria.blueprintSearchType; if (!searchType && criteria["searchType"]) { searchType = criteria["searchType"][0]; } found = searchType && searchType.indexOf("_LISTINGS") > 0; found = found || criteria["subtype"] || criteria["propertyType"]; for (var i in SinglePropertyType.NAMES_BY_ID) { if (found) break; found = criteria["{0}_subtype".format(i)]; } return found; } } PropertyType.APPLY_ON_TYPE_SELECT = false; function PropertyTypeTree(parentElement) { this.branches = new Object(); var thisTree = this; var options = $(parentElement).find("form.type-options"); options.find("input.type-indicator").each(function() { var typeID = this.value; var branch = new PropertyTypeBranch(); branch.expandee = $(this).parent().next('.expandee')[0]; $(this).parent().prev('.expander').each(function() { branch.expander = this; $(this).click(function() { branch.toggleExpand(); }); }); branch.indicator = this; options.find("input:checkbox[name='" + typeID + "_subtype']").each(function() { branch.subTypes.push(this); $(this).click(function() { branch.updateIndicator() }); }); $(this).click(function() { branch.selectAll(this.checked); }) thisTree.branches[typeID] = branch; }); this.getBranch = function(typeID) { return this.branches[typeID]; } this.expandSelectedTypes = function() { for (var id in this.branches) { var branch = this.branches[id]; if (branch.indicator && (branch.indicator.mode == PropertyTypeBranch.INDICATOR_ALL || branch.indicator.mode == PropertyTypeBranch.INDICATOR_SOME)) { branch.expand(); } } } } function PropertyTypeBranch() { this.expander = null; this.expandee = null; this.indicator = null; this.subTypes = new Array(); this.getSubTypes = function() { var subTypeValues = new Array(); for (var i = 0; i < this.subTypes.length; i++) { if (this.subTypes[i].checked) { subTypeValues.push(this.subTypes[i].value); } } return subTypeValues; } this.updateIndicator = function() { var checked = false; var unchecked = false; for (var i = 0; i < this.subTypes.length; i++) { if (this.subTypes[i].checked) { checked = true; } else { unchecked = true; } } if (checked && !unchecked) { this.indicator.mode = PropertyTypeBranch.INDICATOR_ALL; this.indicator.checked = true; } else if (!checked) { this.indicator.mode = PropertyTypeBranch.INDICATOR_NONE; this.indicator.checked = false; } else { this.indicator.mode = PropertyTypeBranch.INDICATOR_SOME; this.indicator.checked = true; } } this.selectAll = function(select) { for (var i = 0; i < this.subTypes.length; i++) { this.subTypes[i].checked = select; } this.indicator.checked = select; this.indicator.mode = select ? PropertyTypeBranch.INDICATOR_ALL : PropertyTypeBranch.INDICATOR_NONE; } this.select = function(subTypesToSelect) { for (var i = 0; i < this.subTypes.length; i++) { for (var j = 0; j < subTypesToSelect.length; j++) { if (this.subTypes[i].value == subTypesToSelect[j]) { this.subTypes[i].checked = true; } } } this.updateIndicator(); } this.expand = function() { $(this.expander).addClass('expanded'); $(this.expandee).removeClass('hidden'); } this.toggleExpand = function() { $(this.expander).toggleClass('expanded'); $(this.expandee).toggleClass('hidden'); } } PropertyTypeBranch.INDICATOR_ALL = 1; PropertyTypeBranch.INDICATOR_SOME = 2; PropertyTypeBranch.INDICATOR_NONE = 3; function SinglePropertyType(id) { this.id = id; //subtypes are just strings this.subtypes = new Array(); this.addSubtypes = function(subtypes) { for (var i=0;i 0) { str += "" + this.subtypes.join(", ") + ""; } return str; } } SinglePropertyType.NAMES_BY_ID = new Array(); SinglePropertyType.NAMES_BY_ID[new String(INDUSTRIAL)] = "Industrial"; SinglePropertyType.NAMES_BY_ID[new String(MULTIFAMILY)] = "Multi-Family"; SinglePropertyType.NAMES_BY_ID[new String(OFFICE)] = "Office"; SinglePropertyType.NAMES_BY_ID[new String(RETAIL)] = "Shopping Center"; SinglePropertyType.NAMES_BY_ID[new String(HOSPITALITY)] = "Hospitality"; SinglePropertyType.NAMES_BY_ID[new String(FARMRANCH)] = "Farm/Ranch"; SinglePropertyType.NAMES_BY_ID[new String(RETAIL_COMMERCIAL)] = "Retail Commercial"; SinglePropertyType.NAMES_BY_ID[new String(SPECIAL_PURPOSE)] = "Special Purpose"; SinglePropertyType.NAMES_BY_ID[new String(BIZ_OPP)] = "Business Opportunity"; SinglePropertyType.NAMES_BY_ID[new String(VACANTLAND)] = "Vacant Land"; $(document).ready(function() { $("form.type-options").hide(); }); function BuildToSuit () { Criterion.call(this,"BuildToSuit", {'leaseOrSale':FOR_SALE, 'propertyTypes':[VACANTLAND], 'entityType':LISTING, 'notForOffMarket':true}); } function DateArchived () { Criterion.call(this,"DateArchived", {'entityType':COMPARABLE}); } function SaleTerms () { MultiSelectCriterion.call(this,"SaleTerms",{'leaseOrSale':FOR_SALE, 'entityType':LISTING, 'notForOffMarket':true}); } function Auction () { Criterion.call(this,"Auction",{'leaseOrSale':FOR_SALE, 'entityType':LISTING}); } function InternetAccess () { MultiSelectCriterion.call(this,"InternetAccess",{'propertyTypes':[MULTIFAMILY,INDUSTRIAL,SPECIAL_PURPOSE], 'entityType':LISTING}); } function LeaseType () { MultiSelectCriterion.call(this,"LeaseType",{'leaseOrSale':FOR_LEASE, 'propertyTypes':[INDUSTRIAL,VACANTLAND,OFFICE,RETAIL,RETAIL_COMMERCIAL], 'defaultFilter':true, 'notForOffMarket':true}); } function LandSplits () { Criterion.call(this,"LandSplits",{'propertyTypes':[FARMRANCH], 'entityType':LISTING}); } function PropertyName () { Criterion.call(this,"PropertyName",{'entityType':COMPARABLE}); } function UseType () { MultiSelectCriterion.call(this,"UseType",{'leaseOrSale':FOR_SALE, 'propertyTypes':[INDUSTRIAL,OFFICE,RETAIL,RETAIL_COMMERCIAL,SPECIAL_PURPOSE], 'entityType':LISTING, 'defaultFilter':true, 'notForOffMarket':true}); }