<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">

var timestamp = Math.floor(Date.now());

function debugTime(message) {
	if (!SpatialSearch.System.bdebug)
		return;
	var time_total = Math.floor(Date.now()) - timestamp;
	console.log('(client) ' + message, time_total);
}


(function($) {
$(document).ready(function() {
	
	debugTime('Document Ready (ms)');
	
	
	// Poll every 100ms until the SpatialSearch object exists and the header element is present
	var intervalId = setInterval(function() {
		if (window.SpatialSearch ) {
			SpatialSearch.UI.initSpatialSearchUI();
			clearInterval(intervalId);
		}
	}, 1);


	// ------------------------------------------------------------ //
	// -------------------------- WINDOW -------------------------- //
	// ------------------------------------------------------------ //

	// LOAD
	$(window).on('load', function(){
		
		debugTime('Window Loaded (ms)');
		
		SpatialSearch.UI.initSpatialSearchUI_onWindowLoad();
	}); // end window on load block


	// RESIZE
	$(window).on('resize', function() {
		if ($("#ss__header").length) {
			SpatialSearch.UI.setBrokersDropdownMaxHeight();
		}
		
		// page - search
		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
			SpatialSearch.UI.manageResultsViewMode();
			SpatialSearch.UI.SearchTitlebarAlignment();
			SpatialSearch.UI.setMapHeight();
		}

		// page - property
		if ($(SpatialSearch.root.selector).hasClass('ss__page_property')) {
			// SpatialSearch.UI.resizePropertyFotoramas();
		}
	});
	
	
	
	// initialize various DOM, UI elements - on document ready
	SpatialSearch.UI.initSpatialSearchUI = function() {
		
		debugTime('Initialize UI - Ready (ms)');
		
		if ($("#ss__header").length) {
			
			SpatialSearch.Data.UI.setCountry();
			SpatialSearch.UI.initUpdateAdvancedFiltersHeight();
			SpatialSearch.UI.initializeLocationSearchNew();
		
			// initial selection of custom radio buttons
			$('#ss__header .subgroup .customrb_container').each(function(){
				if ($(this).find('.active').length==0) {
					$(this).find('.default').addClass('active');
					$('#' + $(this).data('field')).val( $(this).find('.default').data('value') );
				}
			});
		
			// property type
			if ($('input#property_type').val()!='') {
				SpatialSearch.Data.UI.setSizeSubgroupsVisibility();
			}
			$('input#property_type').change(function(){
				SpatialSearch.Data.UI.setSizeSubgroupsVisibility();
			});
		
			// price subgroups visibility
			if ($('input#availability_transaction_type').val()!='') {
				SpatialSearch.Data.UI.setPriceSubgroupsVisibility();
			}
			$('input#availability_transaction_type').change(function(){
				SpatialSearch.Data.UI.setPriceSubgroupsVisibility();
			});
		}
		
		
		if ($('#ss__advanced_filters').length) {
			SpatialSearch.Data.UI.setAvailabilityBuildingClassStates();
			SpatialSearch.Data.UI.setRetailShoppingCentersState();
			SpatialSearch.Data.UI.synchronizeUseTypeDropdowns();
		}
		
		
		// page - search
		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
			SpatialSearch.Data.UI.setInitialSortOptions();
			SpatialSearch.UI.manageResultsViewMode();
			SpatialSearch.UI.SearchTitlebarAlignment();
			
			SpatialSearch.UI.setMapHeight();
			// disable button saved if there are no saved properties
			if (SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_saved)===undefined)
				$('.ss__show_saved').addClass('disabled');
		}
		
		// page - property
		if ($(SpatialSearch.root.selector).hasClass('ss__page_property')) {
			SpatialSearch.UI.setBackButton();
			SpatialSearch.UI.setSocialActions();
			SpatialSearch.UI.PropertySetFotoramaAriaLabels();
			// SpatialSearch.UI.resizePropertyFotoramas();
			// SpatialSearch.Property.map.render();
		}
		
		// page - team and person
		if ($(SpatialSearch.root.selector).hasClass('ss__page_team') || $(SpatialSearch.root.selector).hasClass('ss__page_person')) {
			SpatialSearch.Team.initTeamFilters();
		}
		
		// page - team
		if ($(SpatialSearch.root.selector).hasClass('ss__page_team')) {
			SpatialSearch.Team.initSortClick();
		}
	};
	
	
	SpatialSearch.UI.PropertySetFotoramaAriaLabels = function() {
		if ($('.fotorama__arr.fotorama__arr--next').length) {
			$('.fotorama__arr.fotorama__arr--next').attr('aria-label', 'Next Slide');
		}
		if ($('.fotorama__arr.fotorama__arr--prev').length) {
			$('.fotorama__arr.fotorama__arr--prev').attr('aria-label', 'Next Slide');
		}
		if ($('.fotorama__nav__frame--dot').length) {
			$('.fotorama__nav__frame--dot').attr('aria-label', 'Slide');
		}
		
		const interval = setInterval(() =&gt; {
	  		if ($('.mapboxgl-marker').length) {
				$('.mapboxgl-marker').removeAttr('aria-label');
				$('.mapboxgl-ctrl-attrib-inner').removeAttr('role');
				debugTime('mapbox accessibility fixes (ms)');
				clearInterval(interval);
	  		}
		}, 100);
		setTimeout(() =&gt; clearInterval(interval), 2000);
	};
	
	
	
	
	// initialize various DOM, UI elements - on window load
	SpatialSearch.UI.initSpatialSearchUI_onWindowLoad = function() {
		
		// debugTime('Initialize UI - Load (ms)');
		
		if ($("#ss__header").length) {
			SpatialSearch.UI.setBrokersDropdownMaxHeight();
		}
		
		if ($('#ss__advanced_filters').length) {
		}
		
		// page - search
		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
		}
		
		// page - property
		if ($(SpatialSearch.root.selector).hasClass('ss__page_property')) {
			// SpatialSearch.UI.resizePropertyFotoramas();
			SpatialSearch.Property.map.render();
		}
		
		// page - team and person
		if ($(SpatialSearch.root.selector).hasClass('ss__page_team') || $(SpatialSearch.root.selector).hasClass('ss__page_person')) {
		}
		
		// page - team
		if ($(SpatialSearch.root.selector).hasClass('ss__page_team')) {
		}
	};
	
	
	
	
	SpatialSearch.UI.setBrokersDropdownMaxHeight = function() {
		if ($("#availability_broker_select").length) {
			var viewportHeight = $(window).height();
			var bodyHeight = $('body').height();
			var documentHeight = $(document).height();
			var availableHeight = Math.min(viewportHeight, bodyHeight);
			
			var elementTop = $('#ss__header .ss__field.availability_broker').offset().top;
			var scrollTop = $(window).scrollTop();
			var substract = 100;
			
			var brokers_dropdown_height = availableHeight - (elementTop - scrollTop) - substract;
			
			$('#availability_broker_select').css('max-height', brokers_dropdown_height + 'px');
		}
	}
	
	
	
	
	// initiate observing change of height of header container
	// needed for adjusting top position and height of advanced filters
	// at &lt;800 resolution
	SpatialSearch.UI.initUpdateAdvancedFiltersHeight = function() {
		const headerContainter = document.getElementById('ss__header_container');
		const resizeObserver = new ResizeObserver(entries =&gt; {
			for (let entry of entries) {
				SpatialSearch.UI.updateAdvancedFiltersHeight();
			}
		});
		resizeObserver.observe(headerContainter);
	}

	// update height of advanced filters on mobile devices (&lt;800)
	// on change of height of ss__header_container
	SpatialSearch.UI.updateAdvancedFiltersHeight = function() {
		// toggleFieldDropdown
		const root = document.getElementById(SpatialSearch.root.id);
		const advanced_filters = document.getElementById('ss__advanced_filters');
		const header = document.getElementById('ss__header');
		const headerContainter = document.getElementById('ss__header_container');
		const filtersContainer = document.getElementById('ss__advanced_filters_container');

		if (advanced_filters.classList.contains('ss__expanded')) {
			if (window.innerWidth &lt; 800) {
				const filtersHeight = filtersContainer.offsetHeight;
				const availableHeight = $(window).height() - header.getBoundingClientRect().bottom;
				// const availableHeight = $(window).height() - header.getBoundingClientRect().bottom;
				const newHeight = (filtersHeight &gt; availableHeight) ? availableHeight : filtersHeight;

				advanced_filters.style.height = newHeight + 'px';
			}
			if (window.innerWidth &lt; SpatialSearch.Constants.header_mobile_breakpoint &amp;&amp; root.classList.contains('sticky_header')) {
				advanced_filters.style.top = (header.offsetHeight - 2) + 'px';
			}
		}
	}



	// ------------------------------------------------------------ //



	SpatialSearch.UI.initializeLocationSearchNew = function() {
		// debugTime('Initialize Location Search (ms)');
		
		const searchIcon = document.querySelector('#prop-keyword i');
		const inputField = document.querySelector('#prop-keyword input');
		const resetIcon = document.querySelector('#prop-keyword b');
		const searchContainer = document.querySelector('#prop-keyword');
	
		// click on search icon
		if (searchIcon) {
			searchIcon.addEventListener('click', function(event) {
				// SpatialSearch.Utils.dumpJS(event.target, 'location search: search icon click');
				if (inputField &amp;&amp; inputField.value.trim() !== '') {
					// SpatialSearch.Utils.dumpJS(inputField.value, 'location search: input field value = ');
					inputField.disabled = true;
					if (searchContainer) {
						searchContainer.setAttribute("data-animation", "searching");
					}
					SpatialSearch.Reset.Msa(false);
					SpatialSearch.Reset.County(false);
					SpatialSearch.Reset.locationAddress(false);
					SpatialSearch.API.run();
				}
			});
		}
	
		// press enter key
		if (inputField) {
			inputField.addEventListener('keypress', function(event) {
				if (event.key === 'Enter' &amp;&amp; inputField.value.trim() !== '') {
					// SpatialSearch.Utils.dumpJS(event.target, 'location search: Enter key pressed');
					inputField.disabled = true;
					if (searchContainer) {
						// searchContainer.setAttribute("data-used", "");
						searchContainer.setAttribute("data-animation", "searching");
					}
					SpatialSearch.Reset.Msa(false);
					SpatialSearch.Reset.County(false);
					SpatialSearch.Reset.locationAddress(false);
					SpatialSearch.API.run();
				}
			});
		}
	
		// click on X icon to reset search
		if (resetIcon) {
			resetIcon.addEventListener('click', function(event) {
				// SpatialSearch.Utils.dumpJS(event.target, 'location search: reset icon click');
				if (inputField) {
					inputField.disabled = true;
					if (searchContainer) {
						searchContainer.setAttribute("data-used", "");
						searchContainer.setAttribute("data-animation", "loading");
					}
					SpatialSearch.Reset.searchKeyword();
				}
			});
		}
	}





	// -------------------- DATA UI methods -------------------- //

	// manage transaction subtypes visibility
	// ok for ss__page_header
	SpatialSearch.Data.UI.showTransactionTypeSubType = function(subtype='') {
		if (subtype!='') {
			if (subtype!='all') {
				$('.transaction_subtype').hide().attr('data-used','no');
				var item = $('.transaction_type .transaction_subtype[data-type="' + subtype + '"]');
				item.show().attr('data-used','yes');

				// resetting subtype toggle active element
				$('.transaction_subtype .transaction_type_toggle div').removeClass('active');
				$('.transaction_subtype .transaction_type_toggle div.default').addClass('active');
				$('.transaction_subtype_input').val('');
				$('#ss__inline_inputs #' + subtype).val( item.find('div.default').data('value') );
			}
			else {
				$('.transaction_subtype').show().attr('data-used','yes');
				$('.transaction_subtype .transaction_type_toggle div').removeClass('active');
				$('.transaction_subtype .transaction_type_toggle div.default').addClass('active');
				$('.transaction_subtype_input').val('');
				$('#ss__inline_inputs #availability_sublease').val( $('.transaction_subtype[data-type="availability_sublease"]').find('div.active').data('value') );
				$('#ss__inline_inputs #availability_investment').val( $('.transaction_subtype[data-type="availability_investment"]').find('div.active').data('value') );
			}
		}
	}


	// manage size subgroups visibility
	// ok for ss__page_header
	SpatialSearch.Data.UI.setSizeSubgroupsVisibility = function() {
		var property_types = $('input#property_type').val().split(',');
		var land_subgroup = $('.property_size .subgroup[data-type="land"]');
		var available_subgroup = $('.property_size .subgroup[data-type="available"]');

		if (jQuery.inArray( 'land', property_types) == -1) {
			SpatialSearch.Reset.subgroup(land_subgroup);
			$(land_subgroup).hide();
			$(available_subgroup).show();
		}
		else {
			if (property_types.length==1) {
				SpatialSearch.Reset.subgroup(available_subgroup);
				$(available_subgroup).hide();
			}
			$(land_subgroup).show();
		}
	}


	// manage price subgroups visibility
	// ok for ss__page_header
	SpatialSearch.Data.UI.setPriceSubgroupsVisibility = function() {
		var availability_transaction_types = $('input#availability_transaction_type').val().split(',');

		if (availability_transaction_types!='all') {
			$('.property_price .subgroup').each(function(){
				if (jQuery.inArray( $(this).data('type'), availability_transaction_types) == -1) {
					SpatialSearch.Reset.subgroup($(this));
					$(this).hide();
				}
				else {
					$(this).show();
				}
			});
		}
		else {
			$('.property_price .subgroup').show();
		}
	}


	// set initial value for country
