PageSourceSearch

https://edrater.com/wp-content/themes/listar/assets/js/frontend.js?ver=1.5.4.91

js edrater.com collected 2026-09-28 13:38:04 UTC 650,027 bytes, 17,277 lines download raw bytes

1/**
2 Theme Name:         Listar
3 Theme URI:          http://listar.directory/
4 Author:             Web Design Trade
5 Author URI:         https://themeforest.net/user/webdesigntrade
6 File Description:   Main JavaScript for the theme (front end)
7
8 @package Listar
9 */
10
11/* Hide following variables from JSHint because they are globally declared earlier by other scripts */
12
13/* global AOS, listarMinMapZoomLevel, listarMaxMapZoomLevel, listarInitialArchiveMapZoomLevel, listarInitialSingleMapZoomLevel, listarThemeURL, L, listarLocalizeAndAjax, listarAjaxPostsParams, listarMapMarkers, listarSiteCountryCode, jQuery, vhCheck, ifvisible, wpMyInstagramVars, listarSiteURL, opr, safari, InstallTrigger, MSStream, tinyMCE */
14
15/* jshint esversion: 6 */
16/* jshint bitwise: false */
17/* jshint -W018 */
18/* jshint sub:true */
19
20var linereport = '';
21/* Set '$' (from jQuery) to its existing value (if present) */
22
23var usingPagespeed = 'yes' === listarLocalizeAndAjax.listarUsingPagespeed;
24
25window.$ = window.$ || {};
26
27( function ( $ ) {
28	
29	/* VH Check for CSS */	
30
31	var vhCheckAttempties = 0
32
33	setTimeout( function () {
34		vhCheck();
35	}, 150 );
36
37	var vhCheckInterval = setInterval( function () {
38		vhCheck();
39		vhCheckAttempties++
40
41		if ( vhCheckAttempties > 8 ) {
42			clearInterval( vhCheckInterval );
43		}
44	}, 500 );
45
46	/* Global variables for this scope ************************** */
47
48	var
49		theDocument,
50		theBody,
51		theHTML,
52		htmlInner,
53		htmlAndBody,
54		headMenu,
55		nothing,
56		hasGrid2,
57		hasGrid3,
58		toggler,
59		pageWrapper,
60		navigationWrapper,
61		menuWidth,
62		menuNegativeWidth,
63		selected,
64		elemToTest,
65		elemPosition,
66		forceTermClick = false,
67		headerPosition,
68		diffHeaderPosition,
69		priceRange,
70		priceRangeValue,
71		retryInstagram = false,
72		priceAverage,
73		hasUpdatedHoursTable = false,
74		catScrollQtd,
75		catCondition2,
76		isStandardPackage = false,
77		isClaimingListing = false,
78		launchedReviewPopup = false,
79		cancelAccordionPropagation = false,
80		isNearestMeReload = false,
81		nearestHash = '',
82		hyphenPos = '',
83		sanitizedLat = '',
84		sanitizedLng = '',
85		geolocationAttempties = 3,
86		userGeolocated = false,
87		avoidSearchScroll = false,
88		myScaleFunction,
89		markerCounterAfterLoad,
90		dataMinimumClaimTextChars,
91		requiredClaimCharsField,
92		multipleRegionsActive,
93		urlProtocol,
94		currentClaimPackageID = 0,
95		hasExecutedOnLoadAndVisible = false,
96		preventEvenCallStack2  = false,
97		preventEvenCallStack3  = false,
98		preventEvenCallStack4  = false,
99		preventEvenCallStack5  = false,
100		preventEvenCallStack6  = false,
101		preventEvenCallStack7  = false,
102		preventEvenCallStack10 = false,
103		preventEvenCallStack11 = false,
104		isLoadMoreEqualizer    = false,
105		disableRegionSelector  = false,
106		disableHeightEqualizerListingCards = true,
107		closeUserMenu,
108		siblingsOpacityEnabled,
109		breakClickLoop,
110		tempModify = false,
111		tempModify2 = false,
112		isBrowsingSearchMenu = false,
113		preventReclick = false,
114		loadingClick   = false,
115		dlTags = [],
116		dtTags = [],
117		skipEmbedDlOptimization = false,
118		skipEmbedDtOptimization = false,
119		isLastBlogPage = false,
120		hoveringGalleryTimeout = 0,
121		hasGalleryMouseleave = false,
122		cancelListingCardCircleEvents = true,
123		quantifyCounter = 1,
124		viewportHeight = 0,
125		didInitialAccordionClick = false,
126		thisElement,
127		customListarStyle = false,
128		mobileCompensation,
129		scrollToTarget,
130		callToActionsBoxedSquared,
131		animatingMask = false,
132		headerTransparentTopbar,
133		hasBackgroundImages = true,
134		onMap,
135		osmUrl,
136		osmAttrib,
137		osm,
138		lat,
139		lng,
140		map,
141		markers,
142		geocoder,
143		divMarker,
144		listingItem,
145		bounds = [],
146		popupToggling,
147		idArray,
148		markersList,
149                minimumZoom = 3,
150                maximumZoom = 20,
151                initialMapZoomArchive = 0,
152                initialMapZoomSingle = 0,
153                initialMapZoom = 0,
154                hasCustomInitialMapZoom = false,
155		lastListingID,
156		clusteredMarkers,
157		mapStarted,
158		preventDoubleClick,
159		lastDragPosition = 0,
160		dragging,
161		data,
162		lastScrollPosition = 0,
163		saveScrollPosition = true,
164		gotUpdatedNonce = false,
165		listingGallery,
166		listingGalleryItems = nothing,
167		listingGalleryLinks = nothing,
168		listingGalleryInitialBackup = false,
169		currentListingGallerySlide = 0,
170		maxListingGallerySlides = 0,
171		slideWidth = 0,
172		centralizeMainSlide = 0,
173		currentURL = window.location.href,
174		isFrontPage,
175		pageBGColor,
176		lastViewportWidth = false,
177		scrollbarWidth = false,
178		searchByInputToFocus = false,
179		originalCanvasImage,
180		appending,
181		singleContent,
182		singleheaderBackgroundWrapper,
183		readyForHoverTimeout = setTimeout( false, 0 ),
184		imageCanvas,
185		imageCanvasContext,
186		lineCanvas,
187		lineCanvasContext,
188		pointLifetime,
189		listarFeaturifyElements,
190		frontPageCallToActionBadge,
191		customGutenbergClasses = '',
192		animateElementsOnScroll,
193		points = [],
194		pageBGColor,
195		isClaimingListing,
196		specialHashes = [
197			'mapview',
198			'gc',
199			'do-login',
200			'comment-',
201			'comments',
202			'more-',
203			'login',
204			'collapse'
205		];
206
207	/* Global variables for Operating Hours ***********************/
208
209	var
210		currentDay,
211		currentDayLetter,
212		currentDayAbbr,
213		selectedOpenHour,
214		selectedCloseHour,
215		currentRealOpenHour,
216		currentRealCloseHour,
217		selectedOpenAttr,
218		selectedCloseAttr,
219		currentHour,
220		isRestartingMap = false,
221		hourFormatFront,
222		hourOpenPlaceholder,
223		hourClosePlaceholder,
224		hasMultiPleHoursPerDay = false;
225
226	/* Functions **************************************************/
227
228	function startMapLeaflet() {
229
230		onMap = 0;
231
232		/* Prepare interface (maps) ***********************************/
233		var mapboxToken = '';
234
235		osmUrl = '';
236		osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a>';
237		lat = 50.5;
238		lng = 30.51;
239		markers = {};
240		listingItem = {};
241		bounds = [];
242		popupToggling = 0;
243		idArray = [];
244		markersList = [];
245		lastListingID = 0;
246		mapStarted = false;
247		preventDoubleClick = 0;
248		dragging = 0;
249		
250		if ( 'mapbox' === listarLocalizeAndAjax.listarMapTilesProvider ) {
251			mapboxToken = listarLocalizeAndAjax.listarMapboxToken;
252			
253			if ( '' === listarLocalizeAndAjax.listarMapStyleURL ) {
254				listarLocalizeAndAjax.listarMapStyleURL = 'mapbox/streets-v11';
255			}
256			
257			osmUrl = urlProtocol + '://api.mapbox.com/styles/v1/' + listarLocalizeAndAjax.listarMapStyleURL + '/tiles/256/{z}/{x}/{y}
257?access_token=' + mapboxToken;
258			osmAttrib = '&copy; <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <a href="https://www.mapbox.com/map-feedback/" target="_blank">' + listarLocalizeAndAjax.improveMap + '</a>';
259			//api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}
260		} else if ( 'jawg' === listarLocalizeAndAjax.listarMapTilesProvider ) {
261			var jawgToken = listarLocalizeAndAjax.listarJawgToken;
262			
263			if ( '' === listarLocalizeAndAjax.listarMapStyleURL ) {
264				listarLocalizeAndAjax.listarMapStyleURL = 'jawg-sunny';
265			}
266			
267			osmUrl = urlProtocol + '://tile.jawg.io/' + listarLocalizeAndAjax.listarMapStyleURL + '/{z}/{x}/{y}{r}.png?access-token=' + jawgToken;
268			osmAttrib = '<a href="http://jawg.io" title="Tiles Courtesy of Jawg Maps" target="_blank" class="jawg-attrib" >&copy; JawgMaps</a> | <a href="https://www.openstreetmap.org/copyright" title="OpenStreetMap is open data licensed under ODbL" target="_blank" class="osm-attrib" >&copy; OSM contributors</a>';
269
270		} else {
271			var fallbackMapboxStyle  = 'wtax1/ckr85jdk108ts17orx8mkn7cl';
272			var fallbackMapboxTokens = [
273				'pk.eyJ1IjoiYmVsaWV2ZWJheHRlciIsImEiOiJjbGVhYjB6MmcweGU5M25taHJ5a2tjbm45In0.As4BS5EB7VTpp9Gfjx2K4g',
274				'pk.eyJ1Ijoia29uYXJqb2V5LWphY2siLCJhIjoiY2xlYWE0OHd4MDU3czNvb2RrN2g5bnZtbyJ9.pApHxfQahntRWQ8zVyRJxQ',
275				'pk.eyJ1IjoiaGFndW5qYWt1YiIsImEiOiJjbGVhYXNxcTUweGs3M3ZvNjhyNXB3cTdzIn0.LwNw2X7nwrhRqA6u--xSLQ',
276				'pk.eyJ1Ijoic2hlcmlmZnJhbm9scGgiLCJhIjoiY2xlYWF5d3NxMHhhbjN4cWd5bXYyYzNrMSJ9.GHq3ZkkgrriOCUoL2XT_cQ',
277				'pk.eyJ1IjoiYWJkYWxyb29mcHJlY2lvdXMiLCJhIjoiY2xlYWI1eWVmMDIydTN4b2cxcmd3b3Y4ZiJ9.NQ4VKPHDxdo3MWq3e9EmSw',
278				'pk.eyJ1IjoiZGFyeW5hcGlzYWkiLCJhIjoiY2xlYWJiYTd0MGhkbzNwbzkxaDA1Nng0ZSJ9.ZPaN0EO4B1u1YsFkoRoDyQ',
279				'pk.eyJ1IjoibWF0ZXVzemJvIiwiYSI6ImNsZWFiZThyMDBlZHgzdWxlOGo3eWdkeHYifQ.LXP4Jlj4OLojkbhsSwzK4A',
280				'pk.eyJ1IjoiZ2xlbm5zY290dCIsImEiOiJjbGVhYmdsZTgwaDlqM3ZwYW8wNmhpNHMyIn0.QMUTLzim7ZVeFz99_8uVkw',
281				'pk.eyJ1IjoiZmVsaXhyaG9sbWFyayIsImEiOiJjbGVhYmttcXAweGQwM29taHplN3Njd2I2In0.R-7oh1Cf7oV-Wy5AoMjnbQ',
282				'pk.eyJ1Ijoib2xsaWV0b2JpYXMiLCJhIjoiY2xlYWJuMHIzMHh0azN2cjFhcHpobHJvOSJ9.3ANyiH50dljF9dNNPa7UOA',
283				'pk.eyJ1IjoiaXJlYXlvbWlkZW1pbGVzIiwiYSI6ImNsZWFicGVxcDA2eGwzd251bHBrYTRid2EifQ.vMwEEUgFy6rH9icwXwlWsg',
284				'pk.eyJ1IjoiYm9iZHlsYW50b3MiLCJhIjoiY2xlYWJydm9zMHhtcDNxcWcyMm03NDhxZCJ9.7YWJTFK6q5L4PSb7BShegQ',
285				'pk.eyJ1IjoibGF1cmlld2lsa2llIiwiYSI6ImNsZWFidm1seDA1a2ozcG9kNmZhZnEwMG8ifQ.WPN0Nt4Pf_ypGWX29aRdUQ',
286				'pk.eyJ1Ijoiam9uc29ua2FzaGlmIiwiYSI6ImNsZWFieXphYTBocGgzeG85czExeGw3ZzkifQ._7HfwCsYvt-EnW_NgRvwJQ',
287				'pk.eyJ1IjoiZnJhbmtyeWhzIiwiYSI6ImNsZWFjMWhyZzB4ZzYzcnMzd2tnb2xzeGgifQ.xodBFSS6-9TtGtc1dlg1zQ',
288				'pk.eyJ1IjoibHVjaWVuYWJkdXIiLCJhIjoiY2xmZmxhMnY4MGEzbjN3b3p6M2VyaGVvbiJ9.VdQH8BZwyEE5eLGbqgwY5g',
289				'pk.eyJ1IjoibGluZGVuYXBpc2FpIiwiYSI6ImNsZmZsdWIzMzBueTYzcG04NnBrNngwYWQifQ.YyUpJ19hxN-42YG0hp1C4A',
290				'pk.eyJ1Ijoicm9iaW5qb2FxdWluIiwiYSI6ImNsZmZseGo0azBlYzIzenB1NDQwNGVjbjkifQ.UiV5mQ2UKC2aTKCPxi65ag',
291				'pk.eyJ1IjoianViaW5kaW5hcmFzIiwiYSI6ImNsZmZsenpuZzExM2kzeG51ZDh6bXRoN2EifQ.2iCy1JXXE09Sxrp-25ghTQ',
292				'pk.eyJ1Ijoiemhlbmtlbnp5IiwiYSI6ImNsZmZtMjUyNzBkejYzcGs4ZWt5NHF5NWEifQ.NVUGCogH5EOonipkPfnNkA',
293				'pk.eyJ1IjoiYmFsZXltYWRkaXNvbiIsImEiOiJjbGZmbTV2aWQwYTg0M3VvNXF2ZXNjMXRoIn0.rj7noky_oDhQh9uv4XW5VQ',
294				'pk.eyJ1Ijoic2hpbG9oc3Rld2FydHkiLCJhIjoiY2xmZm1nOTVqMGU3ejQzcGEybml4NDRpcCJ9.zIOKA6a0kgIf0hLeb2s01w',
295				'pk.eyJ1Ijoic3RldmVudW1hciIsImEiOiJjbGZmbWtoaDQwb2FzM3JvaG01MmoyaWs1In0.dwL8cB6xM1bDXNqE8U-BDQ',
296				'pk.eyJ1IjoiamFzaW15b3VjZWYiLCJhIjoiY2xmZm1tb3J0MDAzNDN0bzdhdWxnZ2FxNSJ9.QT4ADC6v90tWnG9Mc_ZyAg',
297				'pk.eyJ1IjoiYXplZGluZWNlcGhhcyIsImEiOiJjbGZmbXFtMWQxMWFwM3hudXo2NnhxMzRhIn0.YCqlKNPV8P7loFzJV-zaVw',
298				'pk.eyJ1Ijoia3ltYXJ2ZWQiLCJhIjoiY2xmZm11c3hkMDl3azNxbXRyZXRpcTI1ZSJ9.MWWpBsY1aw4LqGgrR3y7vQ',
299				'pk.eyJ1IjoiYnJ1bm9uc2hhaG1pciIsImEiOiJjbGZmbnMzbHAwMDB1M3NsaTZmY2lkMm8zIn0._JWIx9YoYuNYVLnTY1-Elg',
300				'pk.eyJ1IjoiYWxiZXJlc3RlYmFuIiwiYSI6ImNsZmZueDlmNTBvaTgzcG04eTN5bjhnZ2MifQ.iane_nRFMBxB0Oa7VeuZHQ',
301				'pk.eyJ1IjoiZG9tYW5pY2JyZW5keW4iLCJhIjoiY2xmZm56c29qMDBnOTN0cW5yMGYwdTZrciJ9.gpvlJor5dLCrlH4XBnHSdQ',
302				'pk.eyJ1Ijoiam9ubnlrcmlzIiwiYSI6ImNsZmZvMXhlYzBvaHczd204Y3F6MXcyYngifQ.RnmjN7BmLVlbZeHED5LCcg',
303				'pk.eyJ1IjoiZWxqYXlhbmF5IiwiYSI6ImNsZmZvNWZvMjAyeXA0M29kdjVwNWMzZ24ifQ.QnOqmqnK-7uyTddNpHQ3pQ',
304				'pk.eyJ1IjoiamFtZXMtcGF1bG9yc29uIiwiYSI6ImNsZmZvOGtubjAwMmMzdHBhZ2RvZTdsMnEifQ.gjodB6hbbbJxfV2Z1i7LPg',
305				'pk.eyJ1IjoiamFtZWlsd2luZHNvciIsImEiOiJjbGZmb2JwZmcwYWJ6M3BtdGRteWk3M3M0In0.al9HCpKmG-CiaGtEEVv5Dw',
306				'pk.eyJ1IjoiY29zbW9lYm93IiwiYSI6ImNsZmZvZWM1aDBvbGQzd204a2I3eGtvZ3oifQ.AmEdvbLHFSpVEWUH7hqdqw',
307				'pk.eyJ1IjoiaHVzc2FudmFsZW4iLCJhIjoiY2xmZm9oYWt5MTUwMzN0bzYydXFlcDVlMCJ9.53KRgbAwNOrc9_b6E18Rng',
308				'pk.eyJ1IjoiZ3JhbnRqb2huamF5IiwiYSI6ImNsZmZvbDA1MDAwbGc0NnFuNzh5OHNhemQifQ.OaPFGsoRJnK0XIlbPEdlKg',
309				'pk.eyJ1Ijoicm9uaW5sbGlhbSIsImEiOiJjbGZmcHh0djAwMGo2M3RwYXo2dTJoMXJwIn0.DGDmtQ-mPCnzW8v8Dapiug',
310				'pk.eyJ1Ijoiam9lZGR5b3Jzb24iLCJhIjoiY2xmZnEwbHVmMDBuMjQ0bGlvNHg3czExciJ9.QwtfL_84f1Yvrd8F5odbCQ',
311				'pk.eyJ1IjoiemFjaGFyaWFodGpheSIsImEiOiJjbGZmcTM3ZGsxMjVxM3FycmI3NXY0dW84In0.Gs1GpTGv6fEmlNjurstjag',
312				'pk.eyJ1IjoiYXJ5aWFuY2hlIiwiYSI6ImNsZmZxNmNkcjAxMzUzdW83M3J2OGF3YWIifQ.0Zx4Adnpk5dZVUjZx7U-0Q',
313				'pk.eyJ1IjoicHJvbWlzZWhvd2llIiwiYSI6ImNsZmZxOHk3NTAwcWwzc250eGNuZGhxZ2IifQ.PrawiSEDFS-AySRFVHu0YQ',
314				'pk.eyJ1IjoiaGFyaWNhaGx1bSIsImEiOiJjbGZmcmZlbXAwM3B3NDVtejc3MHo0M2RxIn0.zKob4x6x-xYlL4CxLUREWQ',
315				'pk.eyJ1Ijoiam9hcXVpbmFsZXhlaSIsImEiOiJjbGZmcmlnMnMwcGdwM3hvaGk3bjRwazhkIn0.3tQVA0XrWwvnSRNN0G2k_g',
316				'pk.eyJ1IjoiYXNodHludmFsbyIsImEiOiJjbGZoY2c2djAwNnVwM3JubWRwa3NyNXZ3In0.49PJsSM5ClVy5yj0uDZgJg',
317				'pk.eyJ1Ijoiam9yZHlreXJvIiwiYSI6ImNsZmhjanlvbTAzY2ozdm81ZDdrZWt2MDMifQ.iNfBkd33E4oiodlFfLMNvA',
318				'pk.eyJ1IjoiYnJhZGFuY2FpZSIsImEiOiJjbGZoY212Nncwdnl4M3dxbnp5ODAyNmUzIn0.SHMPi8UCkAYpW81kckmL3Q',
319				'pk.eyJ1IjoiY2lhcmFucmlsZXkiLCJhIjoiY2xmaGNwanRyMDI0NjNybGk2OWY4c3VlZiJ9.cTQUmP5oRdzK-UoMnv5DmQ',
320				'pk.eyJ1IjoiZXZhbmFybmFiIiwiYSI6ImNsZmhjc20xNzA0bnQzc3M1em5scGI4dWoifQ.SBbJd-wM-Pu1xyKC3bPR_w',
321				'pk.eyJ1Ijoia29yYmVubGVub24iLCJhIjoiY2xmaGN2YnRsMGEycTN4bnJwM2RibDhmNCJ9.6q_2kcBhJEyk0tC-8sfVyg',
322				'pk.eyJ1IjoiZ2lyaXVzcmFqYWItYWxpIiwiYSI6ImNsZmhjeTlicDE1cWkzeHBkd3BtaWx2ZzUifQ.458o704AfjAlvmjyY5cZ-g',
323				'pk.eyJ1Ijoicm9iYnlwaWV0cm8iLCJhIjoiY2xmaGQxOG02MWxyMTNxbzZqcHcwdnEwMSJ9.PuZluzYKVG5kuRjUES57xg',
324				'pk.eyJ1IjoiemFrYXJpeWFrZWlyZW4iLCJhIjoiY2xmaGQzdTRiMTVlNzNwbTh5N2hsZTh4aiJ9.HV8x5sN123u9tTX2UtI98A',
325				'pk.eyJ1Ijoibmlja2hpbGxicmVhbmRhbiIsImEiOiJjbGZoZDYwdGgxNjB4NDBwZGRuYWZyOGZtIn0.yQVOr0YHMkk3ZgFQwG-vEA',
326				'pk.eyJ1Ijoiam9yZHlicm9nYW4iLCJhIjoiY2xmaGQ5NmZkMDU0bjQzcWduajBtOWZsYyJ9.hEebZV_7TcMcAYtYhQbjYA',
327				'pk.eyJ1IjoiamF5ZGVuLXBhdWxoYXJqZWV2YW4iLCJhIjoiY2xmaGRieTdvMDJhcDNybGk0eWplbDU3byJ9.QfFfbKENEazH1nq1_aJdrQ',
328				'pk.eyJ1IjoibHVjYWFsbHkiLCJhIjoiY2xmaGRlbDZlMDR4ajNyczVsbHNxbmJ4bCJ9.UYmt9PZ9m5Yi0JZ0GI9syA',
329				'pk.eyJ1IjoiYWxseWhhcmp5b3QiLCJhIjoiY2xmaGRoOTIwMTVmazN4b2h2Z2V6ZHpzdSJ9.RiL0XkM7-Ey19TgzLLT90w',
330				'pk.eyJ1IjoiYWlsaW5lbnJpcXVlIiwiYSI6ImNsZmhka2JtMzAzbnIzcHJ4aTNqbTgxaGYifQ.iniEVFMPFXpZJe_msUNn0g',
331				'pk.eyJ1Ijoia2FyYW5kZWVwb3dlbiIsImEiOiJjbGZoZHVhY2IxaHJiM3pxc3k1a2d6OTU3In0.WrCsDfnmM9u4evEavlyKWw',
332				'pk.eyJ1Ijoia3J1em1hc29uLWpheSIsImEiOiJjbGZoZHlzcXowM3FrM3NwbXMxaWVwM3QyIn0.DSqmI39XWYKVvephXlmpDA',
333				'pk.eyJ1IjoiZnJhbmtvbWFrc2ltIiwiYSI6ImNsZmhlMWJ5ZDA2a240Mmxodm9haWJza3EifQ.j77sz1DcyLo7GOvgvS1U3Q',
334				'pk.eyJ1IjoibGFzc2VrZWVuYW4iLCJhIjoiY2xmaGU0YmZlMDVzdDNybGpnOWNncWtqZCJ9.zUByNgOFUW4TVP1bZEYcEg',
335				'pk.eyJ1Ijoib2doZW5lb2NodWtvbmV2YW4iLCJhIjoiY2xmaGU3M2N3MDJrMjNxbDkzMXoxY3Y5ayJ9.SOmIXmYbVlZr6K_RNjaBWw',
336				'pk.eyJ1Ijoia3J1enJvaGluIiwiYSI6ImNsZmhlYWFicTAzc3ozb3J4YWR2MmkzaGsifQ.U4ducy4sR2FJk-ivLii68A',
337				'pk.eyJ1IjoiYW1pcm5pa2hpbCIsImEiOiJjbGZpdmc3eWQwcDRlM3hucjd4b3B5dWo2In0.GPQe2zyeGXtg68xhyXYcvg',
338				'pk.eyJ1IjoibGVpdGVuY2F5ZGVuLXJvYmVydCIsImEiOiJjbGZpdmx5MjIwaWg2M3FyeGc2ZGttd3BnIn0.8BH8j80fC5FHs8FR3YLyzA',
339				'pk.eyJ1Ijoicm9iYmllcHJlc3RvbiIsImEiOiJjbGZpdm9hNzYwMjU4M29vNGFzdzM2cHptIn0.EgwJvMrzfjuTyLQjIyNShg',
340				'pk.eyJ1IjoidXJiYW5jYWxlYiIsImEiOiJjbGZpdnF6a3cwaDVyM3JsaTF1bnptZmxyIn0.Bdsgo7rFH9ORnThpMuHirQ',
341				'pk.eyJ1IjoiYXVsYXlsYXdzb24iLCJhIjoiY2xmaXZ0M21yMGxiZTN3bGgzN3FqbDI3cyJ9.YHgpq-gKGsUAtViIuIHUuQ',
342				'pk.eyJ1IjoiY2hpeWFuZ3hwIiwiYSI6ImNsZml2dzBkbDAybDQzeG8wOG1lajAxaGYifQ.u2pvAdoNzAmDuPa_Y3uZBQ',
343				'pk.eyJ1IjoiamVlbWllZGFycnlsIiwiYSI6ImNsZml2eWZuZjAyYzEzcXAwM2E0czEwdmsifQ.7DqAUBM8uzsh3moj_BhDSw',
344				'pk.eyJ1Ijoib2xpdmllcnJheWFuZSIsImEiOiJjbGZpdzBsdHIwbTcxNDNubW4xdDQyajQzIn0.-i_zJxT8GX6bKvwHoBdc2g',
345				'pk.eyJ1IjoibGVpZ2hqdXJhIiwiYSI6ImNsZml3MnNrejBhaTgzc25xamFlYTk3dHEifQ.FLFNiP24f3U09FqonV9FxQ',
346				'pk.eyJ1IjoiYWFycm9ucmh1YXJpZGgiLCJhIjoiY2xmaXc1MGFjMDk1djN3bzY3NXpvMHFkNCJ9.Nj5_jcSqhD6YIV2S1luHjA',
347				'pk.eyJ1Ijoia3ltYWRkaXNzb24iLCJhIjoiY2xmaXc3NWp1MDJmNDN5cDA3eW9hbWNkdyJ9.LszKd4W5P4vE8sFEMkMLXA',
348				'pk.eyJ1IjoicGF0cnlrc29oYW0iLCJhIjoiY2xmaXc5a3B5MDA1NDN5cGp1ZWNtZHNvayJ9.7_3W5gadmA7xRx0rsGDZOg',
349				'pk.eyJ1IjoiYWJpZHNhY2hraXJhdCIsImEiOiJjbGZpd2JvMXEwODJuM3FrcGV1b3ZoNzB5In0.SU8YYi_GgGzs3rc6t3vbXw',
350				'pk.eyJ1Ijoib3Nlc2VuYWdoYXRvbXNvbiIsImEiOiJjbGZpd2RreDgwN3ViM3drcGQ3NTk1MThrIn0.MfnMEUi9tRGJ0kS96C73KQ',
351				'pk.eyJ1Ijoiam9zaWFoY2hpbXNvbSIsImEiOiJjbGZpd2ZuanMwMDBmM29zMHZybDZvNTc0In0.nYXTZ4pOdBgfs7WIOZqpXQ',
352				'pk.eyJ1IjoibWFzb25jaHJpc3RpZSIsImEiOiJjbGZpd2hvaHkwMnF6M3hvMGRiM2tibnJvIn0.2ksq4z6tQmun7pQJlQ31_w',
353				'pk.eyJ1Ijoib2x1d2FmZW1pZmF3a2VzIiwiYSI6ImNsZml3am5uMjA4amgzeG11YTBmMzI0NDcifQ.pK47DS-naXjzSAYPleSBfA',
354				'pk.eyJ1IjoiYW1vc3Jlbm8iLCJhIjoiY2xmaXdsbDl5MDJodjNxcDBkcjNpZnppaCJ9.tb5V2D7WQIhyE5dpz2l9kw',
355				'pk.eyJ1IjoiZHlsYW4tamFja2NhYmhhbiIsImEiOiJjbGZpd25tYnQwMDJxM3ZzMHY2b2VkbWh
3555In0.du-bOTtQw-1V8q0wVoAOEg',
356				'pk.eyJ1Ijoia2Vsc29jb25yYWQiLCJhIjoiY2xmaXdwdnJsMHdzdDN0cXdpc215azF6eiJ9.LuC1okmN7zLUOECqPpiNhA',
357				'pk.eyJ1Ijoia2l0am9hcXVpbiIsImEiOiJjbGZuOWRpcnIwaHhmM3JzdzJyajd2MTR3In0.mqFEPfWPwz9BXPKXy-MyVQ',
358				'pk.eyJ1Ijoid2FidXlhc29oYWliIiwiYSI6ImNsZm45eWtqajAzMjkzcXQycDViNDU3dTAifQ.LiJCqsRkSNMx47_-dLrrBA',
359				'pk.eyJ1IjoiYnJheWRvbnRqIiwiYSI6ImNsZm5hMXAwczAzNGUzeHQyN3VmMW1oZnUifQ.poxrLlpFsXrlVMy3-g4MmA',
360				'pk.eyJ1Ijoia2VoaW5kZW11c3RhcGhhIiwiYSI6ImNsZm5hNGY3ajAxNW80NnA5ajR1MzhoaWgifQ.buMRsDPVS-PMShEOME1XDg',
361				'pk.eyJ1IjoiaXNpbWVsaXBvcnRlciIsImEiOiJjbGZuYTZtZWwwMWp3NDNtaHd3NGpxZjUwIn0.s5cRdMY3jEDAsg6x9y3NEg',
362				'pk.eyJ1IjoiY29yaWVtb3J0b24iLCJhIjoiY2xmbmE4eTd5MDRwMjN0bnJxZWJ6cXRvMyJ9.nj_OEkg5_zhrf4_PRjgabA',
363				'pk.eyJ1IjoiaWRyaXN0YWxoYSIsImEiOiJjbGZuYWJkeWswMHBqM29uM2xlNHhsbGl2In0.2RPdmr28ifyfuYRIuXUXhQ',
364				'pk.eyJ1IjoicmljaGV5ZXJkZWhhbiIsImEiOiJjbGZuYWU3OGcwMWx2M3FtaHk4ZTByMTl1In0.SIfxYKZwvQbS8UdRCMbHVw',
365				'pk.eyJ1IjoiYW1tYWFyaW1hbiIsImEiOiJjbGZuYWg5NmcwOHpmM3JvNXZmNzVoem9lIn0.ItnzViCOdzR-f5pzs1E4AA',
366				'pk.eyJ1IjoiZ2VvZmZyZXlzYXVsIiwiYSI6ImNsZm5hamx6YzBhNXo0MnB0dXExdGl0YjIifQ.X-8HaJFL4fDAjE15Uj-HSQ',
367				'pk.eyJ1IjoiZXJpem5hdGUiLCJhIjoiY2xmbmFtaXpjMDh5MjNxcW9sc3N5dnFybCJ9.eH1Y_GpDTjmVL5lQB44CFQ',
368				'pk.eyJ1IjoiZmlubmVhbmxvbW9uZCIsImEiOiJjbGZuYW93eWYwM3ZwM3NzMGVidXdmN3A1In0.NM7TyqOKx9XBOA-E8_JO4g',
369				'pk.eyJ1IjoiaXNtYWVlbHRva2luYWdhIiwiYSI6ImNsZm5hcmFuNDA4cHYzb281emRxb2NhNzIifQ.7CNO6_t5onvmR5_zeoys3Q',
370				'pk.eyJ1IjoiamFtZXNjYWlsZWFuIiwiYSI6ImNsZm5hdWp1bTAxOXQzdnA0aHFjb2ZkOWMifQ.XQao5SbkT0U5NumbVWGLuQ',
371				'pk.eyJ1IjoicmVnZ2llbG9jaGxhbm4iLCJhIjoiY2xmbmF5b29mMGsxaDQ0bGtyNTNhbzJoZiJ9.xjcvKBLNyePzDHbpAzlifg',
372				'pk.eyJ1IjoibG9raWt5cmFuIiwiYSI6ImNsZm5iMjJrMTAxdjYzeG1ocmx2bHpjdzIifQ.wQomotTbL-_LA8oT6kSMeQ',
373				'pk.eyJ1Ijoid2FsaWRtYXNvbi1qYXkiLCJhIjoiY2xmbmI0ZnJ2MDhyeDN4bzVtcXlldmk3byJ9.S7LkS2VFsC5mGqvi4O_IIQ',
374				'pk.eyJ1Ijoic2hhZG93bGFpcmQiLCJhIjoiY2xmbmI4aTBoMDF1ZzNxbWhwdGZtMDlpMiJ9.VOIHnchBqo1e4JIJCIwL9A',
375				'pk.eyJ1IjoiamlheWFuZ3giLCJhIjoiY2xmbmJjeHhjMGs0bTNvbW9qa2hzcjU3YiJ9.MdD2RC6_29YvakmJ__bJOw',
376				'pk.eyJ1IjoiZnJhemVydWNoZW5uYSIsImEiOiJjbGZuYmZsOHgwM2U0NDN0MnZhOXdvM2Y5In0.iGNCbeIS3nHFyaq5LYe96Q',
377				'pk.eyJ1IjoiZGVjbHlhbnZpbmNlbnQiLCJhIjoiY2xmcTMwbzQ3MDRwaDN3bnNkZWVibnYzeCJ9.EvOzCEHyNeojRws539xKGQ',
378				'pk.eyJ1IjoiaG93YXJkbWFudXMiLCJhIjoiY2xmcTM5ZDA2MWMzdzN2cDl3ZDR4N25xcCJ9.UDe12Czzb9lGIe2oBSeWaA',
379				'pk.eyJ1Ijoicml0Y2hpZXV6YXlyIiwiYSI6ImNsZnEzYzc1ZzB0ZXczcm1oZWsydGhuMWsifQ.-g1HykZRRpIV8HsTgYuNkQ',
380				'pk.eyJ1IjoiYWhtZWQtYXppenplZWsiLCJhIjoiY2xmcTNmZGtpMDR2ejN3cnI0NWZlaXllcCJ9.JsxY_CtOq4YlwWVU8vkYjA',
381				'pk.eyJ1IjoiYW5kcmV3aGFuIiwiYSI6ImNsZnEzaHBpbTFibGs0MXA5cjNseXRkcHkifQ.aEjZUCJZPapriYIVCbaxuw',
382				'pk.eyJ1IjoiZXN0ZWJhbnBoaW5laGFzIiwiYSI6ImNsZnEza2t6dDFibnUzcHA5ZGxzcXA0NDEifQ.VGrYaHHrgcZkFT1g9nh5fg',
383				'pk.eyJ1IjoibWFkaXNvbmpvbmF0aGFuIiwiYSI6ImNsZnEzbmNqYzA0c2Q0MGxjYW1iemd4YzQifQ.DFbCVZ-UKgEZSdymOFO8mg',
384				'pk.eyJ1Ijoiam9obm55bW9tb29yZW9sdXdhIiwiYSI6ImNsZnEzcGx5NjEwZzczeG81ZmhscHVqbmcifQ.TCFVY5_7Py91z_-3V5arSw',
385				'pk.eyJ1Ijoiam9vam9hbGlzZGFpciIsImEiOiJjbGZxM3J3b2IwdGh0M3FtaHR4bnJkOG10In0.tD8w0czOlncP0Nz1AC3pjA',
386				'pk.eyJ1IjoiaGVpbmlhbnRvbmkiLCJhIjoiY2xmcTN0ejFmMHgzYjN0cGp4aHVoMmN4NCJ9.eD0yHIKQh40f73F_bYoEdg',
387				'pk.eyJ1IjoibW9ycmlza2llcmFuLXNjb3R0IiwiYSI6ImNsZnEzeDZ3bzFicWE0MXA5NXlmdDJ0dnMifQ.AvezL6tTKktZ0bC_Z8y9Iw',
388				'pk.eyJ1IjoibXVoYW1tZWRuaWtpIiwiYSI6ImNsZnEzem5lcjA1NHUzcXJyejByZW41YmkifQ.dDZmj3Ja-l32zALY9MbMbA',
389				'pk.eyJ1Ijoia2FybGVyZW4iLCJhIjoiY2xmcTQxbXQ2MDU1YjNxcnJ4enEyd3RwYyJ9.rXO9kQ_vkxdQMPB0_tQUcw',
390				'pk.eyJ1IjoicmFkbWlyYXNhbGEiLCJhIjoiY2xmcTRwbGg4MWNybjN5bXZmYnE0NmNsbiJ9.xkAa2E8uem726FP6Vl-Z_g',
391				'pk.eyJ1IjoicWFzaW1ub29yeCIsImEiOiJjbGZxNHMzbjQwZnloM3JubDMyZGRkZDdnIn0.RFHIcWA0csdoQV3bMprUEA',
392				'pk.eyJ1IjoiZ2FyZXRobm9sYW4iLCJhIjoiY2xmcTR1Y21qMDAxbjQ1cnJnZ3JnZDV1cyJ9.tDN1XHTdBQ4bQN3Wl-eROQ',
393				'pk.eyJ1IjoiY2FybGRpc3NhbmF5YWtlIiwiYSI6ImNsZnE0eGx5NzFjOXozc25yNmZ0MTBrZHoifQ.liIMcoCAz7vCsuRclLRUCQ',
394				'pk.eyJ1Ijoia2FlbGFuYWJkaXJhaG1hbiIsImEiOiJjbGZxNHp0NmowZmptM3JwZjBiMHI1ajAzIn0.HZNc0Bjjayj1X0DxaYL5gg',
395				'pk.eyJ1IjoidGF5eWVzd2V5biIsImEiOiJjbGZxNTJkdWEwMjlvM3JxZmp1N2JvanJyIn0.hS479IuZvYkb7F6EWDXa-w',
396				'pk.eyJ1IjoiZ2xhc2NvdHRkYW4iLCJhIjoiY2xmcTVkYmNvMDVibzNxbzN6ODZweWRveSJ9.nV6bvBuCi8mjINAPhKvLHg',
397				'pk.eyJ1IjoiZGVub25yZWlkIiwiYSI6ImNsZnE1Zm03cDExMjIzeXFvcGVieWhxZW0ifQ.5y0kZCzV7TokSkhptB7Oew',
398				'pk.eyJ1IjoidHVybmVyY2hhcmxleSIsImEiOiJjbGZxNWh3NWIwNWN2M3BzaGM2N3FnZ296In0.hF92crOSYXj0xKfke3S3fw',
399				'pk.eyJ1IjoidW1hcnJvYW4iLCJhIjoiY2xmcTVrNDk3MWNqODQxcWQ0ZHFqMHhrcSJ9.J8ow34_lCk_wAhoHfnlVvA',
400				'pk.eyJ1IjoiamVhbi1waWVycmV0eSIsImEiOiJjbGZxNW1haG8wdnlhM3lzMHVvend0YWpwIn0.kEuzbtVnvJJ-3exQoK_QlA',
401				'pk.eyJ1IjoiZ2h5bGx6ZWNoYXJpYWgiLCJhIjoiY2xmcTVvYzUxMGdyOTNxcG94dmluZGxsYyJ9.sESGczeqKatWpqO--Ls7xQ',
402				'pk.eyJ1IjoiZGFueXNkaWxsb24iLCJhIjoiY2xmcTVxZmlsMDVmaTNwc2h6eG5pYzVhdSJ9.QTBTOMeCHIqrmm56rFi3Vg',
403				'pk.eyJ1IjoiYWx1bWNvZGV5IiwiYSI6ImNsZnE1c205dzFjYmMzcHFkOGdhY3U3bGEifQ.y_sqOi70G7jLeqnCe0jAaw',
404				'pk.eyJ1IjoiY29vcGVyYXJpaGFudCIsImEiOiJjbGZxNXV4aWwwdmt2M3hrYnVxaDI4N2lxIn0.N6xRtlBSFbB2JbvgFm
404jX7A',
405				'pk.eyJ1Ijoib3NrYXJvd2FpbiIsImEiOiJjbGZxNXd6MWUxMnRzM3FwdHF2NHByaXA3In0._EE0vNkFxd_MLICl3lkFKQ',
406				'pk.eyJ1Ijoia291c2hpa2xvcm5lIiwiYSI6ImNsZnE1enNobjA1aWQzcnBiZ2ptdjZ1cmsifQ.2KntgZg-BZt_J2OJgfxSmA',
407				'pk.eyJ1IjoiZHJld2RvdWdhbCIsImEiOiJjbGZxNjF0eTIwNWlkNDJuczdiNXZwdjFiIn0.hjqs0hMLGZ9vYhU7by4vSg'
408			];
409
410			var fallbackMapboxStyles = [
411					'mapbox://styles/believebaxter/cleab2j9v003z01phprzvp472',
412					'mapbox://styles/konarjoey-jack/cleaaekz3005b01p5544flj5t',
413					'mapbox://styles/hagunjakub/cleaauchu003x01phwfn28xdg',
414					'mapbox://styles/sheriffranolph/cleaazjez003y01phsh7s4pk3',
415					'mapbox://styles/abdalroofprecious/cleab77w5004s01meizsfjuy1',
416					'mapbox://styles/darynapisai/cleabchnv00aj01rwuyxwu7zm',
417					'mapbox://styles/mateuszbo/cleabeog6005801s0zw375yan',
418					'mapbox://styles/glennscott/cleabipsp00ak01rwsmcxik1b',
419					'mapbox://styles/felixrholmark/cleablrqo005901s0d9hun3bm',
420					'mapbox://styles/ollietobias/cleabnidv005d01p56tgakebu',
421					'mapbox://styles/ireayomidemiles/cleabpu4k002m01ljcrnin8mr',
422					'mapbox://styles/bobdylantos/cleabsagc005x01ldlnu8ge69',
423					'mapbox://styles/lauriewilkie/cleabxevv001601mhqdw98r5n',
424					'mapbox://styles/jonsonkashif/cleac090000ay01pblyfp3ww1',
425					'mapbox://styles/frankryhs/cleac2kd7001o01qkms9y5oha',
426					'mapbox://styles/lucienabdur/clffldr6p000f01nx9cu6toyi',
427					'mapbox://styles/lindenapisai/clfflvkp7009c01nzc704pt1v',
428					'mapbox://styles/robinjoaquin/clfflyllx005l01t5eqj39197',
429					'mapbox://styles/jubindinaras/clffm0hzj000201p7rin5wu12',
430					'mapbox://styles/zhenkenzy/clffm3hfu000301l3rsymh5q0',
431					'mapbox://styles/baleymaddison/clffm6yus009v01o5sltg3ygy',
432					'mapbox://styles/shilohstewarty/clffmhn2z000z01nnixv4kskr',
433					'mapbox://styles/stevenumar/clffmldc3001001nn0vitpow1',
434					'mapbox://styles/jasimyoucef/clffmp4tl000301p7harqot5e',
435					'mapbox://styles/azedinecephas/clffms0td000101r3opuk7aj3',
436					'mapbox://styles/kymarved/clffmvjpe000n01pgad0fbmnj',
437					'mapbox://styles/brunonshahmir/clffnv0mt009g01nzsojc9773',
438					'mapbox://styles/alberesteban/clffnyk3b005v01pdnuyvmxx3',
439					'mapbox://styles/domanicbrendyn/clffo09m7000o01tkco9jx7h0',
440					'mapbox://styles/jonnykris/clffo3iok000401lnk2didn6u',
441					'mapbox://styles/eljayanay/clffo6rq8005601o18my81yt9',
442					'mapbox://styles/james-paulorson/clffoa776000001ry712cix9h',
443					'mapbox://styles/jameilwindsor/clffoc7st00a001o5exq3bdmc',
444					'mapbox://styles/cosmoebow/clffofpbu000a01p6z4t0ja50',
445					'mapbox://styles/hussanvalen/clffoidex005n01t5460zobid',
446					'mapbox://styles/grantjohnjay/clffom3du000701l3ihrdpfwn',
447					'mapbox://styles/roninlliam/clffpz4zr00a301o5b68yxw7y',
448					'mapbox://styles/joeddyorson/clffq1nlg000l01nxjerp3agb',
449					'mapbox://styles/zachariahtjay/clffq4lfg005r01t5frwsn55i',
450					'mapbox://styles/aryianche/clffq7fj5000y01o1ia4ilabu',
451					'mapbox://styles/promisehowie/clffqa0o1000901lnnl25gkqc',
452					'mapbox://styles/haricahlum/clffrghpv000w01pges4hkinv',
453					'mapbox://styles/joaquinalexei/clffrjj1a000n01nxdr3gy6u4',
454					'mapbox://styles/ashtynvalo/clfhci29l000001qj51xaty33', 
455					'mapbox://styles/jordykyro/clfhcl64p005w01pbr0c85dwn', 
456					'mapbox://styles/bradancaie/clfhcnzei000401n30h59d3fd', 
457					'mapbox://styles/ciaranriley/clfhcr1ls009a01pdcy89reni', 
458					'mapbox://styles/evanarnab/clfhcttrk004d01pgmlk4jeq9', 
459					'mapbox://styles/korbenlenon/clfhcwfdk001101pb1eg7as30', 
460					'mapbox://styles/giriusrajab-ali/clfhcze2x003v01nx3i599wi5', 
461					'mapbox://styles/robbypietro/clfhd2f00000201qjsdqiwvz7', 
462					'mapbox://styles/zakariyakeiren/clfhd4c9u000701p366x3jikv', 
463					'mapbox://styles/nickhillbreandan/clfhd7gma001301pbdgwekukm', 
464					'mapbox://styles/jordybrogan/clfhdad39001p01le0wufpw6y', 
465					'mapbox://styles/jayden-paulharjeevan/clfhdd418000901p3e0iml0se', 
466					'mapbox://styles/lucaally/clfhdfw4h004e01pgi9ruj8h6', 
467					'mapbox://styles/allyharjyot/clfhdikj7003w01nxge8xoe0w', 
468					'mapbox://styles/ailinenrique/clfhdpl91000901n3xwznav65', 
469					'mapbox://styles/karandeepowen/clfhdvfbv002t01patmcsq4me', 
470					'mapbox://styles/kruzmason-jay/clfhdzrwo000d01p3y7vztpnx', 
471					'mapbox://styles/frankomaksim/clfhe1vdw009g01pdg3h4r90j', 
472					'mapbox://styles/lassekeenan/clfhe5gwk000301ob0kkpi57y', 
473					'mapbox://styles/ogheneochukonevan/clfhe8dxs002v01pamc7t2yaq', 
474					'mapbox://styles/kruzrohin/clfhebfp0002x01paa9ds49ct', 
475					'mapbox://styles/amirnikhil/clfivk6y3000n01pa3lore1p5', 
476					'mapbox://styles/leitencayden-robert/clfivmwpc000j01m9u45jtto1', 
477					'mapbox://styles/robbiepreston/clfivpb42000k01m9g0ct14m8', 
478					'mapbox://styles/urbancaleb/clfivryvc001a01m7moygn8jt', 
479					'mapbox://styles/aulaylawson/clfivu7wi001401mllw17i85v', 
480					'mapbox://styles/chiyangxp/clfivx57g000p01paq2qxz3cl', 
481					'mapbox://styles/jeemiedarryl/clfivzh02000001owhcij4994', 
482					'mapbox://styles/olivierrayane/clfiw1jtx000q01pavq4rcunl', 
483					'mapbox://styles/leighjura/clfiw3pwn001b01m7uhou3ej2', 
484					'mapbox://styles/aarronrhuaridh/clfiw61m5008601nx81ddgwgn', 
485					'mapbox://styles/kymaddisson/clfiw858s000201ows2n06n9s', 
486					'mapbox://styles/patryksoham/clfiwafoc000301owqkmo8x7b', 
487					'mapbox://styles/abidsachkirat/clfiwchrl000001qwsy1hc3bl', 
488					'mapbox://styles/osesenaghatomson/clfiweczt000501ntz6tdfjfe', 
489					'mapbox://styles/josiahchimsom/clfiwgg0c000201plk67mqj4o', 
490					'mapbox://styles/masonchristie/clfiwifft007k01o7bxzk79ok', 
491					'mapbox://styles/oluwafemifawkes/clfiwkgaf000101qwzgl0m10q', 
492					'mapbox://styles/amosreno/clfiwmj2200aa01pb2ehre7p4', 
493					'mapbox://styles/dylan-jackcabhan/clfiwol2l000201qwj5exd51o', 
494					'mapbox://styles/kelsoconrad/clfiwqrxm006n01le06prnkns', 
495					'mapbox://styles/kitjoaquin/clfn9f5ix00k201nxbb3dw3ck', 
496					'mapbox://styles/wabuyasohaib/clfn9zucr001x01mrtc0ew9u4', 
497					'mapbox://styles/braydontj/clfna2v97002q01qom7noa9yk', 
498					'mapbox://styles/kehindemustapha/clfna5bey000l01ofu96n38ik', 
499					'mapbox://styles/isimeliporter/clfna7mfi005j01p99o89akna', 
500					'mapbox://styles/coriemorton/clfnaa0un006p01qj2eswml7w', 
501					'mapbox://styles/idristalha/clfnacf20000v01l84n1yyflu', 
502					'mapbox://styles/richeyerdehan/clfnaftzj002w01pb010rfmqz', 
503					'mapbox://styles/ammaariman/clfnaie0f00l701pbimgpwk4z', 
504					'mapbox://styles/geoffreysaul/clfnal25q000301qbnbizrnw2', 
505					'mapbox://styles/eriznate/clfnanm90000w01l8j733x1v4', 
506					'mapbox://styles/finneanlomond/clfnapxyb000y01l8o01h0thf', 
507					'mapbox://styles/ismaeeltokinaga/clfnaspc9002p01o7hlclvu1g', 
508					'mapbox://styles/jamescailean/clfnavn83001y01mrh288tur0', 
509					'mapbox://styles/reggielochlann/clfnazuv0002v01pg168wzftg', 
510					'mapbox://styles/lokikyran/clfnb37rd000501mn281pxb4a', 
511					'mapbox://styles/walidmason-jay/clfnb5noo003g01ry64saenx2', 
512					'mapbox://styles/shadowlaird/clfnb9w3q002t01lrjbztqg8e', 
513					'mapbox://styles/jiayangx/clfnbdwzx002w01pg56e7g7dz', 
514					'mapbox://styles/frazeruchenna/clfnbg3ie00k801nx4y8spx2y', 
515					'mapbox://styles/declyanvincent/clfq37bb9000c01nqoexgezk0', 
516					'mapbox://styles/howardmanus/clfq3acki000001t4lacp4sw5', 
517					'mapbox://styles/ritchieuzayr/clfq3d5zj006p01pef0k34cct', 
518					'mapbox://styles/ahmed-azizzeek/clfq3gg99006z01rysx11hout', 
519					'mapbox://styles/andrewhan/clfq3j9k400ap01qj8epnpyew', 
520					'mapbox://styles/estebanphinehas/clfq3m2s0000q01pkzbreyhzc', 
521					'mapbox://styles/madisonjonathan/clfq3o8ml006901pbbwf3t8mz', 
522					'mapbox://styles/johnnymomooreoluwa/clfq3qkda000t01oy4s78bk5w', 
523					'mapbox://styles/joojoalisdair/clfq3ss03000g01mxo9g5jumx', 
524					'mapbox://styles/heiniantoni/clfq3uyji000e01n3fzuspprz', 
525					'mapbox://styles/morriskieran-scott/clfq3yahi00os01pbl5gpevus', 
526					'mapbox://styles/muhammedniki/clfq40gmn000h01mxmgvbp0ez', 
527					'mapbox://styles/karleren/clfq42jei004801o2dcty7nch', 
528					'mapbox://styles/radmirasala/clfq4qjbj006c01pgg8g1ctvb', 
529					'mapbox://styles/qasimnoorx/clfq4t0bs006d01lru3jdemhv', 
530					'mapbox://styles/garethnolan/clfq4vh9u007301ry8ynzpzis', 
531					'mapbox://styles/carldissanayake/clfq4yk0u006c01pb0bqda892', 
532					'mapbox://styles/kaelanabdirahman/clfq50zuv000s01pkv0m8ctrp', 
533					'mapbox://styles/tayyesweyn/clfq54ctg000001pmo12g2l0s', 
534					'mapbox://styles/glascottdan/clfq5eaeh006d01pb7icfjlkk', 
535					'mapbox://styles/denonreid/clfq5gmyk000f01nqsqa0bvqm', 
536					'mapbox://styles/turnercharley/clfq5itco00aq01qjq398hmfh', 
537					'mapbox://styles/umarroan/clfq5l3ym007501ryupars9up', 
538					'mapbox://styles/jean-pierrety/clfq5n57q004a01o2hjcrfur2', 
539					'mapbox://styles/ghyllzechariah/clfq5p4ks006e01pgkohbkk14', 
540					'mapbox://styles/danysdillon/clfq5re1d000001qevlse3u85', 
541					'mapbox://styles/alumcodey/clfq5tkyz00nt01nxp2bu7cie', 
542					'mapbox://styles/cooperarihant/clfq5vpz5006g01lrz03mrf2j', 
543					'mapbox://styles/oskarowain/clfq5ynsx00ov01pbgak6w2lf', 
544					'mapbox://styles/koushiklorne/clfq60oba009d01p9q50lfdvp', 
545					'mapbox://styles/drewdougal/clfq62pm300ar01qjul20vs35'
546			];
547
548			var randToken = Math.floor( Math.random() * fallbackMapboxTokens.length );
549
550			//randToken = 40;
551
552			mapboxToken = fallbackMapboxTokens[ randToken ];
553			listarLocalizeAndAjax.listarMapStyleURL = fallbackMapboxStyles[ randToken ].replace( 'mapbox://styles/', '' );
554			
555			osmUrl = urlProtocol + '://api.mapbox.com/styles/v1/' + listarLocalizeAndAjax.listarMapStyleURL + '/tiles/256/{z}/{x}/{y}
555?access_token=' + mapboxToken;
556			osmAttrib = '&copy; <a href="https://www.mapbox.com/about/maps/">Mapbox</a> &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <a href="https://www.mapbox.com/map-feedback/" target="_blank">' + listarLocalizeAndAjax.improveMap + '</a>';
557
558		}
559
560		setInterval( function () {
561			$( '.leaflet-control-attribution' ).each( function () {
562				$( this ).prop( 'innerHTML', osmAttrib );
563			} );
564		}, 2000 );
565
566		/* Initiate the map(s) if its container is visible on viewport after page load */
567		$( '.listar-map' ).each( function () {
568			if ( isInViewport( $( this ) ) ) {
569				leafletMapInit();
570			}
571		} );
572	}
573			
574	function restartMapPosition( mapPositionID ) {
575		if ( ! isRestartingMap && ! $( '.leaflet-pane.leaflet-tile-pane .leaflet-layer .leaflet-tile-container' ).length ) {
576			isRestartingMap = true;
577
578			var lastItemTitle = $( '.' + mapPositionID + ' .listar-aside-post-title' ).prop( 'innerHTML' );
579
580			//alert( lastItemTitle );
581
582			//alert( .length );
583
584			$( '#map' ).prop( 'outerHTML', '<div id="map" class="listar-map"><div class="listar-back-listing-button icon-arrow-left">Listing View</div></div>' );
585			//$( '.listar-aside-list' ).prop( 'outerHTML', '<div class="listar-aside-list"></div>' );
586
587			$( '.listar-aside-post, .listar-aside-list .listar-more-results' ).each( function () {
588				$( this ).prop( 'outerHTML', '' );
589			} );
590
591			startMapLeaflet();
592
593			var reclick = setInterval( function () {
594				if ( $( '.listar-aside-post-title' ).length ) {
595					$( '.listar-aside-post-title' ).each( function () {
596						if ( $( this ).prop( 'innerHTML' ) === lastItemTitle ) {
597							$( this ).parents( 'a' ).find( '.listar-aside-post-data' ).each( function () {
598								var itemClick = $( this );
599								var popAttempties = 4;
600
601								var popupDetection = setInterval( function () {
602									popAttempties--;
603
604									if ( ! $( '.leaflet-popup-content' ).length ) {
605										itemClick.trigger( 'mouseenter' );
606									} else {
607										clearInterval( popupDetection );
608									}
609
610									if ( 0 === popAttempties ) {
611										isRestartingMap = false;
612									}
613
614								}, 1500 ); 
615							} );
616
617							clearInterval( reclick );
618						}
619					} );
620				}				
621
622			}, 200 );
623
624			setTimeout( function () {
625				$( '#map' ).removeClass( 'listar-map-hidden' );
626			}, 3000 );
627		}
628	}
629
630	function preloadImages(array, waitForOtherResources, timeout) {
631		var loaded = false, list = preloadImages.list, imgs = array.slice(0), t = timeout || 15*1000, timer;
632		if (!preloadImages.list) {
633		    preloadImages.list = [];
634		}
635		if (!waitForOtherResources || document.readyState === 'complete') {
636		    loadNow();
637		} else {
638		    window.addEventListener("load", function() {
639			clearTimeout(timer);
640			loadNow();
641		    });
642		    // in case window.addEventListener doesn't get called (sometimes some resource gets stuck)
643		    // then preload the images anyway after some timeout time
644		    
645		    timer = setTimeout(loadNow, t);
646		}
647
648		function loadNow() {
649		    if (!loaded) {
650			loaded = true;
651			for (var i = 0; i < imgs.length; i++) {
652			    var img = new Image();
653			    img.onload = img.onerror = img.onabort = function() {
654				var index = list.indexOf(this);
655				if (index !== -1) {
656				    // remove image from the array once it's loaded
657				    // for memory consumption reasons
658				   // list.splice(index, 1);
659				}
660			    };
661			    //list.push(img);
662			    //img.src = imgs[i];
663			}
664		    }
665		}
666	    }
667
668	/* Detecting if Desktop or Mobile *************************** */
669
670	/* Reference: https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser */
671
672	function mobileAndTabletCheck() {
673		let mobileCheck = false;
674
675		( function( a ){
676			if( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test( a ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
676sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( a.substr(0,4 ) ) ) {
677				mobileCheck = true;
678			}
679		} )( navigator.userAgent || navigator.vendor || window.opera );
680
681		return mobileCheck;
682	}
683
684	function detectMobileByUserAgent() {
685		const toMatch = [
686		    /Mobi/i,
687		    /Android/i,
688		    /webOS/i,
689		    /iPhone/i,
690		    /iPad/i,
691		    /iPod/i,
692		    /BlackBerry/i,
693		    /PlayBook/i,
694		    /BB10/i,
695		    /Nexus/i,
696		    /Kindle Fire/i,
697		    /PalmSource|Palm/i,
698		    /Opera Mini/i,
699		    /Windows Phone/i,
700		    /WPDesktop/i,
701		    /IEMobile/i
702		];
703
704		return toMatch.some( detectMobileByUserAgent2 );
705	}
706
707	function detectMobileByUserAgent2( toMatchItem ) {
708		return navigator.userAgent.match( toMatchItem );
709	}
710
711	function detectMobileByTouch() {
712		return ( navigator.maxTouchPoints ) || ( ( 'ontouchstart' in document.documentElement ) && ( ( window.innerWidth <= 1024 ) && ( window.innerHeight <= 768 ) ) );
713	}
714
715	function detectMobileByWidth() {
716
717		// Any screen shorter than that will represent a mobile device */
718		return ( ( window.innerWidth <= 800 ) && ( window.innerHeight <= 600 ) );
719	}
720
721	/* Complex Kaimallea mobile detection */
722	/* Reference: https://github.com/kaimallea/isMobile/blob/master/src/isMobile.ts */
723
724	var appleIphone = /iPhone/i;
725	var appleIpod = /iPod/i;
726	var appleTablet = /iPad/i;
727	var appleUniversal = /\biOS-universal(?:.+)Mac\b/i;
728	var androidPhone = /\bAndroid(?:.+)Mobile\b/i;
729	var androidTablet = /Android/i;
730	var amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i;
731	var amazonTablet = /Silk/i;
732	var windowsPhone = /Windows Phone/i;
733	var windowsTablet = /\bWindows(?:.+)ARM\b/i;
734	var otherBlackBerry = /BlackBerry/i;
735	var otherBlackBerry10 = /BB10/i;
736	var otherOpera = /Opera Mini/i;
737	var otherChrome = /\b(CriOS|Chrome)(?:.+)Mobile/i;
738	var otherFirefox = /Mobile(?:.+)Firefox\b/i;
739
740	var isAppleTabletOnIos13Kaimallea = function ( navigator ) {
741		return ( typeof navigator !== 'undefined' &&
742			navigator.platform === 'MacIntel' &&
743			typeof navigator.maxTouchPoints === 'number' &&
744			navigator.maxTouchPoints > 1 &&
745			typeof MSStream === 'undefined' );
746	};
747
748	function createMatchKaimallea( userAgent ) {
749		return function ( regex ) {
750			return regex.test( userAgent );
751		};
752	}
753
754	function isMobileKaimallea( param ) {
755		var nav = {
756			userAgent: '',
757			platform: '',
758			maxTouchPoints: 0
759		};
760
761		if ( ! param && typeof navigator !== 'undefined' ) {
762			nav = {
763				userAgent: navigator.userAgent,
764				platform: navigator.platform,
765				maxTouchPoints: navigator.maxTouchPoints || 0
766			};
767		} else if ( typeof param === 'string' ) {
768			nav.userAgent = param;
769		} else if ( param && param.userAgent ) {
770			nav = {
771				userAgent: param.userAgent,
772				platform: param.platform,
773				maxTouchPoints: param.maxTouchPoints || 0
774			};
775		}
776
777		var userAgent = nav.userAgent;
778		var tmp = userAgent.split( '[FBAN' );
779
780		if ( typeof tmp[1] !== 'undefined' ) {
781			userAgent = tmp[0];
782		}
783
784		tmp = userAgent.split( 'Twitter' );
785
786		if ( typeof tmp[1] !== 'undefined' ) {
787			userAgent = tmp[0];
788		}
789
790		var match = createMatchKaimallea( userAgent );
791		var result = {
792			apple: {
793				phone: match( appleIphone ) && ! match( windowsPhone ),
794				ipod: match( appleIpod ),
795				tablet: ! match( appleIphone ) &&
796					( match( appleTablet ) || isAppleTabletOnIos13Kaimallea( nav ) ) &&
797					! match( windowsPhone ),
798				universal: match( appleUniversal ),
799				device: ( match( appleIphone ) ||
800					match( appleIpod ) ||
801					match( appleTablet ) ||
802					match( appleUniversal ) ||
803					isAppleTabletOnIos13Kaimallea( nav ) ) &&
804					! match( windowsPhone )
805			},
806			amazon: {
807				phone: match( amazonPhone ),
808				tablet: ! match( amazonPhone ) && match( amazonTablet ),
809				device: match( amazonPhone ) || match( amazonTablet )
810			},
811			android: {
812				phone: ( ! match( windowsPhone ) && match( amazonPhone ) ) ||
813					( ! match( windowsPhone ) && match( androidPhone ) ),
814				tablet: ! match( windowsPhone ) &&
815					! match( amazonPhone ) &&
816					! match( androidPhone ) &&
817					( match( amazonTablet ) || match( androidTablet ) ),
818				device: ( ! match( windowsPhone ) &&
819					( match( amazonPhone ) ||
820						match( amazonTablet ) ||
821						match( androidPhone ) ||
822						match( androidTablet ) ) ) ||
823					match( /\bokhttp\b/i )
824			},
825			windows: {
826				phone: match( windowsPhone ),
827				tablet: match( windowsTablet ),
828				device: match( windowsPhone ) || match( windowsTablet )
829			},
830			other: {
831				blackberry: match( otherBlackBerry ),
832				blackberry10: match( otherBlackBerry10 ),
833				opera: match( otherOpera ),
834				firefox: match( otherFirefox ),
835				chrome: match( otherChrome ),
836				device: match( otherBlackBerry ) ||
837					match( otherBlackBerry10 ) ||
838					match( otherOpera ) ||
839					match( otherFirefox ) ||
840					match( otherChrome )
841			},
842			any: false,
843			phone: false,
844			tablet: false
845		};
846
847		result.any =
848			result.apple.device ||
849			result.android.device ||
850			result.windows.device ||
851			result.other.device;
852
853		result.phone =
854			result.apple.phone || result.android.phone || result.windows.phone;
855
856		result.tablet =
857			result.apple.tablet || result.android.tablet || result.windows.tablet;
858
859		return result;
860	}
861
862	/* All detections options joined */
863
864	function isMobile() {
865		if ( detectMobileByWidth() ) {
866			return true;
867		} else if ( mobileAndTabletCheck() ) {
868			return true;
869		} else if ( detectMobileByTouch() ) {
870			return true;
871		} else if ( detectMobileByUserAgent() ) {
872			return true;
873		} else {
874			var isMobileKaimalleaCheck = isMobileKaimallea();
875
876			if ( isMobileKaimalleaCheck.any ) {
877				return true;
878			} else {
879				return false;
880			}
881		}
882	}
883	
884	// Remove all unwanted HTML tags (mainly <script>), except these.
885
886	function stripHTMLTags( _html ) {
887		var _tags = [ ], _tag = '';
888		for ( var _a = 1; _a < arguments.length; _a ++ )
889		{
890			_tag = arguments[_a].replace( /<|>/g, '' ).trim();
891			if ( arguments[_a].length > 0 )
892				_tags.push( _tag, '/' + _tag );
893		}
894
895		if ( ! ( typeof _html === 'string' ) && ! ( _html instanceof String ) )
896			return '';
897		else if ( _tags.length === 0 )
898			return _html.replace( /<(\s*\/?)[^>]+>/g, '' );
899		else
900		{
901			var _re = new RegExp( '<(?!(' + _tags.join( '|' ) + ')\s*\/?)[^>]+>', 'g' );
902			return _html.replace( _re, '' );
903		}
904	}
905	
906	// Seems to contain a URL.
907
908	function containURLPattern( string ) {
909		return string.indexOf( 'http://' ) >= 0 || string.indexOf( 'https://' ) >= 0 ? string : '';
910	}
911			
912	function extractContent( s ) {
913		var span = $( '<span>' + s + '</span>' );
914		var finalHTML = '';
915
916		span.find( '*' ).each( function () {
917			finalHTML += $( this ).prop( 'outerHTML' );
918		} );
919
920		return finalHTML;
921	}
922		
923	function richMediaFieldsetAppend( mediaValue ) {
924
925		// Create fieldset dynamic fieldset inputs.
926
927		var rand = Math.floor( ( Math.random() * 99999999 ) + 1 );
928
929		if ( 'string' !== typeof mediaValue ) {
930			mediaValue = '';
931		}
932
933		$( '.listar-business-rich-media-fields .listar-boxed-fields-inner-2' ).append( '<fieldset class="fieldset-company_business_rich_media fieldset-type-text listar-rich-media-fieldset"><label for="company_business_rich_media_value_' + rand + '">' + listarLocalizeAndAjax.mediaLinkOrCode + '</label><div class="field "><textarea class="input-text" name="company_business_rich_media_value_' + rand + '" id="company_business_rich_media_value_' + rand + '" >' + mediaValue + '</textarea><small class="description">' + listarLocalizeAndAjax.enterMediaValue + '</small></div></fieldset>' );
934	}
935
936	function getElementIndex( htmlMarkup ) {
937		return htmlInner.indexOf( htmlMarkup );
938	}
939
940	function checkNavbarToggle() {
941		if ( viewport().width > 767 && $( '.navbar-toggle' ).is( ':hidden' ) ) {
942			$( selected ).removeClass( 'listar-primary-navbar-mobile-visible' );
943		}
944	}
945
946	function tryParseJSON( jsonString ){
947
948		/* Reference: https://stackoverflow.com/a/20392392/7765298 */
949
950		try {
951			var o = JSON.parse( jsonString );
952
953			if ( o && typeof o === 'object' ) {
954				return o;
955			}
956		}
957		catch ( e ) {}
958
959		return false;
960	}
961		
962	function verifyBookingPopup() {
963		return $( '.listar-booking-slide' ).length > 0;
964	}
965
966	function launchBookingPopup() {
967		stopScrolling( 1 );
968		$( '.listar-booking-popup' ).addClass( 'listar-showing-booking' ).css( { left : 0, opacity : 1 } );
969	}
970
971	function firstUserEventHappened() {
972		if ( ! gotUpdatedNonce ) {
973			var countFeatures = 1;
974			var owlCarouselsStart = $( '.listar-carousel-loop.listar-use-carousel' );
975			var fixDelay = 600;
976
977			setTimeout( function () {
978				theDocument.off( 'touchstart touchmove scroll mouseenter mousedown mousemove DOMMouseScroll mousewheel keyup' );
979				theBody.removeClass( 'listar-not-loaded' );
980			
981				/* Optimization Mar 22 2021 */
982				
983				convertDataBackgroundImage();
984			}, fixDelay );
985
986			
987			gotUpdatedNonce = true;
988			
989			/*xxx6584*/
990			setInterval( function () {
991				
992				theBody.find( '[data-background-image]' ).each( function () {
993					if ( isInViewport( $( this ) ) ) {
994						convertDataBackgroundImage( $( this ) );
995					}
996				} );				
997
998				$( '.single-job_listing .listar-listing-header-topbar-wrapper.listar-show-all-topbar-buttons:not(.listar-listing-header-menu-fixed)' ).each( function () {
999					if ( isInViewport( $( this ) ) ) {
1000						$( '.listar-bookmark-button-fixed, .listar-operating-hours-quick-button-wrapper, .listar-booking-quick-button-wrapper' ).removeClass( 'listar-allow-visibility' );
1001					} else {
1002						$( '.listar-bookmark-button-fixed, .listar-operating-hours-quick-button-wrapper, .listar-booking-quick-button-wrapper' ).addClass( 'listar-allow-visibility' );
1003					}
1004				} );
1005
1006				if ( ! $( '.single-job_listing .listar-listing-header-topbar-wrapper.listar-show-all-topbar-buttons:not(.listar-listing-header-menu-fixed)' ).length ) {
1007					$( '.listar-bookmark-button-fixed, .listar-operating-hours-quick-button-wrapper, .listar-booking-quick-button-wrapper' ).removeClass( 'listar-allow-visibility' );
1008				}
1009
1010				if ( $( '.listar-load-card-content-ajax .listar-location-references-wrapper' ).length ) {
1011					$( '.listar-load-card-content-ajax' ).addClass( 'listar-cards-has-reference-row' );
1012				}
1013
1014				$( '.listar-load-card-content-ajax .listar-listing-card' ).not( '.listar-card-content-ajax-loading, .listar-card-content-ajax-loaded, .listar-grid-filler' ).each( function () {
1015					if ( isInViewport( $( this ) ) ) {
1016						$( this ).addClass( 'listar-card-content-ajax-loading' );
1017						loadListingCardContentAjax( $( this ) );
1018					}
1019				} );
1020
1021				$( '.listar-load-card-content-ajax' ).find( '.listar-grid-filler' ).each( function () {
1022					$( this ).addClass( 'listar-height-changed' );
1023				} );
1024
1025				if ( ! skipEmbedDtOptimization ) {
1026					dtTags = $( 'dt' );
1027				}
1028
1029				if ( ! skipEmbedDlOptimization ) {
1030					dlTags = $( 'dl' );
1031				}
1032
1033				if ( dtTags.length ) {
1034					dtTags.each( function () {
1035						if ( ! $( this )[0].hasAttribute( 'data-skip-tag' )  ) {
1036							if ( isInViewport( $( this ) )  ) {
1037								var tempOuterHTML = $( this ).prop( 'outerHTML' );
1038								var dtTagNames = [ 'param', 'source' ];
1039								var breakThis = false;
1040
1041								for ( var dt = 0; dt < dtTagNames.length; dt++ ) {
1042									if ( ! breakThis ) {
1043										var currentTagName = dtTagNames[ dt ];
1044
1045										if ( $( this )[0].hasAttribute( 'data-dynamic-embed-' + currentTagName ) ) {
1046											tempOuterHTML = tempOuterHTML.replace( '<dt', '<' + currentTagName );
1047											tempOuterHTML = tempOuterHTML.replace( '</dt', '</' + currentTagName );
1048											tempOuterHTML = tempOuterHTML.replace( 'data-dynamic-embed-' + currentTagName, 'data-skip-tag' );
1049											tempOuterHTML = tempOuterHTML.replace( /data-temp-/g, '' );
1050											$( this ).prop( 'outerHTML', tempOuterHTML );
1051											breakThis = true;
1052										}
1053									}
1054								}
1055							}
1056						}
1057					} );
1058				} else {
1059					skipEmbedDtOptimization = true;
1060				}
1061
1062				if ( dlTags.length ) {
1063					dlTags.each( function () {
1064						if ( ! $( this )[0].hasAttribute( 'data-skip-tag' ) ) {
1065							if ( isInViewport( $( this ) ) ) {
1066								var tempOuterHTML = $( this ).prop( 'outerHTML' );
1067								var dlTagNames = [ 'iframe', 'object', 'audio', 'audio', 'video' ];
1068								var breakThis = false;
1069
1070								for ( var dl = 0; dl < dlTagNames.length; dl++ ) {
1071									if ( ! breakThis ) {
1072										var currentTagName = dlTagNames[ dl ];
1073
1074										if ( $( this )[0].hasAttribute( 'data-dynamic-embed-' + currentTagName ) ) {
1075											tempOuterHTML = tempOuterHTML.replace( '<dl', '<' + currentTagName );
1076											tempOuterHTML = tempOuterHTML.replace( '</dl', '</' + currentTagName );
1077											tempOuterHTML = tempOuterHTML.replace( 'data-dynamic-embed-' + currentTagName, 'data-skip-tag' );
1078											tempOuterHTML = tempOuterHTML.replace( /data-temp-/g, '' );
1079											$( this ).prop( 'outerHTML', tempOuterHTML );
1080											breakThis = true;
1081										}
1082									}
1083								}
1084
1085								setTimeout( function () {
1086									if ( window.wp && window.wp.mediaelement ) {
1087										window.wp.mediaelement.initialize();
1088									}
1089
1090									equalizeVideoHeights();
1091								}, 50 );
1092							}
1093						}
1094					} );
1095				} else {
1096					skipEmbedDlOptimization = true;
1097				}
1098			}, 250 );
1099
1100			/*xxx 6782 */
1101
1102			/*xxx 7215 */
1103			setTimeout( function () {
1104				$( '#job_business_use_booking' ).each( function () {
1105					if ( $( this ).is( ':checked' ) ) {
1106						$( '.fieldset-job_business_bookings_third_party_service' ).css( { display : 'block' } );
1107					}
1108				} );
1109			}, 300 );
1110
1111
1112			/* Prepare wrapper for menu/catalog files - external */
1113			setTimeout( function () {
1114				$( '.fieldset-job_business_document_1_title_external' ).each( function () {
1115					var
1116						docsSection2 = $( this ),
1117						checkboxDoc = $( '.fieldset-job_business_use_catalog_external' ).prop( 'outerHTML' ),
1118						menuTitle1  = docsSection2,
1119						menuFile1   = menuTitle1.next(),
1120						menuTitle2  = menuFile1.next(),
1121						menuFile2   = menuTitle2.next(),
1122						menuTitle3  = menuFile2.next(),
1123						menuFile3   = menuTitle3.next(),
1124						menuTitle4  = menuFile3.next(),
1125						menuFile4   = menuTitle4.next(),
1126						menuTitle5  = menuFile4.next(),
1127						menuFile5   = menuTitle5.next(),
1128						menuTitle6  = menuFile5.next(),
1129						menuFile6   = menuTitle6.next();
1130
1131					var
1132						catalogsOutput =
1133							menuTitle1.prop( 'outerHTML' ) +
1134							menuFile1.prop( 'outerHTML' ) +
1135							menuTitle2.prop( 'outerHTML' ) +
1136							menuFile2.prop( 'outerHTML' ) +
1137							menuTitle3.prop( 'outerHTML' ) +
1138							menuFile3.prop( 'outerHTML' ) +
1139							menuTitle4.prop( 'outerHTML' ) +
1140							menuFile4.prop( 'outerHTML' ) +
1141							menuTitle5.prop( 'outerHTML' ) +
1142							menuFile5.prop( 'outerHTML' ) +
1143							menuTitle6.prop( 'outerHTML' ) +
1144							menuFile6.prop( 'outerHTML' );
1145
1146					docsSection2.before( '<div class="listar-business-catalog-fields listar-boxed-fields-docs-external hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
1147
1148					menuTitle1.prop( 'outerHTML', '' );
1149					menuFile1.prop( 'outerHTML', '' );
1150					menuTitle2.prop( 'outerHTML', '' );
1151					menuFile2.prop( 'outerHTML', '' );
1152					menuTitle3.prop( 'outerHTML', '' );
1153					menuFile3.prop( 'outerHTML', '' );
1154					menuTitle4.prop( 'outerHTML', '' );
1155					menuFile4.prop( 'outerHTML', '' );
1156					menuTitle5.prop( 'outerHTML', '' );
1157					menuFile5.prop( 'outerHTML', '' );
1158					menuTitle6.prop( 'outerHTML', '' );
1159					menuFile6.prop( 'outerHTML', '' );
1160
1161					$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-boxed-fields-inner' ).prop( 'innerHTML', catalogsOutput );
1162
1163					$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-boxed-fields-wrapper' ).prepend( '<div class="listar-catalog-files-header"></div>' );
1164
1165					$( '.fieldset-job_business_use_catalog_external' ).prop( 'outerHTML', '' );
1166
1167					$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-catalog-files-header' ).before( checkboxDoc );
1168
1169					setTimeout( function () {
1170						if ( $( '#job_business_use_catalog' ).is( ':checked' ) ) {
1171							$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external' ).removeClass( 'hidden' );
1172						}
1173
1174						if ( $( '#job_business_use_catalog_external' ).is( ':checked' ) ) {
1175							$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-boxed-fields-inner' ).removeClass( 'hidden' );
1176						}
1177					}, 100 );
1178
1179				} );
1180			}, 20 );
1181
1182			/*xxx 7913 */
1183			setTimeout( function () {
1184				$( '.listar-account-menu-item ul a' ).off( 'click' );
1185			}, 1200 );
1186
1187			/*xxx 8189 */
1188			setTimeout( function () {
1189				setTooltips();
1190			}, 1000 );
1191
1192
1193			/*xxx 8512 */
1194			setTimeout( function () {
1195				if ( false === preventEvenCallStack3 ) {
1196					preventEvenCallStack3 = true;
1197
1198					setTimeout( function () {
1199						$( '.select2-selection__rendered, .select2-selection__rendered li' ).each( function () {
1200							if ( $( this )[0].hasAttribute( 'title' ) ) {
1201								$( this ).attr( 'title', $.trim( $( this ).attr( 'title' ) ) );
1202							}
1203						} );
1204
1205						$( '.listar-custom-select' ).each( function () {
1206							var selectedCount = $( this ).find( 'option[selected]' );
1207							var mainClass = $( this ).attr( 'class' ).split( ' ' );
1208
1209							mainClass = mainClass[0];
1210
1211							if ( ! $( this ).hasClass( 'listar-search-sort-listings' ) && selectedCount.length ) {
1212								$( this ).attr( 'data-selected-count', selectedCount.length );
1213							}
1214
1215							$( this ).siblings( '.select2-container' ).find( '.select2-selection__choice__remove' ).each( function () {
1216								$( this ).addClass( '____' + mainClass );
1217							} );
1218						} );
1219					}, 20 );
1220				}
1221			}, 800 );
1222
1223			/*xxx 9824 */
1224			/* Replicate fixed header menu for single listing pages */
1225			setTimeout( function () {
1226				$( '.listar-listing-header-topbar-wrapper' ).each( function () {
1227					var listingHeaderMenu = $( this );
1228					var listingHeaderMenuClone = listingHeaderMenu.clone();
1229
1230					listingHeaderMenu.after( listingHeaderMenuClone.addClass( 'listar-listing-header-menu-fixed listar-hidden-fixed-button' ) );
1231				} );
1232			}, 1200 );
1233
1234			/*xxx 9833 */
1235			setTimeout( function () {
1236				var iconClass = 'icon-paperclip';
1237
1238				if ( $( 'article .post-password-form' ).length ) {
1239					iconClass = 'icon-lock';
1240				}
1241
1242				if ( theBody.hasClass( 'single-post' ) ) {
1243					if ( $( '.listar-single-content p.has-background[class*="fa fa-"], .listar-single-content p.has-background[class*="icon-"]' ).length ) {
1244						iconClass = $( '.listar-single-content p.has-background[class*="fa fa-"], .listar-single-content p.has-background[class*="icon-"]' ).eq( 0 ).attr( 'class' ).replace( / has-/g, ' ' );
1245					}
1246
1247					$( '.listar-page-header .listar-page-header-content' )
1248						.append( '<span class="listar-post-header-icon-1 listar-delay-effect ' + iconClass + '"></span>' )
1249						.append( '<span class="listar-post-header-icon-2 listar-delay-effect ' + iconClass + '"></span>' )
1250						.append( '<span class="listar-post-header-icon-3 listar-delay-effect ' + iconClass + '"></span>' )
1251						.append( '<span class="listar-post-header-icon-4 listar-delay-effect ' + iconClass + '"></span>' )
1252						.append( '<span class="listar-post-header-icon-5 listar-delay-effect ' + iconClass + '"></span>' );
1253
1254					$( '.listar-page-header .listar-page-header-content [class*="listar-post-header-icon-"]' )
1255						.removeClass( 'has-background' )
1256						.removeClass( 'has-text-color' );
1257
1258					setTimeout( function () {
1259						$( '.listar-post-header-icon-1' ).removeClass( 'listar-delay-effect' );
1260					}, 1600 );
1261
1262					setTimeout( function () {
1263						$( '.listar-post-header-icon-2' ).removeClass( 'listar-delay-effect' );
1264					}, 1900 );
1265
1266					setTimeout( function () {
1267						$( '.listar-post-header-icon-3' ).removeClass( 'listar-delay-effect' );
1268					}, 2200 );
1269
1270					setTimeout( function () {
1271						$( '.listar-post-header-icon-4' ).removeClass( 'listar-delay-effect' );
1272					}, 2500 );
1273
1274					setTimeout( function () {
1275						$( '.listar-post-header-icon-5' ).removeClass( 'listar-delay-effect' );
1276					}, 2800 );
1277				}
1278
1279			}, 1 );
1280
1281			/*xxx 10010 */
1282			setTimeout( function () {
1283				$( 'input[type="checkbox"]' ).each( function () {
1284					$( this ).parent().addClass( 'listar-custom-checkbox' );
1285
1286					if( $( this ).is( ':checked' ) ) {
1287						$( this ).parent().addClass( 'listar-custom-checkbox-checked' );
1288					}
1289				} );
1290			}, 1500 );
1291
1292			/*xxx 10020 */
1293			setTimeout( function () {
1294				var hasPhones = false;
1295
1296				$( '.job-manager-form #company_phone, .job-manager-form #company_fax, .job-manager-form #company_mobile, .job-manager-form #company_whatsapp' ).each( function () {
1297					if ( ! hasPhones ) {
1298						hasPhones = true;
1299
1300						var phoneFields = [];
1301						var fieldIndex = 0;
1302
1303						if ( $( '.job-manager-form #company_phone' ).length ) {
1304							phoneFields.push( '#company_phone' );
1305						}
1306
1307						if ( $( '.job-manager-form #company_fax' ).length ) {
1308							phoneFields.push( '#company_fax' );
1309						}
1310
1311						if ( $( '.job-manager-form #company_mobile' ).length ) {
1312							phoneFields.push( '#company_mobile' );
1313						}
1314
1315						if ( $( '.job-manager-form #company_whatsapp' ).length ) {
1316							phoneFields.push( '#company_whatsapp' );
1317						}
1318
1319						for ( fieldIndex = 0; fieldIndex < phoneFields.length; fieldIndex++ ) {
1320							var inputField = document.querySelector( phoneFields[ fieldIndex ] );
1321							var myUrlPattern = '.local';
1322							var siteHostname = window.location.hostname;
1323							var hostnameHasDot = siteHostname.indexOf( '.' ) >= 0 ? true : false;
1324
1325							if ( 'localhost' === siteHostname || '127.0.0.1' === siteHostname || siteHostname.indexOf( myUrlPattern ) >= 0 || '' === siteHostname || ! hostnameHasDot ) {
1326								window.intlTelInput( inputField, {
1327									initialCountry: listarSiteCountryCode,
1328									nationalMode: true,
1329									formatOnDisplay: true,
1330									autoPlaceholder: 'aggressive',
1331									preferredCountries: [ listarSiteCountryCode ],
1332									utilsScript: listarThemeURL + '/assets/lib/intl-tel-input/build/js/utils.js?' + Math.floor( ( Math.random() * 99999999 ) + 1 ) // Just for formatting/placeholders etc.
1333								} );
1334							} else {
1335								const tempJquery = $;
1336
1337								window.intlTelInput( inputField, {
1338									initialCountry: 'auto',
1339									nationalMode: true,
1340									formatOnDisplay: true,
1341									autoPlaceholder: 'aggressive',
1342									preferredCountries: [ listarSiteCountryCode ],
1343									geoIpLookup: function( callback ) {
1344										tempJquery.get( 'https://ipinfo.io', function() {}, 'jsonp' ).always( function( resp ) {
1345										      var countryCode = ( resp && resp.country ) ? resp.country : '';
1346										      callback( countryCode );
1347										} );
1348									},
1349									utilsScript: listarThemeURL + '/assets/lib/intl-tel-input/build/js/utils.js?' + Math.floor( ( Math.random() * 99999999 ) + 1 ) // Just for formatting/placeholders etc.
1350								} );
1351							}
1352						}
1353					}
1354				} );
1355			}, 1000 );
1356			
1357			/* End Optimization Mar 22 2021 */
1358			
1359			getUpdatedNonce();
1360
1361			$( '.listar-features-design-2 .listar-feature-item-title ' ).each( function () {
1362				$( this ).find( 'span' ).prepend( '<span>0' + countFeatures + '</span>' );
1363				$( this ).addClass( 'listar-feature-counter-added' );
1364				countFeatures++;
1365			} );
1366
1367			$( '.listar-listing-regions-popup, .listar-search-by-popup, .listar-report-popup, .listar-claim-popup, .listar-listing-categories-popup' ).each( function () {
1368				$( this ).addClass( 'listar-toggle-background-image' );
1369			} );
1370
1371			/* Move background image URL from 'data-background-image' attribute to 'background-image' for Call To Action widget if it has the wavy badge mask */
1372
1373			setTimeout( function () {
1374				$( '.listar-has-wavy-badge-mask [data-background-image]' ).each( function () {
1375					convertDataBackgroundImage( $( this ) );
1376				} );
1377			}, 10 );
1378
1379			startHeightEqualizer();
1380			updateOperatingHoursAndAvailability();
1381			setSmashBalloonImages();			
1382
1383			setTimeout( function () {
1384				initOwlCarousel( owlCarouselsStart, true );
1385			}, fixDelay );
1386
1387			startAfterFirstInteraction();
1388			termNameBigEffect();
1389		}
1390	}
1391
1392	function stopScrolling( action ) {
1393		if ( ! isMobile() ) {
1394			if ( ! theBody.hasClass( 'listar-showing-map' ) ) {
1395				if ( 1 === action ) {
1396					saveScrollPosition = false;
1397					theBody.addClass( 'listar-stop-scrolling' );
1398				} else {
1399					theBody.removeClass( 'listar-stop-scrolling' );
1400					htmlAndBody.stop().animate( { scrollTop : lastScrollPosition }, 1 );
1401					saveScrollPosition = true;
1402				}
1403			}
1404		} else {
1405			if ( ! theBody.hasClass( 'listar-showing-map' ) ) {
1406				if ( 1 === action ) {
1407					saveScrollPosition = false;
1408					setTimeout( function() {
1409						theBody.addClass( 'listar-stop-scrolling-mobile' );
1410					}, 500 );
1411				} else {
1412					theBody.removeClass( 'listar-stop-scrolling-mobile' );
1413					htmlAndBody.stop().animate( { scrollTop : lastScrollPosition }, 1 );
1414					saveScrollPosition = true;
1415				}
1416			}
1417		}
1418	}
1419
1420	function hideListingSearchMenu() {
1421		if ( ! isBrowsingSearchMenu && loadingClick ) {
1422			$( '.listar-search-popup .listar-hero-section-title' ).removeClass( 'listar-reduce-hero-title' );
1423			$( '.listar-listing-search-menu-wrapper' ).addClass( 'hidden' );
1424			$( '.listar-search-categories.listar-categories-fixed-bottom' ).removeClass( 'hidden' );
1425		}
1426	}
1427
1428	function checkScrolling() {
1429		if ( viewport().width > 767 ) {
1430			if ( '0px' === $( '#listar-primary-menu' ).css( 'left' ) ) {
1431				$( '.navbar-toggle' ).trigger( 'click' );
1432			}
1433		}
1434	}
1435
1436	function resetAccordionPropagation() {
1437		setTimeout( function () {
1438			cancelAccordionPropagation = false;
1439		}, 10 );
1440	}
1441
1442	function validHexColor( color ){
1443		var $div = $( '<div>' );
1444		$div.css( 'border', '1px solid ' + color );
1445		return ( '' !== $div.css( 'border-color' ) );
1446	}
1447
1448	function headerTopbarDistance( ignoreHeadmenu ) {
1449		var
1450			distance = 0,
1451			adminBar = $( '#wpadminbar' );
1452
1453		if ( 'undefined' === typeof ignoreHeadmenu ) {
1454			distance = headMenu.height();
1455
1456			if ( distance < 74 ) {
1457				distance = 74;
1458			}
1459		}
1460
1461		if ( adminBar.length ) {
1462			distance += adminBar.height();
1463		}
1464
1465		return distance;
1466	}
1467
1468	function toggleCheckboxDependantField( checkField, dependant, hideParent ) {
1469		$( checkField ).each( function () {
1470			dependant = true === hideParent ? $( dependant ).parent() : $( dependant );
1471
1472			if ( $( this ).is( ':checked' ) ) {
1473				dependant.removeClass( 'hidden' );
1474			} else {
1475				dependant.addClass( 'hidden' );
1476			}
1477		} );
1478	}
1479
1480	function selectClaimPackage() {
1481		window.location.replace( '' );
1482		window.location.replace( currentURL + '&claim_package_id=' + currentClaimPackageID );
1483		return false;
1484	}
1485
1486	// Add/Remove listings from user Bookmarks list
1487	function handleBookmarks( callerButton, bookmarkListingID, bookmarkUserID, bookmarkAction = 'add'  ) {
1488
1489		callerButton.addClass( 'listar-bookmark-loading' );
1490
1491		var theAjaxURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/bookmark-ajax.php';
1492		var dataToSend = { send_data : '[{"type":"' + bookmarkAction + '"},{"id":"' + bookmarkListingID + '"},{"user":"' + bookmarkUserID + '"}]' };
1493
1494		$.ajax( {
1495			crossDomain: true,
1496			url: theAjaxURL,
1497			type: 'POST',
1498			data: dataToSend,
1499			cache    : false,
1500			timeout  : 30000
1501
1502		} ).done( function ( response ) {
1503			callerButton.removeClass( 'listar-bookmark-loading' );
1504
1505			if ( response && 'string' === typeof response ) {
1506				if ( response.indexOf( 'Done!' ) >= 0 ) {
1507					var bookmarkCounter = parseInt( callerButton.siblings( '.listar-bookmark-counter' ).attr( 'data-bookmark-counter' ), 10 );
1508
1509					if ( 'add' === bookmarkAction ) {
1510						bookmarkCounter++;
1511						callerButton.parent().addClass( 'listar-bookmarked-item' );
1512					} else {
1513						bookmarkCounter--;
1514						callerButton.parent().removeClass( 'listar-bookmarked-item' );
1515					}
1516
1517					callerButton.siblings( '.listar-bookmark-counter' ).attr( 'data-bookmark-counter', bookmarkCounter );
1518					callerButton.siblings( '.listar-bookmark-counter' ).prop( 'innerHTML', bookmarkCounter );
1519				}
1520			}
1521		} );
1522	}
1523
1524	// Get detailed data for geolocated coordinates.
1525	function saveGeolocationDetails( latitude, longitude, address, number, region, country, geolocationType ) {
1526
1527		// geolocationType: address-save, address-edit-save.
1528
1529		if (
1530			! 'string' === typeof address ||
1531			! 'string' === typeof region ||
1532			! 'string' === typeof country ||
1533
1534			'' === address ||
1535			'' === region ||
1536			'' === country
1537		) {
1538			return impossibleGeolocation( '', '' );
1539		}
1540
1541		var saveNearestMe = isNearestMeReload ? 'save' : '';
1542		var theAjaxURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/geolocate-data.php';
1543		var dataToSend = ',{"data-order-1":"' + address + ' ' + number + ' ' + region + ' ' + country + '"}';
1544		dataToSend = { send_data : '[{"type":"' + geolocationType + '"},{"latitude":"' + latitude + '"},{"longitude":"' + longitude + '"},{"saveNearestMe":"' + saveNearestMe + '"}' + dataToSend + ']' };
1545
1546		$.ajax( {
1547			crossDomain: true,
1548			url: theAjaxURL,
1549			type: 'POST',
1550			data: dataToSend,
1551			cache    : false,
1552			timeout  : 30000
1553
1554		} ).done( function ( response ) {
1555			if ( response ) {
1556				var data = $.parseJSON( response );
1557				var tempConfirm = false;
1558
1559				if ( 'reset' === geolocationType ) {
1560				} else {
1561					$.each( data, function() {
1562						if (
1563							'string' !== typeof this.lat && '' !== this.lat &&
1564							'string' !== typeof this.lng && '' !== this.lng
1565						) {
1566							tempConfirm = true;
1567						}
1568					} );
1569
1570					if ( tempConfirm ) {
1571
1572						var newExploreByClass = 'listar-search-by-button fa fa-scrubber';
1573						var newExploreByPlaceholder = $( '.listar-general-explore-by-options a[data-explore-by-type="nearest_me"]' ).attr( 'data-explore-by-placeholder' );
1574						var newExploreByTitle = $( '.listar-general-explore-by-options a[data-explore-by-type="nearest_me"]' ).attr( 'data-explore-by-title' );
1575						var newExploreBySlug = $( '.listar-general-explore-by-options a[data-explore-by-type="nearest_me"]' ).attr( 'data-explore-by-type' );
1576						var newExploreByOrder = $( '.listar-general-explore-by-options a[data-explore-by-type="nearest_me"]' ).attr( 'data-explore-by-order' );
1577
1578						$( '.listar-search-by-button' ).attr( 'class', newExploreByClass ).attr( 'data-explore-by-type', newExploreBySlug );
1579
1580						$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( newExploreByOrder );
1581						$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( newExploreBySlug );
1582						$( '.listar-listing-search-input-field' ).attr( 'placeholder', newExploreByPlaceholder );
1583						$( '.listar-current-search-by' ).prop( 'innerHTML', newExploreByTitle );
1584
1585						$( '.listar-search-by-popup .listar-back-site' )[0].click();
1586
1587						if ( isNearestMeReload ) {
1588							var href = currentURL;
1589
1590							if ( href.indexOf( 'explore_by' ) ) {
1591								var urlParams = new URLSearchParams( window.location.search );
1592								var exploreByParam = urlParams.get( 'explore_by' );
1593								var listingSortParam = urlParams.get( 'listing_sort' );
1594
1595								href = href.replace( 'listing_sort=' + listingSortParam, 'listing_sort=nearest_me'  );
1596								href = href.replace( 'explore_by=' + exploreByParam, 'explore_by=nearest_me'  );
1597							}
1598
1599							if ( href.indexOf( '#' ) >=0 ) {
1600								href = href.split( '#' );
1601								href = href[0];
1602							}
1603
1604							if ( -1 === href.indexOf( '?' ) ) {
1605								href = href + '?near=';
1606							}
1607
1608							nearestHash = "#" + nearestHash;
1609
1610							window.location.replace( '' );
1611							window.location.replace( href + nearestHash );
1612						} else {
1613							$( '.listar-hero-search-wrapper .search-form' ).submit();
1614						}
1615
1616					} else {
1617						impossibleGeolocation( region, country );
1618					}
1619				}
1620			} else {
1621				impossibleGeolocation( region, country );
1622			}
1623		} ).fail( function( response ) {
1624			impossibleGeolocation( region, country );
1625		} );
1626	}
1627
1628	function featuredListingCategorySelect( currentSelected ) {
1629
1630		currentSelected = 'string' === typeof currentSelected ? currentSelected : '';
1631
1632		setTimeout( function () {
1633			$( '#job_category' ).each( function () {
1634				var outerSelectCategories = $( this ).prop( 'outerHTML' );
1635				var hasFoundSelected = false;
1636				outerSelectCategories = outerSelectCategories.replace( /job_category/g, 'featured_job_category' ).replace( /&nbsp;/g, '' );
1637
1638				var selectedCats = $( "#job_category" ).val();
1639
1640				$( '.listar-featured-job-categories' ).each( function () {
1641					$( '#featured_job_category[data-select2-id]' ).each( function () {
1642						var hasSelect2 = true;
1643
1644						try {
1645							$( this ).select2( '' );
1646						} catch( err ) {
1647							// No Select2 in the element
1648							hasSelect2 = false;
1649						}
1650
1651						if ( hasSelect2 ) {
1652							$( this ).siblings( '.select2' ).prop( 'outerHTML', '' );
1653							$( this ).select2( 'destroy' ).removeAttr( 'data-select2-id' );
1654
1655								$( this ).find( 'option' ).each( function () {
1656									$( this ).removeAttr( 'data-select2-id' );
1657								} );
1658						}
1659
1660						currentSelected = $( this ).val();
1661
1662						$( this ).prop( 'outerHTML', '' );
1663					} );
1664
1665					$( this ).prop( 'outerHTML', '' );
1666				} );
1667
1668				if ( null !== selectedCats ) {
1669					if ( 'object' === typeof selectedCats ) {
1670						var countSelectedCats = Object.keys( selectedCats ).length;
1671
1672						if ( countSelectedCats > 1 ) {
1673
1674							if ( $( ".fieldset-job_category" ).length ) {
1675								$( '.fieldset-job_category' ).after( '<fieldset class="fieldset-job_featured_category fieldset-type-term-multiselect listar-featured-job-categories"><label for="job_category_featured">' + listarLocalizeAndAjax.featuredCategory + '</label><div class="field">' + outerSelectCategories + '</div></fieldset>' );
1676							}
1677
1678							$( '#featured_job_category' ).removeAttr( 'multiple' ).removeAttr( 'data-multiple_text' ).removeAttr( 'data-select2-id' ).removeAttr( 'data-no_results_text' ).removeClass( 'select2-hidden-accessible job-manager-category-dropdown' );
1679
1680							var selectedCatsAsArray = [];
1681
1682							Object.keys( selectedCats ).forEach( function( key ) {
1683								selectedCatsAsArray.push( selectedCats[key] );
1684							} );
1685
1686							$( '#featured_job_category option' ).each( function () {
1687								var testCategoryID = $( this ).attr( 'value' );
1688
1689								if ( -1 === selectedCatsAsArray.indexOf( testCategoryID ) ) {
1690									$( this ).prop( 'outerHTML', '' );
1691								} else {
1692									$( this ).removeAttr( 'data-select2-id' ).removeAttr( 'class' );
1693
1694									if ( currentSelected === $( this ).attr( 'value' ) ) {
1695										$( '#company_featured_listing_category' ).val( currentSelected );
1696										$( '#featured_job_category' ).val( currentSelected );
1697										$( this ).attr( 'selected', 'selected' );
1698
1699										hasFoundSelected = true;
1700									} else {
1701										$( this ).removeAttr( 'selected' );
1702									}
1703								}
1704							} );
1705
1706							if ( ! $( '#featured_job_category option' ).length ) {
1707								$( '#featured_job_category' ).prop( 'outerHTML', '' );
1708							}
1709
1710							if ( ! hasFoundSelected ) {
1711								$( '#company_featured_listing_category' ).val( '' );
1712							}
1713
1714							$( '#featured_job_category' ).select2( {
1715								minimumResultsForSearch: -1
1716							} );
1717						} else {
1718                                                        $( '#company_featured_listing_category' ).val( '' );
1719                                                }
1720					}
1721				}
1722			} );
1723
1724			setTimeout( function () {
1725				$( '.job-manager-category-dropdown' ).each( function () {
1726					$( this ).siblings( '.select2' ).find( 'input[class="select2-search__field"]' ).each( function () {
1727						$( this ).attr( 'autocomplete', 'new-password' );
1728					} );
1729				} );
1730			}, 50 );
1731		}, 50 );
1732	}
1733
1734	function featuredListingRegionSelect( currentSelected ) {
1735
1736		if ( multipleRegionsActive ) {
1737			currentSelected = 'string' === typeof currentSelected ? currentSelected : '';
1738
1739			setTimeout( function () {
1740				$( '#job_region' ).each( function () {
1741					var outerSelectRegions = $( this ).prop( 'outerHTML' );
1742					var hasFoundSelected = false;
1743					outerSelectRegions = outerSelectRegions.replace( /job_region/g, 'featured_job_region' ).replace( /&nbsp;/g, '' );
1744
1745					var selectedRegs = $( "#job_region" ).val();
1746
1747					$( '.listar-featured-job-regions' ).each( function () {
1748						$( '#featured_job_region[data-select2-id]' ).each( function () {
1749							var hasSelect2 = true;
1750
1751							try {
1752								$( this ).select2( '' );
1753							} catch( err ) {
1754								// No Select2 in the element
1755								hasSelect2 = false;
1756							}
1757
1758							if ( hasSelect2 ) {
1759								$( this ).siblings( '.select2' ).prop( 'outerHTML', '' );
1760								$( this ).select2( 'destroy' ).removeAttr( 'data-select2-id' );
1761
1762								$( this ).find( 'option' ).each( function () {
1763									$( this ).removeAttr( 'data-select2-id' );
1764								} );
1765							}
1766
1767							currentSelected = $( this ).val();
1768
1769							$( this ).prop( 'outerHTML', '' );
1770						} );
1771
1772						$( this ).prop( 'outerHTML', '' );
1773					} );
1774
1775					if ( null !== selectedRegs ) {
1776						if ( 'object' === typeof selectedRegs ) {
1777							var countSelectedRegs = Object.keys( selectedRegs ).length;
1778
1779							if ( countSelectedRegs > 1 ) {
1780
1781								if ( $( ".fieldset-job_region" ).length ) {
1782									$( '.fieldset-job_region' ).after( '<fieldset class="fieldset-job_featured_region fieldset-type-term-multiselect listar-featured-job-regions"><label for="job_region_featured">' + listarLocalizeAndAjax.featuredRegion + '</label><div class="field">' + outerSelectRegions + '</div></fieldset>' );
1783								}
1784
1785								$( '#featured_job_region' ).removeAttr( 'multiple' ).removeAttr( 'data-multiple_text' ).removeAttr( 'data-select2-id' ).removeAttr( 'data-no_results_text' ).removeClass( 'select2-hidden-accessible job-manager-region-dropdown' );
1786
1787								var selectedRegsAsArray = [];
1788
1789								Object.keys( selectedRegs ).forEach( function( key ) {
1790									selectedRegsAsArray.push( selectedRegs[key] );
1791								} );
1792
1793								$( '#featured_job_region option' ).each( function () {
1794									var testRegionID = $( this ).attr( 'value' );
1795
1796									if ( -1 === selectedRegsAsArray.indexOf( testRegionID ) ) {
1797										$( this ).prop( 'outerHTML', '' );
1798									} else {
1799										$( this ).removeAttr( 'data-select2-id' ).removeAttr( 'class' );
1800
1801										if ( currentSelected === $( this ).attr( 'value' ) ) {
1802											$( '#company_featured_listing_region' ).val( currentSelected );
1803											$( '#featured_job_region' ).val( currentSelected );
1804											$( this ).attr( 'selected', 'selected' );
1805
1806											hasFoundSelected = true;
1807										} else {
1808											$( this ).removeAttr( 'selected' );
1809										}
1810									}
1811								} );
1812
1813								if ( ! $( '#featured_job_region option' ).length ) {
1814									$( '#featured_job_region' ).prop( 'outerHTML', '' );
1815								}
1816
1817								if ( ! hasFoundSelected ) {
1818									$( '#company_featured_listing_region' ).val( '' );
1819								}
1820
1821								$( '#featured_job_region' ).select2( {
1822									minimumResultsForSearch: -1
1823								} );
1824							} else {
1825                                                                $( '#company_featured_listing_region' ).val( '' );
1826                                                        }
1827						}
1828					}
1829				} );
1830
1831				setTimeout( function () {
1832					$( '.job-manager-category-dropdown' ).each( function () {
1833						$( this ).siblings( '.select2' ).find( 'input[class="select2-search__field"]' ).each( function () {
1834							$( this ).attr( 'autocomplete', 'new-password' );
1835						} );
1836					} );
1837				}, 50 );
1838			}, 50 );
1839		}
1840	}
1841
1842	function ajaxCleanOldSerchResults() {
1843		$( '.listar-ajax-search li' ).not( '.listar-searching-ajax-results-item' ).each( function () {
1844			$( this ).prop( 'outerHTML', '' );
1845		} );
1846	}
1847
1848	function ajaxSerchingResults() {
1849		$( '.listar-ajax-search' ).removeClass( 'hidden' ).addClass( 'listar-showing-ajax-search' );
1850
1851		$( '.listar-searching-string, .listar-loading-string' ).each( function () {
1852			$( this ).prop( 'innerHTML', $( this ).attr( 'data-searching' ) );
1853		} );
1854
1855		ajaxCleanOldSerchResults();
1856
1857		$( '.listar-searching-ajax-results .listar-cat-icon' ).each( function () {
1858			var notFoundClasses = $( this ).attr( 'data-not-found' );
1859			var searchingClasses = $( this ).attr( 'data-searching' );
1860
1861			$( this ).removeClass( notFoundClasses ).addClass( searchingClasses );
1862		} );
1863
1864		$( '.listar-ajax-search' ).removeClass( 'listar-ajax-search-found-results' );
1865	}
1866
1867	function ajaxSerchNoResults() {
1868		$( '.listar-searching-ajax-results .listar-cat-icon' ).each( function () {
1869			var notFoundClasses = $( this ).attr( 'data-not-found' );
1870			var searchingClasses = $( this ).attr( 'data-searching' );
1871
1872			$( this ).removeClass( searchingClasses ).addClass( notFoundClasses );
1873		} );
1874
1875		$( '.listar-searching-string, .listar-loading-string' ).each( function () {
1876			$( this ).prop( 'innerHTML', $( this ).attr( 'data-not-found' ) );
1877		} );
1878
1879		ajaxCleanOldSerchResults();
1880
1881		$( '.listar-ajax-search' ).removeClass( 'listar-ajax-search-found-results' );
1882	}
1883
1884	function unhideSearchMenu() {
1885		$( '.listar-ajax-search' ).addClass( 'hidden' ).removeClass( 'listar-showing-ajax-search' );
1886	}
1887
1888	// Submit claim verification text.
1889	function sendClaimVerificationText() {
1890
1891		var claimTextForm = $( '#listar-claim-form' );
1892
1893		var theAjaxURL = claimTextForm.attr( 'action' );
1894		var dataToSend = { send_data : '[{"text":"' + encodeURIComponent( claimTextForm.find( 'textarea' ).val() ) + '"},{"nonce":"' + claimTextForm.find( '#listar-claim-security' ).val() + '"}]' };
1895
1896		$.ajax( {
1897			crossDomain: true,
1898			url: theAjaxURL,
1899			type: 'POST',
1900			data: dataToSend,
1901			cache    : false,
1902			timeout  : 30000
1903
1904		} ).done( function ( response ) {
1905			if ( 'string' === typeof response ) {
1906				if ( -1 !== response.indexOf( 'listar-valid-ajax-process-completed' ) ) {
1907					selectClaimPackage();
1908
1909					// Make sure that the form has the 'sent-success' class.
1910					claimTextForm.parent().removeClass( 'sent-error' );
1911					claimTextForm.parent().addClass( 'sent-success' );
1912				} else {
1913
1914					// Make sure that the form has the 'sent-error' class.
1915					claimTextForm.parent().removeClass( 'sent-success' );
1916					claimTextForm.parent().addClass( 'sent-error' );
1917
1918					$( 'button[data-loading-text]' ).prop( 'innerHTML', $( this ).attr( 'data-button-text' ) );
1919				}
1920			} else {
1921
1922				// Make sure that the form has the 'sent-error' class.
1923				claimTextForm.parent().removeClass( 'sent-success' );
1924				claimTextForm.parent().addClass( 'sent-error' );
1925
1926				$( 'button[data-loading-text]' ).prop( 'innerHTML', $( this ).attr( 'data-button-text' ) );
1927			}
1928		} ).fail( function() {
1929
1930			// Make sure that the form has the 'sent-error' class.
1931			claimTextForm.parent().removeClass( 'sent-success' );
1932			claimTextForm.parent().addClass( 'sent-error' );
1933
1934			$( 'button[data-loading-text]' ).prop( 'innerHTML', $( this ).attr( 'data-button-text' ) );
1935		} );
1936	}
1937
1938	myScaleFunction = debounce( function () {
1939		scaleHeader();
1940	}, 2050 );
1941
1942	function termNameBigEffect() {
1943		if ( ( ! isMobile() || ( theBody.hasClass( 'listar-force-big-text-category' ) || theBody.hasClass( 'listar-force-big-text-region' ) ) ) && theBody.find( '.listar-term-name-big' ).length > 0 && theBody.attr( 'class' ).indexOf( 'listar-enable-big-text-' ) >= 0 ) {
1944			myScaleFunction();
1945			window.addEventListener( 'resize', myScaleFunction );
1946		}
1947	}
1948
1949	function populateTermPopups( $popup ) {
1950		if ( 'categories' === $popup ) {
1951
1952			/*
1953			 * Populate the 'listing categories' popup with listing categories from hero header.
1954			 * Make it with JavaScript to avoid duplicated WP_Query.
1955			 */
1956			$( '.listar-search-categories .listar-listing-categories' ).each( function () {
1957				var terms = $( this ).find( '.listar-listing-category-link' );
1958
1959				terms.each( function () {
1960					var term = $( this );
1961
1962					var termURL = term.attr( 'href' ),
1963						termId = term.attr( 'data-term-id' ),
1964						termColor = term.attr( 'data-term-color' ),
1965						termGradientOverlay = term.attr( 'data-gradient-background' ),
1966						termImage = term.attr( 'data-term-image' ),
1967						termIcon = term.find( '.listar-category-icon-wrapper span' ),
1968						termIconContent,
1969						termName = term.attr( 'data-term-name' ),
1970						termDescription = term.attr( 'data-term-description' ),
1971						termCount = term.attr( 'data-term-count' ),
1972						termCountHover = term.attr( 'data-term-count-hover' );
1973
1974					if ( termIcon.length ) {
1975						termIconContent = termIcon.prop( 'innerHTML' );
1976					} else {
1977						termIcon = '';
1978					}
1979
1980					$( '.listar-listing-categories-popup .listar-term-items' ).each( function () {
1981						var popup = $( this ),
1982							buildTerm = '';
1983
1984						popup.append( '<div class="listar-featured-listing-term-item listar-term-bordered col-xs-12 col-sm-6 col-md-4 listar-build-term"><div class="listar-term-wrapper"></div></div>' );
1985
1986						buildTerm = popup.find( '.listar-build-term .listar-term-wrapper' );
1987
1988						buildTerm
1989							.append( '<a class="listar-term-link listar-hoverable-overlay" href="' + termURL + '"></a>' )
1990							.append( '<div class="listar-term-3d-effect-wrapper"></div>' );
1991
1992						buildTerm.find( '.listar-term-3d-effect-wrapper' )
1993							.append( '<div class="listar-term-inner"></div>' )
1994							.append( '<div class="listar-term-count-hover"></div>' );
1995
1996						buildTerm.find( '.listar-term-count-hover' )
1997							.append( termCountHover );
1998
1999						if ( '' !== termIcon ) {
2000							buildTerm.find( '.listar-term-inner' ).append( '<div class="listar-cat-icon" style="background-color:rgb(' + termColor + ');"></div>' );
2001
2002							buildTerm.find( '.listar-cat-icon' ).addClass( termIcon.attr( 'class' ) );
2003							buildTerm.find( '.listar-cat-icon' ).prop( 'innerHTML', termIconContent );
2004						}
2005
2006						buildTerm.find( '.listar-term-inner' )
2007							.append( '<div class="listar-term-data-wrapper"></div>' )
2008							.append( '<div class="listar-term-counter" style="background-color:rgb(' + termColor + ');"></div>' );
2009
2010						buildTerm.find( 'a' )
2011							.attr( 'data-term-id', termId );
2012
2013						buildTerm.find( '.listar-term-data-wrapper' )
2014							.append( '<div class="listar-term-overlay" style="background-color:rgba(' + termColor + ',0.7);"></div>' )
2015							.append( '<div class="listar-gradient-overlay" style="' + termGradientOverlay + '"></div>' )
2016							.append( '<div class="listar-listing-term-image listar-term-on-popup" data-background-image="' + termImage + '"></div>' )
2017							.append( '<div class="listar-term-background-overlay" style="background-color:rgb(' + termColor + ');box-shadow: 5px 5px rgb(' + termColor + ');"></div>' )
2018							.append( '<div class="listar-lateral-padding listar-term-text-wrapper"><div class="listar-term-text listar-ribbon">' + termName + '</div></div>' );
2019
2020						buildTerm.find( '.listar-term-text-wrapper' )
2021							.append( '<div class="listar-term-name-big"><span>' + termName + '</span></div>' );
2022
2023						if ( '' !== termDescription && viewport().width >= 378 ) {
2024							buildTerm.find( '.listar-term-text-wrapper' ).append( '<div class="listar-term-description">' + termDescription + '</div>' );
2025						}
2026
2027						buildTerm.find( '.listar-term-counter' )
2028							.append( termCount );
2029
2030						buildTerm.parent().removeClass( 'listar-build-term' );
2031
2032						return false;
2033					} );
2034				} );
2035
2036				return false;
2037			} );
2038
2039		}
2040
2041		if ( 'regions' === $popup ) {
2042
2043			/*
2044			 * Populate the 'listing regions' popup with listing regions from hero header.
2045			 * Make it with JavaScript to avoid duplicated WP_Query.
2046			 */
2047			$( '.listar-search-regions .listar-regions-list' ).each( function () {
2048				var terms = $( this ).find( '.listar-listing-region-link' );
2049
2050				terms.each( function () {
2051					var term = $( this );
2052
2053					var termURL = term.attr( 'href' ),
2054						termId = term.attr( 'data-term-id' ),
2055						termColor = term.attr( 'data-term-color' ),
2056						termGradientOverlay = term.attr( 'data-gradient-background' ),
2057						termImage = term.attr( 'data-term-image' ),
2058						termName = term.attr( 'data-term-name' ),
2059						termDescription = term.attr( 'data-term-description' ),
2060						termCount = term.attr( 'data-term-count' ),
2061						termCountHover = term.attr( 'data-term-count-hover' );
2062
2063					$( '.listar-listing-regions-popup .listar-term-items' ).each( function () {
2064						var popup = $( this ),
2065							buildTerm = '';
2066
2067						popup.append( '<div class="listar-featured-listing-term-item listar-term-bordered col-xs-12 col-sm-6 col-md-4 listar-build-term"><div class="listar-term-wrapper"></div></div>' );
2068
2069						buildTerm = popup.find( '.listar-build-term .listar-term-wrapper' );
2070
2071						buildTerm
2072							.append( '<a class="listar-term-link listar-hoverable-overlay" href="' + termURL + '"></a>' )
2073							.append( '<div class="listar-term-3d-effect-wrapper"></div>' );
2074
2075						buildTerm.find( '.listar-term-3d-effect-wrapper' )
2076							.append( '<div class="listar-term-inner"></div>' )
2077							.append( '<div class="listar-term-count-hover"></div>' );
2078
2079						buildTerm.find( '.listar-term-count-hover' )
2080							.append( termCountHover );
2081
2082						buildTerm.find( '.listar-term-inner' )
2083							.append( '<div class="listar-term-data-wrapper"></div>' )
2084							.append( '<div class="listar-term-counter" style="background-color:rgb(' + termColor + ');"></div>' );
2085
2086						buildTerm.find( 'a' )
2087							.attr( 'data-term-id', termId )
2088							.attr( 'data-term-name', termName );
2089
2090						buildTerm.find( '.listar-term-data-wrapper' )
2091							.append( '<div class="listar-term-overlay" style="background-color:rgba(' + termColor + ',0.7);"></div>' )
2092							.append( '<div class="listar-gradient-overlay" style="' + termGradientOverlay + '"></div>' )
2093							.append( '<div class="listar-listing-term-image listar-term-on-popup" data-background-image="' + termImage + '"></div>' )
2094							.append( '<div class="listar-term-background-overlay" style="background-color:rgb(' + termColor + ');box-shadow: 5px 5px rgb(' + termColor + ');"></div>' )
2095							.append( '<div class="listar-lateral-padding listar-term-text-wrapper"><div class="listar-term-text listar-ribbon">' + termName + '</div></div>' );
2096
2097						buildTerm.find( '.listar-term-text-wrapper' )
2098							.append( '<div class="listar-term-name-big"><span>' + termName + '</span></div>' );
2099
2100						if ( '' !== termDescription && viewport().width >= 378 ) {
2101							buildTerm.find( '.listar-term-text-wrapper' ).append( '<div class="listar-term-description">' + termDescription + '</div>' );
2102						}
2103
2104						buildTerm.find( '.listar-term-counter' )
2105							.append( termCount );
2106
2107						buildTerm.parent().removeClass( 'listar-build-term' );
2108
2109						return false;
2110					} );
2111				} );
2112
2113				return false;
2114			} );
2115
2116		}
2117
2118		termNameBigEffect();
2119	}
2120
2121	function unpopulateTermPopups( $popup ) {
2122		if ( 'categories' === $popup ) {
2123			$( '.listar-listing-categories-popup .listar-term-items' ).each( function () {
2124				$( this ).prop( 'innerHTML', '' );
2125			} );
2126		}
2127
2128		if ( 'regions' === $popup ) {
2129			$( '.listar-listing-regions-popup .listar-term-items' ).each( function () {
2130				$( this ).prop( 'innerHTML', '' );
2131			} );
2132		}
2133	}
2134
2135	function hasPriceListItems() {
2136		if ( $( '.listar-price-item[data-visibility="true"]' ).length ) {
2137			$( '.listar-price-builder-items-wrapper' ).addClass( 'listar-builder-has-price-itens' );
2138		} else {
2139			$( '.listar-price-builder-items-wrapper' ).removeClass( 'listar-builder-has-price-itens' );
2140		}
2141	}
2142
2143
2144
2145                function verifyUserAvatarImageUpload() {
2146                        $( '.listar-user-account-avatar-image' ).each( function () {
2147                                if ( $( this )[0].hasAttribute( 'style' ) ) {
2148                                        if ( $( this ).attr( 'style' ).indexOf( 'file-upload.png' ) >= 0 || $( this ).attr( 'style' ).indexOf( 'empty-avatar.png' ) >= 0 || $( this ).attr( 'style' ).indexOf( '.gravatar.' ) >= 0 ) {
2149                                                $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image-button.fa-plus' ).removeClass( 'hidden' );
2150                                                $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image-button.fa-times' ).addClass( 'hidden' );
2151                                        } else {
2152                                                $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image-button.fa-plus' ).addClass( 'hidden' );
2153                                                $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image-button.fa-times' ).removeClass( 'hidden' );
2154                                        }                                        
2155                                } else {
2156                                        $( this ).attr( 'style', ' ' );
2157                                }
2158                        } );
2159
2160                        setTimeout( function () {
2161                                isVerifiyingImageUpload = false;
2162                        }, 50 );
2163                }
2164
2165                var isVerifiyingImageUpload = false;
2166                var fieldDeleteOldImage = false;
2167                var updateImageField = true;
2168
2169                verifyUserAvatarImageUpload();
2170
2171                $( 'body' ).on( 'click', '.listar-user-account-avatar-image, .listar-user-account-avatar-image-add', function ( e ) {
2172                        e.preventDefault();
2173                        e.stopPropagation();
2174
2175                        if ( ! $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).hasClass( 'listar-uploading-image-ajax' ) ) {
2176                                $( this ).parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' )[0].click();
2177                        }
2178                } );
2179
2180                $( 'body' ).on( 'click', '.listar-user-account-avatar-image-remove', function ( e ) {
2181                        e.preventDefault();
2182                        e.stopPropagation();
2183
2184                        var confirmExclusion = true;
2185                        var fileInputField = $( this );
2186
2187                        if ( fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-upload-file-ajax' ).length ) {
2188                                confirmExclusion = confirm( listarLocalizeAndAjax.deleteImage );
2189                        }
2190
2191                        if ( confirmExclusion ) {                                
2192                                isVerifiyingImageUpload = true;
2193                                updateImageField = true;
2194                                fieldDeleteOldImage = false;
2195
2196                                if ( fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).hasClass( 'listar-upload-file-ajax' ) ) {
2197                                        var fieldImageID = 0;
2198                                        
2199                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).each( function () {
2200                                                fieldImageID = $( this ).val();
2201
2202                                                if ( 'undefined' === typeof fieldImageID || undefined === fieldImageID || 'undefined' === fieldImageID || 'NaN' === fieldImageID || 0 === fieldImageID || '0' === fieldImageID|| '' === fieldImageID  ) {
2203                                                        fieldImageID = 0;
2204                                                        fieldDeleteOldImage = false;
2205                                                } else {
2206                                                        fieldDeleteOldImage = fieldImageID;
2207                                                }
2208                                        } );
2209
2210                                        if ( false !== fieldDeleteOldImage ) {
2211                                                var myFormData = new FormData();
2212                                                myFormData.append( 'action', 'delete' );
2213                                                myFormData.append( 'delete_image', fieldDeleteOldImage );
2214
2215                                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).addClass( 'listar-uploading-image-ajax' );
2216
2217                                                $.ajax( {
2218                                                        url: window.listarAddonsDirectoryURL + '/inc/file-upload-ajax.php',
2219                                                        type: 'POST',
2220                                                        processData: false, // important
2221                                                        contentType: false, // important
2222                                                        dataType: 'json',
2223                                                        data: myFormData,
2224                                                        success: function( jsonData ) {
2225                                                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).removeClass( 'listar-uploading-image-ajax' );
2226                                                                verifyUserAvatarImageUpload();
2227                                                        },
2228                                                        error: function( xhr, ajaxOptions, thrownError ) {
2229                                                                var hasErrorMessage = false;
2230
2231                                                                if ( 'string' === typeof xhr.message ) {
2232                                                                        if ( '' !== xhr.message ) {
2233                                                                                hasErrorMessage = true;
2234                                                                                alert( xhr.message );
2235                                                                        }
2236                                                                }
2237
2238                                                                if ( ! hasErrorMessage ) {
2239                                                                        alert( thrownError );
2240                                                                }
2241
2242                                                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).removeClass( 'listar-uploading-image-ajax' );
2243                                                                verifyUserAvatarImageUpload();
2244                                                        }
2245                                                } );
2246                                        }
2247                                }
2248
2249                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).css( { 'background-image' : 'url( ' + fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).attr( 'data-fallback-image' ) + ' )' } );
2250                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).val( '' );
2251                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-url' ).val( '' );
2252                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).val( '' );
2253                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).trigger( 'change' );
2254                                fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field-reset' ).val( 1 ).attr( 'value', 1 );
2255
2256                                verifyUserAvatarImageUpload();
2257                        }
2258                } );
2259
2260                $( 'body' ).on( 'change', '.listar-user-image-upload-field', function() {
2261                        var field = $( this );
2262                        const [file] = field[0].files;
2263                        updateImageField = true;
2264                        fieldDeleteOldImage = false;
2265
2266                        if ( file ) {
2267                                if ( field.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).hasClass( 'listar-upload-file-ajax' ) ) {
2268                                        var fieldImageID = 0;
2269                                        
2270                                        field.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).each( function () {
2271                                                fieldImageID = $( this ).val();
2272
2273                                                if ( 'undefined' === typeof fieldImageID || undefined === fieldImageID || 'undefined' === fieldImageID || 'NaN' === fieldImageID || 0 === fieldImageID || '0' === fieldImageID || '' === fieldImageID ) {
2274                                                        fieldImageID = 0;
2275                                                        fieldDeleteOldImage = false;
2276                                                } else {
2277                                                        fieldDeleteOldImage = fieldImageID;
2278                                                }
2279                                        } );
2280                                }
2281
2282                                if ( false !== fieldDeleteOldImage ) {
2283                                        var tempConfirm = confirm( listarLocalizeAndAjax.deleteEarlierImage );
2284                                        
2285                                        if ( tempConfirm ) {
2286                                                updateImageField = true;
2287                                        } else {                                                
2288                                                updateImageField = false;
2289                                                field.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).val( '' );
2290                                                return false;
2291                                        }
2292                                }
2293
2294                                if ( updateImageField ) {
2295                                        field.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).css( { 'background-image' : 'url( ' + URL.createObjectURL(file) + ' )' } );
2296                                        field.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field-reset' ).val( 0 ).attr( 'value', 0 );
2297                                }
2298                        }
2299
2300                        verifyUserAvatarImageUpload();
2301                } );
2302
2303                $( 'body' ).on( 'change', '.listar-upload-file-ajax', function() {
2304                        if ( ! isVerifiyingImageUpload && updateImageField ) {                         
2305                                var fileInputField = $( this );
2306
2307                                if ( ! fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).hasClass( 'listar-uploading-image-ajax' ) ) {
2308                                        var fileInput = fileInputField.prop('files')[0];
2309                                        var myFormData = new FormData();
2310                                        myFormData.append( 'the_file', fileInput );
2311                                        myFormData.append( 'extensions_allowed', 'jpg jpeg gif png JPG JPEG GIF PNG' );
2312                                        myFormData.append( 'type', 'all' );
2313                                        myFormData.append( 'action', 'upload' );
2314
2315                                        if ( false !== fieldDeleteOldImage ) {
2316                                                myFormData.append( 'delete_image', fieldDeleteOldImage );
2317                                        }
2318
2319                                        fileInputField.val('');
2320                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).addClass( 'listar-uploading-image-ajax' );
2321
2322                                        $.ajax( {
2323                                                url: window.listarAddonsDirectoryURL + '/inc/file-upload-ajax.php',
2324                                                type: 'POST',
2325                                                processData: false, // important
2326                                                contentType: false, // important
2327                                                dataType: 'json',
2328                                                data: myFormData,
2329                                                success: function( jsonData ) {
2330                                                        console.log( jsonData.url );
2331                                                        console.log( jsonData.id );                                        
2332
2333                                                        if ( 'string' === typeof jsonData.message ) {
2334                                                                if ( '' !== jsonData.message || 'undefined' === typeof jsonData.url || 'undefined' === typeof jsonData.id ) {
2335                                                                        alert( jsonData.message );
2336                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).css( { 'background-image' : '' } );
2337                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).val( '' );
2338                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-url' ).val( '' );
2339                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).val( '' );
2340
2341                                                                } else {
2342                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-url' ).val( jsonData.url );
2343                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).val( jsonData.id );
2344                                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).css( { 'background-image' : 'url(' + jsonData.url + ')' } );
2345                                                                }
2346                                                        }
2347
2348                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).removeClass( 'listar-uploading-image-ajax' );
2349                                                        verifyUserAvatarImageUpload();
2350                                                },
2351                                                error: function( xhr, ajaxOptions, thrownError ) {
2352                                                        var hasErrorMessage = false;
2353
2354                                                        if ( 'string' === typeof xhr.message ) {
2355                                                                if ( '' !== xhr.message ) {
2356                                                                        hasErrorMessage = true;
2357                                                                        alert( xhr.message );
2358                                                                }
2359                                                        }
2360
2361                                                        if ( ! hasErrorMessage ) {
2362                                                                alert( thrownError );
2363                                                        }
2364
2365                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-account-avatar-image' ).css( { 'background-image' : '' } );
2366                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-user-image-upload-field' ).val( '' );
2367                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-url' ).val( '' );
2368                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).find( '.listar-price-item-image-val-id' ).val( '' );
2369
2370                                                        fileInputField.parents( '.listar-user-account-avatar-image-wrapper' ).removeClass( 'listar-uploading-image-ajax' );
2371                                                        verifyUserAvatarImageUpload();
2372                                                }
2373                                        } );
2374                                }
2375                        }
2376                } );
2377
2378		function createPriceListItem( listItemID, listCategoryID, priceTag, priceTitle, pricePrice, priceDescr, priceLink, priceLabel, priceImageURL, priceImageID ) {
2379                        var verifiedItemID = false;
2380                        var verifiedCategoryID = false;
2381
2382                        if ( ! ( 'string' !== typeof listItemID || undefined === listItemID || 'undefined' === listItemID || 'NaN' === listItemID || '0' === listItemID || '' === listItemID ) ) {
2383                                if ( listItemID.indexOf( 'price-item-' ) >= 0 ) {
2384                                        verifiedItemID = true;
2385                                }
2386                        }
2387
2388                        if ( ! ( 'string' !== typeof listCategoryID || undefined === listCategoryID || 'undefined' === listCategoryID || 'NaN' === listCategoryID || '0' === listCategoryID || '' === listCategoryID ) ) {
2389                                if ( listCategoryID.indexOf( 'price-category-' ) >= 0 ) {
2390                                        verifiedCategoryID = true;
2391                                }
2392                        }
2393
2394                        var itemID = ! verifiedItemID ? 'price-item-' + ( Math.floor( Math.random() * 999999 ) + 100000 ) : listItemID;
2395                        var itemCategory = ! verifiedCategoryID ? '' : listCategoryID;
2396                        var itemTable = '';
2397                        var itemControls = '';
2398
2399                        $( '.listar-price-builder-items-wrapper' ).append( '<div class="listar-price-item" id="' + itemID + '" data-category="' + itemCategory + '" data-visibility="false"></div>' );
2400                        $( '#' + itemID ).append( '<div class="listar-price-list-items-controls"></div>' );
2401
2402                        itemControls = $( '#' + itemID ).find( '.listar-price-list-items-controls' );
2403
2404                        itemControls.append( '<div class="listar-price-list-item-control-bottom fa fa-arrow-down"></div>' );
2405                        itemControls.append( '<div class="listar-price-list-item-control-top fa fa-arrow-up"></div>' );
2406                        itemControls.append( '<div class="listar-price-list-item-control-left fa fa-arrow-left hidden listar-hidden hidden"></div>' );
2407                        itemControls.append( '<div class="listar-price-list-item-control-right fa fa-arrow-right hidden listar-hidden hidden"></div>' );
2408                        itemControls.append( '<div class="listar-price-list-item-control-delete fa fa-times"></div>' );
2409
2410                        $( '#' + itemID ).append( '<table></table>' );
2411
2412                        itemTable = $( '#' + itemID + ' table' );
2413
2414                        var labelsHTML = '<select class="listar-price-item-label-val">';
2415
2416                        if ( 'string' === typeof listarLocalizeAndAjax.label.info ) {
2417                                var labelTarget = listarLocalizeAndAjax.label;
2418
2419                                labelsHTML += '<option value="" default selected class="listar-default-select-option">' + listarLocalizeAndAjax.selectLabel + '</option>';                                
2420
2421                                for ( var k in labelTarget ){
2422                                        if ( labelTarget.hasOwnProperty( k ) ) {
2423                                                labelsHTML += '<option value="' + k + '">' + labelTarget[k] + '</option>';
2424                                        }
2425                                }
2426                        }
2427
2428                        labelsHTML += '</select>';
2429
2430                        itemTable.append( '<tr><td class="listar-price-item-image"><div class="listar-user-account-avatar-image-wrapper"><input type="file" class="listar-upload-file-ajax listar-user-image-upload-field hidden"><input type="hidden" class="listar-price-item-image-val-url hidden"><input type="hidden" class="listar-price-item-image-val-id hidden"><div class="listar-user-account-avatar-image-button listar-user-account-avatar-image-add fas fa-plus hidden"></div><div class="listar-user-account-avatar-image-button listar-user-account-avatar-image-remove fas fa-times hidden"></div><div class="listar-user-account-avatar-image" data-fallback-image="' + window.listarThemeURL + '/assets/images/file-upload.png' + '"></div></div></td><td></td></tr>' );
2431                        itemTable.append( '<tr class="listar-price-item-tag-tr"><td class="listar-price-item-tag"><input type="text" class="listar-price-item-tag-val" placeholder="' + listarLocalizeAndAjax.featuredTag + '"></td><td></td></tr>' );
2432                        itemTable.append( '<tr><td class="listar-price-item-title"><input type="text" class="listar-price-item-title-val" placeholder="' + listarLocalizeAndAjax.title + '" required="required"></td><td class="listar-price-item-price"><input type="text" class="listar-price-item-price-val" placeholder="' + listarLocalizeAndAjax.price + '"></td></tr>' );
2433                        itemTable.append( '<tr><td class="listar-price-item-descr" colspan="2"><textarea class="listar-price-item-descr-val" placeholder="' + listarLocalizeAndAjax.description + '"></textarea></td></tr>' );
2434                        itemTable.append( '<tr><td class="listar-price-item-link"><input type="url" class="listar-price-item-link-val" placeholder="' + listarLocalizeAndAjax.link + '"></td><td class="listar-price-item-label">' + labelsHTML + '</td></tr>' );
2435
2436                        // If a category is selected.
2437
2438                        if ( ! verifiedItemID ) {
2439                                $( '.listar-price-builder-category[data-selected="selected"]' ).each( function () {
2440                                        $( '#' + itemID ).attr( 'data-category', $( this ).attr( 'id' ) );
2441                                } );
2442                        }
2443
2444                        // Set saved values (coming from JSON).
2445
2446                        if ( ! ( 'string' !== typeof priceTag || undefined === priceTag || 'undefined' === priceTag || 'NaN' === priceTag || '0' === priceTag || '' === priceTag ) ) {
2447                                itemTable.find( '.listar-price-item-tag-val' ).val( priceTag );
2448                        }
2449
2450                        if ( ! ( 'string' !== typeof priceTitle || undefined === priceTitle || 'undefined' === priceTitle || 'NaN' === priceTitle || '0' === priceTitle || '' === priceTitle ) ) {
2451                                itemTable.find( '.listar-price-item-title-val' ).val( priceTitle );
2452                        }
2453
2454                        if ( ! ( 'string' !== typeof pricePrice || undefined === pricePrice || 'undefined' === pricePrice || 'NaN' === pricePrice || '0' === pricePrice || '' === pricePrice ) ) {
2455                                itemTable.find( '.listar-price-item-price-val' ).val( pricePrice );
2456                        }
2457
2458                        if ( ! ( 'string' !== typeof priceDescr || undefined === priceDescr || 'undefined' === priceDescr || 'NaN' === priceDescr || '0' === priceDescr || '' === priceDescr ) ) {
2459                                itemTable.find( '.listar-price-item-descr-val' ).val( priceDescr );
2460                        }
2461
2462                        if ( ! ( 'string' !== typeof priceLink || undefined === priceLink || 'undefined' === priceLink || 'NaN' === priceLink || '0' === priceLink || '' === priceLink ) ) {
2463                                itemTable.find( '.listar-price-item-link-val' ).val( priceLink );
2464                        }
2465
2466                        if ( ! ( 'string' !== typeof priceImageURL || undefined === priceImageURL || 'undefined' === priceImageURL || 'NaN' === priceImageURL || '0' === priceImageURL || '' === priceImageURL ) ) {
2467                                itemTable.find( '.listar-price-item-image .listar-user-account-avatar-image' ).css( { 'background-image' : 'url(' + priceImageURL + ')' } );
2468                                itemTable.find( '.listar-price-item-image-val-url' ).val( priceImageURL );
2469                        } else {
2470                                itemTable.find( '.listar-price-item-image .listar-user-account-avatar-image' ).each( function () {
2471                                        $( this ).css( { 'background-image' : 'url(' + $( this ).attr( 'data-fallback-image' ) + ')' } );
2472                                } );
2473                        }
2474
2475                        if ( ! ( 'string' !== typeof priceImageID || undefined === priceImageID || 'undefined' === priceImageID || 'NaN' === priceImageID || '0' === priceImageID || '' === priceImageID ) ) {
2476                                itemTable.find( '.listar-price-item-image-val-id' ).val( priceImageID );
2477                        }
2478
2479                        if ( ! ( 'string' !== typeof priceLabel || undefined === priceLabel || 'undefined' === priceLabel || 'NaN' === priceLabel || '0' === priceLabel || '' === priceLabel ) ) {
2480                                itemTable.find( '.listar-price-item-label-val' ).val( priceLabel );
2481                                itemTable.find( 'option' ).each( function () {
2482                                        if ( priceLabel === $( this ).attr( 'value' ) ) {
2483                                                $( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
2484                                        }
2485                                } );
2486                        }
2487
2488                        priceListCategoryItemsVisibility( itemCategory );
2489
2490                        verifyUserAvatarImageUpload();
2491
2492                        return itemID;
2493                }
2494
2495	function highlightPriceListCategory( categoryID ) {
2496		$( '.listar-price-builder-categories-wrapper' ).find( '.listar-price-builder
2496-category' ).attr( 'data-selected', 'not-selected' );
2497
2498		$( '#' + categoryID ).each( function () {
2499			$( this ).attr( 'data-selected', 'selected' );
2500		} );
2501	}
2502
2503	function priceListCategoryItemsVisibility( itemCategory ) {
2504
2505		var categoryVisibility = '';
2506
2507		if ( undefined !== itemCategory && '' !== itemCategory && 'string' === typeof itemCategory ) {
2508			categoryVisibility = itemCategory;
2509		} else {
2510			categoryVisibility = 'unknown-category';
2511		}
2512
2513		if ( ! $( '.listar-price-builder-category' ).length ) {
2514
2515			// Turn every item visible if no categories found.
2516
2517			$( '.listar-price-item' ).each( function () {
2518				$( this ).attr( 'data-visibility', 'true' );
2519			} );
2520		} else {
2521
2522			// Prepare to turn price items visible only for this category.
2523
2524			$( '.listar-price-item' ).each( function () {
2525				$( this ).attr( 'data-visibility', 'false' );
2526			} );
2527		}
2528
2529		$( '.listar-price-item[data-category="' + categoryVisibility + '"]' ).each( function () {
2530			$( this ).attr( 'data-visibility', 'true' );
2531		} );
2532
2533		hasPriceListItems();
2534
2535		return categoryVisibility;
2536	}
2537
2538	function createPriceListCategory( listCategoryID, priceCat ) {
2539		var verifiedCategoryID = false;
2540
2541		if ( ! ( 'string' !== typeof listCategoryID || undefined === listCategoryID || 'undefined' === listCategoryID || 'NaN' === listCategoryID || '0' === listCategoryID || '' === listCategoryID ) ) {
2542			if ( listCategoryID.indexOf( 'price-category-' ) >= 0 ) {
2543				verifiedCategoryID = true;
2544			}
2545		}
2546
2547		var itemID = 'price-category-' + ( Math.floor( Math.random() * 999999 ) + 100000 );
2548		var itemCategory = ! verifiedCategoryID ? itemID : listCategoryID;
2549
2550		if ( ! $( '#' + itemCategory ).length ) {
2551
2552			// Category no exists yet.
2553
2554			$( '.listar-price-list-add-category' ).before( '<div class="listar-price-builder-category" id="' + itemCategory + '"><div class="listar-price-list-category-delete fa fa-times"></div><input type="text" class="listar-price-builder-category-val" placeholder="' + listarLocalizeAndAjax.category + '" required="required"></div>' );
2555
2556			// Set saved values (coming from JSON).
2557
2558			if ( ! ( 'string' !== typeof priceCat || undefined === priceCat || 'undefined' === priceCat || 'NaN' === priceCat || '0' === priceCat || '' === priceCat ) ) {
2559				$( '#' + itemCategory ).find( 'input' ).val( priceCat );
2560			}
2561		}
2562
2563		if ( 1 === $( '.listar-price-builder-categories-wrapper input' ).length ) {
2564			$( '.listar-price-item' ).each( function () {
2565				$( this ).attr( 'data-category', itemCategory );
2566			} );
2567		}
2568
2569		highlightPriceListCategory( itemCategory );
2570
2571		// Turn price items visible for this category.
2572
2573		priceListCategoryItemsVisibility( itemCategory );
2574
2575		return itemCategory;
2576	}
2577
2578	function galleryLengthVerification() {
2579		var galleryImageLimit = 30;
2580
2581		if ( 'string' === typeof listarLocalizeAndAjax.maxGalleryUploadImages ) {
2582			if ( '' !== listarLocalizeAndAjax.maxGalleryUploadImages ) {
2583				galleryImageLimit = listarLocalizeAndAjax.maxGalleryUploadImages;
2584			}
2585		}
2586
2587		if ( $( '.fieldset-gallery_images' ).length ) {
2588			if ( ! $( '.fieldset-gallery_images' ).hasClass( 'listar-has-added-limit-string' ) ) {
2589				var innerDescr = $( '.fieldset-gallery_images small.description' ).prop( 'innerHTML' );
2590
2591				$( '.fieldset-gallery_images small.description' ).prop( 'innerHTML', innerDescr.trim() + ' ' + listarLocalizeAndAjax.maxGalleryImages + ': ' + galleryImageLimit );
2592				$( '.fieldset-gallery_images' ).addClass( 'listar-has-added-limit-string' );
2593			}
2594
2595			if ( $( '.fieldset-gallery_images .job-manager-uploaded-file' ).length >= galleryImageLimit ) {
2596				$( '.fieldset-gallery_images .wp-job-manager-file-upload' ).addClass( 'hidden' );
2597
2598				if ( $( '.fieldset-gallery_images .job-manager-uploaded-file' ).length > galleryImageLimit ) {
2599					$( '.fieldset-gallery_images .job-manager-uploaded-file' ).last().find( '.job-manager-remove-uploaded-file' )[0].click();
2600				}
2601			} else {
2602				$( '.fieldset-gallery_images .wp-job-manager-file-upload' ).removeClass( 'hidden' );
2603			}
2604		}
2605	}
2606
2607	function mediaLengthVerification() {
2608		var mediaLimit = 30;
2609		var mediaFields = $( 'textarea[id*="company_business_rich_media_value_"]' );
2610
2611		if ( 'string' === typeof listarLocalizeAndAjax.maxMediaFields ) {
2612			if ( '' !== listarLocalizeAndAjax.maxMediaFields ) {
2613				mediaLimit = listarLocalizeAndAjax.maxMediaFields;
2614			}
2615		}
2616		
2617		if ( mediaFields.length >= mediaLimit ) {
2618			$( '.listar-rich-media-add-item' ).prop( 'outerHTML', '' );
2619		}
2620		
2621		$( '.listar-business-rich-media-fields .listar-boxed-fields-inner-2 fieldset:nth-child(n+' + ( parseInt( mediaLimit, 10 ) + 2 ) + ')' ).each( function () {
2622			$( this ).prev().addClass( 'listar-remove-fieldset-border-bottom' );
2623			$( this ).addClass( 'hidden' );
2624		} );
2625	}
2626
2627	function sanitizePricingFields( field ) {
2628		var priceVal = field.val();
2629
2630		if ( 'string' === typeof priceVal && 'undefined' !== priceVal ) {
2631			priceVal = priceVal.replace( /[^0-9\.,]/g, '' ).replace( '..', '.' ).replace( '.,', '.' ).replace( ',.', ',' ).replace( ',,', ',' );
2632		} else {
2633			priceVal = '';
2634		}
2635
2636		if ( '' === priceVal || undefined === priceVal || 'undefined' === priceVal ) {
2637			priceVal = '';
2638		}
2639
2640		field.val( priceVal );
2641	}
2642
2643	function checkLinkAnchor( h, e ) {
2644		var hasSpecialHash = false;
2645
2646		if ( '' !== h ) {
2647			var hashAnchor = $( '#primary' ).find( '#' + h );
2648
2649			for ( var hashCounter = 0; hashCounter < specialHashes.length; hashCounter++ ) {
2650				if ( h.indexOf( specialHashes[ hashCounter ] ) >= 0 ) {
2651					hasSpecialHash = true;
2652				}
2653			}
2654
2655			if ( ! hasSpecialHash && hashAnchor.length > 0 ) {
2656
2657				/* Exception for Bootstrap Tabs */
2658				if ( ! hashAnchor.parents( '.tab-content' ).length ) {
2659					setTimeout( function () {
2660
2661						/* Fix hash/anchor scroll */
2662						htmlAndBody.stop().animate( {
2663							scrollTop : hashAnchor.offset().top - ( 110 + headerTopbarDistance( true ) )
2664						}, 600 );
2665					} , 150 );
2666				}
2667			}
2668		}
2669	}
2670
2671	function startGeolocationPopup( launchPopup ) {
2672		var hasUserLatitudeAndLongitude = false;
2673
2674		if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' ).length ) {
2675			var userLatitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
2676			var userLongitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
2677
2678			if ( userLatitudeField.length && userLongitudeField.length ) {
2679				if ( '' !== userLatitudeField.val() && '' !==  userLongitudeField.val() ) {
2680					hasUserLatitudeAndLongitude = true;
2681				}
2682			}
2683
2684			if ( ! hasUserLatitudeAndLongitude ) {
2685
2686				if ( launchPopup ) {
2687					if ( $( '#menu-primary-menu .listar-header-search-button' ).length ) {
2688						$( '#menu-primary-menu .listar-header-search-button' ).eq( 0 )[0].click();
2689					}
2690				}
2691
2692				setTimeout( function () {
2693					$( '.search-form .listar-search-by-button' )[0].click();
2694				}, 500 );
2695
2696				setTimeout( function () {
2697					$( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' )[0].click();
2698				}, 600 );
2699			}
2700		}
2701
2702		return hasUserLatitudeAndLongitude;
2703	}
2704
2705	function fixListingCoordinates( latField, lngField ) {
2706		var returnValue = true;
2707		var hasAlert1 = false;
2708		var hasAlert2 = false;
2709		var hasAlert3 = false;
2710
2711		if ( latField.length && lngField.length ) {
2712			if ( 'string' === typeof latField.val() ) {
2713				var latFieldInitial = latField.val().replace( /\s+/g, '' );
2714
2715				// Does the string contains '.-' or '-.'?
2716				latFieldInitial = latFieldInitial.replace( '.-', '' ).replace( '-.', '-' );
2717				latField.val( latFieldInitial );
2718
2719				// Does the string contains a hyphen out of position?
2720				if ( latFieldInitial.indexOf( '-' ) > 0 ) {
2721					hyphenPos = latFieldInitial.indexOf( '-' );
2722					latFieldInitial = latFieldInitial.substring( 0, hyphenPos ) + latFieldInitial.substring( hyphenPos + 1 );
2723					latField.val( latFieldInitial );
2724				}
2725
2726				// Is the first character a dot?
2727				if ( '.' === latFieldInitial.charAt( 0 ) ) {
2728					latFieldInitial = latFieldInitial.substring(1);
2729					latField.val( latFieldInitial );
2730				}
2731
2732				latFieldInitial = latFieldInitial.replace( '.-', '' ).replace( '-.', '-' );
2733				latField.val( latFieldInitial );
2734
2735				sanitizedLat = latFieldInitial.replace( /[^0-9\.-]/g, '' );
2736				var countDotsLat = '' !== sanitizedLat && sanitizedLat.indexOf( '.' ) >= 0 ? ( sanitizedLat.match( /\./g ) || [] ).length : 0;
2737				var countHyphensLat = '' !== sanitizedLat && sanitizedLat.indexOf( '-' ) >= 0 ? ( sanitizedLat.match( /\-/g ) || [] ).length : 0;
2738
2739				if ( ( latFieldInitial !== sanitizedLat ) ) {
2740					hasAlert1 = true;
2741					latField.val( sanitizedLat );
2742					returnValue = false;
2743				}
2744
2745				var testFloatLat = sanitizedLat;
2746
2747				if ( '' !== testFloatLat ) {
2748					testFloatLat = Number( testFloatLat );
2749
2750					if ( testFloatLat < -90 || testFloatLat > 90 ) {
2751						hasAlert2 = true;
2752						returnValue = false;
2753					}
2754				}
2755
2756				if ( countDotsLat > 1 || countHyphensLat > 1 ) {
2757					hasAlert3 = true;
2758					returnValue = false;
2759				}
2760			}
2761
2762			if ( 'string' === typeof lngField.val() ) {
2763				var lngFieldInitial = lngField.val().replace( /\s+/g, '' );
2764
2765				// Does the string contains '.-' or '-.'?
2766				lngFieldInitial = lngFieldInitial.replace( '.-', '' ).replace( '-.', '-' );
2767				lngField.val( lngFieldInitial );
2768
2769				// Does the string contains a hyphen out of position?
2770				if ( lngFieldInitial.indexOf( '-' ) > 0 ) {
2771					hyphenPos = lngFieldInitial.indexOf( '-' );
2772					lngFieldInitial = lngFieldInitial.substring( 0, hyphenPos ) + lngFieldInitial.substring( hyphenPos + 1 );
2773					lngField.val( lngFieldInitial );
2774				}
2775
2776				// Is the first character a dot?
2777				if ( '.' === lngFieldInitial.charAt( 0 ) ) {
2778					lngFieldInitial = lngFieldInitial.substring(1);
2779					lngField.val( lngFieldInitial );
2780				}
2781
2782				sanitizedLng = lngFieldInitial.replace( /[^0-9\.-]/g, '' );
2783				var countDotsLng = '' !== sanitizedLng && sanitizedLng.indexOf( '.' ) >= 0 ? ( sanitizedLng.match( /\./g ) || [] ).length : 0;
2784				var countHyphensLng = '' !== sanitizedLng && sanitizedLng.indexOf( '-' ) >= 0 ? ( sanitizedLng.match( /\-/g ) || [] ).length : 0;
2785
2786				if ( ( lngFieldInitial !== sanitizedLng ) ) {
2787					hasAlert1 = true;
2788					lngField.val( sanitizedLng );
2789					returnValue = false;
2790				}
2791
2792				var testFloatLng =  sanitizedLng;
2793
2794				if ( '' !== testFloatLng ) {
2795					testFloatLng = Number( testFloatLng );
2796
2797					if ( testFloatLng < -180 || testFloatLng > 180 ) {
2798						hasAlert2 = true;
2799						returnValue = false;
2800					}
2801				}
2802
2803				if ( countDotsLng > 1 || countHyphensLng > 1 ) {
2804					hasAlert3 = true;
2805					returnValue = false;
2806				}
2807			}
2808		}
2809
2810		if ( hasAlert1 ) {
2811			alert( listarLocalizeAndAjax.fixCoordinates1 );
2812		}
2813
2814		if ( hasAlert2 ) {
2815			alert( listarLocalizeAndAjax.fixCoordinates2 );
2816		}
2817
2818		if ( hasAlert3 ) {
2819			alert( listarLocalizeAndAjax.fixCoordinates3 );
2820		}
2821
2822		return returnValue;
2823	}
2824
2825	function fixLastCharacterCoordinates( latField, lngField ) {
2826		sanitizedLat = '';
2827		sanitizedLng = '';
2828		var returnValue  = true;
2829
2830		if ( latField.length && lngField.length ) {
2831			if ( 'string' === typeof latField.val() ) {
2832				var latFieldInitial = latField.val().replace( /\s+/g, '' );
2833
2834				// Does the string contains '.-' or '-.'?
2835				latFieldInitial = latFieldInitial.replace( '.-', '' ).replace( '-.', '-' );
2836				latField.val( latFieldInitial );
2837
2838				// Does the string contains a hyphen out of position?
2839				if ( latFieldInitial.indexOf( '-' ) > 0 ) {
2840					hyphenPos = latFieldInitial.indexOf( '-' );
2841					latFieldInitial = latFieldInitial.substring( 0, hyphenPos ) + latFieldInitial.substring( hyphenPos + 1 );
2842					latField.val( latFieldInitial );
2843				}
2844
2845				if ( '' !== latField.val() ) {
2846					sanitizedLat = latFieldInitial.replace( /[^0-9\.-]/g, '' );
2847
2848					// Is the last character a dot or hyphen?
2849					if ( '.' === sanitizedLat.slice( -1 ) || '-' === sanitizedLat.slice( -1 ) ) {
2850						sanitizedLat = sanitizedLat.slice( 0, -1 );
2851					}
2852
2853					// Is the first character a dot?
2854					if ( '.' === sanitizedLat.charAt( 0 ) ) {
2855						sanitizedLat = sanitizedLat.substring(1);
2856					}
2857
2858					latField.val( sanitizedLat );
2859				}
2860			}
2861		}
2862
2863		if ( lngField.length && lngField.length ) {
2864			if ( 'string' === typeof lngField.val() ) {
2865				var lngFieldInitial = lngField.val().replace( /\s+/g, '' );
2866
2867				// Does the string contains '.-' or '-.'?
2868				lngFieldInitial = lngFieldInitial.replace( '.-', '' ).replace( '-.', '-' );
2869				lngField.val( lngFieldInitial );
2870
2871				// Does the string contains a hyphen out of position?
2872				if ( lngFieldInitial.indexOf( '-' ) > 0 ) {
2873					hyphenPos = lngFieldInitial.indexOf( '-' );
2874					lngFieldInitial = lngFieldInitial.substring( 0, hyphenPos ) + lngFieldInitial.substring( hyphenPos + 1 );
2875					lngField.val( lngFieldInitial );
2876				}
2877
2878				if ( '' !== lngField.val() ) {
2879					sanitizedLng = lngFieldInitial.replace( /[^0-9\.-]/g, '' );
2880
2881					// Is the last character a dot or hyphen?
2882					if ( '.' === sanitizedLng.slice( -1 ) || '-' === sanitizedLng.slice( -1 ) ) {
2883						sanitizedLng = sanitizedLng.slice( 0, -1 );
2884					}
2885
2886					// Is the first character a dot?
2887					if ( '.' === sanitizedLng.charAt( 0 ) ) {
2888						sanitizedLng = sanitizedLng.substring(1);
2889					}
2890
2891					lngField.val( sanitizedLng );
2892				}
2893			}
2894		}
2895
2896		if ( ( '' === sanitizedLat && '' !== sanitizedLng ) || ( '' === sanitizedLng && '' !== sanitizedLat ) || '.' === sanitizedLat || '-' === sanitizedLat || '.' === sanitizedLng || '-' === sanitizedLng ) {
2897			returnValue = false;
2898			alert( listarLocalizeAndAjax.fixCoordinates4 );
2899		}
2900
2901		return returnValue;
2902	}
2903
2904
2905        function setInitialMapZoom( delay ) {
2906                if ( hasCustomInitialMapZoom ) {
2907                        if ( 'undefined' === typeof delay ) {
2908                                delay = 4000;
2909                        }
2910
2911                        /**
2912                         * Sets the initial map zoom level.
2913                         * Leaflet has unstable/no time precision here
2914                         */                                        
2915
2916                        setTimeout( function () {
2917                                map.setZoom( initialMapZoom );
2918                        }, delay );
2919
2920                        setTimeout( function () {
2921                                map.setZoom( initialMapZoom );
2922                        }, delay + 1000 );
2923
2924                        setTimeout( function () {
2925                                map.setZoom( initialMapZoom );
2926                        }, delay + 2000 );
2927                }
2928        }
2929
2930	function setSmashBalloonImages() {
2931
2932		/* Smash Balloon images - Pagespeed */
2933		setTimeout( function () {
2934			$( '.listar-instagram-feed-image' ).each( function () {
2935				var sbiItem = $( this ).parents( '.listar-sbi_item' );
2936				var sbiBGImage = $( this ).attr( 'data-temp-background-image' );
2937				var sbiSRC = $( this ).attr( 'data-src' );
2938				var sbiALT = $( this ).attr( 'data-alt' );
2939				var sbiFORCE = $( this ).attr( 'data-force-img' );
2940				$( this ).prop( 'outerHTML', '<img src="' + sbiSRC + '" alt="' + sbiALT + '" data-background-image="' + sbiBGImage + '" data-force-img="' + sbiFORCE + '" />' );
2941
2942				sbiItem.removeClass( 'listar-sbi_item' ).addClass( 'sbi_item' );
2943				convertDataBackgroundImage( sbiItem.find( 'img' ) );
2944			} );
2945		}, 100 );
2946	}
2947
2948	function fixSmashBalloonImages() {
2949		setTimeout( function () {
2950			$( '.sbi_photo_wrap img' ).each( function () {
2951				if ( $( this )[0].hasAttribute( 'src' ) ) {
2952					var sbiSRC = $( this ).attr( 'src' );
2953
2954					if ( 'string' === typeof sbiSRC ) {
2955						if ( -1 === sbiSRC.indexOf( 'data:image/gif;base64' ) ) {
2956							$( this ).attr( 'src', 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==' );
2957							$( this ).css( { 'background-image' : 'url(' + sbiSRC + ')' } );
2958						}
2959					}
2960				}
2961			} );
2962		}, 200 );
2963	}
2964
2965	function getTotalMinutes( inputTime ) {
2966
2967		if ( -1 === inputTime.indexOf( ' AM' ) && -1 === inputTime.indexOf( ' PM' ) ) {
2968			return 0;
2969		}
2970
2971		var inputHours = Number(inputTime.match(/^(\d+)/)[1]);
2972		var inputMinutes = Number(inputTime.match(/:(\d+)/)[1]);
2973		var AMPM = inputTime.match(/\s(.*)$/)[1];
2974		var totalMinutes = 0;
2975		var inputHoursString = 0;
2976		var inputMinutesString = 0;
2977
2978		if ( 'PM' === AMPM && inputHours < 12 ) {
2979			inputHours = inputHours + 12;
2980		}
2981
2982		if( 'AM' === AMPM && 12 === inputHours ) {
2983			inputHours = inputHours - 12;
2984		}
2985
2986		inputHoursString = inputHours.toString();
2987		inputMinutesString = inputMinutes.toString();
2988
2989		if( inputHours < 10 ) {
2990			inputHoursString = '0' + inputHoursString;
2991		}
2992
2993		if( inputMinutes < 10 ) {
2994			inputMinutesString = '0' + inputMinutesString;
2995		}
2996
2997		totalMinutes = ( parseInt( inputHoursString, 10 ) * 60 ) + parseInt( inputMinutesString, 10 );
2998
2999		return totalMinutes;
3000	}
3001
3002	function enableNearestMeDataEditor() {
3003
3004		var hasUserLatitudeAndLongitude = false;
3005		var userLatitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
3006		var userLongitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
3007
3008		if ( userLatitudeField.length && userLongitudeField.length ) {
3009			if ( '' !== userLatitudeField.val() && '' !==  userLongitudeField.val() ) {
3010				hasUserLatitudeAndLongitude = true;
3011			}
3012		}
3013
3014		if ( hasUserLatitudeAndLongitude ) {
3015			$( '.listar-edit-nearest-me-wrapper' ).removeClass( 'hidden' );
3016		} else {
3017			$( '.listar-edit-nearest-me-wrapper' ).addClass( 'hidden' );
3018		}
3019	}
3020
3021	function loadListingCardContentAjax( listingCard ) {
3022		var listingCardID = listingCard.attr( 'data-listing-id' );
3023		var contentDataURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/listing-card-content-ajax.php';
3024		var dataToSend = { send_data : '[{"type":"listing-content"},{"id":"' + listingCardID + '"}]' };
3025		var timeOut = 8;
3026
3027
3028		var ajaxTimeout = setInterval( function () {
3029			timeOut--;
3030
3031			/* Ajax Failed? keep calling. */				
3032			if ( 0 === timeOut ) {
3033				timeOut = 8;
3034
3035				loadListingCardContentAjax( listingCard );
3036			}
3037		}, 1000 );
3038
3039		$.ajax( {
3040			crossDomain: true,
3041			url: contentDataURL,
3042			type: 'POST',
3043			data: dataToSend,
3044			cache    : false,
3045			timeout  : 30000
3046
3047		} ).done( function ( response ) {
3048			if ( response ) {
3049				clearInterval( ajaxTimeout );
3050				listingCard.addClass( 'listar-card-content-ajax-loaded' ).removeClass( 'listar-card-content-ajax-loading' );
3051				listingCard.find( 'article' ).prop( 'innerHTML', response );
3052			}
3053		} );
3054	}
3055
3056	function primaryMenuMaxWidth() {
3057		setTimeout( function () {
3058			var
3059				timeOut = viewport().width < 400 ? 0 : 400,
3060				timeOut2 = viewport().width <= 0 ? 0 : 400,
3061				nav = $( '.listar-primary-navigation-wrapper .navbar-nav' );
3062
3063			if ( $( '.listar-more-menu-links-wrapper' ).length ) {
3064				$( '.listar-more-menu-links-wrapper, .listar-left-menu-limit' ).prop( 'outerHTML', '' );
3065				nav.removeClass( 'listar-too-high-menu' );
3066			}
3067
3068			setTimeout( function () {
3069
3070				if ( $( '.listar-primary-navigation-wrapper .listar-user-buttons' ).length && nav.length ) {
3071
3072					if ( viewport().width > 767 ) {
3073						var menuScrollHeight = 0;
3074						var userButtonsWidth = $( '.listar-primary-navigation-wrapper .listar-user-buttons' ).width();
3075
3076						nav.css( { 'max-width' : 'calc(100% - ' + ( userButtonsWidth + 65 ) + 'px)' } );
3077
3078						setTimeout( function () {
3079							menuScrollHeight = nav.height();
3080
3081							if ( menuScrollHeight > 86 ) {
3082								if ( ! $( '.listar-more-menu-links-wrapper' ).length ) {
3083									nav.append( '<li class="listar-more-menu-links-wrapper"><div class="listar-more-menu-links"></div></li>' );
3084									nav.find( '.listar-header-search-button' ).after( '<li class="listar-left-menu-limit"></li>' );
3085									nav.addClass( 'listar-too-high-menu' );
3086									$( '.listar-left-menu-limit' ).css( { height : menuScrollHeight } );
3087								}
3088							}
3089						}, 100 );
3090					} else {
3091						nav.css( { 'max-width' : '99999px' } );
3092						nav.removeClass( 'listar-too-high-menu' );
3093
3094						if ( $( '.listar-more-menu-links-wrapper' ).length ) {
3095							$( '.listar-more-menu-links-wrapper, .listar-left-menu-limit' ).prop( 'outerHTML', '' );
3096						}
3097					}
3098				}
3099
3100				setTimeout( function () {
3101					$( theBody ).addClass( 'listar-loaded-menu' );
3102				}, timeOut2 );
3103			}, timeOut );
3104		}, 100 );
3105	}
3106
3107	function startHeightEqualizer() {
3108		if ( gotUpdatedNonce ) {
3109			heightEqualizer( '.listar-listing-card' );
3110			heightEqualizer( '.listar-blog-card' );
3111			heightEqualizer( '.listar-woo-product-card' );
3112			heightEqualizer( '.listar-feature-item-wrapper' );
3113			heightEqualizer( '.listar-partner-wrapper', true, false, true );
3114			heightEqualizer( '.listar-setting-control > div', false, '.listar-setting-groups-wrapper' );
3115		}
3116	}
3117
3118	function resetElements( isResizing ) {
3119		resizeHeroVideos();
3120
3121		if ( ! preventEvenCallStack7 ) {
3122			var resetDelay = 0;
3123			preventEvenCallStack7 = true;
3124
3125			if ( ! lastViewportWidth ) {
3126				lastViewportWidth = viewport().width;
3127			}
3128
3129			if ( ! scrollbarWidth ) {
3130				scrollbarWidth = getScrollBarWidth();
3131			}
3132
3133			if ( 'undefined' !== typeof isResizing ) {
3134				resetDelay = 2000;
3135			}
3136
3137			setTimeout( function () {
3138				var currentViewportWidth = viewport().width;
3139
3140				if ( ( 2000 === resetDelay && lastViewportWidth !== currentViewportWidth ) || ( 0 === resetDelay ) ) {
3141					var owlCarousels = $( '.listar-carousel-loop.listar-use-carousel' );
3142
3143					lastViewportWidth = currentViewportWidth;
3144					scrollbarWidth = getScrollBarWidth();
3145
3146					defineHiddenFooterHeight();
3147					adjustFeatureBlocks();
3148					equalizeVideoHeights();
3149					equalizeWordPressGalleryHeights();
3150
3151					if ( gotUpdatedNonce ) {
3152						initOwlCarousel( owlCarousels, true );
3153					}
3154
3155					checkNavbarToggle();
3156					mobileMenuMaxHeight();
3157					setTooltips();
3158					setUserFormsPosition();
3159					checkGrid();
3160					bodyWrapperOverflow();
3161					checkScrolling();
3162					prepareHeaderListings();
3163					prepareMainMenu();
3164					prepareCatsUnderSearchField();
3165					moreCategoriesButtonVisibility();
3166					resetMap();
3167					initOnScrollEffects();
3168					initListingGalleryScroll();
3169					fixGutenbergImageBlocks();
3170					resizeCanvases();
3171					primaryMenuMaxWidth();
3172					adjustWidgetImageCaptionsWidth();
3173					captureCurrentViewportHeight();
3174					checkGridFillerCard();
3175					createListingGallery();
3176					equalizeCallToActionColumnsHeights( true );
3177					fixGutenbergAlignFull();
3178					fixPopupHeights();
3179					setFallbackNoReviewContentHeight();
3180					chechListingTopbarButtonsQty();
3181					verifyBootstrapAccordions();
3182				}// End if().
3183
3184				setTimeout( function () {
3185					preventEvenCallStack7 = false;
3186				}, 1500 );
3187
3188			}, resetDelay );
3189		}// End if().
3190	}
3191
3192	function fixPopupHeights() {
3193		setTimeout( function () {
3194
3195			/* Set proper heights to popups based on the device viewport height */
3196			var currentViewportHeight = viewport().height;
3197
3198			$( 'body > [class*="-popup"]' ).css( { height : currentViewportHeight, 'line-height' : currentViewportHeight + 'px' } );
3199		}, 250 );
3200	}
3201
3202	function setUserFormsPosition() {
3203		var
3204			screenHeight = viewport().height,
3205			formRecipient,
3206			formRecipientHeight = 0,
3207			topbarheight = headerTopbarDistance();
3208
3209		if ( $( '.site-header' ).length ) {
3210			topbarheight = $( '.site-header' ).height();
3211		}
3212
3213		if ( $( '#password-form' ).length ) {
3214			formRecipient = $( '#password-form' ).parent().parent().parent().parent();
3215			formRecipientHeight = formRecipient.height();
3216
3217			if ( screenHeight - topbarheight - 120 > formRecipientHeight ) {
3218				formRecipient.css( { display : 'inline-block', top : '50%', marginTop : - ( formRecipientHeight / 2 ) + topbarheight / 2 } );
3219				formRecipient.parent().css( { height : screenHeight, marginTop : 0, 'overflow-y' : 'hidden' } );
3220			} else {
3221				if ( 60 !== topbarheight ) {
3222					formRecipient.css( { display : 'inline-block', top : 0, marginTop : '55px' } );
3223				} else {
3224					formRecipient.css( { display : 'inline-block', top : 0, marginTop : 0 } );
3225				}
3226				formRecipient.parent().css( { height : screenHeight - topbarheight, marginTop : topbarheight, 'overflow-y' : 'auto' } );
3227			}
3228
3229			formRecipient.parent().parent().css( { width : '100%', position : 'relative', display : 'table', 'text-align' : 'center' } );
3230		}
3231
3232		if ( $( '.listar-search-popup' ).length ) {
3233			formRecipientHeight = $( '.listar-search-popup .listar-listing-categories' ).height() + 130;
3234
3235			if ( screenHeight - topbarheight - 60 > formRecipientHeight ) {
3236				$( '.listar-search-popup' ).removeClass( 'listar-search-short-height' );
3237			} else {
3238				$( '.listar-search-popup' ).addClass( 'listar-search-short-height' );
3239			}
3240		}
3241
3242		if ( $( '.listar-front-header, .listar-search-popup' ).length ) {
3243			var thisElement = $( '.listar-front-header, .listar-search-popup' );
3244			var heroSearch = thisElement.find( '.listar-hero-search' );
3245
3246			if ( viewport().width <= 480 ) {
3247				thisElement.stop().css( { height : '' } );
3248				heroSearch.stop().animate( { marginTop : '40px' }, { duration : 10 } );
3249			} else {
3250				thisElement.stop().css( { height : '' } );
3251				heroSearch.stop().animate( { marginTop : '20px' }, { duration : 10 } );
3252			}
3253		}
3254	}
3255
3256	function viewport() {
3257		var
3258			e = window,
3259			a = 'inner';
3260
3261		if ( ! ( 'innerWidth' in window ) ) {
3262			a = 'client';
3263			e = document.documentElement || document.body;
3264		}
3265
3266		return { width : e[ a + 'Width' ], height : e[ a + 'Height' ] };
3267	}
3268
3269	/* Check if a element starts to become visible on viewport */
3270	function isInViewport( elem, verticalMargin ) {
3271		var	elementTop;
3272		
3273		if ( 'undefined' !== typeof elem ) {
3274			if ( 'undefined' !== typeof elem.offset() ) {
3275				if ( 'undefined' !== elem.offset().top ) {
3276					elementTop = elem.offset().top;
3277				}
3278			}
3279		}
3280		
3281		var
3282			elementBottom = elementTop + elem.outerHeight(),
3283			viewportTop = $( window ).scrollTop();
3284		var	viewportBottom = viewportTop + $( window ).height();
3285
3286		if ( 'undefined' === typeof verticalMargin ) {
3287			verticalMargin = 0;
3288		}
3289
3290		return elementBottom - verticalMargin > viewportTop && elementTop + verticalMargin < viewportBottom;
3291	}
3292
3293	/* Move background image URL from 'data-background-image' attribute to 'background-image' style */
3294	function convertDataBackgroundImage( elem, forceConversion ) {
3295
3296		if ( 'undefined' === typeof elem ) {
3297			elem = $( '[data-background-image]' );
3298		}
3299
3300		if ( 'undefined' === typeof forceConversion ) {
3301			forceConversion = false;
3302		}
3303
3304		var doElements = [];
3305
3306		elem.each( function () {
3307			doElements.push( $( this ) );
3308		} );
3309
3310		/* Lazy Load - Set one image every 250ms */
3311
3312
3313		var setBgInterval = setInterval( function () {
3314			if ( doElements.length ) {
3315				var firstDoElem = doElements[0];
3316
3317				if ( firstDoElem[0].hasAttribute( 'data-background-image' ) ) {
3318					var bg = firstDoElem.attr( 'data-background-image' );
3319					var bg2 = firstDoElem.css( 'background-image' );
3320					var dataImageChanged = false;
3321					var src = '';
3322
3323					if ( firstDoElem[0].hasAttribute( 'data-background-image-mobile' ) && viewport().width < 420 ) {
3324						bg = firstDoElem.attr( 'data-background-image-mobile' );
3325					}
3326
3327					if ( firstDoElem.hasClass( 'listar-term-on-popup' ) ) {
3328						if ( firstDoElem.parents( '.listar-listing-regions-popup, .listar-listing-categories-popup' ).hasClass( 'listar-toggle-background-image' ) ) {
3329							firstDoElem.removeClass( 'listar-term-on-popup' );
3330						} else {
3331							return false;
3332						}
3333					}
3334
3335					if ( 'IMG' === firstDoElem.prop( 'tagName' ) ) {
3336						src = firstDoElem.attr( 'src' );
3337					}
3338
3339					if ( '' !== bg && '0' !== bg && undefined !== bg && -1 === bg2.indexOf( 'Ow==' ) && '==' !== src.substr( src.length - 2 ) ) {
3340
3341						/* Skip if image URL was sanitized and printed as http://0
3342						 * or similar (with /0 at end), meaning that no real background image was attributed to the element
3343						 */
3344						if ( '/0' !== bg.substr( bg.length - 2 ) && '0/' !== bg.substr( bg.length - 2 ) && '==' !== bg.substr( bg.length - 2 ) ) {
3345							if ( bg !== 'temp-data' ) {
3346								preloadImages( [ bg ], true );
3347
3348								if ( ! firstDoElem[0].hasAttribute( 'data-force-img' ) ) {
3349									firstDoElem.css( { 'background-image' : 'url(' + bg + ')' } );
3350								} else {
3351									firstDoElem.attr( 'src', bg );
3352									firstDoElem.removeAttr( 'data-force-img' );
3353								}
3354							} else {
3355								if ( firstDoElem.hasClass( 'listar-page-header' ) ) {
3356
3357									var background = firstDoElem.css( 'background-image' );
3358
3359									firstDoElem.removeAttr( 'data-background-image' );
3360									firstDoElem.removeAttr( 'data-force-img' );
3361
3362									if ( 'IMG' === firstDoElem.prop( 'tagName' ) ) {
3363										src = firstDoElem.attr( 'src' );
3364									}
3365
3366									if (
3367										'/0' === src.substr( src.length - 2 ) ||
3368										'0/' === src.substr( src.length - 2 ) ||
3369										'==' === src.substr( bg.length - 2 ) ||
3370										'/0")' === background.substr( background.length - 4 ) ||
3371										'0/")' === background.substr( background.length - 4 ) ||
3372										'==")' === background.substr( background.length - 4 )
3373										) {
3374										return;
3375									}
3376								}
3377							}
3378
3379							if ( firstDoElem.hasClass( 'author-avatar' ) || firstDoElem.hasClass( 'listar-no-image' ) ) {
3380								dataImageChanged = true;
3381							}
3382
3383							firstDoElem.removeClass( 'listar-no-image' );
3384
3385							/* Skip icons as image */
3386							if ( ! firstDoElem.parent().hasClass( 'listar-image-icon' ) && ! dataImageChanged  ) {
3387								/* Sometimes the 'listar-no-image' class is attributed to parent element (max 4 levels) */
3388								if ( firstDoElem.parents( '.listar-card-content' ).hasClass( 'listar-no-image' ) ) {
3389									firstDoElem.parents( '.listar-card-content' ).removeClass( 'listar-no-image' );
3390								} else if ( firstDoElem.hasClass( 'listar-no-image' ) ) {
3391									firstDoElem.removeClass( 'listar-no-image' );
3392								} else if ( firstDoElem.parent().hasClass( 'listar-no-image' ) ) {
3393									firstDoElem.parent().removeClass( 'listar-no-image' );
3394								} else if ( firstDoElem.parent().parent().hasClass( 'listar-no-image' ) ) {
3395									firstDoElem.parent().parent().removeClass( 'listar-no-image' );
3396								} else if ( firstDoElem.parent().parent().parent().hasClass( 'listar-no-image' ) ) {
3397									firstDoElem.parent().parent().parent().removeClass( 'listar-no-image' );
3398								} else if ( firstDoElem.parent().parent().parent().parent().hasClass( 'listar-no-image' ) ) {
3399									firstDoElem.parent().parent().parent().parent().removeClass( 'listar-no-image' );
3400								}
3401							}
3402						}// End if().
3403					}// End if().
3404
3405					firstDoElem.removeAttr( 'data-background-image' );
3406				}
3407			} else {
3408				clearInterval( setBgInterval );
3409			}
3410
3411			doElements.shift();
3412		}, 150 );
3413	}
3414
3415	function prepareCatsUnderSearchField() {
3416		if ( ! $( '.listar-search-categories' ).hasClass( 'listar-showing-more-cats' ) ) {
3417			if ( $( '.listar-search-categories .listar-listing-categories' ).height() / $( '.listar-search-categories' ).height() > 1.73 ) {
3418				$( '.listar-search-categories' ).removeClass( 'listar-hidden-category-nav' );
3419			} else {
3420				$( '.listar-search-categories' ).addClass( 'listar-hidden-category-nav' );
3421			}
3422		}
3423	}
3424
3425	function prepareMainMenu() {
3426		if ( viewport().width > 767 && ! isMobile() ) {
3427			$( '#listar-primary-menu > .navbar-nav li a.dropdown-toggle' ).each( function () {
3428				if ( '' !== $( this ).attr( 'href' ) && '#' !== $( this ).attr( 'href' ) ) {
3429					$( this ).addClass( 'disabled' );
3430				}
3431			} );
3432		} else {
3433			$( '#listar-primary-menu > .navbar-nav li a.dropdown-toggle' ).each( function () {
3434				$( this ).removeClass( 'disabled' );
3435			} );
3436		}
3437	}
3438
3439	function prepareHeaderListings() {
3440		setTimeout( function () {
3441			if ( viewport().width > 1300 ) {
3442				$( '.listar-hero-header .listar-aside-list' ).stop().animate( { right : [ 0, 'easeOutExpo' ] }, { duration : 500 } );
3443			}
3444		}, 100 );
3445	}
3446
3447	function mobileMenuMaxHeight() {
3448		if ( viewport().width <= 767 ) {
3449			$( '.listar-full-dimming-overlay' ).css( { 'height' : viewport().height + 2, 'max-height' : viewport().height + 2 } );
3450		} else {
3451			$( '#listar-primary-menu, .listar-full-dimming-overlay' ).css( { 'height' : 'auto' } );
3452		}
3453	}
3454
3455	function checkGrid() {
3456		if ( viewport().width < 600 ) {
3457			if ( ! $( '.listar-grid' ).hasClass( 'listar-hold-grid' ) ) {
3458				if ( $( '.listar-grid' ).hasClass( 'listar-grid2' ) ) {
3459					hasGrid2 = 1;
3460					$( '.listar-grid' ).removeClass( 'listar-grid2' );
3461				}
3462				if ( $( '.listar-grid' ).hasClass( 'listar-grid3' ) ) {
3463					hasGrid3 = 1;
3464					$( '.listar-grid' ).removeClass( 'listar-grid3' );
3465				}
3466			}
3467		} else if ( hasGrid2 ) {
3468			$( '.listar-grid' ).addClass( 'listar-grid2' );
3469		} else if ( hasGrid3 ) {
3470			$( '.listar-grid' ).addClass( 'listar-grid3' );
3471		}
3472	}
3473
3474	function bodyWrapperOverflow() {
3475		if ( isMobile() ) {
3476			theBody.addClass( 'listar-is-mobile' );
3477			theBody.removeClass( 'listar-is-desktop' );
3478		} else {
3479			theBody.addClass( 'listar-is-desktop' );
3480			theBody.removeClass( 'listar-is-mobile' );
3481		}
3482	}
3483
3484	function setTooltips() {
3485		setTimeout( function () {
3486			if ( isMobile() ) {
3487				$( '[data-toggle="tooltip"]' ).tooltip( 'disable' );
3488			} else {
3489				$( '[data-toggle="tooltip"]' ).tooltip( 'enable' );
3490			}
3491		}, 1000 );
3492	}
3493
3494	function moreCategoriesButtonVisibility() {
3495
3496		/* To front page hero header and search popup */
3497		if ( $( '.listar-search-categories .listar-listing-categories .listar-listing-categories-inner > div' ).length ) {
3498
3499			setTimeout( function () {
3500				if ( $( '.listar-search-categories .listar-listing-categories .listar-listing-categories-inner > div' )[0].scrollHeight > 165 ) {
3501					$( '.listar-search-categories .listar-more-categories' ).css( { display : 'block' } );
3502					$( '.listar-search-categories' ).removeClass( 'listar-hidden-category-nav' );
3503				} else {
3504					$( '.listar-search-categories .listar-more-categories' ).css( { display : 'none' } );
3505					$( '.listar-search-categories' ).addClass( 'listar-hidden-category-nav' );
3506				}
3507
3508				if ( $( '.listar-search-categories .listar-no-icon' ).length ) {
3509					if ( $( '.listar-search-categories .listar-no-icon' ).length === $( '.listar-search-categories a' ).length ) {
3510						if ( $( '.listar-search-categories .listar-listing-categories .listar-listing-categories-inner > div' )[0].scrollHeight < 70 ) {
3511							$( '.listar-search-categories' ).removeClass( 'listar-no-icons-two-lines' ).addClass( 'listar-no-icons-one-line' );
3512						} else {
3513							$( '.listar-search-categories' ).removeClass( 'listar-no-icons-one-line' ).addClass( 'listar-no-icons-two-lines' );
3514							$( '.listar-search-categories .listar-more-categories' ).css( { top : 90 } );
3515						}
3516					}
3517				}
3518			}, 1000 );
3519		}
3520	}
3521
3522	function resetOwlCarousel( selector ) {
3523		if ( selector.length ) {
3524			selector.each( function () {
3525				var carousel = $( this );
3526
3527				if ( carousel.hasClass( 'owl-loaded' ) ) {
3528					carousel.owlCarousel( 'destroy' );
3529					carousel.owlCarousel( { touchDrag : false, mouseDrag : false } );
3530					carousel.find( '.owl-stage-outer' ).children().unwrap();
3531					carousel.find( '.owl-stage' ).children().unwrap();
3532					carousel.find( '.owl-item.cloned' ).prop( 'outerHTML', '' );
3533					carousel.find( '.owl-item' ).children().unwrap();
3534					carousel.removeData();
3535					carousel.removeClass( 'owl-loaded' );
3536					carousel.find( '.owl-nav, .owl-dots' ).each( function () {
3537						$( this ).prop( 'outerHTML', '' );
3538					} );
3539				}
3540
3541			} );
3542		}
3543	}
3544
3545	function initOwlCarousel( selector, skipPopups ) {
3546		selector.each( function () {
3547			var carousel = $( this );
3548
3549			if ( true === skipPopups ) {
3550				if ( $( this ).parents( '.listar-hero-header' ).length > 0 ) {
3551					return;
3552				}
3553			}
3554
3555			var
3556				carouselItems		= carousel.find( '.listar-featured-listing-term-item, .listar-listing-card, .listar-partner-wrapper' ),
3557				carouselLateralMargin	= 30,
3558				carouselSteps		= 1,
3559				carouselCenter		= true,
3560				carouselStagePadding	= 10,
3561				carouselRequiredColumns = 1;
3562
3563			if ( carousel.find( '.listar-grid-filler' ).length ) {
3564				carousel.find( '.listar-grid-filler' ).prop( 'outerHTML', '' );
3565			}
3566
3567			$( '.listar-listing-categories-popup .listar-featured-listing-term-item,.listar-listing-regions-popup .listar-featured-listing-term-item' ).css( { display : 'none' } );
3568
3569			carouselItems.css( { opacity : 0 } );
3570			carousel.find( '.listar-term-text-wrapper' ).removeClass( 'listar-lateral-padding' );
3571
3572			setTimeout( function () {
3573				var scrollbarWidth = getScrollBarWidth();
3574
3575				if ( viewport().width > 3125 ) {
3576					carouselRequiredColumns	= 99999; // Don't create carousels.
3577				} else if ( viewport().width > 2720 ) {
3578					carouselRequiredColumns	= 7;
3579					carouselStagePadding = ( viewport().width - 2686.8 - scrollbarWidth ) / 2;
3580
3581					if ( 8 === carouselItems.length ) {
3582						carouselSteps = 1;
3583					} else if ( 9 === carouselItems.length ) {
3584						carouselSteps = 2;
3585					} else if ( 10 === carouselItems.length ) {
3586						carouselSteps = 3;
3587					} else if ( 11 === carouselItems.length ) {
3588						carouselSteps = 4;
3589					} else if ( 12 === carouselItems.length ) {
3590						carouselSteps = 5;
3591					} else if ( 13 === carouselItems.length ) {
3592						carouselSteps = 6;
3593					} else if ( carouselItems.length > 13 ) {
3594						carouselSteps = 7;
3595					}
3596				} else if ( viewport().width > 2332 ) {
3597					carouselRequiredColumns	= 6;
3598					carouselCenter = false;
3599					carouselStagePadding = ( viewport().width - 2300 - scrollbarWidth ) / 2;
3600
3601					if ( 7 === carouselItems.length ) {
3602						carouselSteps = 1;
3603					} else if ( 8 === carouselItems.length ) {
3604						carouselSteps = 2;
3605					} else if ( 9 === carouselItems.length ) {
3606						carouselSteps = 3;
3607					} else if ( 10 === carouselItems.length ) {
3608						carouselSteps = 4;
3609					} else if ( 11 === carouselItems.length ) {
3610						carouselSteps = 5;
3611					} else if ( carouselItems.length > 11 ) {
3612						carouselSteps = 6;
3613					}
3614				} else if ( viewport().width > 1938 ) {
3615					carouselRequiredColumns	= 5;
3616					carouselStagePadding = ( viewport().width - 1913.3 - scrollbarWidth ) / 2;
3617
3618					if ( 6 === carouselItems.length ) {
3619						carouselSteps = 1;
3620					} else if ( 7 === carouselItems.length ) {
3621						carouselSteps = 2;
3622					} else if ( 8 === carouselItems.length ) {
3623						carouselSteps = 3;
3624					} else if ( 9 === carouselItems.length ) {
3625						carouselSteps = 4;
3626					} else if ( carouselItems.length > 9 ) {
3627						carouselSteps = 5;
3628					}
3629				} else if ( viewport().width > 1547 ) {
3630					carouselRequiredColumns	= 4;
3631					carouselCenter = false;
3632					carouselStagePadding = ( viewport().width - 1536.7 - scrollbarWidth ) / 2;
3633
3634					if ( 5 === carouselItems.length ) {
3635						carouselSteps = 1;
3636					} else if ( 6 === carouselItems.length ) {
3637						carouselSteps = 2;
3638					} else if ( 7 === carouselItems.length ) {
3639						carouselSteps = 3;
3640					} else if ( carouselItems.length > 7 ) {
3641						carouselSteps = 4;
3642					}
3643
3644				} else if ( viewport().width > 1199 ) {
3645					carouselRequiredColumns	= 3;
3646					carouselStagePadding = ( viewport().width - 1140 - scrollbarWidth ) / 2;
3647
3648					if ( 5 === carouselItems.length ) {
3649						carouselSteps = 2;
3650					} else if ( carouselItems.length > 5 ) {
3651						carouselSteps = 3;
3652					}
3653
3654				} else if ( viewport().width > 991 ) {
3655					carouselRequiredColumns	= 3;
3656					carouselStagePadding = ( viewport().width - 940 - scrollbarWidth ) / 2;
3657
3658					if ( 5 === carouselItems.length ) {
3659						carouselSteps = 2;
3660					} else if ( carouselItems.length > 5 ) {
3661						carouselSteps = 3;
3662					}
3663
3664				} else if ( viewport().width > 767 ) {
3665					carouselRequiredColumns	= 2;
3666					carouselStagePadding = ( viewport().width - 720 - scrollbarWidth ) / 2;
3667					carouselCenter = false;
3668
3669					if ( carouselItems.length >= 4 ) {
3670						carouselSteps = 2;
3671					}
3672				}// End if().
3673
3674				if ( carouselItems.length > carouselRequiredColumns && 0 === carouselItems.parents( '#secondary' ).length && 0 === carouselItems.parents( 'footer' ).length ) {
3675					if ( carousel.hasClass( 'owl-loaded' ) ) {
3676						carousel.data( 'owl.carousel' ).options.center = carouselCenter;
3677						carousel.data( 'owl.carousel' ).options.stagePadding = carouselStagePadding;
3678						carousel.data( 'owl.carousel' ).options.margin = carouselLateralMargin;
3679						carousel.data( 'owl.carousel' ).options.items = carouselRequiredColumns;
3680						carousel.data( 'owl.carousel' ).options.slideBy = carouselSteps;
3681						carousel.trigger( 'refresh.owl.carousel' );
3682					} else {
3683						var owlNavTop = 0;
3684							carousel.parent().removeClass( 'container container-fluid' );
3685							carousel.removeClass( 'row' );
3686							carousel.find( '[class*=col-]' ).removeClass( 'col-xs-12 col-sm-6 col-md-4 col-md-8' );
3687							carousel.css( { opacity : 0 } );
3688
3689						carousel.owlCarousel( {
3690							loop	     : true,
3691							nav	     : true,
3692							dots	     : false,
3693							center	     : carouselCenter,
3694							stagePadding : carouselStagePadding,
3695							margin	     : carouselLateralMargin,
3696							items	     : carouselRequiredColumns,
3697							slideBy	     : carouselSteps
3698						} );
3699
3700						if ( carousel.find( '.listar-listing-card' ).length ) {
3701							owlNavTop = carousel.find( '.listar-card-content-title-centralizer' ).eq( 0 ).height() / 2 + 38;
3702							carousel.find( '.owl-nav [class*=owl-]' ).css( { marginTop : 0, top : owlNavTop } );
3703						}
3704
3705					}
3706				} else {
3707					carousel.removeClass( 'listar-carousel-loop listar-use-carousel owl-carousel owl-theme' );
3708					carousel.parent().removeClass( 'container-fluid' ).addClass( 'container' );
3709				}// End if().
3710
3711			}, 200 );
3712
3713			setTimeout( function () {
3714				carousel.find( '.listar-featured-listing-term-item, .listar-listing-card, .listar-partner-wrapper' ).css( { opacity : 1 } );
3715				carousel.css( { opacity : 0 } ).stop().animate( { opacity : 1 }, { duration : 1500 } );
3716				carousel.find( '.listar-term-text-wrapper' ).addClass( 'listar-lateral-padding' );
3717
3718				$( '.listar-listing-categories-popup .listar-featured-listing-term-item,.listar-listing-regions-popup .listar-featured-listing-term-item' ).css( { display : 'block' } );
3719
3720				carousel.stop().animate( { opacity : 1 }, { duration : 800 } );
3721
3722				if ( carousel.parents( '.entry-content' ).length ) {
3723					carousel.stop().css( { opacity : '' } );
3724					carousel.find( '.listar-featured-listing-term-item, .listar-listing-card' ).stop().css( { opacity : '' } );
3725				}
3726
3727				if ( $( '.owl-stage-outer .listar-partner-wrapper' ).length ) {
3728					heightEqualizer( '.listar-partner-wrapper', true, true, true );
3729				}
3730
3731			}, 500 );
3732		} );
3733
3734		$( '.listar-carousel-loop.owl-carousel' ).not( '.listar-use-carousel' ).each( function () {
3735			$( this ).parent().removeClass( 'container-fluid' ).addClass( 'container' );
3736			$( this ).removeClass( 'listar-carousel-loop listar-use-carousel owl-carousel owl-theme' );
3737		} );
3738	}
3739
3740	function checkFrontPageTopbar() {
3741		var
3742			scrollTop = theDocument.scrollTop(),
3743			b = theBody;
3744
3745		if ( scrollTop >= 5 ) {
3746			if ( true === isFrontPage && - 1 !== b.attr( 'class' ).indexOf( 'listar-frontpage-topbar-transparent' ) ) {
3747				b.removeClass( 'listar-frontpage-topbar-transparent' );
3748			}
3749		} else {
3750			if ( headerTransparentTopbar ) {
3751				b.addClass( 'listar-frontpage-topbar-transparent' );
3752			}
3753		}
3754	}
3755
3756	/* Equalize the height of elements - Cross browser solution */
3757
3758	function heightEqualizer( elem, forceLineHeight, forceParentReference, forceVerticalPadding ) {
3759
3760		var skipEqualizer = false;
3761
3762		if ( disableHeightEqualizerListingCards && 'string' === typeof elem ) {
3763			if ( elem.indexOf( 'listar-listing-card' ) >= 0 ) {
3764				if ( $( '.listar-load-card-content-ajax' ).length ) {
3765					return;
3766				}
3767			}
3768		}
3769
3770		var
3771			waitToEqualize  = isLoadMoreEqualizer ? 250 : 500,
3772			waitToEqualize2 = isLoadMoreEqualizer ? 250 : 1000;
3773
3774		isLoadMoreEqualizer = false;
3775
3776		clearTimeout( readyForHoverTimeout );
3777
3778		theBody.removeClass( 'listar-ready-for-hover' );
3779
3780		if ( 'undefined' === typeof forceLineHeight ) {
3781			forceLineHeight = false;
3782		}
3783
3784		if ( 'undefined' === typeof forceParentReference ) {
3785			forceParentReference = false;
3786		}
3787
3788		if ( 'undefined' === typeof forceVerticalPadding ) {
3789			forceLineHeight = false;
3790		}
3791
3792		if ( viewport().width > 767 ) {
3793			if ( elem.indexOf( 'listar-feature-item' ) >= 0 ) {
3794				waitToEqualize  += 500;
3795				$( '.listar-feature-item.listar-feature-has-link ~ .listar-feature-fix-bottom-padding' ).removeClass( 'listar-fix-feature-arrow-button-height' );
3796			}
3797
3798			setTimeout( function () {
3799				var parent = 0,
3800					heights = 0,
3801					minHeight = 0;
3802
3803				$( elem ).each( function () {
3804					if ( $( this ).attr( 'class' ).indexOf( 'listar-grid-design-image-block' ) >= 0 ) {
3805						skipEqualizer = true;
3806						$( this ).addClass( 'listar-height-changed' );
3807						return;
3808					}
3809
3810					$( this ).height( '' );
3811
3812					if ( ! $( this )[0].hasAttribute( 'data-line-height' ) ) {
3813						$( this ).attr( 'data-line-height', $( this ).css( 'line-height' ) );
3814					}
3815
3816					if ( forceLineHeight ) {
3817						$( this ).css( { 'line-height' : '120px' } );
3818					}
3819				} );
3820
3821				if ( ! skipEqualizer ) {
3822
3823					$( '.listar-feature-content-wrapper' ).each( function () {
3824						$( this ).css( { paddingTop : 0 } );
3825					} );
3826
3827					setTimeout( function () {
3828						var heightFixApplied = false;
3829
3830						$( elem ).each( function () {
3831							if ( 0 === $( this ).parents( '#secondary' ).length && 0 === $( this ).parents( 'footer' ).length ) {
3832								var parentClass = $( this ).parent().attr( 'class' ),
3833									realParent = 0;
3834
3835								/* Detects the original parent after Owl Carousel has beent initiated */
3836								if ( parentClass.indexOf( 'owl' ) >= 0 ) {
3837									realParent = $( this ).parent().parent().parent().parent();
3838								} else {
3839									realParent = $( this ).parent();
3840								}
3841
3842								if ( false !== forceParentReference ) {
3843									realParent = $( this ).parents( forceParentReference );
3844								}
3845
3846								if ( parent !== realParent ) {
3847									parent  = realParent;
3848
3849									heights = parent.find( elem ).map( function () {
3850										return $( this ).height();
3851									} ).get();
3852
3853									minHeight = Math.max.apply( null, heights );
3854								}
3855
3856								if ( $( this ).find( '.listar-feature-item' ).length && ! heightFixApplied ) {
3857									heightFixApplied = true;
3858									minHeight += 25;
3859								}
3860
3861								$( this ).height( minHeight );
3862
3863								if ( forceLineHeight ) {
3864									$( this ).css( { 'line-height' : ( minHeight - 90 ) + 'px' } );
3865								}
3866
3867								if ( $( this ).find( '.listar-feature-item.listar-feature-has-link' ).length ) {
3868									$( this ).find( '.listar-feature-item.listar-feature-has-link ~ .listar-feature-fix-bottom-padding' ).addClass( 'listar-fix-feature-arrow-button-height' );
3869								}
3870
3871								$( this ).addClass( 'listar-height-changed' );
3872							}
3873						} );
3874					}, waitToEqualize2 );
3875				}
3876			}, waitToEqualize );
3877		} else {
3878			$( elem ).each( function () {
3879				if ( $( this ).attr( 'class' ).indexOf( 'listar-grid-design-image-block' ) >= 0 ) {
3880					skipEqualizer = true;
3881					return;
3882				}
3883
3884				$( this ).height( '' );
3885
3886				if ( ! $( this )[0].hasAttribute( 'data-line-height' ) ) {
3887					$( this ).attr( 'data-line-height', $( this ).css( 'line-height' ) );
3888				}
3889
3890				if ( forceLineHeight ) {
3891					$( this ).css( { 'line-height' : '150px' } );
3892				}
3893			} );
3894		}// End if().
3895
3896		readyForHoverTimeout = setTimeout( function () {
3897			theBody.addClass( 'listar-ready-for-hover' );
3898		}, waitToEqualize + 1500 );
3899	}
3900
3901	/* Compensate different "content" heights between listing feature blocks / centralize contents vertically */
3902
3903	function adjustFeatureBlocks() {
3904		var timeOut = viewport().width < 500 ? 0 : 0;
3905
3906		setTimeout( function () {
3907			if ( $( '.listar-features-design-2 .listar-feature-without-image .listar-feature-item' ).length ) {
3908				$( '.listar-features-design-2' ).each( function () {
3909					if ( $( this ).find( '.listar-feature-item-wrapper' ).length ) {
3910						if ( $( this ).find( '.listar-feature-item-wrapper' ).eq( 0 ).hasClass( 'listar-feature-without-image' ) ) {
3911							$( this ).addClass( 'listar-features-without-image' );
3912						}
3913					}
3914				} );
3915			}
3916		}, timeOut );
3917	}
3918
3919	/* Equalize call to action columns heights */
3920
3921	function equalizeCallToActionColumnsHeights( isResizing ) {
3922		if ( 'undefined' === typeof isResizing ) {
3923			isResizing = false;
3924		}
3925
3926		if ( preventEvenCallStack10 ) {
3927			return;
3928		}
3929
3930		preventEvenCallStack10 = true;
3931
3932		setTimeout( function () {
3933			callToActionsBoxedSquared.each( function () {
3934				var thisElem   = $( this );
3935				var halfBorder = thisElem.find( '.listar-half-call-to-action-border' );
3936
3937				if ( isResizing ) {
3938					thisElem.removeClass( 'listar-call-to-action-cols-equalized' );
3939				}
3940
3941				if ( ! thisElem.hasClass( 'listar-call-to-action-cols-equalized' ) ) {
3942					if ( isInViewport( thisElem ) ) {
3943						if ( viewport().width > 767 ) {
3944							thisElem.find( '.listar-equalize-container-height' ).each( function () {
3945								$( this ).css( { height : $( this ).parents( '.listar-call-to-action-inner' ).height() } );
3946							} );
3947						} else {
3948							thisElem.find( '.listar-equalize-container-height' ).each( function () {
3949								$( this ).css( { height : '' } );
3950							} );
3951						}
3952
3953						$( this ).addClass( 'listar-call-to-action-cols-equalized' );
3954					}
3955				}
3956
3957				if ( halfBorder.length ) {
3958					halfBorder.css( { width : thisElem.find( '.listar-call-to-action-first-content-wrapper' ).width() } );
3959				}
3960			} );
3961		}, 1500 );
3962
3963		setTimeout( function () {
3964			preventEvenCallStack10 = false;
3965		}, 250 );
3966	}
3967
3968	/* Equalize WordPress gallery item heights */
3969
3970	function equalizeWordPressGalleryHeights() {
3971		setTimeout( function () {
3972			$( '.gallery' ).each( function () {
3973				var gallery = $( this );
3974				/* Get the highest gallery item height */
3975				var minHeight = gallery.find( '.gallery-item' ).eq( 0 ).height();
3976
3977				gallery.find( '.gallery-item img' ).css( { width : '', marginleft : '' } );
3978
3979				gallery.find( '.gallery-item' ).each( function () {
3980					var
3981						diffImageWidth,
3982						imageWidth = $( this ).find( 'img' ).width(),
3983						checkHeight = minHeight / $( this ).find( 'img' ).height();
3984
3985					if ( checkHeight > 1 ) {
3986						diffImageWidth = ( ( imageWidth * checkHeight ) - imageWidth ) / 2;
3987
3988						$( this ).find( 'img' ).css( { width : imageWidth * checkHeight + 'px' } );
3989						$( this ).find( 'img' ).css( { marginLeft : - diffImageWidth + 'px' } );
3990					}
3991				} );
3992			} );
3993
3994			initOnScrollEffects();
3995		}, 500 );
3996
3997		/* For Gutenberg gallery */
3998		setTimeout( function () {
3999			$( '.wp-block-gallery, .gallery' ).each( function () {
4000				var gallery = $( this );
4001
4002				gallery.removeClass( 'listar-equalize-gallery' );
4003
4004				setTimeout( function () {
4005					gallery.find( 'img' ).each( function () {
4006						var galleryImg = $( this );
4007						galleryImg.css( { height : 'auto', width : 'auto', 'min-width' : '' } );
4008
4009						var imgWidth = galleryImg.width();
4010						var imgHeight = galleryImg.height();
4011						var proportion = imgWidth / imgHeight;
4012						var newHeight = galleryImg.parents( '.blocks-gallery-item,.gallery-item' ).height();
4013						var newWidth1 = galleryImg.parents( '.blocks-gallery-item,.gallery-item' ).width();
4014						var newWidth2 = Math.ceil( newHeight * proportion ) + 2;
4015						var newWidth = 0;
4016
4017						if ( newWidth1 > newWidth2 ) {
4018							newWidth = newWidth1;
4019							newHeight = Math.ceil( newWidth / proportion );
4020						} else {
4021							newWidth = newWidth2;
4022						}
4023
4024						if ( 0 !== newWidth % 2 ) {
4025							newWidth++;
4026						}
4027
4028						if ( 0 !== newHeight % 2 ) {
4029							newHeight++;
4030						}
4031
4032						galleryImg.css( { height : newHeight, width : newWidth, 'min-width' : newWidth } );
4033					} );
4034
4035					gallery.addClass( 'listar-equalize-gallery' );
4036				}, 500 );
4037			} );
4038
4039		}, 750 );
4040	}
4041
4042	/* Make video size proportional */
4043
4044	function equalizeVideoHeights() {
4045		setTimeout( function () {
4046			$( 'iframe[allowfullscreen]' ).each( function () {
4047				$( this ).css( { height : ( Math.ceil( $( this ).width() * 0.562 ) ) + 'px' } );
4048			} );
4049
4050			initOnScrollEffects();
4051		}, 500 );
4052	}
4053
4054	function toggleUserMenu() {
4055		var menuRight = thisElement.length ? thisElement.css( 'right' ) : 0;
4056		menuRight = parseInt( menuRight.replace( /[^-\d\.]/g, '' ), 10 );
4057
4058		if ( menuRight < 0 ) {
4059			thisElement.stop().animate( { 'right' : [ 0, 'easeOutExpo' ] }, { duration : 500 } );
4060		} else {
4061			thisElement.stop().animate( { 'right' : - 500 }, { duration : 500 } );
4062		}
4063	}
4064
4065	function mouseleaveUserMenu() {
4066		setTimeout( function () {
4067			if ( closeUserMenu ) {
4068				if ( $( '.listar-logged-user-menu-wrapper' ).length ) {
4069					if ( '0px' === $( '.listar-logged-user-menu-wrapper' ).css( 'right' ) ) {
4070						if ( $( '.listar-user-logged .listar-user-login' ).length ) {
4071							$( '.listar-logged-user-menu-wrapper' ).eq( 0 ).trigger( 'mouseleave' );
4072							closeUserMenu = false;
4073						}
4074					}
4075				}
4076			}
4077		}, 50 );
4078	}
4079
4080	/* AOS (animations on scroll) */
4081
4082	function initOnScrollEffects( skipTimeout ) {
4083		var timeOut  = 2000;
4084		var timeOut2 = 500;
4085
4086		if ( ! animateElementsOnScroll ) {
4087			return;
4088		}
4089
4090		if ( 'undefined' === typeof skipTimeout ) {
4091			skipTimeout = false;
4092		}
4093
4094		if ( $( '[data-aos]' ).length ) {
4095			if ( ! isMobile() ) {
4096				setTimeout( function () {
4097					if ( skipTimeout ) {
4098						setTimeout( function() {
4099							AOS.refresh();
4100						}, 300 );
4101					} else {
4102						appendAOSDelay();
4103
4104						if ( $( '.aos-init' ).length ) {
4105							AOS.refreshHard();
4106						} else {
4107							AOS.init( {
4108								disable: 'mobile'
4109							} );
4110						}
4111
4112						preventAOSObserverFail();
4113
4114						/* Only Owl Carousels must wait a little more */
4115
4116						if ( $( '[data-temp-aos]' ).length ) {
4117							setTimeout( function () {
4118								$( '[data-temp-aos]' ).attr( 'data-aos', 'fade-zoom-in' );
4119								$( '[data-temp-aos]' ).removeAttr( 'data-temp-aos' );
4120
4121								AOS.init( {
4122									disable: 'mobile'
4123								} );
4124
4125								preventAOSObserverFail();
4126
4127							}, timeOut );
4128						}
4129
4130						setTimeout( function() {
4131							AOSRefresh();
4132						}, 30 );
4133					}// End if().
4134
4135				}, timeOut2 );
4136
4137			} else {
4138				preventAOSObserverFail();
4139			}// End if().
4140		}// End if().
4141	}
4142
4143	/* Init effects to elements created with dinamically after Ajax 'load more' */
4144
4145	function ajaxAOS() {
4146		if ( ! animateElementsOnScroll ) {
4147			return;
4148		}
4149
4150		if ( $( '[data-aos]' ).length ) {
4151			if ( ! isMobile() ) {
4152				appendAOSDelay();
4153			}
4154
4155			preventAOSObserverFail();
4156		}
4157	}
4158
4159	/* Prevents fail on AOS observer if not supported by the browser */
4160
4161	function preventAOSObserverFail() {
4162		if ( ! animateElementsOnScroll ) {
4163			return;
4164		}
4165
4166		setTimeout( function () {
4167			if ( $( '[data-aos]' ).not( '.aos-init' ).length ) {
4168
4169				/* Try to init AOS again */
4170				AOS.init( {
4171					disable: 'mobile'
4172				} );
4173
4174				/* If no success, cancel disable AOS to avoid hidden elements */
4175				if ( $( '[data-aos]' ).not( '.aos-init' ).length ) {
4176					$( '[data-aos]' ).not( '.aos-init' ).removeAttr( 'data-aos' );
4177					$( '[data-aos-delay]' ).not( '.aos-init' ).removeAttr( 'data-aos-delay' );
4178				}
4179			}
4180
4181			if ( isMobile() ) {
4182				$( '[data-aos]' ).removeAttr( 'data-aos' );
4183				$( '[data-aos-delay]' ).removeAttr( 'data-aos-delay' );
4184			}
4185		}, 100 );
4186	}
4187
4188	/* Append time delay to AOS elements that are side by side on the screen */
4189
4190	function appendAOSDelay() {
4191		var group = 0;
4192		var delay = 450;
4193		var carouselVisibleDelay = 450;
4194		var carouselClasses = 0;
4195		var yPosition = 0;
4196
4197		if ( ! animateElementsOnScroll ) {
4198			return;
4199		}
4200
4201		$( '[data-aos]' ).each( function () {
4202			var element = $( this );
4203
4204			if ( ! element[0].hasAttribute( 'data-aos-offset' ) ) {
4205				element.attr( 'data-aos-offset', '-450' );
4206			}
4207
4208			if ( element[0].hasAttribute( 'data-aos-group' ) ) {
4209				var currentYPosition = element.offset().top;
4210
4211				if ( element.parents( '.owl-carousel' ).length ) {
4212					if ( carouselClasses === element.parents( '.owl-carousel' ).attr( 'class' ) ) {
4213						if ( element.hasClass( 'active' ) || element.parent().hasClass( 'active' ) || element.parent().parent().hasClass( 'active' ) ) {
4214							carouselVisibleDelay += 450;
4215							element.attr( 'data-aos-delay', carouselVisibleDelay );
4216						} else {
4217							carouselVisibleDelay = 450;
4218						}
4219					} else {
4220						carouselVisibleDelay = 450;
4221					}
4222
4223					carouselClasses = element.parents( '.owl-carousel' ).attr( 'class' );
4224					element.removeAttr( 'data-aos' ).attr( 'data-temp-aos', '1' );
4225				}
4226
4227				if ( group !== element.attr( 'data-aos-group' ) ) {
4228					group = element.attr( 'data-aos-group' );
4229					delay = 450;
4230				}
4231
4232				if ( yPosition === currentYPosition ) {
4233					delay += 450;
4234				} else {
4235					delay = 450;
4236					yPosition = currentYPosition;
4237				}
4238
4239				if ( delay > 1350 && 'header-categories' !== group ) {
4240					delay = 450;
4241				}
4242
4243				if ( ! element[0].hasAttribute( 'data-aos-delay' ) ) {
4244					element.attr( 'data-aos-delay', delay );
4245				}
4246
4247			} else {
4248				delay = 450;
4249			}// End if().
4250		} );
4251	}
4252
4253	/* Scale texts to fulfill the width/height of parent container */
4254
4255	function scaleHeader() {
4256		var
4257			scalable = $( '.listar-term-name-big span' ),
4258			margin	 = viewport().width < 600 ? 130 : 140;
4259
4260		scalable.css( {
4261			'-webkit-transform' : 'scale(1)',
4262			'-moz-transform'    : 'scale(1)',
4263			'-ms-transform'     : 'scale(1)',
4264			'-o-transform'      : 'scale(1)',
4265			'transform'         : 'scale(1)'
4266		} );
4267
4268		scalable.each( function () {
4269			var thisElem = $( this );
4270			var scalableContainer = thisElem.parent();
4271			var parentScaleWidthFactor = scalableContainer.width() / thisElem.width();
4272
4273			var scalableContainerWidth = scalableContainer.width() - margin;
4274			var scalableWidth = thisElem.width();
4275
4276			var scalableContaineHeight = scalableContainer.parent().height() - margin;
4277			var scalableHeight = 14;
4278
4279			var scaleWidth = scalableContainerWidth / scalableWidth;
4280			var scaleHeight = scalableContaineHeight / scalableHeight;
4281			var scale = Math.min( scaleWidth, scaleHeight );
4282
4283			if ( parentScaleWidthFactor < 6 ) {
4284				scaleWidth = ( scalableContainerWidth + margin ) / ( scalableWidth + ( 4 * parentScaleWidthFactor ) );
4285				scaleHeight = scalableContaineHeight / ( scalableHeight + ( 3 * parentScaleWidthFactor ) );
4286				scale = Math.min( scaleWidth, scaleHeight );
4287			}
4288
4289			if ( scale < 0 ) {
4290				setTimeout( function () {
4291					scaleHeader();
4292				}, 500 );
4293			} else {
4294				thisElem.css( {
4295					'-webkit-transform' : 'scale(' + scale + ')',
4296					'-moz-transform'    : 'scale(' + scale + ')',
4297					'-ms-transform'     : 'scale(' + scale + ')',
4298					'-o-transform'      : 'scale(' + scale + ')',
4299					'transform'         : 'scale(' + scale + ')'
4300				} );
4301			}
4302		} );
4303	}
4304
4305	/* Debounce by David Walsch */
4306	/* Link: https://davidwalsh.name/javascript-debounce-function */
4307
4308	function debounce( func, wait, immediate ) {
4309		var timeout;
4310
4311		return function () {
4312			var context = this, args = arguments;
4313			var later = function () {
4314				timeout = null;
4315
4316				if ( ! immediate ) {
4317					func.apply( context, args );
4318				}
4319			};
4320
4321			var callNow = immediate && ! timeout;
4322
4323			clearTimeout( timeout );
4324
4325			timeout = setTimeout( later, wait );
4326
4327			if ( callNow ) {
4328				func.apply( context, args );
4329			}
4330		};
4331	}
4332
4333	function getScrollBarWidth() {
4334		return viewport().width - $( 'html' ).width();
4335	}
4336
4337	/* Fix AOS negative vertical offsets only one time, if available */
4338	/* Because nested AOS offsets not calculate distances properly */
4339
4340	function AOSRefresh() {
4341
4342		if ( ! animateElementsOnScroll ) {
4343			return;
4344		}
4345
4346		$( '.aos-animate[data-aos-offset=-450]' ).each( function() {
4347			var element = $( this );
4348
4349			if ( element.parents( '[data-aos]' ).length ) {
4350				element.attr( 'data-aos-offset', '30' );
4351			} else {
4352				element.attr( 'data-aos-offset', '100' );
4353			}
4354
4355			AOS.refresh();
4356		} );
4357	}
4358
4359	function initListingGalleryScroll() {
4360		setTimeout( function() {
4361			if ( listingGallery.prop( 'scrollWidth' ) > listingGallery.width() + 3 ) {
4362				if ( $.isFunction( $.fn.dragScroll ) ) {
4363					listingGallery.dragScroll( {} );
4364					listingGallery.removeClass( 'listar-no-drag-scroll' );
4365				}
4366			} else {
4367				listingGallery.addClass( 'listar-no-drag-scroll' );
4368			}
4369		}, 500 );
4370	}
4371
4372	function fitMapBounds( listingMap, boundsArray ) {
4373		if ( boundsArray.length > 0 ) {
4374			listingMap.fitBounds( boundsArray );
4375		}
4376	}
4377
4378	/* Get updated nonce for login/register form with Ajax */
4379	/* Useful mainly if a cache plugin is currently installed */
4380
4381	function getUpdatedNonce() {
4382		if ( 'listarAddonsDirectoryURL' in window ) {
4383			var fileURL = window.listarAddonsDirectoryURL + 'inc/get-updated-nonce.php?rand=' + Math.floor( ( Math.random() * 999999999999 ) + 1 );
4384
4385			if ( $( '#login-security' ).length || $( '#listar-private-message-security' ).length || $( '#listar-claim-security' ).length ) {
4386				$.ajax( {
4387					crossDomain: true,
4388					timeout  : 30000,
4389					url: fileURL,
4390					success: function( data ) {
4391						if ( $( data ).find( '#login-security' ).length && $( '#login-security' ).length ) {
4392							$( '#login-security' ).val( $( data ).find( '#login-security' ).val() ).addClass( 'listar-nonce-updated' );
4393						}
4394
4395						if ( $( data ).find( '#register-security' ).length && $( '#register-security' ).length ) {
4396							$( '#register-security' ).val( $( data ).find( '#register-security' ).val() ).addClass( 'listar-nonce-updated' );
4397						}
4398
4399						if ( $( data ).find( '#password-security' ).length && $( '#password-security' ).length ) {
4400							$( '#password-security' ).val( $( data ).find( '#password-security' ).val() ).addClass( 'listar-nonce-updated' );
4401						}
4402
4403						if ( $( data ).find( '#listar-private-message-security' ).length && $( '#listar-private-message-security' ).length ) {
4404							$( '#listar-private-message-security' ).val( $( data ).find( '#listar-private-message-security' ).val() ).addClass( 'listar-nonce-updated' );
4405						}
4406
4407						if ( $( data ).find( '#listar-claim-security' ).length && $( '#listar-claim-security' ).length ) {
4408							$( '#listar-claim-security' ).val( $( data ).find( '#listar-claim-security' ).val() ).addClass( 'listar-nonce-updated' );
4409						}
4410					}
4411				} );
4412			}
4413		}
4414	}
4415
4416	function startCanvas() {
4417		document.addEventListener( 'mousemove', onMouseMove );
4418		window.addEventListener( 'resize', resizeCanvases );
4419		appending.appendChild( imageCanvas );
4420		resizeCanvases();
4421		tickCanvas();
4422	}
4423
4424	function onMouseMove( event ) {
4425		var scroll = 0;
4426
4427		if ( ! $( '.search-popup' ).length ) {
4428			scroll = theDocument.scrollTop();
4429
4430			points.push( {
4431				time : Date.now(),
4432				x : event.clientX,
4433				y : event.clientY + scroll
4434			} );
4435		}
4436	}
4437
4438	function resizeCanvases() {
4439		if ( ! ( 'listarDisableRubber' in window ) && ! isMobile() ) {
4440			theBody.addClass( 'listar-rubber-effect-enabled' );
4441
4442			setTimeout( function () {
4443				
4444				var c = setInterval( function () {
4445					var heroHeaderElements = $( '.listar-front-header, .listar-search-popup' );
4446
4447					if ( heroHeaderElements.length && heroHeaderElements.find( '.listar-rubber-container canvas' ).length ) {
4448						heroHeaderElements.each( function () {
4449							imageCanvas.width = lineCanvas.width = $( this ).find( '.listar-rubber-container' ).width();
4450							imageCanvas.height = lineCanvas.height = $( this ).find( '.listar-rubber-container' ).height();
4451						} );
4452					}
4453				}, 1 );
4454
4455				setTimeout( function () {
4456					clearInterval( c );
4457				}, 200 );
4458			}, 2000 );
4459		} else {
4460			theBody.addClass( 'listar-rubber-effect-disabled' );
4461		}
4462	}
4463
4464	function tickCanvas() {
4465		points = points.filter( function ( point ) {
4466			var age = Date.now() - point.time;
4467			return age < pointLifetime;
4468		});
4469
4470		drawLineCanvas();
4471		drawImageCanvas();
4472		requestAnimationFrame( tickCanvas );
4473	}
4474
4475	function drawLineCanvas() {
4476		var minimumLineWidth = 40;
4477		var maximumLineWidth = 100;
4478		var lineWidthRange   = maximumLineWidth - minimumLineWidth;
4479		var maximumSpeed     = 50;
4480		var pointsCount	     = points.length;
4481
4482		lineCanvasContext.clearRect( 0, 0, lineCanvas.width, lineCanvas.height );
4483		lineCanvasContext.lineCap = 'round';
4484		lineCanvasContext.shadowBlur = 20;
4485		lineCanvasContext.shadowColor = '#000';
4486
4487		for ( var i = 1; i < pointsCount; i++ ) {
4488			var point		= points[ i ];
4489			var previousPoint	= points[ i - 1 ];
4490			var distance		= getDistanceBetween( point, previousPoint );
4491			var speed		= Math.max( 0, Math.min( maximumSpeed, distance ) );
4492			var percentageLineWidth = ( maximumSpeed - speed ) / maximumSpeed;
4493			var age			= Date.now() - point.time;
4494			var opacity		= ( pointLifetime - age ) / pointLifetime;
4495
4496			lineCanvasContext.lineWidth   = minimumLineWidth + percentageLineWidth * lineWidthRange;
4497			lineCanvasContext.strokeStyle = 'rgba(0, 0, 0, ' + opacity + ')';
4498			lineCanvasContext.beginPath();
4499			lineCanvasContext.moveTo( previousPoint.x, previousPoint.y );
4500			lineCanvasContext.lineTo( point.x, point.y );
4501			lineCanvasContext.stroke();
4502		}
4503	}
4504
4505	function getDistanceBetween( a, b ) {
4506		return Math.sqrt( Math.pow( a.x - b.x, 2 ) + Math.pow( a.y - b.y, 2 ) );
4507	}
4508
4509	function drawImageCanvas() {
4510		var top    = 0, left = 0;
4511		var width  = imageCanvas.width;
4512		var height = imageCanvas.width / originalCanvasImage.naturalWidth * originalCanvasImage.naturalHeight;
4513
4514		if ( height < imageCanvas.height ) {
4515			width  = imageCanvas.height / originalCanvasImage.naturalHeight * originalCanvasImage.naturalWidth;
4516			height = imageCanvas.height;
4517			left   = -( width - imageCanvas.width ) / 2;
4518		} else {
4519			top = -( height - imageCanvas.height ) / 2;
4520		}
4521
4522		imageCanvasContext.clearRect( 0, 0, imageCanvas.width, imageCanvas.height );
4523		imageCanvasContext.globalCompositeOperation = 'source-over';
4524		imageCanvasContext.drawImage( originalCanvasImage, left, top, width, height );
4525		imageCanvasContext.globalCompositeOperation = 'destination-in';
4526		imageCanvasContext.drawImage( lineCanvas, 0, 0 );
4527
4528	}
4529
4530	function addCanvasEffect() {
4531		originalCanvasImage = document.querySelector( '.listar-rubber-clear-image' );
4532		appending	    = document.querySelector( '.listar-rubber-container' );
4533		imageCanvas	    = document.createElement( 'canvas' );
4534		imageCanvasContext  = imageCanvas.getContext( '2d' );
4535		lineCanvas	    = document.createElement( 'canvas' );
4536		lineCanvasContext   = lineCanvas.getContext( '2d' );
4537		pointLifetime	    = 1000;
4538		points		    = [];
4539
4540		if ( originalCanvasImage.complete ) {
4541			startCanvas();
4542		} else {
4543			originalCanvasImage.onload = startCanvas;
4544		}
4545	}
4546
4547	function setCanvasEffect() {
4548		if ( ! ( 'listarDisableRubber' in window ) && ! isMobile() && ! ( $( '.listar-hero-gooey-effect' ).length ) ) {
4549			var href = window.location.href;
4550			var dir  = href.substring( 0, href.lastIndexOf( '/' ) ) + '/';
4551			var bgImage;
4552			var heroHeaderElements = $( '.listar-front-header, .listar-search-popup' );
4553
4554			if ( heroHeaderElements.length && heroHeaderElements.find( '.listar-hero-image' ).length ) {
4555
4556				heroHeaderElements.each( function () {
4557					var thisHeader = $( this );
4558
4559					if ( thisHeader.find( '.listar-hero-image' )[0].hasAttribute( 'data-background-image' ) ) {
4560						bgImage = thisHeader.find( '.listar-hero-image' ).attr( 'data-background-image' );
4561					} else {
4562						bgImage = thisHeader.find( '.listar-hero-image' ).css( 'background-image' );
4563					}
4564
4565					if ( bgImage !== 'none' && typeof bgImage !== 'undefined' ) {
4566						bgImage = bgImage.replace( dir, '' );
4567						bgImage = bgImage.replace( ' ', '' ).replace( ' ', '' ).replace( ' ', '' ).replace( ' ', '' ).replace( ' ', '' );
4568						bgImage = bgImage.replace( 'url(\"', '' ).replace( "url(\'", '' ).replace( 'url(', '' ).replace( '")', '' );
4569						bgImage = bgImage.replace( "')", '' ).replace( ')', '' );
4570
4571						thisHeader.append( '<div class="listar-rubber-container listar-rubber-media"><img class="listar-rubber-clear-image" src="' + bgImage + '"></div>' );
4572						addCanvasEffect();
4573					}
4574				} );
4575			}
4576		}
4577	}
4578
4579	function executeAfterLoad() {
4580
4581		var scrollTop = theDocument.scrollTop();
4582
4583		if ( true === isFrontPage && animateElementsOnScroll ) {
4584			var searchCategoriesBottom = scrollTop * 0.3 + 100;
4585			var diff = 0;
4586
4587			if ( searchCategoriesBottom <= 100 ) {
4588				searchCategoriesBottom = 0;
4589				$( '.listar-search-categories' ).addClass( 'listar-categories-fi
4589xed-bottom' );
4590			} else {
4591				$( '.listar-search-categories' ).removeClass( 'listar-categories-fixed-bottom' );
4592			}
4593
4594			if ( $( '.listar-search-categories' ).length || '0px' === $( '.listar-search-categories' ).css( 'bottom' ) ) {
4595				diff = 150;
4596			}
4597
4598			if ( scrollTop < 40 ) {
4599				diff = 0;
4600			}
4601
4602			$( '.listar-front-header .listar-header-centralizer' ).css( { top : '-' + ( scrollTop + diff ) * 0.5 + 'px' } );
4603			$( '.listar-search-categories' ).css( { bottom : searchCategoriesBottom + 'px' } );
4604
4605		}
4606
4607		frontPageCallToActionBadge.each( function () {
4608			if ( $( this ).parent().hasClass( 'listar-animate-wavy-badge' ) ) {
4609
4610				if ( isInViewport( $( this ).parent() ) ) {
4611					$( this ).addClass( 'listar-animate-badge-mask' );
4612				} else {
4613					$( this ).removeClass( 'listar-animate-badge-mask' );
4614				}
4615			}
4616		} );
4617
4618		listarFeaturifyElements.each( function () {
4619			if ( isInViewport( $( this ) ) ) {
4620				$( this ).removeClass( 'listar-hidden-featured-left listar-hidden-featured-right' ).addClass( 'listar-show-featurify' );
4621			}
4622		} );
4623
4624		fixListingTermCardsInnerDistances();
4625		equalizeCallToActionColumnsHeights();
4626	}
4627
4628	function defineHiddenFooterHeight() {
4629		var footerHeight = 0;
4630		var footerHeight2 = 0;
4631
4632		setTimeout( function () {
4633			if ( $( '.listar-footer-navigation-wrapper' ).length ) {
4634				footerHeight = $( '.listar-footer-navigation-wrapper' ).parents( '.navbar' ).height() + 60;
4635			}
4636
4637			if ( $( '.listar-footer-credits .copyright' ).length ) {
4638				footerHeight += $( '.listar-footer-credits .copyright' ).parents( '.listar-container-wrapper' ).height() + 60;
4639			}
4640
4641			if ( $( '.listar-footer-menu' ).length || $( '#colophon .copyright' ).length ) {
4642				if ( $( '#colophon' ).length ) {
4643					footerHeight2 += $( '#colophon' ).height() + 60;
4644				}
4645			}
4646
4647			if ( footerHeight + 150 < viewport().height ) {
4648				theBody.addClass( 'listar-hidden-footer' );
4649				$( '.listar-hidden-footer .listar-site-footer .listar-site-footer-inner' ).css( { marginBottom : footerHeight2 } );
4650			} else {
4651				$( '.listar-hidden-footer .listar-site-footer .listar-site-footer-inner' ).css( { marginBottom : 0  } );
4652				theBody.removeClass( 'listar-hidden-footer' );
4653			}
4654		}, 1000 );
4655	}
4656
4657	function adjustWidgetImageCaptionsWidth() {
4658		setTimeout( function () {
4659			$( '.wp-caption-text' ).each( function () {
4660				var images = $( this ).parent().find( 'img' );
4661
4662				if ( 1 === images.length ) {
4663					var figure = images.parents( 'figure.gallery-item' );
4664					var link   = images.parents( 'a' );
4665
4666					if ( figure.length && link.length ) {
4667						$( this ).width( link.eq( 0 ).width() - 20 );
4668					} else {
4669						$( this ).width( images.eq( 0 ).width() - 20 );
4670					}
4671				}
4672			} );
4673		}, 1000 );
4674	}
4675
4676	function captureCurrentViewportHeight() {
4677		setTimeout( function () {
4678			viewportHeight = viewport().height;
4679		}, 2000 );
4680	}
4681
4682	function fixListingTermCardsInnerDistances() {
4683		setTimeout( function () {
4684			$( '.listar-term-description' ).each( function () {
4685				var parentHeight = $( this ).parent().height();
4686				var thisHeight = $( this ).height();
4687				var termTitleHeight = $( this ).siblings( '.listar-term-text' ).height();
4688				var diff = parentHeight - ( thisHeight + termTitleHeight );
4689
4690				if ( parentHeight - ( thisHeight + termTitleHeight ) < 99 ) {
4691					diff = -1 * ( 112 - diff );
4692					$( this ).siblings( '.listar-term-text' ).css( { top : diff } );
4693				} else {
4694					$( this ).siblings( '.listar-term-text' ).css( { top : '' } );
4695				}
4696			} );
4697		}, 2000 );
4698	}
4699
4700	function checkGridFillerCard() {
4701		$( '.listar-grid-filler' ).each( function () {
4702			var
4703				gridFillerOuter = '',
4704				gridFiller = $( this ),
4705				gridFillerParent = $( this ).parent();
4706
4707			/* Force the card position to the end of the grid */
4708			gridFillerOuter = gridFiller.prop( 'outerHTML' );
4709			gridFiller.prop( 'outerHTML', '' );
4710			gridFillerParent.append( gridFillerOuter );
4711			gridFiller = gridFillerParent.find( '.listar-grid-filler' );
4712
4713			gridFiller.attr( 'class', ( gridFiller.prev().attr( 'class' ) ) ).addClass( 'listar-grid-filler' );
4714
4715			setTimeout( function () {
4716				var
4717					cardWidth          = gridFiller.width() - 1,
4718					containerWidth     = gridFiller.parent().width(),
4719					cardsCount         = gridFiller.siblings().length,
4720					descriptionWrapper = gridFiller.find( '.listar-fallback-content-data' );
4721
4722				var
4723					cardsPerRow = Math.floor( containerWidth / cardWidth );
4724
4725				var
4726					missingGridLength = cardsPerRow - ( cardsCount % cardsPerRow );
4727
4728				if ( missingGridLength !== cardsPerRow ) {
4729					var
4730						colClass1 = gridFiller.parents( '.col-lg-9' ).length ? 'nothing' : 'col-md-8',
4731						colClass2 = gridFiller.parents( '.col-lg-9' ).length ? 'nothing' : 'col-md-4';
4732
4733					if ( gridFiller.hasClass( 'col-md-12' ) ) {
4734						colClass1 = 'nothing';
4735						colClass2 = 'nothing';
4736					}
4737
4738					if ( 1 === missingGridLength ) {
4739						gridFiller.removeClass( colClass1 ).addClass( colClass2 );
4740					} else if ( 2 === missingGridLength ) {
4741						gridFiller.removeClass( colClass2 ).addClass( colClass1 );
4742					}
4743
4744					gridFiller.removeClass( 'hidden' );
4745				} else {
4746					gridFiller.addClass( 'hidden' );
4747				}
4748
4749				if ( descriptionWrapper.length ) {
4750					if ( descriptionWrapper.prop( 'innerHTML' ).replace( /\s/g, '' ).length < 5 ) {
4751						descriptionWrapper.prop( 'outerHTML', '' );
4752					}
4753				}
4754
4755			}, 500 );
4756		} );
4757	}
4758
4759	function checkGalleryHoverTimeout( gallery ) {
4760		if ( gallery.hasClass( 'listar-gallery-dark' ) ) {
4761			var bodySlideClass = theBody.hasClass( 'listar-listing-has-slideshow-cover' ) ? 'listar-hovering-listing-slideshow-gallery' : 'listar-hovering-listing-gallery-dark';
4762
4763			clearTimeout( hoveringGalleryTimeout );
4764			$( theBody ).addClass( bodySlideClass );
4765
4766			hoveringGalleryTimeout = setTimeout( function () {
4767				if ( hasGalleryMouseleave ) {
4768					hasGalleryMouseleave = false;
4769					$( theBody ).removeClass( bodySlideClass );
4770				}
4771			}, 500 );
4772		}
4773	}
4774
4775	var firstCreation = false;
4776
4777	function createListingGallery() {
4778		
4779		if ( ! firstCreation ) {
4780			firstCreation = true;
4781			listingGallery = $( '.listar-listing-gallery' );
4782
4783			listingGallery.each( function () {
4784				var gallery = $( this );
4785				var galleryParent = $( this ).parent();
4786
4787				$( theBody ).removeClass( 'listar-listing-without-slideshow-cover' );
4788
4789				if ( false !== listingGalleryInitialBackup ) {
4790					gallery.prop( 'outerHTML', listingGalleryInitialBackup );
4791						gallery = galleryParent.find( '.listar-listing-gallery' );
4792						listingGallery = gallery;
4793						listingGalleryItems = gallery.find( '.gallery-item' );
4794						listingGalleryLinks = gallery.find( 'a' );
4795				} else {
4796					listingGalleryInitialBackup = gallery.prop( 'outerHTML' );
4797				}
4798
4799				setTimeout( function () {
4800					if ( listingGalleryItems.length > 0 && ( gallery.hasClass( 'listar-gallery-slideshow-squared' ) || gallery.hasClass( 'listar-gallery-slideshow-rounded' ) ) ) {
4801						var galleryNav    = '<div class="listar-gallery-slideshow-thumbs">' + gallery.prop( 'innerHTML' ) + '</div>';
4802						var gallerySlides = '<div class="listar-gallery-slideshow-slides-wrapper"><div class="listar-gallery-slideshow-slides">' + gallery.prop( 'innerHTML' ) + '</div></div>';
4803						var firstItemHTML = '';
4804
4805						$( theBody ).addClass( 'listar-listing-has-slideshow-cover' );
4806						gallery.parents( 'section' ).find( 'header' ).removeClass( 'hidden' );
4807
4808						gallery.prop( 'innerHTML', gallerySlides );
4809
4810						if ( ! $( '.listar-gallery-slideshow-separator' ).length ) {
4811							gallery.parents( 'section' ).after( '<div class="listar-section listar-section-no-padding-top listar-section-no-padding-bottom listar-gallery-slideshow-separator"></div>' );
4812						}
4813
4814						gallery
4815							.append( galleryNav );
4816
4817						$( '.listar-gallery-slideshow-slides .gallery-item a, .listar-gallery-slideshow-slides .listar-listing-gallery-more-images' ).prop( 'outerHTML', '' );
4818
4819						gallerySlides = $( '.listar-gallery-slideshow-slides .gallery-item' );
4820
4821						if ( gallerySlides.length > 1 ) {
4822							firstItemHTML = gallerySlides.eq( 0 ).prop( 'outerHTML' );
4823
4824							gallerySlides.parent()
4825								.prepend( gallerySlides.eq( gallerySlides.length - 1 ).prop( 'outerHTML' ) )
4826								.append( firstItemHTML );
4827						}
4828
4829						gallerySlides = $( '.listar-gallery-slideshow-slides .gallery-item' );
4830
4831						var
4832							navWidth  = 0,
4833							viewportW = viewport().width;
4834
4835						if ( viewportW > 991 ) {
4836							navWidth = 160;
4837						} else if ( viewportW > 767 ) {
4838							navWidth = 90;
4839						} else {
4840							navWidth = 0;
4841						}
4842
4843						slideWidth = theBody.width() - ( navWidth * 2 ) + 0.5;
4844
4845						if ( viewportW > 1199 && viewportW < 1301 ) {
4846							slideWidth = 1020;
4847							navWidth = ( -1 * ( slideWidth - theBody.width() - 0.5 ) ) / 2; /* Reverse */
4848						} else if ( viewportW > 1300 ) {
4849							slideWidth = 1140;
4850							navWidth = ( -1 * ( slideWidth - theBody.width() - 0.5 ) ) / 2; /* Reverse */
4851						} else if ( viewportW > 991 ) {
4852							slideWidth = 800;
4853							navWidth = ( -1 * ( slideWidth - theBody.width() - 0.5 ) ) / 2; /* Reverse */
4854						} else if ( viewportW < 860 && viewportW > 766 && slideWidth < 620 ) {
4855							slideWidth = 620;
4856							navWidth = ( -1 * ( slideWidth - theBody.width() - 0.5 ) ) / 2; /* Reverse */
4857						}
4858
4859						centralizeMainSlide = ( -1 * slideWidth ) + navWidth;
4860
4861						gallery.append( '<div class="listar-listing-gallery-overlay"></div>' );
4862
4863						if ( gallerySlides.length > 1 ) {
4864							gallery
4865								.append( '<div class="listar-listing-gallery-nav-previous"><div class="icon-arrow-left"></div></div>' )
4866								.append( '<div class="listar-listing-gallery-nav-next"><div class="icon-arrow-right"></div></div>' );
4867
4868							gallerySlides.css( { width : slideWidth, height : gallery.siblings( 'header' ).outerHeight() } );
4869							gallerySlides.eq( 0 ).css( { marginLeft : centralizeMainSlide - ( 0 * slideWidth ) } );
4870
4871							$( '.listar-listing-gallery-nav-previous, .listar-listing-gallery-nav-next' ).css( { width : navWidth } );
4872						} else {
4873							gallerySlides.css( { width : viewportW, height : gallery.siblings( 'header' ).outerHeight() } );
4874						}
4875					} else {
4876						$( theBody ).addClass( 'listar-listing-without-slideshow-cover' );
4877					}
4878
4879					$( '.listar-listing-gallery' ).addClass( 'listar-listing-gallery-loaded' );
4880				}, 500 );
4881			} );
4882
4883			listingGalleryLinks.each( function () {
4884				var thisElement = $( this );
4885				var title = thisElement.attr( 'data-title' );
4886
4887				if ( undefined !== title && 'undefined' !== title && '' !== title && ' ' !== title ) {
4888					thisElement.after( '<div class="listar-listing-gallery-item-caption">' + title + '</div>' );
4889				} else {
4890					/* Avoid print 'undefined' on 'alt' attribute */
4891					title = '';
4892				}
4893
4894				if ( ! thisElement.parent().find( 'img' ).length ) {
4895					thisElement.after( '<img alt="' + title + '" src="' + thisElement.attr( 'data-image-placeholder' ) + '" \/>' );
4896					thisElement.parent().find( 'img' ).css( { 'background-image' : 'url(' + thisElement.attr( 'href' ) + ')' } );
4897				}
4898			} );
4899			
4900			setTimeout( function () {
4901				firstCreation = false;
4902			}, 1000 );
4903		}
4904	}
4905
4906	function setFallbackNoReviewContentHeight() {
4907		$( '.listar-no-reviews-content.listar-fallback-content' ).each( function () {
4908			var thisContent = $( this );
4909
4910			thisContent.parent().css( { height : '' } );
4911
4912			setTimeout( function () {
4913				thisContent.parent().css( { height : thisContent.height() + 60 } );
4914
4915				if ( viewport().width >=992 && $( '.listar-mood-icon.icon-neutral' ).length ) {
4916					setTimeout( function () {
4917						if ( $( '.listar-review-second-col' ).height() < $( '.listar-review-first-col' ).height() ) {
4918							thisContent.parent().css( { height : $( '.listar-review-first-col' ).height() - 30 } );
4919						}
4920					}, 800 );
4921				}
4922			}, 1000 );
4923		} );
4924	}
4925
4926	function checkFillerButtonBlog() {
4927		setTimeout( function () {
4928			$( '.listar-fallback-blog-button' ).each( function () {
4929				var button = $( this );
4930				var url = button.parents( '.listar-fallback-content' ).siblings( 'a' ).attr( 'href' );
4931				var innerText = button.find( '.button' ).prop( 'innerHTML' );
4932				var hasNext = false;
4933
4934				if ( ! isLastBlogPage ) {
4935					$( '.listar-navigation.posts-navigation .next.page-numbers' ).each( function () {
4936						url = $( this ).attr( 'href' );
4937						hasNext = true;
4938						innerText = button.find( '.button' ).attr( 'data-next-posts' );
4939					} );
4940
4941					if ( ! hasNext ) {
4942						$( '.listar-navigation.posts-navigation .prev.page-numbers' ).each( function () {
4943							url = $( this ).attr( 'href' );
4944							innerText = button.find( '.button' ).attr( 'data-previous-posts' );
4945						} );
4946					}
4947				} else {
4948					innerText = button.find( '.button' ).attr( 'data-default-text' );
4949					url = button.parents( '.listar-fallback-content' ).siblings( 'a' ).attr( 'data-default-url' );
4950				}
4951
4952				button.parents( '.listar-fallback-content' ).siblings( 'a' ).attr( 'href', url );
4953				button.find( '.button' ).prop( 'innerHTML', innerText );
4954			} );
4955		}, 1000 );
4956	}
4957
4958	function fallbackCopyTextToClipboard( text ) {
4959		var textArea = document.createElement( 'textarea' );
4960		textArea.value = text;
4961		document.body.appendChild( textArea );
4962		textArea.focus();
4963		textArea.select();
4964
4965		document.execCommand( 'copy' );
4966		document.body.removeChild( textArea );
4967	}
4968
4969	function copyTextToClipboard( text ) {
4970
4971		/* Link: https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript */
4972
4973		if ( ! navigator.clipboard ) {
4974			fallbackCopyTextToClipboard( text );
4975			return;
4976		}
4977
4978		navigator.clipboard.writeText( text );
4979	}
4980
4981	// Get an element's distance from the top of the page
4982	function getElemDistance( elem ) {
4983		var
4984			scrollTop = $( window ).scrollTop(),
4985			elementOffset = elem.offset().top;
4986
4987		return elementOffset - scrollTop;
4988	}
4989
4990	function chechListingTopbarButtonsQty() {
4991		setTimeout( function () {
4992			var buttonsQty = $( '.listar-listing-header-topbar-item' ).length;
4993			var viewportWidth = viewport().width;
4994
4995			if ( viewportWidth < 1201 ) {
4996				if ( buttonsQty < 6 && viewportWidth > 980 ) {
4997					$( '.listar-listing-header-topbar-wrapper' ).addClass( 'listar-hide-plus-button' );
4998				} else if ( buttonsQty < 5 && viewportWidth > 767 ) {
4999					$( '.listar-listing-header-topbar-wrapper' ).addClass( 'listar-hide-plus-button' );
5000				} else if ( buttonsQty < 4 && viewportWidth > 600 ) {
5001					$( '.listar-listing-header-topbar-wrapper' ).addClass( 'listar-hide-plus-button' );
5002				} else {
5003					$( '.listar-listing-header-topbar-wrapper' ).removeClass( 'listar-hide-plus-button' );
5004				}
5005			} else {
5006				$( '.listar-listing-header-topbar-wrapper' ).removeClass( 'listar-hide-plus-button' );
5007			}
5008
5009			if ( buttonsQty <= 3 ) {
5010				$( '.listar-listing-header-plus-button-wrapper' ).prop( 'outerHTML', '' );
5011				$( '.listar-listing-header-topbar-item' ).css( { display : 'inline-block' } );
5012			}
5013		}, 1800 );
5014	}
5015
5016	/* Detects if a colors is too light */
5017
5018	function tooLightColor( colorCode, minimumLuma, returnLuma ) {
5019		var
5020			rgb,
5021			r = 255,
5022			g = 255,
5023			b = 255,
5024			luma = 0;
5025
5026		if ( 'undefined' === typeof minimumLuma ) {
5027			minimumLuma = 150;
5028		}
5029
5030		if ( 'string' === typeof colorCode ) {
5031			rgb = parseInt( colorCode, 16 ); // Convert rrggbb to decimal.
5032			r = ( rgb >> 16 ) & 0xff; // Extract red.
5033			g = ( rgb >> 8 ) & 0xff; // Extract green.
5034			b = ( rgb >> 0 ) & 0xff; // Extract blue.
5035		} else if ( 'object' === typeof colorCode ) {
5036			r = colorCode[0];
5037			g = colorCode[1];
5038			b = colorCode[2];
5039		}
5040
5041		luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // Per ITU-R BT.709.
5042
5043		if ( true === returnLuma ) {
5044			return luma;
5045		}
5046
5047		if ( luma > minimumLuma ) {
5048			return true;
5049		} else {
5050			return false;
5051		}
5052	}
5053
5054	function verifyBootstrapAccordions(){
5055		var accordionHasDescription = false;
5056		var hasAccordion = false;
5057
5058                if ( 'none' === listarLocalizeAndAjax.listingAccordionPreopen ) {
5059                        $('.panel-collapse.in').collapse( 'hide' );
5060                } else {
5061                        $( '.panel-group .accordion-group' ).each( function () {
5062                                hasAccordion = true;
5063
5064                                if ( $( this ).hasClass( 'listar-introduction-accordion' ) ) {
5065                                        accordionHasDescription = true;
5066                                }
5067
5068                                if ( viewport().width >= 992 ) {
5069                                        $( this ).addClass( 'panel panel-default ' );
5070
5071                                        if ( $( this ).hasClass( 'listar-introduction-accordion' ) && $( this ).find( '.panel-title a' )[0].hasAttribute( 'aria-expanded' ) ) {
5072                                                if ( 'false' === $( this ).find( '.panel-title a' ).attr( 'aria-expanded' ) ) {
5073                                                        $( this ).find( '.panel-title a' )[0].click();
5074                                                }
5075                                        }
5076                                } else {
5077                                        $( this ).removeClass( 'panel panel-default ' );
5078
5079                                        if ( $( this ).hasClass( 'listar-business-hours-accordion' ) && $( this ).find( '.panel-title a' )[0].hasAttribute( 'aria-expanded' ) ) {
5080                                                if ( 'true' === $( this ).find( '.panel-title a' ).attr( 'aria-expanded' ) ) {
5081                                                        $( this ).find( '.panel-title a' )[0].click();
5082                                                }
5083                                        }
5084
5085                                        if ( $( this ).hasClass( 'listar-introduction-accordion' ) && $( this ).find( '.panel-title a' )[0].hasAttribute( 'aria-expanded' ) ) {
5086                                                if ( 'false' === $( this ).find( '.panel-title a' ).attr( 'aria-expanded' ) ) {
5087                                                        $( this ).find( '.panel-title a' )[0].click();
5088                                                }
5089                                        }
5090                                }
5091
5092                                if ( 1 === $( this ).parent().find( '.accordion-group' ).length ) {
5093                                        $( this ).parent().addClass( 'listar-accordion-one-group' );
5094                                }
5095
5096                                setTimeout( function () {
5097                                        didInitialAccordionClick = true;
5098                                }, 400 );
5099                        } );
5100
5101                        if ( hasAccordion && ! accordionHasDescription ) {
5102                                var hasOpenedAccordion = false;
5103
5104                                setTimeout( function () {
5105                                        $( '.panel-group .accordion-group' ).eq( 0 ).not( '.listar-business-video-accordion, .listar-business-claim-accordion, .listar-business-booking-accordion' ).find( '.collapsed[aria-expanded="false"]' ).each( function () {
5106                                                hasOpenedAccordion = true;
5107                                                $( this )[0].click();
5108
5109                                        } );
5110
5111                                        if ( ! hasOpenedAccordion ) {
5112                                                $( '.panel-group .accordion-group' ).eq( 1 ).not( '.listar-business-video-accordion, .listar-business-claim-accordion, .listar-business-booking-accordion' ).find( '.collapsed[aria-expanded="false"]' ).each( function () {
5113                                                        hasOpenedAccordion = true;
5114                                                        $( this )[0].click();
5115                                                } );
5116                                        }
5117
5118                                        if ( ! hasOpenedAccordion ) {
5119                                                $( '.panel-group .accordion-group' ).eq( 2 ).not( '.listar-business-video-accordion, .listar-business-claim-accordion, .listar-business-booking-accordion' ).find( '.collapsed[aria-expanded="false"]' ).each( function () {
5120                                                        hasOpenedAccordion = true;
5121                                                        $( this )[0].click();
5122                                                } );
5123                                        }
5124                                }, 200 );
5125
5126                        }
5127                }
5128	}
5129
5130	function fixGutenbergImageBlocks() {
5131		setTimeout( function () {
5132			/* Fix Gutenberg image block width to match the inner image width*/
5133			$( '.wp-block-image img' ).each( function () {
5134				if ( ! $( this ).parents( 'figure' ).hasClass( 'alignfull' ) && ! $( this ).parents( 'figure' ).hasClass( 'alignwide' ) ) {
5135					$( this ).parents( 'figure' ).css( { width : 'auto' } );
5136					$( this ).parents( 'figure' ).css( { width : $( this ).width() } );
5137				}
5138			} );
5139		}, 500 );
5140	}
5141
5142	function fixGutenbergAlignFull() {
5143		setTimeout( function () {
5144			$( '.alignfull:not(.wp-block-embed)' ).each( function () {
5145				if ( 0 === $( this ).parents( '.col-md-8,.col-md-9,.col-lg-9' ).length ) {
5146					var translateX = 0;
5147
5148					if ( ! $( this ).hasClass( 'has-parallax' ) ) {
5149						translateX = Math.floor( scrollbarWidth / 2 );
5150					}
5151
5152					$( this ).css( {
5153						width : lastViewportWidth - scrollbarWidth,
5154						'-webkit-transform' : 'translate(' + translateX + 'px,0)',
5155						'-moz-transform'    : 'translate(' + translateX + 'px,0)',
5156						'-ms-transform'     : 'translate(' + translateX + 'px,0)',
5157						'-o-transform'      : 'translate(' + translateX + 'px,0)',
5158						'transform'         : 'translate(' + translateX + 'px,0)'
5159					} );
5160				} else {
5161					$( this ).css( {
5162						width : '',
5163						'-webkit-transform' : 'translate(0,0)',
5164						'-moz-transform'    : 'translate(0,0)',
5165						'-ms-transform'     : 'translate(0,0)',
5166						'-o-transform'      : 'translate(0,0)',
5167						'transform'         : 'translate(0,0)'
5168					} );
5169				}
5170			} );
5171		}, 250 );
5172	}
5173
5174	function circleEvents() {
5175
5176		if ( theBody.hasClass( 'listar-spiral-effect' ) ) {
5177			cancelListingCardCircleEvents = false;
5178		}
5179
5180		if ( cancelListingCardCircleEvents ) {
5181			return false;
5182		}
5183
5184		$( '.listar-listing-card' ).off( 'mouseenter mouseleave' );
5185
5186		theBody.on( 'mouseenter', '.listar-listing-card', function () {
5187			var thisElement = $( this ).find( '.listar-card-content-image' );
5188
5189			if ( theBody.hasClass( 'listar-listing-card-design-squared' ) ) {
5190				thisElement.siblings( '.listar-listing-rating' ).stop().animate( { marginLeft : '10px', opacity : 0 } );
5191				thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-40px', opacity : 0 } );
5192				thisElement.siblings( '.listar-category-icon' ).stop().animate( { top : '-40px', left : '-40px', opacity : 0 } );
5193				thisElement.siblings( '.listar-listing-logo-wrapper' ).stop().animate( { bottom : '-50px', right : '-50px', opacity : 0 } );
5194			} else if ( thisElement.parent().parent().parent().hasClass( 'listar-grid2' ) || thisElement.parent().parent().parent().hasClass( 'listar-grid3' ) ) {
5195				thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-40px', opacity : 0 } );
5196				thisElement.siblings( 'a, .listar-listing-rating' ).not( '.listar-card-content-author' ).stop().animate( { marginLeft : '10px', opacity : 0 } );
5197				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : '110px', opacity : 0 } );
5198				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-60px', opacity : 0 } );
5199			} else if ( thisElement.parent().parent().parent().parent().hasClass( 'listar-grid6' ) && thisElement.parent().parent().parent().parent().hasClass( 'listar-rounded-pic' ) ) {
5200				thisElement.siblings( 'a' ).not( '.listar-card-content-author' ).stop().animate( { top : '-20px', opacity : 0 } );
5201				thisElement.find( '.listar-listing-rating' ).stop().animate( { marginLeft : '10px', opacity : 0 } );
5202				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : 0, opacity : 0 } );
5203				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-60px', opacity : 0 } );
5204			} else {
5205				thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-40px', opacity : 0 } );
5206				thisElement.siblings( '.listar-listing-rating' ).stop().animate( { marginLeft : '10px', opacity : 0 } );
5207				thisElement.siblings( '.listar-category-icon' ).stop().animate( { top : '-15px', left : '-15px', opacity : 0 } );
5208				thisElement.siblings( '.listar-listing-logo-wrapper' ).stop().animate( { bottom : '-30px', right : '-30px', opacity : 0 } );
5209				thisElement.siblings( '.listar-fav-listing' ).stop().animate( { marginTop : '-60px', opacity : 0 } );
5210				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : 0, opacity : 0 } );
5211				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-90px', opacity : 0 } );
5212			}
5213		} );
5214
5215		theBody.on( 'mouseleave', '.listar-listing-card', function () {
5216			var thisElement = $( this ).find( '.listar-card-content-image' );
5217
5218			if ( theBody.hasClass( 'listar-listing-card-design-squared' ) ) {
5219				thisElement.siblings( '.listar-listing-rating' ).stop().animate( { marginLeft : '-28px', opacity : 1 }, { complete : function () {
5220					thisElement.siblings( '.listar-listing-rating' ).css( { marginLeft : '' } );
5221				} } );
5222
5223				thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-15px', opacity : 1 }, { complete : function () {
5224					thisElement.siblings( '.listar-claimed-icon' ).css( { bottom : '' } );
5225				} } );
5226
5227				thisElement.siblings( '.listar-category-icon' ).stop().animate( { top : '-24px', left : '-18px', opacity : 1 }, { complete : function () {
5228					thisElement.siblings( '.listar-category-icon' ).css( { top : '' } );
5229				} } );
5230
5231				thisElement.siblings( '.listar-listing-logo-wrapper' ).stop().animate( { bottom : '-24px', right : '-26px', opacity : 1 }, { complete : function () {
5232					thisElement.siblings( '.listar-listing-logo-wrapper' ).css( { top : '', left: '' } );
5233				} } );
5234			} else if ( thisElement.parent().parent().parent().hasClass( 'listar-grid2' ) || thisElement.parent().parent().parent().hasClass( 'listar-grid3' ) ) {
5235				thisElement.siblings( '.listar-listing-rating' ).stop().animate( { marginLeft : '-26px', opacity : 1 }, { complete : function () {
5236					thisElement.siblings( '.listar-listing-rating' ).css( { marginLeft : '' } );
5237				} } );
5238
5239				thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-15px', opacity : 1 }, { complete : function () {
5240					thisElement.siblings( '.listar-claimed-icon' ).css( { bottom : '' } );
5241				} } );
5242
5243				thisElement.siblings( '.listar-category-icon' ).stop().animate( { top : '10%', opacity : 1 }, { complete : function () {
5244					thisElement.siblings( '.listar-category-icon' ).css( { top : '' } );
5245				} } );
5246
5247				thisElement.siblings( '.listar-fav-listing' ).stop().animate( { marginTop : '0px', opacity : 1 }, { complete : function () {
5248					thisElement.siblings( '.listar-fav-listing' ).css( { marginTop : '' } );
5249				} } );
5250
5251				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : '84px', opacity : 1 }, { complete : function () {
5252					thisElement.siblings( '.listar-card-content-author' ).css( { top : '' } );
5253				} } );
5254
5255				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-12px', opacity : 1 }, { complete : function () {
5256					thisElement.siblings( '.listar-card-content-date' ).css( { top : '' } );
5257				} } );
5258
5259			} else if ( thisElement.parent().parent().parent().parent().hasClass( 'listar-grid6' ) && thisElement.parent().parent().parent().parent().hasClass( 'listar-rounded-pic' ) ) {
5260				thisElement.find( '.listar-listing-rating' ).stop().animate( { top : '-8px', opacity : 1 }, { complete : function () {
5261					thisElement.find( '.listar-listing-rating' ).css( { top : '' } );
5262				} } );
5263
5264				thisElement.siblings( 'a' ).not( '.listar-card-content-author' ).stop().animate( { top : '35px', opacity : 1 }, { complete : function () {
5265					thisElement.siblings( 'a' ).not( '.listar-card-content-author' ).css( { top : '' } );
5266				} } );
5267
5268				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : '-44px', opacity : 1 }, { complete : function () {
5269					thisElement.siblings( '.listar-card-content-author' ).css( { top : '' } );
5270				} } );
5271
5272				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-12px', opacity : 1 }, { complete : function () {
5273					thisElement.siblings( '.listar-card-content-date' ).css( { top : '' } );
5274				} } );
5275
5276			} else if ( thisElement.parent().parent().parent().hasClass( 'listar-squared-shape' ) || ( thisElement.parent().parent().parent().hasClass( 'listar-squared-shape-mobile' ) && viewport().width <= 600 ) ) {
5277				thisElement.siblings( 'a, .listar-listing-rating' ).not( '.listar-card-content-author' ).stop().animate( { top : '6%', opacity : 1 }, { complete : function () {
5278					thisElement.siblings( 'a, .listar-listing-rating' ).not( '.listar-card-content-author' ).css( { top : '' } );
5279				} } );
5280
5281				thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : '-44px', opacity : 1 }, { complete : function () {
5282					thisElement.siblings( '.listar-card-content-author' ).css( { top : '' } );
5283				} } );
5284
5285				thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-12px', opacity : 1 }, { complete : function () {
5286					thisElement.siblings( '.listar-card-content-date' ).css( { top : '' } );
5287				} } );
5288
5289			} else {
5290				if ( thisElement.parent().parent().parent().hasClass( 'listar-grid-design-2' ) ) {
5291					thisElement.siblings( '.listar-listing-rating' ).stop().animate( { marginLeft : '-26px', opacity : 1 }, { complete : function () {
5292						thisElement.siblings( '.listar-listing-rating' ).css( { marginLeft : '' } );
5293					} } );
5294
5295					thisElement.siblings( '.listar-claimed-icon' ).stop().animate( { bottom : '-15px', opacity : 1 }, { complete : function () {
5296						thisElement.siblings( '.listar-claimed-icon' ).css( { bottom : '' } );
5297					} } );
5298				} else {
5299
5300					thisElement.siblings( '.listar-fav-listing' ).stop().animate( { marginTop : '0px', opacity : 1 }, { complete : function () {
5301						thisElement.siblings( '.listar-fav-listing' ).css( { marginTop : '' } );
5302					} } );
5303
5304					thisElement.siblings( '.listar-card-content-author' ).stop().animate( { top : '-44px', opacity : 1 }, { complete : function () {
5305						thisElement.siblings( '.listar-card-content-author' ).css( { top : '' } );
5306					} } );
5307
5308					thisElement.siblings( '.listar-card-content-date' ).stop().animate( { top : '-12px', opacity : 1 }, { complete : function () {
5309						thisElement.siblings( '.listar-card-content-date' ).css( { top : '' } );
5310					} } );
5311				}
5312
5313				thisElement.siblings( '.listar-category-icon' ).stop().animate( { top : '5%', left : '5%', opacity : 1 }, { complete : function () {
5314					thisElement.siblings( '.listar-category-icon' ).css( { top : '', left: '' } );
5315				} } );
5316
5317				thisElement.siblings( '.listar-listing-logo-wrapper' ).stop().animate( { bottom : '1%', right : '1%', opacity : 1 }, { complete : function () {
5318					thisElement.siblings( '.listar-listing-logo-wrapper' ).css( { top : '', left: '' } );
5319				} } );
5320			}// End if().
5321		} );
5322	}
5323
5324	function validatePhoneCharacters( fields ) {
5325		fields.each( function () {
5326			var field = $( this );
5327			var str = field.val();
5328
5329			field.val( validatePhoneCharactersString( str ) );
5330		} );
5331	}
5332
5333	function validatePhoneCharactersString( str ) {
5334		return str
5335			.replace( /[^+()0-9 -]/g, '' )
5336			.replace( '+ ', '+' )
5337			.replace( ' +', '+' )
5338			.replace( /  /g, '' )
5339			.replace( /^\s+/g, ''); // If first character is a space, remove it.
5340	}
5341
5342	function verifySelect2SubtreePlaceholder() {
5343		$( '.select2-selection__choice' ).each( function () {
5344			var innerCode = $( this ).prop( 'innerHTML' );
5345			var noPrefixSpaces = innerCode.replace( /&nbsp;/g, '' );
5346
5347			$( this ).prop( 'innerHTML', noPrefixSpaces );
5348		} );
5349
5350		setTimeout( function () {
5351
5352			$( '.select2-selection__rendered' ).each( function () {
5353
5354				var select2Wrapper = $( this ).parents( '.select2' );
5355				var theSelect = select2Wrapper.prev();
5356
5357				if ( 'SELECT' === theSelect.prop( 'tagName' ) ) {
5358					if ( '' !== theSelect.val() ) {
5359						theSelect.parent().removeClass( 'listar-showing-placeholder' ).addClass( 'listar-hidding-placeholder' );
5360					} else {
5361						theSelect.parent().addClass( 'listar-showing-placeholder' ).removeClass( 'listar-hidding-placeholder' );
5362					}
5363				}
5364			} );
5365		}, 10 );
5366	}
5367
5368	function forceSelectSelected( theSelect ) {
5369
5370		/* For Safari browser */
5371		theSelect.not( '[data-multiple_text],[multiple]' ).find( 'option' ).each( function () {
5372			if ( 'selected' === $( this ).attr( 'selected' ) ) {
5373				$( this ).prop( 'selected', true );
5374			} else {
5375				$( this ).prop( 'selected', false );
5376			}
5377		} );
5378	}
5379
5380	function checkOpenHourSelected( theSelect ) {
5381		var startTimeWrapper = theSelect.parents( '.listar-business-start-time-field' );
5382		var dayRow = theSelect.parent().parent().parent();
5383
5384		forceSelectSelected( theSelect );
5385
5386		if ( startTimeWrapper.length ) {
5387			setTimeout( function () {
5388				var currentOpenValue = theSelect.val();
5389				var hasChanged = 0;
5390
5391				if ( '11:59 PM' === currentOpenValue ) {
5392					theSelect.val( '00:00 AM' ).attr( 'value', '00:00 AM' );
5393					forceSelectSelected( theSelect );
5394					theSelect.select2().trigger( 'change' );
5395					currentOpenValue = '00:00 AM';
5396					hasChanged = 15;
5397				}
5398
5399				setTimeout( function () {
5400					if ( currentOpenValue.indexOf( ' AM' ) >=0 || currentOpenValue.indexOf( ' PM' ) >= 0  ) {
5401						var currentOpenOrder = theSelect.attr( 'data-multiple-order' );
5402						var currentCloseValue  = dayRow.find( '.listar-business-end-time-field select[data-multiple-order="' + currentOpenOrder + '"]' ).val();
5403
5404						if ( getTotalMinutes( currentOpenValue ) >= getTotalMinutes( currentCloseValue ) ) {
5405							dayRow.find( '.listar-business-end-time-field select[data-multiple-order="' + parseInt( currentOpenOrder, 10 ) + '"]' ).val( '11:59 PM' ).attr( 'value', '11:59 PM' );
5406
5407							dayRow.find( '.listar-business-end-time-field select[data-multiple-order="' + parseInt( currentOpenOrder, 10 ) + '"] option' ).each( function () {
5408								$( this ).removeAttr( 'selected' ).prop( 'selected', false );
5409
5410								if ( '11:59 PM' === $( this ).attr( 'value' ) ) {
5411									$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
5412									$( this ).parent().val( '11:59 PM' ).attr( 'value', '11:59 PM' );
5413								}
5414							} );
5415
5416							forceSelectSelected( dayRow.find( '.listar-business-end-time-field select[data-multiple-order="' + parseInt( currentOpenOrder, 10 ) + '"]' ) );
5417							dayRow.find( '.listar-business-end-time-field select[data-multiple-order="' + parseInt( currentOpenOrder, 10 ) + '"]' ).select2().trigger( 'change' );
5418						}
5419
5420						startTimeWrapper.parent().removeClass( 'listar-hide-multiple-hours-buttons' );
5421						startTimeWrapper.siblings( '.listar-business-end-time-field' ).find( 'select' ).prop( 'disabled', false );
5422						startTimeWrapper.find( 'select' ).prop( 'disabled', false );
5423					} else {
5424						startTimeWrapper.siblings( '.listar-business-end-time-field' ).find( 'select' ).prop( 'disabled', true );
5425						startTimeWrapper.find( 'select' ).prop( 'disabled', true );
5426						theSelect.prop( 'disabled', false );
5427						startTimeWrapper.parent().addClass( 'listar-hide-multiple-hours-buttons' );
5428					}
5429				}, hasChanged );
5430			}, 15 );
5431		}
5432	}
5433
5434	function checkCloseHourSelected( theSelect ) {
5435		forceSelectSelected( theSelect );
5436
5437		if ( theSelect.parents( '.listar-business-end-time-field' ).length ) {
5438			var endTimeWrapper = theSelect.parents( '.listar-business-end-time-field' );
5439			var dayRow = theSelect.parent().parent().parent();
5440
5441			if ( endTimeWrapper.length ) {
5442				setTimeout( function () {
5443					var currentCloseValue = theSelect.val();
5444
5445					if ( '00:00 AM' === currentCloseValue ) {
5446						theSelect.val( '11:59 PM' ).attr( 'value', '11:59 PM' );
5447						forceSelectSelected( theSelect );
5448						theSelect.select2().trigger( 'change' );
5449					} else {
5450						var currentCloseOrder = theSelect.attr( 'data-multiple-order' );
5451						var currentOpenValue  = dayRow.find( '.listar-business-start-time-field select[data-multiple-order="' + currentCloseOrder + '"]' ).val();
5452
5453						if ( getTotalMinutes( currentCloseValue ) <= getTotalMinutes( currentOpenValue ) ) {
5454							theSelect.val( '11:59 PM' ).attr( 'value', '11:59 PM' );
5455
5456							theSelect.find( 'option' ).each( function () {
5457								$( this ).removeAttr( 'selected' ).prop( 'selected', false );
5458
5459								if ( '11:59 PM' === $( this ).attr( 'value' ) ) {
5460									$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
5461									$( this ).parent().val( '11:59 PM' ).attr( 'value', '11:59 PM' );
5462								}
5463							} );
5464
5465							forceSelectSelected( theSelect );
5466							theSelect.select2().trigger( 'change' );
5467
5468							if ( 0 === theSelect.parent().parent().find( 'select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ).length ) {
5469								dayRow.find( '.listar-business-start-time-field .listar-multiple-hours-plus' )[0].click();
5470							}
5471
5472							setTimeout( function () {
5473								theSelect.parent().parent().parent().find( '.listar-business-start-time-field select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ).val( '00:00 AM' ).attr( 'value', '00:00 AM' );
5474								forceSelectSelected( theSelect.parent().parent().parent().find( '.listar-business-start-time-field select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ) );
5475								theSelect.parent().parent().parent().find( '.listar-business-start-time-field select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ).select2().trigger( 'change' );
5476								theSelect.parent().parent().find( 'select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ).val( currentCloseValue ).attr( 'value', currentCloseValue );
5477
5478								theSelect.parent().parent().find( 'select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"] option' ).each( function () {
5479									$( this ).removeAttr( 'selected' ).prop( 'selected', false );
5480
5481									if ( $( this ).attr( 'value' ) === currentCloseValue ) {
5482										$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
5483										$( this ).parent().val( currentCloseValue ).attr( 'value', currentCloseValue );
5484									}
5485								} );
5486
5487								forceSelectSelected( theSelect.parent().parent().find( 'select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ) );
5488								theSelect.parent().parent().find( 'select[data-multiple-order="' + ( parseInt( currentCloseOrder, 10 ) + 1 ) + '"]' ).select2().trigger( 'change' );
5489							}, 20 );
5490						}
5491					}
5492				}, 13 );
5493			}
5494		}
5495	}
5496
5497	function prepareSelect2Hierarchy( thisSelect2Expanded ) {
5498		var realSelect = thisSelect2Expanded.parents( '.select2' ).prev();
5499		var childArray = [];
5500
5501		forceSelectSelected( realSelect );
5502
5503		realSelect.find( 'option' ).each( function () {
5504			var selectOption = $( this );
5505
5506			if ( selectOption[0].hasAttribute( 'data-icon' ) ) {
5507				for ( var childCount = 0; childCount < 12; childCount++ ) {
5508
5509					var childLevel = 'child' + childCount;
5510
5511					if ( selectOption.attr( 'data-icon' ).indexOf( childLevel ) >= 0 ) {
5512						var termName = selectOption.prop( 'innerHTML' ).trim();
5513						var tempTerm = [ termName, childLevel, selectOption.index() ];
5514						childArray.push( tempTerm );
5515					}
5516				}
5517			}
5518		} );
5519
5520		if ( childArray.length ) {
5521			setTimeout( function () {
5522				var select2DropDown = $( '.select2-results__options' );
5523
5524				if ( select2DropDown.length ) {
5525					for ( var childCount2 = 0; childCount2 < childArray.length; childCount2++ ) {
5526						if ( select2DropDown.find( 'li' ).length ) {
5527							select2DropDown.find( 'li' ).eq( childArray[ childCount2 ][2] ).addClass( childArray[ childCount2 ][1] );
5528						}
5529					}
5530				}
5531			}, 20 );
5532		}
5533
5534		if ( thisSelect2Expanded.hasClass( 'select2-selection--single' ) ) {
5535			setTimeout( function () {
5536				$( '.select2-container--open .select2-search__field' ).focus();
5537			}, 5 );
5538		} else {
5539			setTimeout( function () {
5540				thisSelect2Expanded.find( '.select2-search__field' ).focus();
5541			}, 5 );
5542		}
5543	}
5544
5545	function hoursFormatReplace( string ) {
5546		var hoursFormat24Search = [
5547			'01:00 PM',
5548			'01:30 PM',
5549			'02:00 PM',
5550			'02:30 PM',
5551			'03:00 PM',
5552			'03:30 PM',
5553			'04:00 PM',
5554			'04:30 PM',
5555			'05:00 PM',
5556			'05:30 PM',
5557			'06:00 PM',
5558			'06:30 PM',
5559			'07:00 PM',
5560			'07:30 PM',
5561			'08:00 PM',
5562			'08:30 PM',
5563			'09:00 PM',
5564			'09:30 PM',
5565			'10:00 PM',
5566			'10:30 PM',
5567			'11:00 PM',
5568			'11:30 PM',
5569			'11:59 PM'
5570		];
5571
5572		var hoursFormat24Replace = [
5573			'13:00',
5574			'13:30',
5575			'14:00',
5576			'14:30',
5577			'15:00',
5578			'15:30',
5579			'16:00',
5580			'16:30',
5581			'17:00',
5582			'17:30',
5583			'18:00',
5584			'18:30',
5585			'19:00',
5586			'19:30',
5587			'20:00',
5588			'20:30',
5589			'21:00',
5590			'21:30',
5591			'22:00',
5592			'22:30',
5593			'23:00',
5594			'23:30',
5595			'24:00'
5596		];
5597
5598		if ( '12' === listarLocalizeAndAjax.operatingHoursFormat ) {
5599			return string;
5600		}
5601
5602		for ( var hourIndex = 0; hourIndex < hoursFormat24Search.length; hourIndex++ ) {
5603			string = string.replace( hoursFormat24Search[ hourIndex ], hoursFormat24Replace[ hourIndex ] );
5604		}
5605
5606		return string;
5607	}
5608
5609	function updateOperatingHoursAndAvailability() {
5610
5611		if ( ! hasUpdatedHoursTable ) {
5612			hasUpdatedHoursTable = true;
5613
5614			markerCounterAfterLoad = false;
5615			var markerCounterAfterLoadJSON = '[';
5616			var updateOperatingHoursURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/update-public-operating-hours.php';
5617			var relatedListings  = $( '.listar-related-listings article' );
5618			var widgetListings   = $( '.widget_listar_listings article' );
5619			var currentArticleID = false;
5620
5621			if ( 'undefined' !== typeof listarMapMarkers ) {
5622				markerCounterAfterLoad = listarMapMarkers.length;
5623			}
5624
5625			if ( markerCounterAfterLoad ) {
5626				var tempMarkerArray = [];
5627
5628				for ( var n = 0; n < markerCounterAfterLoad; n++ ) {
5629					var tempMarker = listarMapMarkers[ n ];
5630
5631					if ( 'string' === typeof tempMarker.lat && 'string' === typeof tempMarker.lng ) {
5632						tempMarker.lat = tempMarker.lat.replace( /[^0-9\.-]/g, '' );
5633						tempMarker.lng = tempMarker.lng.replace( /[^0-9\.-]/g, '' );							
5634					}
5635
5636					tempMarkerArray.push( tempMarker );
5637				}
5638
5639				window.listarMapMarkers = tempMarkerArray;
5640				markerCounterAfterLoad = listarMapMarkers.length;
5641			}
5642
5643			if ( markerCounterAfterLoad && theBody.hasClass( 'listar-addons-active' ) ) {
5644
5645				if ( theBody.hasClass( 'single-job_listing' ) ) {
5646					var currentArticle = theBody.find( 'main > article' );
5647					currentArticleID = false;
5648
5649					if ( currentArticle ) {
5650						if ( currentArticle[0].hasAttribute( 'id' ) ) {
5651							currentArticleID = currentArticle.attr( 'id' );
5652							currentArticleID = currentArticleID.replace( 'post-', '' );
5653						}
5654
5655						markerCounterAfterLoadJSON += '{"single-listing-page":"' + currentArticleID +'"},';
5656					}
5657				}
5658
5659				for ( var mc = 0; mc < markerCounterAfterLoad; mc++ ) {
5660					markerCounterAfterLoadJSON += '{"listing-id-' + mc + '":"' + listarMapMarkers[ mc ].listingID +'"},';
5661				}
5662
5663				relatedListings.each( function () {
5664					var currentRelatedArticle = $( this );
5665					var currentRelatedArticleID = false;
5666
5667					if ( currentRelatedArticle ) {
5668						if ( currentRelatedArticle[0].hasAttribute( 'id' ) ) {
5669							currentRelatedArticleID = currentRelatedArticle.attr( 'id' );
5670							currentRelatedArticleID = currentRelatedArticleID.replace( 'post-', '' );
5671						}
5672
5673						if ( false !== currentRelatedArticleID ) {
5674							markerCounterAfterLoadJSON += '{"listing-id-' + currentRelatedArticleID + '":"' + currentRelatedArticleID +'"},';
5675						}
5676					}
5677				} );
5678
5679				widgetListings.each( function () {
5680					var currentWidgetArticle = $( this );
5681					var currentWidgetArticleID = false;
5682
5683					if ( currentWidgetArticle ) {
5684						if ( currentWidgetArticle[0].hasAttribute( 'id' ) ) {
5685							currentWidgetArticleID = currentWidgetArticle.attr( 'id' );
5686							currentWidgetArticleID = currentWidgetArticleID.replace( 'post-', '' );
5687						}
5688
5689						if ( false !== currentWidgetArticleID ) {
5690							markerCounterAfterLoadJSON += '{"listing-id-' + currentWidgetArticleID + '":"' + currentWidgetArticleID +'"},';
5691						}
5692					}
5693				} );
5694
5695				/* Remove last comma */
5696				markerCounterAfterLoadJSON = markerCounterAfterLoadJSON.replace( /,\s*$/, '' );
5697
5698				markerCounterAfterLoadJSON += ']';
5699
5700				markerCounterAfterLoadJSON = { my_data : markerCounterAfterLoadJSON };
5701
5702				$( '.listar-open-or-closed' ).each( function () {
5703					if ( ! $( this ).parent().hasClass( 'listar-booking-quick-button-inner' ) ) {
5704						$( this ).addClass( 'listar-updating-hours' );
5705					}
5706				} );
5707
5708				$.ajax( {
5709					crossDomain: true,
5710					url: updateOperatingHoursURL,
5711					type: 'POST',
5712					data: markerCounterAfterLoadJSON
5713				} ).done( function ( response ) {
5714					if ( response ) {
5715						var data = $.parseJSON( response );
5716
5717						$.each( data, function() {
5718							if ( 'undefined' !== typeof this.id && 'undefined' !== typeof this.statushtml ) {
5719								var theListingID = this.id;
5720								var theListingStatusName = this.status;
5721								var theListingStatus = this.statushtml;
5722								var theListingIconClass = this.iconclass;
5723								var theListingHoursTable = '';
5724								var theListingArticle = $( 'article.post-' + theListingID );
5725
5726								if ( theListingArticle.length ) {
5727									var cardAvailabilityDiv = theListingArticle.find( '.listar-open-or-closed' );
5728
5729									if ( cardAvailabilityDiv.length ) {
5730										cardAvailabilityDiv.prop( 'outerHTML', theListingStatus );
5731									}
5732								}
5733
5734								if ( false !== currentArticleID && theListingID === currentArticleID ) {
5735									$( '.listar-operating-hours-quick-button-inner' ).each( function () {
5736										$( this ).prop( 'innerHTML', theListingStatus );
5737									} );
5738
5739									$( '.listar-business-hours-accordion .listar-open-or-closed' ).each( function () {
5740										$( this ).parent().removeClass( 'icon-alarm-check icon-alarm-error' ).addClass( theListingIconClass );
5741										$( this ).prop( 'outerHTML', theListingStatus );
5742
5743									} );
5744
5745									theListingHoursTable = this.hourstablehtml;
5746
5747									if ( 'undefined' !== typeof this.id && 'undefined' !== typeof theListingHoursTable ) {
5748										if ( '' !== theListingHoursTable ) {
5749											$( '.listar-hours-table-wrapper' ).each( function () {
5750												if ( 'open' === theListingStatusName ) {
5751													$( this ).parents( '.listar-business-status-open, .listar-business-status-closed' )
5752														.removeClass( 'listar-business-status-closed' )
5753														.addClass( 'listar-business-status-open' );
5754												} else {
5755													$( this ).parents( '.listar-business-status-open, .listar-business-status-closed' )
5756														.removeClass( 'listar-business-status-open' )
5757														.addClass( 'listar-business-status-closed' );
5758												}
5759												$( this ).prop( 'outerHTML', theListingHoursTable );
5760											} );
5761										}
5762									}
5763								}
5764							}
5765						} );
5766					}
5767				} );
5768			}
5769		}
5770	}
5771
5772	/* Ajax login / register inside popup *************************/
5773
5774	function listarOpenLoginDialog( href ) {
5775		var modalDialog;
5776
5777		$( '#listar-user-modal .modal-dialog' ).removeClass( 'listar-registration-complete' );
5778		modalDialog = $( '#listar-user-modal .modal-dialog' );
5779		modalDialog.attr( 'data-active-tab', '' );
5780
5781		switch ( href ) {
5782			case '#listar-register' :
5783				modalDialog.attr( 'data-active-tab', '#listar-register' );
5784				break;
5785			case '#listar-login' :
5786				modalDialog.attr( 'data-active-tab', '#listar-login' );
5787				break;
5788			default :
5789				modalDialog.attr( 'data-active-tab', '#listar-login' );
5790				break;
5791		}
5792
5793		$( '#listar-user-modal' ).modal( 'show' );
5794	}
5795
5796	// No geolocation possible
5797	function impossibleGeolocation( regionFallback, countryFallback ) {
5798
5799		/* Set initial values again, to be used in case of new geolocation requests */
5800		geolocationAttempties = 3;
5801		userGeolocated = false;
5802
5803		$( '.listar-nearest-me-main' ).addClass( 'hidden' );
5804		$( '.listar-nearest-me-secondary' ).removeClass( 'hidden' );
5805		$( '.listar-not-geolocated-user' ).removeClass( 'hidden' );
5806
5807		$( '.listar-submit-geolocation-data' ).prop( 'innerHTML', $( '.listar-submit-geolocation-data' ).attr( 'data-button-text' ) );
5808
5809		return false;
5810	}
5811
5812	// Geolocated data found
5813	function geolocatedDataFound( address, number, region, country, lat, lng ) {
5814
5815		/* Set initial values again, to be used in case of new geolocation requests */
5816		geolocationAttempties = 3;
5817		userGeolocated = false;
5818
5819		$( '.listar-nearest-me-main' ).addClass( 'hidden' );
5820		$( '.listar-nearest-me-secondary' ).removeClass( 'hidden' );
5821		$( '.listar-not-geolocated-user' ).addClass( 'hidden' );
5822
5823		$( '#listar_geolocated_data_address' ).val( address );
5824		$( '#listar_geolocated_data_number' ).val( number );
5825		$( '#listar_geolocated_data_region' ).val( region );
5826		$( '#listar_geolocated_data_country' ).val( country );
5827		$( '#listar_geolocated_data_latitude' ).val( lat );
5828		$( '#listar_geolocated_data_longitude' ).val( lng );
5829	}
5830
5831	// Get detailed data for geolocated coordinates.
5832	function getGeolocationDetails( latitude, longitude, regionFallback, countryFallback ) {
5833		if ( ! 'string' === typeof latitude || ! 'string' === typeof longitude || '' === latitude || '' === longitude ) {
5834			return impossibleGeolocation( regionFallback, countryFallback );
5835		}
5836
5837		var geolocationType = 'coordinates';
5838		var theAjaxURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/reverse-geocode.php';
5839		var dataToSend = { send_data : '[{"type":"' + geolocationType + '"},{"latitude":"' + latitude + '"},{"longitude":"' + longitude + '"}]' };
5840
5841		$.ajax( {
5842			crossDomain: true,
5843			url: theAjaxURL,
5844			type: 'POST',
5845			data: dataToSend,
5846			cache    : false,
5847			timeout  : 30000
5848
5849		} ).done( function ( response ) {
5850
5851			if ( response ) {
5852
5853				var data = $.parseJSON( response );
5854
5855				if ( '1' === data.geolocated ) {
5856					var address = 'string' === typeof data.geolocation_street ? data.geolocation_street : '' ;
5857					var houseNumber = 'string' === typeof data.geolocation_street_number ? data.geolocation_street_number : '' ;
5858					var city = 'string' === typeof data.geolocation_city ? data.geolocation_city : '' ;
5859					var country = 'string' === typeof data.geolocation_country_long ? data.geolocation_country_long : '' ;
5860					var lat = 'string' !== typeof data.geolocation_lat && 'undefined' !== typeof data.geolocation_lat ? data.geolocation_lat : '' ;
5861					var lng = 'string' !== typeof data.geolocation_long && 'undefined' !== typeof data.geolocation_long ? data.geolocation_long : '' ;
5862					var formatted_address = 'string' === typeof data.geolocation_formatted_address ? data.geolocation_formatted_address : '' ;
5863
5864					if ( '' === address ) {
5865							address = formatted_address;
5866					}
5867
5868					// Finish Process here.
5869					geolocatedDataFound( address, houseNumber, city, country, lat, lng );
5870				} else {
5871					impossibleGeolocation( regionFallback, countryFallback );
5872				}
5873			} else {
5874				impossibleGeolocation( regionFallback, countryFallback );
5875			}
5876		} ).fail( function( response ) {
5877			impossibleGeolocation( regionFallback, countryFallback );
5878		} );
5879	}
5880
5881	// Quaternary - Low precision
5882	function userGeolocationMethod4() {
5883
5884		$.ajax( {
5885			/* Ajax handler */
5886			crossDomain: true,
5887			url: 'https://get.geojs.io/v1/ip/geo.json',
5888			type: 'GET',
5889			async: true,
5890			cache: false,
5891			timeout  : 5000,
5892			dataType: 'json'
5893		} ).done( function( data ) {
5894			if ( data ) {
5895				if ( data.city && data.country && data.latitude && data.longitude ) {
5896					getGeolocationDetails( data.latitude, data.longitude, data.city, data.country );
5897				} else {
5898					return impossibleGeolocation( '', '' );
5899				}
5900			} else {
5901				return impossibleGeolocation( '', '' );
5902			}
5903		} )
5904		.fail( function( data ) {
5905			return impossibleGeolocation( '', '' );
5906		} );
5907	}
5908
5909
5910	// Tertiary - Low precision
5911
5912	function userGeolocationMethod3() {
5913		$.ajax( {
5914			/* Ajax handler */
5915			crossDomain: true,
5916			url: 'https://ipinfo.io',
5917			type: 'GET',
5918			async: true,
5919			cache: false,
5920			timeout  : 5000,
5921			dataType: 'json'
5922		} ).done( function( data ) {
5923			if ( data ) {
5924				var geo1 = 'string' === typeof data.loc ? data.loc : '';
5925				var geo2 = geo1.indexOf( ',' ) > 0 ? geo1.split( ',' ) : [ '', '' ];
5926				var geoLat = geo2[0];
5927				var geoLng = geo2[1];
5928
5929				if ( '' !== geoLat && '' !== geoLng && data.city && data.region ) {
5930					getGeolocationDetails( geoLat, geoLng, data.city, data.region );
5931				} else {
5932					return userGeolocationMethod4();
5933				}
5934			} else {
5935				return userGeolocationMethod4();
5936			}
5937		} )
5938		.fail( function( data ) {
5939			return userGeolocationMethod4();
5940		} );
5941	}
5942
5943	// Secondary - Medium/Low precision
5944	function userGeolocationMethod2() {
5945
5946		var dataToSend = { send_data : '[{"type":"curl"}]' };
5947
5948		$.ajax( {
5949			/* Ajax handler */
5950			crossDomain: true,
5951			url: listarSiteURL + '/wp-content/plugins/listar-addons/inc/geolocate-data-curl.php',
5952			type: 'POST',
5953			async: true,
5954			cache: false,
5955			data: dataToSend,
5956			timeout  : 5000,
5957			dataType: 'json'
5958		} ).done( function( data ) {
5959			if ( data ) {
5960				data = $.parseJSON( data );
5961				var region = '';
5962
5963				if ( data.geoplugin_city && data.geoplugin_region && '' !== data.geoplugin_city && '' !== data.geoplugin_region ) {
5964					region = data.geoplugin_city + ' ' + data.geoplugin_region;
5965				} else if ( data.geoplugin_city  && '' !== data.geoplugin_city ) {
5966					region = data.geoplugin_city;
5967				} else if ( data.geoplugin_region && '' !== data.geoplugin_region ) {
5968					region = data.geoplugin_region;
5969				}
5970
5971				if ( '' !== region && data.geoplugin_countryName && data.geoplugin_latitude && data.geoplugin_longitude ) {
5972					getGeolocationDetails( data.geoplugin_latitude, data.geoplugin_longitude, region, data.geoplugin_countryName );
5973				} else {
5974					return userGeolocationMethod3();
5975				}
5976			} else {
5977				return userGeolocationMethod3();
5978			}
5979		} )
5980		.fail( function( data ) {
5981			return userGeolocationMethod3();
5982		} );
5983	}
5984
5985
5986	// Priority - (via Browser permission) High precision
5987
5988	function browserGeolocationSuccess( position ) {
5989		userGeolocated = true;
5990		geolocationAttempties = -1;
5991		getGeolocationDetails( position.coords.latitude, position.coords.longitude, '', '' );
5992	}
5993
5994	function browserGeolocationFail(error) {
5995		userGeolocationMethod1();
5996	}
5997
5998	function tryGeolocation() {
5999		if ( navigator.geolocation ) {
6000			navigator.geolocation.getCurrentPosition(
6001				browserGeolocationSuccess,
6002				browserGeolocationFail,
6003				{ maximumAge: 24000, timeout: 8000, enableHighAccuracy: true }
6004			);
6005		}
6006	}
6007
6008	function userGeolocationMethod1() {
6009		geolocationAttempties--;
6010
6011		if ( ! userGeolocated && geolocationAttempties > -1 ) {
6012			tryGeolocation();
6013		} else {
6014			geolocationAttempties = -1;
6015			return userGeolocationMethod2();
6016		}
6017	}
6018
6019	/* Fix for WP Instant Feeds (Instagram) plugin */
6020
6021	function fixInstagramFeed() {
6022		var hasWrongImages = false;
6023
6024		$( '.wp-my-instagram.wpmi' ).each( function () {
6025			var widgetInsta = $( this );
6026
6027			var
6028				args = { };
6029
6030			if ( widgetInsta.find( '.wpmi-list' ).length ) {
6031				var firstImg = widgetInsta.find( 'img' );
6032				var firstUrl = '';
6033
6034				if ( firstImg.length ) {
6035					firstImg = firstImg.eq( 0 );
6036
6037					if ( firstImg[0].hasAttribute( 'src' ) ) {
6038						firstUrl = firstImg.attr( 'src' );
6039					}
6040				}
6041
6042				if ( firstUrl.indexOf( 'instagram.' ) < 0 ) {
6043					widgetInsta.attr( 'data-cached', 'false' );
6044					widgetInsta.find( '.wpmi-list' ).attr( 'data-cached', 'false' );
6045					hasWrongImages = true;
6046
6047					if ( false === retryInstagram ) {
6048						
6049						retryInstagram = setInterval( function () {
6050							fixInstagramFeed();
6051						}, 3000 );
6052					}
6053
6054					widgetInsta.each( function () {
6055						var $el = $( this ),
6056							id = $el.attr( 'id' );
6057
6058						args[id] = $el.data( 'args' );
6059					} );
6060
6061					if ( args ) {
6062
6063						$.ajax( {
6064							crossDomain: true,
6065							url: wpMyInstagramVars.ajaxurl,
6066							type: 'GET',
6067							async: true,
6068							cache: false,
6069							// dataType: 'json',
6070							data: {
6071								action: 'wpmi-init-cache',
6072								security: wpMyInstagramVars.nonce,
6073								args: args
6074							}
6075						} ).done( function ( response ) {
6076							if ( response && response.data ) {
6077								for ( var key in response.data ) {
6078									if ( key ) {
6079										var newWmmi = $( '#' + key + '.wp-my-instagram.wpmi' );
6080										$( '.wpmi-list', newWmmi ).html( response.data[key] );
6081										$( '.wpmi-list', newWmmi ).attr( 'data-cached', 'true' );
6082									}
6083								}
6084							}
6085
6086						} );
6087					}
6088				}
6089
6090			}
6091		} );
6092
6093		if ( ! hasWrongImages && false !== retryInstagram ) {
6094			clearInterval( retryInstagram );
6095		}
6096	}
6097
6098	function startAfterFirstInteraction() {
6099
6100		$( '[data-toggle="tooltip"]' ).tooltip( 'hide' );
6101
6102		setInterval( function () {
6103			var scrollTop = theDocument.scrollTop();
6104
6105			if ( saveScrollPosition ) {
6106				lastScrollPosition = scrollTop;
6107			}
6108
6109			executeAfterLoad();
6110
6111			if ( scrollTop > 5 ) {
6112				theBody.addClass( 'listar-page-has-scrolled' );
6113			} else {
6114				theBody.removeClass( 'listar-page-has-scrolled' );
6115			}
6116
6117			if ( scrollTop > viewportHeight || scrollTop > 1200 ) {
6118				$( '.listar-back-to-top, .listar-toggle-fixed-quick-menu-wrapper' ).removeClass( 'listar-hidden-fixed-button' );
6119			} else {
6120				$( '.listar-back-to-top, .listar-toggle-fixed-quick-menu-wrapper, .listar-listing-header-menu-fixed' ).addClass( 'listar-hidden-fixed-button' );
6121			}
6122
6123			if ( theBody.hasClass( 'listar-ajax-pagination' ) && theBody.hasClass( 'listar-ajax-infinite-scroll' ) ) {
6124				var loadMore = $( '.listar-main-block .listar-more-results, .site-main .listar-more-results' );
6125
6126				if ( loadMore.length ) {
6127					if ( isInViewport( loadMore ) ) {
6128						loadMore.eq( 0 ).trigger( 'click' );
6129					}
6130				}
6131			}
6132
6133			if ( isInViewport( $( '.listar-site-footer' ) ) && scrollTop > 130 ) {
6134				headMenu.addClass( 'listar-hide-main-menu' );
6135				theBody.addClass( 'listar-footer-is-visible' );
6136				$( '.listar-toggle-fixed-quick-menu-wrapper, .listar-listing-header-menu-fixed' ).addClass( 'listar-hidden-fixed-button' );
6137			} else {
6138				headMenu.removeClass( 'listar-hide-main-menu' );
6139				theBody.removeClass( 'listar-footer-is-visible' );
6140			}
6141
6142			AOSRefresh();
6143
6144			/* Initialize map (if not initiated yet) */
6145			leafletMapInit();
6146			checkFrontPageTopbar();
6147			fixSmashBalloonImages();
6148		}, 400 );
6149	}
6150
6151	/* Map Functions **********************************************/
6152
6153	function showMap() {
6154		if ( $( '#map' ).length ) {
6155			onMap = 1;
6156
6157			if ( 0 === $( '.listar-widgetized-map-container' ).length ) {
6158				$( 'html, body, .listar-posts-column-list' ).stop().animate( { scrollTop : '0' }, 500 );
6159				theBody.addClass( 'listar-showing-map listar-hide-main-menu' );
6160
6161				if ( ! theBody.hasClass( 'listar-map-and-page' ) ) {
6162					if ( ! isMobile() ) {
6163						theBody.addClass( 'listar-stop-scrolling' );
6164					}
6165
6166					$( '.listar-grid' ).siblings( '.listar-more-results' ).css( { display : 'none' } );
6167				}
6168
6169				$( '#page' ).css( { height: '100%' } );
6170				$( '.listar-map-button' ).stop().animate( { opacity : 0 } );
6171				$( '#map' ).removeClass( 'listar-map-hidden' );
6172				$( '.listar-map-listing' ).stop().animate( { height: $( window ).height() - headerTopbarDistance( true ) }, { duration : 1000 } );
6173				$( '.listar-current-page-info, .listar-header-search' ).addClass( 'listar-hide-page-info' );
6174			}
6175
6176			if ( viewport().width > 767 ) {
6177				$( '.listar-map ~ .listar-aside-list' ).stop().animate( { right: 0 }, { duration : 400 } );
6178				listingMapResize( 1 );
6179			} else {
6180				$( '.listar-map ~ .listar-aside-list .listar-close-aside-listings' ).addClass( 'icon-location' ).removeClass( 'icon-cross2' );
6181				$( '.listar-map ~ .listar-aside-list' ).stop().animate( { right: '-290px' }, { duration : 400 } );
6182				listingMapResize();
6183			}
6184
6185			setTimeout( function () {
6186				map.invalidateSize();
6187				fitMapBounds( map, bounds );
6188				mapFitBoundsFix();
6189			}, 800 );
6190
6191			setTimeout( function () {
6192				$( '.listar-map-listing' ).removeClass( 'listar-map-hidden' );
6193				$( '.listar-page-header-with-map' ).css( { display : 'none' } );
6194
6195				if ( $( '#secondary .listar-map ~ .listar-aside-list' ).length > 0 ) {
6196					$( '.listar-map ~ .listar-aside-list .listar-close-aside-listings' ).trigger( 'click' );
6197				}
6198
6199			}, 1000 );
6200
6201			setMapDefaultVisibility();
6202                        setInitialMapZoom( 1000 );
6203		}// End if().
6204	}
6205
6206	function addMapMarkers() {
6207		var hasLatLng = false;
6208		var mapSidebarWasCreated = $( '.listar-aside-post-pic' ).length;
6209
6210		if ( 'undefined' !== typeof listarMapMarkers ) {
6211			var markersCount = listarMapMarkers.length;
6212
6213			for ( var m = 0; m < markersCount; m++ ) {
6214				var
6215					tempListingItem,
6216					categoryColor = '',
6217					categoryColorStyle = '',
6218					latLng,
6219					icon;
6220
6221				listarMapMarkers[ m ].id = '_' + Math.random().toString( 36 ).substr( 2, 9 );
6222				listingItem[ listarMapMarkers[ m ].id ] = listarMapMarkers[ m ];
6223
6224				tempListingItem = listingItem[ listarMapMarkers[ m ].id ];
6225
6226				if ( 'undefined' !== typeof tempListingItem.categoryColor ) {
6227					categoryColor = 'rgb(' + tempListingItem.categoryColor + ')';
6228					categoryColorStyle = ' style="background-color:' + categoryColor + ';"';
6229				}
6230
6231				if ( 'undefined' === typeof tempListingItem.icon || undefined === typeof tempListingItem.icon ) {
6232					icon = 'icon-map-marker';
6233				} else if ( 'undefined' === tempListingItem.icon || undefined === tempListingItem.icon || '' === tempListingItem.icon || ' ' === tempListingItem.icon ) {
6234					icon = 'icon-map-marker';
6235				} else {
6236					icon = tempListingItem.icon;
6237				}
6238
6239				if ( undefined !== tempListingItem.lat && undefined !== tempListingItem.lng ) {
6240
6241					hasLatLng = true;
6242
6243					latLng = new L.LatLng( tempListingItem.lat, tempListingItem.lng );
6244
6245					if ( - 1 !== icon.indexOf( '<svg' ) ) {
6246						divMarker = L.divIcon( {
6247							iconSize: new L.Point( 50, 50 ),
6248							html: '<div class="leaflet-marker-pin-border"></div><div class="leaflet-marker-pin"' + categoryColorStyle + '></div><i class=" ref_' + tempListingItem.id + '">' + icon + '</i>'
6249						} );
6250					} else {
6251						divMarker = L.divIcon( {
6252							iconSize: new L.Point( 50, 50 ),
6253							html: '<div class="leaflet-marker-pin-border"></div><div class="leaflet-marker-pin"' + categoryColorStyle + '></div><i class="' + icon + ' ref_' + tempListingItem.id + '"></i>'
6254						} );
6255					}
6256
6257					markers[ tempListingItem.id ] = new L.marker( latLng, { icon: divMarker } );
6258					markersList.push( markers[ tempListingItem.id ] );
6259					clusteredMarkers.addLayer( markers[ tempListingItem.id ] );
6260					bounds[ m ] = [ tempListingItem.lat, tempListingItem.lng ];
6261
6262					idArray.push( [
6263						tempListingItem.id,
6264						tempListingItem.lat,
6265						tempListingItem.lng,
6266						markers[ tempListingItem.id ]
6267					] );
6268				}// End if().
6269
6270				if ( mapSidebarWasCreated && 0 ===1 ) {
6271					if ( $( '.listar-map ~ .listar-aside-list' ).length ) {
6272						//alert(85);
6273					}
6274				} else {
6275					if ( $( '.listar-map ~ .listar-aside-list' ).length ) {
6276
6277						setTimeout( function () {
6278							$( '.listar-aside-list .listar-posts-column' ).addClass( 'listar-enable-mouse-events' );
6279						}, 6000 );
6280
6281						$( '.listar-aside-post.listar-temp-div' ).each( function () {
6282							$( this ).prop( 'outerHTML' );
6283						} )
6284
6285						/* Creat map sidebar with listings */
6286						$( '.listar-map ~ .listar-aside-list .listar-posts-column-list' ).append( '<div class="listar-aside-post listar-temp-div"></div>' );
6287						$( '.listar-aside-post.listar-temp-div' ).addClass( tempListingItem.id );
6288
6289						if ( 'undefined' !== typeof tempListingItem.listingID ) {
6290							$( '.listar-aside-post.listar-temp-div' ).attr( 'id', 'listar-listing-map-' + tempListingItem.listingID );
6291							lastListingID = tempListingItem.listingID;
6292						}
6293
6294						if ( 'undefined' !== typeof tempListingItem.link ) {
6295							$( '.listar-aside-post.listar-temp-div' ).append( '<a href="' + tempListingItem.link + '"></a>' );
6296						} else {
6297							$( '.listar-aside-post.listar-temp-div' ).append( '<a href="#"></a>' );
6298						}
6299
6300						if ( - 1 !== icon.indexOf( '<svg' ) ) {
6301							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-aside-post-icon">' + icon + '</div>' );
6302						} else {
6303							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-aside-post-icon ' + icon + '"></div>' );
6304						}
6305
6306						if ( 'undefined' !== typeof tempListingItem.categoryColor ) {
6307							$( '.listar-aside-post.listar-temp-div .listar-aside-post-icon' ).css( 'background-color', categoryColor );
6308						}
6309
6310						if ( isMobile() ) {
6311							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-show-map-popup"></div>' );
6312						}
6313
6314						$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-single-listing-link"></div>' );
6315
6316						if ( 'undefined' !== typeof tempListingItem.featText ) {
6317							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-ribbon">' + tempListingItem.featText + '</div>' );
6318						}
6319
6320						if ( 'undefined' !== typeof tempListingItem.rating ) {
6321							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-listing-rating">' + tempListingItem.rating + '</div>' );
6322						}
6323
6324						if ( 'undefined' !== typeof tempListingItem.trending ) {
6325							$( '.listar-aside-post.listar-temp-div' ).attr( 'data-has', 'trending' );
6326							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-trending-icon fal fa-bolt"></div>' );
6327						}
6328
6329						if ( 'undefined' !== typeof tempListingItem.claimed ) {
6330							$( '.listar-aside-post.listar-temp-div' ).attr( 'data-has', 'claim' );
6331							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-claimed-icon"></div>' );
6332						}
6333
6334						if ( 'undefined' === typeof tempListingItem.lat || 'undefined' === typeof tempListingItem.lng ) {
6335							$( '.listar-aside-post.listar-temp-div' ).attr( 'data-no-coordinates', 'no-coordinates' );
6336							$( '.listar-aside-post.listar-temp-div a' ).append( '<div class="listar-no-map-nav icon-map-marker-crossed"></div>' );
6337
6338							if ( $( '.listar-aside-post.listar-temp-div .icon-map-marker' ).length ) {
6339								$( '.listar-aside-post.listar-temp-div .icon-map-marker' ).prop( 'outerHTML', '' );
6340							}
6341						}
6342
6343						$( '.listar-aside-post.listar-temp-div a' )
6344							.append( '<div class="listar-aside-post-pic"></div>' )
6345							.append( '<div class="listar-aside-post-data"></div>' );
6346
6347						if ( 'undefined' !== typeof tempListingItem.img ) {
6348							if ( -1 === tempListingItem.img.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
6349								var listingImage = '<div id="listar-listing-image-' + tempListingItem.id + '"></div>';
6350								$( '.listar-aside-post.listar-temp-div .listar-aside-post-pic' ).append( listingImage );
6351								$( '#listar-listing-image-' + tempListingItem.id ).css( { 'background-image' : 'url(' + tempListingItem.img + ')' } );
6352
6353								if ( 'undefined' !== typeof tempListingItem.logo ) {
6354									//alert( tempListingItem.img );
6355									//alert( tempListingItem.logo );
6356									if ( -1 === tempListingItem.logo.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
6357										var listingLogo = '<div class="listar-listing-logo-wrapper"><div class="listar-listing-logo" id="listar-listing-logo-' + tempListingItem.id + '"></div></div>';
6358										$( '.listar-aside-post.listar-temp-div a' ).append( listingLogo );
6359										$( '#listar-listing-logo-' + tempListingItem.id ).css( { 'background-image' : 'url(' + tempListingItem.logo + ')' } );
6360									}
6361								}
6362							} else {
6363								$( '.listar-aside-post.listar-temp-div' ).attr( 'data-no-image', 'listar-no-image' );
6364							}
6365						} else {
6366							$( '.listar-aside-post.listar-temp-div' ).attr( 'data-no-image', 'listar-no-image' );
6367						}
6368
6369						$( '.listar-aside-post.listar-temp-div .listar-aside-post-data' ).append( '<div class="listar-aside-post-title"></div>' );
6370
6371						if ( 'undefined' !== typeof tempListingItem.title ) {
6372							$( '.listar-aside-post.listar-temp-div .listar-aside-post-title' ).append( tempListingItem.title );
6373						}
6374
6375						if ( 'undefined' !== typeof tempListingItem.category ) {
6376							$( '.listar-aside-post.listar-temp-div .listar-aside-post-data' ).append( '<div class="listar-aside-post-category"></div>' );
6377							$( '.listar-aside-post.listar-temp-div .listar-aside-post-category' ).append( tempListingItem.category );
6378						}
6379
6380						if ( 'undefined' !== typeof tempListingItem.region ) {
6381							$( '.listar-aside-post.listar-temp-div .listar-aside-post-data' ).append( '<div class="listar-aside-post-region"></div>' );
6382							$( '.listar-aside-post.listar-temp-div .listar-aside-post-region' ).append( tempListingItem.region );
6383						}
6384
6385						$( '.listar-aside-post.listar-temp-div' ).removeClass( 'listar-temp-div' );
6386
6387					}// End if().
6388				}
6389
6390			}// End for().
6391
6392		}// End if().
6393
6394		if ( ! hasLatLng ) {
6395			if ( '' === listarLocalizeAndAjax.fallbackMapLocation ) {
6396				listarLocalizeAndAjax.fallbackMapLocation = 'Las Vegas';
6397			}
6398
6399			setTimeout( function () {
6400				geocoder = L.esri.Geocoding.geocodeService();
6401
6402				geocoder.geocode().text( listarLocalizeAndAjax.fallbackMapLocation ).run( function ( leafletGeocoderError, response ) {
6403					if ( leafletGeocoderError ) {
6404						return;
6405					}
6406
6407					map.fitBounds( response.results[0].bounds );
6408				} );
6409			}, 1800 );
6410		}
6411	}
6412
6413	function addAjaxMapMarkers() {
6414		addMapMarkers();
6415		listingMapResize( 0, '100%' );
6416		fitMapBounds( map, bounds );
6417
6418		setTimeout( function () {
6419			map.invalidateSize();
6420		}, 1000 );
6421
6422		map.addLayer( clusteredMarkers );
6423
6424	}
6425
6426	function setMapDefaultVisibility() {
6427		if ( $( '.listar-main-block.listar-listings' ).length > 0 ) {
6428			if ( theBody.hasClass( 'listar-map-and-page' ) ) {
6429				$( '.listar-main-block' ).css( { opacity : 1 } );
6430				$( '.listar-main-block, footer' ).css( { display : 'block' } );
6431			} else {
6432				$( '.listar-main-block' ).stop().animate( { opacity : 0 }, { duration : 500, complete : function () {
6433					$( '.listar-main-block, footer' ).css( { display : 'none' } );
6434				} } );
6435			}
6436		}
6437	}
6438
6439	function listingMapResize( init, w ) {
6440		if ( $( '.listar-map ~ .listar-aside-list' ).length ) {
6441			var
6442				listRight = parseInt( $( '.listar-map ~ .listar-aside-list' ).css( 'right' ).replace( /[^-\d\.]/g, '' ), 10 ),
6443				ww = $( window ).width(),
6444				dif = 288; /* Map sidebar width */
6445
6446			if ( 'undefined' !== typeof init ) {
6447				if ( 1 === init ) {
6448					w = ww - dif;
6449				} else {
6450					if ( 'undefined' === typeof w ) {
6451						if ( listRight < - 285 ) {
6452							w = ww;
6453						} else {
6454							w = ww - dif;
6455						}
6456					}
6457				}
6458			} else {
6459				if ( listRight < - 285 ) {
6460					w = ww;
6461				} else {
6462					w = ww - dif;
6463				}
6464
6465			}
6466
6467			if ( 'undefined' !== typeof listarMapMarkers && $( '#map' ).length ) {
6468				$( '#map' ).height( $( window ).height() - headerTopbarDistance( true ) ).width( w );
6469				$( '.listar-map ~ .listar-aside-list' ).css( { display : 'block' } );
6470			} else {
6471				$( '#map' ).height( $( window ).height() - headerTopbarDistance( true ) ).width( $( window ).width() );
6472			}
6473
6474			$( '.listar-map ~ .listar-aside-list' ).height( '100%' ).width( 285 );
6475
6476		}// End if().
6477
6478	}
6479
6480	function singleListingMapResize() {
6481		var mapHeight = 332;
6482
6483		$( '.listar-listing-map #map' ).height( mapHeight ).width( $( '.listar-listing-map #map' ).parent().width() );
6484	}
6485
6486	function centerLeafletMapOnMarker( map, marker ) {
6487		var latLngs = [ marker.getLatLng() ];
6488		var markerBounds = L.latLngBounds( latLngs );
6489
6490		map.fitBounds( markerBounds );
6491	}
6492
6493	function resetMap() {
6494		if ( 'undefined' !== typeof listarMapMarkers && $( '#map' ).length && true === mapStarted ) {
6495			if ( ! $( '.listar-map-listing.listar-map-hidden' ).length ) {
6496				$( '.listar-map-listing' ).stop().animate( { height: $( window ).height() - headerTopbarDistance( true ) }, { duration : 300 } );
6497			}
6498
6499			setTimeout( function () {
6500				listingMapResize();
6501				singleListingMapResize();
6502			}, 300 );
6503
6504			setTimeout( function () {
6505				fitMapBounds( map, bounds );
6506				mapFitBoundsFix();
6507			}, 500 );
6508
6509			setTimeout( function () {
6510				if ( 0 === $( '#map' ).parents( '#secondary' ).length && 0 === $( '#map' ).parents( '.listar-footer-column' ).length > 0 ) {
6511					map.invalidateSize();
6512				}
6513			}, 1100 );
6514		}
6515	}
6516
6517	function mapFitBoundsFix() {
6518		/*
6519		 * Leaflet tries to keep all markers and clusters visible
6520		 * on map, but sometimes they are positioned too next of laterals.
6521		 * Call zoomOut() (after fitBounds were defined) to fix it.
6522		 */
6523		setTimeout( function () {
6524			map.zoomOut();
6525		}, 600 );
6526	}
6527
6528	function leafletMapInit() {
6529		if ( false === mapStarted ) {
6530			mapStarted = true;
6531			resetMap();
6532			listingMapResize( 1 );
6533			singleListingMapResize();
6534
6535			if ( $( '.listar-map ~ .listar-aside-list' ).length ) {
6536
6537				$( '.listar-map ~ .listar-aside-list' )
6538					.append( '<div class="listar-close-aside-listings icon-cross2"></div>' )
6539					.append( '<div class="listar-posts-column"></div>' );
6540
6541				if ( ! $( '.listar-map ~ .listar-aside-list .listar-posts-column .listar-posts-column-list-wrapper' ).length ) {
6542					$( '.listar-map ~ .listar-aside-list .listar-posts-column' ).append( '<div class="listar-posts-column-list-wrapper"></div>' );
6543				}
6544
6545				if ( ! $( '.listar-map ~ .listar-aside-list .listar-posts-column .listar-posts-column-list-wrapper .listar-posts-column-list' ).length ) {
6546					$( '.listar-map ~ .listar-aside-list .listar-posts-column-list-wrapper' ).append( '<div class="listar-posts-column-list"></div>' );
6547				}
6548
6549
6550
6551				
6552				
6553
6554				setTimeout( function () {
6555					
6556
6557					if ( ! $( '.listar-map ~ .listar-aside-list .listar-posts-column .listar-posts-column-list-wrapper .listar-results-count' ).length ) {
6558						$( '.listar-map ~ .listar-aside-list .listar-posts-column-list' ).prepend( $( '.listar-results-container .listar-results-count' ).prop( 'outerHTML' ) );
6559					}
6560				}, 500 );
6561
6562			}
6563
6564			if ( 'undefined' !== typeof listarMapMarkers && $( '#map' ).length ) {
6565				var
6566					latlng  = new L.LatLng( lat, lng ),
6567					dragMap = true,
6568					tapMap  = true;
6569
6570				$( '.listar-map-button-text' ).css( { display : 'inline-block' } ).stop().animate( { opacity : 1 }, { duration : 1000 } );
6571
6572				clusteredMarkers = new L.MarkerClusterGroup( {
6573					showCoverageOnHover: false,
6574					maxClusterRadius : 30,
6575					iconCreateFunction: function ( cluster ) {
6576
6577						/* Get the number of items in the cluster */
6578						var count = cluster.getChildCount();
6579
6580						/* Figure out how many digits long the number is */
6581						var digits = ( count + '' ).length;
6582
6583						/* Return a new L.DivIcon with our classes so we can style them with CSS. */
6584						return new L.divIcon( {
6585							html: '<div class="leaflet-cluster-content"><div class="leaflet-cluster-border"></div><div class="leaflet-cluster-counter">' + count + '</div></div>',
6586							className: 'leaflet-cluster digits-' + digits,
6587							iconSize: null
6588						} );
6589					}
6590				} );
6591
6592				/* Always draw cluster's coverage ?
6593
6594				var coverages = new L.LayerGroup();
6595
6596				clusteredMarkers.on("animationend", function() {
6597					// Here getting clusters randomly, but you can decide which one you want to show coverage of.
6598
6599
6600					coverages.clearLayers();
6601
6602					clusteredMarkers._featureGroup.eachLayer(function(layer) {
6603					  	if (layer instanceof L.MarkerCluster && layer.getChildCount() > 2) {
6604							//clusteredMarkers._showCoverage({ layer: layer });
6605							coverages.addLayer(L.polygon(layer.getConvexHull()));
6606						}
6607
6608						coverages.addTo(map);
6609					});
6610				});
6611
6612				*/
6613
6614				if ( 'undefined' !== typeof ( listarMinMapZoomLevel ) ) {
6615					minimumZoom = listarMinMapZoomLevel;
6616				}
6617
6618				if ( 'undefined' !== typeof ( listarMaxMapZoomLevel ) ) {
6619					maximumZoom = listarMaxMapZoomLevel;
6620				}
6621
6622                                if ( 'undefined' !== typeof ( listarInitialArchiveMapZoomLevel ) ) {
6623                                        var tempZoom = parseInt( listarInitialArchiveMapZoomLevel, 10 );
6624
6625                                        if ( 0 !== tempZoom ) {
6626                                                initialMapZoomArchive = tempZoom;
6627                                        }
6628                                }
6629
6630                                if ( 'undefined' !== typeof ( listarInitialSingleMapZoomLevel ) ) {
6631                                        var tempZoom = parseInt( listarInitialSingleMapZoomLevel, 10 );
6632
6633                                        if ( 0 !== tempZoom ) {
6634                                                initialMapZoomSingle = tempZoom;
6635                                        }
6636                                }
6637
6638                                if ( theBody.hasClass( 'single-job_listing' ) ) {
6639                                        initialMapZoom = initialMapZoomSingle;
6640                                } else {
6641                                        initialMapZoom = initialMapZoomArchive;
6642                                }
6643
6644                                if ( 0 !== initialMapZoom ) {
6645                                        hasCustomInitialMapZoom = true;
6646                                } else {
6647                                        initialMapZoom = 14;
6648                                }
6649
6650				if ( viewport().width < 500 ) {
6651					minimumZoom = 1;
6652				}
6653
6654				if ( isMobile() && 0 === $( 'header.listar-map-listing' ).length ) {
6655					dragMap = false;
6656					tapMap  = false;
6657				}
6658
6659				osm = L.tileLayer( osmUrl, { minZoom: minimumZoom, maxZoom: maximumZoom, attribution: osmAttrib } );
6660				map = new L.Map( 'map', { center: latlng, zoom: initialMapZoom, dragging: dragMap, tap: tapMap, layers: [ osm ] } );
6661
6662				map.setMaxZoom( maximumZoom );
6663
6664				if ( isMobile() || $( '.single-job_listing .leaflet-map-pane, .widget_listar_listing_map .leaflet-map-pane' ).length > 0 ) {
6665
6666					/* Do maps on mobiles, single listing pages and widgets need get focus to enable zoom in/out with mousewheel */
6667					map.scrollWheelZoom.disable();
6668
6669					if ( true === dragMap ) {
6670
6671						map.on( 'focus click', function () {
6672							map.scrollWheelZoom.enable();
6673						} );
6674
6675						map.on( 'blur mouseout', function () {
6676							map.scrollWheelZoom.disable();
6677						} );
6678					}
6679				}
6680
6681				addMapMarkers();
6682
6683				if ( $( '.listar-map ~ .listar-aside-list' ).length ) {
6684					var
6685						mapSidebar,
6686						moreListingsButton,
6687						pagination;
6688
6689					$( '#map' ).addClass( 'listar-map-hidden' );
6690					$( '.listar-widgetized-map-container #map' ).removeClass( 'listar-map-hidden' );
6691
6692					$( '.leaflet-control-zoom' ).append( '<a class="leaflet-control-zoom-reset fa fa-redo" href="#" title="Reset Map" role="button" aria-label="Reset Map"></a>' );
6693
6694					/* Append 'More Results' button to map sidebar, if Ajax Pagination is enabled */
6695					mapSidebar = $( '.listar-map ~ .listar-aside-list .listar-posts-column-list' );
6696					moreListingsButton = $( '.listar-ajax-pagination .listar-more-results.listar-load-listings, .widget_listar_listing_map .listar-more-results.listar-load-listings' );
6697
6698					if ( mapSidebar.length && moreListingsButton.length ) {
6699						moreListingsButton = moreListingsButton.parent().prop( 'outerHTML' );
6700						mapSidebar.append( moreListingsButton );
6701
6702						moreListingsButton = mapSidebar.find( '.listar-more-results' );
6703
6704						moreListingsButton.addClass( 'listar-more-results-map' ).removeClass( 'hidden' );
6705
6706						if ( moreListingsButton.parent().prop( 'outerHTML' ).indexOf( 'col-sm-12' ) ) {
6707							moreListingsButton.parent().removeClass( 'col-sm-12' ).addClass( 'listar-load-more-wrapper' );
6708						}
6709
6710						moreListingsButton.parent().removeClass( 'hidden aos-init' ).removeAttr( 'data-aos' );
6711					}
6712
6713					/* Append default pagination links to map sidebar, if Ajax Pagination is disabled */
6714					pagination = $( '.listar-no-ajax-pagination .listar-results-container' ).parents( '#primary' ).find( 'section .posts-navigation' );
6715
6716					if ( mapSidebar.length && pagination.length ) {
6717						pagination = pagination.prop( 'outerHTML' );
6718						mapSidebar.append( pagination );
6719
6720						mapSidebar.find( '.posts-navigation a' ).each( function () {
6721							var hash = $( this ).attr( 'href' ) + '#mapview';
6722							$( this ).attr( 'href', hash );
6723						} );
6724					}
6725
6726					/* Append 'More Results' button to map sidebar, if map widget on front page */
6727					moreListingsButton = $( '.page-template-front-page .listar-more-results.listar-load-listings' );
6728
6729					if ( mapSidebar.length && moreListingsButton.length && 0 === mapSidebar.find( '.listar-more-results' ).length ) {
6730						moreListingsButton = moreListingsButton.prop( 'outerHTML' );
6731						mapSidebar.append( moreListingsButton );
6732						mapSidebar.find( '.listar-more-results' ).addClass( 'listar-more-results-map' ).removeClass( 'hidden' );
6733					}
6734
6735					listingMapResize( 0, '100%' );
6736				}// End if().
6737
6738				fitMapBounds( map, bounds );
6739
6740				setTimeout( function () {
6741					var map_zoom_menu_items = $( '.leaflet-touch .leaflet-bar a' );
6742
6743					map.invalidateSize();
6744
6745					map_zoom_menu_items.each( function () {
6746						var span = $( this ).find( 'span' );
6747
6748						if ( ! span.length ) {
6749							$( this ).prop( 'innerHTML', '<span>' + $( this ).prop( 'innerHTML' ) + '</span>' );
6750						}
6751					} );
6752
6753					/* Remove Leaflet attributtion, keep attribution only for Openstreet Map */
6754					if ( $( '.leaflet-control-attribution' ).length ) {
6755						$( '.leaflet-control-attribution' ).prop( 'innerHTML', $( '.leaflet-control-attribution a:last-child' ).prop( 'outerHTML' ) );
6756					}
6757				}, 1000 );
6758
6759                                setInitialMapZoom();                                
6760
6761				map.addLayer( clusteredMarkers );
6762
6763				if ( theBody.hasClass( 'listar-map-view' ) || $( '.listar-widgetized-map-container' ).length > 0 ) {
6764					showMap();
6765				}
6766
6767				hasBackgroundImages = true;
6768
6769				$( '.listar-posts-column-list' ).scroll( function () {
6770
6771					/* Move background image URL from 'data-background-image' attribute to 'background-image' style */
6772					if ( hasBackgroundImages ) {
6773						hasBackgroundImages = false;
6774						convertDataBackgroundImage();
6775					}
6776				} );
6777
6778				$( '.listar-front-widget-wrapper .widget_listar_listing_map' ).each( function () {
6779					$( this ).parents( '.listar-front-widget-wrapper' ).addClass( 'listar-map-ready-to-launch' );
6780
6781					if ( $( this ).find( '.listar-map-waves' ).length ) {
6782						$( this ).parents( '.listar-front-widget-wrapper' )
6783							.addClass( '.listar-map-with-waves' )
6784							.append( '<div class="listar-wave-top"></div>' )
6785							.append( '<div class="listar-wave-bottom"></div>' );
6786					}
6787				} );
6788
6789			} else {
6790
6791				$( '.widget_listar_listing_map' ).addClass( 'leaflet-show-map-fail' );
6792
6793				if ( ! $( '.page-content.listar-not-found' ).length ) {
6794					$( '.listar-map-button' ).css( { display : 'none' } );
6795					$( '.listar-current-page-info' ).animate( { width: '100%' } );
6796				}
6797			}// End if().
6798
6799			/* Map events *********************************/
6800
6801			theBody.on( 'click', '.leaflet-control-zoom-reset', function ( e ) {
6802				e.preventDefault();
6803				e.stopPropagation();
6804				resetMap();
6805			} );
6806
6807			$( '.listar-map-button' ).not( '.disabled' ).on( {
6808				'mouseenter' : function () {
6809					if ( ! onMap ) {
6810						leafletMapInit();
6811						$( '.listar-current-page-info, .listar-header-search' ).addClass( 'listar-hide-page-info' );
6812					}
6813				},
6814				'mouseleave' : function () {
6815					if ( ! onMap ) {
6816						$( '.listar-current-page-info, .listar-header-search' ).removeClass( 'listar-hide-page-info' );
6817					}
6818				},
6819				'click' : function () {
6820					leafletMapInit();
6821					showMap();
6822
6823					$( '.listar-page-header' ).removeClass( 'listar-display-all-filters' );
6824				}
6825			} );
6826
6827			theBody.on( 'click', '.listar-back-listing-button', function () {
6828				onMap = 0;
6829
6830				isLoadMoreEqualizer = true;
6831
6832				theBody.removeClass( 'listar-stop-scrolling' );
6833				theBody.removeClass( 'listar-showing-map listar-hide-main-menu' );
6834				$( '#page' ).css( { height: '' } );
6835
6836				initOnScrollEffects( true );
6837
6838				setTimeout( function () {
6839					$( '.listar-current-page-info, .listar-header-search' ).stop().removeClass( 'listar-hide-page-info' );
6840					checkGridFillerCard();
6841				}, 500 );
6842
6843				$( '.listar-more-results' ).css( { display : 'inline-block' } );
6844				$( '.listar-page-header-with-map' ).css( { display : 'table' } );
6845				$( '.listar-page-header-with-map, .listar-map-button' ).stop().animate( { opacity : 1 } );
6846				$( '.listar-map-listing' ).stop().animate( { height: 164 }, { duration : 1000 } );
6847
6848				listingMapResize( 0, '100%' );
6849
6850				setTimeout( function () {
6851					map.invalidateSize();
6852				}, 800 );
6853
6854				setTimeout( function () {
6855					$( '.listar-map-listing' ).addClass( 'listar-map-hidden' );
6856				}, 1000 );
6857
6858				setTimeout( function () {
6859					heightEqualizer( '.listar-listing-card' );
6860				}, 500 );
6861
6862				$( '#map' ).addClass( 'listar-map-hidden' );
6863				$( '.listar-map ~ .listar-aside-list' ).stop().animate( { right: - 350 }, { duration : 800 } );
6864				$( '.listar-main-block, footer' ).css( { display : 'block' } );
6865				$( '.listar-main-block' ).stop().animate( { opacity : 1 }, { duration : 2000 } );
6866				$( '.listar-map ~ .listar-aside-list .listar-close-aside-listings' ).addClass( 'icon-cross2' ).removeClass( 'icon-location' );
6867
6868			} );
6869
6870			theBody.on( 'click', '.listar-map ~ .listar-aside-list .listar-close-aside-listings', function () {
6871				var list = $( this ).parent();
6872				var listRight = list.css( 'right' );
6873
6874				if ( '0px' === listRight ) {
6875					$( this ).removeClass( 'icon-cross2' ).addClass( 'icon-location' );
6876					listingMapResize( 0, '100%' );
6877
6878					setTimeout( function () {
6879						map.invalidateSize();
6880					}, 1000 );
6881
6882					list.stop().animate( { right: - 290 }, { duration : 800 } );
6883
6884				} else {
6885					$( this ).addClass( 'icon-cross2' ).removeClass( 'icon-location' );
6886					list.stop().animate( { right: 0 }, { duration : 800 } );
6887
6888					setTimeout( function () {
6889						listingMapResize( 1 );
6890					}, 1000 );
6891
6892					setTimeout( function () {
6893						map.invalidateSize();
6894					}, 1500 );
6895				}
6896
6897				if ( '0px' === listRight && viewport().width < 400 ) {
6898					$( '.leaflet-control-container' ).css( { display : 'block' } );
6899				} else if ( viewport().width < 400 ) {
6900					$( '.leaflet-control-container' ).css( { display : 'none' } );
6901				} else {
6902					$( '.leaflet-control-container' ).css( { display : 'block' } );
6903				}
6904			} );
6905
6906			theBody.on( 'click', '#map', function ( e ) {
6907				if ( $( e.target ).hasClass( 'leaflet-pane' ) || $( e.target ).hasClass( 'leaflet-container' ) && 0 === dragging ) {
6908					$( '.leaflet-div-icon' ).removeClass( 'selected leaflet-popup-recently-closed' );
6909					$( '.leaflet-popup' ).stop().animate( { marginBottom: '0px' }, { duration : 300 } );
6910				}
6911			} );
6912
6913			preventDoubleClick = 0;
6914
6915			theBody.on( 'mouseenter click', '.listar-map ~ .listar-aside-list .listar-aside-post a .listar-show-map-p
6915opup', function ( e ) {
6916				e.preventDefault();
6917				e.stopPropagation();
6918
6919				if ( ! preventDoubleClick ) {
6920					var
6921						sidebarListingElem = $( this ).parent().parent(),
6922						elementToClick,
6923						id;
6924
6925					preventDoubleClick = 1;
6926
6927					if ( sidebarListingElem.hasClass( 'listar-aside-post' ) ) {
6928						id = sidebarListingElem.attr( 'class' ).replace( 'listar-aside-post ', '' );
6929
6930						if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
6931							var idsCount = idArray.length;
6932
6933							for ( var i = 0; i < idsCount; i++ ) {
6934								if ( idArray[ i ][0] === id ) {
6935									centerLeafletMapOnMarker( map, idArray[ i ][3] );
6936									$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
6937									break;
6938								}
6939							}
6940
6941							$( 'i.ref_' + id ).each( function () {
6942								elementToClick = $( this );
6943
6944								if ( viewport().width < 600 ) {
6945									$( '.listar-close-aside-listings.icon-cross2' ).trigger( 'click' );
6946								}
6947							} );
6948
6949							setTimeout( function () {
6950								elementToClick.trigger( 'click' );
6951							}, 1050 );
6952
6953						}
6954
6955						setTimeout( function () {
6956							$( '.leaflet-div-icon' ).removeClass( 'selected' );
6957							$( '#' + id ).addClass( 'selected' );
6958							preventDoubleClick = 0;
6959						}, 1250 );
6960					}
6961				}// End if().
6962			} );
6963
6964			var hoverTest;
6965
6966			theBody.on( 'mouseenter', '.listar-map ~ .listar-aside-list .listar-aside-post a .listar-aside-post-pic, .listar-map ~ .listar-aside-list .listar-aside-post a .listar-listing-rating, .listar-map ~ .listar-aside-list .listar-aside-post a .listar-aside-post-data', function ( e ) {
6967				var
6968					elemmen = $( this ),
6969					parentElement = $( e.target ).parent(),
6970					id;
6971
6972				e.preventDefault();
6973				e.stopPropagation();
6974
6975				// Cancel/Repeats mouseenter to display the listing popup on map.
6976
6977				setTimeout( function () {
6978					elemmen.parents( '.listar-aside-post' ).each( function () {
6979						//alert( $( '.leaflet-marker-icon[id="' + id + '"]' ).length );
6980						if ( $( '.leaflet-marker-icon[id="' + id + '"]' ).length ) {
6981
6982							clearInterval( hoverTest );
6983
6984							hoverTest = setInterval( function () {
6985
6986								//alert( ! $( '.leaflet-popup-content' ).length );
6987								if ( ! $( '.leaflet-marker-icon.selected' ).length || ! $( '.leaflet-popup-content' ).length ) {
6988
6989									$( '.leaflet-marker-icon[id="' + id + '"]' ).each( function () {
6990										$( '.leaflet-marker-icon[id="' + id + '"]' ).removeClass( 'selected' );
6991										$( '.leaflet-marker-icon[id="' + id + '"]' )[0].click();
6992										//$( this ).find( '*' ).trigger( 'mouseleave' );
6993										//$( this ).find( '.listar-aside-post-data' ).trigger( 'mouseenter' );
6994
6995									} );
6996								} else {
6997
6998									if ( ! $( '.leaflet-pane.leaflet-tile-pane .leaflet-layer .leaflet-tile-container' ).length ) {
6999										isRestartingMap = false;
7000										restartMapPosition( id );
7001
7002									} else {
7003										clearInterval( hoverTest );
7004									}
7005								}
7006
7007							}, 1000 );
7008						}
7009					} );
7010
7011				}, 1500 );
7012
7013				if ( ! parentElement.parent()[0].hasAttribute( 'data-no-coordinates' ) && ! parentElement.parent().parent()[0].hasAttribute( 'data-no-coordinates' ) && ! parentElement.parent().parent().parent()[0].hasAttribute( 'data-no-coordinates' ) ) {
7014					id = $( this ).parents( '.listar-aside-post' ).attr( 'class' ).replace( 'listar-aside-post ', '' );
7015
7016					if ( parentElement.hasClass( 'listar-aside-post' ) ) {
7017						id = parentElement.attr( 'class' ).replace( 'listar-aside-post ', '' );
7018
7019						if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7020							var idsCount = idArray.length;
7021
7022							for ( var i = 0; i < idsCount; i++ ) {
7023								if ( idArray[ i ][0] === id ) {
7024									centerLeafletMapOnMarker( map, idArray[ i ][3] );
7025									$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
7026									break;
7027								}
7028							}
7029
7030							$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7031						}
7032
7033						setTimeout( function () {
7034							$( '.leaflet-div-icon' ).removeClass( 'selected' );
7035							$( '#' + id ).addClass( 'selected' );
7036						}, 15 );
7037					} else if ( parentElement.parent().hasClass( 'listar-aside-post' ) ) {
7038						id = parentElement.parent().attr( 'class' ).replace( 'listar-aside-post ', '' );
7039
7040						if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7041							var idsCount2 = idArray.length;
7042
7043							for ( var n = 0; n < idsCount2; n++ ) {
7044								if ( idArray[ n ][0] === id ) {
7045									centerLeafletMapOnMarker( map, idArray[ n ][3] );
7046									$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
7047									break;
7048								}
7049							}
7050
7051							$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7052						}
7053
7054						setTimeout( function () {
7055							$( '.leaflet-div-icon' ).removeClass( 'selected' );
7056							$( '#' + id ).addClass( 'selected' );
7057						}, 15 );
7058
7059					} else if ( parentElement.parent().parent().hasClass( 'listar-aside-post' ) ) {
7060						id = parentElement.parent().parent().attr( 'class' ).replace( 'listar-aside-post ', '' );
7061
7062						if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7063							var idsCount3 = idArray.length;
7064							var currentMapZoom = 0;
7065
7066							for ( var c = 0; c < idsCount3; c++ ) {
7067								if ( undefined !== idArray[ c ] && 'undefined' !== idArray[ c ] ) {
7068									if ( idArray[ c ][0] === id ) {
7069										centerLeafletMapOnMarker( map, idArray[ c ][3] );
7070										$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
7071										break;
7072									}
7073								}
7074							}
7075
7076							currentMapZoom = map.getZoom();
7077
7078							if ( 'undefined' !== typeof idArray[ c ] ) {
7079								if ( undefined !== idArray[ c ] && 'undefined' !== idArray[ c ] ) {
7080									if ( ! map.hasLayer( idArray[ c ][3] ) ) {
7081										map.setMaxZoom( currentMapZoom + 1 );
7082
7083										setTimeout( function () {
7084											$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
7085											currentMapZoom = map.getZoom();
7086											map.setZoom( currentMapZoom + 1 );
7087
7088											if ( 'undefined' !== typeof idArray[ c ] ) {
7089												if ( ! map.hasLayer( idArray[ c ][3] ) ) {
7090													map.setMaxZoom( currentMapZoom + 1 );
7091													map.setZoom( currentMapZoom + 1 );
7092
7093													setTimeout( function () {
7094														$( '#map' ).find( '.ref_' + id ).parent().attr( 'id', id );
7095														$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7096													}, 200 );
7097												} else {
7098													if ( $( '#' + id + ' .leaflet-marker-pin-border' ).length ) {
7099														$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7100													}
7101												}
7102											} else {
7103												if ( $( '#' + id + ' .leaflet-marker-pin-border' ).length ) {
7104													$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7105												}
7106											}
7107										}, 200 );
7108									} else {
7109										$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7110									}
7111								}
7112							}
7113						}
7114
7115						setTimeout( function () {
7116							$( '.leaflet-div-icon' ).removeClass( 'selected' );
7117							$( '#' + id ).addClass( 'selected' );
7118						}, 15 );
7119					}// End if().
7120
7121					if ( 'undefined' !== typeof id ) {
7122						setTimeout( function () {
7123							restartMapPosition( id );
7124						}, 2000 );
7125					}
7126
7127
7128				}// End if().
7129			} );
7130
7131			theBody.on( 'click', '.listar-map ~ .listar-aside-list .listar-aside-post .listar-map-icon', function ( e ) {
7132				var
7133					mapIconParent = $( e.target ).parent().parent(),
7134					id;
7135
7136				if ( mapIconParent.hasClass( 'listar-aside-post' ) ) {
7137					id = mapIconParent.attr( 'class' ).replace( 'listar-aside-post ', '' );
7138
7139					if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7140						$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7141					}
7142				} else if ( mapIconParent.parent().hasClass( 'listar-aside-post' ) ) {
7143					id = mapIconParent.parent().attr( 'class' ).replace( 'listar-aside-post ', '' );
7144
7145					if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7146						$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7147					}
7148				} else if ( mapIconParent.parent().parent().hasClass( 'listar-aside-post' ) ) {
7149					id = mapIconParent.parent().parent().attr( 'class' ).replace( 'listar-aside-post ', '' );
7150
7151					if ( ! $( '#' + id ).hasClass( 'selected' ) ) {
7152						$( '#' + id + ' .leaflet-marker-pin-border' ).trigger( 'click' );
7153					}
7154				}
7155			} );
7156
7157			theBody.on( 'mouseenter', '.listar-map ~ .listar-aside-list .listar-aside-post[data-no-coordinates]', function ( e ) {
7158				var closeMarkerPopup = $( '.leaflet-div-icon.selected' );
7159
7160				if ( closeMarkerPopup.length ) {
7161					closeMarkerPopup.trigger( 'click' );
7162				}
7163			} );
7164
7165			theBody.on( 'click', '.leaflet-popup-listing-link', function ( e ) {
7166				if ( '#' === $( this ).attr( 'data-link' ) ) {
7167					e.preventDefault();
7168					e.stopPropagation();
7169				} else {
7170					window.location.href = $( this ).attr( 'data-link' );
7171				}
7172			} );
7173
7174			theBody.off( 'click', '.leaflet-div-icon' );
7175
7176			theBody.on( 'click', '.leaflet-div-icon', function () {
7177				var
7178					id,
7179					innerContent,
7180					thisMarker = this,
7181					markerPinWrapper,
7182					categoryColor,
7183					isSingleListingMap = theBody.hasClass( 'single-job_listing' ),
7184					html;
7185
7186				if ( ! isSingleListingMap ) {
7187
7188					innerContent = $( thisMarker ).find( '.leaflet-marker-pin-border' );
7189					id = $( thisMarker ).find( 'i' ).attr( 'class' ).replace( 'ref_', '' );
7190					categoryColor = $( thisMarker ).find( '.leaflet-marker-pin' ).css( 'background-color' );
7191
7192					if ( id.indexOf( ' ' ) >= 0 ) {
7193						id = id.split( ' ' );
7194						id = id[ id.length - 1 ];
7195					}
7196
7197					markerPinWrapper = innerContent.parent();
7198					markerPinWrapper.attr( 'id', id );
7199
7200					if ( 'undefined' !== typeof listingItem[ id ].link ) {
7201						if ( 'undefined' !== listingItem[ id ].link && undefined !== listingItem[ id ].link && '#' !== listingItem[ id ].link && '' !== listingItem[ id ].link && ' ' !== listingItem[ id ].link ) {
7202							html = '<div class="leaflet-popup-listing-link ' + id + '" data-link="' + listingItem[ id ].link + '">';
7203						} else {
7204							html = '<div class="leaflet-popup-listing-link leaflet-popup-no-hover ' + id + '" data-link="#">';
7205						}
7206					} else {
7207						html = '<div class="leaflet-popup-listing-link leaflet-popup-no-hover ' + id + '" data-link="#">';
7208					}
7209
7210					popupToggling = 1;
7211
7212					setTimeout( function () {
7213						if ( ! markerPinWrapper.hasClass( 'selected' ) && ! markerPinWrapper.hasClass( 'leaflet-popup-recently-closed' ) ) {
7214							$( '.leaflet-div-icon' ).removeClass( 'leaflet-popup-recently-closed' );
7215							$( '.leaflet-div-icon' ).not( thisMarker ).removeClass( 'selected' );
7216							$( '.leaflet-div-icon' ).removeClass( 'leaflet-high-z-index' ).css( { zIndex : 11999 } );
7217							markerPinWrapper.addClass( 'selected' ).css( { backgroundColor : categoryColor } ).removeClass( 'leaflet-high-z-index' ).css( { zIndex : 211999 } );
7218
7219							popupToggling = 0;
7220
7221							if ( 'undefined' !== typeof listingItem[ id ] ) {
7222								if ( 'undefined' !== typeof listingItem[ id ] ) {
7223									if ( 'undefined' !== typeof listingItem[ id ].rating ) {
7224										html += '<div class="listar-popup-rating">' + listingItem[ id ].rating + '</div>';
7225									}
7226								}
7227
7228								if ( 'undefined' !== typeof listingItem[ id ].img && 'undefined' !== typeof listingItem[ id ].logo ) {
7229									if ( -1 === listingItem[ id ].logo.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
7230										html += '<div class="listar-listing-logo-wrapper"><div class="listar-listing-logo" data-background-image="' + listingItem[ id ].logo + '"></div></div>';
7231									}
7232								}
7233
7234								if ( 'string' !== typeof listingItem[ id ].img ) {
7235									if ( -1 === listingItem[ id ].img.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
7236										html += '<div class="leaflet-popup-image" data-background-image="' + listingItem[ id ].img + '">';
7237									} else {
7238										html += '<div class="leaflet-popup-image">';
7239									}
7240								} else {
7241									html += '<div class="leaflet-popup-image">';
7242								}
7243
7244								/* If listing has image, display category name on the footer of thumbnail */
7245								if ( 'undefined' !== typeof listingItem[ id ].category && 'undefined' !== typeof listingItem[ id ].img ) {
7246									if ( -1 === listingItem[ id ].img.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
7247										html += '<div class="leaflet-pop-category">' + listingItem[ id ].category + '</div>';
7248									}
7249								}
7250
7251								if ( 'undefined' !== typeof listingItem[ id ].featText ) {
7252									html += '<div class="listar-ribbon">' + listingItem[ id ].featText + '</div>';
7253								}
7254
7255								html += '</div>';
7256
7257								if ( 'undefined' !== typeof listingItem[ id ].title ) {
7258									html += '<div class="leaflet-pop-title">' + listingItem[ id ].title + '</div>';
7259								}
7260
7261								var listingCategoryWithAddress = '';
7262
7263								/* If listing hasn't image, display category name inside 'leaflet-pop-address' div */
7264								if ( 'undefined' !== typeof listingItem[ id ].category && 'string' === typeof listingItem[ id ].img ) {
7265									if ( listingItem[ id ].img.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) >= 0 ) {
7266										listingCategoryWithAddress += '<span>' + listingItem[ id ].category + '</span>';
7267									}
7268								}
7269
7270								if ( 'undefined' !== typeof listingItem[ id ].address ) {
7271									html += '<div class="leaflet-pop-address">' + listingCategoryWithAddress + '<span>' + listingItem[ id ].address + '</span></div>';
7272								}
7273
7274								html += '</div>';
7275								markers[ id ].bindPopup( html );
7276								markers[ id ].openPopup();
7277
7278								if ( 'string' === typeof listingItem[ id ].img ) {
7279									if ( -1 === listingItem[ id ].img.indexOf( '5BAEAAAAALAAAAAABAAEAAAICRAEAOw' ) ) {
7280										$( '.leaflet-popup-image' ).css( 'background-image', 'url(' + listingItem[ id ].img + ')' );
7281										$( '.leaflet-popup-image' ).parent().removeClass( 'leaflet-no-popup-image' );
7282									} else {
7283										$( '.leaflet-popup-image' ).parent().addClass( 'leaflet-no-popup-image' );
7284									}
7285								} else {
7286									$( '.leaflet-popup-image' ).parent().addClass( 'leaflet-no-popup-image' );
7287								}
7288							}
7289						} else {
7290							popupToggling = 0;
7291
7292							$( '.leaflet-div-icon' ).removeClass( 'selected leaflet-popup-recently-closed' );
7293							$( '.leaflet-popup' ).stop().animate( { marginBottom: '0px' }, { duration : 300 } );
7294
7295							if ( 'undefined' !== typeof markers[ id ] ) {
7296								markers[ id ].closePopup();
7297							}
7298							
7299						}// End if().
7300					}, 3 );
7301
7302					/* Force selected map markers to open the leaflet marker popup, if not opened yet */
7303					setTimeout( function () {
7304						var
7305							currentMapMarkerSelectedID = id,
7306							currentMapMarkerSelected = $( '#' + currentMapMarkerSelectedID + '.selected' ),
7307							leafletPopup = $( '.leaflet-popup' );
7308
7309						if ( currentMapMarkerSelected.length && 0 === leafletPopup.length ) {
7310							currentMapMarkerSelected.removeClass( 'selected' );
7311							currentMapMarkerSelected.trigger( 'click' );
7312						}
7313
7314						if ( leafletPopup.length && 0 === currentMapMarkerSelected.length ) {
7315							$( '#' + currentMapMarkerSelectedID ).addClass( 'selected' );
7316						}
7317
7318						if ( leafletPopup.length ) {
7319							leafletPopup.css( { marginBottom : '32px' } );
7320						}
7321
7322					}, 350 );
7323				}// End if().
7324			} );
7325
7326			theBody.on( 'click', '.leaflet-div-icon', function ( e ) {
7327				if ( ! e.isTrigger ) {
7328
7329					/* Not a programmatic click */
7330					var thisElement = $( this );
7331
7332					if ( $( '.leaflet-popup' ).length ) {
7333						if ( '1' === $( '.leaflet-popup' ).css( 'opacity' ) ) {
7334							thisElement.addClass( 'leaflet-popup-recently-closed' );
7335						}
7336					}
7337				}
7338			} );
7339
7340			dragging = 0;
7341
7342			if ( 'undefined' !== typeof listarMapMarkers && $( '#map' ).length ) {
7343				map.on( 'movestart', function () {
7344					dragging = 1;
7345				} );
7346
7347				map.on( 'moveend', function () {
7348					setTimeout( function () {
7349						dragging = 0;
7350					}, 10 );
7351				} );
7352
7353				map.on( 'popupopen', function ( e ) {
7354
7355					/* Find the pixel location on the map where the popup anchor is */
7356					var px = map.project( e.popup._latlng );
7357
7358					/* Find the height of the popup container, divide by 2, subtract from the Y axis of marker location */
7359					px.y -= e.popup._container.clientHeight / 2;
7360
7361					/* Pan to new center */
7362					map.panTo( map.unproject( px ), { animate: true } );
7363
7364					$( '.leaflet-popup' ).css( { marginBottom: '0px' } ).stop().animate( { marginBottom: '32px' }, { duration : 100 } );
7365				} );
7366
7367				map.on( 'popupclose', function () {
7368					if ( ! popupToggling ) {
7369						$( '.leaflet-div-icon' ).each( function () {
7370							if ( $( this ).hasClass( 'selected' ) ) {
7371								$( this ).removeClass( 'selected' ).addClass( 'leaflet-popup-recently-closed' );
7372							}
7373						} );
7374
7375						$( '.leaflet-popup' ).stop().animate( { marginBottom: '0px' }, { duration : 300 } );
7376					}
7377
7378					setTimeout( function () {
7379						$( '.leaflet-div-icon' ).removeClass( 'leaflet-popup-recently-closed' );
7380					}, 16 );
7381				} );
7382			}// End if().
7383		}// End if().
7384	}
7385
7386	function executeCurrentHash() {
7387
7388		setTimeout( function () {
7389
7390			/**
7391			 * Do programmatic navigation based on URL hashs
7392			 * Detects if the user just posted a review and scroll programatically to show it
7393			 * Sets initial listing view
7394			 * Also, detect the 'read more' tag
7395			 */
7396			if ( window.location.hash ) {
7397				var h = window.location.hash.replace( '#', '' );
7398
7399				var hasLinkAnchor = false;
7400
7401				if ( '' !== h ) {
7402					for ( var hashCounter = 0; hashCounter < specialHashes.length; hashCounter++ ) {
7403						if ( h.indexOf( specialHashes[ hashCounter ] ) >= 0 ) {
7404							hasLinkAnchor = true;
7405						}
7406					}
7407
7408					if ( ! hasLinkAnchor ) {
7409						setTimeout( function () {
7410							var hashAnchor = $( '#primary' ).find( '#' + h );
7411
7412							/* Fix hash/anchor scroll */
7413							if ( hashAnchor.length > 0 ) {
7414								htmlAndBody.stop().animate( {
7415									scrollTop : hashAnchor.offset().top - ( 110 + headerTopbarDistance( true ) )
7416								}, 600 );
7417							}
7418						}, 10 );
7419					}
7420
7421					if ( h.indexOf( 'do-login' ) >= 0 ) {
7422						convertDataBackgroundImage();
7423
7424						setTimeout( function () {
7425							$( '.listar-user-not-logged .listar-user-login' ).eq( 0 ).trigger( 'click' );
7426						}, 2500 );
7427					}
7428
7429					if ( h.indexOf( 'comment-' ) >= 0 || h.indexOf( 'comments' ) >= 0 ) {
7430						setTimeout( function () {
7431							var secondColClasses = 'col-xs-12 col-md-8 listar-review-second-col listar-single-listing-has-reviews';
7432
7433							$( '.listar-review-second-col.listar-single-listing-without-reviews' ).each( function () {
7434								$( this ).addClass( 'hidden' );
7435							} );
7436
7437							$( '.listar-review-second-col.listar-single-listing-without-reviews + div.hidden' ).each( function () {
7438								$( this ).attr( 'class', secondColClasses );
7439							} );
7440
7441							/* Scroll to blog comments, if available */
7442							if ( $( '.listar-comments-container' ).length > 0 ) {
7443								htmlAndBody.stop().animate( {
7444									scrollTop : $( '.listar-comments-container' ).offset().top - 30
7445								}, 600 );
7446							}
7447
7448							/* Scroll to listing reviews, if available */
7449							if ( $( '#listar-listing-review' ).length > 0 ) {
7450								htmlAndBody.stop().animate( {
7451									scrollTop : $( '#listar-listing-review' ).offset().top - 30
7452								}, 600 );
7453							}
7454						}, 10 );
7455					}
7456
7457					/* Read More tag */
7458					if ( h.indexOf( 'more-' ) >= 0 ) {
7459						setTimeout( function () {
7460
7461							/* Scroll to 'more' tag, if available */
7462							var moreTag = $( 'span[id^=more-' );
7463
7464							if ( moreTag.length > 0 ) {
7465								htmlAndBody.stop().animate( {
7466									scrollTop : moreTag.offset().top - 80
7467								}, 600 );
7468							}
7469						}, 10 );
7470					}
7471
7472					/* Set map view? */
7473					if ( h.indexOf( 'mapview' ) >= 0 ) {
7474						setTimeout( function () {
7475							$( '.listar-map-button' ).trigger( 'click' );
7476						}, 2500 );
7477					}
7478
7479					/* Read More tag */
7480					if ( h.indexOf( 'post' ) >= 0 ) {
7481						var tempNewURL = currentURL.split( '?near' ) ;
7482						window.location.hash = '';
7483						history.pushState({}, null, tempNewURL[0] );
7484					}
7485				}
7486			}// End if().
7487
7488			/*
7489			 * If current URL has '?write-review':
7490			 * User was logged out and clicked on 'Write a Review' button,
7491			 * automatically open the review popup right after login.
7492			 */
7493
7494			if ( ! launchedReviewPopup ) {
7495				launchedReviewPopup = true;
7496
7497				if ( currentURL.indexOf( '?write-review' ) >= 0 && $( '.listar-write-review a' ).length > 0 ) {
7498					convertDataBackgroundImage();
7499
7500					setTimeout( function () {
7501						$( '.listar-write-review a' ).eq( 0 ).trigger( 'click' );
7502					}, 3000 );
7503				}
7504			}
7505		}, 500 );
7506	}
7507
7508        function resizeHeroVideosExecute() {
7509                if ( viewport().width >= parseInt( listarLocalizeAndAjax.minimumScreeWidthHeroVideo, 10 ) ) {                        
7510                        var heroWidth = $( '.listar-hero-video' ).width();
7511                        var heroHeight = $( '.listar-hero-video' ).height();
7512                        var videoHeight = heroHeight;
7513                        var videoWidth = videoHeight * 16 / 9;
7514
7515                        if ( heroWidth > heroHeight && videoWidth < heroWidth ) {
7516                                videoWidth = heroWidth;
7517                                videoHeight = videoWidth * 9 / 16;
7518                        }
7519
7520                        $( '.listar-hero-video video, .listar-hero-video iframe, .listar-hero-video .mejs__inner, .listar-hero-video .mejs-inner, .listar-hero-video .mejs__container, .listar-hero-video .mejs-container' ).css( { width : videoWidth, height : videoHeight, maxWidth : '99999px' } );
7521                        $( '.listar-hero-video video, .listar-hero-video iframe, .listar-hero-video .mejs__inner, .listar-hero-video .mejs-inner, .listar-hero-video .mejs__container, .listar-hero-video .mejs-container' ).css( { height : videoHeight + 20 } );
7522
7523                        preventEvenCallStack11 = false;
7524                }
7525        }
7526
7527	function resizeHeroVideos( delay = 0 ) {
7528                if ( viewport().width >= parseInt( listarLocalizeAndAjax.minimumScreeWidthHeroVideo, 10 ) ) {
7529                        if ( ! preventEvenCallStack11 ) {
7530                                preventEvenCallStack11 = true;
7531                                
7532                                setTimeout( function () {
7533                                        resizeHeroVideosExecute();
7534                                        
7535                                        setInterval( function () {
7536                                                resizeHeroVideosExecute()
7537                                        }, 500 );
7538                                }, delay );
7539                        }
7540                }
7541	}
7542
7543	/* Execute only when current browser tab/window be active *****/
7544
7545	function executeOnLoadAndVisible() {
7546		if ( hasExecutedOnLoadAndVisible ) {
7547			return false;
7548		}
7549
7550		hasExecutedOnLoadAndVisible = true;
7551
7552		verifySelect2SubtreePlaceholder();
7553
7554		executeCurrentHash();
7555	}
7556	
7557	$( function () {
7558		
7559		// Define global variables before proceed.
7560
7561		theDocument = $( document );
7562		theBody = $( document.body );
7563		theHTML = theDocument.find( 'html' ).eq( 0 );
7564		htmlInner = theHTML.prop( 'innerHTML' );
7565		htmlAndBody = theHTML.add( theBody );
7566		headMenu = theBody.find( '#masthead' ).eq( 0 );
7567		nothing = theBody.find( '.listar-nothing' ).eq( 0 );
7568		dataMinimumClaimTextChars = theBody.find( '#listar_claim_sender_message' ).eq( 0 ).length ? parseInt( theBody.find( '#listar_claim_sender_message' ).eq( 0 ).attr( 'data-minimun-chars' ), 10 ) : 0;
7569		requiredClaimCharsField = theBody.find( '.listar-claim-required-chars' ).eq( 0 );
7570		multipleRegionsActive = theBody.hasClass( 'listar-multiple-regions-enabled' );
7571		urlProtocol = location.protocol.indexOf( 'https' ) >= 0 ? 'https' : 'http';
7572		siblingsOpacityEnabled = theBody.hasClass( 'listar-disable-sibling-hover-opacity' ) ? false : true;
7573		callToActionsBoxedSquared = theBody.find( '.entry-content .listar-2-cols-boxed-squared-design' );
7574		headerTransparentTopbar = theDocument.find( 'body.page-template-front-page.listar-frontpage-topbar-transparent' ).eq( 0 ).length > 0 ? true : false;
7575		listingGallery = theBody.find( '.listar-listing-gallery' ).eq( 0 );
7576		currentURL = window.location.href;
7577		isFrontPage = theDocument.find( 'body.page-template-front-page' ).eq( 0 ).length ? true : false;
7578		pageBGColor = theBody.find( '#content' ).eq( 0 );
7579		singleContent = theBody.find( '.listar-single-content > *' );
7580		singleheaderBackgroundWrapper = theBody.find( '.listar-post-content-header-background-wrapper' ).eq( 0 );
7581		listarFeaturifyElements = theBody.find( 'main article .listar-featurify' );
7582		frontPageCallToActionBadge = theBody.find( '.entry-content .listar-badge-mask' );
7583		animateElementsOnScroll = theBody.hasClass( 'listar_animate_elements_on_scroll' );
7584		pageBGColor = pageBGColor.length ? pageBGColor.css( 'background-color' ).replace( /\s/g, '' ) : 'rgb(255,255,255)';
7585		isClaimingListing = currentURL.indexOf( 'claim_listing=1' ) >= 0 && currentURL.indexOf( 'claim_listing_id' ) >= 0;
7586
7587		if ( isClaimingListing && currentURL.indexOf( 'claim_package_id' ) >= 0 ) {
7588			theBody.find( '#primary' ).eq( 0 ).css( { opacity : 0, left : '-10000px' } );
7589		}
7590	} );
7591	
7592	function listarExecute() {
7593		
7594		/* Set Google Fonts Media - Pagespeed */
7595		$( 'link[id="listar-google-fonts-into-footer-css"]' ).each( function () {
7596			//$( this ).attr( 'media', 'all' );
7597		} );
7598		
7599		/* Execute Main JavaScript ************************************/
7600
7601		hasGrid2 = 0;
7602		hasGrid3 = 0;
7603
7604		/* Prepare interface ******************************************/
7605
7606                if ( viewport().width >= parseInt( listarLocalizeAndAjax.minimumScreeWidthHeroVideo, 10 ) ) {
7607                        var mediaElements = document.querySelectorAll('.listar-hero-video video'), total = mediaElements.length;
7608
7609                        for (var i = 0; i < total; i++) {
7610                                new MediaElementPlayer(mediaElements[i], {
7611                                        shimScriptAccess: 'always',
7612                                        autoplay: true,
7613                                        hideVideoControlsOnLoad: true,
7614                                        hideVideoControlsOnPause : true,
7615                                        controlsTimeoutDefault: 1,
7616                                        controlsTimeoutMouseEnter: 1,
7617                                        controlsTimeoutMouseLeave: 1,
7618                                        features : ['playpause'],
7619                                        muted: true,
7620                                        success: function(mediaElement, domObject) {
7621                                                var target = document.body.querySelectorAll('.listar-hero-video .player'), targetTotal = target.length;
7622                                                var startTime = $( mediaElements[i] ).attr( 'data-start-time' );
7623                                                var endTime = parseInt( $( mediaElements[i] ).attr( 'data-end-time' ), 10 );
7624                                                var endTimeCaptureAttempties = 0;
7625                                                var source = $( mediaElements[i] ).find( 'source' ).attr( 'src' );
7626
7627                                                var notFile = -1 !== source.indexOf( 'youtube.' ) || -1 !== source.indexOf( 'vimeo.' );
7628                                                var displayDelay = notFile ? 50 : 50;
7629
7630
7631                                                for (var j = 0; j < targetTotal; j++) {
7632                                                        target[j].style.visibility = 'visible';
7633                                                }
7634
7635                                                mediaElement.setCurrentTime( startTime );
7636
7637                                                mediaElement.play();
7638
7639                                                mediaElement.addEventListener('loadedmetadata', function (e) {
7640                                                        if ( 0 === endTime ) {
7641                                                                endTime = parseInt( mediaElement.duration, 10 );
7642                                                        }
7643                                                }, true);
7644
7645                                                mediaElement.addEventListener('timeupdate', function (e) {
7646                                                        if ( 0 === endTime || 6000000 === endTime ) {
7647                                                                endTime = parseInt( mediaElement.duration, 10 );
7648
7649                                                                if ( isNaN( endTime ) ) {
7650                                                                        endTime = 0;
7651                                                                }
7652
7653                                                                if ( ( '' === endTime || 0 === endTime || 'undefined' === typeof endTime || startTime >= endTime ) ) {
7654                                                                        endTime = 6000000;
7655                                                                }
7656                                                        }
7657
7658                                                        if ( mediaElement.currentTime >= endTime - 1 ) {
7659                                                                mediaElement.setCurrentTime( startTime );
7660                                                                mediaElement.play();
7661                                                        }
7662                                                }, true);
7663
7664                                                mediaElement.addEventListener('ended', function (e) {
7665                                                        mediaElement.setCurrentTime( startTime );
7666                                                }, true);
7667
7668                                                mediaElement.addEventListener('playing', function (e) {
7669                                                        setTimeout( function () {
7670                                                                resizeHeroVideos();
7671
7672                                                                setTimeout( function () {
7673                                                                        $( '.listar-hero-video' ).addClass( 'listar-video-rendered' );
7674                                                                }, 50 );
7675                                                        }, displayDelay );
7676                                                }, true);
7677
7678
7679                                        }
7680                                });
7681                        }
7682                }
7683
7684		$( '.wp-editor-wrap' ).each( function () {
7685
7686			/* Reference: https://wordpress.stackexchange.com/a/120835 */
7687			setInterval( function () {
7688				if ( 'undefined' !== typeof tinyMCE && null !== tinyMCE ) {
7689					if ( 'undefined' !== typeof tinyMCE.activeEditor && null !== tinyMCE.activeEditor ) {
7690						if ( 'undefined' !== typeof tinyMCE.activeEditor.dom && null !== tinyMCE.activeEditor.dom ) {
7691							var tinyMCETemp = tinyMCE.activeEditor.dom;
7692
7693							if ( 'undefined' !== typeof tinyMCETemp ) {
7694								tinyMCETemp.addStyle('iframe {width:100%;}');
7695							}
7696						}
7697					}
7698				}
7699			}, 2000 );
7700		} );
7701
7702		/* User has the most recent version of Listar Addons, meaning it is compatible with current theme version? */
7703		if ( '' !== listarLocalizeAndAjax.listarAddonsVersion ) {
7704			if ( listarLocalizeAndAjax.listarThemeVersion !== listarLocalizeAndAjax.listarAddonsVersion ) {
7705				alert( listarLocalizeAndAjax.updateListarAddons );
7706			}
7707		}
7708
7709		/* Detect UC Browser and Safari */
7710
7711		if ( 'undefined' !== typeof navigator ) {
7712			if ( 'undefined' !== typeof navigator.userAgent && 'undefined' !== typeof navigator.platform ) {
7713
7714				/* See: https://stackoverflow.com/a/31732310/7765298 */
7715				var isSafari = navigator.vendor && navigator.vendor.indexOf( 'Apple' ) > -1 &&
7716					navigator.userAgent &&
7717					-1 === navigator.userAgent.indexOf( 'CriOS' ) &&
7718					-1 === navigator.userAgent.indexOf( 'FxiOS' );
7719
7720				if ( isSafari ) {
7721					theBody.addClass( 'listar-is-safari' );
7722				} else if ( navigator.userAgent.indexOf( 'UBrowser' ) >= 0 || navigator.userAgent.indexOf( 'UCBrowser' ) >= 0 ) {
7723					theBody.addClass( 'listar-is-uc-browser' );
7724				}
7725			}
7726		}
7727
7728		/* Transfer WordPress <li> menu classes for the menu <a> tag */
7729		$( 'li[class*="menu-item-type-"] a' ).each( function () {
7730			var menuItem = $( this ).parent();
7731
7732			if ( menuItem.attr( 'class' ).indexOf( 'fa fa-' ) >= 0 || menuItem.attr( 'class' ).indexOf( 'fal fa-' ) >= 0 || menuItem.attr( 'class' ).indexOf( 'icon-' ) >= 0 ) {
7733				$( this ).attr( 'class', menuItem.attr( 'class' ) );
7734				menuItem.attr( 'class', menuItem.attr( 'class' ).replace( /icon-/g, '' ).replace( /fa fa-/g, '' ).replace( /fal fa-/g, '' ) );
7735			}
7736		} );
7737
7738		/* Return only characters for princing fields - 0 until 9 and dot (.) */
7739		$( 'input[class*="price-range"]' ).each( function () {
7740			sanitizePricingFields( $( this ) );
7741		} );
7742
7743		/* Return only characters for princing fields - 0 until 9 and dot (.) */
7744		$( 'input[class*="price-range"]' ).each( function () {
7745			sanitizePricingFields( $( this ) );
7746		} );
7747
7748		/* Display/hide custom excerpt field */
7749		toggleCheckboxDependantField( '#job_business_use_custom_excerpt', '.fieldset-job_business_custom_excerpt' );
7750		
7751		// Create "More Itens" button for listing products.
7752		var onlineStoreButton = $( '.listar-listing-header-online-store' );
7753		
7754		if ( onlineStoreButton.length ) {
7755			$( '.listar-listing-products-more' ).each( function () {
7756				$( this ).removeClass( 'hidden' );
7757				
7758				$( this ).find( 'a' ).each( function () {
7759					$( this ).attr( 'href', onlineStoreButton.attr( 'href' ) );
7760				} );
7761			} );
7762		}
7763
7764		$( '.listar-user-packages .listar-listing-package' ).each( function () {
7765			$( this ).parents( '.listar-user-packages' ).removeClass( 'hidden' );
7766			$( this ).parents( '.listar-user-packages' ).prev( 'h2' ).removeClass( 'hidden' );
7767		} );
7768		
7769		// Expose duplicated packages, if yet available.
7770		$( '.listar-user-packages .listar-listing-package' ).each( function () {
7771			$( this ).parents( '.listar-user-packages' ).removeClass( 'hidden' );
7772			$( this ).parents( '.listar-user-packages' ).prev( 'h2' ).removeClass( 'hidden' );
7773		} );
7774
7775		/*
7776		 * If a listing package (plan) be selected via widget, skip the package selection on pricings page;
7777		 */
7778
7779		if ( window.location.hash ) {
7780			var packageHash = window.location.hash.replace( '#', '' );
7781
7782			if ( packageHash.indexOf( 'skip-package-selection' ) >= 0 ) {
7783				window.location.hash = '';
7784				packageHash = packageHash.replace( 'skip-package-selection-', '' );
7785
7786				if ( $( 'a[data-user-package="' + packageHash + '"]' ).length || $( 'a[data-package="' + packageHash + '"]' ).length ) {
7787					$( '.page-content' ).each( function () {
7788						$( this ).animate( { opacity : 0 } );
7789					} );
7790
7791					setTimeout( function () {
7792						if ( $( 'a[data-user-package="' + packageHash + '"]' ).length ) {
7793							$( 'a[data-user-package="' + packageHash + '"]' ).eq( 0 ).each( function () {
7794								$( this )[0].click();
7795							} );
7796						} else {
7797							$( 'a[data-package="' + packageHash + '"]' ).eq( 0 ).each( function () {
7798								$( this )[0].click();
7799							} );
7800						}
7801					}, 10 );
7802				}
7803			}
7804		}
7805
7806		/* Append ribbon design for product price on product page */
7807		$( '.single-product .summary.entry-summary .price, .listar-booking-popup .summary.entry-summary .price' ).each( function () {
7808			if ( 0 === $( this ).find( '*' ).length ) {
7809				$( this ).prop( 'innerHTML', '<span class="woocommerce-Price-amount amount listar-uppercase">' + $( this ).prop( 'innerHTML' ) + '</span>' );
7810			}			
7811			
7812			$( this ).find( '.woocommerce-Price-amount.amount' ).each( function () {
7813				if ( ! $( this ).parents( 'del' ).length ) {
7814					$( this ).addClass( 'listar-ribbon' );
7815				}
7816
7817				if ( 0 === $( this ).find( '*' ).length ) {
7818					$( this ).parents( '.price' ).prop( 'outerHTML', '' );
7819				}
7820			} );
7821		} );
7822		
7823		$( '.listar-booking-slide' ).eq( 0 ).removeClass( 'hidden' ).addClass( 'current' );
7824
7825		/*
7826		 * Move background image URL from 'data-background-image' attribute to 'background-image' style
7827		 * Only for currently visible elements
7828		 */
7829
7830		checkFrontPageTopbar();
7831
7832		/*xxxx*/
7833		
7834		
7835		
7836		
7837		
7838		
7839		
7840		
7841		
7842		
7843		
7844		
7845		
7846		
7847		
7848		
7849		
7850		
7851		
7852		
7853		
7854		
7855		
7856		
7857		
7858		
7859		
7860		
7861		
7862		
7863		
7864		
7865		
7866		
7867		
7868		
7869		
7870		
7871		
7872		
7873		
7874		
7875		
7876		
7877		
7878		
7879		
7880		
7881		
7882		
7883		
7884		
7885		
7886		
7887		
7888		
7889		
7890		
7891		
7892		
7893		
7894		
7895		
7896		
7897		
7898		
7899		
7900		
7901		
7902		
7903		
7904		
7905		
7906		
7907		
7908		
7909		
7910		
7911		
7912		
7913		
7914		
7915		
7916		
7917		
7918		
7919		
7920		
7921		
7922		
7923		
7924		
7925		
7926		
7927		
7928		
7929		
7930		
7931		
7932		
7933		
7934		
7935		
7936		
7937		
7938		
7939		
7940
7941		
7942		/*xxxx*/
7943		
7944		
7945		
7946		
7947		
7948		
7949		
7950		
7951		
7952		
7953
7954		
7955
7956		termNameBigEffect();
7957
7958		
7959		/*xxx*/
7960		
7961		
7962		
7963		
7964		
7965		
7966		
7967		
7968		
7969		
7970
7971		$( '.listar-hero-section-title' ).each( function () {
7972			if ( $( this ).parents( '.listar-hero-header' ).find( '.listar-category-icon-wrapper' ).length > 0 ) {
7973				$( this ).parents( '.listar-hero-header' ).addClass( 'listar-has-hero-title' );
7974			}
7975		} );
7976
7977		$( '.wc-item-meta li' ).each( function () {
7978			if ( $( this ).prop( 'innerHTML' ).indexOf( 'listar_' ) >= 0 ) {
7979				$( this ).css( { display : 'none' } );
7980			}
7981		} );
7982
7983		$( '.listar-temp-chosen-region' ).each( function () {
7984			$( '.listar-chosen-region' ).val( $( this ).val() ).attr( 'value', $( this ).val() );
7985		} );
7986
7987
7988
7989		if ( $( '.listar-search-filter-categories' ).length ) {
7990			var searchCategories = String( $( '.listar-search-filter-categories' ).val() );
7991			var searchCategoriesInput = String( $( '.listar-chosen-category' ).val() );
7992
7993			if ( 'null' !== searchCategories && 'null' === searchCategoriesInput || '' === searchCategoriesInput ) {
7994				$( '.listar-chosen-category' ).val( searchCategories );
7995			}
7996		}
7997
7998		$( '.listar-clean-search-input-button' ).each( function () {
7999			var clearSearchInputButton   = $( this );
8000			var clearSearchFiltersButton = clearSearchInputButton.parents( 'form' ).find( '.listar-clean-search-by-filters-button' );
8001			var searchInputField         = clearSearchInputButton.parents( 'form' ).find( '.listar-listing-search-input-field' );
8002			var searchByButton           = clearSearchInputButton.parents( 'form' ).find( '.listar-search-by-button' );
8003			var searchByOrder            = '';
8004			var exploreByType            = '';
8005
8006			setInterval( function () {
8007				searchByOrder = searchByButton.parents( 'form' ).find( '[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).attr( 'value' );
8008				exploreByType = searchByButton.parents( 'form' ).find( '[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).attr( 'value' );
8009
8010				if ( '' !== searchInputField.val() ) {
8011					clearSearchInputButton.css( { display : 'block' } );
8012				} else {
8013					clearSearchInputButton.css( { display : 'none' } );
8014				}
8015
8016				if ( exploreByType !== listarLocalizeAndAjax.listarInitialExploreByOption || searchByOrder !== listarLocalizeAndAjax.listarInitialForcedSearchOrder ) {
8017					clearSearchFiltersButton.css( { display : 'block' } );
8018				} else {
8019					clearSearchFiltersButton.css( { display : 'none' } );
8020				}
8021			}, 500 );
8022		} );
8023
8024		if ( listarLocalizeAndAjax.listarIsClaimingListing ) {
8025			if ( ! $( '.listar-listing-package' ).length && $( '#submit-job-form' ).length ) {
8026				$( '.listar-no-claim-packages' ).removeClass( 'hidden' );
8027				$( '.page-content' ).prop( 'innerHTML', '' );
8028			}
8029		}
8030
8031
8032		$( '.listar-search-by-button' ).each( function () {
8033			var newExploreBySlug = $( this ).attr( 'data-explore-by-type' );
8034
8035			if ( 'shop_products' === newExploreBySlug ) {
8036				$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
8037				$( '.listar-all-regions-button' ).css( { display : 'none' } );
8038			} else if ( 'blog' === newExploreBySlug ) {
8039				$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
8040				$( '.listar-all-regions-button' ).css( { display : 'none' } );
8041			} else {
8042				$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( 'listing' );
8043				$( '.listar-all-regions-button' ).css( { display : '' } );
8044			}
8045
8046			$( '.listar-search-by-options-wrapper a[data-explore-by-type="' + newExploreBySlug + '"]' ).each( function () {
8047				var placeholder = $( this ).attr( 'data-explore-by-placeholder' );
8048				$( '.listar-listing-search-input-field' ).attr( 'placeholder', placeholder );
8049			} );
8050		} );
8051
8052		// Limit the number of images for gallery upload.
8053		if ( $( '.fieldset-gallery_images .wp-job-manager-file-upload' ).length ) {
8054			setInterval( function () {
8055				galleryLengthVerification();
8056			}, 500 );
8057		}
8058
8059
8060		/*xxx */
8061		
8062		
8063		
8064		
8065		
8066		
8067		
8068		
8069		
8070		
8071
8072		/* Organize custom location fields fields */
8073		if ( 'string' === typeof listarLocalizeAndAjax.addressAdvanced ) {
8074			$( '.fieldset-job_location label' ).each( function () {
8075				$( this ).append( '<br><a href="#" class="listar-location-show-advanced">' + listarLocalizeAndAjax.addressAdvanced + '</a>' );
8076				$( this ).parent().after( '<div class="listar-custom-location-fields listar-boxed-fields-label-customizer hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner"></div></div></div>' );
8077
8078				var
8079					customLocationField1 = $( '.fieldset-job_customlatitude' );
8080
8081				var
8082					customLocationField2 = customLocationField1.next(),
8083					customLocationField3 = customLocationField2.next(),
8084					customLocationField4 = customLocationField3.next();
8085
8086				var
8087					customLocationOutput =
8088						customLocationField1.prop( 'outerHTML' ) +
8089						customLocationField2.prop( 'outerHTML' ) +
8090						customLocationField3.prop( 'outerHTML' ) +
8091						customLocationField4.prop( 'outerHTML' );
8092
8093				customLocationField1.prop( 'outerHTML', '' );
8094				customLocationField2.prop( 'outerHTML', '' );
8095				customLocationField3.prop( 'outerHTML', '' );
8096				customLocationField4.prop( 'outerHTML', '' );
8097
8098				$( '.listar-custom-location-fields .listar-boxed-fields-inner' ).append( customLocationOutput );
8099			} );
8100		}
8101
8102		/* Append Business Hours fields */
8103		$( '.fieldset-job_business_hours_monday' ).each( function () {
8104			var hoursForm  = '';
8105			var realOpenCloseValues = [];
8106			var realValuesFields = $( 'input[id*="job_business_hours_"]' );
8107
8108			realValuesFields.each( function () {
8109				var currentValue = $( this ).val();
8110				var multipleDayValues = [];
8111
8112				if ( currentValue.indexOf( '***' ) >= 0 ) {
8113					var multiple = currentValue.split( '***' );
8114
8115					for ( var mt = 0; mt < multiple.length; mt++ ) {
8116						var currentMultipleValue = multiple[ mt ];
8117
8118						if ( currentMultipleValue.indexOf( '-' ) >= 0 ) {
8119							var doubleM = currentMultipleValue.split( '-' );
8120							doubleM[0] = doubleM[0].trim();
8121							doubleM[1] = doubleM[1].trim();
8122
8123							multipleDayValues.push( [ doubleM[0], doubleM[1] ] );
8124						} else {
8125							multipleDayValues.push( [ '', '' ] );
8126						}
8127					}
8128				} else {
8129					if ( currentValue.indexOf( '-' ) >= 0 ) {
8130						var double = currentValue.split( '-' );
8131						double[0] = double[0].trim();
8132						double[1] = double[1].trim();
8133
8134						multipleDayValues.push( [ double[0], double[1] ] );
8135					} else {
8136						multipleDayValues.push( [ '', '' ] );
8137					}
8138				}
8139
8140				realOpenCloseValues.push( multipleDayValues );
8141			} );
8142
8143			var days = [
8144				[ 'Monday', listarLocalizeAndAjax.monday ],
8145				[ 'Tuesday', listarLocalizeAndAjax.tuesday ],
8146				[ 'Wednesday', listarLocalizeAndAjax.wednesday ],
8147				[ 'Thursday', listarLocalizeAndAjax.thursday ],
8148				[ 'Friday', listarLocalizeAndAjax.friday ],
8149				[ 'Saturday', listarLocalizeAndAjax.saturday ],
8150				[ 'Sunday', listarLocalizeAndAjax.sunday ]
8151			];
8152
8153			var hoursOpen = [
8154				[ 'Closed', listarLocalizeAndAjax.closed ],
8155				[ 'Open 24 Hours', listarLocalizeAndAjax.open ],
8156				[ '00:00 AM', '00:00 AM' ],
8157				[ '00:30 AM', '00:30 AM' ],
8158				[ '01:00 AM', '01:00 AM' ],
8159				[ '01:30 AM', '01:30 AM' ],
8160				[ '02:00 AM', '02:00 AM' ],
8161				[ '02:30 AM', '02:30 AM' ],
8162				[ '03:00 AM', '03:00 AM' ],
8163				[ '03:30 AM', '03:30 AM' ],
8164				[ '04:00 AM', '04:00 AM' ],
8165				[ '04:30 AM', '04:30 AM' ],
8166				[ '05:00 AM', '05:00 AM' ],
8167				[ '05:30 AM', '05:30 AM' ],
8168				[ '06:00 AM', '06:00 AM' ],
8169				[ '06:30 AM', '06:30 AM' ],
8170				[ '07:00 AM', '07:00 AM' ],
8171				[ '07:30 AM', '07:30 AM' ],
8172				[ '08:00 AM', '08:00 AM' ],
8173				[ '08:30 AM', '08:30 AM' ],
8174				[ '09:00 AM', '09:00 AM' ],
8175				[ '09:30 AM', '09:30 AM' ],
8176				[ '10:00 AM', '10:00 AM' ],
8177				[ '10:30 AM', '10:30 AM' ],
8178				[ '11:00 AM', '11:00 AM' ],
8179				[ '11:30 AM', '11:30 AM' ],
8180				[ '12:00 PM', '12:00 PM' ],
8181				[ '12:30 PM', '12:30 PM' ],
8182				[ '01:00 PM', '01:00 PM' ],
8183				[ '01:30 PM', '01:30 PM' ],
8184				[ '02:00 PM', '02:00 PM' ],
8185				[ '02:30 PM', '02:30 PM' ],
8186				[ '03:00 PM', '03:00 PM' ],
8187				[ '03:30 PM', '03:30 PM' ],
8188				[ '04:00 PM', '04:00 PM' ],
8189				[ '04:30 PM', '04:30 PM' ],
8190				[ '05:00 PM', '05:00 PM' ],
8191				[ '05:30 PM', '05:30 PM' ],
8192				[ '06:00 PM', '06:00 PM' ],
8193				[ '06:30 PM', '06:30 PM' ],
8194				[ '07:00 PM', '07:00 PM' ],
8195				[ '07:30 PM', '07:30 PM' ],
8196				[ '08:00 PM', '08:00 PM' ],
8197				[ '08:30 PM', '08:30 PM' ],
8198				[ '09:00 PM', '09:00 PM' ],
8199				[ '09:30 PM', '09:30 PM' ],
8200				[ '10:00 PM', '10:00 PM' ],
8201				[ '10:30 PM', '10:30 PM' ],
8202				[ '11:00 PM', '11:00 PM' ],
8203				[ '11:30 PM', '11:30 PM' ],
8204				[ '11:59 PM', '11:59 PM' ]
8205			];
8206
8207			var hoursClose = hoursOpen.slice();
8208
8209			hoursClose.shift();
8210			hoursClose.shift();
8211			$( this ).before( '<div class="listar-business-hours-fields hidden"></div>' );
8212
8213			hoursForm = $( '.listar-business-hours-fields' );
8214			hoursForm.append( '<fieldset class="fieldset-job_hours fieldset-type-business-hours"></fieldset>' );
8215			hoursForm.find( 'fieldset' ).append( '<div class="listar-hours-table-wrapper" style="display: block;"><table></table></div>' );
8216
8217			// Headings.
8218			hoursForm.find( 'table' ).append( '<thead></thead>' );
8219			hoursForm.find( 'table thead' ).append( '<th>' + listarLocalizeAndAjax.day + '</th>' );
8220			hoursForm.find( 'table thead' ).append( '<th>' + listarLocalizeAndAjax.opens + '</th>' );
8221			hoursForm.find( 'table thead' ).append( '<th>' + listarLocalizeAndAjax.close + '</th>' );
8222
8223			// Body.
8224			hoursForm.find( 'table' ).append( '<tbody></tbody>' );
8225
8226			// Inset customized values on the open/close hours (in case of third part listings import).
8227			for ( var day = 0; day < days.length; day++ ) {
8228				currentDay           = days[ day ][1];
8229				selectedOpenHour     = false;
8230				selectedCloseHour    = false;
8231
8232				for ( var mtph = 0; mtph < realOpenCloseValues[ day ].length; mtph++ ) {
8233					currentRealOpenHour  = realOpenCloseValues[ day ][ mtph ][0];
8234					currentRealCloseHour = realOpenCloseValues[ day ][ mtph ][1];
8235
8236					if ( '' !== currentRealOpenHour ) {
8237						var foundOpenHour = false;
8238						selectedOpenHour = currentRealOpenHour;
8239
8240						for ( var hourx = 0; hourx < hoursOpen.length; hourx++ ) {
8241							if ( hoursOpen[ hourx ].indexOf( selectedOpenHour ) >= 0 ) {
8242								foundOpenHour = true;
8243							}
8244						}
8245
8246						if ( ! foundOpenHour ) {
8247							hoursOpen.splice( 2, 0, [ selectedOpenHour, selectedOpenHour ] );
8248						}
8249					}
8250
8251					if ( '' !== currentRealCloseHour ) {
8252						var foundCloseHour = false;
8253						selectedCloseHour = currentRealCloseHour;
8254
8255						for ( var hourY = 0; hourY < hoursClose.length; hourY++ ) {
8256							if ( hoursClose[ hourY ].indexOf( selectedCloseHour ) >= 0 ) {
8257								foundCloseHour = true;
8258							}
8259						}
8260
8261						if ( ! foundCloseHour ) {
8262							hoursClose.splice( 2, 0, [ selectedCloseHour, selectedCloseHour ] );
8263						}
8264					}
8265				}
8266			}
8267
8268			for ( var dayX = 0; dayX < days.length; dayX++ ) {
8269				currentDay           = days[ dayX ][1];
8270				currentDayLetter     = days[ dayX ][1].substring(0,1).toUpperCase() ;
8271				currentDayAbbr       = days[ dayX ][0].substring(0,3).toLowerCase() ;
8272				selectedOpenHour     = false;
8273				selectedCloseHour    = false;
8274				selectedOpenAttr     = '';
8275				selectedCloseAttr    = '';
8276				hourOpenPlaceholder  = hoursFormatReplace( '09:00 AM' );
8277				hourClosePlaceholder = hoursFormatReplace( '05:00 PM' );
8278				hasMultiPleHoursPerDay = realOpenCloseValues[ dayX ].length > 1 ? true : false;
8279
8280				if ( 1 === parseInt( listarLocalizeAndAjax.disableAMPM, 10 ) && '24' === listarLocalizeAndAjax.operatingHoursFormat ) {
8281					hourOpenPlaceholder = hourOpenPlaceholder.replace( ' AM', '' );
8282				}
8283
8284				if ( 1 === parseInt( listarLocalizeAndAjax.disableAMPM, 10 ) && '24' === listarLocalizeAndAjax.operatingHoursFormat ) {
8285					hourClosePlaceholder = hourClosePlaceholder.replace( ' PM', '' );
8286				}
8287
8288				hoursForm.find( 'tbody' ).append( '<tr class="listar-business-hours-row-' + currentDayAbbr + '"></tr>' );
8289
8290				if ( hasMultiPleHoursPerDay ) {
8291					hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr ).addClass( 'listar-has-multiple-hours' );
8292				}
8293
8294				// Day name.
8295				hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr ).append( '<td class="listar-business-day"><span class="listar-business-day-letter">' + currentDayLetter + '</span><span class="listar-business-day-name">' + currentDay + '</span></td>' );
8296
8297				// Day open hours row.
8298				hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr ).append( '<td class="listar-business-start-time-field"><div class="listar-multiple-hours-buttons"><a href="#" class="listar-multiple-hours-minus fa fa-minus" data-toggle="tooltip" data-placement="top" title="' + listarLocalizeAndAjax.multipleHoursMinus + '"></a><a href="#" class="listar-multiple-hours-plus fa fa-plus" data-toggle="tooltip" data-placement="top" title="' + listarLocalizeAndAjax.multipleHoursPlus + '"></a></div><a href="#" class="listar-copy-day-button listar-copy-to-all" data-toggle="tooltip" data-placement="top" title="' + listarLocalizeAndAjax.copyForAll + '"></a></td>' );
8299
8300				// Day close hours row.
8301				hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr ).append( '<td class="listar-business-end-time-field"></td>' );
8302
8303				// Start processing multiple hours per day from here - Open Hours.
8304
8305				for ( var mtph3 = 0; mtph3 < realOpenCloseValues[ dayX ].length; mtph3++ ) {
8306					var openHourAttr = '';
8307					var closeHourAttr = '';
8308
8309					currentRealOpenHour  = realOpenCloseValues[ dayX ][ mtph3 ][0];
8310					currentRealCloseHour = realOpenCloseValues[ dayX ][ mtph3 ][1];
8311
8312					if ( '' !== currentRealOpenHour ) {
8313						selectedOpenHour = currentRealOpenHour;
8314					}
8315
8316					if ( '' !== currentRealCloseHour ) {
8317						selectedCloseHour = currentRealCloseHour;
8318					}
8319
8320					if ( false !== selectedOpenHour && '' !== selectedOpenHour && undefined !== selectedOpenHour ) {
8321						openHourAttr = selectedOpenHour;
8322					}
8323
8324					if ( false !== selectedCloseHour && '' !== selectedCloseHour && undefined !== selectedCloseHour ) {
8325						closeHourAttr = selectedCloseHour;
8326					}
8327
8328					// Day open hours - The select.
8329					hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr + ' .listar-business-start-time-field' ).append( '<span class="listar-business-hour"><select name="job_hours[' + currentDayAbbr + '][' + mtph3 + '][open]" data-multiple-order="' + mtph3 + '" value="' + openHourAttr + '" placeholder="' + hourOpenPlaceholder + '"></span>' );
8330
8331					// Day close hours - The select.
8332					hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr + ' .listar-business-end-time-field' ).append( '<span class="listar-business-hour"><select name="job_hours[' + currentDayAbbr + '][' + mtph3 + '][close]" data-multiple-order="' + mtph3 + '" value="' + closeHourAttr + '" placeholder="' + hourClosePlaceholder + '"></span>' );
8333
8334					for ( var hour = 0; hour < hoursOpen.length; hour++ ) {
8335						currentHour = hoursOpen[ hour ];
8336						hourFormatFront = hoursFormatReplace( currentHour[1] );
8337
8338						if ( false === selectedOpenHour ) {
8339							selectedOpenHour = hoursFormatReplace( '09:00 AM' );
8340						}
8341
8342						if ( currentHour[0] === selectedOpenHour || currentHour[1] === selectedOpenHour ) {
8343							selectedOpenAttr = ' selected="selected"';
8344						} else {
8345							selectedOpenAttr = '';
8346						}
8347
8348						hourFormatFront = hourFormatFront.replace( '11:59 PM', '00:00 AM' );
8349						hourFormatFront = hourFormatFront.replace( '11:59', '00:00' );
8350
8351						if ( 1 === parseInt( listarLocalizeAndAjax.disableAMPM, 10 ) && '24' === listarLocalizeAndAjax.operatingHoursFormat ) {
8352							hourFormatFront = hourFormatFront.replace( ' AM', '' );
8353							hourFormatFront = hourFormatFront.replace( ' PM', '' );
8354						}
8355
8356						hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr + ' .listar-business-start-time-field select[data-multiple-order="' + mtph3 + '"]' ).append( '<option value="' + currentHour[1] + '" ' + selectedOpenAttr + '>' + hourFormatFront + '</option>' );
8357					}
8358
8359					for ( var hour2 = 0; hour2 < hoursClose.length; hour2++ ) {
8360						currentHour = hoursClose[ hour2 ];
8361						hourFormatFront = hoursFormatReplace( currentHour[1] );
8362
8363						if ( false === selectedCloseHour ) {
8364							selectedCloseHour = hoursFormatReplace( '05:00 PM' );
8365						}
8366
8367						if ( currentHour[0] === selectedCloseHour || currentHour[1] === selectedCloseHour ) {
8368							selectedCloseAttr = ' selected="selected"';
8369						} else {
8370							selectedCloseAttr = '';
8371						}
8372
8373						hourFormatFront = hourFormatFront.replace( '11:59 PM', '00:00 AM' );
8374						hourFormatFront = hourFormatFront.replace( '11:59', '00:00' );
8375
8376						if ( 1 === parseInt( listarLocalizeAndAjax.disableAMPM, 10 ) && '24' === listarLocalizeAndAjax.operatingHoursFormat ) {
8377							hourFormatFront = hourFormatFront.replace( ' AM', '' );
8378							hourFormatFront = hourFormatFront.replace( ' PM', '' );
8379						}
8380
8381						hoursForm.find( '.listar-business-hours-row-' + currentDayAbbr + ' .listar-business-end-time-field select[data-multiple-order="' + mtph3 + '"]' ).append( '<option value="' + currentHour[1] + '" ' + selectedCloseAttr + '>' + hourFormatFront + '</option>' );
8382					}
8383				}
8384
8385				// Stop processing multiple hours per day from here - Close Hours.
8386			}
8387
8388			setTimeout( function () {
8389				if ( $( '#job_business_use_hours' ).is( ':checked' ) ) {
8390					$( '.listar-business-hours-fields' ).removeClass( 'hidden' );
8391				}
8392			}, 300 );
8393
8394			setTimeout( function () {
8395				$( '.listar-hours-table-wrapper select[name*=job_hours]' ).each( function () {
8396					var theSelect = $( this );
8397					checkOpenHourSelected( theSelect );
8398				} );
8399			}, 500 );
8400		} );
8401
8402		/*xxx */ 
8403		
8404		
8405		
8406		
8407		
8408		
8409
8410		/* Prepare wrapper for social network fields */
8411		$( '.fieldset-company_facebook' ).each( function () {
8412			var socialNetwork1 = $( this );
8413
8414			setTimeout( function () {
8415				socialNetwork1.before( '<div class="listar-business-social-network-fields hidden"><div class="listar-boxed-fields-wrapper"></div></div>' );
8416
8417				var
8418					socialNetwork2  = socialNetwork1.next(),
8419					socialNetwork3  = socialNetwork2.next(),
8420					socialNetwork4  = socialNetwork3.next(),
8421					socialNetwork5  = socialNetwork4.next(),
8422					socialNetwork6  = socialNetwork5.next(),
8423					socialNetwork7  = socialNetwork6.next(),
8424					socialNetwork8  = socialNetwork7.next(),
8425					socialNetwork9  = socialNetwork8.next(),
8426					socialNetwork10 = socialNetwork9.next(),
8427					socialNetwork11 = socialNetwork10.next();
8428
8429				var
8430					socialOutput =
8431						socialNetwork1.prop( 'outerHTML' ) +
8432						socialNetwork2.prop( 'outerHTML' ) +
8433						socialNetwork3.prop( 'outerHTML' ) +
8434						socialNetwork4.prop( 'outerHTML' ) +
8435						socialNetwork5.prop( 'outerHTML' ) +
8436						socialNetwork6.prop( 'outerHTML' ) +
8437						socialNetwork7.prop( 'outerHTML' ) +
8438						socialNetwork8.prop( 'outerHTML' ) +
8439						socialNetwork9.prop( 'outerHTML' ) +
8440						socialNetwork10.prop( 'outerHTML' ) +
8441						socialNetwork11.prop( 'outerHTML' );
8442
8443				socialNetwork1.prop( 'outerHTML', '' );
8444				socialNetwork2.prop( 'outerHTML', '' );
8445				socialNetwork3.prop( 'outerHTML', '' );
8446				socialNetwork4.prop( 'outerHTML', '' );
8447				socialNetwork5.prop( 'outerHTML', '' );
8448				socialNetwork6.prop( 'outerHTML', '' );
8449				socialNetwork7.prop( 'outerHTML', '' );
8450				socialNetwork8.prop( 'outerHTML', '' );
8451				socialNetwork9.prop( 'outerHTML', '' );
8452				socialNetwork10.prop( 'outerHTML', '' );
8453				socialNetwork11.prop( 'outerHTML', '' );
8454
8455				$( '.listar-business-social-network-fields .listar-boxed-fields-wrapper' ).prop( 'innerHTML', socialOutput );
8456
8457				setTimeout( function () {
8458					if ( $( '#company_use_social_networks' ).is( ':checked' ) ) {
8459						$( '.listar-business-social-network-fields' ).removeClass( 'hidden' );
8460					}
8461				}, 300 );
8462			}, 20 );
8463		} );
8464
8465		/* Prepare wrapper for external links fields */
8466		$( '.fieldset-company_external_link_1' ).each( function () {
8467			var externalLink1  = $( this );
8468
8469			setTimeout( function () {
8470				externalLink1.before( '<div class="listar-business-external-link-fields hidden"><div class="listar-boxed-fields-wrapper"></div></div>' );
8471
8472				var
8473					externalLink2  = externalLink1.next(),
8474					externalLink3  = externalLink2.next(),
8475					externalLink4  = externalLink3.next(),
8476					externalLink5  = externalLink4.next(),
8477					externalLink6  = externalLink5.next(),
8478					externalLink7  = externalLink6.next(),
8479					externalLink8  = externalLink7.next(),
8480					externalLink9  = externalLink8.next(),
8481					externalLink10 = externalLink9.next(),
8482					externalLink11 = externalLink10.next(),
8483					externalLink12 = externalLink11.next();
8484
8485				var
8486					externalLinksOutput =
8487						externalLink1.prop( 'outerHTML' ) +
8488						externalLink2.prop( 'outerHTML' ) +
8489						externalLink3.prop( 'outerHTML' ) +
8490						externalLink4.prop( 'outerHTML' ) +
8491						externalLink5.prop( 'outerHTML' ) +
8492						externalLink6.prop( 'outerHTML' ) +
8493						externalLink7.prop( 'outerHTML' ) +
8494						externalLink8.prop( 'outerHTML' ) +
8495						externalLink9.prop( 'outerHTML' ) +
8496						externalLink10.prop( 'outerHTML' ) +
8497						externalLink11.prop( 'outerHTML' ) +
8498						externalLink12.prop( 'outerHTML' );
8499
8500				externalLink1.prop( 'outerHTML', '' );
8501				externalLink2.prop( 'outerHTML', '' );
8502				externalLink3.prop( 'outerHTML', '' );
8503				externalLink4.prop( 'outerHTML', '' );
8504				externalLink5.prop( 'outerHTML', '' );
8505				externalLink6.prop( 'outerHTML', '' );
8506				externalLink7.prop( 'outerHTML', '' );
8507				externalLink8.prop( 'outerHTML', '' );
8508				externalLink9.prop( 'outerHTML', '' );
8509				externalLink10.prop( 'outerHTML', '' );
8510				externalLink11.prop( 'outerHTML', '' );
8511				externalLink12.prop( 'outerHTML', '' );
8512
8513				$( '.listar-business-external-link-fields .listar-boxed-fields-wrapper' ).prop( 'innerHTML', externalLinksOutput );
8514
8515				setTimeout( function () {
8516					if ( $( '#company_use_external_links' ).is( ':checked' ) ) {
8517						$( '.listar-business-external-link-fields' ).removeClass( 'hidden' );
8518					}
8519				}, 300 );
8520			}, 20 );
8521		} );
8522		
8523		
8524		
8525		
8526		
8527		
8528		
8529
8530		/* Prepare wrapper for rich media label customizer */
8531		$( '.fieldset-company_business_rich_media_label' ).each( function () {
8532			var labelSelector = $( this );
8533
8534			setTimeout( function () {
8535				var customLabelField = $( '.fieldset-company_business_rich_media_custom_label' );
8536				var appendGalleryField = $( '.fieldset-company_business_rich_media_append_gallery' );
8537
8538				var
8539					selectorOutput = labelSelector.prop( 'outerHTML' ),
8540					customLabelFieldContent = customLabelField.prop( 'outerHTML' ),
8541					appendGalleryContent = appendGalleryField.prop( 'outerHTML' );
8542
8543				labelSelector.before( '<div class="listar-business-rich-media-fields listar-boxed-fields-label-customizer hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div><div class="listar-boxed-fields-inner-2"></div></div></div>' );
8544
8545				labelSelector.prop( 'outerHTML', '' );
8546
8547				$( '.listar-business-rich-media-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).prepend( selectorOutput );
8548
8549				customLabelField.prop( 'outerHTML', '' );
8550				appendGalleryField.prop( 'outerHTML', '' );
8551
8552				setTimeout( function () {
8553					labelSelector = $( '.fieldset-company_business_rich_media_label' );
8554
8555					$( '.listar-business-rich-media-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-inner' ).append( customLabelFieldContent );
8556
8557					if ( 'custom' === labelSelector.find( 'select' ).val() ) {
8558						labelSelector.siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
8559					} else {
8560						labelSelector.siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
8561					}
8562					
8563					// Append listing gallery to the end.
8564
8565					$( '.listar-business-rich-media-fields .listar-boxed-fields-inner-2' ).append( appendGalleryContent );
8566					
8567					// Create fieldset dynamic fieldset inputs.
8568					
8569					var nFields = 0;
8570					var forceShowFields = false;
8571					
8572					var fieldsJSON = $( '#company_business_rich_media_values' ).val();
8573					
8574					if ( 'string' === typeof fieldsJSON ) {
8575						if ( fieldsJSON.indexOf( '[' ) >= 0 && fieldsJSON.indexOf( ']' ) >= 0 ) {
8576							var fieldsArray = JSON.parse( fieldsJSON );
8577
8578							fieldsArray.forEach(function( entry ) {
8579								if ( 'string' === typeof entry.code && '' !== entry.code ) {
8580									nFields += 1;
8581									richMediaFieldsetAppend( decodeURI( entry.code ) );
8582								}
8583							} );
8584						}
8585					}
8586					
8587					if ( 0 === nFields ) {
8588
8589						// Try the deprecated Youtube Video field
8590						$( '#company_video' ).each( function () {
8591							var value = $( this ).val();
8592							
8593							if ( 'string' === typeof value ) {
8594								if ( value.indexOf( 'youtu' ) >= 0 ) {
8595									nFields = 1;
8596									forceShowFields = true;
8597									richMediaFieldsetAppend( value );
8598									$( this ).val( '' );
8599								}
8600							}
8601						} );
8602					}
8603					
8604					if ( 0 === nFields ) {
8605						richMediaFieldsetAppend();
8606					}
8607					
8608					// Add Media buttom.
8609					$( '.listar-business-rich-media-fields .listar-boxed-fields-inner-2' ).after( '<div><a href="#" class="listar-rich-media-add-item fa fa-plus">' + listarLocalizeAndAjax.media + '</a></div>' );
8610					
8611					// Show media fields if Rich Media is active.
8612					
8613					if ( $( '#company_use_rich_media' ).is( ':checked' ) || forceShowFields ) {
8614						$( '#company_use_rich_media' ).prop( 'checked', true );
8615						$( '.listar-business-rich-media-fields' ).removeClass( 'hidden' );
8616					} else {
8617						$( '.listar-business-rich-media-fields' ).addClass( 'hidden' );
8618					}
8619					
8620					mediaLengthVerification();
8621					
8622				}, 100 );
8623			}, 20 );
8624		} );
8625
8626		/* Prepare wrapper for Products label customizer */
8627		$( '.fieldset-job_business_products_label' ).each( function () {
8628			var labelSelector = $( this );
8629
8630			setTimeout( function () {
8631				var customLabelField = $( '.fieldset-job_business_products_custom_label' );
8632				var productListField = $( '.fieldset-job_business_products_list' );
8633
8634				var
8635					selectorOutput = labelSelector.prop( 'outerHTML' ),
8636					customLabelFieldContent = customLabelField.prop( 'outerHTML' ),
8637					productListFieldContent = productListField.prop( 'outerHTML' );
8638
8639				labelSelector.before( '<div class="listar-business-products-fields listar-boxed-fields-label-customizer hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
8640
8641				labelSelector.prop( 'outerHTML', '' );
8642
8643				$( '.listar-business-products-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).prepend( selectorOutput );
8644
8645				customLabelField.prop( 'outerHTML', '' );
8646				productListField.prop( 'outerHTML', '' );
8647
8648				setTimeout( function () {
8649					labelSelector = $( '.fieldset-job_business_products_label' );
8650
8651					$( '.listar-business-products-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-inner' ).append( customLabelFieldContent );
8652					$( '.listar-business-products-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).append( productListFieldContent );
8653					
8654					if ( $( '#job_business_use_products' ).is( ':checked' ) ) {
8655						$( '.listar-business-products-fields.listar-boxed-fields-label-customizer' ).removeClass( 'hidden' );
8656					}
8657
8658					if ( 'custom' === labelSelector.find( 'select' ).val() ) {
8659						labelSelector.siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
8660					} else {
8661						labelSelector.siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
8662					}
8663				}, 100 );
8664			}, 20 );
8665		} );
8666
8667		/* Prepare wrapper for menu/catalog label customizer */
8668		$( '.fieldset-job_business_catalog_label' ).each( function () {
8669			var labelSelector = $( this );
8670
8671			setTimeout( function () {
8672				var customLabelField = $( '.fieldset-job_business_catalog_custom_label' );
8673
8674				var
8675					selectorOutput = labelSelector.prop( 'outerHTML' ),
8676					customLabelFieldContent = customLabelField.prop( 'outerHTML' );
8677
8678				labelSelector.before( '<div class="listar-business-catalog-fields listar-boxed-fields-label-customizer hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
8679
8680				labelSelector.prop( 'outerHTML', '' );
8681
8682				$( '.listar-business-catalog-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).prepend( selectorOutput );
8683
8684				customLabelField.prop( 'outerHTML', '' );
8685
8686				setTimeout( function () {
8687					labelSelector = $( '.fieldset-job_business_catalog_label' );
8688
8689					$( '.listar-business-catalog-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-inner' ).append( customLabelFieldContent );
8690
8691					if ( $( '#job_business_use_catalog' ).is( ':checked' ) ) {
8692						$( '.listar-business-catalog-fields.listar-boxed-fields-price-list' ).removeClass( 'hidden' );
8693						$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload' ).removeClass( 'hidden' );
8694						$( '.listar-business-catalog-fields.listar-boxed-fields-label-customizer' ).removeClass( 'hidden' );
8695					}
8696
8697					if ( $( '#job_business_use_catalog_documents' ).is( ':checked' ) ) {
8698						$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-inner' ).removeClass( 'hidden' );
8699					}
8700
8701					if ( $( '#job_business_use_price_list' ).is( ':checked' ) ) {
8702						$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).removeClass( 'hidden' );
8703					}
8704
8705					if ( 'custom' === labelSelector.find( 'select' ).val() ) {
8706						labelSelector.siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
8707					} else {
8708						labelSelector.siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
8709					}
8710				}, 100 );
8711			}, 20 );
8712		} );
8713
8714		/* Prepare wrapper for Appointments label customizer */
8715		$( '.fieldset-job_business_booking_label' ).each( function () {
8716			var labelSelector = $( this );
8717
8718			setTimeout( function () {
8719				var customLabelField = $( '.fieldset-job_business_booking_custom_label' );
8720				var methodField      = $( '.fieldset-job_business_booking_method' );
8721				var embeddingField   = $( '.fieldset-job_business_bookings_third_party_service' );
8722				var selectedMethod   = $( '.fieldset-job_business_booking_method option[selected]' );
8723				var descriptionMethodHTML = '<fieldset class="fieldset-job_business_bookings_products_description fieldset-type-textarea"><label for="job_business_bookings_products_description">' + listarLocalizeAndAjax.hasBookingProducts + '</small></label><div class="field ">' + listarLocalizeAndAjax.hasBookingProductsDescr + '</div></fieldset>';
8724
8725				selectedMethod = selectedMethod.length ? selectedMethod.attr( 'value' ) : '';
8726
8727				var
8728					selectorOutput = labelSelector.prop( 'outerHTML' ),
8729					customLabelFieldContent = customLabelField.prop( 'outerHTML' ),
8730					methodFieldContent = methodField.prop( 'outerHTML' ),
8731					embedingFieldContent = embeddingField.prop( 'outerHTML' );
8732
8733				labelSelector.before( '<div class="listar-business-booking-fields listar-boxed-fields-label-customizer hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
8734
8735				labelSelector.prop( 'outerHTML', '' );
8736
8737				$( '.listar-business-booking-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).prepend( selectorOutput );
8738
8739				customLabelField.prop( 'outerHTML', '' );
8740				embeddingField.prop( 'outerHTML', '' );
8741				methodField.prop( 'outerHTML', '' );
8742
8743				setTimeout( function () {
8744					labelSelector = $( '.fieldset-job_business_booking_label' );
8745
8746					$( '.listar-business-booking-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-inner' ).append( customLabelFieldContent );
8747
8748					$( '.listar-business-booking-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).append( methodFieldContent );
8749					
8750					if ( listarLocalizeAndAjax.wooBookingsActive ) {
8751						$( '.listar-business-booking-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).append( descriptionMethodHTML );
8752					}					
8753					
8754					$( '.listar-business-booking-fields.listar-boxed-fields-label-customizer .listar-boxed-fields-wrapper' ).append( embedingFieldContent );
8755
8756					if ( $( '#job_business_use_booking' ).is( ':checked' ) ) {
8757						$( '.listar-business-booking-fields' ).removeClass( 'hidden' );
8758					}
8759
8760					$( '.fieldset-job_business_bookings_third_party_service, .fieldset-job_business_bookings_products_description' ).addClass( 'hidden' );
8761
8762					if ( 'external' === selectedMethod ) {
8763						$( '.fieldset-job_business_bookings_third_party_service' ).removeClass( 'hidden' );
8764					} else if ( 'booking' === selectedMethod ) {
8765						$( '.fieldset-job_business_bookings_products_description' ).removeClass( 'hidden' );
8766					}
8767
8768					if ( 'custom' === labelSelector.find( 'select' ).val() ) {
8769						labelSelector.siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
8770					} else {
8771						labelSelector.siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
8772					}
8773				}, 100 );
8774			}, 20 );
8775		} );
8776
8777		$( theBody ).on( 'click', '.listar-price-list-add-category', function ( e ) {
8778			e.preventDefault();
8779			e.stopPropagation();
8780
8781			createPriceListCategory();
8782		} );
8783
8784		$( theBody ).on( 'click', '.listar-price-list-add-item', function ( e ) {
8785			e.preventDefault();
8786			e.stopPropagation();
8787
8788			var selectedCategory;
8789
8790			$( '.listar-price-builder-category[id*="price-category-"][data-selected="selected"]' ).each( function () {
8791				selectedCategory = $( this ).attr( 'id' );
8792			} );
8793
8794			createPriceListItem( undefined, selectedCategory );
8795		} );
8796
8797		$( theBody ).on( 'click', '.listar-price-builder-category-val', function ( e ) {
8798			e.preventDefault();
8799			e.stopPropagation();
8800
8801			var categoryID = $( this ).parent().attr( 'id' );
8802
8803			highlightPriceListCategory( categoryID );
8804
8805			priceListCategoryItemsVisibility( categoryID );
8806		} );
8807
8808                $( theBody ).on( 'change', '.listar-price-item-label-val', function ( e ) {
8809                        var elem = $( this );
8810
8811                        setTimeout( function () {
8812                                var currentVal = elem.val();
8813
8814                                elem.find( 'option' ).each( function () {
8815                                        if ( currentVal === $( this ).attr( 'value' ) ) {
8816                                                $( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
8817                                        } else {
8818                                                $( this ).removeAttr( 'selected' ).prop( 'selected', false );
8819                                        }
8820                                } );
8821
8822                        }, 20 );
8823                } );
8824
8825                $( theBody ).on( 'click', '.listar-price-list-item-control-top', function ( e ) {
8826                        e.preventDefault();
8827                        e.stopPropagation();
8828
8829                        var currentAction = $( this );
8830                        var currentElement = currentAction.parents( '.listar-price-item' );
8831
8832                        currentElement.prevAll( '.listar-price-item[data-visibility="true"]' ).first().each( function () {
8833
8834                                var outerItem = currentElement.clone();
8835
8836                                $( this ).before( outerItem );
8837                                currentElement.prop( 'outerHTML', '' );
8838                        } );
8839                } );
8840
8841		$( theBody ).on( 'click', '.listar-price-list-item-control-bottom', function ( e ) {
8842			e.preventDefault();
8843			e.stopPropagation();
8844
8845			var currentAction = $( this );
8846			var currentElement = currentAction.parents( '.listar-price-item' );
8847
8848			currentElement.nextAll( '.listar-price-item[data-visibility="true"]' ).first().each( function () {
8849				var outerItem = currentElement.clone();
8850
8851				$( this ).after( outerItem );
8852				currentElement.prop( 'outerHTML', '' );
8853			} );
8854		} );
8855
8856		$( theBody ).on( 'click', '.listar-price-list-item-control-delete', function ( e ) {
8857			e.preventDefault();
8858			e.stopPropagation();
8859
8860			var confirmExclusion = confirm( listarLocalizeAndAjax.excludeItem );
8861
8862			if ( confirmExclusion ) {
8863				$( this ).parents( '.listar-price-item' ).prop( 'outerHTML', '' );
8864			}
8865		} );
8866
8867		$( theBody ).on( 'change paste keyup', '.listar-price-item-price-val', function ( e ) {
8868			sanitizePricingFields( $( this ) );
8869		} );
8870
8871		$( theBody ).on( 'click', '.listar-price-list-category-delete', function ( e ) {
8872			e.preventDefault();
8873			e.stopPropagation();
8874
8875			var confirmExclusion = confirm( listarLocalizeAndAjax.excludeCategory );
8876
8877			if ( confirmExclusion ) {
8878				var priceCategoryID = $( this ).parents( '.listar-price-builder-category' ).attr( 'id' );
8879				var siblingCatNext = $( this ).parents( '.listar-price-builder-category' ).next( '.listar-price-builder-category' );
8880				var siblingCat = siblingCatNext.length ? siblingCatNext : $( this ).parents( '.listar-price-builder-category' ).prev( '.listar-price-builder-category' );
8881				var confirmExclusion2 = $( '.listar-price-item[data-category="' + priceCategoryID + '"]' ).length ? confirm( listarLocalizeAndAjax.excludeItems ) : false;
8882
8883				$( this ).parents( '.listar-price-builder-category' ).prop( 'outerHTML', '' );
8884
8885				if ( confirmExclusion2 ) {
8886					$( '.listar-price-item[data-category="' + priceCategoryID + '"]' ).each( function () {
8887						$( this ).prop( 'outerHTML', '' );
8888					} );
8889				}
8890
8891				if ( siblingCat.length ) {
8892
8893					// If not deleted, move items from the deleted category to the sibling category found.
8894
8895					$( '.listar-price-item[data-category="' + priceCategoryID + '"]' ).each( function () {
8896						$( this ).attr( 'data-category', siblingCat.attr( 'id' ) );
8897					} );
8898
8899					siblingCat.find( 'input' )[0].click();
8900				} else {
8901
8902					// No categories remaining.
8903
8904					$( '.listar-price-item' ).each( function () {
8905						$( this ).attr( 'data-category', '' );
8906					} );
8907
8908					priceListCategoryItemsVisibility();
8909				}
8910			}
8911		} );
8912
8913		/* Prepare wrapper for menu/catalog price list */
8914		$( '.fieldset-job_business_use_price_list' ).each( function () {
8915			var
8916				priceListEnablerFieldset = $( this ),
8917				priceListFieldset = $( '.fieldset-job_business_price_list_content' );
8918
8919			var
8920				priceListOutput = priceListEnablerFieldset.prop( 'outerHTML' ),
8921				priceListFieldsetContent = priceListFieldset.prop( 'outerHTML' );
8922
8923			priceListEnablerFieldset.before( '<div class="listar-business-catalog-fields listar-boxed-fields-price-list hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
8924
8925			priceListEnablerFieldset.prop( 'outerHTML', '' );
8926
8927			$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-wrapper' ).prepend( priceListOutput );
8928
8929			$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).before( '<div class="listar-catalog-files-header"></div>' );
8930				$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-catalog-files-header' ).append( $( '#job_business_price_list_content' ).siblings( 'small' ).prop( 'outerHTML' ) );
8931
8932			priceListFieldset.prop( 'outerHTML', '' );
8933
8934			// Construct the price list builder.
8935
8936			setTimeout( function () {
8937				$( '.fieldset-job_business_price_list_content' ).each( function () {
8938					$( this ).before( '<div class="listar-price-list-builder"></div>' );
8939
8940					var priceBuilder = $( '.listar-price-list-builder' );
8941
8942					priceBuilder.append( '<div class="listar-price-builder-categories"><div class="listar-price-builder-categories-wrapper"><a href="#" class="listar-price-list-add-category fa fa-plus">' + listarLocalizeAndAjax.category + '</a></div></div>' );
8943					priceBuilder.append( '<div class="listar-price-builder-items"><div class="listar-price-builder-items-wrapper"></div><a href="#" class="listar-price-list-add-item fa fa-plus">' + listarLocalizeAndAjax.item + '</a></div>' );
8944
8945					// Read the data saved.
8946					var savedJSON = $( '#job_business_price_list_content' ).val();
8947					var parsedData = tryParseJSON( savedJSON );
8948
8949					if ( false !== parsedData ) {
8950
8951						$.each( parsedData, function() {
8952
8953							//JSONValues += '{"category_id":"' + priceCatID + '","category":"' + priceCat + '","item_id":"'
8954							//+ priceItemID + '","tag":"' + priceTag + '","title":"' + priceTitle + '",\n\
8955							//"price":"' + pricePrice + '","description":"' + priceDescr + '"},';
8956
8957
8958							var priceCatID  = 'string' === typeof this.category_id ? decodeURIComponent( this.category_id ) : '';
8959							var priceCat    = 'string' === typeof this.category ? decodeURIComponent( this.category ) : '';
8960							var priceItemID = 'string' === typeof this.item_id ? decodeURIComponent( this.item_id ) : '';
8961							var priceTag    = 'string' === typeof this.tag ? decodeURIComponent( this.tag ) : '';
8962							var priceTitle  = 'string' === typeof this.title ? decodeURIComponent( this.title ) : '';
8963							var pricePrice  = 'string' === typeof this.price ? decodeURIComponent( this.price ) : '';
8964							var priceDescr  = 'string' === typeof this.description ? decodeURIComponent( this.description ) : '';
8965                                                        var priceLink   = 'string' === typeof this.link ? decodeURIComponent( this.link ) : '';
8966	                                                var priceImageURL  = 'string' === typeof this.imageURL ? decodeURIComponent( this.imageURL ) : '';
8967	                                                var priceImageID  = 'string' === typeof this.imageID ? decodeURIComponent( this.imageID ) : '';
8968	                                                var priceLabel  = 'string' === typeof this.label ? decodeURIComponent( this.label ) : '';
8969
8970	                                                createPriceListItem( priceItemID, priceCatID, priceTag, priceTitle, pricePrice, priceDescr, priceLink, priceLabel, priceImageURL, priceImageID );
8971
8972							if ( ! ( 'string' !== typeof priceCat || undefined === priceCat || 'undefined' === priceCat || 'NaN' === priceCat || '0' === priceCat || '' === priceCat ) ) {
8973								createPriceListCategory( priceCatID, priceCat );
8974							}
8975						} );
8976					}
8977
8978				} );
8979			}, 500 );
8980
8981			// Is price list active?
8982
8983			setTimeout( function () {
8984				priceListEnablerFieldset = $( '.fieldset-job_business_use_price_list' );
8985
8986				$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).append( priceListFieldsetContent );
8987
8988				if ( $( '#job_business_use_price_list' ).is( ':checked' ) ) {
8989					$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).removeClass( 'hidden' );
8990				}
8991			}, 100 );
8992		} );
8993
8994		/* Prepare wrapper for menu/catalog image gallery */
8995		$( '.fieldset-job_business_use_catalog_images' ).each( function () {
8996			var
8997				galleryEnablerFieldset = $( this ),
8998				galleryFieldset = $( '.fieldset-gallery_images_menu' );
8999
9000			var
9001				galleryOutput = galleryEnablerFieldset.prop( 'outerHTML' ),
9002				galleryFieldsetContent = galleryFieldset.prop( 'outerHTML' );
9003
9004			galleryEnablerFieldset.before( '<div class="listar-business-catalog-fields listar-boxed-fields-catalog-gallery hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
9005
9006			galleryEnablerFieldset.prop( 'outerHTML', '' );
9007
9008			$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-gallery .listar-boxed-fields-wrapper' ).prepend( galleryOutput );
9009
9010			galleryFieldset.prop( 'outerHTML', '' );
9011
9012			setTimeout( function () {
9013				galleryEnablerFieldset = $( '.fieldset-job_business_use_catalog_images' );
9014
9015				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-gallery .listar-boxed-fields-inner' ).append( galleryFieldsetContent );
9016
9017				if ( $( '#job_business_use_catalog_images' ).is( ':checked' ) ) {
9018					$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-gallery .listar-boxed-fields-inner' ).removeClass( 'hidden' );
9019				}
9020			}, 100 );
9021		} );
9022
9023		/*xxx */
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164		/* Prepare wrapper for menu/catalog creator */
9165		$( '.fieldset-job_business_use_catalog_create' ).each( function () {
9166			var
9167				creatorFieldset = $( this ),
9168				jsonFieldset = $( '.fieldset-job_business_use_catalog_create_json' );
9169
9170			var
9171				creatorOutput = creatorFieldset.prop( 'outerHTML' ),
9172				jsonFieldsetContent = jsonFieldset.prop( 'outerHTML' );
9173
9174			creatorFieldset.before( '<div class="listar-business-catalog-fields listar-boxed-fields-catalog-creator hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
9175
9176			creatorFieldset.prop( 'outerHTML', '' );
9177
9178			$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-creator .listar-boxed-fields-wrapper' ).prepend( creatorOutput );
9179
9180			jsonFieldset.prop( 'outerHTML', '' );
9181
9182			setTimeout( function () {
9183				creatorFieldset = $( '.fieldset-job_business_catalog_label' );
9184
9185				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-creator .listar-boxed-fields-inner' ).append( jsonFieldsetContent );
9186
9187				if ( $( '#job_business_use_catalog_create' ).is( ':checked' ) ) {
9188					$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-creator .listar-boxed-fields-inner' ).removeClass( 'hidden' );
9189				}
9190			}, 100 );
9191		} );
9192
9193		/* Create review popup, if on single listing page */
9194		if ( theBody.hasClass( 'single-job_listing' ) ) {
9195			var reviewPopupBgImage;
9196
9197			theBody.append( '<div class="listar-review-popup listar-hero-header listar-transparent-design"></div>' );
9198
9199			$( '.listar-review-popup' )
9200				.append( '<div class="listar-hero-image"></div>' )
9201				.append( '<div class="listar-valign-form-holder"></div>' );
9202
9203			$( '.listar-review-popup .listar-valign-form-holder' ).append( '<div class="text-center listar-valign-form-content"></div>' );
9204			$( '.listar-review-popup .listar-valign-form-content' ).append( '<div class="listar-panel-form-wrapper"><div class="panel listar-panel-form"><div class="panel-body"></div></div></div>' );
9205
9206			reviewPopupBgImage = $( '.listar-review-popup .listar-hero-image' ).css( 'background-image' );
9207
9208			/* Does review popup has a valid background image?
9209			 * If not, background color should be black with opacity
9210			 */
9211			if (
9212				'' === reviewPopupBgImage ||
9213				'0' === reviewPopupBgImage ||
9214				'none' === reviewPopupBgImage ||
9215				reviewPopupBgImage.indexOf( '/0' ) >= 0
9216			) {
9217				$( '.listar-review-popup' ).addClass( 'listar-no-background-image' );
9218			}
9219		}
9220
9221		/* Check if front page has hero image */
9222
9223		$( '.listar-front-header' ).each( function () {
9224			var frontpageHeroHeader = $( this );
9225			var backgroundImage = frontpageHeroHeader.find( '.listar-hero-image' ).css( 'background-image' );
9226
9227			if ( 'none' === backgroundImage || '' === backgroundImage ) {
9228				frontpageHeroHeader.addClass( 'listar-no-frontpage-hero-image' );
9229			}
9230		} );
9231
9232		/* Create the 'hamburguer' main menu (mobile menu) only if primary menu has links */
9233		if ( $( '#listar-primary-menu > .navbar-nav' ).length ) {
9234			$( '.navbar-inverse .listar-primary-navigation-wrapper' ).prepend( '<div class="navbar-header"></div>' );
9235			$( '.navbar-inverse .navbar-header' ).append( '<a class="navbar-toggle"></a>' );
9236
9237			if ( ! $( '.listar-user-logged' ).length ) {
9238				$( '.navbar-inverse .navbar-header .navbar-toggle' )
9239					.append( '<span class="sr-only"></span>' )
9240					.append( '<span class="icon-bar"></span>' )
9241					.append( '<span class="icon-bar"></span>' )
9242					.append( '<span class="icon-bar"></span>' );
9243			} else {
9244
9245				/*
9246				 * User is logged in:
9247				 */
9248
9249				 /* Replicate the name/username of current user inside the 'hamburguer' menu */
9250
9251				$( '.navbar-inverse .navbar-header' )
9252					.append( '<div class="listar-logged-user-name"></div>' );
9253
9254				$( '.navbar-inverse .navbar-header .listar-logged-user-name' )
9255					.append( '<span>' + $( '#listar-logged-user-menu-list .listar-logged-user-name' ).prop( 'innerHTML' ) + '</span>' );
9256
9257				/* Replicate the user avatar inside 'hamburguer' menu */
9258
9259				$( '.navbar-inverse .navbar-header .navbar-toggle' )
9260					.append( $( '<div class="listar-user-buttons"></div>' ) )
9261					.append( '<span class="sr-only"></span>' )
9262					.append( '<span class="icon-bar"></span>' )
9263					.append( '<span class="icon-bar"></span>' )
9264					.append( '<span class="icon-bar"></span>' );
9265
9266				$( '.navbar-inverse .navbar-header .navbar-toggle > .listar-user-buttons' )
9267					.append( $( '<div href="#" class="listar-user-login"></div>' ) );
9268
9269				/* Replicate the menu to logged users inside the 'hamburguer' menu */
9270
9271				$( '.listar-account-menu-item ul' )
9272					.append( $( '.listar-user-logged .listar-logged-user-menu-wrapper #listar-logged-user-menu-list' ).prop( 'innerHTML' ) );
9273
9274				/* Remove unwanted/duplicated links */
9275
9276				$( '.listar-account-menu-item .listar-logged-user-name' ).prop( 'outerHTML', '' );
9277
9278				/* But if the menu has less than 2 li elements on root level, move all inner elements to root and remove 'listar-account-menu-item' */
9279
9280				if ( $( '.listar-account-menu-item ' ).siblings( 'li' ).length < 2 ) {
9281					$( '.listar-account-menu-item ' ).prop( 'outerHTML', $( '.listar-account-menu-item ul' ).prop( 'innerHTML' ) );
9282				}
9283
9284				/* Disable unwanted click event for these links */
9285
9286				/*xxx */
9287				
9288				
9289			}// End if().
9290
9291			/* If primary menu is empty or the menu isn't set */
9292
9293			if (
9294				$( '#listar-primary-menu' ).hasClass( 'listar-primary-menu-mobile' ) ||
9295				0 === $( '#masthead > .navbar-inverse li[id]' ).length
9296			) {
9297				if ( 1 === $( '#listar-primary-menu .listar-header-search-button' ).length ) {
9298					$( '#listar-primary-menu .listar-header-search-button' ).prop( 'outerHTML','' );
9299				}
9300
9301				headMenu.addClass( 'listar-no-primary-menu' );
9302
9303				if ( $( '.listar-search-button-mobile' ).length ) {
9304					$( '.listar-primary-navigation-wrapper' ).append( '<div class="listar-header-search-button listar-search-button-desktop"></div>' );
9305				}
9306			}
9307
9308		} else {
9309			headMenu.addClass( 'listar-no-primary-menu' );
9310		}// End if().
9311
9312		$( '.listar-hero-header' ).prepend( '<div class="listar-hero-header-overlay"></div>' );
9313		$( '.listar-front-header.listar-hero-header' ).find( '.listar-hero-header-overlay' ).css( { opacity: 0, display : 'block' } );
9314		$( '.listar-front-header.listar-hero-header' ).find( '.listar-hero-header-overlay' ).stop().animate( { opacity: 1 }, { duration : 1000 } );
9315
9316		$( '.listar-search-categories' ).append( '<span class="listar-more-categories"></span>' );
9317
9318		moreCategoriesButtonVisibility();
9319		enableNearestMeDataEditor();
9320
9321		$( '#site-navigation.navbar-inverse' ).after( $( '<div class="listar-navbar-height-col-inverse" id="listar-navbar-height-col"></div>' ) );
9322		$( '#site-navigation.navbar-default' ).after( $( '<div id="listar-navbar-height-col"></div>' ) );
9323		$( '#listar-primary-menu' ).prepend( '<div class="listar-mobile-menu-header-background"></div>' );
9324		$( '.listar-search-popup, .listar-review-popup, .listar-social-share-popup, .listar-login-popup, .listar-booking-popup, .listar-listing-categories-popup, .listar-listing-regions-popup, .listar-search-by-popup, .listar-report-popup, .listar-claim-popup, .listar-settings-popup' ).prepend( '<div class="listar-back-site icon-cross2"></div>' );
9325
9326		/* Automatic Lightbox for Woocommerce image gallery */
9327		if ( $( '.woocommerce-product-gallery' ).length ) {
9328			var o = 1;
9329
9330			$( '.woocommerce-product-gallery' ).each( function () {
9331				$( this ).find( 'a' ).each( function () {
9332					if (
9333						$( this ).attr( 'href' ).indexOf( 'jpg' ) >= 0 ||
9334						$( this ).attr( 'href' ).indexOf( 'jpeg' ) >= 0 ||
9335						$( this ).attr( 'href' ).indexOf( 'gif' ) >= 0 ||
9336						$( this ).attr( 'href' ).indexOf( 'png' ) >= 0 ||
9337						$( this ).attr( 'href' ).indexOf( 'bmp' ) >= 0 ||
9338						$( this ).attr( 'href' ).indexOf( 'jpg' ) >= 0
9339					) {
9340						$( this ).attr( 'data-lightbox', 'gallery-' + o );
9341						$( '.lightbox' ).css( { marginLeft : 0 } );
9342					}
9343				} );
9344
9345				o++;
9346			} );
9347		}
9348
9349		/* Set image caption to the image wrapping hyperlink */
9350		$( '.wp-caption-text, figcaption' ).each( function () {
9351			var
9352				caption = $( this ).prop( 'innerHTML' ),
9353				prev = $( this ).prev();
9354
9355			if ( prev.length > 0 ) {
9356				if ( 'lightbox' === prev.attr( 'rel' ) ) {
9357					prev.attr( 'title', caption );
9358				}
9359			}
9360		} );
9361
9362		/* Change placeholder text for Regions selector on Add Listing page */
9363		$( '#submit-job-form select#job_region' ).each( function () {
9364			$( this ).attr( 'data-placeholder', listarLocalizeAndAjax.regionSelectPlaceholder );
9365		} );
9366
9367		/*
9368		 * Move aligncenter class from img elements to its parent hiperlink, if it exists
9369		 * Because we don't want the blank laterals of the image as hyperlink (clickable) area
9370		 */
9371		$( 'img.aligncenter' ).each( function () {
9372			var thisElement = $( this );
9373
9374			if ( 'A' === thisElement.parent().prop( 'tagName' ) ) {
9375				thisElement.removeClass( 'aligncenter' );
9376				thisElement.parent().addClass( 'aligncenter' );
9377			}
9378		} );
9379
9380		/* Add alignmobile class to parent hyperlinks of <img> tags on posts/pages */
9381		$( 'img.alignleft, img.alignright, img.aligncenter, img.alignnone' ).each( function () {
9382			var thisElement = $( this );
9383
9384			if ( 'A' === thisElement.parent().prop( 'tagName' ) && ! thisElement.hasClass( 'size-thumbnail' ) ) {
9385				thisElement.parent().addClass( 'alignmobile' );
9386			}
9387		} );
9388
9389		/* Add 'alignmedium' class to parent hyperlinks of <img> tags with 'size-medium' class ( if found sequence of two images with this class ) */
9390		$( 'img.size-medium' ).each( function () {
9391			var thisElement = $( this );
9392
9393			/* Sequence of 'a img.size-medium' + 'a img.size-medium' */
9394			if ( 'A' === thisElement.parent().prop( 'tagName' ) ) {
9395				if ( thisElement.parent().next().length > 0 ) {
9396					if ( 'A' === thisElement.parent().next().prop( 'tagName' ) && thisElement.parent().next().find( 'img.size-medium' ).length > 0 ) {
9397						thisElement.parent().addClass( 'alignmedium' );
9398						thisElement.parent().next().addClass( 'alignmedium' );
9399					}
9400				}
9401			}
9402
9403			/* Sequence of 'img.size-medium' + 'a img.size-medium' */
9404			if ( thisElement.next().length > 0 ) {
9405				if ( 'A' === thisElement.next().prop( 'tagName' ) && thisElement.next().find( 'img.size-medium' ).length > 0 ) {
9406					thisElement.addClass( 'alignmedium' );
9407					thisElement.next().addClass( 'alignmedium' );
9408				}
9409			}
9410
9411			/* Sequence of 'a img.size-medium' + 'img.size-medium' */
9412			if ( thisElement.parent().next().length > 0 ) {
9413				if ( 'IMG' === thisElement.parent().next().prop( 'tagName' ) && thisElement.parent().next().hasClass( 'size-medium' ) ) {
9414					thisElement.parent().addClass( 'alignmedium' );
9415					thisElement.parent().next().addClass( 'alignmedium' );
9416				}
9417			}
9418
9419			/* Sequence of 'img.size-medium' + 'img.size-medium' (no hyperlinks) */
9420			if ( thisElement.next().length > 0 ) {
9421				if ( 'IMG' === thisElement.next().prop( 'tagName' ) && thisElement.next().hasClass( 'size-medium' ) ) {
9422					thisElement.addClass( 'alignmedium' );
9423					thisElement.next().addClass( 'alignmedium' );
9424				}
9425			}
9426		} );
9427
9428		/* Because we don't want the blank laterals of the image as hyperlink (clickable) area */
9429		$( 'img.aligncenter' ).each( function () {
9430			var thisElement = $( this );
9431
9432			if ( 'A' === thisElement.parent().prop( 'tagName' ) ) {
9433				thisElement.removeClass( 'aligncenter' );
9434				thisElement.parent().addClass( 'aligncenter' );
9435			}
9436		} );
9437
9438		/* Fix repeated empty <p> elements on post/page contents */
9439		$( '.entry-content p' ).each( function () {
9440			var thisElement = $( this );
9441
9442			if ( '&nbsp;' === thisElement.prop( 'innerHTML' ) ) {
9443				thisElement.addClass( 'listar-empty-line' );
9444			}
9445		} );
9446
9447		/*
9448		 * If 'Recent Posts' widget is exposing the date of posts, move
9449		 * the date's <span> tags into the respective 'listar-post-title-wrapper' divs
9450		 * for better design. Doing this with JavaScript avoids extend/rewrite
9451		 * the whole widget for such simple change
9452		 */
9453		$( '.widget_recent_entries' ).each( function () {
9454			$( this ).find( '.post-date' ).each( function () {
9455				var date = $( this ).prop( 'outerHTML' );
9456				$( this ).siblings( 'a' ).find( '.listar-post-title-wrapper' ).append( date );
9457				$( this ).prop( 'outerHTML', '' );
9458			} );
9459		} );
9460
9461		$( '.listar-hero-header' ).not( '.listar-color-design' ).find( '.listar-hero-image' ).animate( { opacity : 1 }, { duration : 250 } );
9462		$( '.listar-user-logged .listar-user-buttons.listar-user-buttons-responsive > .listar-user-buttons' ).css( { 'background-image' : $( '.listar-user-logged .site-header .listar-user-buttons .listar-user-login' ).eq( 0 ).css( 'background-image' ) } );
9463
9464		if ( 0 === $( '.listar-regions-list a' ).length >= 1 && $( '.listar-regions-list a.current' ).length ) {
9465			$( '.listar-regions-list a:eq( 0 )' ).addClass( 'current' );
9466		}
9467
9468		if ( 1 === $( '.listar-regions-list a' ).length ) {
9469			$( '.listar-regions-list a' ).addClass( 'listar-region-no-hover' );
9470		}
9471
9472		$( '.fieldset-company_instagram' ).append( '<div class="listar-clear-both"></div><div class="listar-show-more-social"></div>' );
9473
9474		$( '.fieldset-company_external_link_3' ).append( '<div class="listar-clear-both"></div><div class="listar-show-more-social"></div>' );
9475
9476		$( '.account-sign-in a' ).each( function () {
9477			var thisElement = $( this );
9478
9479			/* If 'Listar Addons' plugin is active, remove the default WordPress login URL */
9480			if ( - 1 === thisElement.attr( 'href' ).indexOf( 'logout' ) && ! theBody.hasClass( 'listar-no-addons' ) ) {
9481				thisElement.attr( 'href', '#' );
9482			}
9483		} );
9484
9485		$( '#submit-job-form fieldset' ).each( function () {
9486			if ( '' === $( '#submit-job-form #job_title' ).attr( 'value' ) && $( this ).index() > 5 ) {
9487				$( this ).find( 'input' ).attr( 'value', '' );
9488				$( '.job-manager-remove-uploaded-file' ).eq( 0 ).trigger( 'click' );
9489				$( '.job-manager-remove-uploaded-file' ).eq( 1 ).trigger( 'click' );
9490				$( '.job-manager-uploaded-files' ).prop( 'innerHTML', '' );
9491				$( '#job_useuseremail' ).prop( 'checked', true );
9492			}
9493		} );
9494
9495		if ( $( '#job_useuseremail' ).is( ':checked' ) ) {
9496			$( '.fieldset-job_custom_email' ).css( { display : 'none' } );
9497		}
9498
9499		$( '.comment-content' ).each( function () {
9500			var thisElement = $( this ).find( '.wpjmr-list-reviews, .listar-list-reviews' ).eq( 0 );
9501
9502			if ( thisElement.length ) {
9503				if ( thisElement.prop( 'innerHTML' ).length < 20 ) {
9504					thisElement.css( { display : 'none' } );
9505				}
9506			}
9507		} );
9508
9509		$( '.listar-fav-listing .listar-card-content-image' ).prop( 'outerHTML', '' );
9510
9511		toggler = '.navbar-toggle';
9512		pageWrapper = '#page-content';
9513		navigationWrapper = '.navbar-header';
9514		menuWidth = '300px';
9515		menuNegativeWidth = '-300px';
9516		selected = '#listar-primary-menu, body, .navbar, .navbar-header';
9517
9518		/* Prepare main menu structure if has submenus */
9519		$( '#listar-primary-menu > .navbar-nav li a' ).each( function () {
9520			if ( $( this ).next().hasClass( 'dropdown-menu' ) ) {
9521				$( this ).append( '<b class="caret"></b>' ).addClass( 'dropdown-toggle' ).attr( 'data-toggle', 'dropdown' );
9522			}
9523		} );
9524
9525		prepareMainMenu();
9526
9527		if ( ! $( '.site-header' ).length ) {
9528			theBody.append( '<div class="listar-full-dimming-overlay"></div>' );
9529		} else {
9530			$( '.site-header' ).append( '<div class="listar-full-dimming-overlay"></div>' );
9531		}
9532
9533		setCanvasEffect();
9534
9535		/*xxx */
9536		
9537		
9538
9539		/* Initialize Tooltips */
9540		if ( $.isFunction( $.fn.tooltip ) ) {
9541			$( '.listar-social-networks a[data-toggle="tooltip"], .listar-page-user[data-toggle="tooltip"], .listar-more-results[data-toggle="tooltip"], .listar-more-map-listing[data-toggle="tooltip"], .listar-template-colors [data-toggle="tooltip"], .listar-read-more-link[data-toggle="tooltip"], .listar-settings-button[data-toggle="tooltip"], .listar-copy-day-button[data-toggle="tooltip"], .listar-multiple-hours-buttons a[data-toggle="tooltip"], .listar-toggle-listing-sidebar-position[data-toggle="tooltip"], .listar-clean-search-by-filters-button[data-toggle="tooltip"], .listar-clean-search-input-button[data-toggle="tooltip"], .listar-get-geolocated[data-toggle="tooltip"], .listar-trending-icon[data-toggle="tooltip"]' ).tooltip();
9542			$( '[data-toggle="tooltip"]' ).not( '[data-original-title]' ).tooltip( {
9543				container : 'body'
9544			} );
9545		}
9546
9547		/* Price range */
9548		var requiredPriceRange = '';
9549		priceRange = $( '#job_pricerange' );
9550		priceRangeValue = priceRange.val();
9551
9552		priceRange.each( function () {
9553			requiredPriceRange = priceRange[0].hasAttribute( 'required' ) ? 'required' : '';
9554		} );
9555
9556		if ( priceRange.length ) {
9557			priceRange.after( '<div class="listar-price-range-fields"></div>' );
9558
9559			$( '.listar-price-range-fields' )
9560				.append( '<span class="listar-price-range-symbol">' + listarLocalizeAndAjax.wooCurrencySymbol + '&nbsp;</span>' )
9561				.append( '<input class="listar-price-range-from" type="text" placeholder="15" ' + requiredPriceRange + '>' )
9562				.append( '<span class="listar-price-range-separator">
9562~</span>' )
9563				.append( '<span class="listar-price-range-symbol">' + listarLocalizeAndAjax.wooCurrencySymbol + '&nbsp;</span>' )
9564				.append( '<input class="listar-price-range-to" type="text" placeholder="45" ' + requiredPriceRange + '>' );
9565
9566			/* Check/get saved price range */
9567			if ( - 1 !== priceRangeValue.indexOf( '/////' ) ) {
9568				var priceValues = priceRangeValue.split( '/////' );
9569
9570				if ( 'string' === typeof priceValues[0] && undefined !== priceValues[0] && 'undefined' !== priceValues[0] && 'NaN' !== priceValues[0]  ) {
9571					$( '.listar-price-range-from' ).val( parseFloat( priceValues[0] ) );
9572				}
9573
9574				if ( 'string' === typeof priceValues[1] && undefined !== priceValues[1] && 'undefined' !== priceValues[1] && 'NaN' !== priceValues[1]  ) {
9575					$( '.listar-price-range-to' ).val( parseFloat( priceValues[1] ) );
9576				}
9577			}
9578		}
9579
9580		priceAverage = $( '#job_priceaverage' );
9581
9582		if ( priceAverage.length ) {
9583			priceAverage.before( '<span class="listar-price-average-symbol">' + listarLocalizeAndAjax.wooCurrencySymbol + '&nbsp;</span>' );
9584		}
9585
9586		$( '#commentform' ).each( function () {
9587			$( this )[0].encoding = 'multipart/form-data';
9588		} );
9589
9590		$( 'article iframe' ).each( function () {
9591			if ( 'P' === $( this ).parent().prop( 'tagName' ) && 'BR' === $( this ).prev().prop( 'tagName' ) ) {
9592				$( this ).prev().prop( 'outerHTML', '' );
9593			}
9594		} );
9595
9596		$( '.single-job_listing .job_description p:first-child > *:first-child, .entry-content p:first-child > *:first-child' ).each( function () {
9597			if ( 'BR' === $( this ).prop( 'tagName' ) ) {
9598				$( this ).prop( 'outerHTML', '' );
9599			}
9600		} );
9601
9602		/* Hide sections on single listing pages */
9603		if ( theBody.hasClass( 'single-job_listing' ) ) {
9604			var
9605				descriptionWrapper = $( '.listar-single-listing-description-wrapper' ),
9606				listinSocialNetworks = $( '.single-job_listing .listar-listing-description .listar-social-networks' ),
9607				listingContactDataWrapper = $( '.single-job_listing .listar-listing-contact-data' ),
9608				listingDescriptionFirstCol = $( '.listar-listing-description-first-col' ),
9609				listingDescriptionSecondCol = $( '.listar-listing-description-second-col' ),
9610				listingDescriptionFirstColContainers,
9611				priceRanges = $( '.listar-listing-price-range-wrapper' ),
9612				listingDescriptionText = $( '.listar-listing-description-text' ),
9613				hasPrivateMessageForm  = $( '.listar-private-message-accordion' ).length > 0,
9614				listingDescriptionTextTemp = $( '<div></div>' );
9615
9616			if ( 0 === listingDescriptionText.length ) {
9617				listingDescriptionText = '';
9618			} else {
9619				listingDescriptionTextTemp = $( $( '.listar-listing-description-text' ).prop( 'outerHTML' ) );
9620				listingDescriptionTextTemp.find( '.listar-listing-description-title' ).prop( 'outerHTML', '' );
9621
9622				/* Clean all HTML comments */
9623				listingDescriptionTextTemp.prop( 'innerHTML', listingDescriptionTextTemp.prop( 'innerHTML' ).replace( /<\!--.*?-->/g, '' ) );
9624
9625				/* Remove all empty tags */
9626				listingDescriptionTextTemp.prop( 'innerHTML', listingDescriptionTextTemp.prop( 'innerHTML' ).replace( /<[\S]+><\/[\S]+>/gim, '' ) );
9627			}
9628
9629			/* Is all description block empty? */
9630			if ( descriptionWrapper.length ) {
9631				if ( descriptionWrapper.prop( 'innerHTML' ).replace( /\s/g, '' ).length < 918 ) {
9632					descriptionWrapper.prop( 'outerHTML', '' );
9633				}
9634			}
9635
9636			/*
9637			 * Hide contact data container on single listings if empty
9638			 * If gallery is empty, hide it too
9639			 */
9640			if ( ! listingContactDataWrapper.find( 'li' ).length ) {
9641				listingContactDataWrapper.prop( 'outerHTML', '' );
9642			}
9643
9644			/* Does the listing has social networks? */
9645			if ( ! listinSocialNetworks.find( 'a' ).length ) {
9646				listinSocialNetworks.parent().prop( 'outerHTML', '' );
9647				descriptionWrapper.addClass( 'listar-no-social-networks' );
9648			}
9649
9650			/* Does the listing has a description text? */
9651			if ( listingDescriptionText.length ) {
9652				if ( 0 === listingDescriptionTextTemp.prop( 'innerHTML' ).replace( /\s/g, '' ).length ) {
9653					/* Does the listing has the private message form, at least? */
9654					if ( ! hasPrivateMessageForm ) {
9655						listingDescriptionText.prop( 'outerHTML', '' );
9656					}
9657				}
9658			}
9659
9660			/* Are the description cols not tall enough? */
9661			if ( listingDescriptionFirstCol.length ) {
9662				if ( listingDescriptionFirstCol.height() < 100 ) {
9663					if ( listingDescriptionSecondCol.length ) {
9664						listingDescriptionSecondCol.removeClass( 'col-md-8' ).addClass( 'col-md-12' );
9665					}
9666
9667					if ( $( '.listar-toggle-listing-sidebar-position' ).length ) {
9668						$( '.listar-toggle-listing-sidebar-position' ).prop( 'outerHTML', '' );
9669					}
9670				}
9671			}
9672
9673			/* Is there just the logo wrapper on first column? */
9674			setTimeout( function () {
9675				listingDescriptionFirstColContainers = $( '.listar-listing-description-first-col > div' );
9676
9677				if ( 1 === listingDescriptionFirstColContainers.length ) {
9678					if ( listingDescriptionFirstColContainers.hasClass( 'listar-listing-logo-data' ) ) {
9679						listingDescriptionFirstCol.removeClass( 'col-md-4' ).addClass( 'col-md-12' );
9680
9681						if ( listingDescriptionSecondCol.length ) {
9682							listingDescriptionSecondCol.removeClass( 'col-md-8' ).addClass( 'col-md-12' );
9683						}
9684
9685						if ( $( '.listar-toggle-listing-sidebar-position' ).length ) {
9686							$( '.listar-toggle-listing-sidebar-position' ).prop( 'outerHTML', '' );
9687						}
9688					}
9689				}
9690			}, 100 );
9691
9692			if ( listingDescriptionSecondCol.length ) {
9693				if ( listingDescriptionSecondCol.height() < 100 ) {
9694					listingDescriptionSecondCol.removeClass( 'col-md-8' ).addClass( 'col-md-12' );
9695
9696					if ( listingDescriptionFirstCol.length ) {
9697						listingDescriptionFirstCol.removeClass( 'col-md-4' ).addClass( 'col-md-12' );
9698					}
9699
9700					if ( $( '.listar-toggle-listing-sidebar-position' ).length ) {
9701						$( '.listar-toggle-listing-sidebar-position' ).prop( 'outerHTML', '' );
9702					}
9703				}
9704			}
9705
9706			/* Fix if there is only one price range block */
9707			if ( 1 === priceRanges.length ) {
9708				priceRanges.removeClass( 'col-sm-6' ).addClass( 'col-sm-12' );
9709			}
9710
9711			/* Is the description finished with a empty paragraph? */
9712
9713			if ( listingDescriptionText.length ) {
9714				if ( listingDescriptionText.find( 'p' ).length ) {
9715					var lastP = listingDescriptionText.find( 'p:last-child' );
9716
9717					if ( lastP.prop( 'innerHTML' ).indexOf( 'wp:paragraph' ) >= 0 ) {
9718						lastP.prop( 'outerHTML', '' );
9719					}
9720				}
9721			}
9722
9723			setTimeout( function () {
9724
9725				var
9726					contactDataCol1 = $( '.listar-listing-description-first-col' ),
9727					descriptionCol1 = $( '.listar-listing-description-second-col' ),
9728					listingHasRightSidebar = theBody.hasClass( 'listar-listing-sidebar-position-right' );
9729
9730				if ( contactDataCol1.length && descriptionCol1.length && listingHasRightSidebar ) {
9731
9732					var cloneA = contactDataCol1.clone();
9733					var cloneB = descriptionCol1.clone();
9734
9735					contactDataCol1.replaceWith( cloneB );
9736					descriptionCol1.replaceWith( cloneA );
9737
9738					theBody.addClass( 'listar-listing-sidebar-on-right' );
9739
9740					setTimeout( function () {
9741						/* Removes the tooltip */
9742						$( '.listar-listing-description-first-col' ).find( '.tooltip' ).prop( 'outerHTML', '' );
9743						setTooltips();
9744					}, 10 );
9745				}
9746
9747				/* Is the accordion section not tall enough? */
9748				if ( $( '.listar-listing-description-text #accordion' ).length > 0 ) {
9749					if ( 0 === $( '.listar-listing-description-text #accordion' ).height() ) {
9750						$( '.listar-listing-description-text' ).prop( 'outerHTML', '' );
9751					}
9752				}
9753			}, 15 );
9754
9755		}// End if().
9756
9757		if ( $( '.listar-search-results-count-wrapper.listar-not-found' ).length > 0 && $( '#map' ).length > 0 ) {
9758			$( '#map' ).addClass( 'listar-map-disabled' );
9759		}
9760
9761		/*
9762		 * Pages shouldn't contain more than one listing map block.
9763		 * If it is the case, remove and keep the first found.
9764		 * It can happen, for example, if a map widget is included on
9765		 * footer and single listing pages/archive are accessed.
9766		 * Also, if two listing map widgets are in use on any page.
9767		 */
9768		if ( $( '.listar-map ~ .listar-aside-list' ).length > 1 ) {
9769			$( '.listar-map ~ .listar-aside-list' ).not( ':first' ).parent().prop( 'outerHTML', '' );
9770		}
9771
9772		resetElements();
9773
9774		/*
9775		 * Init Select2
9776		 */
9777		$( '.listar-business-hours-fields select' ).each( function() {
9778			var theSelect = $( this );
9779			var initialSelectedValue = theSelect.attr( 'value' );
9780			var initialSelectedValue2 = theSelect.val();
9781
9782			if ( theSelect.parents( '.listar-business-start-time-field' ).length ) {
9783				if ( '' === initialSelectedValue || '' === initialSelectedValue2 || 'undefined' === typeof( initialSelectedValue ) || 'undefined' === typeof( initialSelectedValue2 ) ) {
9784					theSelect.find( 'option' ).each( function () {
9785						$( this ).removeAttr( 'selected' ).prop( 'selected', false );
9786
9787						if ( '09:00 AM' === $( this ).attr( 'value' ) ) {
9788							$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
9789						}
9790					} );
9791
9792					theSelect.val( '09:00 AM' );
9793					theSelect.attr( 'value', '09:00 AM' );
9794				} else {
9795					theSelect.attr( 'value', theSelect.val() );
9796				}
9797			}
9798
9799			if ( theSelect.parents( '.listar-business-end-time-field' ).length ) {
9800				if ( ( '00:00 AM' === initialSelectedValue || '' === initialSelectedValue ) ) {
9801					theSelect.find( 'option' ).each( function () {
9802						$( this ).removeAttr( 'selected' ).prop( 'selected', false );
9803
9804						if ( '06:00 PM' === $( this ).attr( 'value' ) ) {
9805							$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
9806						}
9807					} );
9808
9809					theSelect.val( '06:00 PM' );
9810					theSelect.attr( 'value', '06:00 PM' );
9811				} else {
9812					theSelect.attr( 'value', theSelect.val() );
9813				}
9814			}
9815		} );
9816
9817		featuredListingCategorySelect( $( '#company_featured_listing_category' ).val() );
9818		featuredListingRegionSelect( $( '#company_featured_listing_region' ).val() );
9819
9820		var select2Selectors = $( '#product_type, .woocommerce-input-wrapper select, #vendor_commission_mode, form[class*="woo"] select, form[id*="woo"] select, form[name*="woo"] select, .job-manager-form select, .listar_theme_shapes_session, .listar-search-by-custom-location-data-countries-select select, select[id*="wc_bookings_field"], select[name*="wc_bookings_field"]' );
9821
9822		select2Selectors.each( function () {
9823			forceSelectSelected( $( this ) );
9824		} );
9825
9826		if ( $.isFunction( $.fn.select2 ) ) {				
9827			select2Selectors.select2( {
9828				minimumResultsForSearch: 3
9829			} );
9830
9831			$( '.listar-select-single, .variations_form select, .woocommerce .woocommerce-ordering select' ).select2( {
9832				minimumResultsForSearch: -1
9833			} );
9834
9835			setTimeout( function () {
9836				$( 'select[name="job_business_products_label"], #company_business_rich_media_label, #job_business_catalog_label, #job_business_booking_label' ).each( function () {
9837					if ( $( this ).siblings( '.select2' ).length ) {
9838						$( this ).siblings( '.select2' ).prop( 'outerHTML', '' );
9839						$( this ).select2( 'destroy' );
9840						$( this ).select2();
9841					}
9842				} );
9843			}, 100 );
9844
9845                        setTimeout( function () {                
9846                                $( '#job_business_products_list, #job_business_booking_method' ).each( function () {
9847                                        var select2Elem = $( this );
9848
9849                                        if ( select2Elem.siblings( '.select2' ).length ) {
9850                                                select2Elem.select2( 'destroy' );
9851                                                select2Elem.siblings( '.select2' ).prop( 'outerHTML', '' );
9852                                                select2Elem.removeAttr( 'aria-hidden' );
9853                                                select2Elem.removeAttr( 'tabindex' );
9854                                                select2Elem.removeAttr( 'data-select2-id' );
9855                                                select2Elem.removeClass( 'select2-hidden-accessible' );
9856                                                select2Elem.css( { height : 'auto' } );
9857
9858                                                if ( ! isMobile() ) {
9859                                                        select2Elem.select2();
9860                                                }
9861                                        }
9862                                } );
9863                        }, 3000 );
9864		}
9865		
9866		
9867		
9868		
9869		
9870		
9871		
9872		
9873		
9874		
9875		
9876		
9877		
9878		
9879		
9880		
9881		
9882		
9883		
9884		
9885		
9886		
9887		
9888		
9889		
9890		
9891		
9892		
9893		
9894		
9895		
9896		
9897		
9898		
9899		
9900		
9901		
9902		
9903		
9904		
9905		
9906		
9907		
9908		
9909		
9910		
9911		
9912		
9913		
9914		
9915		
9916		
9917		
9918		
9919		
9920		
9921		
9922		
9923		
9924		
9925		
9926		
9927		
9928		
9929		
9930		
9931		
9932		
9933		
9934		
9935		
9936		
9937		
9938		
9939		
9940		
9941		
9942		
9943		
9944		
9945		
9946		
9947		
9948
9949		/*xxx */
9950		
9951		
9952		
9953		
9954		
9955		
9956		
9957		
9958		
9959		
9960		
9961		
9962		
9963		
9964		
9965		
9966		
9967		
9968		
9969		
9970		
9971		
9972		
9973		
9974		
9975		
9976		
9977		
9978
9979		/*xxx */ 
9980		
9981		
9982		
9983		
9984
9985		/* Append AOS (animation) to front page widgets */
9986
9987		if ( animateElementsOnScroll ) {
9988			$( '.entry-content .widget' ).each( function () {
9989
9990				$( this ).attr( 'data-aos', 'fade-up' );
9991
9992				if ( $( this ).find( '.widget-title' ).length ) {
9993					$( this ).find( '.widget-title' ).attr( 'data-aos', 'fade-up' );
9994				}
9995
9996				if ( $( this ).find( '.widget-title ~ *' ).length ) {
9997					$( this ).find( '.widget-title ~ *' ).attr( 'data-aos', 'fade-zoom-in' );
9998				}
9999
10000				if ( $( this ).find( '.listar-widget-content-wrapper' ).length ) {
10001					$( this ).find( '.listar-widget-content-wrapper' ).attr( 'data-aos', 'fade-zoom-in' );
10002				}
10003			} );
10004		}
10005
10006		if ( $( '.job-manager-form' ).length ) {
10007			if ( 0 === $( '#job_amenities option' ).length ) {
10008				$( '.fieldset-job_amenities' ).css( { display : 'none' } );
10009			}
10010		}
10011
10012		if ( $( '.job-manager-form' ).length ) {
10013			if ( 0 === $( '#job_amenities option' ).length ) {
10014				$( '.fieldset-job_amenities' ).css( { display : 'none' } );
10015			}
10016
10017			/* Move WP Job Manager checkbox field to new position */
10018
10019			if ( $( '.fieldset-job_fullwidth' ).length ) {
10020				var fieldsetHTML = $( '.fieldset-job_fullwidth' ).prop( 'outerHTML' );
10021
10022				$( '.fieldset-job_fullwidth' ).prop( 'outerHTML', '' );
10023				$( '.fieldset-job_description' ).before( fieldsetHTML );
10024			}
10025		}
10026
10027		$( '.listar-add-wave-top' ).not( 'img, video' ).append( '<div class="listar-wave-top"></div>' ).removeClass( 'listar-add-wave-top' );
10028		$( '.listar-add-wave-bottom' ).not( 'img, video' ).append( '<div class="listar-wave-bottom"></div>' ).removeClass( 'listar-add-wave-bottom' );
10029
10030		/* For users who downgraded for WordPress < 5.0 or disabled Gutenberg: try to fix public Gutenberg blocks, if available */
10031
10032		if ( theBody.hasClass( 'listar-no-gutenberg' ) ) {
10033			$( '.wp-block-gallery' ).each( function() {
10034				var classes = $( this ).attr( 'class' );
10035				classes = classes.replace( /columns-/g, 'gallery gallery-columns-' );
10036
10037				$( this ).find( '.blocks-gallery-item' ).addClass( 'gallery-item' );
10038				$( this ).find( 'figure' ).addClass( 'gallery-icon' );
10039				$( this ).attr( 'class', classes );
10040			} );
10041		}
10042		
10043		/*xxx */
10044		
10045		
10046
10047		$( '.entry-content .listar-wavy-badge-design .listar-wave-top, .entry-content .listar-wavy-badge-design .listar-wave-bottom' ).each( function () {
10048			$( this ).prop( 'outerHTML', '' );
10049		} );
10050
10051		$( '.widget_recent_entries' ).each( function () {
10052			$( this ).removeClass( 'widget' ).addClass( 'listar-recent-entries-wrapper' );
10053			$( this ).prop( 'innerHTML', '<div class="widget">' + $( this ).prop( 'innerHTML' ) + '</div>' );
10054		} );
10055
10056		/* Custom Gutenberg classes */
10057
10058		customGutenbergClasses = '[class*="listar-iconify"],[class*="listar-cloudify"],[class*="listar-borderify"],[class*="listar-embossify"],[class*="listar-wavify"],[class*="listar-max-embossify"],[class*="listar-skewfy"],[class*="listar-gradientify"],[class*="listar-roundify"],[class*="listar-max-roundify"],[class*="listar-iconify"],[class*="listar-quantify"],[class*="listar-mixify"]';
10059
10060		$( 'main article .listar-featurify, main article .listar-featurify-squared, main article .listar-featurify-uncloudify' ).each( function () {
10061			$( this ).addClass( 'listar-center-aside listar-borderify-inner listar-embossify listar-max-roundify' );
10062
10063			if ( $( this ).hasClass( 'listar-featurify-squared' ) ) {
10064				$( this ).removeClass( 'listar-max-roundify-top' );
10065			}
10066
10067			if ( $( this ).hasClass( 'listar-featurify-uncloudify' ) ) {
10068				$( this ).removeClass( 'listar-cloudify' );
10069			}
10070		} );
10071
10072		$( 'main article .listar-featurify, main article .listar-featurify-squared' ).each( function () {
10073			if ( $( this ).hasClass( 'listar-featurify-squared' ) ) {
10074				$( this ).removeClass( 'listar-max-roundify-top' );
10075			}
10076		} );
10077
10078		$( 'main article' ).each( function () {
10079			$( customG
10079utenbergClasses ).each( function () {
10080				if ( ! $( this ).hasClass( 'listar-play-button' ) ) {
10081					if ( $( this ).find( 'figure a' ).length ) {
10082						$( this ).find( 'figure a' ).append( '<div class="listar-custom-gutenberg-classes-inner"></div>' );
10083					} else {
10084						$( this ).find( 'figure' ).each( function () {
10085							$( this ).append( '<div class="listar-custom-gutenberg-classes-inner"></div>' );
10086						} );
10087
10088					}
10089				}
10090			} );
10091		} );
10092
10093		$( 'main article .listar-borderify-inner' ).each( function () {
10094			$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10095				$( this ).append( '<div class="listar-do-borderify-inner"></div>' );
10096			} );
10097		} );
10098
10099		$( 'main article .listar-gradientify-bottom' ).each( function () {
10100			$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10101				$( this ).append( '<div class="listar-do-gradientify-bottom"></div>' );
10102			} );
10103		} );
10104
10105		$( 'main article .listar-quantify-left' ).each( function () {
10106			$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10107				$( this ).append( '<div class="listar-do-quantify listar-do-quantify-left"></div>' );
10108			} );
10109		} );
10110
10111		$( 'main article .listar-quantify-right' ).each( function () {
10112			$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10113				$( this ).append( '<div class="listar-do-quantify listar-do-quantify-right"></div>' );
10114			} );
10115		} );
10116
10117		$( 'main article .listar-do-quantify' ).each( function () {
10118			$( this ).append( '0' + quantifyCounter );
10119			quantifyCounter += 1;
10120		} );
10121
10122		$( 'main article .listar-roundify-top.listar-borderify-inner .listar-do-quantify-left' ).each( function () {
10123			var imageWidth = $( this ).parent().width();
10124			var radius = imageWidth / 2;
10125			var counterTop    = ( radius ) - Math.sqrt( ( ( Math.pow( ( radius ), 2 ) ) / 2 ) ) - 4;
10126			var counterLeft = counterTop + 20 - 25;
10127			counterTop = counterTop + 40 - 25;
10128
10129			$( this ).css( { top : counterTop, left : counterLeft } );
10130		} );
10131
10132		$( 'main article .listar-roundify-top.listar-borderify-inner .listar-do-quantify-right' ).each( function () {
10133			var imageWidth = $( this ).parent().width();
10134			var radius = imageWidth / 2;
10135			var counterTop    = ( radius ) - Math.sqrt( ( ( Math.pow( ( radius ), 2 ) ) / 2 ) ) - 4;
10136			var counterRight = counterTop + 20 - 25;
10137			counterTop = counterTop + 40 - 25;
10138
10139			$( this ).css( { top : counterTop, right : counterRight } );
10140		} );
10141
10142		$( 'main article .listar-max-roundify-top.listar-borderify-inner .listar-do-quantify-left' ).each( function () {
10143			var imageWidth = $( this ).parent().width();
10144			var radius = imageWidth / 2;
10145			var counterTop    = ( radius ) - Math.sqrt( ( ( Math.pow( ( radius ), 2 ) ) / 2 ) ) + 7;
10146			var counterLeft = counterTop + 20 - 25;
10147			counterTop = counterTop + 40 - 25;
10148
10149			$( this ).css( { top : counterTop, left : counterLeft } );
10150		} );
10151
10152		$( 'main article .listar-max-roundify-top.listar-borderify-inner .listar-do-quantify-right' ).each( function () {
10153			var imageWidth = $( this ).parent().width();
10154			var radius = imageWidth / 2;
10155			var counterTop    = ( radius ) - Math.sqrt( ( ( Math.pow( ( radius ), 2 ) ) / 2 ) ) + 7;
10156			var counterRight = counterTop + 20 - 25;
10157			counterTop = counterTop + 40 - 25;
10158
10159			$( this ).css( { top : counterTop, right : counterRight } );
10160		} );
10161
10162		$( 'main article [class*="listar-iconify-icon-"], main article [class*="listar-iconify-fa-"]' ).each( function () {
10163			var classes = $( this ).attr( 'class' );
10164			classes = classes.split( ' ' );
10165
10166			var classesCount = classes.length;
10167			var iconClass = '';
10168			var ind;
10169
10170			for ( ind = 0; ind < classesCount; ind++ ) {
10171				if ( classes[ ind ].indexOf( 'listar-iconify-icon-' ) >= 0 ) {
10172					iconClass = classes[ ind ].replace( 'listar-iconify-', '' );
10173					break;
10174				} else if ( classes[ ind ].indexOf( 'listar-iconify-fa-' ) >= 0 ) {
10175					iconClass = classes[ ind ].replace( '-icon-fa-', '-fa-' );
10176					iconClass = iconClass.replace( 'listar-iconify-fa-fa-', 'fa fa-' );
10177					iconClass = iconClass.replace( 'listar-iconify-fa-', 'fa fa-' );
10178					break;
10179				}
10180			}
10181
10182			if ( '' !== iconClass ) {
10183				$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10184					if ( ! $( this ).find( '.listar-do-iconify' ).length ) {
10185						$( this ).append( '<div class="listar-do-iconify"></div>' );
10186					}
10187					$( this ).find( '.listar-do-iconify' ).attr( 'class', 'listar-do-iconify ' + iconClass );
10188				} );
10189			}
10190		} );
10191
10192		$( 'main article [class*="listar-iconify-size"]' ).each( function () {
10193			var classes = $( this ).attr( 'class' );
10194			classes = classes.split( ' ' );
10195
10196			var classesCount = classes.length;
10197			var fontSize = '';
10198			var ind;
10199
10200			for ( ind = 0; ind < classesCount; ind++ ) {
10201				if ( classes[ ind ].indexOf( 'listar-iconify-size-' ) >= 0 ) {
10202					fontSize = classes[ ind ].replace( 'listar-iconify-size-', '' );
10203					fontSize = fontSize.replace( 'px', '' ).replace( '*', '' ).replace( 'em', '' ).replace( 'rem', '' ).replace( 'pt', '' );
10204					break;
10205				}
10206			}
10207
10208			if ( '' !== fontSize ) {
10209				$( this ).find( '.listar-do-iconify' ).each( function () {
10210					$( this ).css( { 'font-size' : fontSize + 'px' } );
10211				} );
10212			}
10213		} );
10214
10215		$( 'main article [class*="listar-iconify-space-left"]' ).each( function () {
10216			var classes = $( this ).attr( 'class' );
10217			classes = classes.split( ' ' );
10218
10219			var classesCount = classes.length;
10220			var space = '';
10221			var ind;
10222
10223			for ( ind = 0; ind < classesCount; ind++ ) {
10224				if ( classes[ ind ].indexOf( 'listar-iconify-space-left-' ) >= 0 ) {
10225					space = classes[ ind ].replace( 'listar-iconify-space-left-', '' );
10226					space = space.replace( 'px', '' ).replace( '*', '' ).replace( 'em', '' ).replace( 'rem', '' ).replace( 'pt', '' );
10227					space = parseInt( space, 10 );
10228					break;
10229				}
10230			}
10231
10232			if ( '' !== space ) {
10233				$( this ).find( '.listar-do-iconify' ).each( function () {
10234					if ( space > 0 ) {
10235						$( this ).css( { 'padding-left' : space + 'px' } );
10236					} else {
10237						$( this ).css( { 'padding-right' : -1 * space + 'px' } );
10238					}
10239				} );
10240			}
10241		} );
10242
10243		$( 'main article [class*="listar-iconify-space-top"]' ).each( function () {
10244			var classes = $( this ).attr( 'class' );
10245			classes = classes.split( ' ' );
10246
10247			var classesCount = classes.length;
10248			var space = '';
10249			var ind;
10250
10251			for ( ind = 0; ind < classesCount; ind++ ) {
10252				if ( classes[ ind ].indexOf( 'listar-iconify-space-top-' ) >= 0 ) {
10253					space = classes[ ind ].replace( 'listar-iconify-space-top-', '' );
10254					space = space.replace( 'px', '' ).replace( '*', '' ).replace( 'em', '' ).replace( 'rem', '' ).replace( 'pt', '' );
10255					space = parseInt( space, 10 );
10256					break;
10257				}
10258			}
10259
10260			if ( '' !== space ) {
10261				$( this ).find( '.listar-do-iconify' ).each( function () {
10262					$( this ).css( { 'line-height' : 47 + space + 'px' } );
10263				} );
10264			}
10265		} );
10266
10267		$( 'main article [class*="listar-iconify-color"]' ).each( function () {
10268			var classes = $( this ).attr( 'class' );
10269			classes = classes.split( ' ' );
10270
10271			var classesCount = classes.length;
10272			var color = '';
10273			var ind;
10274
10275			for ( ind = 0; ind < classesCount; ind++ ) {
10276				if ( classes[ ind ].indexOf( 'listar-iconify-color-' ) >= 0 ) {
10277					color = classes[ ind ].replace( 'listar-iconify-color-', '' ).replace( '#', '' );
10278					break;
10279				}
10280			}
10281
10282			if ( '' !== color ) {
10283				color = '#' + color;
10284
10285				if ( validHexColor( color ) ) {
10286
10287					$( this ).find( '.listar-do-iconify' ).each( function () {
10288						$( this ).css( { 'background-color' : color } );
10289					} );
10290				}
10291			}
10292		} );
10293
10294		$( 'main article [class*="listar-iconify-force-square"]' ).each( function () {
10295			$( this ).find( '.listar-do-iconify' ).each( function () {
10296				$( this ).addClass( 'listar-do-iconify-squared' );
10297			} );
10298		} );
10299
10300		$( 'main article .listar-skewfy' ).each( function () {
10301			var skewElement = $( this );
10302
10303			setTimeout( function ( ) {
10304				skewElement.addClass( 'listar-do-skewfy' );
10305			}, 1500 );
10306		} );
10307
10308		if ( $( 'main article .listar-cloudify' ).length ) {
10309			setTimeout( function () {
10310				$( 'main article .listar-cloudify' ).each( function () {
10311					$( this ).find( '.listar-custom-gutenberg-classes-inner' ).each( function () {
10312						var
10313							imageWidth  = $( this ).width(),
10314							imageHeight = $( this ).height();
10315
10316						var maxShadowsAmount = parseInt( ( imageHeight / 70 ) * 2.1 );
10317
10318						var shadowColors = [
10319							'rgba(100,100,100,0)',
10320							'rgba(100,100,100,0)',
10321							'rgba(100,100,100,0.08)',
10322							'rgba(255,200,0,0.6)',
10323							'rgba(255,15,255,0.45)',
10324							'rgba(255,108,0,0.4)',
10325							'rgba(50,0,200,0.4)',
10326							'rgba(200,200,200,0.3)',
10327							'rgba(10,200,255,0.65)',
10328							'rgba(200,200,200,0.45)',
10329							'rgba(200,200,150,0.45)',
10330							'rgba(200,200,200,0.30)',
10331							'rgba(53,248,1,0.45)',
10332							'rgba(255,255,0,0.45)',
10333							'rgba(255,108,217,0.15)',
10334							'rgba(180,180,180,0.65)',
10335							'rgba(255,0,180,0.35)',
10336							'rgba(180,255,25,0.55)',
10337							'rgba(150,220,200,0.35)',
10338							'rgba(40,180,180,0.6)',
10339							'rgba(180,10,180,0.1)',
10340							'rgba(18,180,18,0.15)',
10341							'rgba(50,0,255,0.4)',
10342							'rgba(255,180,180,0.25)',
10343							'rgba(200,200,0,0.45)',
10344							'rgba(180,180,180,0.35)',
10345							'rgba(255,0,180,0.35)',
10346							'rgba(180,255,255,0.55)',
10347							'rgba(200,0,100,0.25)',
10348							'rgba(230,108,0,0.4)',
10349							'rgba(180,10,180,0.4)',
10350							'rgba(10,180,180,0.25)',
10351							'rgba(18,180,18,0.35)'
10352						];
10353
10354						var colorsAmount = shadowColors.length;
10355
10356						var shadowPositions = [
10357							/* Pattern 1 */
10358							[
10359								[
10360									// Grey top.
10361									imageWidth - 250, // X.
10362									20000 - 80		           // Y.
10363								],
10364								[
10365									// Grey Bottom.
10366									imageWidth - 250,
10367									20000 + imageHeight - 20
10368								],
10369
10370								[
10371									-100,
10372									20000 - 20
10373								],
10374								[
10375									imageWidth - 170,
10376									20000 + 65
10377								],
10378
10379								[
10380									imageWidth - 110,
10381									20000 + 240
10382								],
10383
10384								[
10385									-50,
10386									20000 + 120
10387								],
10388
10389								[
10390									-100,
10391									20000 + 110
10392								],
10393								[
10394									imageWidth - 80,
10395									20000 + 280
10396								],
10397
10398								[
10399									-200,
10400									20000 + 250
10401								],
10402								[
10403									imageWidth - 80,
10404									20000 + 270
10405								],
10406
10407								[
10408									-50,
10409									20000 + 280
10410								],
10411								[
10412									imageWidth - 10,
10413									20000 + 290
10414								],
10415
10416								[
10417									-90,
10418									20000 + 380
10419								],
10420								[
10421									imageWidth + 60,
10422									20000 + 360
10423								],
10424
10425								[
10426									-290,
10427									20000 + 430
10428								],
10429								[
10430									imageWidth - 130,
10431									20000 + 400
10432								],
10433
10434								[
10435									-10,
10436									20000 + 440
10437								],
10438								[
10439									imageWidth - 90,
10440									20000 + 470
10441								],
10442
10443								/* Extended height */
10444
10445								[
10446									-100,
10447									20000 + 520
10448								],
10449								[
10450									imageWidth - 170,
10451									20000 + 565
10452								],
10453
10454								[
10455									imageWidth - 110,
10456									20000 + 740
10457								],
10458
10459								[
10460									-100,
10461									20000 + 610
10462								],
10463								[
10464									imageWidth - 80,
10465									780
10466								],
10467
10468								[
10469									-200,
10470									20000 + 750
10471								],
10472								[
10473									imageWidth - 80,
10474									20000 + 770
10475								],
10476
10477								[
10478									-50,
10479									20000 + 780
10480								],
10481								[
10482									imageWidth - 10,
10483									20000 + 790
10484								],
10485
10486								[
10487									-90,
10488									20000 + 880
10489								],
10490								[
10491									imageWidth + 60,
10492									20000 + 860
10493								],
10494
10495								[
10496									-290,
10497									20000 + 930
10498								],
10499								[
10500									imageWidth - 130,
10501									20000 + 900
10502								],
10503
10504								[
10505									-10,
10506									20000 + 940
10507								],
10508								[
10509									imageWidth - 90,
10510									20000 + 970
10511								]
10512							]
10513						];
10514
10515						var patternsAmount = shadowPositions.length;
10516
10517						var lastShadow = -1;
10518
10519						$( this ).before( '<div class="listar-do-cloudify"></div>' );
10520
10521						$( this ).parent().find( '.listar-do-cloudify' ).each( function () {
10522							var
10523								boxShadow = '',
10524								currentShadow = 0,
10525								shadowsAmount = 0,
10526								currentColor = -1,
10527								currentPatern;
10528
10529							lastShadow++;
10530
10531							if ( lastShadow >= patternsAmount ) {
10532								lastShadow = 0;
10533							}
10534
10535							currentPatern = shadowPositions[ lastShadow ];
10536							shadowsAmount = currentPatern.length;
10537
10538							for ( currentShadow = 0; currentShadow < shadowsAmount; currentShadow++ ) {
10539								if ( currentShadow < maxShadowsAmount ) {
10540									var colorRGBA = '';
10541
10542									currentColor++;
10543
10544									if ( currentColor >= colorsAmount ) {
10545										currentColor = 0;
10546									}
10547
10548									colorRGBA = shadowColors[ currentColor ];
10549
10550									boxShadow += currentPatern[ currentShadow ][0] + 'px ' + currentPatern[ currentShadow ][1] + 'px 1px ' + colorRGBA + ',';
10551								}
10552							}
10553
10554							boxShadow = boxShadow.substring( 0, boxShadow.length - 1 ); /* Remove last comma */
10555
10556							$( this ).css( { 'box-shadow' : boxShadow } );
10557						} );
10558					} );
10559				} );
10560			}, 2000 );
10561		}
10562
10563		listarFeaturifyElements.each( function () {
10564			if ( $( this ).find( 'figure' ).length ) {
10565				var figure = $( this ).find( 'figure' ).eq( 0 );
10566
10567				if ( figure.offset().left + ( figure.width() / 2 ) < viewport().width / 2 ) {
10568					$( this ).addClass( 'listar-hidden-featured-left' );
10569				} else {
10570					$( this ).addClass( 'listar-hidden-featured-right' );
10571				}
10572			}
10573		} );
10574
10575		$( '.listar-play-button' ).each( function () {
10576			$( this ).find( 'a' ).each( function () {
10577				$( this ).attr( 'data-lity', 'data-lity' );
10578			} );
10579
10580			$( this ).find( '.aligncenter,.alignleft,.alignright,.alignwide,.alignfull,.alignnone' ).each( function () {
10581				$( this ).removeClass( 'aligncenter alignleft alignright alignwide alignfull alignnone' );
10582			} );
10583
10584			if ( 'DIV' === $( this ).prop( 'tagName' ) ) {
10585				$( this ).find( 'figure' ).attr( 'class', $( this ).attr( 'class' ) );
10586				$( this ).prop( 'outerHTML', $( this ).prop( 'innerHTML' ) );
10587			}
10588		} );
10589
10590		$( '.listar-play-button' ).each( function () {
10591			var caption = '';
10592
10593			$( this ).find( 'img' ).each( function () {
10594				var img = $( this ).attr( 'src' );
10595				$( this ).css( { 'background-image' : 'url(' + img + ')' } );
10596				$( this ).parent().prepend( '<div class="listar-play-button-overlay"></div>' );
10597
10598				/* This is an empty png 1x1px */
10599				$( this ).attr( 'src', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' );
10600				$( this ).attr( 'srcset', '' );
10601			} );
10602
10603			$( this ).find( 'figcaption' ).each( function () {
10604				caption = $( this ).prop( 'innerHTML' );
10605				$( this ).prop( 'outerHTML', '' );
10606				$( this ).attr( 'title', 'Settings' ).attr( 'data-toggle', 'tooltip' ).attr( 'data-placement', 'top' );
10607			} );
10608
10609			$( this ).find( 'a' ).each( function () {
10610				if ( '' !== caption ) {
10611					$( this ).attr( 'title', caption ).attr( 'data-toggle', 'tooltip' ).attr( 'data-placement', 'top' );
10612				}
10613			} );
10614
10615			$( this ).animate( { opacity: 1 }, { duration: 1000 } );
10616		} );
10617
10618		$( '.listar-package-description p' ).each( function () {
10619			var classes = $( this ).attr( 'class' );
10620
10621			if ( 'undefined' !== typeof classes ) {
10622				classes = classes
10623					.replace( 'icon-', 'listar-has-icon icon-' )
10624					.replace( 'fa fa', 'listar-has-icon fa fa' );
10625
10626				$( this ).attr( 'class', classes );
10627			}
10628		} );
10629
10630		if ( 0 === $( '.listar-site-footer .widget' ).length ) {
10631			$( '.listar-site-footer' ).addClass( 'listar-no-footer-widgets' );
10632		}
10633
10634		theBody.addClass( 'listar-loaded' );
10635
10636		/*xxx */ setTimeout( function () {
10637			//
10638		}, 2000 );
10639
10640		$( '.listar-testimonial-avatar' ).each( function () {
10641			var html = $( this ).prop( 'outerHTML' );
10642			$( this ).parents( '.listar-review-items' ).find( '.listar-testimonial-avatars' ).append( html );
10643			$( this ).prop( 'outerHTML', '' );
10644		} );
10645
10646		$( '.listar-testimonial-avatars' ).each( function () {
10647			if ( $( this ).find( '.listar-testimonial-avatar' ).length ) {
10648				$( this ).find( '.listar-testimonial-avatar' ).eq( 0 ).addClass( 'current' );
10649			}
10650		} );
10651
10652		$( '.listar-testimonial-items' ).each( function () {
10653			if ( $( this ).find( '.listar-testimonial-item' ).length ) {
10654				$( this ).find( '.listar-testimonial-item' ).eq( 0 ).addClass( 'current' ).css( { opacity : 1 } );
10655			}
10656		} );
10657
10658		$( '.listar-front-page-widgetized-section' ).each( function () {
10659			if ( $( this ).find( '.listar-front-widget-wrapper' ).length ) {
10660				var lastWidget = $( this ).find( '.listar-front-widget-wrapper' ).last();
10661				var bgColor = lastWidget.css( 'background-color' );
10662
10663				if ( 'rgb(255, 255, 255)' === bgColor || '#ffffff' === bgColor ) {
10664					lastWidget.addClass( 'listar-last-widget-gradient-bg' );
10665				}
10666			}
10667		} );
10668
10669		$( '.entry-content .listar-badge-masked-container' ).each( function () {
10670			if ( 'rgb(255, 255, 255)' !== $( this ).parents( '.listar-front-widget-wrapper' ).css( 'background-color' ) && '#ffffff' !== $( this ).parents( '.listar-front-widget-wrapper' ).css( 'background-color' ) ) {
10671				$( this ).parents( '.listar-section' ).addClass( 'listar-badge-inner-box-shadow' );
10672			}
10673		} );
10674
10675		$( '.listar-back-to-top' ).each( function () {
10676			var footerDetailLines = $( 'footer .copyright' ).length;
10677
10678			if ( 1 === footerDetailLines ) {
10679				$( this ).addClass( 'listar-footer-details-one-line' );
10680			}
10681		} );
10682
10683		$( '.listar-grid-design-2 .listar-card-content' ).each( function () {
10684			if ( ! $( this ).find( '.listar-listing-address' ).length ) {
10685				$( this ).addClass( 'listar-no-listing-address' );
10686			}
10687		} );
10688
10689		$( '.listar-footer-navigation-wrapper' ).each( function () {
10690			if ( ! $( this ).find( 'li' ).length ) {
10691				$( this ).parents( '.listar-footer-menu-wrapper' ).prop( 'outerHTML', '' );
10692			}
10693		} );
10694
10695		$( '.listar-search-results-count-wrapper.listar-not-found' ).each( function () {
10696			$( this ).siblings( '.listar-page-header' ).addClass( 'listar-no-results-header' );
10697		} );
10698
10699		/*xxxxx */
10700		
10701		
10702		
10703		
10704		
10705		
10706		
10707		
10708		
10709		
10710		
10711		
10712		
10713
10714		$( '.entry-content .listar-section-title' ).each( function () {
10715			if ( $( this ).siblings( '.listar-widget-subtitle' ).length ) {
10716				var titleContent = '';
10717
10718				$( this ).removeClass( 'listar-section-title' );
10719				titleContent = $( this ).parent().prop( 'innerHTML' );
10720
10721				$( this ).parent().prop( 'innerHTML', '<div class="listar-section-title">' + titleContent + '</div>' );
10722			}
10723		} );
10724
10725		$( '.listar-map-no-title' ).each( function () {
10726			$( this ).removeClass( 'listar-map-no-title' );
10727			$( this ).parents( '.widget' ).addClass( 'listar-map-no-title' );
10728		} );
10729
10730		$( '.widget_listar_call_to_action' ).each( function () {
10731			if ( $( this ).find( '.listar-wavy-badge-design' ).length ) {
10732				$( this ).addClass( 'listar-has-wavy-badge-mask' );
10733			} else {
10734				$( this ).addClass( 'listar-no-wavy-badge-mask' );
10735			}
10736		} );
10737
10738		$( '.listar-data-review-popup-background-image' ).each( function () {
10739			var bgImage = $( this ).attr( 'data-review-popup-background-image' );
10740
10741			$( '.listar-review-popup .listar-hero-image' ).each( function () {
10742				$( this ).css( 'background-image', 'url(' + bgImage + ')' );
10743			} );
10744		} );
10745
10746		$( '.listar-user-thumbnail-background-image' ).each( function () {
10747			var bgImage = $( this ).attr( 'data-user-thumbnail-image' );
10748
10749			$( '.listar-user-logged .listar-user-login' ).each( function () {
10750				$( this ).css( 'background-image', 'url(' + bgImage + ')' );
10751			} );
10752		} );
10753
10754		/* Fix for Monster Widget - Remove menu links without a title */
10755
10756		$( '.widget .dropdown-menu li a' ).each( function () {
10757			if ( '' === $( this ).prop( 'innerHTML' ) ) {
10758				$( this ).parent().prop( 'outerHTML', '' );
10759			}
10760		} );
10761
10762		$( '#secondary .listar-term-wrapper .listar-term-description, footer .listar-term-wrapper .listar-term-description' ).each( function () {
10763			$( this ).prop( 'outerHTML', '' );
10764		} );
10765
10766		if ( listingGallery.length ) {
10767			var countGalleryItems = listingGalleryItems.length;
10768
10769			if ( 1 === countGalleryItems ) {
10770				listingGalleryItems.addClass( 'listar-gallery-item-full' );
10771				listingGallery.addClass( 'listar-single-gallery-item' );
10772			}
10773		}
10774
10775		listingGallery.each( function () {
10776			var gallery = $( this );
10777			var galleryLinks = gallery.find( 'a' );
10778
10779			if ( ! gallery.hasClass( 'listar-gallery-dark' ) ) {
10780				theBody.addClass( 'listar-listing-gallery-has-light-design' );
10781			}
10782
10783			if ( galleryLinks.length > 0 && gallery.hasClass( 'listar-gallery-dark' ) ) {
10784				$( '#primary' ).addClass( 'listar-current-gallery-is-dark' );
10785			}
10786
10787			if ( galleryLinks.length > 0 && gallery.hasClass( 'listar-gallery-dark' ) && ! ( gallery.hasClass( 'listar-gallery-slideshow-squared' ) || gallery.hasClass( 'listar-gallery-slideshow-rounded' ) ) ) {
10788				var
10789					headerRating       = $( '.listar-listing-header-topbar-wrapper' ),
10790					headerRatingHeight = 0,
10791					headerTitleHeight  = 0,
10792					galleryHeight      = 0,
10793					galleryBGHeight    = 0;
10794
10795				setTimeout( function() {
10796					if ( headerRating.length ) {
10797						headerRating
10798							.addClass( 'listar-header-rating-dark' );
10799
10800						headerRatingHeight = headerRating.height();
10801					}
10802
10803					headerTitleHeight = $( '.listar-listing-title' ).height();
10804					galleryHeight = gallery.height();
10805
10806					galleryBGHeight = headerRatingHeight + headerTitleHeight + galleryHeight;
10807
10808					gallery.parents( '#content' )
10809						.append( '<div class="listar-listing-gallery-backgrounds"></div>' );
10810
10811					$( '.listar-listing-gallery-backgrounds' )
10812						.css( { 'background-image' : 'url(' + galleryLinks.eq( 0 ).attr( 'href' ) + ')', height : galleryBGHeight + 280 } );
10813				}, 1000 );
10814			} else {
10815				gallery
10816					.addClass( 'listar-section-no-padding-bottom listar-no-gallery-background' );
10817			}
10818		} );
10819
10820		$( '.listar-gallery-tiny-rounded, .listar-gallery-tiny-squared' ).each( function () {
10821			var gallery = $( this );
10822			var galleryImages = gallery.find( 'img' );
10823			var countImages = galleryImages.length;
10824
10825			if ( countImages > 1 ) {
10826				galleryImages.eq( 0 ).parents( '.gallery-item' )
10827					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages ) + '</div></div>' );
10828			}
10829
10830			if ( countImages > 2 ) {
10831				galleryImages.eq( 1 ).parents( '.gallery-item' )
10832					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 1 ) + '</div></div>' );
10833			}
10834
10835			if ( countImages > 3 ) {
10836				galleryImages.eq( 2 ).parents( '.gallery-item' )
10837					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 2 ) + '</div></div>' );
10838			}
10839
10840			if ( countImages > 4 ) {
10841				galleryImages.eq( 3 ).parents( '.gallery-item' )
10842					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 3 ) + '</div></div>' );
10843			}
10844
10845			if ( countImages > 5 ) {
10846				galleryImages.eq( 4 ).parents( '.gallery-item' )
10847					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 4 ) + '</div></div>' );
10848			}
10849		} );
10850
10851		$( '.listar-gallery-rounded-boxed, .listar-gallery-squared-boxed' ).each( function () {
10852			var gallery = $( this );
10853			var galleryImages = gallery.find( 'img' );
10854			var countImages = galleryImages.length;
10855
10856			if ( countImages > 1 ) {
10857				galleryImages.eq( 0 ).parents( '.gallery-item' )
10858					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages ) + '</div></div>' );
10859			}
10860
10861			if ( countImages > 2 ) {
10862				galleryImages.eq( 1 ).parents( '.gallery-item' )
10863					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 1 ) + '</div></div>' );
10864			}
10865
10866			if ( countImages > 3 ) {
10867				galleryImages.eq( 2 ).parents( '.gallery-item' )
10868					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 2 ) + '</div></div>' );
10869			}
10870
10871			if ( countImages > 4 ) {
10872				galleryImages.eq( 3 ).parents( '.gallery-item' )
10873					.append( '<div class="listar-listing-gallery-more-images"><div>+' + ( countImages - 3 ) + '</div></div>' );
10874			}
10875		} );
10876
10877		$( '.listar-gallery-dark' ).each( function () {
10878			var gallery = $( this );
10879			var galleryImages = gallery.find( 'a' );
10880			var countImages = galleryImages.length;
10881
10882			if ( countImages > 0 ) {
10883				gallery
10884					.addClass( 'listar-gallery-has-images' );
10885			} else {
10886				gallery
10887					.addClass( 'listar-gallery-without-images' );
10888			}
10889		} );
10890
10891		/* Fix for bad WordPress paragraph output (text and image in the same paragraph) */
10892
10893		$( '.entry-content p img, .comment-content p img, article p img' ).each( function () {
10894			var
10895				checkInitialText = '',
10896				initialTextIndex = 0,
10897				img = $( this ),
10898				innerHTML = $( this ).parents( 'p' ).prop( 'innerHTML' );
10899
10900			if ( 'A' === img.parent().prop( 'tagName' ) ) {
10901				checkInitialText = '<a ';
10902			} else if ( 'P' === img.parent().prop( 'tagName' ) ) {
10903				checkInitialText = '<img ';
10904			}
10905
10906			initialTextIndex = innerHTML.indexOf( checkInitialText );
10907
10908			if ( initialTextIndex > 10 ) {
10909
10910				/* This paragraph has text badly inserted before the image! The image needs margin on top. */
10911				img.addClass( 'listar-fix-bad-image-insertion-margin' );
10912			}
10913		} );
10914
10915		/* Remove empty paragraphs and fix for bad WordPress paragraph output (wp:p
10915aragraph) comming from Gutenberg */
10916
10917		$( '.entry-content p, article p' ).each( function () {
10918			var innerHTML = $( this ).prop( 'innerHTML' );
10919			var innerHTMLWithoutSpaces = innerHTML.replace( /\s+/g, '' );
10920			var countTags = 0;
10921			var countGutenbergComments = 0;
10922
10923			if ( innerHTMLWithoutSpaces.indexOf( '<' ) >= 0 ) {
10924				countTags = innerHTMLWithoutSpaces.split( '<' ).length - 1;
10925			}
10926
10927			if ( innerHTMLWithoutSpaces.indexOf( 'wp:paragraph' ) >= 0 ) {
10928				countGutenbergComments = innerHTMLWithoutSpaces.split( 'wp:paragraph' ).length - 1;
10929			}
10930
10931			if ( ( countGutenbergComments > 0 && ( countTags === countGutenbergComments ) ) || 0 === innerHTMLWithoutSpaces.length ) {
10932				$( this ).prop( 'outerHTML', '' );
10933			} else if ( innerHTMLWithoutSpaces.indexOf( 'wp:paragraph' ) >= 0 && 0 === $( this ).index() ) {
10934				$( this ).addClass( 'listar-fix-first-wp-paragraph' );
10935			}
10936		} );
10937
10938		/* Remove the margin-bottom from last element on articles */
10939
10940		$( 'article > *:last-child' ).each( function () {
10941			var elem = $( this );
10942
10943			if ( elem.hasClass( 'listar-clear-both' ) ) {
10944				if ( elem.prev().length ) {
10945					if ( elem.prev().hasClass( 'listar-clear-both' ) ) {
10946						if ( elem.prev().prev().length ) {
10947							if ( ! elem.prev().prev().hasClass( 'listar-section' ) ) {
10948								elem.prev().prev().addClass( 'listar-remove-last-margin-bottom' );
10949							}
10950						} else {
10951							if ( ! elem.prev().hasClass( 'listar-section' ) ) {
10952								elem.prev().addClass( 'listar-remove-last-margin-bottom' );
10953							}
10954						}
10955					} else {
10956						if ( ! elem.prev().hasClass( 'listar-section' ) ) {
10957							elem.prev().addClass( 'listar-remove-last-margin-bottom' );
10958						}
10959					}
10960				}
10961			} else {
10962				if ( ! elem.hasClass( 'listar-section' ) ) {
10963					elem.addClass( 'listar-remove-last-margin-bottom' );
10964				}
10965			}
10966		} );
10967
10968		$( '.listar-listing-description-content .listar-open-or-closed.listar-listing-open' ).each( function () {
10969			$( this ).prop( 'innerHTML', $( this ).attr( 'data-short-open' ) );
10970		} );
10971
10972		$( '.listar-listing-description-content .listar-open-or-closed.listar-listing-closed' ).each( function () {
10973			$( this ).prop( 'innerHTML', $( this ).attr( 'data-short-closed' ) );
10974		} );
10975
10976		$( '.listar-listing-header-website-button' ).each( function () {
10977			var theButton = $( this );
10978
10979			if ( $( '.listar-listing-website a' ).length ) {
10980				theButton.attr( 'href', $( '.listar-listing-website a' ).attr( 'href' ) );
10981			} else {
10982				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
10983			}
10984		} );
10985
10986		$( '.listar-listing-share-button' ).each( function () {
10987			var theButton = $( this );
10988
10989			if ( ! $( '.listar-social-share-popup' ).length ) {
10990				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
10991			}
10992		} );
10993
10994		$( '.listar-listing-header-gallery-button' ).each( function () {
10995			var theButton = $( this );
10996			var elementsCount = $( '.listar-listing-gallery .gallery-item' ).length;
10997
10998			if ( elementsCount < 1 ) {
10999				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11000			} else {
11001				theButton.find( '.listar-rating-count' ).prop( 'innerHTML', '(' + elementsCount + ')' );
11002			}
11003		} );
11004
11005		/*xxx */ 
11006		
11007		
11008		
11009		
11010		
11011		
11012		
11013
11014		$( '.listar-listing-header-call-button' ).each( function () {
11015			var theButton = $( this );
11016			var phoneNumber = '';
11017			var numberPattern = /\d+/g;
11018			var phoneNumberTest;
11019
11020			var phoneContainer  = $( '.listar-listing-phone' );
11021			var mobileContainer = $( '.listar-listing-mobile.listar-listing-only-mobile' );
11022
11023			if ( phoneContainer.length && ! theBody.hasClass( 'listar-phone-online-call-disable' ) ) {
11024				phoneNumber = phoneContainer.prop( 'innerHTML' ).replace( /\s+/g, '' ).replace( /(<([^>]+)>)/gi, '' );
11025			} else if ( mobileContainer.length && ! theBody.hasClass( 'listar-mobile-online-call-disable' ) ) {
11026				phoneNumber = mobileContainer.prop( 'innerHTML' ).replace( /\s+/g, '' ).replace( /(<([^>]+)>)/gi, '' );
11027			} else if ( $( '.listar-listing-mobile.listar-listing-whatsapp' ).length && ! theBody.hasClass( 'listar-whatsapp-online-call-disable' ) ) {
11028				var tempPhone = $( '.listar-listing-mobile.listar-listing-whatsapp' ).clone();
11029
11030				if ( tempPhone.find( 'span' ).length ) {
11031					tempPhone.find( 'span' ).prop( 'outerHTML', '' );
11032				}
11033
11034				phoneNumber = tempPhone.prop( 'innerHTML' ).replace( /\s+/g, '' ).replace( /(<([^>]+)>)/gi, '' );
11035			} else {
11036				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11037			}
11038
11039			phoneNumber = validatePhoneCharactersString( phoneNumber );
11040
11041			if( '' !== phoneNumber ) {
11042				phoneNumberTest = phoneNumber.match( numberPattern ).join([]);
11043
11044				if( '' !== phoneNumberTest ) {
11045					theButton.attr( 'href', 'tel:' + phoneNumber );
11046				} else {
11047					theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11048				}
11049			}
11050
11051			if ( phoneContainer.length && ! theBody.hasClass( 'listar-phone-online-call-disable' ) ) {
11052				phoneNumber = phoneContainer.prop( 'innerHTML' ).replace( /\s+/g, '' ).replace( /(<([^>]+)>)/gi, '' );
11053				phoneNumberTest = phoneNumber.match( numberPattern ).join([]);
11054
11055				if( '' !== phoneNumberTest ) {
11056					phoneContainer.prop( 'innerHTML', '<a class="listar-callable-phone-number-active" href="tel:' +  phoneNumber + '">' + phoneContainer.prop( 'innerHTML' ).replace( /(<([^>]+)>)/gi, '' ) + '</a>' );
11057				}
11058			}
11059
11060			if ( mobileContainer.length && ! theBody.hasClass( 'listar-mobile-online-call-disable' ) ) {
11061				phoneNumber = mobileContainer.prop( 'innerHTML' ).replace( /(<([^>]+)>)/gi, '' ).replace( /\s+/g, '' ).replace( /(<([^>]+)>)/gi, '' );
11062				phoneNumberTest = phoneNumber.match( numberPattern ).join([]);
11063
11064				if( '' !== phoneNumberTest ) {
11065					mobileContainer.prop( 'innerHTML', '<a class="listar-callable-phone-number-active" href="tel:' +  phoneNumber + '">' + mobileContainer.prop( 'innerHTML' ).replace( /(<([^>]+)>)/gi, '' ) + '</a>' );
11066				}
11067			}
11068		} );
11069
11070		if ( ! theBody.hasClass( 'listar-whatsapp-online-call-disable' ) ) {
11071			$( '.listar-listing-mobile.listar-listing-whatsapp' ).each( function () {
11072				var theButton = $( this );
11073				var phoneNumber = '';
11074				var numberPattern = /\d+/g;
11075
11076				var tempPhone = $( this ).clone();
11077
11078				if ( tempPhone.find( 'span' ).length ) {
11079					tempPhone.find( 'span' ).prop( 'outerHTML', '' );
11080				}
11081
11082				phoneNumber = tempPhone.prop( 'innerHTML' ).replace( /(<([^>]+)>)/gi, '' );
11083
11084				phoneNumber = validatePhoneCharactersString( phoneNumber ).replace( /[^\w]/gi, '' );
11085
11086				if( '' !== phoneNumber ) {
11087					var phoneNumberTest = phoneNumber.match( numberPattern ).join([]);
11088
11089					if( '' !== phoneNumberTest ) {
11090						var dataSiteName = $( this ).attr( 'data-site-name' );
11091						var dataURL = $( this ).attr( 'data-company-url' );
11092						var dataTitle = $( this ).attr( 'data-company-title' );
11093						var whatsAppLink = 'https://wa.me/' + phoneNumber + '?text=' + dataSiteName + '+-+' + dataTitle + '+-+' + dataURL.replace( 'http://', '' ).replace( 'https://', '' );
11094						theButton.prop( 'innerHTML', '<a class="listar-whatsapp-number-active" target="blank" href="' + whatsAppLink + '">' + theButton.prop( 'innerHTML' ).replace( /(<([^>]+)>)/gi, '' ).replace( '(WhatsApp)', '' ) + '<span class="listar-phone-has-icon"><span>(WhatsApp)</span></span></a>'  );
11095
11096						$( '.listar-listing-header-whatsapp-button' ).each( function () {
11097							theButton = $( this );
11098
11099							theButton.attr( 'href', whatsAppLink );
11100							theButton.attr( 'target', '_blank' );
11101						} );
11102					}
11103				}
11104			} );
11105		}
11106
11107		if ( theBody.hasClass( 'listar-whatsapp-online-call-disable' ) || 0 === $( '.listar-listing-mobile.listar-listing-whatsapp' ).length ) {
11108			$( '.listar-listing-header-whatsapp-button' ).each( function () {
11109				var theButton = $( this );
11110				theButton.prop( 'outerHTML', '' );
11111			} );
11112		}
11113
11114		$( '.listar-listing-header-message-button' ).each( function () {
11115			var theButton = $( this );
11116
11117			if ( 0 === $( '.listar-private-message-accordion' ).length ) {
11118				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11119			}
11120		} );
11121
11122		$( '.listar-listing-header-references-button' ).each( function () {
11123			var theButton = $( this );
11124
11125			if ( 0 === $( '.listar-listing-more-info-accordion' ).length ) {
11126				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11127			}
11128		} );
11129
11130		$( '.listar-listing-header-catalog-button' ).each( function () {
11131			var theButton = $( this );
11132
11133			if ( 0 === $( '.listar-listing-menu-accordion' ).length ) {
11134				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11135			} else {
11136				var menuLabel = $( '.listar-listing-menu-accordion' ).find( '.panel-heading a' ).prop( 'innerHTML' );
11137
11138				$( this ).find( '.listar-listing-header-topbar-item-label' ).prop( 'innerHTML', menuLabel );
11139			}
11140		} );
11141
11142		$( '.listar-listing-header-hours-button' ).each( function () {
11143			var theButton = $( this );
11144
11145			if ( 0 === $( '.listar-business-hours-accordion' ).length ) {
11146				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11147			}
11148		} );
11149
11150		$( '.listar-listing-header-video-button' ).each( function () {
11151			var theButton = $( this );
11152
11153			if ( 0 === $( '.listar-business-video-accordion' ).length ) {
11154				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11155			} else {
11156				var menuLabel = $( '.listar-business-video-accordion' ).find( '.panel-heading a .listar-accordion-title-inner' ).prop( 'innerHTML' );
11157
11158				$( this ).find( '.listar-listing-header-topbar-item-label' ).prop( 'innerHTML', menuLabel );
11159			}
11160		} );
11161
11162		$( '.listar-listing-header-booking-button' ).each( function () {
11163			var theButton = $( this );
11164
11165			if ( 0 === $( '.listar-business-booking-accordion' ).length ) {
11166				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11167			}
11168		} );
11169
11170		$( '.listar-listing-header-directions-button' ).each( function () {
11171			var theButton  = $( this );
11172			var theButton2 = $( '.listar-map-button-directions' );
11173			var theButton3 = $( '.listar-listing-header-coordinates-button' );
11174
11175			if ( 1 === listarMapMarkers.length ) {
11176				var mapMarker = listarMapMarkers[0];
11177
11178				if ( 'undefined' !== typeof mapMarker.lat && 'undefined' !== typeof mapMarker.lng ) {
11179					theButton.attr( 'href', 'http://maps.google.com/maps?daddr=' + mapMarker.lat + '%2C' + mapMarker.lng );
11180
11181					if ( theButton2.length ) {
11182						theButton2.attr( 'href', 'http://maps.google.com/maps?daddr=' + mapMarker.lat + '%2C' + mapMarker.lng );
11183					}
11184
11185					if ( 0 === $( '.listar-listing-map' ).length || 0 === $( '.listar-map-button-coordinates-link' ).length ) {
11186						theButton3.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11187					}
11188				} else {
11189					theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11190                                        theButton2.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11191					theButton3.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11192				}
11193			} else {
11194				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11195                                theButton2.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11196				theButton3.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11197			}
11198		} );
11199
11200		$( '.listar-listing-header-coordinates-button' ).each( function () {
11201			var theButton = $( this );
11202
11203			if ( 0 === $( '.listar-listing-map' ).length || 0 === $( '.listar-map-button-coordinates-link' ).length ) {
11204				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11205			}
11206		} );
11207
11208		$( '.listar-listing-header-similar-button' ).each( function () {
11209			var theButton  = $( this );
11210			var theButton2 = $( '.listar-map-button-find-similar-link' );
11211
11212			if ( theButton2.length ) {
11213				theButton.attr( 'href', theButton2.eq( 0 ).attr( 'href' ) );
11214			} else {
11215				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
11216			}
11217		} );
11218
11219		$( '.nav .menu-item a' ).each( function () {
11220			$( this ).attr( 'data-menu-item-title', $( this ).text().toLowerCase() );
11221		} );
11222
11223		if ( ! $( '.listar-post-comments-wrapper' ).length ) {
11224			if ( $( '.listar-comments-section' ).length ) {
11225				$( '.listar-comments-section' ).prop( 'outerHTML', '' );
11226			}
11227		}
11228
11229		/* Add asterisk for required fields on listing submission form */
11230
11231		/* xxxxx */ 
11232		
11233		
11234		
11235		
11236		
11237		
11238		
11239		
11240		
11241		
11242		
11243		
11244		
11245		
11246		
11247
11248		
11249
11250		/* xxx */ 
11251		
11252		
11253		
11254		
11255		
11256		
11257		
11258
11259		/*xxx */
11260		
11261		
11262		
11263		
11264		
11265		
11266		
11267		
11268		
11269		
11270		
11271		
11272		
11273		
11274		
11275		
11276		
11277		
11278		
11279		
11280		
11281		
11282		
11283		
11284		
11285		
11286		
11287		
11288		
11289		
11290		
11291		
11292		
11293		
11294		
11295		
11296		
11297		
11298		
11299		
11300		
11301		
11302		
11303		
11304
11305		/* Always keep custom CSS from listar after everything, even under Autoptimize criterea */
11306
11307		$( 'style' ).each( function () {
11308			var styleInnerHTML = false;
11309
11310			if ( 'string' === typeof $( this ).prop( 'innerHTML' ) ) {
11311				styleInnerHTML = $( this ).prop( 'innerHTML' );
11312
11313				if (
11314					styleInnerHTML.indexOf( '.page-template-front-page .listar-widget-subtitle' ) >= 0 &&
11315					styleInnerHTML.indexOf( '.listar-card-content-title,.entry-content .listar-card-content-title,' ) >= 0 &&
11316					styleInnerHTML.indexOf( '#page .listar-hero-section-title h1 span span' ) >= 0
11317				) {
11318					customListarStyle = $( this );
11319				}
11320			}
11321		} );
11322
11323		if ( false !== customListarStyle ) {
11324			var lastStyle = $( 'style' ).last();
11325			var lastLink  = $( 'link' ).last();
11326
11327			var lastStyleIndex = getElementIndex( lastStyle.prop( 'outerHTML' ) );
11328			var lastLinkIndex = getElementIndex( lastLink .prop( 'outerHTML' ) );
11329
11330			var lastStyleTagIndex = Math.max( lastStyleIndex, lastLinkIndex );
11331
11332			if ( getElementIndex( customListarStyle.prop( 'outerHTML' ) ) < lastStyleTagIndex ) {
11333				var customListarStyleInnerHTML = customListarStyle.prop( 'outerHTML' );
11334
11335				lastStyle.after( customListarStyleInnerHTML );
11336				customListarStyle.prop( 'outerHTML', '' );
11337			}
11338		}
11339
11340		/* Reorder WP Job Manager fields */
11341
11342		var fieldsetDOM = '';
11343		var fieldsetContent = '';
11344
11345		$( '.fieldset-job_business_use_hours' ).each( function () {
11346			if ( $( '.fieldset-job_description' ).length ) {
11347				fieldsetDOM = $( this );
11348				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11349				fieldsetDOM.prop( 'outerHTML', '' );
11350				$( '.fieldset-job_description' ).after( fieldsetContent );
11351			}
11352		} );
11353
11354		$( '.fieldset-job_business_use_custom_excerpt' ).each( function () {
11355			if ( $( '.fieldset-job_description' ).length ) {
11356				fieldsetDOM = $( this );
11357				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11358				fieldsetDOM.prop( 'outerHTML', '' );
11359				$( '.fieldset-job_description' ).after( fieldsetContent );
11360			}
11361		} );
11362
11363		$( '.fieldset-job_business_custom_excerpt' ).each( function () {
11364			if ( $( '.fieldset-job_business_use_custom_excerpt' ).length ) {
11365				fieldsetDOM = $( this );
11366				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11367				fieldsetDOM.prop( 'outerHTML', '' );
11368				$( '.fieldset-job_business_use_custom_excerpt' ).after( fieldsetContent );
11369			}
11370		} );
11371
11372		$( '.fieldset-job_business_use_products' ).each( function () {
11373			if ( $( '.fieldset-job_business_products_label' ).length ) {
11374				fieldsetDOM = $( this );
11375				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11376				fieldsetDOM.prop( 'outerHTML', '' );
11377				$( '.fieldset-job_business_products_label' ).before( fieldsetContent );
11378			}
11379		} );
11380
11381		$( '.fieldset-job_business_use_catalog' ).each( function () {
11382			if ( $( '.fieldset-job_business_catalog_label' ).length ) {
11383				fieldsetDOM = $( this );
11384				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11385				fieldsetDOM.prop( 'outerHTML', '' );
11386				$( '.fieldset-job_business_catalog_label' ).before( fieldsetContent );
11387			}
11388		} );
11389
11390		$( '.fieldset-job_business_use_booking' ).each( function () {
11391			if ( $( '.fieldset-job_business_booking_label' ).length ) {
11392				fieldsetDOM = $( this );
11393				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11394				fieldsetDOM.prop( 'outerHTML', '' );
11395				$( '.fieldset-job_business_booking_label' ).before( fieldsetContent );
11396			}
11397		} );
11398
11399		$( '.fieldset-job_business_use_catalog_documents' ).each( function () {
11400			if ( $( '.fieldset-job_business_document_1_title' ).length ) {
11401				fieldsetDOM = $( this );
11402				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11403				fieldsetDOM.prop( 'outerHTML', '' );
11404				$( '.fieldset-job_business_document_1_title' ).before( fieldsetContent );
11405			}
11406		} );
11407
11408		$( '.fieldset-job_business_use_catalog_external' ).each( function () {
11409			if ( $( '.fieldset-job_business_document_1_title_external' ).length ) {
11410				fieldsetDOM = $( this );
11411				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11412				fieldsetDOM.prop( 'outerHTML', '' );
11413				$( '.fieldset-job_business_document_1_title_external' ).before( fieldsetContent );
11414			}
11415		} );
11416
11417		$( '.fieldset-job_business_use_social_networks' ).each( function () {
11418			if ( $( '.fieldset-company_facebook' ).length ) {
11419				fieldsetDOM = $( this );
11420				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11421				fieldsetDOM.prop( 'outerHTML', '' );
11422				$( '.fieldset-company_facebook' ).before( fieldsetContent );
11423			}
11424		} );
11425
11426		$( '.fieldset-job_business_use_external_links' ).each( function () {
11427			if ( $( '.fieldset-company_external_link_1' ).length ) {
11428				fieldsetDOM = $( this );
11429				fieldsetContent = fieldsetDOM.prop( 'outerHTML' );
11430				fieldsetDOM.prop( 'outerHTML', '' );
11431				$( '.fieldset-company_external_link_1' ).before( fieldsetContent );
11432			}
11433		} );
11434
11435		
11436
11437		/* xxx */
11438		
11439		
11440		
11441		
11442		
11443		
11444
11445		/* xxx*/
11446		
11447		
11448		
11449		
11450		
11451		
11452		
11453		
11454
11455		/* xxxx */ 
11456		
11457		
11458		
11459		
11460		
11461		
11462		
11463		
11464		
11465		
11466		
11467		
11468		
11469		
11470		
11471		
11472		
11473		
11474		
11475		
11476		
11477		
11478		
11479		
11480		
11481		
11482		
11483		
11484		
11485		
11486		
11487		
11488		
11489		
11490		
11491		
11492		
11493		
11494		
11495		
11496		
11497		
11498		
11499		
11500		
11501		
11502		
11503		
11504		
11505		
11506		
11507		
11508		
11509		
11510		
11511		
11512		
11513		
11514		
11515		
11516		
11517		
11518
11519		if ( theBody.hasClass( 'single-job_listing' ) ) {
11520			updateOperatingHoursAndAvailability();
11521		}
11522
11523		if ( viewport().width < 378 ) {
11524			$( '.listar-term-description' ).each( function () {
11525				$( this ).prop( 'outerHTML', '' );
11526			} );
11527		}
11528
11529		if ( singleContent.length <= 1 ) {
11530			theBody.addClass( 'listar-post-without-content' );
11531		}
11532
11533		if ( 2 === singleContent.length && viewport().width > 480 ) {
11534			if ( singleContent.eq( 0 ).height() < 45 ) {
11535				if ( 0 === $( '.listar-single-tags' ).length ) {
11536					theBody.addClass( 'listar-fix-single-post-section' );
11537				}
11538			}
11539		}
11540
11541		/* xxxx */
11542		if ( singleContent.length >
11542 1 && singleheaderBackgroundWrapper.length ) {
11543			elemToTest = $( '.listar-single-content > *' ).eq( 0 );
11544
11545			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11546				theBody.addClass( 'listar-shrink-single-header-background' );
11547			}
11548		}
11549
11550		if ( singleContent.length > 2 && singleheaderBackgroundWrapper.length ) {
11551			elemToTest = $( '.listar-single-content > *' ).eq( 1 );
11552
11553			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11554				elemPosition   = getElemDistance( elemToTest );
11555				headerPosition = getElemDistance( $( '.listar-post-content-header-background-wrapper' ).eq( 0 ) );
11556				diffHeaderPosition = elemPosition - headerPosition;
11557
11558				if ( diffHeaderPosition < 200 && diffHeaderPosition !== 0 ) {
11559					theBody.addClass( 'listar-shrink-single-header-background' );
11560				}
11561			}
11562		}
11563
11564		if ( singleContent.length > 3 && singleheaderBackgroundWrapper.length ) {
11565			elemToTest = $( '.listar-single-content > *' ).eq( 2 );
11566
11567			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11568				elemPosition   = getElemDistance( elemToTest );
11569				headerPosition = getElemDistance( $( '.listar-post-content-header-background-wrapper' ).eq( 0 ) );
11570				diffHeaderPosition = elemPosition - headerPosition;
11571
11572				if ( diffHeaderPosition < 200 && diffHeaderPosition !== 0 ) {
11573					theBody.addClass( 'listar-shrink-single-header-background' );
11574				}
11575			}
11576		}
11577
11578		if ( singleContent.length > 4 && singleheaderBackgroundWrapper.length ) {
11579			elemToTest = $( '.listar-single-content > *' ).eq( 3 );
11580
11581			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11582				elemPosition   = getElemDistance( elemToTest );
11583				headerPosition = getElemDistance( $( '.listar-post-content-header-background-wrapper' ).eq( 0 ) );
11584				diffHeaderPosition = elemPosition - headerPosition;
11585
11586				if ( diffHeaderPosition < 200 && diffHeaderPosition !== 0 ) {
11587					theBody.addClass( 'listar-shrink-single-header-background' );
11588				}
11589			}
11590		}
11591
11592		if ( singleContent.length > 5 && singleheaderBackgroundWrapper.length ) {
11593			elemToTest = $( '.listar-single-content > *' ).eq( 4 );
11594
11595			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11596				elemPosition   = getElemDistance( elemToTest );
11597				headerPosition = getElemDistance( $( '.listar-post-content-header-background-wrapper' ).eq( 0 ) );
11598				diffHeaderPosition = elemPosition - headerPosition;
11599
11600				if ( diffHeaderPosition < 200 && diffHeaderPosition !== 0 ) {
11601					theBody.addClass( 'listar-shrink-single-header-background' );
11602				}
11603			}
11604		}
11605
11606		if ( singleContent.length > 6 && singleheaderBackgroundWrapper.length ) {
11607			elemToTest = $( '.listar-single-content > *' ).eq( 5 );
11608
11609			if ( elemToTest.hasClass( 'alignwide' ) || elemToTest.hasClass( 'alignfull' ) ) {
11610				elemPosition   = getElemDistance( elemToTest );
11611				headerPosition = getElemDistance( $( '.listar-post-content-header-background-wrapper' ).eq( 0 ) );
11612				diffHeaderPosition = elemPosition - headerPosition;
11613
11614				if ( diffHeaderPosition < 200 && diffHeaderPosition !== 0 ) {
11615					theBody.addClass( 'listar-shrink-single-header-background' );
11616				}
11617			}
11618		}
11619
11620		$( '.single-job_listing .job_listing > section:last-child' ).removeClass( 'listar-section-no-padding-bottom' );
11621
11622		checkFillerButtonBlog();
11623
11624		$( '#sbi_mod_error' ).each( function () {
11625			$( this ).append( '<br/><p class="listar-error-sbi-caps"><b>' + listarLocalizeAndAjax.clickHere + '</b></p>' );
11626			$( this ).append( '<a class="listar-error-sbi-admin-link" href="' + listarSiteURL + '/wp-admin/admin.php?page=sb-instagram-feed' + '" target="_blank"></a>' );
11627		} );
11628
11629		pageBGColor = pageBGColor.replace( 'rgb(', '' ).replace( ')', '' );
11630		pageBGColor = pageBGColor.split( ',' );
11631
11632		if ( tooLightColor( pageBGColor, 250 ) ) {
11633			theBody.addClass( 'listar-empty-background-color' );
11634		}
11635
11636		/* Fix for WP Instant Feeds (Instagram) plugin */
11637
11638		if ( 'undefined' !== typeof wpMyInstagramVars ) {
11639			setTimeout( function () {
11640				fixInstagramFeed();
11641			}, 3000 );
11642		}
11643
11644		captureCurrentViewportHeight();
11645
11646		executeAfterLoad();
11647
11648		fixPopupHeights();
11649
11650		/* General events *********************************************/                
11651
11652                /* Disables iphone viewport zoom when showing virtual keyboard */
11653
11654                theBody.on( 'click touch mousedown touchmove touchstart mouseenter change', 'input, textarea, .select2-search__field, .select2-search, .select2-search--inline, .select2-selection--multiple', function (){
11655                        var inputElem = $( this );
11656
11657                        if ( isMobile() ) {
11658                                inputElem.addClass( 'listar-forced-font-size' );
11659
11660                                inputElem.find( 'input, textarea' ).each( function () {
11661                                        $( this ).addClass( 'listar-forced-font-size' );
11662                                } );
11663
11664                                setTimeout( function () {
11665                                        inputElem.removeClass( 'listar-forced-font-size' );
11666
11667                                        inputElem.find( 'input, textarea' ).each( function () {
11668                                                $( this ).removeClass( 'listar-forced-font-size' );
11669                                        } );
11670                                }, 500 );
11671                        }
11672                } );
11673				
11674		$( theBody ).on( 'click', '.listar-booking-nav-next', function ( e ) {
11675			e.preventDefault();
11676			e.stopPropagation();
11677
11678			$( '.listar-booking-slide.current' ).each( function () {
11679				$( this ).removeClass( 'current' ).addClass( 'hidden' );
11680
11681				if ( $( this ).next().length ) {
11682					$( this ).next().addClass( 'current' ).removeClass( 'hidden' );
11683				} else {
11684					$( this ).parent().find( '.listar-booking-slide' ).eq( 0 ).addClass( 'current' ).removeClass( 'hidden' );
11685				}
11686			} );
11687		} );
11688				
11689		$( theBody ).on( 'click', '.listar-booking-nav-prev', function ( e ) {
11690			e.preventDefault();
11691			e.stopPropagation();
11692
11693			$( '.listar-booking-slide.current' ).each( function () {
11694				$( this ).removeClass( 'current' ).addClass( 'hidden' );
11695
11696				if ( $( this ).prev().length ) {
11697					$( this ).prev().addClass( 'current' ).removeClass( 'hidden' );
11698				} else {
11699					$( this ).parent().find( '.listar-booking-slide:last-child' ).addClass( 'current' ).removeClass( 'hidden' );
11700				}
11701			} );
11702		} );
11703		
11704		$( theBody ).on( 'click', '.listar-rich-media-add-item', function ( e ) {
11705			e.preventDefault();
11706			e.stopPropagation();
11707
11708			richMediaFieldsetAppend();
11709			mediaLengthVerification();
11710		} );
11711		
11712		$( theBody ).on( 'click', '.listar-more-regions-button-widget', function ( e ) {
11713			e.preventDefault();
11714			e.stopPropagation();
11715			
11716			forceTermClick = true;
11717			
11718			populateTermPopups( 'regions' );
11719			resetOwlCarousel( $( '.listar-listing-regions-popup .listar-carousel-loop.listar-use-carousel' ) );
11720			initOwlCarousel( $( '.listar-listing-regions-popup .listar-carousel-loop.listar-use-carousel' ) );
11721			stopScrolling( 1 );
11722
11723			$( '.listar-listing-regions-popup' ).addClass( 'listar-showing-regions' ).css( { left : 0, opacity : 1 } );
11724		} );
11725		
11726		$( theBody ).on( 'click', '.listar-more-categories-button-widget', function ( e ) {
11727			e.preventDefault();
11728			e.stopPropagation();
11729			
11730			forceTermClick = false;
11731
11732			populateTermPopups( 'categories' );
11733			resetOwlCarousel( $( '.listar-listing-categories-popup .listar-carousel-loop.listar-use-carousel' ) );
11734			initOwlCarousel( $( '.listar-listing-categories-popup .listar-carou
11734sel-loop.listar-use-carousel' ) );
11735			stopScrolling( 1 );
11736
11737			$( '.listar-listing-categories-popup' ).addClass( 'listar-showing-categories' ).css( { left : 0, opacity : 1 } );
11738		} );
11739
11740		$( theBody ).on( 'click', 'a', function ( e ) {
11741			if ( $( this )[0].hasAttribute( 'href' ) ) {
11742				var linkHref = $( this ).attr( 'href' );
11743
11744				if ( linkHref.indexOf( '#' ) >=0 ) {
11745					var linkAnchor = linkHref.split( '#' );
11746					linkAnchor = linkAnchor[1];
11747					checkLinkAnchor( linkAnchor, e );
11748				}
11749			}
11750		} );
11751
11752		$( theBody ).on( 'click', '.listar-get-geolocated', function ( e ) {
11753			e.preventDefault();
11754			e.stopPropagation();
11755
11756			var geoBt = $( this );
11757
11758			isNearestMeReload = true;
11759
11760			geoBt.removeClass( 'fa-scrubber' ).addClass( 'fa-circle-notch fa-spin' );
11761
11762			setTimeout( function () {
11763				setTimeout( function () {
11764					geoBt.removeClass( 'fa-circle-notch fa-spin' ).addClass( 'fa-scrubber' );
11765				}, 6000 );
11766
11767				var tempTest = tryNearestMePopup( true );
11768
11769				nearestHash = geoBt.parents( 'article' ).attr( 'id' );
11770
11771				if ( true === tempTest[0] ) {
11772					$( '.listar-submit-geolocation-data' ).each( function () {
11773						$( this )[0].click();
11774					} );
11775				}
11776			}, 1000 );
11777		} );
11778
11779		theBody.on( 'click', '.listar-submit-geolocation-data', function ( e ) {
11780			e.preventDefault();
11781			e.stopPropagation();
11782
11783			$( '#listar-geolocation-form input.required' ).each( function () {
11784				if ( '' === $( this ).val() || undefined === $( this ).val() ) {
11785					$( this ).addClass( 'listar-empty-required-field' );
11786				} else {
11787					$( this ).removeClass( 'listar-empty-required-field' );
11788				}
11789			} );
11790
11791			if ( 0 === $( '#listar-geolocation-form input.listar-empty-required-field' ).length ) {
11792
11793				$( this ).prop( 'innerHTML', $( this ).attr( 'data-loading-text' ) );
11794
11795				/* Start the conclusive AJAX request to save user geolocated data in PHP session */
11796
11797				var geoAddress = $( '#listar_geolocated_data_address' ).val();
11798				var geoNumber = $( '#listar_geolocated_data_number' ).val();
11799				var geoRegion = $( '#listar_geolocated_data_region' ).val();
11800				var geoCountry = $( '#listar_geolocated_data_country' ).val();
11801				var geoLat = $( '#listar_geolocated_data_latitude' ).val();
11802				var geoLng = $( '#listar_geolocated_data_longitude' ).val();
11803
11804				geoAddress = 'string' === typeof geoAddress ? geoAddress : '';
11805				geoNumber = 'string' === typeof geoNumber ? geoNumber : '';
11806				geoRegion = 'string' === typeof geoRegion ? geoRegion : '';
11807				geoCountry = 'string' === typeof geoCountry ? geoCountry : '';
11808				geoLat = 'string' === typeof geoLat ? geoLat : '';
11809				geoLng = 'string' === typeof geoLng ? geoLng : '';
11810				
11811				saveGeolocationDetails( geoLat, geoLng, geoAddress, geoNumber, geoRegion, geoCountry, 'address-save' );
11812			}
11813		} );
11814
11815		theBody.on( 'click', '.listar-listing-phone a, .listar-listing-mobile a', function ( e ) {
11816			var outerPhoneData = $( this ).prop( 'outerHTML' );
11817
11818			if ( outerPhoneData.indexOf( '1231234567' ) >= 0 ) {
11819				if ( outerPhoneData.indexOf( 'wa.me' ) >= 0 ) {
11820					setTimeout( function () {
11821						alert( listarLocalizeAndAjax.testingDemoPhone );
11822					}, 100 );
11823				} else {
11824					alert( listarLocalizeAndAjax.testingDemoPhone );
11825				}
11826			}
11827		} );
11828
11829		theBody.on( 'focus click', '.listar-listing-search-input-field', function () {
11830			isBrowsingSearchMenu = true;
11831
11832			var searchMenu = $( this ).parents( '.listar-hero-search-wrapper' ).find( '.listar-is-search-menu' );
11833
11834			searchMenu.each( function () {
11835				$( this ).removeClass( 'hidden' );
11836				$( '.listar-search-categories.listar-categories-fixed-bottom' ).addClass( 'hidden' );
11837
11838				var compensateScroll = 110;
11839				var compensateScrollDevice = viewport().width < 500 ? -40 : 0;
11840				var compensationLogged = 150;
11841
11842				if ( theBody.hasClass( 'listar-user-not-logged' ) ) {
11843					compensationLogged = 120;
11844				}
11845
11846				$( '.listar-search-popup .listar-hero-section-title' ).addClass( 'listar-reduce-hero-title' );
11847
11848				if ( ! avoidSearchScroll ) {
11849					htmlAndBody.stop().animate( { scrollTop : ( $( this ).offset().top - compensateScroll + compensateScrollDevice - compensationLogged ) }, 200);
11850				}
11851			} );
11852
11853			setTimeout( function () {
11854				isBrowsingSearchMenu = false;
11855			}, 350 );
11856		} );
11857
11858		theBody.on( 'click', '.listar-listing-card .listar-floating-card-icons-h, .listar-listing-card .listar-floating-card-icons-h *, .listar-listing-card .listar-trending-icon', function ( e ) {
11859			e.preventDefault();
11860			e.stopPropagation();
11861
11862			$( this ).parents( '.listar-card-content' ).find( '.listar-card-link' ).each( function () {
11863				$( this )[0].click();
11864			} );
11865		} );
11866
11867		theBody.on( 'click', '.listar-trending-flag-single.listar-trending-icon', function ( e ) {
11868			e.preventDefault();
11869			e.stopPropagation();
11870		} );
11871
11872		theBody.on( 'click', '.listar-search-highlight-tip-inner', function () {
11873			$( this ).parents( '.listar-hero-search-wrapper' ).find( '.listar-listing-search-input-field' ).each( function () {
11874				$( this )[0].click();
11875				$( this )[0].focus();
11876			} );
11877		} );
11878
11879
11880		/*xxx */
11881		loadingClick = true;
11882		
11883
11884		theBody.on( 'click', '.listar-listing-search-menu-wrapper, .listar-listing-search-menu-wrapper *', function () {
11885			if ( ! preventReclick ) {
11886				isBrowsingSearchMenu = true;
11887				preventReclick = true;
11888
11889				setTimeout( function () {
11890					preventReclick = false;
11891					isBrowsingSearchMenu = false;
11892				}, 350 );
11893			}
11894		} );
11895
11896		$( theBody ).on( 'click', function () {
11897			setTimeout( function () {
11898				if ( ! isBrowsingSearchMenu ) {
11899					ajaxSerchNoResults();
11900					unhideSearchMenu();
11901					hideListingSearchMenu();
11902
11903				}
11904			}, 30 );
11905		} );
11906
11907		theBody.on( 'click', '.listar-submit-claim', function ( e ) {
11908			e.preventDefault();
11909			e.stopPropagation();
11910
11911			$( '#listar-claim-form textarea.required' ).each( function () {
11912				if ( dataMinimumClaimTextChars > 0 && requiredClaimCharsField.length ) {
11913					var missingClaimTextChars = parseInt( $( '.listar-claim-missing-chars' ).prop( 'innerHTML' ), 10 );
11914
11915					if ( 0 !== missingClaimTextChars ) {
11916						$( this ).addClass( 'listar-empty-required-field' );
11917					} else {
11918						$( this ).removeClass( 'listar-empty-required-field' );
11919					}
11920				} else {
11921					$( this ).removeClass( 'listar-empty-required-field' );
11922				}
11923			} );
11924
11925			if ( 0 === $( '#listar-claim-form textarea.listar-empty-required-field' ).length ) {
11926
11927				$( this ).prop( 'innerHTML', $( this ).attr( 'data-loading-text' ) );
11928
11929				/* Start the conclusive AJAX request to save data in PHP session */
11930
11931				sendClaimVerificationText();
11932			}
11933		} );
11934
11935		theBody.on( 'click', '.listar-listing-regions-popup .listar-featured-listing-term-item', function ( e ) {
11936			if ( $( this ).parents( '.owl-stage' ).length ) {
11937				if ( $( this ).parents( '.owl-item' ).length ) {
11938
11939					if ( ! $( this ).parents( '.owl-item' ).hasClass( 'active' ) ) {
11940						disableRegionSelector = true;
11941
11942						setTimeout( function () {
11943							disableRegionSelector = false;
11944						}, 10 );
11945					}
11946				}
11947			}
11948		} );
11949
11950		/* Ajax search */
11951
11952		$( theBody ).on( 'click', '.listar-searching-ajax-results', function ( e ) {
11953			e.preventDefault();
11954			e.stopPropagation();
11955
11956			var elemen = $( this );
11957
11958			avoidSearchScroll = true;
11959
11960			$( '.listar-listing-search-input-field' ).val( '' );
11961
11962			elemen.parents( '.listar-hero-search-wrapper' ).find( '.listar-listing-search-input-field' ).each( function () {
11963				$( this )[0].click();
11964				$( this )[0].focus();
11965			} );
11966
11967			setTimeout( function () {
11968				avoidSearchScroll = false;
11969			}, 100 );
11970		} );
11971
11972		var doingAjaxSearch = false;
11973
11974		$( theBody ).on( 'keyup', '.listar-listing-search-input-field', function () {
11975			var ajaxSearchField = $( this );
11976			var theForm = $( this ).parents( 'form' );
11977
11978			var searchMenu = $( this ).parents( '.listar-hero-search-wrapper' ).find( '.listar-is-search-menu' );
11979			var ajaxMenu = $( this ).parents( '.listar-hero-search-wrapper' ).find( '.listar-ajax-search' );
11980
11981			if ( ! searchMenu.length ) {
11982				if ( ajaxMenu.length && '' !== ajaxSearchField.val() ) {
11983					$( '.listar-search-categories.listar-categories-fixed-bottom' ).addClass( 'hidden' );
11984
11985					setTimeout( function () {
11986						$( '.listar-search-categories.listar-categories-fixed-bottom' ).addClass( 'hidden' );
11987					}, 400 );
11988				} else {
11989					setTimeout( function () {
11990						$( '.listar-search-categories.listar-categories-fixed-bottom' ).removeClass( 'hidden' );
11991					}, 400 );
11992				}
11993			}
11994
11995			if ( ! doingAjaxSearch ) {
11996				doingAjaxSearch = true;
11997
11998				setTimeout( function () {
11999					var
12000						ajaxS = ajaxSearchField,
12001						ajaxPostType = theForm.find( 'input[name="post_type"]' ),
12002						ajaxSearchType = theForm.find( 'input[name="search_type"]' ),
12003						ajaxListingSort = theForm.find( 'input[name="listing_sort"]' ),
12004						ajaxExploreBy = theForm.find( 'input[name="explore_by"]' ),
12005						ajaxSelectedCountry = theForm.find( 'input[name="selected_country"]' ),
12006						ajaxSavedAddress = theForm.find( 'input[name="saved_address"]' ),
12007						ajaxSavedPostcode = theForm.find( 'input[name="saved_postcode"]' ),
12008						ajaxListingRegions = theForm.find( 'input[name="listing_regions"]' ),
12009						ajaxListingCategories = theForm.find( 'input[name="listing_categories"]' ),
12010						ajaxlistingAmenities = theForm.find( 'input[name="listing_amenities"]' );
12011
12012					/* Get values from fields */
12013
12014					if ( ajaxS.length ) {
12015						ajaxS.each( function () {
12016							ajaxS = $( this ).val();
12017						} );
12018
12019						if ( 'string' !== typeof ajaxS || undefined === ajaxS || 'undefined' === ajaxS || 'NaN' === ajaxS ) {
12020							ajaxS = '';
12021						}
12022					} else {
12023						ajaxS = '';
12024					}
12025
12026					if ( ajaxPostType.length ) {
12027						ajaxPostType.each( function () {
12028							ajaxPostType = $( this ).val();
12029						} );
12030
12031						if ( 'string' !== typeof ajaxPostType || undefined === ajaxPostType || 'undefined' === ajaxPostType || 'NaN' === ajaxPostType ) {
12032							ajaxPostType = '';
12033						}
12034					} else {
12035						ajaxPostType = '';
12036					}
12037
12038					if ( ajaxSearchType.length ) {
12039						ajaxSearchType.each( function () {
12040							ajaxSearchType = $( this ).val();
12041						} );
12042
12043						if ( 'string' !== typeof ajaxSearchType || undefined === ajaxSearchType || 'undefined' === ajaxSearchType || 'NaN' === ajaxSearchType ) {
12044							ajaxSearchType = '';
12045						}
12046					} else {
12047						ajaxSearchType = '';
12048					}
12049
12050					if ( ajaxListingSort.length ) {
12051						ajaxListingSort.each( function () {
12052							ajaxListingSort = $( this ).val();
12053						} );
12054
12055						if ( 'string' !== typeof ajaxListingSort || undefined === ajaxListingSort || 'undefined' === ajaxListingSort || 'NaN' === ajaxListingSort ) {
12056							ajaxListingSort = '';
12057						}
12058					} else {
12059						ajaxListingSort = '';
12060					}
12061
12062					if ( ajaxExploreBy.length ) {
12063						ajaxExploreBy.each( function () {
12064							ajaxExploreBy = $( this ).val();
12065						} );
12066
12067						if ( 'string' !== typeof ajaxExploreBy || undefined === ajaxExploreBy || 'undefined' === ajaxExploreBy || '
12067NaN' === ajaxExploreBy ) {
12068							ajaxExploreBy = '';
12069						}
12070					} else {
12071						ajaxExploreBy = '';
12072					}
12073
12074					if ( ajaxSelectedCountry.length ) {
12075						ajaxSelectedCountry.each( function () {
12076							ajaxSelectedCountry = $( this ).val();
12077						} );
12078
12079						if ( 'string' !== typeof ajaxSelectedCountry || undefined === ajaxSelectedCountry || 'undefined' === ajaxSelectedCountry || 'NaN' === ajaxSelectedCountry ) {
12080							ajaxSelectedCountry = '';
12081						}
12082					} else {
12083						ajaxSelectedCountry = '';
12084					}
12085
12086					if ( ajaxSavedAddress.length ) {
12087						ajaxSavedAddress.each( function () {
12088							ajaxSavedAddress = $( this ).val();
12089						} );
12090
12091						if ( 'string' !== typeof ajaxSavedAddress || undefined === ajaxSavedAddress || 'undefined' === ajaxSavedAddress || 'NaN' === ajaxSavedAddress ) {
12092							ajaxSavedAddress = '';
12093						}
12094					} else {
12095						ajaxSavedAddress = '';
12096					}
12097
12098					if ( ajaxSavedPostcode.length ) {
12099						ajaxSavedPostcode.each( function () {
12100							ajaxSavedPostcode = $( this ).val();
12101						} );
12102
12103						if ( 'string' !== typeof ajaxSavedPostcode || undefined === ajaxSavedPostcode || 'undefined' === ajaxSavedPostcode || 'NaN' === ajaxSavedPostcode ) {
12104							ajaxSavedPostcode = '';
12105						}
12106					} else {
12107						ajaxSavedPostcode = '';
12108					}
12109
12110					if ( ajaxListingRegions.length ) {
12111						ajaxListingRegions.each( function () {
12112							ajaxListingRegions = $( this ).val();
12113						} );
12114
12115						if ( 'string' !== typeof ajaxListingRegions || undefined === ajaxListingRegions || 'undefined' === ajaxListingRegions || 'NaN' === ajaxListingRegions ) {
12116							ajaxListingRegions = '';
12117						}
12118					} else {
12119						ajaxListingRegions = '';
12120					}
12121
12122					if ( ajaxListingCategories.length ) {
12123						ajaxListingCategories.each( function () {
12124							ajaxListingCategories = $( this ).val();
12125						} );
12126
12127						if ( 'string' !== typeof ajaxListingCategories || undefined === ajaxListingCategories || 'undefined' === ajaxListingCategories || 'NaN' === ajaxListingCategories ) {
12128							ajaxListingCategories = '';
12129						}
12130					} else {
12131						ajaxListingCategories = '';
12132					}
12133
12134					if ( ajaxlistingAmenities.length ) {
12135						ajaxlistingAmenities.each( function () {
12136							ajaxlistingAmenities = $( this ).val();
12137						} );
12138
12139						if ( 'string' !== typeof ajaxlistingAmenities || undefined === ajaxlistingAmenities || 'undefined' === ajaxlistingAmenities || 'NaN' === ajaxlistingAmenities ) {
12140							ajaxlistingAmenities = '';
12141						}
12142					} else {
12143						ajaxlistingAmenities = '';
12144					}
12145
12146					var testString = ajaxS.replace( /\s/g, '' );
12147
12148					if ( '' !== testString ) {
12149
12150						ajaxSerchingResults();
12151
12152						var contentDataURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/ajax-search/listar-search-ajax.php';
12153						var dataToSend = { send_data : '[{"type":"ajax-search"},{"s":"' + ajaxS + '"},{"post_type":"' + ajaxPostType + '"},{"search_type":"' + ajaxSearchType + '"},{"listing_sort":"' + ajaxListingSort + '"},{"explore_by":"' + ajaxExploreBy + '"},{"selected_country":"' + ajaxSelectedCountry + '"},{"saved_address":"' + ajaxSavedAddress + '"},{"saved_postcode":"' + ajaxSavedPostcode + '"},{"listing_regions":"' + ajaxListingRegions + '"},{"listing_categories":"' + ajaxListingCategories + '"},{"listing_amenities":"' + ajaxlistingAmenities + '"}]' };
12154
12155						$.ajax( {
12156							crossDomain: true,
12157							url: contentDataURL,
12158							type: 'POST',
12159							data: dataToSend,
12160							cache    : false,
12161							timeout  : 30000
12162
12163						} ).done( function ( response ) {
12164							if ( 'string' === typeof response ) {
12165								if ( response.indexOf( 'listar-has-ajax-posts' ) >= 0 ) {
12166									ajaxCleanOldSerchResults();
12167
12168									$( '.listar-ajax-search' ).addClass( 'listar-ajax-search-found-results' );
12169									$( '.listar-ajax-search ul' ).append( response.replace( '<span class="hidden listar-has-ajax-posts"></span>', '' ) );
12170								} else {
12171									ajaxSerchNoResults();
12172								}
12173							} else {
12174								ajaxSerchNoResults();
12175							}
12176						} ).fail( function( xhr, textStatus, errorThrown ) {
12177							//alert(xhr);
12178							//alert(textStatus);
12179							//alert(errorThrown);
12180							if ( $( '.listar-user-logged' ).length ) {
12181								//alert(32);
12182								//alert(xhr);
12183								//alert(textStatus);
12184								//alert(errorThrown);
12185							}
12186							ajaxSerchNoResults();
12187						} );
12188					} else {
12189						unhideSearchMenu();
12190					}
12191
12192					doingAjaxSearch = false;
12193				}, 300 );
12194			}
12195		} );
12196
12197		$( window ).on( 'resize', function () {
12198			resetElements( true );
12199			fixPopupHeights();
12200		} );		
12201
12202		/* Execute right after the first user interaction */
12203		/* Get updated nonce for login/register form with Ajax on the first user interaction */
12204
12205		theDocument.on( 'touchstart touchmove scroll mouseenter mousedown mousemove DOMMouseScroll mousewheel keyup', function () {
12206			if ( ! gotUpdatedNonce ) {
12207				firstUserEventHappened();
12208			}
12209		} );
12210
12211		/* Or, in case the page has been scrolled */
12212
12213		if( $( window ).scrollTop() ) {
12214			firstUserEventHappened();
12215		}
12216
12217		theBody.on( 'click', '.star', function() {
12218			$( this ).nextAll( '.star' ).removeClass( 'active' );
12219			$( this ).prevAll( '.star' ).removeClass( 'active' );
12220			$( this ).toggleClass( 'active' );
12221			$( this ).parent().find( 'input' ).attr( 'value', $( this ).attr( 'data-star-rating' ) );
12222		} );
12223
12224		theBody.on( 'click', '.listar-current-search-by', function ( e ) {
12225			e.preventDefault();
12226			e.stopPropagation();
12227
12228			var exploreByButton = $( this ).parents( 'form' ).find( '.listar-search-by-button' );
12229
12230			if ( exploreByButton.length ) {
12231				exploreByButton[0].click();
12232			}
12233
12234		} );
12235
12236		theBody.on( 'click', '.listar-clean-search-input-button', function ( e ) {
12237			e.preventDefault();
12238			e.stopPropagation();
12239
12240			var clickedButton = $( this );
12241
12242			$( '.listar-listing-search-input-field' ).val( '' );
12243
12244			setTimeout( function () {
12245				ajaxSerchNoResults();
12246				unhideSearchMenu();
12247				hideListingSearchMenu();
12248
12249				clickedButton.parents( 'form' ).find( '.listar-listing-search-input-field' )[0].focus();
12250			}, 50 );
12251
12252		} );
12253
12254		theBody.on( 'click', '.listar-clean-search-by-filters-button', function ( e ) {
12255			e.preventDefault();
12256			e.stopPropagation();
12257
12258			var clickedButton = $( this );
12259
12260			$( 'a[data-explore-by-type="' + listarLocalizeAndAjax.listarInitialExploreByOption + '"]' ).each( function () {
12261				$( this )[0].click();
12262			} );
12263
12264			$( '.listar-listing-regions-popup .listar-back-site' ).each( function () {
12265				$( this )[0].click();
12266			} );
12267
12268			setTimeout( function () {
12269				clickedButton.parents( 'form' ).find( '.listar-listing-search-input-field' )[0].focus();
12270			}, 50 );
12271		} );
12272		
12273		function forceNearestMePopup() {
12274			var newExploreByClass = 'listar-search-by-button ' + $( this ).attr( 'class' );
12275			var newExploreByPlaceholder = $( this ).attr( 'data-explore-by-placeholder' );
12276			var newExploreByTitle = $( this ).attr( 'data-explore-by-title' );
12277			var newExploreBySlug = $( this ).attr( 'data-explore-by-type' );
12278			var newExploreByOrder = $( this ).attr( 'data-explore-by-order' );
12279			var setFormFields = true;
12280			var hasUserLatitudeAndLongitude = false;
12281			var userLatitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
12282			var userLongitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
12283
12284			if ( userLatitudeField.length && userLongitudeField.length ) {
12285				if ( '' !== userLatitudeField.val() && '' !==  userLongitudeField.val() ) {
12286					hasUserLatitudeAndLongitude = true;
12287				}
12288			}
12289
12290			if ( ! hasUserLatitudeAndLongitude ) {
12291				setFormFields = false;
12292
12293				stopScrolling( 1 );
12294
12295				enableNearestMeDataEditor();
12296
12297				searchByInputToFocus = $( this ).parents( 'form' ).find( '.listar-listing-search-input-field' );
12298
12299				setTimeout( function () {
12300					$( '.listar-search-by-popup' ).addClass( 'listar-showing-search-by' ).css( { left : 0, opacity : 1 } );
12301				}, 510 );
12302
12303				$( '.listar-general-explore-by-options' ).addClass( 'hidden' );
12304				$( '.listar-nearest-me-loading' ).removeClass( 'hidden' );
12305				$( '.listar-nearest-me-loading-icon' ).addClass( 'listar-is-geolocating' );
12306
12307				userGeolocationMethod1();
12308			} else {
12309				$( '.listar-search-by-popup .listar-back-site' )[0].click();
12310			}
12311
12312			if ( setFormFields ) {
12313				if ( 'shop_products' === newExploreBySlug ) {
12314					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
12315					$( '.listar-all-regions-button' ).css( { display : 'none' } );
12316				} else if ( 'blog' === newExploreBySlug ) {
12317					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
12318					$( '.listar-all-regions-button' ).css( { display : 'none' } );
12319				} else {
12320					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( 'listing' );
12321					$( '.listar-all-regions-button' ).css( { display : '' } );
12322				}
12323
12324				$( '.listar-search-by-button' ).attr( 'class', newExploreByClass ).attr( 'data-explore-by-type', newExploreBySlug );
12325
12326				$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( newExploreByOrder );
12327				$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( newExploreBySlug );
12328				$( '.listar-listing-search-input-field' ).attr( 'placeholder', newExploreByPlaceholder );
12329				$( '.listar-current-search-by' ).prop( 'innerHTML', newExploreByTitle );
12330			}
12331		}
12332
12333		theBody.on( 'click', '.listar-search-by-options-wrapper > a', function ( e ) {
12334			e.preventDefault();
12335			e.stopPropagation();
12336
12337			var newExploreByClass = 'listar-search-by-button ' + $( this ).attr( 'class' );
12338			var newExploreByPlaceholder = $( this ).attr( 'data-explore-by-placeholder' );
12339			var newExploreByTitle = $( this ).attr( 'data-explore-by-title' );
12340			var newExploreBySlug = $( this ).attr( 'data-explore-by-type' );
12341			var newExploreByOrder = $( this ).attr( 'data-explore-by-order' );
12342			var setFormFields = true;
12343
12344			if ( 'nearest_me' !== newExploreBySlug ) {
12345				$( '.listar-search-by-popup .listar-back-site' )[0].click();
12346
12347				setTimeout( function () {
12348					if ( false !== searchByInputToFocus ) {
12349						searchByInputToFocus[0].focus();
12350
12351						var inputVal = searchByInputToFocus.val();
12352
12353						if ( 'string' === typeof inputVal && '' !== inputVal ) {
12354							searchByInputToFocus.keyup();
12355						}
12356					}
12357				}, 50 );
12358			} else {
12359				forceNearestMePopup();
12360			}
12361
12362			if ( setFormFields ) {
12363				if ( 'shop_products' === newExploreBySlug ) {
12364					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
12365					$( '.listar-all-regions-button' ).css( { display : 'none' } );
12366				} else if ( 'blog' === newExploreBySlug ) {
12367					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( newExploreBySlug );
12368					$( '.listar-all-regions-button' ).css( { display : 'none' } );
12369				} else {
12370					$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( 'listing' );
12371					$( '.listar-all-regions-button' ).css( { display : '' } );
12372				}
12373
12374				$( '.listar-search-by-button' ).attr( 'class', newExploreByClass ).attr( 'data-explore-by-type', newExploreBySlug );
12375
12376				$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( newExploreByOrder );
12377				$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( newExploreBySlug );
12378				$( '.listar-listing-search-input-field' ).attr( 'placeholder', newExploreByPlaceholder );
12379				$( '.listar-current-search-by' ).prop( 'innerHTML', newExploreByTitle );
12380			}
12381		} );
12382
12383		theBody.on( 'click', '.listar-edit-nearest-me-data', function ( e ) {
12384			e.preventDefault();
12385			e.stopPropagation();
12386
12387			var exploreByButton = $( this ).parents( '.listar-search-by-options-wrapper' ).find( 'a[data-explore-by-order="nearest_me"]' );
12388
12389			var newExploreByClass = 'listar-search-by-button ' + exploreByButton.attr( 'class' );
12390			var newExploreByPlaceholder = exploreByButton.attr( 'data-explore-by-placeholder' );
12391			var newExploreByTitle = exploreByButton.attr( 'data-explore-by-title' );
12392			var newExploreBySlug = 'nearest_me';
12393			var newExploreByOrder = 'nearest_me';
12394
12395			$( 'input[name="' + listarLocalizeAndAjax.searchTypeTranslation + '"]' ).val( 'listing' );
12396			$( '.listar-all-regions-button' ).css( { display : '' } );
12397
12398			$( '.listar-search-by-button' ).attr( 'class', newExploreByClass ).attr( 'data-explore-by-type', newExploreBySlug );
12399
12400			$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( newExploreByOrder );
12401			$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( newExploreBySlug );
12402			$( '.listar-listing-search-input-field' ).attr( 'placeholder', newExploreByPlaceholder );
12403			$( '.listar-current-search-by' ).prop( 'innerHTML', newExploreByTitle );
12404
12405			$( '.listar-nearest-me-main' ).addClass( 'hidden' );
12406			$( '.listar-nearest-me-secondary' ).removeClass( 'hidden' );
12407		} );
12408
12409		theBody.on( 'click', '.listar-reset-nearest-me-data', function ( e ) {
12410			e.preventDefault();
12411			e.stopPropagation();
12412
12413			var defaultExploreByButton = $( this ).parents( '.listar-search-by-options-wrapper' ).find( 'a[data-explore-by-type="' + listarLocalizeAndAjax.listarInitialExploreByOption + '"]' );
12414
12415			$( '#listar_geolocated_data_address' ).val( '' );
12416			$( '#listar_geolocated_data_number' ).val( '' );
12417			$( '#listar_geolocated_data_region' ).val( '' );
12418			$( '#listar_geolocated_data_country' ).val( '' );
12419			$( '#listar_geolocated_data_latitude' ).val( '' );
12420			$( '#listar_geolocated_data_longitude' ).val( '' );
12421
12422			var newExploreByClass = 'listar-search-by-button ' + defaultExploreByButton.attr( 'class' );
12423			var newExploreByPlaceholder = defaultExploreByButton.attr( 'data-explore-by-placeholder' );
12424			var newExploreByTitle = defaultExploreByButton.attr( 'data-explore-by-title' );
12425			var newExploreBySlug = defaultExploreByButton.attr( 'data-explore-by-type' );
12426			var newExploreByOrder = defaultExploreByButton.attr( 'data-explore-by-order' );
12427
12428			$( '.listar-search-by-button' ).attr( 'class', newExploreByClass ).attr( 'data-explore-by-type', newExploreBySlug );
12429
12430			$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( newExploreByOrder );
12431			$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( newExploreBySlug );
12432			$( '.listar-listing-search-input-field' ).attr( 'placeholder', newExploreByPlaceholder );
12433			$( '.listar-current-search-by' ).prop( 'innerHTML', newExploreByTitle );
12434
12435			enableNearestMeDataEditor();
12436
12437			/* Do Ajax reset */
12438			saveGeolocationDetails( '-', '-', '-', '-', '-', '-', 'reset' );
12439		} );
12440
12441		$( theBody ).on( 'click', '.listar-report-listing, .listar-listing-header-report-button', function ( e ) {
12442			e.preventDefault();
12443			e.stopPropagation();
12444
12445			if ( $( this ).hasClass( 'listar-logged-users-can-complaint' ) && theBody.hasClass( 'listar-user-not-logged' ) ) {
12446				$( '.listar-user-buttons-responsive .listar-user-login' ).trigger( 'click' );
12447			} else {
12448				stopScrolling( 1 );
12449				$( '.listar-report-popup' ).addClass( 'listar-showing-report' ).css( { left : 0, opacity : 1 } );
12450			}
12451		} );
12452
12453		theBody.on( 'click', '#listar-primary-menu li a', function ( e ) {
12454			if ( $( this ).find( 'b' ).length ) {
12455				if ( isMobile() || viewport().width < 768 ) {
12456					var thisElem = this;
12457
12458					e.preventDefault();
12459					e.stopPropagation();
12460
12461					$( '#listar-primary-menu li a.dropdown-toggle' ).each( function () {
12462						if ( ! $( this ).parent().find( thisElem ).length ) {
12463							$( this ).attr( 'aria-expanded', 'false' );
12464							$( this ).parent().removeClass( 'open' );
12465						}
12466					} );
12467
12468					if ( 'true' === $( this ).attr( 'aria-expanded' ) ) {
12469						$( this ).attr( 'aria-expanded', 'false' );
12470						$( this ).parent().removeClass( 'open' );
12471					} else {
12472						$( this ).attr( 'aria-expanded', 'true' );
12473						$( this ).parent().addClass( 'open' );
12474					}
12475				}
12476			} else {
12477				e.stopPropagation();
12478			}
12479		} );
12480
12481		$( '.dropdown li' ).on( 'mouseenter mouseleave', function () {
12482			if ( $( 'ul', this ).length ) {
12483				var	elm = $( 'ul:first', this );
12484				var
12485					dropW = elm.width(),
12486					viewportWidth = viewport().width,
12487					dropL = elm.offset(),
12488					isEntirelyVisible;
12489
12490				dropL = dropL.left;
12491				isEntirelyVisible = ( dropL + dropW <= viewportWidth );
12492
12493				if ( ! isEntirelyVisible ) {
12494					$( this ).addClass( 'listar-screen-edge' );
12495				}
12496			}
12497		} );
12498
12499
12500
12501		theBody.on( 'click', '.listar-show-recommended-appointment-tools a', function ( e ) {
12502			e.preventDefault();
12503			e.stopPropagation();
12504
12505			$( this ).prop( 'outerHTML', '' );
12506			$( '.listar-appointment-recommended-services' ).removeClass( 'hidden' );
12507		} );
12508
12509		theBody.on( 'click', '.listar-references-navigation', function ( e ) {
12510			e.preventDefault();
12511			e.stopPropagation();
12512
12513			var countDistances = $( this ).parent().find( '.listar-location-references-wrapper div' ).length;
12514			var currentCarouselOrder = 1;
12515			var translate = 0;
12516
12517			if ( ! $( this ).parent()[0].hasAttribute( 'data-current-carousel-order' ) ) {
12518				$( this ).parent().attr( 'data-current-carousel-order', currentCarouselOrder );
12519			} else {
12520				currentCarouselOrder = parseInt( $( this ).parent().attr( 'data-current-carousel-order' ), 10 );
12521			}
12522
12523			if ( currentCarouselOrder < countDistances ) {
12524				currentCarouselOrder++;
12525				translate = -100 * ( currentCarouselOrder - 1 );
12526
12527			} else {
12528				currentCarouselOrder = 1;
12529				translate = 0;
12530			}
12531
12532			$( this ).parent().attr( 'data-current-carousel-order', currentCarouselOrder );
12533
12534			$( this ).parent().find( '.listar-location-references-wrapper' ).css( {
12535				'-webkit-transform' : 'translate(' + translate + '%,0)',
12536				'-moz-transform'    : 'translate(' + translate + '%,0)',
12537				'-ms-transform'     : 'translate(' + translate + '%,0)',
12538				'-o-transform'      : 'translate(' + translate + '%,0)',
12539				'transform'         : 'translate(' + translate + '%,0)'
12540			} );
12541
12542		} );
12543
12544		/* Show invisible items for dropdown menus inside main menu */
12545		$( theBody ).on( 'click', '.listar-menu-has-invisible-items .listar-plus-drop-down-menu', function () {
12546			if( $( this ).parent().find( '>li:nth-last-child(2)' ).hasClass( 'listar-last-item-being-displayed' ) ) {
12547
12548				/* End of the list is being displayed, revert to initial */
12549
12550				$( this ).parent().find( '>li' ).removeClass( 'listar-hidde-menu-item' ).removeClass( 'listar-show-menu-item' );
12551				$( this ).parent().find( '>li:nth-last-child(2)' ).removeClass( 'listar-last-item-being-displayed' );
12552
12553				if ( parseInt( $( this ).parent().innerHeight(), 10 ) > parseInt ( $( this ).parent().attr( 'data-last-height' ), 10 ) ) {
12554					$( this ).parent().css( { 'min-height' : $( this ).parent().innerHeight() } );
12555					$( this ).parent().attr( 'data-last-height',  $( this ).parent().innerHeight() );
12556				}
12557			} else if( ! $( this ).parent().find( '.listar-hidde-menu-item' ).length ) {
12558
12559				$( this ).parent().css( { 'min-height' : $( this ).parent().innerHeight() } );
12560				$( this ).parent().attr( 'data-last-height', $( this ).parent().innerHeight() );
12561
12562				/* This is the initial display of menu items, show the second list of items */
12563
12564				$( this ).parent().find( '>li:nth-child(-n+13)' ).removeClass( 'listar-show-menu-item' ).addClass( 'listar-hidde-menu-item' );
12565				$( this ).parent().find( '>li:nth-child(n+14)' ).removeClass( 'listar-hide-menu-item' ).addClass( 'listar-show-menu-item' );
12566				$( this ).parent().find( '>li:nth-child(n+27)' ).removeClass( 'listar-show-menu-item' ).addClass( 'listar-hide-menu-item' );
12567
12568				$( this ).parent().find( '>li:last-child' ).removeClass( 'listar-show-menu-item' ).removeClass( 'listar-hide-menu-item' );
12569				$( this ).parent().find( '>li.listar-show-menu-item' ).last().addClass( 'listar-last-item-being-displayed' );
12570
12571				if ( parseInt( $( this ).parent().innerHeight(), 10 ) > parseInt ( $( this ).parent().attr( 'data-last-height' ), 10 ) ) {
12572					$( this ).parent().css( { 'min-height' : $( this ).parent().innerHeight() } );
12573					$( this ).parent().attr( 'data-last-height',  $( this ).parent().innerHeight() );
12574				}
12575			} else {
12576
12577				/* List display was changed at least once proceed here until all items be displayed */
12578
12579				var lastIndexBeingDisplayed = $( this ).parent().find( '.listar-last-item-being-displayed' ).index();
12580
12581				$( this ).parent().find( '>li:nth-child(-n+' + ( lastIndexBeingDisplayed + 1 ) + ')' ).removeClass( 'listar-show-menu-item' ).addClass( 'listar-hidde-menu-item' );
12582				$( this ).parent().find( '>li:nth-child(n+' + ( lastIndexBeingDisplayed + 2 ) + ')' ).removeClass( 'listar-hide-menu-item' ).addClass( 'listar-show-menu-item' );
12583				$( this ).parent().find( '>li:nth-child(n+' + ( lastIndexBeingDisplayed + 2 + 13 ) + ')' ).removeClass( 'listar-show-menu-item' ).addClass( 'listar-hide-menu-item' );
12584
12585				$( this ).parent().find( '>li:last-child' ).removeClass( 'listar-show-menu-item' ).removeClass( 'listar-hide-menu-item' );
12586				$( this ).parent().find( '>li.listar-last-item-being-displayed' ).removeClass( 'listar-last-item-being-displayed' );
12587				$( this ).parent().find( '>li.listar-show-menu-item' ).last().addClass( 'listar-last-item-being-displayed' );
12588
12589				if ( parseInt( $( this ).parent().innerHeight(), 10 ) > parseInt ( $( this ).parent().attr( 'data-last-height' ), 10 ) ) {
12590					$( this ).parent().css( { 'min-height' : $( this ).parent().innerHeight() } );
12591					$( this ).parent().attr( 'data-last-height',  $( this ).parent().innerHeight() );
12592				}
12593			}
12594		} );
12595
12596		theBody.on( 'mousedown', '.listar-listing-gallery', function () {
12597			lastDragPosition = listingGallery.scrollLeft();
12598		} );
12599
12600		theBody.on( 'click', '.listar-listing-gallery a', function () {
12601			if ( 0 !== lastDragPosition - listingGallery.scrollLeft() ) {
12602				$( '#lightbox, #lightboxOverlay' ).stop().hide();
12603			}
12604		} );
12605
12606		theBody.on( 'click', 'a[rel="lightbox"], a[data-lightbox]', function () {
12607			$( '.lb-closeContainer' ).css( { opacity : 0 } );
12608
12609			setTimeout( function () {
12610				$( '.lb-closeContainer' ).animate( { opacity : 1 } );
12611			}, 3000 );
12612		} );
12613
12614		$( '.listar-hero-header .listar-search-submit' ).on( {
12615			'mouseenter' : function () {
12616				$( '.listar-hero-search-icon' ).addClass( 'hover' );
12617			},
12618			'mouseleave' : function () {
12619				$( '.listar-hero-search-icon' ).removeClass( 'hover' );
12620			}
12621		} );
12622
12623		$( '.listar-hero-search .search-form' ).on( 'submit', function ( e ) {
12624			$( this ).find( 'input[data-name="s"]' ).attr( 'name', 's' );
12625
12626			var searchTypeButton = $( this ).find( '.listar-search-by-button' );
12627			var hasUserLatitudeLongitude = true;
12628
12629			if ( searchTypeButton.length ) {
12630				if ( searchTypeButton.attr( 'class' ).indexOf( 'fa-scrubber' ) >= 0 ) {
12631					hasUserLatitudeLongitude = startGeolocationPopup( false );
12632				}
12633			}
12634
12635			if ( ! hasUserLatitudeLongitude ) {
12636				e.preventDefault();
12637				e.stopPropagation();
12638			}
12639		} );
12640
12641		$( '.listar-posts-column .listar-column-toggle-visibility' ).on( 'click', function () {
12642			if ( $( '.listar-posts-column' ).width() > 30 ) {
12643				$( '.listar-hero-search, .listar-posts-column' ).addClass( 'listar-hide-featured' );
12644				$( '.listar-hero-search' ).siblings( '.listar-search-categories' ).addClass( 'listar-hide-featured' );
12645			} else {
12646				$( '.listar-hero-search, .listar-posts-column' ).removeClass( 'listar-hide-featured' );
12647				$( '.listar-hero-search' ).siblings( '.listar-search-categories' ).removeClass( 'listar-hide-featured' );
12648			}
12649		} );
12650
12651		catScrollQtd = 0;
12652		catCondition2 = true;
12653
12654		if ( $( '.listar-search-categories .listar-listing-categories' ).length ) {
12655			catScrollQtd = $( '.listar-search-categories .listar-listing-categories' )[0].scrollHeight;
12656		}
12657
12658		/* Clicking out of .listar-search-categories */
12659		theBody.on( 'click', '*', function () {
12660			var catCondition1 = $( '.listar-search-categories' ).hasClass( 'listar-showing-more-cats' );
12661
12662			if ( $( this ).hasClass( 'listar-search-categories' ) ) {
12663				catCondition2 = false;
12664			}
12665
12666			if ( catCondition1 && catCondition2 ) {
12667				$( '.listar-less-categories' ).trigger( 'click' );
12668			}
12669
12670			setTimeout( function () {
12671				catCondition2 = true;
12672			}, 200 );
12673		} );
12674
12675		/*
12676		 * Clear cache - customized.
12677		 */
12678		theBody.on( 'click', '#wp-admin-bar-autoptimize-default li', function ( e ) {
12679
12680			if ( 'undefined' !== typeof listarSiteURL ) {
12681				if ( 'wp-admin-bar-autoptimize-delete-cache' === $( this ).attr( 'id' ) ) {
12682					e.preventDefault();
12683					e.stopPropagation();
12684
12685					var modal_loading = $( '<div class="autoptimize-loading listar-clean-cache-loading"></div>' );
12686					var cleanCacheURL = listarSiteURL + '/wp-content/plugins/listar-addons/inc/clear-cache.php';
12687					var completedCleaning = false;
12688					var buttonToRepeat = $( this );
12689					var dumbData = { my_data : '[{"dumb_data":"dumb_data"}]' };
12690
12691					if ( 0 === $( '.autoptimize-loading.listar-clean-cache-loading' ).length ) {
12692						modal_loading.appendTo( 'body' ).show();
12693					}
12694
12695					$.ajax( {
12696						crossDomain: true,
12697						url      : cleanCacheURL,
12698						type     : 'POST',
12699						cache    : false,
12700						data     : dumbData,
12701						timeout  : 30000
12702					} ).done( function ( response ) {
12703						if ( 'Done' === response ) {
12704							modal_loading.remove();
12705							completedCleaning = true;
12706						}
12707					} );
12708
12709					setTimeout( function () {
12710						if ( ! completedCleaning ) {
12711							buttonToRepeat[0].click();
12712						}
12713					}, 30000 );
12714				}
12715			}
12716		} );
12717
12718		$( '.listar-mobile-circle-bg-links' ).on( {
12719			'mouseenter' : function () {
12720				$( '.listar-mobile-circle-bg-img img' ).addClass( 'hover' );
12721			},
12722			'mouseleave' : function () {
12723				$( '.listar-mobile-circle-bg-img img' ).removeClass( 'hover' );
12724			}
12725		} );
12726
12727		theBody.on( 'click', '.listar-full-dimming-overlay', function () {
12728			if ( '0' === $( '#listar-primary-menu' ).css( 'left' ).replace( /[^-\d\.]/g, '' ) ) {
12729				$( toggler ).trigger( 'click' );
12730			}
12731		} );
12732
12733		theBody.on( 'click', '.listar-map-button-coordinates-link', function ( e ) {
12734			e.preventDefault();
12735			e.stopPropagation();
12736
12737			$( '.listar-map-button-coordinates' ).removeClass( 'hidden' );
12738			$( this ).prop( 'outerHTML', '' );
12739		} );
12740
12741		$( '#site-navigation' ).on( 'click', toggler, function () {
12742			var selected = $( this ).hasClass( 'listar-primary-navbar-mobile-visible' );
12743
12744			if ( viewport().width < 768 ) {
12745				if ( $( '.listar-login-popup.listar-showing-login' ).length ) {
12746					$( '.listar-user-buttons-responsive .listar-user-login' ).trigger( 'click' );
12747				}
12748
12749				if ( theBody.hasClass( 'admin-bar' ) ) {
12750					htmlAndBody.stop().animate( { scrollTop : '0' }, 500 );
12751				}
12752
12753				if ( ! selected ) {
12754					stopScrolling( 1 );
12755					$( '.listar-full-dimming-overlay' ).css( { display : 'block' } ).stop().animate( { opacity : 0.88 }, { duration : 1000 } );
12756
12757					if ( theBody.hasClass( 'listar-user-not-logged' ) ) {
12758						$( navigationWrapper ).css( {
12759							left : 'auto',
12760							right : 0
12761						} );
12762					} else {
12763						$( navigationWrapper ).css( {
12764							right : 'auto',
12765							left : 0
12766						} );
12767					}
12768				} else {
12769					if ( '0px' !== $( '.listar-search-popup' ).css( 'left' ) && '0px' !== $( '.listar-login-popup' ).css( 'left' ) && '0px' !== $( '.listar-booking-popup' ).css( 'left' ) && '0px' !== $( '.listar-social-share-popup' ).css( 'left' ) && '0px' !== $( '.listar-review-popup' ).css( 'left' ) && '0px' !== $( '.listar-listing-categories-popup' ).css( 'left' ) && '0px' !== $( '.listar-listing-regions-popup' ).css( 'left' ) && '0px' !== $( '.listar-search-by-popup' ).css( 'left' ) && '0px' !== $( '.listar-report-popup' ).css( 'left' )  && '0px' !== $( '.listar-claim-popup' ).css( 'left' ) && '0px' !== $( '.listar-settings-popup' ).css( 'left' ) ) {
12770						stopScrolling( 0 );
12771					}
12772
12773					$( '.listar-full-dimming-overlay' ).stop().animate( { opacity : 0 }, { duration : 1000, complete : function () {
12774						$( '.listar-full-dimming-overlay' ).css( { display : 'none' } );
12775					} } );
12776
12777					$( navigationWrapper ).css( {
12778						right : 'auto',
12779						left : '0'
12780					} );
12781				}// End if().
12782
12783				if ( $( '#listar-primary-menu' ).length ) {
12784					$( '#listar-primary-menu' ).stop().animate( {
12785						left : selected ? menuNegativeWidth : '0px'
12786					} );
12787				}
12788
12789				if ( $( '.listar-mobile-menu-header-background' ).length ) {
12790					$( '.listar-mobile-menu-header-background' ).stop().animate( {
12791						left : selected ? menuNegativeWidth : '0px'
12792					} );
12793				}
12794
12795				if ( $( '#listar-navbar-height-col' ).length ) {
12796					$( '#listar-navbar-height-col' ).stop().animate( {
12797						left : selected ? menuNegativeWidth : '-2px'
12798					} );
12799				}
12800
12801				if ( $( pageWrapper ).length ) {
12802					$( pageWrapper ).stop().animate( {
12803						left : selected ? '0px' : menuWidth
12804					} );
12805				}
12806
12807				$( this ).toggleClass( 'listar-primary-navbar-mobile-visible', ! selected );
12808				$( '#listar-primary-menu' ).toggleClass( 'listar-primary-navbar-mobile-visible' );
12809				$( '.navbar, body, .navbar-header' ).toggleClass( 'listar-primary-navbar-mobile-visible' );
12810			}// End if().
12811		} );
12812
12813		circleEvents();
12814
12815		theBody.on( 'click', '.listar-header-search-button, .listar-search-pop-button, .listar-search-query span', function ( e ) {
12816			e.preventDefault();
12817			e.stopPropagation();
12818
12819			if ( ! $( '.listar-search-popup' ).hasClass( 'listar-showing-search' ) ) {
12820				stopScrolling( 1 );
12821
12822				if ( $( '.navbar.navbar-inverse.listar-primary-navbar-mobile-visible, body.listar-primary-navbar-mobile-visible' ).length ) {
12823					$( '.navbar-toggle' ).eq( 0 ).trigger( 'click' );
12824				}
12825
12826				$( '.listar-search-popup' ).addClass( 'listar-showing-search' ).css( { left : 0, opacity : 1 } );
12827				$( '.listar-review-popup' ).css( { left : '-105%', opacity : 0.99 } );
12828				$( '.listar-social-share-popup' ).css( { left : '-105%', opacity : 0.99 } );
12829				$( '.listar-listing-categories-popup' ).css( { left : '-105%', opacity : 0.99 } );
12830				$( '.listar-listing-regions-popup' ).css( { left : '-105%', opacity : 0.99 } );
12831				$( '.listar-search-by-popup' ).css( { left : '-105%', opacity : 0.99 } );
12832				$( '.listar-report-popup' ).css( { left : '-105%', opacity : 0.99 } );
12833				$( '.listar-claim-popup' ).css( { left : '-105%', opacity : 0.99 } );
12834				$( '.listar-settings-popup' ).css( { left : '-105%', opacity : 0.99 } );
12835				$( '.listar-login-popup' ).css( { zIndex : 998 } ).css( { left : '-105%', opacity : 0.99 } );
12836				$( '.listar-booking-popup' ).css( { zIndex : 998 } ).css( { left : '-105%', opacity : 0.99 } );
12837
12838				setTimeout( function () {
12839					$( '.listar-review-popup' ).removeClass( 'listar-showing-review' );
12840					$( '.listar-social-share-popup' ).removeClass( 'listar-showing-review' );
12841					$( '.listar-login-popup' ).removeClass( 'listar-showing-login' );
12842					$( '.listar-booking-popup' ).removeClass( 'listar-showing-booking' );
12843					$( '.listar-listing-categories-popup' ).removeClass( 'listar-showing-categories' );
12844					$( '.listar-listing-regions-popup' ).removeClass( 'listar-showing-regions' );
12845					$( '.listar-search-by-popup' ).removeClass( 'listar-showing-search-by' );
12846					$( '.listar-report-popup' ).removeClass( 'listar-showing-report' );
12847					$( '.listar-claim-popup' ).removeClass( 'listar-showing-claim' );
12848					$( '.listar-settings-popup' ).removeClass( 'listar-showing-settings' );
12849				}, 500 );
12850
12851				if ( ! $( '.listar-is-search-menu' ).length && ( ! isMobile() || ( 0 === $( '.listar-listing-categories a' ).length && 0 === $( '.listar-regions-list.listar-has-more-regions' ).length ) ) ) {
12852					$( '.listar-search-popup input[data-name="s"]' ).focus();
12853				}
12854
12855			} else {
12856				stopScrolling( 0 );
12857				$( '.listar-search-popup' ).css( { left : '-105%', opacity : 0.99 } );
12858
12859				setTimeout( function () {
12860					$( '.listar-search-popup' ).removeClass( 'listar-showing-search' );
12861				}, 500 );
12862			}
12863		} );
12864
12865		/* Switch forms login/register */
12866
12867		$( 'a.listar-reset-pass-button' ).on( 'click', function ( e ) {
12868			e.preventDefault();
12869			e.stopPropagation();
12870
12871			$( '.listar-login-popup' ).removeClass( 'listar-showing-register-form' ).addClass( 'listar-showing-recover-pass-form' );
12872			$( '.listar-login, .listar-register' ).fadeOut( 0 );
12873			$( '.listar-reset-password' ).fadeIn( 0 );
12874			$( '.listar-login-form-link, .listar-register-form-link' ).removeClass( 'active' );
12875		} );
12876
12877		$( '.listar-login-form-link' ).on( 'click', function ( e ) {
12878			e.preventDefault();
12879			e.stopPropagation();
12880
12881			$( '.listar-login-popup' ).removeClass( 'listar-showing-register-form listar-showing-recover-pass-form' );
12882			$( '.listar-register, .listar-reset-password' ).fadeOut( 0 );
12883			$( '.listar-login' ).fadeIn( 0 );
12884			$( '.listar-register-form-link' ).removeClass( 'active' );
12885			$( '.listar-login-form-link' ).addClass( 'active' );
12886		} );
12887
12888		$( '.listar-register-form-link' ).on( 'click', function ( e ) {
12889			e.preventDefault();
12890			e.stopPropagation();
12891
12892			$( '.listar-login-popup' ).removeClass( 'listar-showing-recover-pass-form' ).addClass( 'listar-showing-register-form' );
12893			$( '.listar-login, .listar-reset-password' ).fadeOut( 0 );
12894			$( '.listar-register' ).fadeIn( 0 );
12895			$( '.listar-login-form-link' ).removeClass( 'active' );
12896			$( '.listar-register-form-link' ).addClass( 'active' );
12897		} );
12898
12899		$( theBody ).on( 'mouseenter', '[data-toggle="tooltip"]', function () {
12900			var thisElement = $( this );
12901
12902			if ( $.isFunction( $.fn.tooltip ) ) {
12903				if ( ! $( this )[0].hasAttribute( 'data-original-title' ) ) {
12904					$( this ).tooltip();
12905				}
12906
12907				$( '[data-toggle="tooltip"]' ).not( this ).tooltip( 'hide' );
12908				thisElement.tooltip( 'show' );
12909			}
12910		} );
12911
12912		$( theBody ).on( 'mouseleave', '[data-toggle="tooltip"]', function () {
12913			var thisElement = $( this );
12914
12915			if ( $.isFunction( $.fn.tooltip ) ) {
12916				thisElement.tooltip( 'hide' );
12917			}
12918		} );
12919
12920		$( theBody ).on( 'click', '.listar-listing-rating-anchor, .listar-listing-header-stars-button', function ( e ) {
12921			mobileCompensation = isMobile() ? 60 : 0;
12922			scrollToTarget = $( '.listar-listing-review' );
12923
12924			if ( scrollToTarget.length > 0 ) {
12925				e.preventDefault();
12926
12927				htmlAndBody.stop().animate( {
12928					scrollTop : scrollToTarget.offset().top - 340 + mobileCompensation
12929				}, 600 );
12930			}
12931
12932			$( this ).parents( '.listar-listing-header-menu-fixed' ).each( function () {
12933				$( this ).addClass( 'listar-hidden-fixed-button' );
12934			} );
12935		} );
12936
12937		theBody.on( 'click', '#accordion a[role="button"]', function ( e ) {
12938			if ( $( this ).parents( '.accordion-group' ).hasClass( 'listar-business-claim-accordion' ) ) {
12939
12940				if ( $( this ).hasClass( 'listar-claim-is-not-claimed' ) ) {
12941					if ( theBody.hasClass( 'listar-user-not-logged' ) ) {
12942						$( '.listar-user-login' ).eq( 0 ).each( function () {
12943							$( this )[0].click();
12944						} );
12945					} else {
12946						window.location.href = $( this ).attr( 'data-claim-url' );
12947					}
12948				}
12949
12950				e.preventDefault();
12951				e.stopPropagation();
12952			}
12953
12954			if ( $( this ).parents( '.accordion-group' ).hasClass( 'listar-business-booking-accordion' ) ) {
12955				var hasBookingPopupEnabled = verifyBookingPopup();
12956				var foundButton = false;
12957			
12958				if ( hasBookingPopupEnabled ) {
12959					e.preventDefault();
12960					e.stopPropagation();
12961					
12962					launchBookingPopup();
12963				} else {
12964					var thisElement = $( this );
12965					var wrapperBooking = $( this ).parents( '.accordion-group' ).find( '.panel-body' );
12966					var innerBooking = wrapperBooking.prop( 'innerHTML' );
12967
12968					/* Remove Acuity unwanted code */
12969					if ( innerBooking.indexOf( 'acuityscheduling.com/embed/button' ) >= 0 || innerBooking.indexOf( 'acuityscheduling.com/js/embed' ) >= 0 ) {
12970						wrapperBooking.find( 'iframe, script' ).each( function () {
12971							if ( $( this ).prop( 'outerHTML' ).indexOf( 'acuityscheduling.com/embed/button' ) >= 0 || $( this ).prop( 'outerHTML' ).indexOf( 'acuityscheduling.com/js/embed' ) >= 0 ) {
12972								$( this ).prop( 'outerHTML', '' );
12973								wrapperBooking = thisElement.parents( '.accordion-group' ).find( '.panel-body' );
12974								innerBooking = wrapperBooking.prop( 'innerHTML' );
12975							}
12976						} );
12977					}
12978
12979					/* For Booksy widget */
12980					if ( innerBooking.indexOf( 'booksy-widget-button' ) >= 0 ) {
12981						e.preventDefault();
12982						e.stopPropagation();
12983
12984						foundButton = true;
12985
12986						$( '.booksy-widget-button' )[0].click();
12987	
12988						var bookInterval = setInterval( function () {
12989							htmlAndBody.stop().animate( { scrollTop : 0 }, 0 );
12990						}, 5 );
12991
12992						setTimeout( function () {
12993							clearInterval( bookInterval );
12994						}, 1000 );
12995					}
12996
12997					/* For Resy widget */
12998					else if ( innerBooking.indexOf( 'data-resy-buttom' ) >= 0 || innerBooking.indexOf( 'resy.com/embed.js' ) >= 0 ) {
12999						$( 'span[data-resy-buttom]' ).each( function () {
13000							e.preventDefault();
13001							e.stopPropagation();
13002
13003							foundButton = true;
13004							$( this )[0].click();
13005						} );
13006					}
13007
13008					/* The ZOMATO API Calendar Button */
13009					else if ( innerBooking.indexOf( 'listar-zomato-button' ) >= 0 ) {
13010						e.preventDefault();
13011						e.stopPropagation();
13012
13013						foundButton = true;
13014						$( '.listar-zomato-button' )[0].click();
13015					}
13016
13017					/* The Bookafy Button */
13018					else if ( $( '.listar-bookafy-button' ).length ) {
13019						e.preventDefault();
13020						e.stopPropagation();
13021
13022						var bookafyButton = $( '.listar-bookafy-button' );
13023
13024						if ( '#' === bookafyButton.attr( 'href' ) ) {
13025							bookafyButton.removeAttr( 'href' );
13026						}
13027
13028						cancelAccordionPropagation = true;
13029						resetAccordionPropagation();
13030
13031						foundButton = true;
13032						$( '.listar-bookafy-button' )[0].click();
13033
13034						var bookIntervalB = setInterval( function () {
13035							htmlAndBody.stop();
13036						}, 5 );
13037
13038						setTimeout( function () {
13039							clearInterval( bookIntervalB );
13040						}, 1000 );
13041					}
13042
13043					/* The SimplyBook Button */
13044					else if ( $( '.simplybook-widget-button' ).length ) {
13045						e.preventDefault();
13046						e.stopPropagation();
13047
13048						var simplyButton = $( '.simplybook-widget-button' );
13049
13050						cancelAccordionPropagation = true;
13051						resetAccordionPropagation();
13052
13053						foundButton = true;
13054						simplyButton[0].click();
13055					}
13056
13057					/* The 'bookingjs-calendar' class comes from Timekit API */
13058					else if ( -1 === innerBooking.indexOf( '<iframe' ) && -1 === innerBooking.indexOf( 'bookingjs-calendar' ) ) {
13059						wrapperBooking.find( 'a' ).eq( 0 ).each( function () {
13060							e.preventDefault();
13061							e.stopPropagation();
13062
13063							foundButton = true;
13064
13065							$( this ).attr( 'target', '_blank' );
13066							$( this )[0].click();
13067						} );
13068
13069						if ( ! foundButton && -1 === innerBooking.indexOf( 'http' ) && innerBooking.indexOf( '.booksy.com' ) >= 0 ) {
13070							var booksyLink = '';
13071							var splitContent = innerBooking.replace( '<p class="listar-accordion-wrapper-paragraph">', '' ).replace( '</p>', '' ).trim().split( ' ' );
13072
13073							for ( var i = 0; i < splitContent.length; i++ ) {
13074								if ( splitContent[ i ].indexOf( '.booksy.com' ) ) {
13075									booksyLink = 'https://' + splitContent[ i ];
13076									break;
13077								}
13078							}
13079
13080							if ( '' !== booksyLink ) {
13081								wrapperBooking.prop( 'innerHTML', booksyLink );
13082								innerBooking = wrapperBooking.prop( 'innerHTML' );
13083							}
13084
13085						}
13086
13087						if ( ! foundButton && -1 !== innerBooking.indexOf( 'http' ) ) {
13088							e.preventDefault();
13089							e.stopPropagation();
13090
13091							foundButton = true;
13092
13093							/* This seems a URL (string) */
13094							/* Reference: https://stackoverflow.com/a/5002161/7765298 */
13095							var cleanText = innerBooking.replace( /<\/?[^>]+(>|$)/g, '' );
13096
13097							/* Remove all white spaces */
13098							/* Reference: https://stackoverflow.com/a/6623263/7765298 */
13099							cleanText = cleanText.replace( /\s/g, '' );
13100
13101							wrapperBooking.prop( 'innerHTML', '<a class="listar-dynamic-booking-url" target="_blank" href="' + cleanText + '"></a>' );
13102
13103							$( '.listar-dynamic-booking-url' )[0].click();
13104						}
13105					}
13106
13107					if ( ! foundButton ) {
13108						wrapperBooking.parents( '.listar-bookings-wrapper' ).removeClass( 'hidden' );
13109					}
13110
13111					$( '.listar-business-booking-accordion iframe[src*="acuityscheduling.com/"]' ).each( function () {
13112						$( this ).parents( '.listar-business-booking-accordion' ).addClass( 'listar-is-acuity' );
13113					} );
13114				}
13115			}
13116		} );
13117
13118		theBody.on( 'click', '.listar-listing-not-claimed', function ( e ) {
13119			if ( theBody.hasClass( 'listar-user-not-logged' ) ) {
13120				$( '.listar-user-login' ).eq( 0 ).each( function () {
13121					$( this )[0].click();
13122				} );
13123			} else {
13124				e.preventDefault();
13125				e.stopPropagation();
13126
13127				window.location.href = $( this ).attr( 'data-claim-url' );
13128			}
13129		} );
13130
13131		theBody.on( 'click', '#accordion .collapsed', function () {
13132
13133			if ( ! cancelAccordionPropagation ) {
13134
13135				if ( didInitialAccordionClick ) {
13136					var previousAccordion = $( this ).parents( '.accordion-group' ).prevAll();
13137					var compensateScroll = 0;
13138					var compensateScrollDevice = 0;
13139					var compensateNotOpenedBefore = 32;
13140					var compensationLogged = 150;
13141
13142					if ( theBody.hasClass( 'listar-user-not-logged' ) ) {
13143						compensationLogged = 120;
13144					}
13145
13146					previousAccordion.each( function () {
13147						if ( $( this ).find( '.panel-heading a' )[0].hasAttribute( 'aria-expanded' ) ) {
13148							if ( 'true' === $( this ).find( '.panel-heading a' ).attr( 'aria-expanded' ) ) {
13149								compensateScroll = $( this ).find( '.panel-body' ).height();
13150								compensateNotOpenedBefore = 0;
13151							}
13152						}
13153					} );
13154
13155					if ( $( this )[0].hasAttribute( 'aria-expanded' ) ) {
13156						if ( 'false' === $( this ).attr( 'aria-expanded' ) ) {
13157							htmlAndBody.stop().animate( { scrollTop : ( $( this ).offset().top - compensateScroll + compensateScrollDevice - compensationLogged + compensateNotOpenedBefore ) }, 200);
13158						}
13159					}
13160				}
13161			} else {
13162				resetAccordionPropagation();
13163			}
13164		} );
13165
13166		theBody.on( 'click', '.listar-listing-header-message-button', function ( e ) {
13167			mobileCompensation = isMobile() ? -70 : 0;
13168			scrollToTarget = $( '.listar-private-message-accordion a' );
13169
13170			if ( scrollToTarget.length > 0 ) {
13171				e.preventDefault();
13172
13173				if ( scrollToTarget.hasClass( 'collapsed' ) ) {
13174					scrollToTarget[0].click();
13175				}
13176
13177				setTimeout( function () {
13178					htmlAndBody.stop().animate( {
13179						scrollTop : scrollToTarget.offset().top - 120 + mobileCompensation
13180					}, 600 );
13181				}, 200 );
13182			}
13183
13184			$( this ).parents( '.listar-listing-header-menu-fixed' ).each( function () {
13185				$( this ).addClass( 'listar-hidden-fixed-button' );
13186			} );
13187		} );
13188
13189		theBody.on( 'click', '.listar-listing-header-coordinates-button', function ( e ) {
13190			mobileCompensation = isMobile() ? -70 : 0;
13191			scrollToTarget = $( '.listar-map-button-coordinates-wrapper' );
13192
13193			if ( scrollToTarget.length > 0 ) {
13194				e.preventDefault();
13195
13196				var coorsButton = scrollToTarget.find( 'a' );
13197
13198				if ( coorsButton.length ) {
13199					coorsButton[0].click();
13200				}
13201
13202				setTimeout( function () {
13203					htmlAndBody.stop().animate( {
13204						scrollTop : scrollToTarget.offset().top - 145 + mobileCompensation
13205					}, 600 );
13206				}, 200 );
13207			}
13208
13209			$( this ).parents( '.listar-listing-header-menu-fixed' ).each( function () {
13210				$( this ).addClass( 'listar-hidden-fixed-button' );
13211			} );
13212		} );
13213
13214		theBody.on( 'click', '.listar-listing-header-references-button', function ( e ) {
13215			mobileCompensation = isMobile() ? -70 : 0;
13216			scrollToTarget = $( '.listar-listing-more-info-accordion a' );
13217
13218			if ( scrollToTarget.length > 0 ) {
13219				e.preventDefault();
13220
13221				if ( scrollToTarget.hasClass( 'collapsed' ) ) {
13222					scrollToTarget[0].click();
13223				}
13224
13225				setTimeout( function () {
13226					htmlAndBody.stop().animate( {
13227						scrollTop : scrollToTarget.offset().top - 120 + mobileCompensation
13228					}, 600 );
13229				}, 200 );
13230			}
13231
13232			$( this ).parents( '.listar-listing-header-menu-fixed' ).each( function () {
13233				$( this ).addClass( 'listar-hidden-fixed-button' );
13234			} );
13235		} );
13236
13237		theBody.on( 'click', '.listar-listing-header-catalog-button', function ( e ) {
13238			mobileCompensation = isMobile() ? -70 : 0;
13239			scrollToTarget = $( '.listar-listing-menu-accordion a' );
13240
13241			if ( scrollToTarget.length > 0 ) {
13242				e.preventDefault();
13243
13244				if ( scrollToTarget.hasClass( 'collapsed' ) ) {
13245					scrollToTarget[0].click();
13246				}
13247
13248				setTimeout( function () {
13249					htmlAndBody.stop().animate( {
13250						scrollTop : scrollToTarget.offset().top - 120 + mobileCompensation
13251					}, 600 );
13252				}, 200 );
13253			}
13254
13255			$( this ).parents( '.listar-listing-header-menu-fixed' ).each( function () {
13256				$( this ).addClass( 'listar-hidden-fixed-button' );
13257			} );
13258		} );
13259
13260		theBody.on( 'click', '.listar-listing-header-hours-button, .listar-operating-hours-quick-button', function ( e ) {
13261			mobileCompensation = isMobile() ? -70 : 0;
13262			scrollToTarget = $( '.listar-business-hours-accordion a' );
13263
13264			if ( scrollToTarget.length > 0 ) {
13265				e.preventDefault();
13266
13267				if ( scrollToTarget.hasClass( 'collapsed' ) ) {
13268					scrollToTarget[0].click();
13269				}
13270
13271				setTimeout( function () {
13272					htmlAndBody.stop().animate( {
13273						scrollTop : scrollToTarget.offset().top - 120 + mobileCompensation
13274					}, 600 );
13275				}, 200 );
13276			}
13277
13278			$( '.listar-listing-header-menu-fixed' ).each( function () {
13279				$( this ).addClass( 'listar-hidden-fixed-button' );
13280			} );
13281		} );
13282
13283		theBody.on( 'click', '.listar-listing-header-booking-button, .listar-booking-quick-button', function ( e ) {			
13284			var hasBookingPopupEnabled = verifyBookingPopup();
13285			
13286			if ( hasBookingPopupEnabled ) {
13287				launchBookingPopup();
13288			} else {
13289
13290				mobileCompensation = isMobile() ? -70 : 0;
13291				scrollToTarget = $( '.listar-business-booking-accordion a' );
13292
13293				if ( scrollToTarget.length > 0 ) {
13294					e.preventDefault();
13295
13296					if ( scrollToTarget.hasClass( 'collapsed' ) ) {
13297						scrollToTarget[0].click();
13298					}
13299
13300					setTimeout( function () {
13301						htmlAndBody.stop().animate( {
13302							scrollTop : scrollToTarget.offset().top - 120 + mobileCompensation
13303						}, 600 );
13304					}, 200 );
13305				}
13306
13307				$( '.listar-listing-header-menu-fixed' ).each( function () {
13308					$( this ).addClass( 'listar-hidden-fixed-button' );
13309				} );
13310			}
13311		} );
13312
13313		theBody.on( 'click', '.listar-write-review a', function ( e ) {
13314
13315			// Cancel comment reply form, if currently visible between comments.
13316			$( '.listar-review-second-col #respond[style="display: block;"] > h3 > small > #cancel-comment-reply-link' ).each( function () {
13317				if ( 0 === $( this ).parents( '.listar-comments-form-wrapper' ).length ) {
13318					$( this )[0].click();
13319				}
13320			} );
13321
13322			if ( ! ( theBody.hasClass( 'listar-no-addons' ) && theBody.hasClass( 'listar-user-not-logged' ) ) ) {
13323				e.preventDefault();
13324				e.stopPropagation();
13325
13326				if ( theBody.hasClass( 'listar-user-not-logged' ) && theBody.hasClass( 'listar-guests-cannot-review' ) ) {
13327					$( '.listar-user-buttons-responsive .listar-user-login' ).trigger( 'click' );
13328					theBody.addClass( 'listar-login-before-review' );
13329				} else {
13330					stopScrolling( 1 );
13331					$( '.listar-review-popup .panel-body' ).prop( 'innerHTML', $( '#respond' ).prop( 'outerHTML' ) );
13332					$( '.listar-review-popup #respond #comment_parent' ).attr( 'value', 0 );
13333					$( '.listar-review-popup' ).addClass( 'listar-showing-review' ).css( { left : 0, opacity : 1 } );
13334				}
13335			}
13336		} );
13337
13338		theBody.on( 'click', '.listar-bookmark-it', function ( e ) {
13339
13340			if ( ! ( theBody.hasClass( 'listar-no-addons' ) && theBody.hasClass( 'listar-user-not-logged' ) ) ) {
13341				e.preventDefault();
13342				e.stopPropagation();
13343
13344				var listingID = parseInt( $( this ).attr( 'data-listing-id' ), 10 );
13345				var userID = parseInt( $( this ).attr( 'data-user-id' ), 10 );
13346
13347				if ( theBody.hasClass( 'listar-user-not-logged' ) || 0 === userID ) {
13348					$( '.listar-user-buttons-responsive .listar-user-login' ).trigger( 'click' );
13349				} else {
13350
13351					if ( $( this ).parent().hasClass( 'listar-bookmarked-item' ) ) {
13352						handleBookmarks( $( this ), listingID, userID, 'remove'  );
13353					} else {
13354						handleBookmarks( $( this ), listingID, userID, 'add'  );
13355					}
13356				}
13357			}
13358		} );
13359
13360		theBody.on( 'click', '.listar-review-popup .listar-back-site', function () {
13361			stopScrolling( 0 );
13362
13363			theBody.removeClass( 'listar-login-before-review' );
13364			$( '.listar-review-popup' ).css( { left : '-105%', opacity : 0.99 } );
13365
13366			setTimeout( function () {
13367				$( '.listar-review-popup' ).removeClass( 'listar-showing-review' );
13368			}, 500 );
13369		} );
13370
13371		theBody.on( 'click', '.listar-listing-share-button', function ( e ) {
13372			e.preventDefault();
13373			e.stopPropagation();
13374			stopScrolling( 1 );
13375
13376			$( '.listar-social-share-popup' ).addClass( 'listar-showing-share' ).css( { left : 0, opacity : 1 } );
13377		} );
13378
13379		theBody.on( 'click', '.listar-social-share-popup .listar-back-site', function () {
13380			stopScrolling( 0 );
13381
13382			$( '.listar-social-share-popup' ).css( { left : '-105%', opacity : 0.99 } );
13383
13384			setTimeout( function () {
13385				$( '.listar-social-share-popup' ).removeClass( 'listar-showing-share' );
13386			}, 500 );
13387		} );
13388
13389		$( 'html' ).on( 'click', '.listar-user-not-logged .listar-user-login, .sign-in, .listar-user-not-logged .account-sign-in a, .listar-user-login-mobile, .listar-user-login-mobile a', function ( e ) {
13390			if ( ! theBody.hasClass( 'listar-no-addons' ) ) {
13391				e.preventDefault();
13392				e.stopPropagation();
13393
13394				if ( ! preventEvenCallStack2 ) {
13395
13396					preventEvenCallStack2 = true;
13397
13398					if ( $( '.navbar.navbar-inverse.listar-primary-navbar-mobile-visible, body.listar-primary-navbar-mobile-visible' ).length ) {
13399						$( '.navbar-toggle' ).eq( 0 ).trigger( 'click' );
13400					}
13401
13402					if ( ! $( '.listar-login-popup' ).hasClass( 'listar-showing-login' ) ) {
13403						stopScrolling( 1 );
13404
13405						$( '.listar-login-popup' ).addClass( 'listar-showing-login' ).css( { left : 0, opacity : 1 } );
13406						$( '.listar-booking-popup' ).css( { left : '-105%', opacity : 0.99 } );
13407						$( '.listar-review-popup' ).css( { left : '-105%', opacity : 0.99 } );
13408						$( '.listar-social-share-popup' ).css( { left : '-105%', opacity : 0.99 } );
13409						$( '.listar-listing-categories-popup' ).css( { left : '-105%', opacity : 0.99 } );
13410						$( '.listar-listing-regions-popup' ).css( { left : '-105%', opacity : 0.99 } );
13411						$( '.listar-search-by-popup' ).css( { left : '-105%', opacity : 0.99 } );
13412						$( '.listar-report-popup' ).css( { left : '-105%', opacity : 0.99 } );
13413						$( '.listar-claim-popup' ).css( { left : '-105%', opacity : 0.99 } );
13414						$( '.listar-settings-popup' ).css( { left : '-105%', opacity : 0.99 } );
13415						$( '.listar-search-popup' ).css( { zIndex : 998 } ).css( { left : '-105%', opacity : 0.99 } );
13416
13417						setTimeout( function () {
13418							$( '.listar-search-popup' ).removeClass( 'listar-showing-search' );
13419							$( '.listar-review-popup' ).removeClass( 'listar-showing-review' );
13420							$( '.listar-social-share-popup' ).removeClass( 'listar-showing-review' );
13421							$( '.listar-listing-categories-popup' ).removeClass( 'listar-showing-categories' );
13422							$( '.listar-listing-regions-popup' ).removeClass( 'listar-showing-regions' );
13423							$( '.listar-search-by-popup' ).removeClass( 'listar-showing-regions' );
13424							$( '.listar-report-popup' ).removeClass( 'listar-showing-report' );
13425							$( '.listar-claim-popup' ).removeClass( 'listar-showing-claim' );
13426							$( '.listar-settings-popup' ).removeClass( 'listar-showing-settings' );
13427						}, 500 );
13428					} else {
13429						stopScrolling( 0 );
13430
13431						$( '.listar-login-popup' ).css( { left : '-105%', opacity : 0.99 } );
13432
13433						setTimeout( function () {
13434							$( '.listar-login-popup' ).removeClass( 'listar-showing-login' );
13435						}, 500 );
13436					}
13437
13438					setTimeout( function () {
13439						preventEvenCallStack2 = false;
13440					}, 100 );
13441				}// End if().
13442			}// End if().
13443		} );
13444
13445		theBody.on( 'click', '.listar-login-popup .listar-back-site', function () {
13446			stopScrolling( 0 );
13447
13448			$( '.listar-login-popup' ).css( { left : '-105%', opacity : 0.99 } );
13449
13450			setTimeout( function () {
13451				$( '.listar-login-popup' ).removeClass( 'listar-showing-login' );
13452			}, 500 );
13453		} );
13454
13455		theBody.on( 'click', '.listar-booking-popup .listar-back-site', function () {
13456			stopScrolling( 0 );
13457
13458			$( '.listar-booking-popup' ).css( { left : '-105%', opacity : 0.99 } );
13459
13460			setTimeout( function () {
13461				$( '.listar-booking-popup' ).removeClass( 'listar-showing-login' );
13462			}, 500 );
13463		} );
13464
13465		theBody.on( 'click', '.listar-search-by-popup .listar-back-site', function () {
13466
13467			$( '.listar-search-by-popup' ).css( { left : '-105%', opacity : 0.99 } );
13468
13469			if ( ! $( '.listar-search-popup.listar-showing-search' ).length ) {
13470				stopScrolling( 0 );
13471			}
13472
13473			setTimeout( function () {
13474				$( '.listar-nearest-me-main' ).removeClass( 'hidden' );
13475				$( '.listar-nearest-me-secondary' ).addClass( 'hidden' );
13476				$( '.listar-general-explore-by-options' ).removeClass( 'hidden' );
13477				$( '.listar-nearest-me-loading' ).addClass( 'hidden' );
13478				$( '.listar-nearest-me-loading-icon' ).removeClass( 'listar-is-geolocating' );
13479				$( '.listar-search-by-popup' ).removeClass( 'listar-showing-search-by' );
13480			}, 500 );
13481		} );
13482
13483		theBody.on( 'click', '.listar-report-popup .listar-back-site', function () {
13484
13485			$( '.listar-report-popup' ).css( { left : '-105%', opacity : 0.99 } );
13486
13487			stopScrolling( 0 );
13488
13489			setTimeout( function () {
13490				$( '.listar-report-popup' ).removeClass( 'listar-showing-report' );
13491			}, 500 );
13492		} );
13493
13494		theBody.on( 'click', '.listar-claim-popup .listar-back-site', function () {
13495
13496			$( '.listar-claim-popup' ).css( { left : '-105%', opacity : 0.99 } );
13497
13498			stopScrolling( 0 );
13499
13500			setTimeout( function () {
13501				$( '.listar-claim-popup' ).removeClass( 'listar-showing-claim' );
13502			}, 500 );
13503		} );
13504
13505		theBody.on( 'click', '.listar-more-categories', function ( e ) {
13506			e.preventDefault();
13507			e.stopPropagation();
13508
13509			populateTermPopups( 'categories' );
13510			resetOwlCarousel( $( '.listar-listing-categories-popup .listar-carou
13510sel-loop.listar-use-carousel' ) );
13511			initOwlCarousel( $( '.listar-listing-categories-popup .listar-carousel-loop.listar-use-carousel' ) );
13512			stopScrolling( 1 );
13513
13514			$( '.listar-listing-categories-popup' ).addClass( 'listar-showing-categories' ).css( { left : 0, opacity : 1 } );
13515		} );
13516
13517		theBody.on( 'click', '.listar-search-by-button', function ( e ) {
13518			e.preventDefault();
13519			e.stopPropagation();
13520
13521			stopScrolling( 1 );
13522
13523			enableNearestMeDataEditor();
13524
13525			searchByInputToFocus = $( this ).parents( 'form' ).find( '.listar-listing-search-input-field' );
13526
13527			$( '.listar-search-by-popup' ).addClass( 'listar-showing-search-by' ).css( { left : 0, opacity : 1 } );
13528		} );
13529
13530		theBody.on( 'click', '.listar-listing-categories-popup .listar-back-site', function ( e ) {
13531			e.preventDefault();
13532			e.stopPropagation();			
13533			
13534			forceTermClick = false;
13535
13536			$( '.listar-listing-categories-popup' ).css( { left : '-105%', opacity : 0.99 } );
13537
13538			resetOwlCarousel( $( '.listar-listing-categories-popup .listar-carousel-loop.listar-use-carousel' ) );
13539
13540			setTimeout( function () {
13541				unpopulateTermPopups( 'categories' );
13542			}, 200 );
13543
13544			$( '.listar-listing-categories-popup' ).removeClass( 'listar-showing-settings' );
13545
13546			if ( $( '.listar-front-header' ).length ) {
13547				stopScrolling( 0 );
13548			}
13549		} );
13550
13551		theBody.on( 'click', '.listar-settings-button', function ( e ) {
13552			e.preventDefault();
13553			e.stopPropagation();
13554			stopScrolling( 1 );
13555
13556			$( '.listar-settings-popup' ).addClass( 'listar-showing-settings' ).css( { left : 0, opacity : 1 } );
13557		} );
13558
13559		theBody.on( 'click', '.listar-settings-popup .listar-back-site', function ( e ) {
13560			e.preventDefault();
13561			e.stopPropagation();
13562
13563			$( '.listar-settings-popup' ).css( { left : '-105%', opacity : 0.99 } );
13564
13565			setTimeout( function () {
13566				$( '.listar-settings-popup' ).removeClass( 'listar-showing-settings' );
13567			}, 500 );
13568
13569			stopScrolling( 0 );
13570		} );
13571
13572		theBody.on( 'click', '.listar-regions-list a', function ( e ) {
13573			e.preventDefault();
13574			e.stopPropagation();
13575
13576			if ( ! $( this ).hasClass( 'listar-region-no-hover' ) ) {
13577				populateTermPopups( 'regions' );
13578				resetOwlCarousel( $( '.listar-listing-regions-popup .listar-carou
13578sel-loop.listar-use-carousel' ) );
13579				initOwlCarousel( $( '.listar-listing-regions-popup .listar-carousel-loop.listar-use-carousel' ) );
13580				stopScrolling( 1 );
13581
13582				$( '.listar-listing-regions-popup' ).addClass( 'listar-showing-regions' ).css( { left : 0, opacity : 1 } );
13583			}
13584		} );
13585
13586		theBody.on( 'click', '.listar-listing-regions-popup .listar-back-site', function ( e ) {
13587			var regionFilterPlaceholder = '';
13588
13589			e.preventDefault();
13590			e.stopPropagation();
13591			forceTermClick = false;
13592
13593			if ( $( '.listar-front-header' ).length ) {
13594				stopScrolling( 0 );
13595			}
13596
13597			$( '.listar-regions-list a' ).removeClass( 'current' );
13598			$( '.listar-more-regions-button' ).addClass( 'current' );
13599
13600			regionFilterPlaceholder = $( '.listar-all-regions-button.current' ).attr( 'data-placeholder' );
13601
13602			$( '.listar-all-regions-button' ).removeClass( 'listar-has-selected-region' );
13603
13604			$( '.listar-all-regions-button.current span strong' ).prop( 'innerHTML', regionFilterPlaceholder );
13605			$( '.listar-chosen-region' ).val( '' );
13606
13607			$( '.listar-listing-regions-popup' ).css( { left : '-105%', opacity : 0.99 } );
13608			
13609			setTimeout( function () {
13610				unpopulateTermPopups( 'regions' );
13611			}, 200 );
13612
13613			resetOwlCarousel( $( '.listar-listing-categories-popup .listar-carou
13613sel-loop.listar-use-carousel' ) );
13614
13615			$( '.listar-listing-regions-popup' ).removeClass( 'listar-showing-regions' );
13616		} );
13617
13618		theBody.on( 'click', '.listar-search-popup .listar-back-site', function () {
13619			if ( ! onMap || $( '.listar-search-popup' ).hasClass( 'listar-showing-search' ) ) {
13620				stopScrolling( 0 );
13621			}
13622
13623			$( '.listar-search-popup' ).css( { left : '-105%', opacity : 0.99 } );
13624
13625			setTimeout( function () {
13626				$( '.listar-search-popup' ).removeClass( 'listar-showing-search' );
13627			}, 500 );
13628		} );
13629
13630		$( '.reply-the-comment' ).on( 'click', function ( e ) {
13631
13632			if ( theBody.hasClass( 'listar-user-not-logged' ) && theBody.hasClass( 'listar-guests-cannot-review' ) ) {
13633				e.preventDefault();
13634				e.stopPropagation();
13635
13636				$( '.listar-user-buttons-responsive .listar-user-login' ).trigger( 'click' );
13637				theBody.addClass( 'listar-login-before-review' );
13638			} else {
13639				var replyID = $( this ).attr( 'id' );
13640				replyID = replyID.replace( 'reply-the-comment-', '' );
13641
13642				$( '#div-comment-' + replyID + ' .comment-reply-link' )[0].click();
13643
13644				if ( 0 === $( '#div-comment-' + replyID ).find( '.listar-clear-float-comment' ).length ) {
13645					$( '#div-comment-' + replyID ).after( '<div class="listar-clear-both listar-clear-float-comment"></div>' );
13646				}
13647
13648				$( '.listar-comments-container .comment-respond' ).css( { display : 'none' } );
13649				$( this ).parents( '#comment-' + replyID ).find( '#respond' ).css( { display : 'block' } );
13650
13651				setTimeout( function () {
13652					htmlAndBody.stop().animate( {
13653						scrollTop : $( '#respond' ).offset().top - 120
13654					}, { duration : 500 } );
13655				}, 100 );
13656			}
13657		} );
13658
13659		theBody.on( 'click', '#cancel-comment-reply-link', function () {
13660			var thisElement = $( '.listar-comments-container li #respond' );
13661
13662			if ( thisElement.length > 0 ) {
13663				thisElement.prop( 'outerHTML', '' );
13664			}
13665
13666			$( '.listar-comments-container .comment-respond' ).css( { display : 'none' } );
13667		} );
13668
13669		$( '.listar-search-submit' ).on( 'click', function () {
13670			var searchForm = $( this ).parent().parent().find( 'form' );
13671			var currentExploreByOption = searchForm.find( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val();
13672			var searchText = searchForm.find( 'input[data-name="s"]' ).val();
13673			var addressSaved = searchForm.find( 'input[name="' + listarLocalizeAndAjax.savedAddressTranslation + '"]' );
13674			var postcodeSaved = searchForm.find( 'input[name="' + listarLocalizeAndAjax.savedPostcodeTranslation + '"]' );
13675			var searchType = searchForm.find( 'input[name="search_type"]' ).val();			
13676
13677			if ( 'shop_products' === currentExploreByOption ) {
13678				$( '.listar-post-type-form-field' ).val( 'product' );
13679			} else if ( 'listing' === searchType ) {
13680				$( '.listar-post-type-form-field' ).val( 'job_listing' );
13681			} else {
13682				$( '.listar-post-type-form-field' ).val( '' );
13683			}
13684
13685			if ( '' === searchText && 'near_address' === currentExploreByOption ) {
13686				addressSaved.val( '' );
13687			}
13688
13689			if ( '' === searchText && 'near_postcode' === currentExploreByOption ) {
13690				postcodeSaved.val( '' );
13691			}
13692
13693			if ( $( '.listar-search-filter-categories' ).length ) {
13694				var searchCategories = String( $( '.listar-search-filter-categories' ).val() );
13695
13696				if ( 'null' !== searchCategories ) {
13697					$( '.listar-chosen-category' ).val( searchCategories );
13698				}
13699			}
13700
13701			if ( $( '.listar-search-filter-regions' ).length ) {
13702				var searchRegions = String( $( '.listar-search-filter-regions' ).val() );
13703
13704				if ( 'null' !== searchRegions && ( '' === $( '.listar-chosen-region' ).attr( 'value' ) || '0' === $( '.listar-chosen-region' ).attr( 'value' ) ) ) {
13705					$( '.listar-chosen-region' ).val( searchRegions );
13706				}
13707			}
13708
13709			if ( $( '.listar-search-filter-amenities' ).length ) {
13710				var searchAmenities = String( $( '.listar-search-filter-amenities' ).val() );
13711
13712				if ( 'null' !== searchAmenities ) {
13713					$( '.listar-chosen-amenity' ).val( searchAmenities );
13714				}
13715			}
13716
13717			$( this ).parent().parent().find( 'form' ).submit();
13718		} );
13719
13720		$( '.listar-listing-category-link, .listar-card-category-name a[data-term-id]' ).on( 'click', function ( e ) {
13721
13722			if ( $( '.listar-chosen-region' ).length ) {
13723				var chosenRegion = String( $( '.listar-chosen-region' ).val() );
13724
13725				if ( 'null' !== chosenRegion && '' !== chosenRegion && '0' !== chosenRegion ) {
13726					if ( $( this )[0].hasAttribute( 'data-term-id' ) ) {
13727						var searchCategories = String( $( this ).attr( 'data-term-id' ) );
13728
13729						if ( 'null' !== searchCategories ) {
13730							$( '.listar-chosen-category' ).val( searchCategories );
13731							$( '.listar-chosen-region' ).parents( 'form' ).submit();
13732
13733							e.preventDefault();
13734							e.stopPropagation();
13735						}
13736					}
13737				}
13738			}
13739		} );
13740
13741		$( '.search-form input' ).keyup( function ( e ) {
13742			if ( 13 === e.keyCode ) {
13743				$( this ).trigger( 'enterKey' );
13744			}
13745		} );
13746
13747		/* Avoid line breaks */
13748
13749		$( theBody ).on( 'change paste keyup', '#job_location', function () {
13750			if ( 'undefined' !== typeof $( this ).attr( 'value' ) ) {
13751				$( this ).attr( 'value', $( this ).attr( 'value' ).replace( /( \r\ n| \n| \r\r\n|\n|\r)/gm, ' ' ) );
13752			} else if ( 'undefined' !== typeof $( this ).prop( 'innerHTML' ) ) {
13753				$( this ).prop( 'innerHTML', $( this ).prop( 'innerHTML' ).replace( /( \r\ n| \n| \r\r\n|\n|\r)/gm, ' ' ) );
13754			}
13755		} );
13756
13757		$( 'input[name=submit_job]' ).on( 'click', function ( e ) {
13758
13759			validatePhoneCharacters( $( '#submit-job-form #company_phone, #submit-job-form #company_fax, #submit-job-form #company_mobile, #submit-job-form #company_whatsapp' ) );
13760
13761			var
13762				str = $( 'iframe' ).eq( 0 ).contents().find( '.job_description' ).prop( 'innerHTML' ),
13763				wpJbManagerCheckeboxesFix = '',
13764				count = 0,
13765				priceFrom,
13766				priceTo,
13767				phoneField  = $( '#submit-job-form #company_phone' ),
13768				faxField    = $( '#submit-job-form #company_fax' ),
13769				mobileField = $( '#submit-job-form #company_mobile' ),
13770				whatsappField = $( '#submit-job-form #company_whatsapp' );
13771
13772			var
13773				hasPhoneField = 0 !== phoneField.length,
13774				hasFaxField = 0 !== faxField.length,
13775				hasMobileField = 0 !== mobileField.length,
13776				hasWhatsappField = 0 !== whatsappField.length;
13777			var
13778				phoneFieldValue		     = phoneField.val(),
13779				faxFieldValue		     = faxField.val(),
13780				mobileFieldValue	     = mobileField.val(),
13781				whatsappFieldValue	     = whatsappField.val(),
13782				phoneFieldCountryCode        = hasPhoneField ? phoneField.parent().find( '.iti__selected-flag div' ).eq( 0 ).attr( 'class' ) : '',
13783				faxFieldCountryCode          = hasFaxField ? faxField.parent().find( '.iti__selected-flag div' ).eq( 0 ).attr( 'class' ) : '',
13784				mobileFieldCountryCode       = hasMobileField ? mobileField.parent().find( '.iti__selected-flag div' ).eq( 0 ).attr( 'class' ) : '',
13785				whatsappFieldCountryCode     = hasWhatsappField ? whatsappField.parent().find( '.iti__selected-flag div' ).eq( 0 ).attr( 'class' ) : '',
13786				phoneFieldCountryCodeLength  = 0,
13787				faxFieldCountryCodeLength    = 0,
13788				mobileFieldCountryCodeLength = 0,
13789				whatsappFieldCountryCodeLength = 0;
13790
13791			var
13792				phoneFieldValueSubstr    = hasPhoneField && 'string' === typeof phoneFieldValue ? phoneFieldValue.substring(0,4) : '',
13793				faxFieldValueSubstr      = hasFaxField && 'string' === typeof faxFieldValue ? faxFieldValue.substring(0,4) : '',
13794				mobileFieldValueSubstr   = hasMobileField && 'string' === typeof mobileFieldValue ? mobileFieldValue.substring(0,4) : '',
13795				whatsappFieldValueSubstr = hasWhatsappField && 'string' === typeof whatsappFieldValue ? whatsappFieldValue.substring(0,4) : '';
13796
13797			var
13798				operationHours = [];
13799
13800			if ( 'string' === typeof str ) {
13801				str = str.replace( /<\s*br\/*>/gi, '\n' );
13802				str = str.replace( /<\s*p\/*>/gi, '\n' );
13803				str = str.replace( /<\s*b\/*>/gi, '\n' );
13804				str = str.replace( /<\s*i\/*>/gi, '\n' );
13805				str = str.replace( /<\s*a.*href="(.*?)".*>(.*?)<\/a>/gi, ' $2 (Link->$1) ' );
13806				str = str.replace( /<\s*\/*.+?>/ig, '\n' );
13807				str = str.replace( / {2,}/gi, ' ' );
13808				str = str.replace( /\n+\s*/gi, '\n\n' );
13809
13810				while ( str.indexOf( '(Link' ) >= 0 ) {
13811					count++;
13812					str = str.replace( /\(.*?\)/gi, '' );
13813
13814					if ( 10 === count ) {
13815						break;
13816					}
13817				}
13818
13819				str = str.replace( /\n/gi, '' );
13820				str = str.replace( /\}/gi, '' );
13821				str = str.replace( /\{/gi, '' );
13822				str = str.replace( /\[/gi, '' );
13823				str = str.replace( /\]/gi, '' );
13824				str = str.replace( /\(/gi, '' );
13825				str = str.replace( /\)/gi, '' );
13826				str = str.replace( /\'/gi, '' );
13827				str = str.replace( /\"/gi, '' );
13828				str = str.replace( /  /gi, '' );
13829
13830				$( '#company_excerpt' ).attr( 'value', str );
13831			}
13832
13833			phoneFieldCountryCode    = phoneFieldCountryCode.replace( /\iti__flag /gi, '' );
13834			faxFieldCountryCode      = faxFieldCountryCode.replace( /\iti__flag /gi, '' );
13835			mobileFieldCountryCode   = mobileFieldCountryCode.replace( /\iti__flag /gi, '' );
13836			whatsappFieldCountryCode = whatsappFieldCountryCode.replace( /\iti__flag /gi, '' );
13837
13838			phoneFieldCountryCode    = hasPhoneField ? $( '.iti__country-list' ).eq( 0 ).find( '.iti__flag-box .' + phoneFieldCountryCode ).eq( 0 ).parents( '.iti__country' ).attr( 'data-dial-code' ) : '';
13839			faxFieldCountryCode      = hasFaxField ? $( '.iti__country-list' ).eq( 0 ).find( '.iti__flag-box .' + faxFieldCountryCode ).eq( 0 ).parents( '.iti__country' ).attr( 'data-dial-code' ) : '';
13840			mobileFieldCountryCode   = hasMobileField ? $( '.iti__country-list' ).eq( 0 ).find( '.iti__flag-box .' + mobileFieldCountryCode ).eq( 0 ).parents( '.iti__country' ).attr( 'data-dial-code' ) : '';
13841			whatsappFieldCountryCode = hasWhatsappField ? $( '.iti__country-list' ).eq( 0 ).find( '.iti__flag-box .' + whatsappFieldCountryCode ).eq( 0 ).parents( '.iti__country' ).attr( 'data-dial-code' ) : '';
13842
13843			phoneFieldCountryCodeLength    = hasPhoneField ? phoneFieldCountryCode.length : 0;
13844			faxFieldCountryCodeLength      = hasFaxField ? faxFieldCountryCode.length : 0;
13845			mobileFieldCountryCodeLength   = hasMobileField ? mobileFieldCountryCode.length : 0;
13846			whatsappFieldCountryCodeLength = hasWhatsappField ? whatsappFieldCountryCode.length : 0;
13847
13848			if ( hasPhoneField ) {
13849				if ( '' !== phoneFieldValueSubstr && phoneFieldValueSubstr.indexOf( '+' + phoneFieldCountryCode ) < 0 && phoneFieldValueSubstr.indexOf( '+ ' + phoneFieldCountryCode ) < 0 && phoneFieldValueSubstr.substring( 0, phoneFieldCountryCodeLength ) !== phoneFieldCountryCode ) {
13850					phoneFieldValue = phoneFieldValue.replace( /\+/gi, '' );
13851					phoneField.attr( 'value', '+' + phoneFieldCountryCode + ' ' + phoneFieldValue );
13852					phoneField.val( '+' + phoneFieldCountryCode + ' ' + phoneFieldValue );
13853				} else if ( phoneFieldValue.substring( 0, phoneFieldCountryCodeLength ) === phoneFieldCountryCode ) {
13854					phoneField.attr( 'value', '+' + phoneFieldValue );
13855					phoneField.val( '+' + phoneFieldValue );
13856				}
13857			}
13858
13859			if ( hasFaxField ) {
13860				if ( '' !== faxFieldValueSubstr && faxFieldValueSubstr.indexOf( '+' + faxFieldCountryCode ) < 0 && faxFieldValueSubstr.indexOf( '+ ' + faxFieldCountryCode ) < 0 && faxFieldValueSubstr.substring( 0, faxFieldCountryCodeLength ) !== faxFieldCountryCode ) {
13861					faxFieldValue = faxFieldValue.replace( /\+/gi, '' );
13862					faxField.attr( 'value', '+' + faxFieldCountryCode + ' ' + faxFieldValue );
13863					faxField.val( '+' + faxFieldCountryCode + ' ' + faxFieldValue );
13864				} else if ( faxFieldValue.substring( 0, faxFieldCountryCodeLength ) === faxFieldCountryCode ) {
13865					faxField.attr( 'value', '+' + faxFieldValue );
13866					faxField.val( '+' + faxFieldValue );
13867				}
13868			}
13869
13870			if ( hasMobileField ) {
13871				if ( '' !== mobileFieldValueSubstr && mobileFieldValueSubstr.indexOf( '+' + mobileFieldCountryCode ) < 0 && mobileFieldValueSubstr.indexOf( '+ ' + mobileFieldCountryCode ) < 0 && mobileFieldValueSubstr.substring( 0, mobileFieldCountryCodeLength ) !== mobileFieldCountryCode ) {
13872					mobileFieldValue = mobileFieldValue.replace( /\+/gi, '' );
13873					mobileField.attr( 'value', '+' + mobileFieldCountryCode + ' ' + mobileFieldValue );
13874					mobileField.val( '+' + mobileFieldCountryCode + ' ' + mobileFieldValue );
13875				} else if ( mobileFieldValue.substring( 0, mobileFieldCountryCodeLength ) === mobileFieldCountryCode ) {
13876					mobileField.attr( 'value', '+' + mobileFieldValue );
13877					mobileField.val( '+' + mobileFieldValue );
13878				}
13879			}
13880
13881			if ( hasWhatsappField ) {
13882				if ( '' !== whatsappFieldValueSubstr && whatsappFieldValueSubstr.indexOf( '+' + whatsappFieldCountryCode ) < 0 && whatsappFieldValueSubstr.indexOf( '+ ' + whatsappFieldCountryCode ) < 0 && whatsappFieldValueSubstr.substring( 0, whatsappFieldCountryCodeLength ) !== whatsappFieldCountryCode ) {
13883					whatsappFieldValue = whatsappFieldValue.replace( /\+/gi, '' );
13884					whatsappField.attr( 'value', '+' + whatsappFieldCountryCode + ' ' + whatsappFieldValue );
13885					whatsappField.val( '+' + whatsappFieldCountryCode + ' ' + whatsappFieldValue );
13886				} else if ( whatsappFieldValue.substring( 0, whatsappFieldCountryCodeLength ) === whatsappFieldCountryCode ) {
13887					whatsappField.attr( 'value', '+' + whatsappFieldValue );
13888					whatsappField.val( '+' + whatsappFieldValue );
13889				}
13890			}
13891			
13892			// Save raw texts for WordPress search.
13893			
13894			$( '#job_business_raw_contents' ).each( function () {
13895				var rawTextarea = $( this );
13896				var rawTextContent = '';
13897				var rawTextCurrent = '';
13898				
13899				$( '[id*="job_business_document_"][id*="_title"], .listar-price-builder-category-val, .listar-price-item-title-val, .listar-price-item-descr-val, .listar-price-item-link-val, .listar-price-item-label-val, #job_listing_subtitle, #job_tagline' ).each( function () {
13900					rawTextCurrent = $( this ).val();
13901					
13902					if ( 'string' === typeof rawTextCurrent ) {
13903						if ( '' !== rawTextCurrent ) {
13904							rawTextContent += rawTextCurrent + ' ';
13905						}
13906					}
13907				} );
13908				
13909				rawTextarea.val( rawTextContent );
13910			} );
13911			
13912		
13913			// Treats the rich media fields.
13914			
13915			var richMediaJSON = '[';
13916			
13917			$( 'textarea[id*="company_business_rich_media_value_"]' ).each( function () {
13918				
13919				// Remove all unwanted HTML tags (mainly <script>), except these.
13920				var tempString = $( this ).val();
13921				var removeScripts = '';
13922				
13923				if ( 'string' !== typeof tempString ) {
13924					tempString = '';
13925				}
13926				
13927				// /\r?\n|\r/gm Removes all line breaks.
13928				
13929				removeScripts = containURLPattern( stripHTMLTags( tempString.replace( /\r?\n|\r/gm, ' ' ), 'iframe', 'embed' ).trim() );
13930				
13931				if ( removeScripts.indexOf( '<' ) >= 0 && removeScripts.indexOf( '>' ) >= 0 ) {
13932
13933					// This seems HTML.
13934					removeScripts = extractContent( removeScripts );
13935				}
13936
13937				$( this ).val( removeScripts );
13938				
13939				if ( '' !== removeScripts ) {
13940					var tempLower = removeScripts.toLowerCase();
13941
13942					if (
13943						-1 === tempLower.indexOf( 'yout' ) &&
13944						-1 === tempLower.indexOf( 'vimeo' ) &&
13945						-1 === tempLower.indexOf( '.mp4' ) &&
13946						-1 === tempLower.indexOf( '.avi' ) &&
13947						-1 === tempLower.indexOf( '.flv' ) &&
13948						-1 === tempLower.indexOf( '.mov' ) &&
13949						-1 === tempLower.indexOf( '.wmv' ) &&
13950						-1 === tempLower.indexOf( '.mkv' ) &&
13951						-1 === tempLower.indexOf( '.jpg' ) &&
13952						-1 === tempLower.indexOf( '.jpeg' ) &&
13953						-1 === tempLower.indexOf( '.png' ) &&
13954						-1 === tempLower.indexOf( '.gif' ) &&
13955						-1 === tempLower.indexOf( '.bmp' ) &&
13956						-1 === tempLower.indexOf( '.webp' ) &&
13957						-1 === tempLower.indexOf( '<iframe' ) &&
13958						-1 === tempLower.indexOf( '<embed' ) &&
13959						-1 === tempLower.indexOf( '#no-iframe' )
13960						
13961					) {
13962						var tempConfirm = confirm( listarLocalizeAndAjax.mediaConfirm + '\n\n' + removeScripts );
13963						
13964						if ( tempConfirm ) {
13965							removeScripts = '<iframe src="' + removeScripts + '"></iframe>';
13966						} else {
13967							removeScripts += '#no-iframe';
13968						}
13969						
13970						$( this ).val( removeScripts );
13971					}
13972					
13973					richMediaJSON += '{"code":"' + encodeURI( removeScripts ) + '"},';
13974				}
13975			} );
13976
13977			if ( ',' === richMediaJSON.substr( -1 ) ) {
13978				richMediaJSON = richMediaJSON.slice( 0, -1 );
13979			}
13980
13981			richMediaJSON += ']';
13982			
13983			$( '#company_business_rich_media_values' ).val( richMediaJSON );
13984
13985			/* Return only characters for princing fields - 0 until 9 and dot (.) */
13986			$( 'input[class*="price-range"]' ).each( function () {
13987				sanitizePricingFields( $( this ) );
13988			} );
13989
13990			/* Return only characters for princing fields - 0 until 9 and dot (.) */
13991			$( 'input[name*="priceaverage"]' ).each( function () {
13992				sanitizePricingFields( $( this ) );
13993			} );
13994
13995			/* Sets price range, if available */
13996			if ( $( '.listar-price-range-from' ).length && $( '.listar-price-range-to' ).length ) {
13997				var requiredPriceRange = $( '#job_pricerange' )[0].hasAttribute( 'required' );
13998
13999				priceFrom = $( '.listar-price-range-from' ).val();
14000				priceTo = $( '.listar-price-range-to' ).val();
14001
14002				priceFrom = 'string' !== typeof priceFrom || undefined === priceFrom || 'undefined' === priceFrom || 'NaN' === priceFrom || '' === priceFrom || 0 === priceFrom || '0' === priceFrom ? 0 : priceFrom;
14003				priceTo = 'string' !== typeof priceTo || undefined === priceTo || 'undefined' === priceTo || 'NaN' === priceTo || '' === priceTo || 0 === priceTo || '0' === priceTo ? 0 : priceTo;
14004
14005				if ( parseInt( priceFrom, 10 ) > 0 ) {
14006					if ( parseInt( priceTo, 10 ) > 0 ) {
14007						if ( parseInt( priceTo, 10 ) <= parseInt( priceFrom, 10 ) ) {
14008							if ( requiredPriceRange ) {
14009								$( '.listar-price-range-to' ).val( '' );
14010							} else {
14011								$( '.listar-price-range-to' ).val( parseInt( priceFrom, 10 ) * 2 );
14012								$( '.listar-price-range-from' ).trigger( 'change' );
14013							}
14014						}
14015					} else {
14016						if ( requiredPriceRange ) {
14017							$( '.listar-price-range-to' ).val( '' );
14018						} else {
14019							$( '.listar-price-range-to' ).val( parseInt( priceFrom, 10 ) * 2 );
14020							$( '.listar-price-range-from' ).trigger( 'change' );
14021						}
14022					}
14023				} else {
14024					$( '.listar-price-range-from' ).val( '' );
14025				}
14026
14027				priceFrom = $( '.listar-price-range-from' ).val();
14028				priceTo = $( '.listar-price-range-to' ).val();
14029
14030				priceFrom = 'string' !== typeof priceFrom || undefined === priceFrom || 'undefined' === priceFrom || 'NaN' === priceFrom || '' === priceFrom || 0 === priceFrom || '0' === priceFrom ? 0 : priceFrom;
14031				priceTo = 'string' !== typeof priceTo || undefined === priceTo || 'undefined' === priceTo || 'NaN' === priceTo || '' === priceTo || 0 === priceTo || '0' === priceTo ? 0 : priceTo;
14032
14033				$( '#job_pricerange' ).val( parseInt( priceFrom, 10 ) + '/////' + parseInt( priceTo, 10 ) );
14034			}
14035
14036			/* Social networks are required? */
14037			$( '#company_use_social_networks' ).each( function () {
14038				var isRequired = $( this )[0].hasAttribute( 'required' );
14039				var hasSomeValue = false;
14040
14041				if ( isRequired ) {
14042					$( '.listar-business-social-network-fields input' ).each( function () {
14043						var fieldValue = $( this ).val();
14044
14045						if ( '' !== fieldValue && undefined !== fieldValue && 'undefined' !== fieldValue && 0 !== fieldValue ) {
14046							hasSomeValue = true;
14047						}
14048					} );
14049
14050					if ( ! hasSomeValue && $( this ).is( ':checked' ) ) {
14051						$( this )[0].click();
14052					}
14053				}
14054			} );
14055
14056			/* External references are required? */
14057			$( '#company_use_external_links' ).each( function () {
14058				var isRequired = $( this )[0].hasAttribute( 'required' );
14059				var hasSomeValue = false;
14060
14061				if ( isRequired ) {
14062					$( '.listar-business-external-link-fields input' ).each( function () {
14063						var fieldValue = $( this ).val();
14064
14065						if ( '' !== fieldValue && undefined !== fieldValue && 'undefined' !== fieldValue && 0 !== fieldValue ) {
14066							hasSomeValue = true;
14067						}
14068					} );
14069
14070					if ( ! hasSomeValue && $( this ).is( ':checked' ) ) {
14071						$( this )[0].click();
14072					}
14073				}
14074			} );
14075
14076			// Prepare operation hours.
14077
14078			if ( $( '.listar-business-hours-fields tr[class*="listar-business-hours-row"]' ).length ) {
14079
14080				$( '.listar-business-hours-fields tr[class*="listar-business-hours-row"]' ).each( function () {
14081
14082					var hoursRow = $( this );
14083					var keepOnlyOrder = -1;
14084					var multipleCount = 0;
14085					var multipleSeparator = '***';
14086					var theDayHours = '';
14087
14088					// Firstly detect any Open 24 Hours / Closed 24 Hours and remove all siblings
14089					hoursRow.find( '.listar-business-start-time-field select' ).each( function () {
14090						if ( -1 === $( this ).val().indexOf( ' AM' ) && -1 === $( this ).val().indexOf( ' PM' ) ) {
14091							keepOnlyOrder = parseInt( $( this ).attr( 'data-multiple-order' ), 10 );
14092							return;
14093						}
14094					} );
14095
14096					if ( -1 !== keepOnlyOrder ) {
14097
14098						// Remove all sibling hours, keep only the most abrangent (24 hours open/closed)
14099						hoursRow.find( '.listar-business-start-time-field select, .listar-business-end-time-field select' ).each( function () {
14100							if ( parseInt( $( this ).attr( 'data-multiple-order' ), 10 ) !== keepOnlyOrder ) {
14101								$( this ).parent().parent().parent().removeClass( 'listar-has-multiple-hours' );
14102								$( this ).parent().prop( 'outerHTML', '' );
14103							}
14104						} );
14105					}
14106
14107					// Now the multiple operating hours can be properly colected
14108					hoursRow.find( '.listar-business-start-time-field select' ).each( function () {
14109						var currentMultipleOrder = $( this ).attr( 'data-multiple-order' );
14110						var currentMultipleHourOpen  = $( this ).val();
14111						var currentMultipleHourClose = $( this ).parents( '.listar-business-start-time-field' ).siblings( '.listar-business-end-time-field' ).find( 'select[data-multiple-order="' + currentMultipleOrder + '"]' ).val();
14112
14113						if ( 0 === multipleCount ) {
14114							theDayHours += currentMultipleHourOpen + ' - ' + currentMultipleHourClose;
14115						} else {
14116							theDayHours += multipleSeparator + currentMultipleHourOpen + ' - ' + currentMultipleHourClose;
14117						}
14118
14119						multipleCount++;
14120					} );
14121
14122					operationHours.push( theDayHours );
14123				} );
14124
14125				$( 'input#job_business_hours_monday' ).val( operationHours[0] );
14126				$( 'input#job_business_hours_tuesday' ).val( operationHours[1] );
14127				$( 'input#job_business_hours_wednesday' ).val( operationHours[2] );
14128				$( 'input#job_business_hours_thursday' ).val( operationHours[3] );
14129				$( 'input#job_business_hours_friday' ).val( operationHours[4] );
14130				$( 'input#job_business_hours_saturday' ).val( operationHours[5] );
14131				$( 'input#job_business_hours_sunday' ).val( operationHours[6] );
14132			}
14133
14134			/* Avoid line breaks */
14135			$( '#job_location' ).each( function () {
14136				if ( 'undefined' !== typeof $( this ).attr( 'value' ) ) {
14137					$( this ).attr( 'value', $( this ).attr( 'value' ).replace( /( \r\ n| \n| \r\r\n|\n|\r)/gm, ' ' ) );
14138				} else if ( 'undefined' !== typeof $( this ).prop( 'innerHTML' ) ) {
14139					$( this ).prop( 'innerHTML', $( this ).prop( 'innerHTML' ).replace( /( \r\ n| \n| \r\r\n|\n|\r)/gm, ' ' ) );
14140				}
14141			} );
14142
14143			/* Fix for WP Job Manager checkboxes - Needed only for front end */
14144			$( '#submit-job-form input[type="checkbox"]' ).each( function () {
14145				var checkboxChecked = $( this ).is( ':checked' ) ? '1' : '0';
14146				wpJbManagerCheckeboxesFix += 'checkboxischecked_' + checkboxChecked + '_' + $( this ).attr( 'name' ) + '-----';
14147			} );
14148
14149			$( '#job_fix_for_checkboxes' )
14150				.val( wpJbManagerCheckeboxesFix )
14151				.attr( 'value', wpJbManagerCheckeboxesFix );
14152
14153			$( '#featured_job_category' ).each( function () {
14154				var featuredCategoryChosen = $( this ).val();
14155				$( '#company_featured_listing_category' ).val( featuredCategoryChosen );
14156			} );
14157
14158			if ( multipleRegionsActive ) {
14159				$( '#featured_job_region' ).each( function () {
14160					var featuredRegionChosen = $( this ).val();
14161					$( '#company_featured_listing_region' ).val( featuredRegionChosen );
14162				} );
14163			}
14164
14165			var hasIssues = false;
14166
14167			/* Get built pricing menu values  */
14168			$( '#submit-job-form input[name="job_business_use_price_list"]' ).each( function () {
14169				if ( $( this ).is( ':checked' ) && $( '#job_business_use_catalog' ).is( ':checked' ) ) {
14170					var JSONValues  = '[';
14171					var priceListCategories = $( '.listar-price-builder-category' );
14172					var priceCat    = '';
14173					var priceCatID  = '';
14174					var priceItemID = '';
14175					var priceTag    = '';
14176					var priceTitle  = '';
14177					var pricePrice  = '';
14178					var priceDescr  = '';
14179                                        var priceLink   = '';
14180                                        var priceImageURL  = '';
14181                                        var priceImageID  = '';
14182                                        var priceLabel  = '';
14183
14184                                        if ( ! priceListCategories.length ) {
14185                                                $( '.listar-price-item' ).each( function () {
14186                                                        priceTag    = $( this ).find( '.listar-price-item-tag-val' ).val();
14187                                                        priceTitle  = $( this ).find( '.listar-price-item-title-val' ).val();
14188                                                        pricePrice  = $( this ).find( '.listar-price-item-price-val' ).val();
14189                                                        priceDescr  = $( this ).find( '.listar-price-item-descr-val' ).val();
14190                                                        priceLink   = $( this ).find( '.listar-price-item-link-val' ).val();
14191                                                        priceImageURL   = $( this ).find( '.listar-price-item-image-val-url' ).val();
14192                                                        priceImageID   = $( this ).find( '.listar-price-item-image-val-id' ).val();
14193                                                        priceLabel  = $( this ).find( '.listar-price-item-label-val' ).val();
14194
14195                                                        if ( 'string' !== typeof priceTitle || undefined === priceTitle || 'undefined' === priceTitle || 'NaN' === priceTitle || '0' === priceTitle ) {
14196                                                                priceTitle = '';
14197                                                        }
14198
14199                                                        if ( '' !== priceTitle ) {
14200                                                                if ( 'string' !== typeof priceTag || undefined === priceTag || 'undefined' === priceTag || 'NaN' === priceTag || '0' === priceTag ) {
14201                                                                        priceTag = '';
14202                                                                }
14203
14204                                                                if ( 'string' !== typeof pricePrice || undefined === pricePrice || 'undefined' === pricePrice || 'NaN' === pricePrice || '0' === pricePrice ) {
14205                                                                        pricePrice = '';
14206                                                                }
14207
14208                                                                if ( 'string' !== typeof priceDescr || undefined === priceDescr || 'undefined' === priceDescr || 'NaN' === priceDescr || '0' === priceDescr ) {
14209                                                                        priceDescr = '';
14210                                                                }
14211
14212                                                                if ( 'string' !== typeof priceLink || undefined === priceLink || 'undefined' === priceLink || 'NaN' === priceLink || '0' === priceLink ) {
14213                                                                        priceLink = '';
14214                                                                }
14215
14216                                                                if ( 'string' !== typeof priceImageURL || undefined === priceImageURL || 'undefined' === priceImageURL || 'NaN' === priceImageURL || '0' === priceImageURL ) {
14217                                                                        priceImageURL = '';
14218                                                                }
14219
14220                                                                if ( 'string' !== typeof priceImageID || undefined === priceImageID || 'undefined' === priceImageID || 'NaN' === priceImageID || '0' === priceImageID ) {
14221                                                                        priceImageID = '';
14222                                                                }
14223
14224                                                                if ( 'string' !== typeof priceLabel || undefined === priceLabel || 'undefined' === priceLabel || 'NaN' === priceLabel || '0' === priceLabel ) {
14225                                                                        priceLabel = '';
14226                                                                }
14227
14228                                                                priceTag   = encodeURIComponent( priceTag.trim() );
14229                                                                priceTitle = encodeURIComponent( priceTitle.trim() );
14230                                                                pricePrice = encodeURIComponent( pricePrice.trim() );
14231                                                                priceDescr = encodeURIComponent( priceDescr.trim() );
14232                                                                priceLink  = encodeURIComponent( priceLink.trim() );
14233                                                                priceImageURL  = encodeURIComponent( priceImageURL.trim() );
14234                                                                priceImageID  = encodeURIComponent( priceImageID.trim() );
14235                                                                priceLabel = encodeURIComponent( priceLabel.trim() );
14236
14237                                                                if ( '' 
14237!== priceTitle ) {
14238                                                                        JSONValues += '{"category_id":"' + priceCatID + '","category":"' + priceCat + '","item_id":"' + priceItemID + '","tag":"' + priceTag + '","title":"' + priceTitle + '","price":"' + pricePrice + '","description":"' + priceDescr + '","link":"' + priceLink + '","imageURL":"' + priceImageURL + '","imageID":"' + priceImageID + '","label":"' + priceLabel + '"},';
14239                                                                } else {
14240                                                                        if ( ! hasIssues ) {
14241                                                                                hasIssues = true;
14242
14243                                                                                if ( '' !== priceCatID ) {
14244                                                                                        $( '.listar-price-builder-category#' + priceCatID + ' input' ).each( function () {
14245                                                                                                $( this )[0].click();
14246                                                                                        } );
14247                                                                                }
14248
14249                                                                                alert( listarLocalizeAndAjax.missingTitle );
14250
14251                                                                                JSONValues  = '[';
14252                                                                                e.preventDefault();
14253                                                                                e.stopPropagation();
14254                                                                                return false;
14255                                                                        }
14256                                                                }
14257                                                        } else {
14258                                                                if ( ! hasIssues ) {
14259                                                                        hasIssues = true;
14260
14261                                                                        if ( '' !== priceCatID ) {
14262                                                                                $( '.listar-price-builder-category#' + priceCatID + ' input' ).each( function () {
14263                                                                                        $( this )[0].click();
14264                                                                                } );
14265                                                                        }
14266
14267                                                                        alert( listarLocalizeAndAjax.missingTitle );
14268
14269                                                                        JSONValues  = '[';
14270                                                                        e.preventDefault();
14271                                                                        e.stopPropagation();
14272                                                                        return false;
14273                                                                }
14274                                                        }
14275                                                } );
14276                                        } else {
14277                                                priceListCategories.each( function () {
14278                                                        priceCat = $( this ).find( 'input' ).val();
14279
14280                                                        if ( 'string' !== typeof priceCat || undefined === priceCat || 'undefined' === priceCat || 'NaN' === priceCat || '0' === priceCat || '' === priceCat ) {
14281                                                                priceCat = '';
14282                                                        } else {
14283                                                                priceCat = encodeURIComponent( priceCat.trim() );
14284
14285                                                                if ( 'string' !== typeof priceCat || undefined === priceCat || 'undefined' === priceCat || 'NaN' === priceCat || '0' === priceCat || '' === priceCat ) {
14286                                                                        priceCat = '';
14287                                                                }
14288                                                        }
14289
14290                                                        if ( '' === priceCat ) {
14291                                                                if ( ! hasIssues ) {
14292                                                                        hasIssues = true;
14293                                                                        alert( listarLocalizeAndAjax.emptyPriceCategory );
14294
14295                                                                        JSONValues  = '[';
14296                                                                        e.preventDefault();
14297                                                                        e.stopPropagation();
14298                                                                        return false;
14299                                                                }
14300                                                        } else {
14301                                                                priceCatID = $( this ).attr( 'id' );
14302
14303                                                                var priceCategoryItems = $( '.listar-price-item[data-category="' + priceCatID + '"]' );
14304
14305                                                                if ( ! priceCategoryItems.length ) {
14306                                                                        if ( ! hasIssues ) {
14307                                                                                hasIssues = true;
14308
14309                                                                                alert( listarLocalizeAndAjax.categoryNoItems );
14310
14311                                                                                JSONValues  = '[';
14312                                                                                e.preventDefault();
14313                                                                                e.stopPropagation();
14314                                                                                return false;
14315                                                                        }
14316                                                                } else {
14317                                                                        priceCategoryItems.each( function () {
14318                                                                                priceItemID = $( this ).attr( 'id' );
14319                                                                                priceTag    = $( this ).find( '.listar-price-item-tag-val' ).val();
14320                                                                                priceTitle  = $( this ).find( '.listar-price-item-title-val' ).val();
14321                                                                                pricePrice  = $( this ).find( '.listar-price-item-price-val' ).val();
14322                                                                                priceDescr  = $( this ).find( '.listar-price-item-descr-val' ).val();
14323                                                                                priceLink   = $( this ).find( '.listar-price-item-link-val' ).val();
14324                                                                                priceImageURL  = $( this ).find( '.listar-price-item-image-val-url' ).val();
14325                                                                                priceImageID  = $( this ).find( '.listar-price-item-image-val-id' ).val();
14326                                                                                priceLabel  = $( this ).find( '.listar-price-item-label-val' ).val();
14327
14328                                                                                if ( 'string' !== typeof priceTitle || undefined === priceTitle || 'undefined' === priceTitle || 'NaN' === priceTitle || '0' === priceTitle ) {
14329                                                                                        priceTitle = '';
14330                                                                                }
14331
14332                                                                                if ( '' !== priceTitle ) {
14333                                                                                        if ( 'string' !== typeof priceTag || undefined === priceTag || 'undefined' === priceTag || 'NaN' === priceTag || '0' === priceTag ) {
14334                                                                                                priceTag = '';
14335                                                                                        }
14336
14337                                                                                        if ( 'string' !== typeof pricePrice || undefined === pricePrice || 'undefined' === pricePrice || 'NaN' === pricePrice || '0' === pricePrice ) {
14338                                                                                                pricePrice = '';
14339                                                                                        }
14340
14341                                                                                        if ( 'string' !== typeof priceDescr || undefined === priceDescr || 'undefined' === priceDescr || 'NaN' === priceDescr || '0' === priceDescr ) {
14342                                                                                                priceDescr = '';
14343                                                                                        }
14344
14345                                                                                        if ( 'string' !== typeof priceLink || undefined === priceLink || 'undefined' === priceLink || 'NaN' === priceLink || '0' === priceLink ) {
14346                                                                                                priceLink = '';
14347                                                                                        }
14348
14349                                                                                        if ( 'string' !== typeof priceImageURL || undefined === priceImageURL || 'undefined' === priceImageURL || 'NaN' === priceImageURL || '0' === priceImageURL ) {
14350                                                                                                priceImageURL = '';
14351                                                                                        }
14352
14353                                                                                        if ( 'string' !== typeof priceImageID || undefined === priceImageID || 'undefined' === priceImageID || 'NaN' === priceImageID || '0' === priceImageID ) {
14354                                                                                                priceImageID = '';
14355                                                                                        }
14356
14357                                                                                        if ( 'string' !== typeof priceLabel || undefined === priceLabel || 'undefined' === priceLabel || 'NaN' === priceLabel || '0' === priceLabel ) {
14358                                                                                                priceLabel = '';
14359                                                                                        }
14360
14361                                                                                        priceCatID  = encodeURIComponent( priceCatID );
14362                                                                                        priceItemID = encodeURIComponent( priceItemID );
14363                                                                                        priceTag    = encodeURIComponent( priceTag.trim() );
14364                                                                                        priceTitle  = encodeURIComponent( priceTitle.trim() );
14365                                                                                        pricePrice  = encodeURIComponent( pricePrice.trim() );
14366                                                                                        priceDescr  = encodeURIComponent( priceDescr.trim() );
14367                                                                                        priceLink  = encodeURIComponent( priceLink.trim() );
14368                                                                                        priceImageURL  = encodeURIComponent( priceImageURL.trim() );
14369                                                                                        priceImageID  = encodeURIComponent( priceImageID.trim() );
14370                                                                                        priceLabel  = encodeURIComponent( priceLabel.trim() );
14371
14372                                                                                        if ( '' 
14372!== priceTitle ) {
14373                                                                                                JSONValues += '{"category_id":"' + priceCatID + '","category":"' + priceCat + '","item_id":"' + priceItemID + '","tag":"' + priceTag + '","title":"' + priceTitle + '","price":"' + pricePrice + '","description":"' + priceDescr + '","link":"' + priceLink + '","imageURL":"' + priceImageURL + '","imageID":"' + priceImageID + '","label":"' + priceLabel + '"},';
14374                                                                                        } else {
14375                                                                                                if ( ! hasIssues ) {
14376                                                                                                        hasIssues = true;
14377
14378                                                                                                        if ( '' !== priceCatID ) {
14379                                                                                                                $( '.listar-price-builder-category#' + priceCatID + ' input' ).each( function () {
14380                                                                                                                        $( this )[0].click();
14381                                                                                                                } );
14382                                                                                                        }
14383
14384                                                                                                        alert( listarLocalizeAndAjax.missingTitle );
14385
14386                                                                                                        JSONValues  = '[';
14387                                                                                                        e.preventDefault();
14388                                                                                                        e.stopPropagation();
14389                                                                                                        return false;
14390                                                                                                }
14391                                                                                        }
14392                                                                                } else {
14393                                                                                        if ( ! hasIssues ) {
14394                                                                                                hasIssues = true;
14395
14396                                                                                                if ( '' !== priceCatID ) {
14397                                                                                                        $( '.listar-price-builder-category#' + priceCatID + ' input' ).each( function () {
14398                                                                                                                $( this )[0].click();
14399                                                                                                        } );
14400                                                                                                }
14401
14402                                                                                                alert( listarLocalizeAndAjax.missingTitle );
14403
14404                                                                                                JSONValues  = '[';
14405                                                                                                e.preventDefault();
14406                                                                                                e.stopPropagation();
14407                                                                                                return false;
14408                                                                                        }
14409                                                                                }
14410                                                                        } );
14411                                                                }
14412                                                        }
14413                                                } );
14414                                        }
14415
14416					if ( ',' === JSONValues.substr( -1 ) ) {
14417						JSONValues = JSONValues.slice( 0, -1 );
14418					}
14419
14420					JSONValues += ']';
14421
14422					$( '#job_business_price_list_content' ).val( JSONValues ).attr( 'value', JSONValues ).prop( 'innerHTML', JSONValues );
14423				}
14424
14425				setTimeout( function () {
14426					hasIssues = false;
14427				}, 20 );
14428			} );
14429
14430			if ( ! hasIssues ) {
14431
14432				/* Menu is required? */
14433				$( '#job_business_use_catalog' ).each( function () {
14434					var isRequired = $( this )[0].hasAttribute( 'required' );
14435					var hasSomeValue = false;
14436
14437					if ( isRequired ) {
14438						if ( $( '#job_business_use_price_list' ).is( ':checked' ) ) {
14439							$( '.listar-boxed-fields-price-list .listar-price-item .listar-price-item-title-val' ).each( function () {
14440								var fieldValue = $( this ).val();
14441
14442								if ( 'string' === typeof fieldValue && 'undefined' !== fieldValue && 'NaN' !== fieldValue && '0' !== fieldValue && '' !== fieldValue ) {
14443									fieldValue = fieldValue.trim();
14444
14445									if ( '' !== fieldValue ) {
14446										hasSomeValue = true;
14447									}
14448								}
14449							} );
14450						}
14451
14452						if ( $( '#job_business_use_catalog_documents' ).is( ':checked' ) ) {
14453							$( '.listar-boxed-fields-docs-upload input[type="file"], .listar-boxed-fields-docs-upload input[name*="current_job_business_document_"][type="hidden"]' ).each( function () {
14454								var fieldValue = $( this ).val();
14455
14456								if ( '' !== fieldValue && undefined !== fieldValue && 'undefined' !== fieldValue && 0 !== fieldValue ) {
14457									hasSomeValue = true;
14458								}
14459							} );
14460						}
14461
14462						if ( $( '#job_business_use_catalog_external' ).is( ':checked' ) ) {
14463							$( '.listar-boxed-fields-docs-external input[name*="_file_external"]' ).each( function () {
14464								var fieldValue = $( this ).val();
14465
14466								if ( '' !== fieldValue && undefined !== fieldValue && 'undefined' !== fieldValue && 0 !== fieldValue ) {
14467									hasSomeValue = true;
14468								}
14469							} );
14470						}
14471
14472						if ( ! hasSomeValue && $( this ).is( ':checked' ) ) {
14473							$( this )[0].click();
14474						}
14475					}
14476				} );
14477
14478				/* Convert <script> tags to <iframes> */
14479				$( '#submit-job-form' ).find( 'textarea' ).each( function () {
14480					var textareaContent = $( this ).val();
14481					var textareaContent2 = textareaContent;
14482
14483					if ( textareaContent.indexOf( '<script' ) >= 0 ) {
14484
14485						/* Until 5 scripts */
14486						textareaContent = textareaContent
14487							.replace( '<script', '<iframe data-script-form-field="true"' ).replace( '/script>', '/iframe>' ).replace( ' type="text/javascript"', '' ).replace( " type='text/javascript'", '' )
14488							.replace( '<script', '<iframe data-script-form-field="true"' ).replace( '/script>', '/iframe>' ).replace( ' type="text/javascript"', '' ).replace( " type='text/javascript'", '' )
14489							.replace( '<script', '<iframe data-script-form-field="true"' ).replace( '/script>', '/iframe>' ).replace( ' type="text/javascript"', '' ).replace( " type='text/javascript'", '' )
14490							.replace( '<script', '<iframe data-script-form-field="true"' ).replace( '/script>', '/iframe>' ).replace( ' type="text/javascript"', '' ).replace( " type='text/javascript'", '' )
14491							.replace( '<script', '<iframe data-script-form-field="true"' ).replace( '/script>', '/iframe>' ).replace( ' type="text/javascript"', '' ).replace( " type='text/javascript'", '' );
14492
14493					}
14494
14495					if ( textareaContent.indexOf( 'onclick' ) >= 0 ) {
14496
14497						/* Convert onclick tags to data-onclick */
14498						textareaContent = textareaContent.replace( 'onclick', 'data-onclick' );
14499					}
14500
14501					if ( textareaContent.indexOf( 'opentable.com' ) >= 0 ) {
14502						textareaContent = textareaContent
14503							.replace( 'opentable.com/widget/reservation/loader', 'opentable.com/restref/client/' );
14504					}
14505
14506					if ( textareaContent !== textareaContent2 ) {
14507						$( this ).val( textareaContent );
14508					}
14509				} );
14510
14511				var fixListingCoords = fixListingCoordinates( $( 'input[name="job_customlatitude"]' ), $( 'input[name="job_customlongitude"]' ) );
14512
14513				if ( ! fixListingCoords ) {
14514					e.preventDefault();
14515					e.stopPropagation();
14516				} else {
14517					var fixLastChar = fixLastCharacterCoordinates( $( 'input[name="job_customlatitude"]' ), $( 'input[name="job_customlongitude"]' ) );
14518					if ( ! fixLastChar ) {
14519						e.preventDefault();
14520						e.stopPropagation();
14521					}
14522				}
14523			}
14524		} );
14525
14526		thisElement = $( '.listar-logged-user-menu-wrapper' );
14527
14528		theBody.on( 'click', function ( e ) {
14529			var thisElement = $( e.target );
14530
14531			if ( thisElement.length && ! preventEvenCallStack2 && ! breakClickLoop ) {
14532
14533				if ( (
14534					'listar-logged-user-menu-wrapper' === thisElement.attr( 'class' ) ||
14535					'listar-logged-user-menu-wrapper' === thisElement.parent().attr( 'class' ) ||
14536					'listar-logged-user-menu-wrapper' === thisElement.parent().parent().attr( 'class' ) ||
14537					'listar-logged-user-menu-wrapper' === thisElement.parent().parent().parent().attr( 'class' ) ||
14538					'listar-logged-user-menu-wrapper' === thisElement.parent().parent().parent().parent().attr( 'class' ) ||
14539					'listar-logged-user-menu-wrapper' === thisElement.parent().parent().parent().parent().parent().attr( 'class' ) ||
14540					thisElement.hasClass( 'listar-user-login' )
14541				) ) {
14542					closeUserMenu  = false;
14543					breakClickLoop = true;
14544
14545					setTimeout( function () {
14546						breakClickLoop = false;
14547					}, 40 );
14548				} else {
14549					closeUserMenu = true;
14550					mouseleaveUserMenu();
14551				}
14552			}
14553		} );
14554
14555		$( '.listar-user-logged header .listar-user-buttons .listar-user-login' ).on( 'click', function ( e ) {
14556			var menuRight = thisElement.length ? thisElement.css( 'right' ) : 0;
14557			menuRight = parseInt( menuRight.replace( /[^-\d\.]/g, '' ), 10 );
14558
14559			e.preventDefault();
14560			e.stopPropagation();
14561
14562			if ( menuRight < 0 && viewport().width > 767 ) {
14563				toggleUserMenu();
14564			} else {
14565				$( toggler ).trigger( 'click' );
14566			}
14567		} );
14568
14569		$( '.listar-logged-user-menu-wrapper' ).on( 'mouseleave', function () {
14570			var thisElement = $( '.listar-logged-user-menu-wrapper' );
14571
14572			if ( '-500px' === thisElement.css( 'right' ) ) {
14573				thisElement.stop().animate( { 'right' : [ 0, 'easeOutExpo' ] }, { duration : 500 } );
14574			} else {
14575				thisElement.stop().animate( { 'right' : - 500 }, { duration : 500 } );
14576			}
14577		} );
14578
14579		/* Also, close .listar-logged-user-menu-wrapper if hovering on main menu links on */
14580		$( '#listar-primary-menu li, .listar-header-search-button' ).on( 'mouseenter click', function () {
14581			$( '.listar-logged-user-menu-wrapper' ).stop().animate( { 'right' : - 500 }, { duration : 500 } );
14582		} );
14583
14584		theBody.on( 'click', '.listar-review-popup .choose-rating span', function ( e ) {
14585			var i = $( e.target ).index();
14586			var rating = 5 - i;
14587
14588			$( e.target ).parent().find( 'span' ).removeClass( 'active' );
14589
14590			for ( var j = 0; j < rating; j++ ) {
14591				$( e.target ).parent().find( 'span' ).eq( 4 - j ).addClass( 'active' );
14592			}
14593
14594			$( e.target ).parent().find( 'input' ).attr( 'value', rating );
14595
14596		} );
14597
14598		$( '#job_useuseremail' ).on( 'click', function () {
14599			if ( $( '#job_useuseremail' ).is( ':checked' ) ) {
14600				$( '.fieldset-job_custom_email' ).css( { display : 'none' } );
14601			} else {
14602				$( '.fieldset-job_custom_email' ).css( { display : 'block' } );
14603			}
14604		} );
14605
14606		$( '#job_business_use_hours' ).on( 'click', function () {
14607			if ( $( this ).is( ':checked' ) ) {
14608				$( '.listar-business-hours-fields' ).removeClass( 'hidden' );
14609			} else {
14610				$( '.listar-business-hours-fields' ).addClass( 'hidden' );
14611			}
14612		} );
14613
14614		$( '#job_business_use_custom_excerpt' ).on( 'click', function () {
14615
14616			/* Display/hide custom excerpt field */
14617			toggleCheckboxDependantField( '#job_business_use_custom_excerpt', '.fieldset-job_business_custom_excerpt' );
14618		} );
14619
14620		$( '#job_business_use_booking' ).on( 'click', function () {
14621			if ( $( this ).is( ':checked' ) ) {
14622				$( '.fieldset-job_business_bookings_third_party_service' ).css( { display : 'block' } );
14623			} else {
14624				$( '.fieldset-job_business_bookings_third_party_service' ).css( { display : 'none' } );
14625			}
14626		} );
14627
14628		$( '#company_use_social_networks' ).on( 'click', function () {
14629			if ( $( this ).is( ':checked' ) ) {
14630				$( '.listar-business-social-network-fields' ).removeClass( 'hidden' );
14631			} else {
14632				$( '.listar-business-social-network-fields' ).addClass( 'hidden' );
14633			}
14634		} );
14635
14636		$( '#company_use_external_links' ).on( 'click', function () {
14637			if ( $( this ).is( ':checked' ) ) {
14638				$( '.listar-business-external-link-fields' ).removeClass( 'hidden' );
14639			} else {
14640				$( '.listar-business-external-link-fields' ).addClass( 'hidden' );
14641			}
14642		} );
14643
14644		$( '#company_use_rich_media' ).on( 'click', function () {
14645			if ( $( this ).is( ':checked' ) ) {
14646				$( '.listar-business-rich-media-fields' ).removeClass( 'hidden' );
14647			} else {
14648				$( '.listar-business-rich-media-fields' ).addClass( 'hidden' );
14649			}
14650		} );
14651
14652		$( '#job_business_use_products' ).on( 'click', function () {
14653			if ( $( this ).is( ':checked' ) ) {
14654				$( '.listar-business-products-fields' ).removeClass( 'hidden' );
14655			} else {
14656				$( '.listar-business-products-fields' ).addClass( 'hidden' );
14657			}
14658		} );
14659
14660		$( '#job_business_use_catalog' ).on( 'click', function () {
14661			if ( $( this ).is( ':checked' ) ) {
14662				$( '.listar-business-catalog-fields' ).removeClass( 'hidden' );
14663			} else {
14664				$( '.listar-business-catalog-fields' ).addClass( 'hidden' );
14665			}
14666		} );
14667
14668		$( '#job_business_use_booking' ).on( 'click', function () {
14669			if ( $( this ).is( ':checked' ) ) {
14670				$( '.listar-business-booking-fields' ).removeClass( 'hidden' );
14671			} else {
14672				$( '.listar-business-booking-fields' ).addClass( 'hidden' );
14673			}
14674		} );
14675
14676		$( theBody ).on( 'click', '#job_business_use_catalog_images', function () {
14677			if ( $( this ).is( ':checked' ) ) {
14678				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-gallery .listar-boxed-fields-inner' ).removeClass( 'hidden' );
14679			} else {
14680				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-gallery .listar-boxed-fields-inner' ).addClass( 'hidden' );
14681			}
14682		} );
14683
14684		$( theBody ).on( 'click', '#job_business_use_catalog_documents', function () {
14685			if ( $( this ).is( ':checked' ) ) {
14686				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-inner' ).removeClass( 'hidden' );
14687			} else {
14688				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-inner' ).addClass( 'hidden' );
14689			}
14690		} );
14691
14692		$( theBody ).on( 'click', '#job_business_use_price_list', function () {
14693			if ( $( this ).is( ':checked' ) ) {
14694				$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).removeClass( 'hidden' );
14695			} else {
14696				$( '.listar-business-catalog-fields.listar-boxed-fields-price-list .listar-boxed-fields-inner' ).addClass( 'hidden' );
14697			}
14698		} );
14699
14700		$( theBody ).on( 'click', '#job_business_use_catalog_external', function () {
14701			if ( $( this ).is( ':checked' ) ) {
14702				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-boxed-fields-inner' ).removeClass( 'hidden' );
14703			} else {
14704				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-external .listar-boxed-fields-inner' ).addClass( 'hidden' );
14705			}
14706		} );
14707
14708		$( theBody ).on( 'click', '#job_business_use_catalog_create', function () {
14709			if ( $( this ).is( ':checked' ) ) {
14710				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-creator .listar-boxed-fields-inner' ).removeClass( 'hidden' );
14711			} else {
14712				$( '.listar-business-catalog-fields.listar-boxed-fields-catalog-creator .listar-boxed-fields-inner' ).addClass( 'hidden' );
14713			}
14714		} );
14715
14716		executeOnLoadAndVisible();
14717		
14718		
14719
14720		/* xxx */
14721
14722		theBody.on( 'click', '.listar-show-more-social', function () {
14723			$( this ).css( 'display', 'none' );
14724			$( this ).parents( '.listar-boxed-fields-wrapper' ).find( 'fieldset' ).css( 'display', 'block' );
14725		} );
14726
14727		/* Return only acceptable characters for a phone number */
14728		$( '#submit-job-form #company_phone, #submit-job-form #company_fax, #submit-job-form #company_mobile, #submit-job-form #company_whatsapp' ).on( 'change paste keyup', function () {
14729			validatePhoneCharacters( $( this ) );
14730		} );
14731
14732		/* Return only characters for coordinates - 0 until 9 and dot (.) */
14733		$( 'input[name="job_customlatitude"], input[name="job_customlongitude"]' ).on( 'change paste keyup', function () {
14734			$( this ).attr( 'value', $( this ).attr( 'value' ).replace( /[^0-9\.-]/g, '' ) );
14735			fixListingCoordinates( $( 'input[name="job_customlatitude"]' ), $( 'input[name="job_customlongitude"]' ) );
14736		} );
14737
14738		/* Return only characters for princing fields - 0 until 9 and dot (.) */
14739		$( theBody ).on( 'change paste keyup', 'input[class*="price-range"], input[name*="priceaverage"]', function () {
14740			sanitizePricingFields( $( this ) );
14741		} );
14742
14743		$( '#listar_claim_sender_message' ).each( function () {
14744			var claimChars = $( this ).val();
14745
14746			if ( dataMinimumClaimTextChars > 0 && requiredClaimCharsField.length ) {
14747
14748				var missingChars = dataMinimumClaimTextChars - claimChars.length;
14749				missingChars = missingChars >= 0 ? missingChars : 0;
14750
14751				$( '.listar-claim-missing-chars' ).prop( 'innerHTML', missingChars );
14752
14753				$( this ).on( 'change paste keyup keydown', function () {
14754					var currentTextarea = $( this );
14755
14756					setTimeout( function () {
14757						claimChars = currentTextarea.val();
14758						missingChars = dataMinimumClaimTextChars - claimChars.length;
14759
14760						if ( missingChars > -1 ) {
14761							$( '.listar-claim-missing-chars' ).prop( 'innerHTML', missingChars );
14762						} else {
14763							$( '.listar-claim-missing-chars' ).prop( 'innerHTML', 0 );
14764						}
14765					}, 10 );
14766				} );
14767			}
14768		} );
14769
14770		/* Average price */
14771		$( theBody ).on( 'change paste keyup', '.listar-price-range-from, .listar-price-range-to', function () {
14772			setTimeout( function () {
14773				var
14774					from = $( '.listar-price-range-from' ).val(),
14775					to = $( '.listar-price-range-to' ).val(),
14776					average = $( '#job_priceaverage' ),
14777					value1 = 0,
14778					value2 = 0;
14779
14780				if ( '' !== from ) {
14781					value1 = parseInt( from, 10 );
14782				}
14783
14784				if ( '' !== to ) {
14785					value2 = parseInt( to, 10 );
14786				}
14787
14788				average.val( ( value1 + value2 ) / 2 );
14789			}, 200 );
14790		} );
14791
14792		theBody.on( 'click', '.listar-disable-click', function ( e ) {
14793			e.preventDefault();
14794			e.stopPropagation();
14795			return false;
14796		} );
14797
14798		theBody.on( 'click', '.listar-more-results, .listar-more-map-listing', function ( e ) {
14799			var
14800				renewCircleEvents,
14801				button = $( this );
14802
14803			if ( button.hasClass( 'listar-disable-click' ) ) {
14804				e.preventDefault();
14805				e.stopPropagation();
14806				return false;
14807			}
14808
14809			button.addClass( 'listar-loading-results' );
14810
14811			if ( ! button.hasClass( 'listar-go-to-listing-page' ) ) {
14812
14813				renewCircleEvents = setInterval( function () {
14814
14815					if ( ! theBody.hasClass( 'listar-loading-posts' ) ) {
14816						clearInterval( renewCircleEvents );
14817						circleEvents();
14818
14819						if ( $( '.listar-ajax-map-markers' ).length ) {
14820
14821							/* Geting the JSON from textarea element as string and convert it to a valid JSON object  */
14822
14823							/* listarMapMarkers is declared globally out of this file and it's value can be overwritten here */
14824							/* jshint ignore: start */
14825							listarMapMarkers = JSON.parse( '[' + $( '.listar-ajax-map-markers' ).prop( 'innerText' ) + ']' );
14826							/* jshint ignore: end */
14827
14828							markerCounterAfterLoad = listarMapMarkers.length;
14829
14830							if ( markerCounterAfterLoad ) {
14831								var tempMarkerArray = [];
14832
14833								for ( var n = 0; n < markerCounterAfterLoad; n++ ) {
14834									var tempMarker = listarMapMarkers[ n ];
14835
14836									if ( 'string' === typeof tempMarker.lat && 'string' === typeof tempMarker.lng ) {
14837										tempMarker.lat = tempMarker.lat.replace( /[^0-9\.-]/g, '' );
14838										tempMarker.lng = tempMarker.lng.replace( /[^0-9\.-]/g, '' );
14839									}
14840
14841									tempMarkerArray.push( tempMarker );
14842								}
14843
14844								window.listarMapMarkers = tempMarkerArray;
14845								markerCounterAfterLoad = listarMapMarkers.length;
14846							}
14847
14848							$( '.listar-ajax-map-markers' ).prop( 'outerHTML', '' );
14849							addAjaxMapMarkers();
14850							resetMap();
14851						}
14852					}
14853				}, 100 );
14854			}
14855		} );
14856
14857		theBody.on( 'click', '.listar-hero-header .listar-close-aside-listings', function () {
14858			var list = $( this ).parent();
14859			var listRight = list.css( 'right' );
14860
14861			if ( '0px' === listRight ) {
14862				$( this ).removeClass( 'icon-cross2' ).addClass( 'icon-location' );
14863				list.stop().animate( { right: - 290 }, { duration : 800 } );
14864			} else {
14865				$( this ).addClass( 'icon-cross2' ).removeClass( 'icon-location' );
14866				list.stop().animate( { right: 0 }, { duration : 800 } );
14867			}
14868		} );
14869
14870		theBody.on( 'mouseenter', '#listar-primary-menu .dropdown-toggle', function () {
14871			var heroPosts = $( '.listar-hero-header .listar-aside-list ' );
14872
14873			if ( heroPosts.length ) {
14874				heroPosts.stop().animate( { opacity : 0 }, { duration : 400 } );
14875			}
14876		} );
14877
14878		theBody.on( 'mouseleave', '#masthead', function () {
14879			var heroPosts = $( '.listar-hero-header .listar-aside-list ' );
14880
14881			if ( heroPosts.length ) {
14882				heroPosts.stop().animate( { opacity : 1 }, { duration : 400 } );
14883			}
14884		} );
14885
14886		var hasAlerted = false;
14887
14888		theBody.on( 'DOMSubtreeModified', '.select2-selection__rendered', function () {
14889			if ( ! hasAlerted ) {
14890				hasAlerted = true;
14891			}
14892
14893			if ( false === preventEvenCallStack6 ) {
14894				preventEvenCallStack6 = true;
14895
14896				verifySelect2SubtreePlaceholder();
14897
14898				setTimeout( function () {
14899					preventEvenCallStack6 = false;
14900				}, 50 );
14901			}
14902		} );
14903
14904		$( theBody ).on( 'select2:selecting', 'select[name*=job_hours]', function() {
14905			var theSelect = $( this );
14906
14907			setTimeout( function () {
14908				var selectedValue = theSelect.val();
14909
14910				theSelect.attr( 'value', selectedValue );
14911
14912				theSelect.find( 'option' ).each( function () {
14913					$( this ).removeAttr( 'selected' ).prop( 'selected', false );
14914
14915					if ( selectedValue === $( this ).attr( 'value' ) ) {
14916						$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
14917					}
14918				} );
14919
14920				theSelect.val( selectedValue );
14921
14922				checkCloseHourSelected( theSelect );
14923				checkOpenHourSelected( theSelect );
14924			}, 10 );
14925		} );
14926
14927		$( theBody ).on( 'select2:selecting', 'select[name*=company_business_rich_media_label]', function() {
14928			var theSelect = $( this );
14929
14930			setTimeout( function () {
14931				if ( 'custom' === theSelect.val() ) {
14932					theSelect.parents( '.fieldset-company_business_rich_media_label' ).siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
14933				} else {
14934					theSelect.parents( '.fieldset-company_business_rich_media_label' ).siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
14935				}
14936			}, 10 );
14937		} );
14938
14939		$( theBody ).on( 'select2:selecting', 'select[name*=job_business_products_label]', function() {
14940			var theSelect = $( this );
14941
14942			setTimeout( function () {
14943				if ( 'custom' === theSelect.val() ) {
14944					theSelect.parents( '.fieldset-job_business_products_label' ).siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
14945				} else {
14946					theSelect.parents( '.fieldset-job_business_products_label' ).siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
14947				}
14948			}, 10 );
14949		} );
14950
14951		$( theBody ).on( 'select2:selecting', 'select[name*=job_business_catalog_label]', function() {
14952			var theSelect = $( this );
14953
14954			setTimeout( function () {
14955				if ( 'custom' === theSelect.val() ) {
14956					theSelect.parents( '.fieldset-job_business_catalog_label' ).siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
14957				} else {
14958					theSelect.parents( '.fieldset-job_business_catalog_label' ).siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
14959				}
14960			}, 10 );
14961		} );
14962
14963		$( theBody ).on( 'select2:selecting', 'select[name*=job_business_booking_label]', function() {
14964			var theSelect = $( this );
14965
14966			setTimeout( function () {
14967				if ( 'custom' === theSelect.val() ) {
14968					theSelect.parents( '.fieldset-job_business_booking_label' ).siblings( '.listar-boxed-fields-inner' ).removeClass( 'hidden' );
14969				} else {
14970					theSelect.parents( '.fieldset-job_business_booking_label' ).siblings( '.listar-boxed-fields-inner' ).addClass( 'hidden' );
14971				}
14972			}, 10 );
14973		} );
14974
14975		$( theBody ).on( 'select2:selecting', 'select[name*=job_business_booking_method]', function() {
14976			var theSelect = $( this );
14977
14978			$( '.fieldset-job_business_bookings_third_party_service, .fieldset-job_business_bookings_products_description' ).addClass( 'hidden' );
14979
14980			setTimeout( function () {
14981				if ( 'external' === theSelect.val() ) {
14982					$( '.fieldset-job_business_bookings_third_party_service' ).removeClass( 'hidden' );
14983				} else if ( 'booking' === theSelect.val() ) {
14984					$( '.fieldset-job_business_bookings_products_description' ).removeClass( 'hidden' );
14985				}
14986			}, 10 );
14987		} );
14988
14989		$( theBody ).on( 'select2:selecting', 'select[name*=job_locationselector]', function() {
14990			var theSelect = $( this );
14991
14992			setTimeout( function () {
14993				if ( 'location-custom' === theSelect.val() ) {
14994					$( '.fieldset-job_customlocation' ).addClass( 'listar-unhide' );
14995					theSelect.parents( '.listar-custom-location-fields' ).removeClass( 'listar-remove-last-border' );
14996				} else {
14997					$( '.fieldset-job_customlocation' ).removeClass( 'listar-unhide' );
14998					theSelect.parents( '.listar-custom-location-fields' ).addClass( 'listar-remove-last-border' );
14999				}
15000			}, 10 );
15001		} );
15002		
15003		
15004
15005		/* xxx */ 
15006		
15007		
15008		
15009		
15010		
15011		
15012		
15013		
15014		
15015		
15016		
15017		
15018		
15019		
15020		
15021		
15022		
15023		
15024		
15025		
15026		
15027		
15028		
15029		
15030		
15031		
15032		
15033		
15034		
15035
15036
15037		/*xxx */ 
15038		
15039		
15040
15041		var isChangingSelect2Country = false;
15042
15043		$( theBody ).on( 'select2:selecting', '.listar-search-by-near-postcode-countries', function() {
15044			var theSelect = $( this );
15045
15046			if ( ! isChangingSelect2Country ) {
15047				isChangingSelect2Country = true;
15048
15049				setTimeout( function () {
15050					$( '.listar-search-by-near-address-countries' ).each( function () {
15051						var newSelect2Value = theSelect.val();
15052
15053						$( this ).find( 'option' ).each( function () {
15054							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
15055
15056							if ( newSelect2Value === $( this ).attr( 'value' ) ) {
15057								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
15058							}
15059						} );
15060
15061						theSelect.find( 'option' ).each( function () {
15062							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
15063
15064							if ( newSelect2Value === $( this ).attr( 'value' ) ) {
15065								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
15066							}
15067						} );
15068
15069						$( this ).attr( 'value', theSelect.val() ).val( theSelect.val() ).select2().trigger( 'change' );
15070						theSelect.attr( 'value', theSelect.val() ).val( theSelect.val() ).select2().trigger( 'change' );
15071
15072					} );
15073
15074					$( '.search-form input[name="' + listarLocalizeAndAjax.selectedCountryTranslation + '"]' ).each( function () {
15075						$( this ).val( theSelect.val() ).attr( 'value', theSelect.val() );
15076					} );
15077
15078					isChangingSelect2Country = false;
15079				}, 10 );
15080			}
15081		} );
15082
15083		$( theBody ).on( 'select2:selecting', '.listar-search-by-near-address-countries', function() {
15084			var theSelect = $( this );
15085
15086			if ( ! isChangingSelect2Country ) {
15087				isChangingSelect2Country = true;
15088
15089				setTimeout( function () {
15090					$( '.listar-search-by-near-postcode-countries' ).each( function () {
15091						var newSelect2Value = theSelect.val();
15092
15093						$( this ).find( 'option' ).each( function () {
15094							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
15095
15096							if ( newSelect2Value === $( this ).attr( 'value' ) ) {
15097								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
15098							}
15099						} );
15100
15101						theSelect.find( 'option' ).each( function () {
15102							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
15103
15104							if ( newSelect2Value === $( this ).attr( 'value' ) ) {
15105								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
15106							}
15107						} );
15108
15109						$( this ).attr( 'value', theSelect.val() ).val( theSelect.val() ).select2().trigger( 'change' );
15110						theSelect.attr( 'value', theSelect.val() ).val( theSelect.val() ).select2().trigger( 'change' );
15111					} );
15112
15113					$( '.search-form input[name="' + listarLocalizeAndAjax.selectedCountryTranslation + '"]' ).each( function () {
15114						$( this ).val( theSelect.val() ).attr( 'value', theSelect.val() );
15115					} );
15116
15117					isChangingSelect2Country = false;
15118				}, 10 );
15119			}
15120		} );
15121
15122		function tryNearestMePopup( forceNearest ) {
15123			var canSubmitAutomatically = true;
15124			var exploreBy = 'default';
15125
15126			if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' ).length || true === forceNearest ) {
15127				exploreBy = 'nearest_me';
15128
15129				var hasUserLatitudeAndLongitude = false;
15130				var userLatitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
15131				var userLongitudeField = $( 'input[name="listar_geolocated_data_latitude"]' );
15132
15133				if ( userLatitudeField.length && userLongitudeField.length ) {
15134					if ( '' !== userLatitudeField.val() && '' !==  userLongitudeField.val() ) {
15135						hasUserLatitudeAndLongitude = true;
15136					}
15137				}
15138
15139				if ( ! hasUserLatitudeAndLongitude) {
15140
15141					canSubmitAutomatically = false;
15142
15143					if ( $( '#menu-primary-menu .listar-header-search-button' ).length ) {
15144						$( '#menu-primary-menu .listar-header-search-button' ).eq( 0 )[0].click();
15145						
15146						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' ).length && $( '.search-form .listar-search-by-button' ).length ) {
15147							setTimeout( function () {
15148								$( '.search-form .listar-search-by-button' )[0].click();
15149							}, 500 );
15150
15151							setTimeout( function () {
15152								$( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' )[0].click();
15153							}, 600 );
15154						} else {
15155							forceNearestMePopup();
15156						}
15157					} else if ( $( '.search-form .listar-search-by-button' ).length ) {
15158						
15159						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' ).length && $( '.search-form .listar-search-by-button' ).length ) {
15160							$( '.search-form .listar-search-by-button' )[0].click();
15161
15162							setTimeout( function () {
15163								$( '.listar-search-by-options-wrapper a[data-explore-by-order="nearest_me"]' )[0].click();
15164							}, 100 );
15165						} else {
15166							forceNearestMePopup();
15167						}
15168					} else if ( true ===forceNearest ) {
15169						forceNearestMePopup();
15170					} else {
15171						canSubmitAutomatically = true;
15172					}
15173				} else {
15174					canSubmitAutomatically = true;
15175				}
15176			} else {
15177				exploreBy = 'default';
15178			}
15179
15180			return [ canSubmitAutomatically, exploreBy ];
15181		}
15182		
15183		/*
15184		 * Force Select2 deselect for dynamic select2 <option>s,
15185		 * like Ajax search filter <options> that are created dynamically.
15186		 **/
15187		
15188		theBody.on("select2:unselect", 'select[data-select2-id]', function(e){
15189			if ( 'undefined' !== typeof e.params.data.id ) {
15190				var wanted_id = e.params.data.id;
15191				var wanted_option = $( this ).find( 'option[value="'+ wanted_id +'"]' );
15192
15193				wanted_option.prop('selected', false);
15194				$( this ).trigger('change.select2');
15195			}
15196		} );
15197
15198		theBody.on( 'change', '.listar-filter-form-wrapper select', function () {
15199			var currentSelect = $( this );
15200
15201			
15202			setTimeout( function () {
15203
15204				var standardSearchForm = $( '.search-form' );
15205				var canSubmitAutomatically = true;
15206
15207				if ( $( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).length && $( '.listar-search-sort-listings' ).length ) {
15208					var sortOrder = $( '.listar-search-sort-listings' ).val();
15209					var exploreBy = 'default';
15210
15211					if (
15212						'newest' === sortOrder ||
15213						'oldest' === sortOrder ||
15214						'asc' === sortOrder ||
15215						'desc' === sortOrder
15216					) {
15217						exploreBy = 'default';
15218					} else if ( 'random' === sortOrder ) {
15219						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="random"]' ).length ) {
15220							exploreBy = 'surprise';
15221						} else {
15222							exploreBy = 'default';
15223						}
15224					} else if ( 'best_rated' === sortOrder ) {
15225						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="best_rated"]' ).length ) {
15226							exploreBy = 'best_rated';
15227						} else {
15228							exploreBy = 'default';
15229						}
15230					} else if ( 'most_viewed' === sortOrder ) {
15231						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="most_viewed"]' ).length ) {
15232							exploreBy = 'most_viewed';
15233						} else {
15234							exploreBy = 'default';
15235						}
15236					} else if ( 'most_bookmarked' === sortOrder ) {
15237						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="most_bookmarked"]' ).length ) {
15238							exploreBy = 'most_bookmarked';
15239						} else {
15240							exploreBy = 'default';
15241						}
15242					} else if ( 'nearest_me' === sortOrder ) {
15243						var tempVar = tryNearestMePopup();
15244
15245						canSubmitAutomatically = tempVar[0];
15246						exploreBy = tempVar[1];
15247					} else if ( 'near_address' === sortOrder ) {
15248						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="near_address"]' ).length ) {
15249							exploreBy = 'near_address';
15250							canSubmitAutomatically = false;
15251
15252							standardSearchForm.each( function () {
15253								var addressSaved = $( this ).find( 'input[name="' + listarLocalizeAndAjax.savedAddressTranslation + '"]' ).val();
15254								$( this ).find( 'input[data-name="s"]' ).val( addressSaved );
15255							} );
15256
15257							if ( $( '#menu-primary-menu .listar-header-search-button' ).length && listarLocalizeAndAjax.listingSortTranslation === currentSelect.attr( 'name' ) ) {
15258								$( '#menu-primary-menu .listar-header-search-button' ).eq( 0 )[0].click();
15259
15260								setTimeout( function () {
15261									$( '.search-form .listar-search-by-button' )[0].click();
15262								}, 500 );
15263
15264								setTimeout( function () {
15265									$( '.listar-search-by-options-wrapper a[data-explore-by-order="near_address"]' )[0].click();
15266								}, 510 );
15267							} else {
15268								canSubmitAutomatically = true;
15269							}
15270						} else {
15271							exploreBy = 'default';
15272							canSubmitAutomatically = true;
15273						}
15274					} else if ( 'near_postcode' === sortOrder ) {
15275						if ( $( '.listar-search-by-options-wrapper a[data-explore-by-order="near_postcode"]' ).length ) {
15276							exploreBy = 'near_postcode';
15277							canSubmitAutomatically = false;
15278
15279							standardSearchForm.each( function () {
15280								var postcodeSaved = $( this ).find( 'input[name="' + listarLocalizeAndAjax.savedPostcodeTranslation + '"]' ).val();
15281								$( this ).find( 'input[data-name="s"]' ).val( postcodeSaved );
15282							} );
15283
15284							if ( $( '#menu-primary-menu .listar-header-search-button' ).length && listarLocalizeAndAjax.listingSortTranslation === currentSelect.attr( 'name' ) ) {
15285								$( '#menu-primary-menu .listar-header-search-button' ).eq( 0 )[0].click();
15286
15287								setTimeout( function () {
15288									$( '.search-form .listar-search-by-button' )[0].click();
15289								}, 500 );
15290
15291								setTimeout( function () {
15292									$( '.listar-search-by-options-wrapper a[data-explore-by-order="near_postcode"]' )[0].click();
15293								}, 510 );
15294							} else {
15295								canSubmitAutomatically = true;
15296							}
15297						} else {
15298							exploreBy = 'default';
15299							canSubmitAutomatically = true;
15300						}
15301					}
15302
15303					$( 'input[name="' + listarLocalizeAndAjax.listingSortTranslation + '"]' ).val( sortOrder );
15304					$( 'input[name="' + listarLocalizeAndAjax.exploreByTranslation + '"]' ).val( exploreBy );
15305				}
15306
15307				if ( $( 'input[name="' + listarLocalizeAndAjax.listingRegionsTranslation + '"]' ).length && $( '.listar-search-filter-regions' ).length ) {
15308					$( 'input[name="' + listarLocalizeAndAjax.listingRegionsTranslation + '"]' ).val( $( '.listar-search-filter-regions' ).val() );
15309				}
15310
15311				if ( $( 'input[name="' + listarLocalizeAndAjax.listingCategoriesTranslation + '"]' ).length && $( '.listar-search-filter-categories' ).length ) {
15312					$( 'input[name="' + listarLocalizeAndAjax.listingCategoriesTranslation + '"]' ).val( $( '.listar-search-filter-categories' ).val() );
15313				}
15314
15315				if ( $( 'input[name="' + listarLocalizeAndAjax.listingAmenitiesTranslation + '"]' ).length && $( '.listar-search-filter-amenities' ).length ) {
15316					$( 'input[name="' + listarLocalizeAndAjax.listingAmenitiesTranslation + '"]' ).val( $( '.listar-search-filter-amenities' ).val() );
15317				}
15318
15319				if ( canSubmitAutomatically ) {
15320					if ( standardSearchForm.length ) {
15321						$( '.listar-search-by-options-wrapper a[data-explore-by-order="' + exploreBy + '"]' ).each( function () {
15322							$( this )[0].click();
15323						} );
15324
15325						standardSearchForm.submit();
15326					} else {
15327						$( '.listar-filter-form-wrapper form' ).submit();
15328					}
15329				}
15330			}, 10 );
15331		} );
15332
15333		theBody.on( 'click', function ( e ) {
15334			if ( $( e.target ).hasClass( 'select2-selection__choice__remove' ) ) {
15335				var select,
15336					options,
15337					visibleSelected,
15338					selectClass = $( e.target ).attr( 'class' ).split( '____' );
15339
15340				selectClass = selectClass[1];
15341				select  = $( '.' + selectClass );
15342				options = select.find( 'option' );
15343				visibleSelected = select.siblings( '.select2-container' ).find( '.select2-selection__choice' );
15344
15345				if ( select.length ) {
15346					if ( select[0].hasAttribute( 'data-selected-count' ) ) {
15347						if ( '1' === select.attr( 'data-selected-count' ) ) {
15348							select.attr( 'data-selected-count', '' );
15349							select.val( '' );
15350							options.removeAttr( 'selected' ).prop( 'selected', false );
15351
15352							$( 'body.search, body.archive' ).addClass( 'listar-hide-select2-dropdown' );
15353
15354							setTimeout( function () {
15355								select  = $( '.' + selectClass );
15356								visibleSelected = select.siblings( '.select2-container' ).find( '.select2-selection__choice' );
15357
15358								if ( visibleSelected.length ) {
15359									visibleSelected.prop( 'outerHTML', '' );
15360									$( '.listar-filter-form-wrapper select' ).eq( 0 ).trigger( 'change' );
15361								}
15362							}, 15 );
15363						}
15364					}
15365				}
15366			}
15367		} );
15368
15369		theBody.on( 'click', '.listar-newsletter-submit', function () {
15370			$( this ).closest( 'form' ).submit();
15371		} );
15372
15373		$( '.select2-search__field' ).keyup( function () {
15374			var thisSelect2Expanded = $( this ).parents( '.select2-selection[aria-expanded=true]' );
15375
15376			if ( thisSelect2Expanded && '' === $( this ).val() ) {
15377				prepareSelect2Hierarchy( thisSelect2Expanded );
15378			}
15379		} );
15380
15381		theBody.on( 'click', '.select2-selection[aria-expanded=true]', function () {
15382			var thisSelect2Expanded = $( this );
15383			prepareSelect2Hierarchy( thisSelect2Expanded );
15384		} );
15385
15386		theBody.on( 'click', '.listar-package-clickable-area', function ( e ) {
15387			var button = $( this ).parents( '.listar-package-standard-form' );
15388
15389			if ( isClaimingListing ) {
15390				e.preventDefault();
15391				e.stopPropagation();
15392
15393				// Claiming listing.
15394				currentClaimPackageID = button.find( 'a[data-package]' ).attr( 'data-
15394package' );
15395
15396				stopScrolling( 1 );
15397				$( '.listar-claim-popup' ).addClass( 'listar-showing-claim' ).css( { left : 0, opacity : 1 } );
15398
15399			} else if ( button.length > 0 ) {
15400				button = button.find( 'input[type="radio"]' );
15401
15402				if ( button.length > 0 ) {
15403
15404					button.prop( 'checked', true );
15405					button.parents( 'form' ).submit();
15406
15407					e.preventDefault();
15408					e.stopPropagation();
15409
15410					isStandardPackage = true;
15411
15412					return false;
15413				}
15414			}
15415		} );
15416
15417		theBody.on( 'click', '.listar-package-content', function ( e ) {
15418			if ( ! isStandardPackage ) {
15419				var button = $( this ).find( '.button' );
15420
15421				if ( button.length && ! preventEvenCallStack4 ) {
15422					preventEvenCallStack4 = true;
15423
15424					if ( '#' !== button.attr( 'href' ) ) {
15425						$( location ).attr( 'href', button.attr( 'href' ) );
15426					}
15427				}
15428			} else {
15429				e.preventDefault();
15430				e.stopPropagation();
15431			}
15432		} );
15433
15434		theBody.on( 'click', '.listar-featured-listing-term-item, .listar-listing-card', function ( e ) {
15435			var thisElem = $( this ).parent();
15436
15437			if ( thisElem.hasClass( 'owl-item' ) ) {
15438				if ( ! thisElem.hasClass( 'active' ) ) {
15439					e.preventDefault();
15440					e.stopPropagation();
15441
15442					preventEvenCallStack5 = true;
15443
15444					if ( e.clientX > viewport().width / 2 ) {
15445						thisElem.parent().parent().parent().find( '.owl-next' ).trigger( 'click' );
15446					} else {
15447						thisElem.parent().parent().parent().find( '.owl-prev' ).trigger( 'click' );
15448					}
15449
15450					if ( $( this ).find( ".listar-card-content-image" ).length ) {
15451						$( this ).find( ".listar-card-content-image" ).trigger( 'mouseleave' );
15452					}
15453
15454					setTimeout( function () {
15455						preventEvenCallStack5 = false;
15456					}, 50 );
15457				}
15458			}
15459		} );
15460
15461		theBody.on( 'click', '.listar-listing-regions-popup .listar-featured-listing-term-item', function ( e ) {
15462			var termID = 0,
15463				termName = 0,
15464				thisElem = $( this ).find( 'a' );
15465
15466			if ( ! forceTermClick ) {
15467				e.preventDefault();
15468				e.stopPropagation();
15469			}
15470
15471			if ( ! disableRegionSelector ) {
15472				if ( ! preventEvenCallStack5 ) {
15473					termID = thisElem.attr( 'data-term-id' );
15474					termName = thisElem.attr( 'data-term-name' );
15475
15476					$( '.listar-listing-regions-popup .listar-back-site' ).trigger( 'click' );
15477
15478					setTimeout( function () {
15479						$( '.listar-all-regions-button.current span strong' ).prop( 'innerHTML', termName );
15480						$( '.listar-chosen-region' ).val( termID );
15481						$( '.listar-all-regions-button' ).addClass( 'listar-has-selected-region' );
15482
15483						if ( theBody.hasClass( 'listar-after-region-selected-search-immediately' ) ) {
15484							$( '.listar-search-submit' )[0].click();
15485						}
15486					}, 50 );
15487				}
15488
15489				if ( $( '.listar-front-header' ).length ) {
15490					stopScrolling( 0 );
15491				}
15492			}
15493		} );
15494
15495		theBody.on( 'click', '.listar-partners a[href="#"]', function ( e ) {
15496			e.preventDefault();
15497			e.stopPropagation();
15498			return false;
15499		} );
15500
15501		theBody.on( 'click', '.wp-caption-text', function () {
15502			if ( $( this ).siblings( '.gallery-icon' ).find( 'a' ).length ) {
15503				$( this ).siblings( '.gallery-icon' ).find( 'a' ).trigger( 'click' );
15504			}
15505		} );
15506
15507		theBody.on( 'click', '.listar-map-launch-wrapper button', function ( e ) {
15508			e.preventDefault();
15509			e.stopPropagation();
15510
15511			$( this ).parent().parent().removeClass( 'listar-hidden-map' );
15512			$( this ).parent().css( { display : 'none' } );
15513			$( this ).parents( '.listar-front-widget-wrapper' ).addClass( 'listar-map-launched' );
15514		} );
15515
15516		theBody.on( 'mouseenter', '.listar-feature-item a', function () {
15517			if ( siblingsOpacityEnabled ) {
15518				$( this ).parents( '.listar-feature-items' ).addClass( 'listar-hovering-features' );
15519			} else {
15520				$( this ).parents( '.listar-feature-items' ).addClass( 'listar-hovering-features-grey' );
15521			}
15522		} );
15523
15524		theBody.on( 'mouseleave', '.listar-feature-item a', function () {
15525			if ( siblingsOpacityEnabled ) {
15526				$( this ).parents( '.listar-feature-items' ).removeClass( 'listar-hovering-features' );
15527			} else {
15528				$( this ).parents( '.listar-feature-items' ).removeClass( 'listar-hovering-features-grey' );
15529			}
15530		} );
15531
15532		theBody.on( 'mouseenter', '.listar-listing-gallery.listar-gallery-dark .gallery-item a,.listar-listing-gallery-nav-previous,.listar-listing-gallery-nav-next', function () {
15533			var gallery = listingGallery;
15534
15535			if ( ! theBody.hasClass( 'listar-listing-has-slideshow-cover' ) ) {
15536				$( this ).parent().addClass( 'listar-dark-overlay' );
15537				$( this ).parent().find( '.listar-listing-gallery-item-caption' ).stop().animate( { opacity : 0 }, { duration : 1000 } );
15538
15539				gallery.addClass( 'listar-hovering-gallery' );
15540			}
15541
15542			checkGalleryHoverTimeout( gallery );
15543			hasGalleryMouseleave = false;
15544		} );
15545
15546		theBody.on( 'mouseleave', '.listar-listing-gallery.listar-gallery-dark .gallery-item a,.listar-listing-gallery-nav-previous,.listar-listing-gallery-nav-next', function () {
15547			var gallery = listingGallery;
15548
15549			if ( ! theBody.hasClass( 'listar-listing-has-slideshow-cover' ) ) {
15550				listingGalleryLinks.parent().removeClass( 'listar-dark-overlay' );
15551				$( this ).parent().find( '.listar-listing-gallery-item-caption' ).stop().animate( { opacity : 1 }, { duration : 1000 } );
15552
15553				gallery.removeClass( 'listar-hovering-gallery' );
15554			}
15555
15556			hasGalleryMouseleave = true;
15557			checkGalleryHoverTimeout( gallery);
15558		} );
15559
15560		theBody.on( 'mouseenter', '.listar-regions a, .listar-term-items a', function () {
15561			if ( $( this ).parents( '.owl-item' ).length ) {
15562				if ( 0 === $( this ).parents( '.owl-item.active' ).length ) {
15563					return;
15564				}
15565			}
15566
15567			if ( siblingsOpacityEnabled ) {
15568				$( this ).parents( '.listar-featured-listing-regions, .listar-term-items' ).addClass( 'listar-hovering-terms' );
15569			}
15570		} );
15571
15572		theBody.on( 'mouseleave', '.listar-regions a, .listar-term-items a', function () {
15573			if ( $( this ).parents( '.owl-item' ).length ) {
15574				if ( 0 === $( this ).parents( '.owl-item.active' ).length ) {
15575					return;
15576				}
15577			}
15578
15579			if ( siblingsOpacityEnabled ) {
15580				$( this ).parents( '.listar-featured-listing-regions, .listar-term-items' ).removeClass( 'listar-hovering-terms' );
15581			}
15582		} );
15583
15584		theBody.on( 'mouseenter', '.listar-partners .listar-partner-has-url', function () {
15585			if ( siblingsOpacityEnabled ) {
15586				$( this ).parents( '.listar-partners' ).addClass( 'listar-hovering-partners' );
15587			}
15588		} );
15589
15590		theBody.on( 'mouseleave', '.listar-partners .listar-partner-has-url', function () {
15591			if ( siblingsOpacityEnabled ) {
15592				$( this ).parents( '.listar-partners' ).removeClass( 'listar-hovering-partners' );
15593			}
15594		} );
15595
15596		theBody.on( 'mouseenter', '.listar-package-content', function () {
15597			if ( siblingsOpacityEnabled ) {
15598				$( this ).parents( '.listar-pricing-table' ).addClass( 'listar-hovering-prices' );
15599			}
15600		} );
15601
15602		theBody.on( 'mouseleave', '.listar-package-content', function () {
15603			if ( siblingsOpacityEnabled ) {
15604				$( this ).parents( '.listar-pricing-table' ).removeClass( 'listar-hovering-prices' );
15605			}
15606		} );
15607
15608		$( '.entry-content .listar-wavy-badge-design' ).on( 'mousemove', function ( e ) {
15609			if ( ! isMobile() && viewport().width > 768 && viewport().width > viewport().height && ! animatingMask && $( this ).find( '.listar-animate-wavy-badge' ).length ) {
15610
15611				var moveX = ( ( $( window ).width() / 2 ) - e.pageX ) * 0.1;
15612				var currentMaskYPosition = $( this ).offset().top;
15613				var moveY = ( ( $( window ).height() / 2 ) + currentMaskYPosition - e.pageY ) * 0.1;
15614
15615				moveY = moveY > 50 ? 50 : moveY;
15616				moveY = moveY < ( -50 ) ? -50 : moveY;
15617
15618				animatingMask = true;
15619
15620				$( this ).find( '.listar-badge-masked-container .listar-masked-image' ).css( { marginLeft : moveX + 'px', marginTop : moveY + 'px' } );
15621
15622				setTimeout( function () {
15623					animatingMask = false;
15624				}, 500 );
15625
15626			}
15627		} );
15628
15629		$( '.listar-cloudify-parallax' ).on( 'mousemove', function ( e ) {
15630			if ( ! isMobile() && viewport().width > 768 && viewport().width > viewport().height && ! animatingMask ) {
15631
15632				var moveX = ( ( $( window ).width() / 2 ) - e.pageX ) * 0.1;
15633				var currentMaskYPosition = $( this ).offset().top;
15634				var moveY = ( ( $( window ).height() / 2 ) + currentMaskYPosition - e.pageY ) * 0.1;
15635
15636				animatingMask = true;
15637
15638				$( this ).find( '.listar-do-cloudify' ).each( function () {
15639					$( this ).css( { marginLeft : moveX * 0.6 + 'px', marginTop : moveY + 'px' } );
15640				} );
15641
15642				setTimeout( function () {
15643					animatingMask = false;
15644				}, 500 );
15645
15646			}
15647		} );
15648
15649		theBody.on( 'mouseenter', '.widget_listar_listing_amenities .listar-term-link', function () {
15650			var thisAmenity = $( this );
15651			var amenityColor = thisAmenity.siblings( '.listar-term-inner' ).find( '.listar-term-background-overlay' ).css( 'background-color' );
15652			thisAmenity.parents( '.listar-featured-listing-term-item' ).removeClass( 'listar-not-hovering' );
15653			thisAmenity.parents( '.listar-featured-listing-term-item' ).siblings().addClass( 'listar-not-hovering' );
15654			thisAmenity.parents( '.listar-term-items' ).find( '.listar-term-text' ).css( { 'background-color' : "#fff", color : '#444' } );
15655			thisAmenity.siblings( '.listar-term-inner' ).find( '.listar-term-text' ).css( { 'background-color' : amenityColor, color : '#ffffff' } );
15656		} );
15657
15658		theBody.on( 'mouseleave', '.widget_listar_listing_amenities .listar-term-link', function () {
15659			$( this ).parents( '.listar-term-items' ).find( '.listar-term-text' ).css( { 'background-color' : "#fff", color : '#444' } );
15660			$( this ).parents( '.listar-term-items' ).find( '.listar-featured-listing-term-item' ).removeClass( 'listar-not-hovering' );
15661		} );
15662
15663		$( theBody ).on( 'mouseenter', '.listar-primary-navigation-wrapper .navbar-nav.listar-too-high-menu', function () {
15664			var highMenu = $( this );
15665
15666			setTimeout( function () {
15667				if ( viewport().width > 767 ) {
15668					var menuScrollHeight = highMenu[0].scrollHeight;
15669
15670					if ( $( '.page-template-front-page.listar-frontpage-topbar-transparent .site-header.listar-light-design .listar-header-background-animation-wrapper' ).length ) {
15671						$( '.listar-header-background-animation-wrapper' ).css( { top : menuScrollHeight - 50, opacity : 1 } );
15672					} else {
15673						$( '.listar-header-background-animation-wrapper' ).css( { top : menuScrollHeight - 50 } );
15674					}
15675				}
15676			}, 10 );
15677		} );
15678
15679		$( theBody ).on( 'mouseleave', '.listar-primary-navigation-wrapper .navbar-nav.listar-too-high-menu', function () {
15680			setTimeout( function () {
15681				if ( viewport().width > 767 ) {
15682					if ( $( '.page-template-front-page.listar-frontpage-topbar-transparent .site-header.listar-light-design .listar-header-background-animation-wrapper' ).length ) {
15683						$( '.listar-header-background-animation-wrapper' ).css( { top : '', opacity : '' } );
15684					} else {
15685						$( '.listar-header-background-animation-wrapper' ).css( { top : '' } );
15686					}
15687				}
15688			}, 10 );
15689		} );
15690
15691		$( theBody ).on( 'click', '.listar-testimonial-avatar', function () {
15692			var index = $( this ).index();
15693			$( this ).addClass( 'current' );
15694			$( this ).siblings().removeClass( 'current' );
15695
15696			$( this ).parents( '.listar-review-items' ).find( '.listar-testimonial-item' ).eq( index ).siblings().stop().animate( { opacity : 0 }, {  duration : 500, complete : function () {
15697				$( this )
15698					.css( { display : 'none' } )
15699					.removeClass( 'current' );
15700
15701				$( this ).parents( '.listar-review-items' ).find( '.listar-testimonial-item' ).eq( index )
15702					.css( { display : 'block' } )
15703					.addClass( 'current' )
15704					.stop().animate( { opacity : 1 }, {  duration : 500 } );
15705			} } );
15706		} );
15707
15708		$( theBody ).on( 'click', '.listar-back-to-top', function () {
15709			$( 'html, body' ).animate( { scrollTop: 0 }, 1000 );
15710		} );
15711
15712		$( theBody ).on( 'mouseenter', '.listar-listing-gallery a', function () {
15713			var gallery   = listingGallery;
15714			var galleryBG = $( '.listar-listing-gallery-backgrounds' );
15715
15716
15717			if ( gallery.hasClass( 'listar-gallery-dark' ) ) {
15718				galleryBG.css( { 'background-image' : 'url(' + $( this ).attr( 'href' ) + ')' } );
15719			}
15720		} );
15721
15722		$( theBody ).on( 'click', '.listar-listing-gallery-nav-next', function () {
15723			currentListingGallerySlide++;
15724
15725			if ( currentListingGallerySlide < maxListingGallerySlides ) {
15726				listingGallery.find( '.listar-gallery-slideshow-slides-wrapper' ).css( { marginLeft : -1 * ( currentListingGallerySlide * slideWidth ) } );
15727			} else {
15728				currentListingGallerySlide = 0;
15729				listingGallery.find( '.listar-gallery-slideshow-slides-wrapper' ).css( { marginLeft : 0 } );
15730			}
15731		} );
15732
15733		$( theBody ).on( 'click', '.listar-listing-gallery-nav-previous', function () {
15734			currentListingGallerySlide--;
15735
15736			if ( currentListingGallerySlide < 0 ) {
15737				var countSlides = listingGallery.find( '.listar-gallery-slideshow-slides .gallery-item' ).length - 3;
15738				currentListingGallerySlide = countSlides;
15739
15740				listingGallery.find( '.listar-gallery-slideshow-slides-wrapper' ).css( { marginLeft : -1 * ( countSlides * slideWidth ) } );
15741			} else {
15742				listingGallery.find( '.listar-gallery-slideshow-slides-wrapper' ).css( { marginLeft : -1 * ( currentListingGallerySlide * slideWidth ) } );
15743			}
15744		} );
15745
15746		$( theBody ).on( 'mouseenter', '.listar-gallery-slideshow-thumbs .gallery-item', function () {
15747			currentListingGallerySlide = $( this ).index();
15748
15749			listingGallery.find( '.listar-gallery-slideshow-slides-wrapper' ).css( { marginLeft : -1 * ( currentListingGallerySlide * slideWidth ) } );
15750		} );
15751
15752		$( '.listar-ajax-pagination' ).on( 'click', '.listar-blog-card.listar-grid-filler .listar-card-content a', function ( e ) {
15753			var loadMore = $( '.listar-load-more-section .listar-more-results' );
15754			var isFallbackBlogButton = $( this ).parent().find( '.listar-fallback-blog-button' );
15755			var hasCustomLink = $( this ).hasClass( 'listar-has-custom-card-link' ) ? true : false;
15756
15757			if ( loadMore.length && ( isFallbackBlogButton.length || ! hasCustomLink ) ) {
15758				e.preventDefault();
15759				e.stopPropagation();
15760
15761				loadMore.trigger( 'click' );
15762			}
15763		} );
15764
15765		$( '.listar-social-share-options a, .listar-social-share-networks-wrapper .listar-social-networks a' ).on( 'click', function ( e ) {
15766			if ( ! $( this ).hasClass( 'listar-social-share-button-mail' ) && ! $( this ).hasClass( 'listar-social-share-button-copy' ) ) {
15767				e.preventDefault();
15768				e.stopPropagation();
15769
15770				if ( $( this ).hasClass( 'listar-social-share-other' ) ) {
15771					stopScrolling( 1 );
15772					$( '.listar-social-share-popup' ).addClass( 'listar-showing-share' ).css( { left : 0, opacity : 1 } );
15773				} else {
15774					var
15775						hasScrollBar = $( this ).find( '.fa-pinterest' ).length ? 'no' : 'yes',
15776						popupTop     = screen.height / 2 - 200,
15777						popupLeft    = screen.width / 2 - 300;
15778
15779					window.open( this.href, 'targetWindow', [ 'toolbar=no', 'location=no', 'status=no', 'menubar=no', 'scrollbars=' + hasScrollBar, 'resizable=yes', 'width=600', 'height=400', 'top=' + popupTop, 'left=' + popupLeft ].join( ',' ) );
15780				}
15781			}
15782		} );
15783
15784		$( theBody ).on( 'click', '.listar-listing-header-plus-button', function ( e ) {
15785			e.preventDefault();
15786			e.stopPropagation();
15787
15788			var theButton = $( this );
15789
15790			if ( theButton.find( '.icon-plus' ).length ) {
15791				theButton.parents( '.listar-listing-header-topbar-wrapper' ).addClass( 'listar-show-all-topbar-buttons' );
15792				theBody.addClass( 'listar-showing-all-topbar-buttons' );
15793				theButton.find( '.icon-plus' )
15794					.removeClass( 'icon-plus' )
15795					.addClass( 'icon-minus' );
15796			} else {
15797				theButton.parents( '.listar-listing-header-topbar-wrapper' ).removeClass( 'listar-show-all-topbar-buttons' );
15798				theBody.removeClass( 'listar-showing-all-topbar-buttons' );
15799				theButton.find( '.icon-minus' )
15800					.addClass( 'icon-plus' )
15801					.removeClass( 'icon-minus' );
15802			}
15803		} );
15804
15805		$( theBody ).on( 'click', '.listar-custom-checkbox', function () {
15806			var checkbox = $( this ).find( 'input[type="checkbox"]' );
15807
15808			if( checkbox.is( ':checked' ) ) {
15809				checkbox.parent().addClass( 'listar-custom-checkbox-checked' );
15810			} else {
15811				checkbox.parent().removeClass( 'listar-custom-checkbox-checked' );
15812			}
15813		} );
15814
15815		$( theBody ).on( 'click', '.listar-listing-header-video-button', function ( e ) {
15816			e.preventDefault();
15817			e.stopPropagation();
15818
15819			var listingVideo = $( '.listar-business-video-accordion a' );
15820
15821			if ( listingVideo.length ) {
15822				listingVideo[0].click();
15823			}
15824		} );
15825
15826		$( theBody ).on( 'click', '.listar-listing-header-gallery-button', function ( e ) {
15827			e.preventDefault();
15828			e.stopPropagation();
15829
15830			var galleryThumbURLs = $( '.listar-listing-gallery .gallery-item a' );
15831
15832			if ( galleryThumbURLs.length ) {
15833				galleryThumbURLs.eq( 0 ).trigger( 'click' );
15834			}
15835		} );
15836
15837		$( theBody ).on( 'click', '.listar-listing-header-copy-button, .listar-social-share-button-copy', function ( e ) {
15838			e.preventDefault();
15839			e.stopPropagation();
15840
15841			copyTextToClipboard( currentURL );
15842
15843			var labelElement = $( this ).find( '.listar-listing-header-topbar-item-label' );
15844			var label = labelElement.attr( 'data-copy-text' );
15845			var copiedLabel = labelElement.attr( 'data-copied-text' );
15846
15847			labelElement.prop( 'innerHTML', copiedLabel );
15848
15849			setTimeout( function () {
15850				labelElement.prop( 'innerHTML', label );
15851			}, 2000 );
15852		} );
15853
15854		$( theBody ).on( 'click', '.listar-more-sharing-networks-button', function ( e ) {
15855			e.preventDefault();
15856			e.stopPropagation();
15857
15858			if ( $( this ).hasClass( 'icon-plus' ) ) {
15859				$( this ).removeClass( 'icon-plus' );
15860				$( this ).addClass( 'icon-minus' );
15861				$( this ).parents( '.listar-social-share-popup' ).addClass( 'listar-show-all-sharing-networks' );
15862			} else {
15863				$( this ).addClass( 'icon-plus' );
15864				$( this ).removeClass( 'icon-minus' );
15865				$( this ).parents( '.listar-social-share-popup' ).removeClass( 'listar-show-all-sharing-networks' );
15866			}
15867		} );
15868
15869		$( theBody ).on( 'click', '.listar-business-video-accordion .icon-play-circle', function ( e ) {
15870			e.preventDefault();
15871			e.stopPropagation();
15872
15873			$( this ).parents( '.panel-heading' ).siblings( '.listar-video-url-wrapper' ).find( 'a' )[0].click();
15874		} );
15875
15876		$( theBody ).on( 'click', '.listar-copy-day-button', function ( e ) {
15877			e.preventDefault();
15878			e.stopPropagation();
15879
15880			var dayPrefix = [
15881				'mon',
15882				'tue',
15883				'wed',
15884				'thu',
15885				'fri',
15886				'sat',
15887				'sun'
15888			];
15889
15890			var currentDayOrder  = $( this ).parents( 'tr[class*="listar-business-hours-row"]' ).index();
15891			var currentClasses  = $( this ).parents( 'tr[class*="listar-business-hours-row"]' ).attr( 'class' );
15892			var dayStartColumnHTML = $( this ).parents( 'tr[class*="listar-business-hours-row"]' ).find( '.listar-business-start-time-field' ).prop( 'outerHTML' );
15893			var dayEndColumnHTML = $( this ).parents( 'tr[class*="listar-business-hours-row"]' ).find( '.listar-business-end-time-field' ).prop( 'outerHTML' );
15894
15895
15896			$( this ).parents( '.listar-hours-table-wrapper' ).find( 'tr[class*="listar-business-hours-row"]' ).each( function () {
15897				var rowDayOrder = $( this ).index();
15898
15899				if ( currentDayOrder !== rowDayOrder ) {
15900					var newDayClasses = currentClasses.replace( 'listar-business-hours-row-' + dayPrefix[ currentDayOrder ], 'listar-business-hours-row-' + dayPrefix[ rowDayOrder ] );
15901					var newDayStartColumnHTML = dayStartColumnHTML.replace( 'job_hours[' + dayPrefix[ currentDayOrder ] + ']', 'job_hours[' + dayPrefix[ rowDayOrder ] + ']' );
15902					var newDayEndColumnHTML = dayEndColumnHTML.replace( 'job_hours[' + dayPrefix[ currentDayOrder ] + ']', 'job_hours[' + dayPrefix[ rowDayOrder ] + ']' );
15903
15904					$( this ).attr( 'class', newDayClasses );
15905					$( this ).find( '.listar-business-start-time-field' ).prop( 'outerHTML', newDayStartColumnHTML );
15906					$( this ).find( '.listar-business-end-time-field' ).prop( 'outerHTML', newDayEndColumnHTML );
15907
15908					$( this ).find( '.select2' ).each( function () {
15909						$( this ).prop( 'outerHTML', '' );
15910					} );
15911
15912					$( this ).find( 'select' ).each( function () {
15913						$( this ).attr( 'class', '' ).removeAttr( 'data-select2-id' );
15914						$( this ).find( 'option[data-select2-id]' ).each( function () {
15915							$( this ).removeAttr( 'data-select2-id' );
15916						} );
15917
15918						$( this ).select2( {
15919							minimumResultsForSearch: 3
15920						} );
15921					} );
15922				}
15923
15924				$( this ).find( '.tooltip' ).each( function () {
15925					$( this ).prop( 'outerHTML', '' );
15926					setTooltips();
15927				} );
15928			} );
15929		} );
15930
15931		$( theBody ).on( 'click', '.listar-multiple-hours-plus', function ( e ) {
15932			e.preventDefault();
15933			e.stopPropagation();
15934
15935			$( this ).parent().parent().parent().addClass( 'listar-has-multiple-hours' );
15936
15937			$( this ).parent().parent().parent().find( '.listar-business-start-time-field, .listar-business-end-time-field' ).each( function () {
15938
15939				$( this ).find( 'select' ).each( function () {
15940					var selectVal = $( this ).val();
15941
15942					$( this ).attr( 'value', selectVal );
15943
15944					$( this ).find( 'option' ).each( function () {
15945						$( this ).removeAttr( 'selected' ).prop( 'selected', false ).removeAttr( 'data-select2-id' );
15946					} );
15947
15948					$( this ).find( 'option' ).each( function () {
15949						if ( selectVal === $( this ).attr( 'value' ) ) {
15950							$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
15951						}
15952					} );
15953
15954					$( this ).attr( 'value', selectVal ).select2( 'destroy' ).removeAttr( 'data-select2-id' );
15955					$( this ).val( selectVal );
15956
15957					forceSelectSelected( $( this ) );
15958				} );
15959
15960				$( this ).find( '.listar-business-hour:last-child' ).each( function () {
15961					var multipleHourOrder = parseInt( $( this ).find( 'select' ).attr( 'data-multiple-order' ), 10 );
15962					var newMultipleHour = $( this ).prop( 'outerHTML' ).replace( 'data-multiple-order="' + multipleHourOrder + '"', 'data-multiple-order="' + ( multipleHourOrder + 1 ) + '"' );
15963
15964					$( this ).after( newMultipleHour );
15965				} );
15966
15967				var numberPattern = /\d+/g;
15968				var selectOrder = 0;
15969				var multipleorder = 0;
15970
15971				$( this ).find( 'select' ).each( function () {
15972					var selectName = $( this ).attr( 'name' );
15973
15974					selectOrder = selectName.match( numberPattern ).join([]);
15975					multipleorder = $( this ).attr( 'data-multiple-order' );
15976
15977					$( this ).attr( 'name', selectName.replace( selectOrder, multipleorder ) );
15978				} );
15979
15980				var currentThis = $( this );
15981
15982				setTimeout( function () {
15983
15984					currentThis.find( 'select, option[data-select2-id]' ).each( function () {
15985						$( this ).removeAttr( 'data-select2-id' );
15986					} );
15987
15988					var lastestHoursEnd = currentThis.parent().find( '.listar-business-end-time-field select[data-multiple-order="' + selectOrder + '"]' ).val();
15989
15990					var newHoursStart = '11:59 PM' !== lastestHoursEnd ? lastestHoursEnd : '00:00 AM';
15991					var newStartHourSelect = currentThis.parent().find( '.listar-business-start-time-field' ).find( 'select[data-multiple-order="' + multipleorder + '"]' );
15992					var newEndHourSelect = currentThis.parent().find( '.listar-business-end-time-field' ).find( 'select[data-multiple-order="' + multipleorder + '"]' );
15993
15994					if ( newStartHourSelect.length ) {
15995						newStartHourSelect.attr( 'value', newHoursStart ).val( newHoursStart );
15996						newStartHourSelect.find( 'option' ).each( function () {
15997							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
15998
15999							if ( newHoursStart === $( this ).attr( 'value' ) ) {
16000								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
16001								newStartHourSelect.val( newHoursStart ).attr( 'value', newHoursStart );
16002							}
16003						} );
16004
16005						forceSelectSelected( newStartHourSelect );
16006
16007						newStartHourSelect.trigger( 'change' );
16008					}
16009
16010					if ( newEndHourSelect.length ) {
16011						if ( '00:00 AM' === newHoursStart ) {
16012							lastestHoursEnd = '12:00 PM';
16013						} else {
16014							lastestHoursEnd = '11:59 PM';
16015						}
16016
16017						newEndHourSelect.attr( 'value', lastestHoursEnd ).val( lastestHoursEnd );
16018						newEndHourSelect.find( 'option' ).each( function () {
16019							$( this ).removeAttr( 'selected' ).prop( 'selected', false );
16020
16021							if ( lastestHoursEnd === $( this ).attr( 'value' ) ) {
16022								$( this ).attr( 'selected', 'selected' ).prop( 'selected', true );
16023								newEndHourSelect.val( lastestHoursEnd ).attr( 'value', lastestHoursEnd );
16024							}
16025						} );
16026
16027						forceSelectSelected( newEndHourSelect );
16028
16029						newEndHourSelect.trigger( 'change' );
16030					}
16031
16032					currentThis.find( 'select' ).each( function () {
16033
16034						$( this ).select2( {
16035							minimumResultsForSearch: 3
16036						} );
16037
16038						$( this ).trigger( 'change' );
16039					} );
16040				}, 10 );
16041			} );
16042
16043			$( this ).find( '.tooltip' ).each( function () {
16044				$( this ).prop( 'outerHTML', '' );
16045				setTooltips();
16046			} );
16047		} );
16048
16049		$( theBody ).on( 'click', '.listar-multiple-hours-minus', function ( e ) {
16050			e.preventDefault();
16051			e.stopPropagation();
16052
16053			var countMultipleHours = $( this ).parent().parent().parent().find( '.listar-business-hour' ).length;
16054
16055			if ( 4 === countMultipleHours ) {
16056				var currentMinus = $( this );
16057
16058				currentMinus.parent().parent().parent().removeClass( 'listar-has-multiple-hours' );
16059
16060				setTimeout( function () {
16061					checkOpenHourSelected( currentMinus.parents( '.listar-business-start-time-field' ).find( 'select' ) );
16062				}, 20 );
16063			}
16064
16065			$( this ).parent().parent().parent().find( '.listar-business-start-time-field, .listar-business-end-time-field' ).each( function () {
16066				$( this ).find( '.listar-business-hour:last-child' ).each( function () {
16067					$( this ).prop( 'outerHTML', '' );
16068				} );
16069			} );
16070
16071			$( this ).find( '.tooltip' ).each( function () {
16072				$( this ).prop( 'outerHTML', '' );
16073				setTooltips();
16074			} );
16075		} );
16076
16077		$( theBody ).on( 'click', '.listar-toggle-fixed-quick-menu-button', function ( e ) {
16078			e.preventDefault();
16079			e.stopPropagation();
16080
16081			$( '.single-job_listing .listar-listing-header-topbar-wrapper.listar-show-all-topbar-buttons:not(.listar-listing-header-menu-fixed)' ).each( function () {
16082				$( this ).find( '.listar-listing-header-plus-button' )[0].click();
16083			} );
16084
16085			$( '.listar-listing-header-menu-fixed' ).each( function () {
16086				if ( $( this ).hasClass( 'listar-hidden-fixed-button' ) ) {
16087					$( this ).removeClass( 'listar-hidden-fixed-button' );
16088				} else {
16089					$( this ).addClass( 'listar-hidden-fixed-button' );
16090					$( '.listar-listing-header-topbar-wrapper' ).removeClass( 'listar-show-all-topbar-buttons' );
16091					theBody.removeClass( 'listar-showing-all-topbar-buttons' );
16092
16093					setTimeout( function () {
16094						$( '.listar-listing-header-plus-button' ).find( '.icon-minus' ).each( function () {
16095							$( this ).addClass( 'icon-plus' );
16096							$( this ).removeClass( 'icon-minus' );
16097						} );
16098					}, 800 );
16099				}
16100			} );
16101		} );
16102
16103		$( theBody ).on( 'click', '.listar-toggle-listing-sidebar-position', function ( e ) {
16104			e.preventDefault();
16105			e.stopPropagation();
16106
16107			var
16108				contactDataCol = $( '.listar-listing-description-first-col' ),
16109				descriptionCol = $( '.listar-listing-description-second-col' );
16110
16111			if ( contactDataCol.length && descriptionCol.length ) {
16112
16113				var clone1 = contactDataCol.clone();
16114				var clone2 = descriptionCol.clone();
16115
16116				contactDataCol.replaceWith( clone2 );
16117				descriptionCol.replaceWith( clone1 );
16118
16119				/* Removes the tooltip */
16120				$( '.listar-listing-description-first-col' ).find( '.tooltip' ).prop( 'outerHTML', '' );
16121				setTooltips();
16122
16123				if ( theBody.hasClass( 'listar-listing-sidebar-on-right' ) ) {
16124					theBody.removeClass( 'listar-listing-sidebar-on-right' );
16125				} else {
16126					theBody.addClass( 'listar-listing-sidebar-on-right' );
16127				}
16128			}
16129		} );
16130
16131		/* Private message */
16132
16133		// Get the form.
16134		var privateMessageForm = $( '.listar-private-message-form' ).eq(0);
16135
16136		// Set up an event listener for the contact form.
16137		$( privateMessageForm ).submit( function ( e ) {
16138
16139			// Stop the browser from submitting the form.
16140			e.preventDefault();
16141
16142			// Copy possible 'disabled' sender info to hidden fields
16143			$( 'input[name=listar_sender_name]' ).attr( 'value', $( 'input[name=listar-private-message-user-name]' ).val() );
16144			$( 'input[name=listar_sender_email]' ).attr( 'value', $( 'input[name=listar-private-message-user-email]' ).val() );
16145
16146			// Gets the updated form
16147			privateMessageForm = $( '.listar-private-message-form' ).eq(0);
16148
16149			if ( $( '#listar-private-message-captcha' ).val() !== '5' ) {
16150				privateMessageForm.addClass( 'errorCaptcha' );
16151				$( '#listar-private-message-captcha' ).val( '' );
16152				return false;
16153			} else {
16154				privateMessageForm.removeClass( 'errorCaptcha' );
16155			}
16156
16157			// Serialize the form data.
16158			var formData = $( privateMessageForm ).serialize();
16159
16160			// Submit the form using AJAX.
16161			$.ajax( {
16162				crossDomain: true,
16163				type: 'POST',
16164				url: $( privateMessageForm ).attr( 'action' ),
16165				data: formData
16166			} )
16167				.done( function( response ) {
16168					// Make sure that the form has the 'sent-success' class.
16169					privateMessageForm.parent().removeClass( 'sent-error' );
16170					privateMessageForm.parent().addClass( 'sent-success' );
16171					// Clear the form.
16172					$( '#listar_sender_message' ).val( '' );
16173					privateMessageForm.css( { display : 'none' } );
16174				} )
16175				.fail( function( data ) {
16176					// Make sure that the form has the 'sent-error' class.
16177					privateMessageForm.parent().removeClass( 'sent-success' );
16178					privateMessageForm.parent().addClass( 'sent-error' );
16179			
16180					$( '#listar-private-message-form button' ).removeAttr( 'disabled' );
16181					$( '#listar-private-message-form button ~ .spinner' ).removeClass( 'active' );
16182				} );
16183		} );
16184
16185		/* Complaint Report */
16186
16187		theBody.on( 'click', '.listar-submit-report', function ( e ) {
16188
16189			var submitFormButton = $( this );
16190
16191			$( '#listar-report-form input.required, #listar-report-form textarea.required' ).each( function () {
16192				if ( '' === $( this ).val() || undefined === $( this ).val() ) {
16193					e.preventDefault();
16194					e.stopPropagation();
16195
16196					$( this ).addClass( 'listar-empty-required-field' );
16197				} else {
16198					$( this ).removeClass( 'listar-empty-required-field' );
16199				}
16200			} );
16201
16202			if ( 0 === $( '#listar-report-form input.listar-empty-required-field, #listar-report-form textarea.listar-empty-required-field' ).length ) {
16203
16204				submitFormButton.prop( 'innerHTML', submitFormButton.attr( 'data-loading-text' ) );
16205
16206				/* Start the conclusive AJAX request to save user geolocated data in PHP session */
16207
16208			} else {
16209				e.preventDefault();
16210				e.stopPropagation();
16211			}
16212		} );
16213
16214		// Get the form.
16215		var complaintReportForm = $( '#listar-report-form' ).eq(0);
16216
16217		// Set up an event listener for the contact form.
16218		$( complaintReportForm ).submit( function ( e ) {
16219
16220			// Stop the browser from submitting the form.
16221			e.preventDefault();
16222
16223			// Copy possible 'disabled' sender info to hidden fields
16224			$( 'input[name=listar_complaint_sender_name]' ).attr( 'value', $( 'input[name=listar-complaint-report-user-name]' ).attr( 'value' ) );
16225			$( 'input[name=listar_complaint_sender_email]' ).attr( 'value', $( 'input[name=listar-complaint-report-user-email]' ).attr( 'value' ) );
16226
16227			// Gets the updated form
16228			complaintReportForm = $( '#listar-report-form' ).eq(0);
16229
16230			// Serialize the form data.
16231			var formData = $( complaintReportForm ).serialize();
16232
16233			// Submit the form using AJAX.
16234			$.ajax( {
16235				crossDomain: true,
16236				type: 'POST',
16237				url: $( complaintReportForm ).attr( 'action' ),
16238				data: formData
16239			} )
16240				.done( function( response ) {
16241					// Make sure that the form has the 'sent-success' class.
16242					complaintReportForm.parent().removeClass( 'sent-error' );
16243					complaintReportForm.parent().addClass( 'sent-success' );
16244					// Clear the form.
16245					$( '#listar_complaint_sender_message' ).val( '' );
16246					complaintReportForm.css( { display : 'none' } );
16247				} )
16248				.fail( function( data ) {
16249					// Make sure that the form has the 'sent-error' class.
16250					complaintReportForm.parent().removeClass( 'sent-success' );
16251					complaintReportForm.parent().addClass( 'sent-error' );
16252
16253					$( '.listar-submit-report' ).prop( 'innerHTML', $( '.listar-submit-report' ).attr( 'data-button-text' ) );
16254				} );
16255		} );
16256
16257		/* Open login/register modal */
16258		$( '[href="#listar-login"], [href="#listar-register"]' ).on( 'click', function ( e ) {
16259			e.preventDefault();
16260			listarOpenLoginDialog( $( this ).attr( 'href' ) );
16261		} );
16262
16263		/* Login form */
16264		$( '#listar-login-form' ).on( 'submit', function ( e ) {
16265			var button = $( this ).find( 'button' );
16266
16267			e.preventDefault();
16268			button.button( 'loading' );
16269
16270			$.post( listarLocalizeAndAjax.ajaxurl, $( '#listar-login-form' ).seri
16270alize(), function ( data ) {
16271				var obj = $.parseJSON( data );
16272
16273				/* Reverse HTML entities */
16274				var message = $( '.listar-login .listar-errors' ).html( obj.message ).text();
16275
16276				$( '.listar-login .listar-errors' ).html( message ).css( { display : 'block' } );
16277
16278				if ( false === obj.error ) {
16279					$( '#listar-user-modal .modal-dialog' ).addClass( 'loading' );
16280
16281					var href = currentURL.replace( '#do-login', '' );
16282
16283					if ( theBody.hasClass( 'listar-login-before-review' ) || href.indexOf( '?write#review' ) > 0 ) {
16284						href = href.substring( 0, href.indexOf( '?write-review' ) ) + '?write-review';
16285					}
16286
16287                                        if ( href.indexOf( '#' ) >= 0 ) {
16288                                                href = href.split( '#' )[0];
16289                                        }
16290
16291					theBody.append( '<a id="listar-login-link-1" class="hidden" href="' + href + '"></a>' );
16292					theBody.append( '<a id="listar-login-link-2" class="hidden" target="_parent" href="' + href + '"></a>' );
16293
16294                                        $( '#listar-login-link-1' )[0].click();
16295                                        $( '#listar-login-link-2' )[0].click();
16296
16297					/* Alternative method, not tested for "mobile" cross browser yet */
16298                                        // window.location.href = href;
16299
16300					button.hide();
16301				}
16302
16303				button.button( 'reset' );
16304			} );
16305		} );
16306
16307
16308
16309
16310		/* Registration form */
16311		$( '#listar-registration-form' ).on( 'submit', function ( e ) {
16312			var button = $( this ).find( 'button' );
16313
16314			e.preventDefault();
16315			button.button( 'loading' );
16316
16317			$.post( listarLocalizeAndAjax.ajaxurl, $( '#listar-registration-form' ).serialize(), function ( data ) {
16318				var obj = $.parseJSON( data );
16319
16320				/* Reverse HTML entities */
16321				var message = $( '.listar-register .listar-errors' ).html( obj.message ).text();
16322
16323				$( '.listar-register .listar-errors' ).html( message ).css( { display : 'block' } );
16324
16325				if ( false === obj.error ) {
16326					$( '#listar-user-modal .modal-dialog' ).addClass( 'listar-registration-complete' );
16327					button.hide();
16328				}
16329
16330				button.button( 'reset' );
16331			} );
16332		} );
16333
16334		/* Reset Password */
16335		$( '#listar-reset-password-form' ).on( 'submit', function ( e ) {
16336			var button = $( this ).find( 'button' );
16337
16338			e.preventDefault();
16339			button.button( 'loading' );
16340
16341			$.post( listarLocalizeAndAjax.ajaxurl, $( '#listar-reset-password-form' ).serialize(), function ( data ) {
16342				var obj = $.parseJSON( data );
16343
16344				/* Reverse HTML entities */
16345				var message = $( '.listar-reset-password .listar-errors' ).html( obj.message ).text();
16346
16347				$( '.listar-reset-password .listar-errors' ).html( message ).css( { display : 'block' } );
16348
16349				if ( false === obj.error ) {
16350					/* Nothing to do here currently, success message was already appended */
16351				}
16352
16353				button.button( 'reset' );
16354			} );
16355		} );
16356
16357		if ( '#login' === window.location.hash ) {
16358			listarOpenLoginDialog( '#listar-login' );
16359		}
16360
16361		theBody.on( 'click', '.listar-location-show-advanced', function ( e ) {
16362			e.preventDefault();
16363			e.stopPropagation();
16364
16365			$( '.listar-custom-location-fields' ).removeClass( 'hidden' );
16366			$( this ).prop( 'outerHTML', '' );
16367		} );
16368
16369		/* Ajax Load More */
16370
16371		theBody.on( 'click', '.listar-more-results', function ( e ) {
16372			var
16373				button,
16374				parent;
16375
16376			if ( ! $( this ).hasClass( 'listar-go-to-listing-page' ) ) {
16377
16378				if ( $( this ).hasClass( 'listar-disable-click' ) ) {
16379					e.preventDefault();
16380					e.stopPropagation();
16381					return false;
16382				}
16383
16384				$( this ).addClass( 'listar-loading-results' ).addClass( 'listar-disable-click' );
16385				theBody.addClass( 'listar-loading-posts' );
16386
16387				button = $( this );
16388				data = {
16389					'action' : 'loadmore',
16390					'query' : listarAjaxPostsParams.posts,
16391					'page' : listarAjaxPostsParams.current_page
16392				};
16393				parent = button.parent().parent();
16394
16395				$.ajax( {
16396					/* Ajax handler */
16397					crossDomain: true,
16398					url: listarAjaxPostsParams.ajaxurl,
16399					data: data,
16400					type: 'POST',
16401					success: function ( data ) {
16402						if ( data ) {
16403
16404							isLoadMoreEqualizer = true;
16405
16406							/* Insert new posts/listings */
16407							$( '.listar-results-container' ).append( data );
16408							theBody.removeClass( 'listar-loading-posts' );
16409
16410							listarAjaxPostsParams.current_page++;
16411
16412							if ( parseInt( listarAjaxPostsParams.current_page, 10 ) === parseInt( listarAjaxPostsParams.max_page, 10 ) ) {
16413
16414								/* If last page, remove the button */
16415								if ( $( '.listar-more-results' ).not( '.listar-go-to-listing-page' ).parents( '.listar-load-more-section' ).length ) {
16416									$( '.listar-more-results' ).not( '.listar-go-to-listing-page' ).parents( '.listar-load-more-section' ).prop( 'outerHTML', '' );
16417									isLastBlogPage = true;
16418								}
16419
16420								if ( $( '.listar-more-results' ).not( '.listar-go-to-listing-page' ).parent().length ) {
16421									$( '.listar-more-results' ).not( '.listar-go-to-listing-page' ).parent().prop( 'outerHTML', '' );
16422								}
16423
16424							} else {
16425								var moreListingMapButton = $( '.listar-map ~ .listar-aside-list .listar-posts-column-list .listar-more-results-map' );
16426
16427								if ( moreListingMapButton.length ) {
16428									var outer = moreListingMapButton.parent().prop( 'outerHTML' );
16429
16430									moreListingMapButton.parent().prop( 'outerHTML', '' );
16431
16432									setTimeout( function () {
16433										$( '.listar-map ~ .listar-aside-list .listar-posts-column-list' ).append( outer );
16434										$( '.listar-map ~ .listar-aside-list .listar-more-results' ).removeClass( 'hidden' );
16435									}, 400 );
16436								}
16437							}
16438
16439							setTimeout( function () {
16440
16441								convertDataBackgroundImage();
16442								checkGridFillerCard();
16443
16444								button = parent.find( '.listar-more-results' );
16445								button.removeClass( 'listar-loading-results' ).removeClass( 'listar-disable-click' );
16446
16447								/* Removes the tooltip */
16448								parent.find( '.tooltip' ).prop( 'outerHTML', '' );
16449								setTooltips();
16450
16451								/* Equalize the height of elements, except if clicked on 'load more' button on map sidebar */
16452
16453								if ( ! parent.hasClass( 'listar-posts-column-list' ) ) {
16454									heightEqualizer( '.listar-listing-card' );
16455								}
16456
16457								isLoadMoreEqualizer = true;
16458
16459								heightEqualizer( '.listar-blog-card' );
16460
16461								checkFillerButtonBlog();
16462
16463								/* Init AOS for new elements */
16464								ajaxAOS();
16465							}, 500 );
16466
16467						} else {
16468							/* Removes the tooltip */
16469							parent.find( '.tooltip' ).prop( 'outerHTML', '' );
16470							setTimeout( function () {
16471
16472								/* If no data, remove the button as well */
16473								button.parent().remove();
16474
16475								/* If last page, remove the button */
16476								if ( button.parents( '.listar-load-more-section' ).length ) {
16477									button.parents( '.listar-load-more-section' ).prop( 'outerHTML', '' );
16478								}
16479
16480								if ( button.parent().length ) {
16481									button.parent().prop( 'outerHTML', '' );
16482								}
16483
16484								checkFillerButtonBlog();
16485
16486								theBody.removeClass( 'listar-loading-posts' );
16487							}, 500 );
16488						}// End if().
16489					}
16490				} );
16491			}// End if().
16492		} );
16493
16494		/********** ALL JAVASCRIPT BELOW IS EXCLUSIVE TO MAPS *********/
16495
16496		startMapLeaflet();
16497	}
16498		
16499	// The only JavaScript that must execute on Dom Ready, with Listar Pagespeed active or not.
16500	$( function () {
16501
16502		$( 'input[type="checkbox"]' ).each( function () {
16503			$( this ).parent().addClass( 'listar-custom-checkbox' );
16504
16505			if( $( this ).is( ':checked' ) ) {
16506				$( this ).parent().addClass( 'listar-custom-checkbox-checked' );
16507			}
16508		} );
16509		
16510		if ( listingGallery.length ) {
16511			listingGalleryItems = listingGallery.find( '.gallery-item' );
16512			listingGalleryLinks = listingGallery.find( 'a' );
16513			maxListingGallerySlides = listingGalleryItems.length;
16514		} else {
16515			listingGalleryLinks = $();
16516		}
16517			
16518		$.fancybox.defaults.loop = true;
16519
16520		if ( listingGalleryLinks.length ) {
16521			
16522			/* Append listing gallery after rich media? */
16523			$( '.listar-business-video-accordion.listar-append-listing-gallery-end .listar-video-url-wrapper .listar-accordion-wrapper-paragraph' ).each( function () {
16524				var innerRichMedia = $( this );
16525				
16526				listingGalleryLinks.each( function () {
16527					var itemHref = $( this ).attr( 'href' );
16528					innerRichMedia.append( '<a data-fancybox="mixed" href="' + itemHref + '"></a>' );
16529				} );
16530			} );
16531			
16532			
16533			var galleryReadyInterval = setInterval( function () {
16534				var galleryLoading = false;
16535
16536				listingGalleryLinks.each( function () {
16537					if ( $( this ).width() < 50 ) {
16538						galleryLoading = true;
16539					}
16540				} );
16541
16542				if ( ! galleryLoading ) {
16543					clearInterval( galleryReadyInterval );
16544					initListingGalleryScroll();
16545				}
16546			}, 500 );
16547		}
16548		
16549		createListingGallery();		
16550		
16551		if ( listingGallery.length || $( 'a[data-lightbox="gallery"]' ).length || $( 'a[rel="lightbox"]' ).length || $( 'a[data-rel="lightbox-gallery-1"]' ).length ) {
16552			$( '.lightbox' ).css( { marginLeft : 0 } );
16553		}
16554
16555		/* Automatic Lightbox for WordPress gallery */
16556		if ( $( '.gallery, .wp-block-gallery' ).length ) {
16557			var i = 1;
16558
16559			$( '.gallery, .wp-block-gallery' ).each( function () {
16560				$( this ).find( 'a' ).each( function () {
16561					if (
16562						$( this ).attr( 'href' ).indexOf( 'jpg' ) >= 0 ||
16563						$( this ).attr( 'href' ).indexOf( 'jpeg' ) >= 0 ||
16564						$( this ).attr( 'href' ).indexOf( 'gif' ) >= 0 ||
16565						$( this ).attr( 'href' ).indexOf( 'png' ) >= 0 ||
16566						$( this ).attr( 'href' ).indexOf( 'bmp' ) >= 0 ||
16567						$( this ).attr( 'href' ).indexOf( 'jpg' ) >= 0
16568					) {
16569						$( this ).attr( 'data-lightbox', 'gallery-' + i );
16570						$( '.lightbox' ).css( { marginLeft : 0 } );
16571					}
16572				} );
16573
16574				i++;
16575			} );
16576		}
16577		
16578		// Handle purchased packages VS purchasable packages, avoiding duplication.
16579		$( '.listar-user-packages .listar-listing-package' ).each( function () {
16580			var userPackage = $( this );
16581			var packageID = userPackage.find( 'a[data-user-package]' ).attr( 'data-user-package' );
16582			var userPackageOuter = userPackage.prop( 'outerHTML' );
16583
16584			$( '.listar-available-packages .listar-listing-package' ).each( function () {
16585				var availablePackageID = $( this ).find( 'a[data-package]' ).attr( 'data-package' );
16586
16587				if ( packageID === availablePackageID ) {
16588					$( this ).prop( 'outerHTML', userPackageOuter );
16589					userPackage.prop( 'outerHTML', '' );
16590				}
16591			} );
16592		} );
16593
16594		// Handles the fixed Reservation button visibility.
16595		$( '.listar-business-booking-accordion' ).each( function () {
16596			$( '.listar-booking-quick-button-wrapper' ).removeClass( 'hidden' );
16597		} );
16598
16599		/* Handle DT tags linking to external domains - Iframes VS Listar Pagespeed */
16600		$( 'dl[data-temp-data-script-form-field]' ).each( function () {
16601			var iframeSRC = $( this ).attr( 'data-temp-src' );
16602			var iframeID  = $( this ).attr( 'data-temp-id' );
16603
16604			if ( undefined !== iframeID && 'undefined' !== iframeID ) {
16605				iframeID = ' id="' + iframeID + '"';
16606			} else {
16607				iframeID = '';
16608			}
16609
16610			$( this ).prop( 'outerHTML', '<iframe src="' + iframeSRC + '"' + iframeID + '></iframe>' );
16611		} );
16612
16613		/* Recognizes Timekit API Widget */
16614
16615		$( '.panel-body #bookingjs' ).each( function () {
16616			var timekitJqueryScript = '';
16617			var timekitBookingScript = '';
16618			var timekitBookingConf = '';
16619
16620			$( 'iframe[src*="libs/jquery/"]' ).each( function () {
16621				timekitJqueryScript = $( this ).attr( 'src' );
16622			} );
16623
16624			$( 'iframe[src*="timekit.io"]' ).each( function () {
16625				timekitBookingScript = $( this ).attr( 'src' );
16626			} );
16627
16628			$( 'iframe' ).each( function () {
16629				var iframeInner = $( this ).prop( 'innerHTML' );
16630
16631				if ( iframeInner.indexOf( 'app_key' ) >= 0 && iframeInner.indexOf( 'project_id' ) >= 0 ) {
16632					timekitBookingConf = iframeInner;
16633				}
16634			} );
16635
16636			if ( '' !== timekitJqueryScript && '' !== timekitBookingScript && '' !== timekitBookingConf ) {
16637				var requiredJquery = document.createElement( 'script' );
16638				var timekitScript = document.createElement( 'script' );
16639
16640				timekitBookingConf = timekitBookingConf.replace( 'window.timekitBookingConfig', '' ).replace( '=', '' ).replace( 'app_key', "'app_key'" ).replace( 'project_id', "'project_id'" ).replace( /\s+/g, '' );
16641				timekitBookingConf = timekitBookingConf.replace( /'/g, '"' );
16642
16643				$( this ).parents( '.panel-body' ).prop( 'innerHTML', '' );
16644
16645				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).append( '<div id="bookingjs"></div>' );
16646
16647				window.timekitBookingConfig = $.parseJSON( timekitBookingConf );
16648
16649				requiredJquery.setAttribute( 'src', timekitJqueryScript );
16650				requiredJquery.setAttribute( 'defer', 'defer' );
16651				requiredJquery.setAttribute( 'type', 'text/javascript' );
16652
16653				timekitScript.setAttribute( 'src', timekitBookingScript );
16654				timekitScript.setAttribute( 'type', 'text/javascript' );
16655				timekitScript.setAttribute( 'defer', 'defer' );
16656
16657				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( requiredJquery );
16658				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( timekitScript );
16659			}
16660		} );
16661
16662		/* Recognizes Booksy API Widget */
16663
16664		$( 'iframe[src*="booksy.com/widget/code.js"]' ).each( function () {
16665			var booksyBookingScript = $( this ).attr( 'src' );
16666
16667			if ( '' !== booksyBookingScript ) {
16668				var booksyScript = document.createElement( 'script' );
16669
16670				$( this ).prop( 'outerHTML', '' );
16671
16672				booksyScript.setAttribute( 'src', booksyBookingScript );
16673				booksyScript.setAttribute( 'defer', 'defer' );
16674				booksyScript.setAttribute( 'type', 'text/javascript' );
16675
16676				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( booksyScript );
16677			}
16678		} );
16679
16680		/* Recognizes Resy API Widget */
16681
16682		$( '.panel-body iframe[src*="widgets.resy.com"]' ).each( function () {
16683			var resyButton = '';
16684			var resyBookingScript = '';
16685			var resyBookingConf = '';
16686
16687			resyBookingScript = $( this ).attr( 'src' );
16688
16689			$( 'iframe' ).each( function () {
16690				var iframeInner = $( this ).prop( 'innerHTML' );
16691
16692				if ( iframeInner.indexOf( 'resyWidget.addButton' ) >= 0 ) {
16693					resyBookingConf = iframeInner;
16694				}
16695			} );
16696
16697			$( 'a[id*="resyButton"]' ).each( function () {
16698				resyButton = $( this ).prop( 'outerHTML' );
16699			} );
16700
16701			if ( '' !== resyButton && '' !== resyBookingScript && '' !== resyBookingConf ) {
16702				var resyScript = document.createElement( 'script' );
16703				var resyConfScript = window.document.createElement( 'script' );
16704
16705				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', '' );
16706				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).append( resyButton );
16707
16708				resyScript.setAttribute( 'src', resyBookingScript );
16709				resyScript.setAttribute( 'defer', 'defer' );
16710				resyScript.setAttribute( 'type', 'text/javascript' );
16711
16712				resyConfScript.setAttribute( 'type', 'text/javascript' );
16713
16714				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( resyScript );
16715
16716				resyBookingConf = "var resyStart = setInterval( function () {if ( 'undefined' !== typeof resyWidget ) { clearInterval( resyStart ); " + resyBookingConf + " setTimeout( function () { document.querySelector( 'iframe[src*=" + '"widgets.resy.com/images"' + "]' ).parentElement.setAttribute( 'data-resy-buttom', 'resy' ); }, 1000 );} }, 2000);";
16717
16718				resyConfScript.innerHTML = resyBookingConf;
16719				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( resyConfScript );
16720			}
16721		} );
16722
16723		/* Recognizes ZOMATO API Calendar Button */
16724
16725		$( 'iframe[src*="zomatobook.com/scripts"][src*="reswidget.min.js"]' ).each( function () {
16726			var zomatoButton = '';
16727			var zomatoBookingScript = '';
16728
16729			zomatoBookingScript = $( this ).attr( 'src' );
16730
16731			$( this ).siblings( 'img' ).prop( 'outerHTML' );
16732
16733			$( this ).siblings( 'img[data-onclick*=".widget."]' ).each( function () {
16734				$( this ).attr( 'onclick', $( this ).attr( 'data-onclick' ) );
16735				zomatoButton = $( this );
16736			} );
16737
16738			if ( '' !== zomatoButton && '' !== zomatoBookingScript ) {
16739				var zomatoScript = document.createElement( 'script' );
16740				var zomatoButtonHTML = '';
16741
16742				zomatoButton.addClass( 'listar-zomato-button' );
16743				zomatoButtonHTML = zomatoButton.prop( 'outerHTML' );
16744
16745				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', '' );
16746				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).append( zomatoButtonHTML );
16747
16748				zomatoScript.setAttribute( 'src', zomatoBookingScript );
16749				zomatoScript.setAttribute( 'defer', 'defer' );
16750				zomatoScript.setAttribute( 'type', 'text/javascript' );
16751
16752				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( zomatoScript );
16753			}
16754		} );
16755
16756		/* Recognizes Agoda API Widget */
16757
16758		$( '.panel-body iframe[src*="agoda.net/"][src*=".min.js"]' ).each( function () {
16759			var agodaButton = '';
16760			var agodaBookingScript = '';
16761			var agodaBookingConf = '';
16762
16763			agodaBookingScript = $( this ).attr( 'src' );
16764
16765			$( 'iframe' ).each( function () {
16766				var iframeInner = $( this ).prop( 'innerHTML' );
16767
16768				if ( iframeInner.indexOf( 'AgdSherpa' ) >= 0 ) {
16769					agodaBookingConf = iframeInner;
16770				}
16771			} );
16772
16773			$( 'div[id*="adgshp"]' ).each( function () {
16774				agodaButton = $( this ).prop( 'outerHTML' );
16775			} );
16776
16777			if ( '' !== agodaButton && '' !== agodaBookingScript && '' !== agodaBookingConf ) {
16778				var agodaScript = document.createElement( 'script' );
16779				var agodaConfScript = window.document.createElement( 'script' );
16780
16781				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', '' );
16782				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).append( agodaButton );
16783
16784				agodaScript.setAttribute( 'src', agodaBookingScript );
16785				agodaScript.setAttribute( 'defer', 'defer' );
16786				agodaScript.setAttribute( 'type', 'text/javascript' );
16787
16788				agodaConfScript.setAttribute( 'type', 'text/javascript' );
16789
16790				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( agodaScript );
16791
16792				agodaBookingConf = "var agodaStart = setInterval( function () {if ( 'undefined' !== typeof AgdSherpa ) { clearInterval( agodaStart ); " + agodaBookingConf + " } }, 2000);";
16793
16794				agodaConfScript.innerHTML = agodaBookingConf;
16795
16796				setInterval( function () {
16797					$( 'div[id*="adgshp"]' ).each( function () {
16798						$( this ).css( { height : '' } );
16799						$( this ).css( { height : $( this ).height() + 15 } );
16800					} );
16801				}, 1000 );
16802
16803				setTimeout( function () {
16804					$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( agodaConfScript );
16805				}, 200 );
16806
16807			}
16808		} );
16809
16810		/* Recognizes Bookafy API Calendar Button */
16811
16812		$( 'iframe[id*="bookafy_script"]' ).each( function () {
16813			var bookafyButton = '';
16814			var bookafyBookingScript = '';
16815
16816			bookafyBookingScript = $( this ).attr( 'src' );
16817
16818			$( this ).parent().parent().find( '#bookafy-scheduling,#app-scheduling' ).each( function () {
16819				$( this ).attr( 'id', 'app-scheduling' );
16820				bookafyButton = $( this );
16821			} );
16822
16823			if ( '' !== bookafyButton && '' !== bookafyBookingScript ) {
16824				var bookafyScript = document.createElement( 'script' );
16825				var bookafyButtonHTML = '';
16826
16827				bookafyButton.addClass( 'listar-bookafy-button hidden' );
16828				bookafyButtonHTML = bookafyButton.prop( 'outerHTML' );
16829
16830				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', '' );
16831				theBody.append( bookafyButtonHTML );
16832
16833				bookafyScript.setAttribute( 'src', bookafyBookingScript );
16834				bookafyScript.setAttribute( 'defer', 'defer' );
16835				bookafyScript.setAttribute( 'type', 'text/javascript' );
16836
16837				$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( bookafyScript );
16838			}
16839		} );
16840
16841		/* Recognizes SimplyBook.ME Widget */
16842
16843		$( 'iframe[src*="widget.simplybook"][src*="widget.js"]' ).each( function () {
16844			var simplyIframeURL = '';
16845			var simplyBookingScript = '';
16846			var simplyBookingConf = '';
16847			var simplyBookingConfBK = '';
16848
16849			simplyBookingScript = $( this ).attr( 'src' );
16850
16851			$( 'iframe' ).each( function () {
16852				simplyBookingConf = $( this ).prop( 'innerHTML' );
16853
16854				if ( simplyBookingConf.indexOf( 'SimplybookWidget' ) >= 0 && simplyBookingConf.indexOf( '"url":"https:\/\/' ) >= 0 ) {
16855
16856					simplyBookingConfBK = simplyBookingConf;
16857
16858					simplyBookingConf = simplyBookingConf.replace( 'SimplybookWidget(', '' ).replace( '= new', '' ).replace( '=new', "'app_key'" ).replace( 'var widget ', '' ).replace( ');', '' ).replace( /\s+/g, '' );
16859
16860					$( this ).parents( '.panel-body' ).prop( 'innerHTML', '' );
16861
16862					window.simplyBookingConfig = $.parseJSON( simplyBookingConf );
16863
16864					var
16865					js_widget_type = window.simplyBookingConfig.widget_type,
16866					js_url = window.simplyBookingConfig.url,
16867					js_theme = window.simplyBookingConfig.theme,
16868					js_timeline = window.simplyBookingConfig.timeline,
16869					js_datepicker = window.simplyBookingConfig.datepicker,
16870					js_is_rtl = window.simplyBookingConfig.is_rtl;
16871
16872					js_widget_type = undefined === js_widget_type ? '' : js_widget_type;
16873					js_url = undefined === js_url ? '' : js_url;
16874					js_theme = undefined === js_theme ? '' : js_theme;
16875					js_timeline = undefined === js_timeline ? '' : js_timeline;
16876					js_datepicker = undefined === js_datepicker ? '' : js_datepicker;
16877					js_is_rtl = undefined === js_is_rtl ? '' : js_is_rtl;
16878
16879					js_is_rtl = false === js_is_rtl || '' === js_is_rtl ? 'false' : js_is_rtl;
16880					js_is_rtl = 'false' !== js_is_rtl ? '&is_rtl=' + js_is_rtl : '';
16881
16882					if ( 'iframe' === js_widget_type ) {
16883						if ( js_url.indexOf( '.simplybook.me' ) >= 0 ) {
16884							js_url = js_url
16885								.replace( 'https:\/\/', 'https://' )
16886								.replace( '\/', '/' )
16887								.replace( '\/', '/' )
16888								.replace( '\/', '/' );
16889
16890							simplyIframeURL = js_url + '/v2/?widget-type=' + js_widget_type + '&theme=' + js_theme + '&timeline=' + js_timeline + '&datepicker=' + js_datepicker + js_is_rtl;
16891
16892							/* Force button + popup outupt */
16893
16894							simplyIframeURL = '';
16895
16896							simplyBookingConfBK = simplyBookingConfBK.replace( 'widget_type":"iframe"', 'widget_type":"button"' );
16897
16898							$( theBody ).addClass( 'listar-hide-simply-button' );
16899						}
16900					}
16901				}
16902			} );
16903
16904			if ( '' !== simplyIframeURL ) {
16905
16906				var simplyIframe = '<iframe src="' + simplyIframeURL + '"></iframe>';
16907
16908				$( this ).parents( '.panel-body' ).prop( 'innerHTML', '' );
16909
16910				$( '.listar-business-booking-accordion' ).find( '.panel-body' ).append( simplyIframe );
16911			} else {
16912
16913				if ( '' !== simplyBookingScript && '' !== simplyBookingConfBK ) {
16914					var simplyScript = document.createElement( 'script' );
16915					var simplyConfScript = window.document.createElement( 'script' );
16916
16917					$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', '' );
16918
16919					simplyScript.setAttribute( 'src', simplyBookingScript );
16920					simplyScript.setAttribute( 'defer', 'defer' );
16921					simplyScript.setAttribute( 'type', 'text/javascript' );
16922
16923					simplyConfScript.setAttribute( 'type', 'text/javascript' );
16924
16925					$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( simplyScript );
16926
16927					simplyBookingConfBK = "var simplyStart = setInterval( function () {if ( 'undefined' !== typeof SimplybookWidget ) { clearInterval( simplyStart ); " + simplyBookingConfBK + "} }, 2000);";
16928
16929					simplyConfScript.innerHTML = simplyBookingConfBK;
16930					$( '.listar-business-booking-accordion' ).find( '.panel-body' )[0].appendChild( simplyConfScript );
16931				}
16932			}
16933		} );
16934
16935		/* Recognizes TheFork API Calendar Button */
16936
16937		$( 'iframe[src*="module.lafourchette.com"]' ).each( function () {
16938			var theForkBookingScript = '';
16939
16940			theForkBookingScript = $( this ).attr( 'src' );
16941
16942			if ( '' !== theForkBookingScript ) {
16943				if ( -1 === theForkBookingScript.indexOf( '/module/' ) ) {
16944
16945					var forkMarkupt = '';
16946
16947					theForkBookingScript = theForkBookingScript.replace( '/js/', '/cta/' );
16948
16949					if ( theForkBookingScript.indexOf( '/button/' ) >= 0 ) {
16950						theForkBookingScript = theForkBookingScript.replace( '/button/', '/iframe/' );
16951						forkMarkupt = '<a href="' + theForkBookingScript + '" target="_blank"></a>';
16952					} else {
16953						forkMarkupt = '<iframe src="' + theForkBookingScript + '"></iframe>';
16954					}
16955
16956					$( '.listar-business-booking-accordion' ).find( '.panel-body' ).prop( 'innerHTML', forkMarkupt );
16957				}
16958			}
16959		} );
16960
16961		convertDataBackgroundImage( $( 'header.listar-front-header .listar-hero-image[data-background-image]' ) );
16962		
16963		$( '[data-background-image]' ).each( function () {
16964			if ( isInViewport( $( this ) ) ) {
16965				convertDataBackgroundImage( $( this ) );
16966			}
16967		} );
16968
16969		/*xxx 10002*/
16970		/* Remove empty paragraphs and fix for bad WordPress paragraph output (wp:paragraph) comming from Gutenberg */
16971		setTimeout( function () {
16972			$( 'table.has-fixed-layout tr, table.has-fixed-layout td, table.has-fixed-layout th, table.has-fixed-layout thead, table.has-fixed-layout tbody' ).each( function () {
16973				if ( $( this ).parents( '.col-md-8,.col-md-9,.col-lg-9' ).length >= 1 ) {
16974					$( this ).css( { width : '' } );
16975				}
16976			} );
16977		}, 40 );
16978		
16979		/*xxx 9262 */
16980		setTimeout( function () {
16981			$( 'ul, ol' ).each( function () {
16982				var styleType = $( this ).css( 'list-style-type' );
16983				var listItems = $( this ).find( 'li' );
16984
16985				if ( listItems.length ) {
16986					var firstItemDisplay = listItems.eq( 0 ).css( 'display' );
16987
16988					if ( ( 'disc' === styleType || 'decimal' === styleType ) && 'list-item' === firstItemDisplay ) {
16989						$( this ).addClass( 'listar-displace-list-left' );
16990					}
16991				}
16992			} );
16993		}, 250 );
16994		
16995		
16996		/* 6872 */
16997
16998		// Force placeholders for all Select2 objects.
16999		setInterval( function () {
17000			$( '.select2-search__field' ).each( function () {
17001				var select2ElemSearch = $( this );
17002
17003				$( this ).parents( '.select2' ).each( function () {
17004					if ( $( this ).prev()[0].hasAttribute( 'data-placeholder' ) ) {
17005						select2ElemSearch.attr( 'placeholder', $( this ).prev().attr( 'data-placeholder' ) );
17006					}
17007				} );
17008			} );
17009		}, 2000 );
17010		
17011		
17012		/*xxx 7651 e 7722*/
17013		/* Prepare wrapper for menu/catalog files */
17014		setTimeout( function () {
17015			$( '.fieldset-job_business_document_1_title' ).each( function () {
17016				var
17017					docsSection1 = $( this ),
17018					checkboxDoc = $( '.fieldset-job_business_use_catalog_documents' ).prop( 'outerHTML' ),
17019					menuTitle1  = docsSection1,
17020					menuFile1   = menuTitle1.next(),
17021					menuTitle2  = menuFile1.next(),
17022					menuFile2   = menuTitle2.next(),
17023					menuTitle3  = menuFile2.next(),
17024					menuFile3   = menuTitle3.next(),
17025					menuTitle4  = menuFile3.next(),
17026					menuFile4   = menuTitle4.next(),
17027					menuTitle5  = menuFile4.next(),
17028					menuFile5   = menuTitle5.next(),
17029					menuTitle6  = menuFile5.next(),
17030					menuFile6   = menuTitle6.next();
17031
17032				var
17033					catalogsOutput =
17034						menuTitle1.prop( 'outerHTML' ) +
17035						menuFile1.prop( 'outerHTML' ) +
17036						menuTitle2.prop( 'outerHTML' ) +
17037						menuFile2.prop( 'outerHTML' ) +
17038						menuTitle3.prop( 'outerHTML' ) +
17039						menuFile3.prop( 'outerHTML' ) +
17040						menuTitle4.prop( 'outerHTML' ) +
17041						menuFile4.prop( 'outerHTML' ) +
17042						menuTitle5.prop( 'outerHTML' ) +
17043						menuFile5.prop( 'outerHTML' ) +
17044						menuTitle6.prop( 'outerHTML' ) +
17045						menuFile6.prop( 'outerHTML' );
17046
17047				docsSection1.before( '<div class="listar-business-catalog-fields listar-boxed-fields-docs-upload hidden"><div class="listar-boxed-fields-wrapper"><div class="listar-boxed-fields-inner hidden"></div></div></div>' );
17048
17049				menuTitle1.prop( 'outerHTML', '' );
17050				menuFile1.prop( 'outerHTML', '' );
17051				menuTitle2.prop( 'outerHTML', '' );
17052				menuFile2.prop( 'outerHTML', '' );
17053				menuTitle3.prop( 'outerHTML', '' );
17054				menuFile3.prop( 'outerHTML', '' );
17055				menuTitle4.prop( 'outerHTML', '' );
17056				menuFile4.prop( 'outerHTML', '' );
17057				menuTitle5.prop( 'outerHTML', '' );
17058				menuFile5.prop( 'outerHTML', '' );
17059				menuTitle6.prop( 'outerHTML', '' );
17060				menuFile6.prop( 'outerHTML', '' );
17061
17062				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-inner' ).prop( 'innerHTML', catalogsOutput );
17063
17064				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-wrapper' ).prepend( '<div class="listar-catalog-files-header"></div>' );
17065				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-catalog-files-header' ).append( $( '.fieldset-job_business_document_1_file .description' ).prop( 'outerHTML' ) + '<br>' );
17066				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-catalog-files-header' ).append( $( '.fieldset-job_business_document_2_file .description' ).prop( 'outerHTML' ) );
17067
17068				$( '.fieldset-job_business_use_catalog_documents' ).prop( 'outerHTML', '' );
17069				$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-catalog-files-header' ).before( checkboxDoc );
17070
17071				setTimeout( function () {
17072					if ( $( '#job_business_use_catalog' ).is( ':checked' ) ) {
17073						$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload' ).removeClass( 'hidden' );
17074					}
17075
17076					if ( $( '#job_business_use_catalog_documents' ).is( ':checked' ) ) {
17077						$( '.listar-business-catalog-fields.listar-boxed-fields-docs-upload .listar-boxed-fields-inner' ).removeClass( 'hidden' );
17078					}
17079				}, 100 );
17080			} );
17081
17082		}, 10 );
17083		
17084		/*xxx 8428 a 8489 */
17085
17086		/*
17087		 * Init Select2
17088		 */
17089	       
17090	       function startLimitedTermsSelect2( elem, tax ) {
17091			forceSelectSelected( elem );
17092			
17093			//alert( tax );
17094
17095			if ( $.isFunction( $.fn.select2 ) ) {
17096				elem.select2( {
17097					minimumResultsForSearch: 3,
17098					ajax: {
17099						url: listarSiteURL + '/wp-content/plugins/listar-addons/inc/ajax-search/listar-select2-terms-search.php',
17100						dataType: 'json',
17101						delay: 250,
17102						data: function ( data ) {
17103							return {
17104								searchTerm: data.term, // search term
17105								taxonomy: tax // search term
17106							};
17107						},
17108						processResults: function ( response ) {
17109							//alert( response );
17110							return {
17111								results: response
17112							};
17113						},
17114						cache: true
17115					}
17116				} );
17117			}
17118	       }
17119
17120		var select2SelectorsTaxonomies = $( '.listar-custom-select[data-tax]' );
17121
17122		select2SelectorsTaxonomies.each( function () {
17123			var tax = $( this ).attr( 'data-tax' );
17124			startLimitedTermsSelect2( $( this ), tax );			
17125		} );
17126
17127		setTimeout( function () {
17128			$( 'select[id="job_region"]' ).each( function () {
17129				if ( $( this ).siblings( '.select2' ).length ) {
17130					$( this ).siblings( '.select2' ).prop( 'outerHTML', '' );
17131					$( this ).select2( 'destroy' );
17132					startLimitedTermsSelect2( $( this ), 'job_listing_region' );
17133				}
17134			} );
17135		}, 1000 );
17136
17137		setTimeout( function () {
17138			$( 'select[id="job_category"]' ).each( function () {
17139				if ( $( this ).siblings( '.select2' ).length ) {
17140					$( this ).siblings( '.select2' ).prop( 'outerHTML', '' );
17141					$( this ).select2( 'destroy' );
17142					startLimitedTermsSelect2( $( this ), 'job_listing_category' );
17143				}
17144			} );
17145		}, 1000 );
17146
17147
17148		if ( $( '#submit-job-form' ).length && $( '#job_region' ).length ) {
17149			if ( '' !== $( '#job_region' ).val() ) {
17150				$( '#job_region' ).parent().removeClass( 'listar-showing-placeholder' ).addClass( 'listar-hidding-placeholder' );
17151			} else {
17152				$( '#job_region' ).parent().addClass( 'listar-showing-placeholder' ).removeClass( 'listar-hidding-placeholder' );
17153			}
17154		}
17155
17156		if ( $( '#submit-job-form .account-sign-in a' ).length ) {
17157			$( '#submit-job-form .account-sign-in a' ).wrap( '<div class="listar-elem-wrapper"></div>' );
17158		}
17159
17160		/*xxx 9585 */
17161		setTimeout( function () {
17162			var theButton = $( '.listar-listing-rating-anchor' );
17163			var elementsCount = $( '.listar-listing-review-wrapper' ).length;
17164
17165			if ( elementsCount < 1 ) {
17166				theButton.parents( '.listar-listing-header-topbar-item' ).prop( 'outerHTML', '' );
17167			}
17168		}, 1000 );
17169
17170		/*xxx 9805 */
17171		setInterval( function () {
17172			$( '#submit-job-form fieldset' ).not( '.listar-required-listing-field' ).each( function () {
17173				$( this ).find( '.required-field' ).each( function () {
17174					var requiredFieldLabel = $( this ).parents( 'fieldset' ).find( 'label' );
17175					var asteriskTooltip = '<span class="listar-required-listing-field-asterisk fa fa-asterisk" data-toggle="tooltip" data-placement="top" title="' + listarLocalizeAndAjax.requiredField + '"></span>';
17176					var innerFieldHTML = requiredFieldLabel.prop( 'innerHTML' );
17177
17178					if ( innerFieldHTML.indexOf( '<br>' ) >= 0 ) {
17179						innerFieldHTML = innerFieldHTML.replace( '<br>', asteriskTooltip + '<br>' );
17180					} else {
17181						innerFieldHTML += asteriskTooltip;
17182					}
17183
17184					$( this ).parents( 'fieldset' ).addClass( 'listar-required-listing-field' );
17185					requiredFieldLabel.prop( 'innerHTML', innerFieldHTML );
17186				} );
17187			} );
17188		}, 40 );
17189		
17190		executeCurrentHash();
17191
17192		/*xxx 12954*/
17193		setTimeout( function () {
17194
17195			// And do it again, because of elements that can populate the page dinamically, like lasy loaded images */
17196			executeCurrentHash();
17197		}, 1000 );
17198
17199		/*xxx 13206*/
17200		setTimeout( function () {
17201			$( theBody ).on( 'change DOMSubtreeModified DOMNodeInserted DOMNodeRemoved', '#job_category, #job_category ~ .select2-selection__rendered', function() {
17202
17203				if ( ! tempModify ) {
17204					tempModify = true;
17205
17206					setTimeout( function () {
17207						featuredListingCategorySelect();
17208					}, 20 );
17209
17210					setTimeout( function () {
17211						tempModify = false;
17212					}, 150 );
17213				}
17214			} );
17215
17216			$( theBody ).on( 'change DOMSubtreeModified DOMNodeInserted DOMNodeRemoved', '#job_region, #job_region ~ .select2-selection__rendered', function() {
17217				if ( ! tempModify2 ) {
17218					tempModify2 = true;
17219
17220					setTimeout( function () {
17221						featuredListingRegionSelect();
17222					}, 20 );
17223
17224					setTimeout( function () {
17225						tempModify2 = false;
17226					}, 150 );
17227				}
17228			} );
17229		}, 3000 );
17230
17231		/* Adds a "plus" button do drop down main menus in case of high amount of itens on the list */
17232
17233		setTimeout( function () {
17234			if ( viewport().width > 767 ) {
17235
17236				$( '#listar-primary-menu .dropdown-menu' ).each( function () {
17237					if ( $( this ).find( '>li' ).length > 13 ) {
17238						$( this ).append( '<li class="listar-plus-drop-down-menu fa fa-plus"></li>' );
17239						$( this ).addClass( 'listar-menu-has-invisible-items' );
17240					}
17241				} );
17242			}
17243		}, 3000 );
17244
17245		/*xxx 8542 */
17246		setTimeout( function () {
17247			$( '.listar-search-regions .listar-regions-list a.current' ).stop().animate( { opacity : 1 }, { duration : 250, complete : function () {
17248				$( '.listar-search-regions .listar-regions-list a.current' ).css( { opacity : '' } );
17249			} } );
17250		}, 250 );
17251	} );
17252	
17253	if ( usingPagespeed && 'no' === listarLocalizeAndAjax.listarUserLogged ) {
17254
17255		// All thing is optimized, so preferably run JavaScript when all assets are completelly (and instantaneously) loaded */
17256		window.addEventListener( 'load', function () {
17257
17258			/* 1.5 Seconds after all content painted - Pagespeed */
17259			setTimeout( function () {
17260				listarExecute();
17261			}, 1500 );
17262		} );
17263	} else {
17264		
17265		// Use jQuery "Ready" if Listar Pagespeed is disabled.
17266		$( function () {
17267			listarExecute();
17268		} );
17269	}
17270	
17271	//setTimeout( function () {
17272		//alert(99);
17273		//$( 'body' ).append( '<div>' + linereport + '</div>' );
17274	//}, 30000 );
17275
17276} )( jQuery );
17277

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.