// 	SpatialSearch.Data.UI.setCountry_OLD = function() {
// 		var country_value = '';
// 
// 		if (SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_country)===undefined) {
// 			country_value = SpatialSearch.System.default_country;
// 			SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_country, country_value);
// 			$( '#' + $('.ss__field#country_dropdown').data('field') ).val(country_value);
// 			$('.ss__field#country_dropdown .field_label').attr('data-value',country_value);
// 			$('.ss__field#country_dropdown li').removeClass('active');
// 			$('.ss__field#country_dropdown li[data-value="' + country_value + '"]').addClass('active');
// 		}
// 		else {
// 			country_value = SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_country);
// 			if ( SpatialSearch.System.hide_country=='yes' &amp;&amp; ( SpatialSearch.System.default_country != country_value ) ) {
// 				country_value = SpatialSearch.System.default_country;
// 				SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_country, country_value);
// 			}
// 			$('#' + $('.ss__field#country_dropdown').data('field') ).val(country_value);
// 			$('.ss__field#country_dropdown .field_label').attr('data-value',country_value);
// 			$('.ss__field#country_dropdown li').removeClass('active');
// 			$('.ss__field#country_dropdown li[data-value="' + country_value + '"]').addClass('active');
// 		}
// 	}
	
	
	SpatialSearch.Data.UI.setCountry = function() {
		var country_value = $('.ss__field#country_dropdown .field_label').attr('data-value');
	
		if (country_value=='') {
			country_value = SpatialSearch.System.default_country;
		}
		else {
			if ( SpatialSearch.System.hide_country=='yes' &amp;&amp; ( SpatialSearch.System.default_country != country_value ) ) {
				country_value = SpatialSearch.System.default_country;
			}
		}
		$( '#' + $('.ss__field#country_dropdown').data('field') ).val(country_value);
		$('.ss__field#country_dropdown .field_label').attr('data-value',country_value);
		$('.ss__field#country_dropdown li').removeClass('active');
		$('.ss__field#country_dropdown li[data-value="' + country_value + '"]').addClass('active');
	}


	SpatialSearch.Data.UI.setAvailabilityBuildingClassStates = function() {
		if ($('#ss__advanced_filters').length) {
			var value = $('#ss__inline_inputs #property_building_class').val();

			//TODO: here add + if need
			if (value!='') {
				if (value.indexOf('a')==-1)
					$('.property_building_class li[data-value="a"]').removeClass('active');
				if (value.indexOf('b')==-1)
					$('.property_building_class li[data-value="b"]').removeClass('active');
				if (value.indexOf('c')==-1)
					$('.property_building_class li[data-value="c"]').removeClass('active');
			}
			else {
				$('.property_building_class li').addClass('active');
			}
		}
	}


	SpatialSearch.Data.UI.setRetailShoppingCentersState = function() {
		if ($('#ss__advanced_filters').length) {
			var value = $('#ss__inline_inputs #property_shopping_center').val();
			if (value!='') {
				$('.property_shopping_center li').removeClass('active');
				$('.property_shopping_center li[data-value="' + value + '"]').addClass('active');
			}
			else
				$('.property_shopping_center li.default').addClass('active');
		}
	}


	SpatialSearch.Data.UI.synchronizeUseTypeDropdowns = function() {
		if ($('#ss__advanced_filters').length) {
			$('.availability_use_type').on('change', function() {
				var selectedValue = $(this).val();
				$('.availability_use_type').val(selectedValue);
			});
		}
	}


// 	SpatialSearch.Data.UI.setInitialSortOptions_OLD = function() {
// 		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
// 			var type = ''
// 			var direction = '';
// 
// 			if (SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_sort_type)===undefined) {
// 				type = SpatialSearch.System.default_sort_type;
// 				SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_sort_type, type);
// 			}
// 			else {
// 				type = SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_sort_type);
// 			}
// 
// 			if (SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_sort_direction)===undefined) {
// 				direction = SpatialSearch.System.default_sort_direction;
// 				SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_sort_direction, direction);
// 			}
// 			else {
// 				direction = SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_sort_direction);
// 			}
// 
// 			$('#ss__inline_inputs #sort').val( type );
// 			if (direction!='desc')
// 				$('#ss__inline_inputs #descending').val('false');
// 			else
// 				$('#ss__inline_inputs #descending').val('true');
// 
// 			$('.ss__sort_dropdown li[data-value="' + type + '"]').addClass('active');
// 			$('.ss__sort_dropdown li[data-value="' + type + '"]').attr('data-direction',direction);
// 			$('.ss__sort_dropdown li[data-value="' + type + '"] .sort_direction[data-direction="' + direction + '"]').addClass('active');
// 		}
// 	}
	
	
	SpatialSearch.Data.UI.setInitialSortOptions = function() {
		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
			var type = $('.ss__sort_dropdown').attr('data-sort-type');
			var direction = $('.ss__sort_dropdown').attr('data-sort-direction');
	
			if (type=='') {
				type = SpatialSearch.System.default_sort_type;
			}
	
			if (direction=='') {
				direction = SpatialSearch.System.default_sort_direction;
			}
	
			$('#ss__inline_inputs #sort').val( type );
			
			if (direction!='desc')
				$('#ss__inline_inputs #descending').val('false');
			else
				$('#ss__inline_inputs #descending').val('true');
	
			$('.ss__sort_dropdown li[data-value="' + type + '"]').addClass('active');
			$('.ss__sort_dropdown li[data-value="' + type + '"]').attr('data-direction',direction);
			$('.ss__sort_dropdown li[data-value="' + type + '"] .sort_direction[data-direction="' + direction + '"]').addClass('active');
		}
	}


	SpatialSearch.Data.UI.executeSortOptions = function(item,type,direction) {
		$('.ss__sort_dropdown li').removeClass('active').attr('data-direction','');
		$('.ss__sort_dropdown .sort_direction').removeClass('active');
		item.addClass('active');
		item.attr('data-direction',direction);
		item.find('.sort_direction[data-direction="' + direction + '"]').addClass('active');

		// SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_sort_type, type);
		// SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_sort_direction, direction);
		$('#ss__inline_inputs #sort').val( type );
		if (direction!='desc')
			$('#ss__inline_inputs #descending').val('false');
		else
			$('#ss__inline_inputs #descending').val('true');

		SpatialSearch.API.run();
	}

	// ---------------------------------------- //






	// -------------------- RESET methods -------------------- //
	
	// reset subgroup - max/min fields, custom radio buttons
	SpatialSearch.Reset.subgroup = function(subgroup) {
		subgroup.find('.subfields input').val('');
		subgroup.find('.customrb_container div').removeClass('active');
		subgroup.find('.customrb_container div.default').addClass('active');
		$('#ss__inline_inputs #' + subgroup.find('.subfields').data('field')).val('');
		$('#ss__inline_inputs #' + subgroup.find('.customrb_container').data('field')).val( subgroup.find('.customrb_container div.default').data('value') );
	}


	SpatialSearch.Reset.availabilityTransactionType = function() {
		$('.transaction_type .transaction_type_toggle div').removeClass('active');
		$('#ss__inline_inputs #availability_transaction_type').val('');
		$('#ss__inline_inputs #availability_sublease').val('');
		$('#ss__inline_inputs #availability_investment').val('');
		$('.transaction_type').attr('data-used','no');
		SpatialSearch.API.run();
	}


	function resetPropertyType(value_to_remove='') {
		var current_values = SpatialSearch.Data.parametersHeader[3]['fields'][0]['value'];
	}


	SpatialSearch.Reset.propertyType = function(value_to_remove='') {
		var resultString = '';
		if (value_to_remove !== '') {
			value_to_remove = value_to_remove.toLowerCase();
			current_values = SpatialSearch.Data.parametersHeader[3]['fields'][0]['value'];
			const valuesArray = current_values.split(',');
			const filteredArray = valuesArray.filter(value =&gt; value !== value_to_remove);
			resultString = filteredArray.join(',');
		}

		$('#ss__inline_inputs #property_type').val(resultString);
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.availabilityBroker = function() {
		$('#ss__inline_inputs #availability_broker').val('');
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.availabilitySize = function() {
		SpatialSearch.Reset.subgroup($('.property_size .subgroup[data-type="available"]'));
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.landSize = function() {
		SpatialSearch.Reset.subgroup($('.property_size .subgroup[data-type="land"]'));
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.leaseRate = function() {
		SpatialSearch.Reset.subgroup($('.property_price .subgroup[data-type="lease"]'));
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.salesPrice = function() {
		SpatialSearch.Reset.subgroup($('.property_price .subgroup[data-type="sale"]'));
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.advancedFilters_Availability = function() {
		$('.availability_details select option[selected]').each(function() {
			$(this).removeAttr("selected");
		});
		$('.availability_details input').val('');
	}
	
	
	SpatialSearch.Reset.searchKeyword = function() {
		$('#keyword').val('');
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.Msa = function(run=true) {
		$('[name="properties_msa_dynamic_market"] option[selected]').each(function() {
			$(this).removeAttr("selected");
		});
		if (run==true)
			SpatialSearch.API.run();
	}


	SpatialSearch.Reset.County = function(run=true) {
		$('[name="properties_county_dynamic_market"] option[selected]').each(function() {
			$(this).removeAttr("selected");
		});
		if (run==true)
			SpatialSearch.API.run();
	}
	
	
	SpatialSearch.Reset.locationAddress = function(run=true) {
		$('.availability_details select#property_location_city option[selected]').removeAttr("selected");
		$('.availability_details select#property_location_state option[selected]').removeAttr("selected");
		$('#availability_zip_code').val('');
		if (run==true)
			SpatialSearch.API.run();
	}


	SpatialSearch.Reset.chipUseType = function() {
		SpatialSearch.Reset.advancedFilters_UseType();
		SpatialSearch.API.run();
	}


	SpatialSearch.Reset.advancedFilters_UseType = function() {
		$('input#availability_use_type').val('');
		$('.availability_use_type option[selected]').each(function() {
			$(this).removeAttr("selected");
		});
	}


	SpatialSearch.Reset.advancedFilters_Industrial = function() {
		$('.ss__section[data-type="industrial"] input').val('');
		$('.ss__section[data-type="industrial"] [data-used]').attr('data-used','no');
	}


	SpatialSearch.Reset.advancedFilters_Office = function() {
		$('.ss__section[data-type="office"] input').val('');
		$('.property_building_class li').removeClass('active').addClass('active');
		$('#ss__inline_inputs #property_building_class').val('');
		$('.ss__section[data-type="office"] [data-used]').attr('data-used','no');
	}


	SpatialSearch.Reset.advancedFilters_Retail = function() {
		$('.property_shopping_center li').removeClass('active');
		$('.property_shopping_center li.default').addClass('active');
		$('#ss__inline_inputs #property_shopping_center').val('');
	}


	SpatialSearch.Reset.advancedFilters_Multifamily = function() {
		$('.ss__section[data-type="multifamily"] input').val('');
		$('.ss__section[data-type="multifamily"] [data-used]').attr('data-used','no');
	}


	SpatialSearch.Reset.advancedFilters_Hospitality = function() {
		$('.ss__section[data-type="hospitality"] input').val('');
		$('.ss__section[data-type="hospitality"] [data-used]').attr('data-used','no');
	}


	SpatialSearch.Reset.advancedFilters_InvestmentSale = function() {
		$('.ss__section[data-type="investmentsale"] input').val('');
		$('.ss__section[data-type="investmentsale"] [data-used]').attr('data-used','no');
	}


	SpatialSearch.Reset.runMobileHeaderCall = function() {
		SpatialSearch.Data.getValues_Main();
		SpatialSearch.API.prepareDataMain();
		//this.Data.getValues_Filters();
		//this.API.prepareDataFilters();

		SpatialSearch.API.Query = SpatialSearch.API.DataMain;
		//this.API.Query = jQuery.merge(this.API.Query,this.API.DataFilters);
		SpatialSearch.API.Query = SpatialSearch.API.Query.join('&amp;');

		if (jQuery(SpatialSearch.root.selector).hasClass('ss__page_search') &amp;&amp; jQuery('.ss__show_saved').hasClass('active') &amp;&amp; SpatialSearch.Utils.cookieGet(this.Constants.cookie_saved)!==undefined)
			SpatialSearch.API.Query += '&amp;filteredItems=' + SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_saved);

		//console.log(this.API.Query);

		window.location.href = SpatialSearch.System.search_page + '?' + SpatialSearch.API.Query;
	}

	// ---------------------------------------- //






	// -------------------- UI methods -------------------- //

	// get width of SC root element
	// ok for ss__page_header
	SpatialSearch.UI.getWidth = function() {
	    return document.getElementById(SpatialSearch.root.id).offsetWidth;
	}


	// page - header
	// ok for ss__page_header
	SpatialSearch.UI.toggleFieldDropdown = function(obj) {
		var field = obj.closest('.ss__field');
		if (field.hasClass('on')) {
			field.removeClass('on');
		}
		else {
			$('#ss__header .has_dropdown').removeClass('on');
			field.addClass('on');
		}
		SpatialSearch.Utils.triggerScrollEvent();
	}


	// page - search
	// setting height of map element
	SpatialSearch.UI.setMapHeight = function() {
		if (!$('#ss__results_wrapper').hasClass('no-results')) {
			
			var map_height = $(window).height() 
			- ($('#ss__header').outerHeight() || 0)
			- ($('#ss__chips_bar').outerHeight() || 0)
			- ($('#ss__titlebar_results').outerHeight() || 0);
			
			$('#ss__results_wrapper').height(map_height).attr('data-height',map_height);
			$('#ss__results_map').height(map_height).attr('data-height',map_height);
			
			var checkInterval = setInterval(function() {
				if (SpatialSearch.Search.map.obj &amp;&amp;  typeof SpatialSearch.Search.map.obj.resize === 'function') {
					SpatialSearch.Search.map.obj.resize();
					clearInterval(checkInterval);
				}
			}, 200);
		}
	}


	// page - search
	// manage results viewmode
	SpatialSearch.UI.manageResultsViewMode = function() {
		if ($(SpatialSearch.root.selector).hasClass('ss__page_search')) {
			if (SpatialSearch.UI.getWidth() &gt; SpatialSearch.Constants.map_split_breakpoint) {
				$(SpatialSearch.root.selector).attr('data-viewmode','');
				if (!$('#ss__switch_view a').hasClass('ss__toggle'))
					$('#ss__switch_view a').addClass('ss__toggle');
				$('.ss__sort_trigger').removeClass('disabled');
			}
			else {
				if ($(SpatialSearch.root.selector).data('viewmode')=='') {
					$(SpatialSearch.root.selector).attr('data-viewmode','list');
				}
				else if ($(SpatialSearch.root.selector).data('viewmode')=='map') {
					$('#ss__switch_view a').text('Show List');
					$('.ss__sort_trigger').addClass('disabled');
				}
				$('#ss__switch_view a').removeClass('ss__toggle');
			}
		}
	}


	// page - search
	// used for some buggy behavior
	SpatialSearch.UI.resultsFixMapSize = function(delaytime=400) {
		setTimeout(function() {
			SpatialSearch.Search.map.obj.resize();
		}, delaytime);
	}


	// page - property
	// set social links actions
	SpatialSearch.UI.setSocialActions = function() {
		var metaTitle = SpatialSearch.Property.metaTitle;
		var metaDescription = SpatialSearch.Property.metaDescription;
		var encodedUrl = encodeURIComponent(window.location.href);

		var linkedinLink = document.querySelector('#social_linkedin');
		var facebookLink = document.querySelector('#social_facebook');
		var twitterLink = document.querySelector('#social_twitter');
		var emailLink = document.querySelector('#social_email');

		linkedinLink.setAttribute('href', 'http://www.linkedin.com/shareArticle?mini=true&amp;url=' + encodedUrl + '&amp;title=' + encodeURIComponent(metaTitle));
		facebookLink.setAttribute('href', 'https://www.facebook.com/sharer/sharer.php?u=' + encodedUrl);
		twitterLink.setAttribute('href', 'http://twitter.com/intent/tweet?text=' + encodedUrl);

		// Attach onclick event to #social_email
		emailLink.addEventListener('click', function(e) {
			e.preventDefault(); // This will prevent the default behavior of the click
			window.open('mailto:?subject=' + decodeURIComponent(metaTitle).replace('&amp;amp;', '%26') + '&amp;body=' + decodeURIComponent(metaDescription).replace('&amp;amp;', '%26') + ' ........ ' + encodedUrl, '_blank');
		});
	}


	// page - property
	SpatialSearch.UI.setBackButton = function() {
		var backElements = document.querySelectorAll('.ss__p_back');

		// Function to handle click event
		var handleClick = function(event) {
			if (this.classList.contains('disabled')) {
				// Prevent default behavior if element has 'disabled' class
				event.preventDefault();
			}
		};

		// Function to check if the referrer is from the same domain
		var isSameDomain = function(referrer) {
			var referrerDomain = new URL(referrer).hostname;
			var currentDomain = window.location.hostname;
			return referrerDomain === currentDomain;
		};

		// Add event listeners and update classes and hrefs based on document.referrer
		backElements.forEach(function(element) {
			element.addEventListener('click', handleClick);

			if (document.referrer === '' || !isSameDomain(document.referrer)) {
				element.classList.add('disabled');
			} else {
				element.classList.remove('disabled');
				element.setAttribute('href', document.referrer);
			}
		});
	}


	// page - property
	// resize fotorama elements
	// SpatialSearch.UI.resizePropertyFotoramas = function() {
	// 	return;
		// SpatialSearch.Property.fotoramas.forEach(function(item) {
		// 	if (SpatialSearch.UI.getWidth() &lt; 600) {
		// 		item.resize({
		// 			minheight: 350,
		// 			maxheight: 350
		// 		});
		// 	}
		// 	else if (SpatialSearch.UI.getWidth() &lt; 500) {
		// 		item.resize({
		// 			minheight: 300,
		// 			maxheight: 300
		// 		});
		// 	}
		// 	else {
		// 		item.resize({
		// 			minheight: 400,
		// 			maxheight: 700
		// 		});
		// 	}
		// });
	// }


	SpatialSearch.UI.SearchTitlebarAlignment = function() {
		var container = $('#ss__titlebar_results .ss__container');
		var title = $('#ss__titlebar_results h1');
		var actions = $('#ss__results-actions');

		if ( (title.outerWidth() + actions.outerWidth()) &gt; container.innerWidth() ) {
			// console.log('center');
			container.addClass('ss__aligncenter');
		}
		else {
			// console.log('normal');
			container.removeClass('ss__aligncenter');
		}
	}

	// ---------------------------------------- //






	// ------------------------------------------------------------ //
	// --------------------------- DATA --------------------------- //
	// ------------------------------------------------------------ //

	// SAVE PROPERTY
	$(SpatialSearch.root.selector).on('click', '.save_property', function() {
		event.preventDefault();
		event.stopPropagation();
		var saved = SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_saved);

		if (!$(this).hasClass('saved')) {
			if (saved===undefined) {
				SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_saved, $(this).data('property-id'));
			}
			else {
				saved = saved.split(',');
				if ( saved.indexOf(String($(this).data('property-id'))) == -1 )
					SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_saved, saved.join(',') + ',' + String($(this).data('property-id')));
			}
			$(this).addClass('saved');
		}
		else {
			if (saved!==undefined) {
				saved = saved.split(',');
				const index = saved.indexOf(String($(this).data('property-id')));
				if (index &gt; -1)
					saved.splice(index, 1);
				saved = saved.join(',');
				if (saved.length==0)
					SpatialSearch.Utils.cookieDelete(SpatialSearch.Constants.cookie_saved);
				else
					SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_saved, saved);
			}
			$(this).removeClass('saved');
		}

		if (SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_saved)===undefined)
			$('.ss__show_saved').addClass('disabled');
		else
			$('.ss__show_saved').removeClass('disabled');
	});


	// display saved properties
	$('.ss__show_saved a').click(function(event){
		event.preventDefault();
		if ( !$(this).parents('li').hasClass('disabled')) {
			if ( !$(this).parents('li').hasClass('active') ) { //  &amp;&amp; SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_country)!=undefined
				window.location.href = SpatialSearch.System.search_page + '?' + SpatialSearch.API.prepareQuery() + '&amp;filteredItems=' + SpatialSearch.Utils.cookieGet(SpatialSearch.Constants.cookie_saved);
			}
			else {
				$(this).parents('li').removeClass('active');
				SpatialSearch.API.run();
			}
		}
	});


	// custom radio buttons click
	$('.customrb_container div').click(function(){
		$('#ss__inline_inputs #' + $(this).parents('[data-field]').data('field')).val( $(this).data('value') );
		$(this).parents('.customrb_container').find('div').removeClass('active');
		$(this).addClass('active');
	});
	// ------------------------




	// HEADER: TRANSACTION TYPE
	// selecting transaction type and subtype, and storing selection to inputs
	$('.transaction_type_toggle div').click(function(){
		$('.transaction_type').attr('data-used','yes');

		if ( !$(this).hasClass('active') ) {
			$(this).parents('.transaction_type_toggle').find('div').removeClass('active');
			$(this).addClass('active');
			$('#ss__inline_inputs #' + $(this).parents('.transaction_type_toggle').data('field')).val( $(this).data('value') ).trigger('change');
			var subtype = $(this).data('subtype');

			// setting subtype blocks visibility and managing inputs data
			if (subtype!=undefined) {
				SpatialSearch.Data.UI.showTransactionTypeSubType(subtype);
			}
		}
	});
	// ------------------------




	// HEADER: PROPERTY TYPE
	// select property type
	$('#ss__header .ss__field.property_type label').click(function(){
		event.stopPropagation();
		var result = Array();
		$('.' + $(this).parents('.ss__field').data('field') + ' input[type="checkbox"]').each(function(){
			if ($(this)[0].checked)
				result[result.length] = $(this).attr('value');
		});
		$('#ss__inline_inputs #' + $(this).parents('.ss__field').data('field')).val(result.join(',')).trigger('change');
		if (result.length&gt;0)
			$('.ss__field.property_type').attr('data-used','yes');
		else
			$('.ss__field.property_type').attr('data-used','no');
	});
	// ------------------------




	// HEADER: AGENTS
	// set height
	$('#ss__header .ss__field.availability_broker').click(function(){
		var viewportHeight = $(window).height();
		var bodyHeight = $('body').height();
		var documentHeight = $(document).height();
		var availableHeight = Math.min(viewportHeight, bodyHeight);
		
		var elementTop = $(this).offset().top;
		var scrollTop = $(window).scrollTop();
		var substract = 100;
		
		
		var brokers_dropdown_height = availableHeight - (elementTop - scrollTop) - substract;

		$('#availability_broker_select').css('max-height', brokers_dropdown_height + 'px');
	});

	// select agent
	$('#availability_broker_select li').click(function(){
		var selectedValue = $(this).attr('value');
		$('#ss__inline_inputs #' + $(this).parents('.ss__field').data('field')).val(selectedValue);
		$('#availability_broker_select li').removeAttr('selected');
		$(this).attr('selected', '');
		$(this).closest('.ss__field').attr('data-used', 'yes');
	});
	// ------------------------




	// HEADER: COUNTRY
	// select country
	$('#ss__header .ss__field#country_dropdown li').click(function(){
		// SpatialSearch.Utils.cookieSet(SpatialSearch.Constants.cookie_country, $(this).data('value'));
		$('#ss__inline_inputs #country').val($(this).data('value'));
		$('#ss__inline_inputs #keyword').val('');
		$('#ss__header').attr('cc',$(this).data('value'));
		SpatialSearch.API.run();
	});
	// ------------------------




	// ADVANCED FILTERS
	$('.property_building_class li').click(function(event){
		$(this).toggleClass('active');
		var data = [];
		$('.property_building_class li').each(function(key,item) {
			if ($(this).hasClass('active'))
				data[data.length] = $(this).data('value');
		});
		$('#ss__inline_inputs #property_building_class').val(data.join(','));
	});

	$('.property_shopping_center li').click(function(event){
		$('.property_shopping_center li').removeClass('active');
		$(this).addClass('active');
		$('#ss__inline_inputs #property_shopping_center').val($(this).data('value'));
	});
	// ------------------------




	// ADVANCED FILTERS: USE TYPE
	$('.availability_use_type').change(function(event){
		var selectedValue = $(this).val();
		$('#availability_use_type').val(selectedValue);
		dump(selectedValue);
	});
	// ------------------------




	// RESULTS: SORTING
	// select sorting type and direction
	$('.ss__sort_dropdown li').click(function(event){
		var target = $(event.target);
		var item;
		if (target.hasClass('item'))
			item = target;
		else
			item = target.parents('.ss__item');

		var sort_value = item.data('value');
		var sort_direction = '';

		if (target.hasClass('sort_direction')) {
			if (target.hasClass('active'))
				return;
			else
				sort_direction = target.data('direction');
		}
		else {
			if (item.hasClass('active')) {
				if (item.attr('data-direction')=='asc')
					sort_direction = 'desc';
				else
					sort_direction = 'asc';
			}
			else {
				sort_direction = SpatialSearch.System.default_sort_direction;
			}
		}
		SpatialSearch.Data.UI.executeSortOptions(item,sort_value,sort_direction);
	});
	// ------------------------




	// HEADER - APPLY and RESET actions

	$('.transaction_type button.reset').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes')
			SpatialSearch.Reset.availabilityTransactionType();
	});

	$('.property_type button.reset').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes')
			SpatialSearch.Reset.propertyType();
	});

	$('.property_size button.reset').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes') {
			$('.property_size').attr('data-used','no');
			SpatialSearch.Reset.availabilitySize();
			SpatialSearch.Reset.landSize();
		}
	});

	$('.property_price button.reset').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes') {
			$('.property_price').attr('data-used','no');
			SpatialSearch.Reset.leaseRate();
			SpatialSearch.Reset.salesPrice();
		}
	});

	$('.availability_broker button.reset').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes')
			SpatialSearch.Reset.availabilityBroker();
	});


	// click on header apply button
	$('#ss__header .ss__field button.apply').click(function(){
		if ($(this).parents('.ss__field').data('used')=='yes')
			SpatialSearch.API.run();
	});

	// click on header mobile apply button
	$('#ss__buttons_mobile button.apply').click(function(){
		SpatialSearch.API.run();
	});


	// click on apply in filters panel
	$('#ss__advanced_filters button.apply').click(function(){
		SpatialSearch.API.run();
	});


	$('#ss__advanced_filters button.reset').click(function(){
		SpatialSearch.Reset.advancedFilters_Availability();
		SpatialSearch.Reset.advancedFilters_Industrial();
		SpatialSearch.Reset.advancedFilters_Office();
		SpatialSearch.Reset.advancedFilters_Retail();
		SpatialSearch.Reset.advancedFilters_Multifamily();
		SpatialSearch.Reset.advancedFilters_Hospitality();
		SpatialSearch.Reset.advancedFilters_InvestmentSale();
		SpatialSearch.Reset.advancedFilters_UseType();
		SpatialSearch.API.run();
	});


	// reset header parameters on mobiles
	$('#ss__buttons_mobile button.reset').click(function(){
		SpatialSearch.Reset.runMobileHeaderCall();
	});


	// home page link to search page, because of seo
	$('#hp_search_link').click(function(){
		event.preventDefault();
		SpatialSearch.Reset.runMobileHeaderCall();
	});


	$('#ss__chips_bar').on('click', 'a.ss__item i', function(){
		event.stopPropagation();
		event.preventDefault();
		var field = $(this).parents('a').attr('field');

		if (field=='availability_transaction_type')
			SpatialSearch.Reset.availabilityTransactionType();
		else if (field=='property_type')
			SpatialSearch.Reset.propertyType( $(this).parents('a').attr('value') );
		else if (field=='availability_size')
			SpatialSearch.Reset.availabilitySize();
		else if (field=='availability_land_size')
			SpatialSearch.Reset.landSize();
		else if (field=='availability_lease_rate')
			SpatialSearch.Reset.leaseRate();
		else if (field=='availability_sales_price')
			SpatialSearch.Reset.salesPrice();
		else if (field=='address')
			SpatialSearch.Reset.locationAddress();
		else if (field=='properties_msa_dynamic_market[]')
			SpatialSearch.Reset.Msa();
		else if (field=='keyword')
			SpatialSearch.Reset.searchKeyword();
		else if (field=='properties_county_dynamic_market[]')
			SpatialSearch.Reset.County();
		else if (field=='availability_use_type')
			SpatialSearch.Reset.chipUseType();
		else if (field=='availability_broker')
			SpatialSearch.Reset.availabilityBroker();
	});


	// ------------------------------------------------------------ //
	// ------------------------------------------------------------ //






	// ------------------------------------------------------------ //
	// ---------------------------- UI ---------------------------- //
	// ------------------------------------------------------------ //

	// page - search ???? height
	// show hide filters
	$(SpatialSearch.root.selector).on('click', '#ss__advanced_filters_toggle_button', function() {
		// event.preventDefault();

		var wrapper_height = $('#ss__results_wrapper').data('height');
		var filters_height = $('#ss__advanced_filters .ss__container').outerHeight();
		const advancedFilters = $('#ss__advanced_filters');

		// "desktop" layout
		if (SpatialSearch.UI.getWidth() &gt; SpatialSearch.Constants.header_mobile_breakpoint) {
			if ($(this).hasClass('on')) {
				wrapper_height += filters_height;
				filters_height = 0;
				$(this).removeClass('on');

				advancedFilters.animate({height: 0},SpatialSearch.Constants.filters_animation_speed).removeClass('ss__expanded');
			}
			else {
				$(this).addClass('on');
				wrapper_height -= filters_height;
				$('#ss__burger').removeClass('on');
				$('#ss__fields-left').removeClass('on');
				advancedFilters.animate({height: filters_height},SpatialSearch.Constants.filters_animation_speed).addClass('ss__expanded');
			}


			$('#ss__results_wrapper').animate({height: wrapper_height},SpatialSearch.Constants.filters_animation_speed).attr('data-height',wrapper_height);
			$('#ss__results_map').height(wrapper_height).attr('data-height',wrapper_height);
			if ($('#ss__results_wrapper').hasClass('show_map'))
				SpatialSearch.UI.resultsFixMapSize(500);
		}

		// mobile layout
		else {
			if ($(this).hasClass('on')) {
				$(this).removeClass('on');
				$('#ss__fields-left').removeClass('on');
				advancedFilters.animate({height: 0},SpatialSearch.Constants.filters_animation_speed).removeClass('ss__expanded');
			}
			else {
				$(this).addClass('on');
				$('#ss__fields-left').addClass('on');
				$('html, body').animate({
					scrollTop: $('#ss__advanced_filters_toggle_button').offset().top
				}, 200);
			}
		}

		SpatialSearch.Utils.triggerScrollEvent();
	});


	// page - search
	// show hide map
	$('#ss__switch_view a').click(function(){
		event.preventDefault();
		const easing = 'linear';

		if ( SpatialSearch.UI.getWidth() &gt; SpatialSearch.Constants.map_split_breakpoint ) {
			if ($(this).hasClass('on')) {
				$('#ss__results_main').animate({width: '100%'},SpatialSearch.Constants.map_animation_speed,easing);
				$('#ss__results_map').hide().css('width', '0%');
				setTimeout(function() {
					$('#ss__results_wrapper').removeClass('show_map').addClass('no_map');
				}, 100);
				$(this).removeClass('on');
			}
			else {
				$('#ss__results_main').animate({width: '50%'},SpatialSearch.Constants.map_animation_speed,easing);
				$('#ss__results_map').animate({width: '50%'},SpatialSearch.Constants.map_animation_speed,easing,SpatialSearch.UI.resultsFixMapSize());
				setTimeout(function() {
					$('#ss__results_map').show();
				}, 200);
				setTimeout(function() {
					$('#ss__results_wrapper').addClass('show_map').removeClass('no_map');
				}, 300);
				$(this).addClass('on');
				$('html, body').animate({
					scrollTop: $('#ss__header').offset().top
				}, 500);
			}
		}
		else {
			if ($(SpatialSearch.root.selector).data('viewmode')=='map')
				$('#view_mode').val('list');
			else
				$('#view_mode').val('map');

			SpatialSearch.API.run();
		}
	});


	// page - search
	// switching mode of map
	$('#map_view_modes a[data-map-mode]').click(function(){
		event.preventDefault();
		SpatialSearch.Search.map.render($(this).data('map-mode'),true);
	});


	// page - search
	// click on "contacts" action at results item
	$(SpatialSearch.root.selector).on('click', '.pbox .brokers', function() {
		if (SpatialSearch.UI.getWidth()&lt;SpatialSearch.Constants.map_split_breakpoint) {
			event.preventDefault();
			event.stopPropagation();
			window.location.href = $(this).parents('.pbox').attr('href') + '#ss__brokers_scroll';
		}
	});
	
	
	
	
	// page - search
	// click on sort trigger, show-hide dropdown
	$('.ss__sort_trigger').click(function(){
		event.preventDefault();
		if (!$('.ss__sort_trigger').hasClass('disabled')) {
			if ($('.ss__sort_trigger').hasClass('on')) {
				$('.ss__sort_trigger').removeClass('on');
			}
			else {
				$('.ss__sort_trigger').addClass('on');
			}
		}
	});


	// page - search
	// click outside of sort dropdown, hide dropdown
	$(document).click(function (event) {
		if ($(".ss__sort_trigger").hasClass("on") &amp;&amp; $(event.target).parents('.ss__sort_trigger').length==0) {
			$('.ss__sort_trigger').removeClass('on');
		}
	});


	// page - search header
	// click on mobile advanced button
	$('#ss__buttons_mobile button.advanced').click(function() {
		setTimeout(function() { toggleFilters(); }, 200);
	});


	function toggleFilters() {
		if ($(SpatialSearch.root.selector).hasClass('sticky_header')) {
			const header = $('#ss__header');
			const advancedFilters = $('#ss__advanced_filters');
			advancedFilters.css('top', (header.outerHeight() - 4) + 'px');
		}

		const advancedFilters = $('#ss__advanced_filters');
		const filtersContainer = $('#ss__advanced_filters .ss__container');
		const header = $('#ss__header');
		const headerOffsetTop = header[0].getBoundingClientRect().top;

		if (headerOffsetTop &gt; 0) {
			// Scroll the page to the top of the header without animation
			window.scrollTo(0, window.scrollY + headerOffsetTop);
			SpatialSearch.UI.stickyHeader_set();
		}

		if (advancedFilters.hasClass('ss__expanded')) {
			// Collapse the filters
			advancedFilters
				.animate(
					{ height: 0 },
					SpatialSearch.Constants.filters_animation_speed,
					function() {
						$(this)
							.css('overflow', '')
							.removeClass('ss__expanded');
					}
				);
		}
		else {
			// Expand the filters
			const filtersHeight = filtersContainer.outerHeight();
			const elementOffsetTop = advancedFilters[0].getBoundingClientRect().top;
			const availableHeight = $(window).height() - elementOffsetTop;
			const newHeight = (filtersHeight &gt; availableHeight) ? availableHeight : filtersHeight;

			advancedFilters
				.css('overflow', 'auto')
				.animate({ height: newHeight }, SpatialSearch.Constants.filters_animation_speed)
				.addClass('ss__expanded');
		}
	}



	// page - header
	// click on header field which has dropdown
	// using .field_label * selector because country dropdown
	$('#ss__header .has_dropdown').on('click', '.field_label, .field_label *', function(e) {
		e.stopPropagation();
		e.preventDefault();
		// Find the nearest .field_label ancestor of the clicked element
		var fieldLabel = $(e.target).closest('.field_label');
		SpatialSearch.UI.toggleFieldDropdown(fieldLabel);
	});


	// page - header
	// click outside of header field, hide dropdown
	$(document).click(function (event) {
		var target = $(event.target);
		if ($(".ss__field").hasClass("on") === true &amp;&amp; !target.hasClass("ss__field") &amp;&amp; !target.hasClass("field_label") &amp;&amp; !target.hasClass("ss__dropdown") &amp;&amp; target.parents('.ss__dropdown').length==0) {
			$('#ss__header .has_dropdown').removeClass('on');
		}
	});


	// page - header
	// set field or filter to data-used=yes if any of its fields are used
	// to do selects
	$('input.set_parent_dataused').change(function(){
		if ($(this).val()!='') {
			$(this).parents('.ss__field').attr('data-used','yes');
			$(this).parents('.filter').attr('data-used','yes');
			$(this).attr('data-used','yes');
		}
		else {
			var value = 'no';
			$(this).parents('.ss__field').find('input').each(function() {
				if ($(this).val()!='') {
					value = 'yes';
				}
			});
			$(this).parents('.filter').find('input').each(function() {
				if ($(this).val()!='') {
					value = 'yes';
				}
			});
			$(this).parents('.ss__field').attr('data-used',value);
			$(this).parents('.filter').attr('data-used',value);
		}
	});








	// page - property
	// collapsible ss__databox
	$('.ss__databox.collapsible').click(function(){
		var box = $(this).closest('.ss__databox');
		if (box.hasClass('ss__expanded')) {
			box.find('.ss__content').animate({height: 0},100);
			box.removeClass('ss__expanded');
		}
		else {
			box.find('.ss__content').animate({height: box.find('.ss__content .ss__inner').outerHeight()},100);
			box.addClass('ss__expanded');
		}
	});


	// page - property
	// toggle map
	$('#ss__property_show_map').click(function(){
		event.preventDefault();
		if ($(this).hasClass('on')) {
			$(this).removeClass('on');
			$('#ss__property_map_wrapper').addClass('bottom');
			$('.ss_property_buttons a[data-container="' + $('#ss__property_wrapper .ss__media').attr('data-active') + '"]').addClass('active');
			$('#' + $('#ss__property_wrapper .ss__media').attr('data-active')).removeClass('bottom');

		}
		else {
			$(this).addClass('on');
			$('.ss__fotorama_top_container').addClass('bottom');
			$('.ss_property_buttons a').removeClass('active');
			$('#ss__property_map_wrapper').removeClass('bottom');
		}
	});


	// page - property
	// click on any of buttons below the gallery
	$('#ss__property_wrapper .ss_property_buttons a').click(function(){
		event.preventDefault();
		if ($('#ss__property_show_map').hasClass('on')) {
			$('#ss__property_show_map').removeClass('on');
			$('#ss__property_map_wrapper').addClass('bottom');
		}
		$('#ss__property_wrapper .ss_property_buttons a').removeClass('active');
		$('.ss__fotorama_top_container').addClass('bottom');
		$(this).addClass('active');
		$('#' + $(this).attr('data-container')).removeClass('bottom');
		$('#ss__property_wrapper .ss__media').attr('data-active',$(this).data('container'));
	});


	// page - property
	// click on .active button in ss_property_actions section
	$('#ss__property_wrapper a.active').click(function(){
		event.preventDefault();
	});


	// page - property
	// disable button for pricing request form on first click
	$('#ss__requestpricing_submit').click(function(){
		$(this).attr('disabled','');
		$('#ss__requestpricing_form').submit();
	});
	// ---------------------------------------- //






	// -------------------- TEAM methods -------------------- //
	SpatialSearch.Team.initTeamFilters = function() {
		// Adding event listener for change on all select elements within .ss__cnt
		document.querySelectorAll('#ss__team_filters select').forEach(function(select) {
			select.addEventListener('change', SpatialSearch.Team.runSearch);
		});

		// Adding keypress event to check for the Enter key in #keyword input
		const keywordInput = document.getElementById('keyword');
		keywordInput.addEventListener('keypress', function(event) {
			if (event.key === 'Enter' &amp;&amp; this.value.length &gt; 3) {
				SpatialSearch.Team.runSearch();
			}
		});

		// Adding click event listener to ".ss__search i"
		const searchIcon = document.querySelector('.ss__search i');
		searchIcon.addEventListener('click', function() {
			if (keywordInput.value.length &gt; 2) {
				SpatialSearch.Team.runSearch();
			}
		});


		var resetLink = document.querySelector('#ss__team_filters_reset a');

		// Add a click event listener to the link
		resetLink.addEventListener('click', function(event) {
			event.preventDefault(); // Prevent the default link behavior
			// Redirect the browser to the URL from SpatialSearch.System.team_page
			window.location.href = SpatialSearch.System.team_page;
		});
	}


	SpatialSearch.Team.runSearch = function() {
		const params = new URLSearchParams();
		// Collect all select elements' values if they have a value
		document.querySelectorAll('#ss__team_filters select').forEach(function(select) {
			const value = select.value;
			if (value &amp;&amp; value !== 'all') {
				// The ID might need cleanup to be used as a URL parameter
				const cleanedId = select.id.replace('[]', '');
				params.append(cleanedId, value);
			}
		});

		// Check keyword input and add to parameters if it has more than 4 characters
		const keywordValue = document.getElementById('keyword').value;
		if (keywordValue.length &gt; 2) {
			params.append('keyword', keywordValue);
		}

		var parameters = params.toString();
		var cleaned_query = SpatialSearch.Team.getCleanQuery();
		var final_query = '';

		if (cleaned_query.length&gt;0) {
			if (parameters.length&gt;0)
				final_query = '?' + parameters + '&amp;' + cleaned_query;
			else
				final_query = '?' + cleaned_query;
		}
		else {
			if (parameters.length&gt;0)
				final_query = '?' + parameters;
		}

		// console.log(parameters);
		window.location.href = SpatialSearch.System.team_page + final_query;
	}


	SpatialSearch.Team.initSortClick = function() {
		// Select the container that holds the spans
		var sortingSpans = document.querySelectorAll('#ss__team_results_sorting span');

		// Attach click event listeners to each span
		sortingSpans.forEach(function(span) {
			span.addEventListener('click', function() {
				SpatialSearch.Team.handleSortClick(this);
			});
		});
	}


	SpatialSearch.Team.handleSortClick = function(span) {
		// Create a new URL object from the current location
		const url = new URL(window.location.href);

		// Get current search parameters
		const params = new URLSearchParams(url.search);

		// Remove 'pageOffset' parameter if it exists
		params.delete('pageOffset');

		// Check if 'sort' parameter is present
		if (!params.has('sort')) {
			// Add 'sort' parameter with value from span's 'type' attribute
			params.set('sort', span.getAttribute('type'));
		}
		else {
			// Update 'sort' parameter to new value from span's 'type' attribute
			params.set('sort', span.getAttribute('type'));
		}

		params.delete('descending');

		if (span.hasAttribute('active')) {
			if (span.hasAttribute('descending')) {
				params.delete('descending');
			}
			else {
				params.set('descending', 'true');
			}
		}

		url.search = params.toString();

		// console.log(url.href); // Logging the updated URL for verification
		window.location.href = url.href;
	}




	SpatialSearch.Team.getCleanQuery = function() {
		/// Get the current URL
		const url = new URL(window.location.href);

		// Create an instance of URLSearchParams from the URL's search property
		const params = new URLSearchParams(url.search);

		// Select all elements within #ss__team_filters that have a 'parameter' attribute
		const filterElements = document.querySelectorAll('#ss__team_filters [parameter]');

		// Collect all parameter names to remove from the query
		const paramsToRemove = Array.from(filterElements).map(el =&gt; el.getAttribute('parameter'));

		// Remove each specified parameter from URLSearchParams
		paramsToRemove.forEach(param =&gt; {
			params.delete(param);
		});

		// Convert URLSearchParams to string without the leading '?'
		let cleanQuery = params.toString();

		// Update the URL search property with the modified URLSearchParams
		url.search = cleanQuery;

		// Check if the query is empty to avoid returning a lone '?'
		return cleanQuery ? cleanQuery : "";
	}




	// team filters - search field
	if ($('#ss__team_filters #keyword').length) {
		// $('#ss__team_filters #keyword').on('input', function() {
		// 	var $searchWrapper = $(this).closest('.ss__search');
		// 	if ($(this).val().trim() !== '') {
		// 		$searchWrapper.addClass('used');
		// 	} else {
		// 		$searchWrapper.removeClass('used');
		// 	}
		// });
		// // Event listener for the clear icon
		// $('.ss__search i').click(function() {
		// 	var $inputField = $(this).siblings('input');
		// 	$inputField.val('');
		// 	$inputField.trigger('input');
		// });
	}
	// ---------------------------------------- //


});
})(jQuery);




</pre></body></html>