PageSourceSearch

https://vds-sonnenschutz.de/wp-content/plugins/w2dc/resources/js/js_functions.js?ver=2.10.10

js vds-sonnenschutz.de collected 2026-10-02 23:36:39 UTC 169,518 bytes, 3,541 lines download raw bytes

1var w2dc_maps = [];
2var w2dc_maps_attrs = [];
3var w2dc_infoWindows = [];
4var w2dc_drawCircles = [];
5var w2dc_searchAddresses = [];
6var w2dc_polygons = [];
7var w2dc_fullScreens = [];
8var w2dc_global_markers_array = [];
9var w2dc_global_locations_array = [];
10var w2dc_markerClusters = [];
11var w2dc_directions_display = [];
12var w2dc_stop_touchmove_listener = function(e){
13	e.preventDefault();
14}
15var w2dc_glocation = (function(id, point, map_icon_file, map_icon_color, listing_title, listing_logo, listing_url, content_fields, anchor, nofollow, show_summary_button, show_readmore_button, map_id, is_ajax_markers) {
16	this.id = id;
17	this.point = point;
18	this.map_icon_file = map_icon_file;
19	this.map_icon_color = map_icon_color;
20	this.listing_title = listing_title;
21	this.listing_logo = listing_logo;
22	this.listing_url = listing_url;
23	this.content_fields = content_fields;
24	this.anchor = anchor;
25	this.nofollow = nofollow;
26	this.show_summary_button = show_summary_button;
27	this.show_readmore_button = show_readmore_button;
28	this.w2dc_placeMarker = function(map_id) {
29		this.marker = w2dc_placeMarker(this, map_id);
30		return this.marker;
31	};
32	this.is_ajax_markers = is_ajax_markers;
33});
34var _w2dc_map_markers_attrs_array;
35var w2dc_dragended;
36var ZOOM_FOR_SINGLE_MARKER = 17;
37
38var w2dc_map_backend = null;
39var w2dc_allow_map_zoom_backend = true; // allow/disallow map zoom in listener, this option needs because w2dc_map_backend.setZoom() also calls this listener
40var w2dc_geocoder_backend = null;
41var w2dc_infoWindow_backend = null;
42var w2dc_markersArray_backend = [];
43var w2dc_glocation_backend = (function(index, point, location, address_line_1, address_line_2, zip_or_postal_index, map_icon_file) {
44	this.index = index;
45	this.point = point;
46	this.location = location;
47	this.address_line_1 = address_line_1;
48	this.address_line_2 = address_line_2;
49	this.zip_or_postal_index = zip_or_postal_index;
50	this.map_icon_file = map_icon_file;
51	this.w2dc_placeMarker = function() {
52		return w2dc_placeMarker_backend(this);
53	};
54	this.compileAddress = function() {
55		var address = this.address_line_1;
56		if (this.address_line_2)
57			address += ", "+this.address_line_2;
58		if (this.location) {
59			if (address)
60				address += " ";
61			address += this.location;
62		}
63		if (w2dc_maps_objects.default_geocoding_location) {
64			if (address)
65				address += " ";
66			address += w2dc_maps_objects.default_geocoding_location;
67		}
68		if (this.zip_or_postal_index) {
69			if (address)
70				address += " ";
71			address += this.zip_or_postal_index;
72		}
73		return address;
74	};
75	this.compileHtmlAddress = function() {
76		var address = this.address_line_1;
77		if (this.address_line_2)
78			address += ", "+this.address_line_2;
79		if (this.location) {
80			if (this.address_line_1 || this.address_line_2)
81				address += "<br />";
82			address += this.location;
83		}
84		if (this.zip_or_postal_index)
85			address += " "+this.zip_or_postal_index;
86		return address;
87	};
88	this.setPoint = function(point) {
89		this.point = point;
90	};
91});
92
93/* Stack-based Douglas Peucker line simplification routine 
94returned is a reduced GLatLng array 
95After code by  Dr. Gary J. Robinson,
96Environmental Systems Science Centre,
97University of Reading, Reading, UK
98*/
99function w2dc_GDouglasPeucker(source, kink) {
100	var n_source, n_stack, n_dest, start, end, i, sig;    
101	var dev_sqr, max_dev_sqr, band_sqr;
102	var x12, y12, d12, x13, y13, d13, x23, y23, d23;
103	var F = ((Math.PI / 180.0) * 0.5 );
104	var index = new Array();
105	var sig_start = new Array();
106	var sig_end = new Array();
107
108	if ( source.length < 3 ) 
109		return(source);
110
111	n_source = source.length;
112	band_sqr = kink * 360.0 / (2.0 * Math.PI * 6378137.0);
113	band_sqr *= band_sqr;
114	n_dest = 0;
115	sig_start[0] = 0;
116	sig_end[0] = n_source-1;
117	n_stack = 1;
118
119	while ( n_stack > 0 ) {
120		start = sig_start[n_stack-1];
121		end = sig_end[n_stack-1];
122		n_stack--;
123
124		if ( (end - start) > 1 ) {
125			x12 = (source[end].lng() - source[start].lng());
126			y12 = (source[end].lat() - source[start].lat());
127			if (Math.abs(x12) > 180.0) 
128				x12 = 360.0 - Math.abs(x12);
129			x12 *= Math.cos(F * (source[end].lat() + source[start].lat()));
130			d12 = (x12*x12) + (y12*y12);
131
132			for ( i = start + 1, sig = start, max_dev_sqr = -1.0; i < end; i++ ) {                                    
133				x13 = (source[i].lng() - source[start].lng());
134				y13 = (source[i].lat() - source[start].lat());
135				if (Math.abs(x13) > 180.0) 
136					x13 = 360.0 - Math.abs(x13);
137				x13 *= Math.cos (F * (source[i].lat() + source[start].lat()));
138				d13 = (x13*x13) + (y13*y13);
139
140				x23 = (source[i].lng() - source[end].lng());
141				y23 = (source[i].lat() - source[end].lat());
142				if (Math.abs(x23) > 180.0) 
143					x23 = 360.0 - Math.abs(x23);
144				x23 *= Math.cos(F * (source[i].lat() + source[end].lat()));
145				d23 = (x23*x23) + (y23*y23);
146
147				if ( d13 >= ( d12 + d23 ) )
148					dev_sqr = d23;
149				else if ( d23 >= ( d12 + d13 ) )
150					dev_sqr = d13;
151				else
152					dev_sqr = (x13 * y12 - y13 * x12) * (x13 * y12 - y13 * x12) / d12;// solve triangle
153
154				if ( dev_sqr > max_dev_sqr  ){
155					sig = i;
156					max_dev_sqr = dev_sqr;
157				}
158			}
159
160			if ( max_dev_sqr < band_sqr ) {
161				index[n_dest] = start;
162				n_dest++;
163			} else {
164				n_stack++;
165				sig_start[n_stack-1] = sig;
166				sig_end[n_stack-1] = end;
167				n_stack++;
168				sig_start[n_stack-1] = start;
169				sig_end[n_stack-1] = sig;
170			}
171		} else {
172			index[n_dest] = start;
173			n_dest++;
174		}
175	}
176	index[n_dest] = n_source-1;
177	n_dest++;
178
179	var r = new Array();
180	for(var i=0; i < n_dest; i++)
181		r.push(source[index[i]]);
182
183	return r;
184}
185
186(function($) {
187	"use strict";
188	
189	$(function() {
190		w2dc_check_support();
191		w2dc_add_body_classes();
192		w2dc_get_rid_of_select2_choosen();
193		w2dc_custom_input_controls();
194		w2dc_my_location_buttons();
195		w2dc_tokenizer();
196		w2dc_equalColumnsHeight();
197		w2dc_equalColumnsHeightEvent();
198		w2dc_listings_carousel();
199		w2dc_radius_slider();
200		w2dc_hint();
201		w2dc_favourites();
202		w2dc_week_day_input();
203		w2dc_check_is_week_day_closed();
204		w2dc_listing_tabs();
205		w2dc_dashboard_tabs();
206		w2dc_sticky_scroll();
207		w2dc_tooltips();
208		w2dc_ratings();
209		w2dc_hours_content_field();
210		w2dc_full_height_maps();
211		w2dc_load_comments();
212		w2dc_content_fields_metabox();
213		w2dc_upload_image();
214		w2dc_media_metabox();
215		w2dc_locations_metabox();
216		w2dc_datetime_input();
217		w2dc_expiration_date_metabox();
218		w2dc_order_date_metabox();
219		w2dc_add_term_links();
220		w2dc_sort_terms();
221	});
222
223	window.w2dc_check_support = function() {
224		
225		$(".w2dc-license-support-checker").each(function() {
226			
227			var el 		= $(this);
228			var nonce	= el.data("nonce");
229			
230			$.ajax({
231				type: 'POST',
232				url: w2dc_js_objects.ajaxurl,
233				data: { 
234					'action': 'w2dc_license_support_checker',
235					'security': nonce
236				},
237				success: function(response) {
238					
239					if (response) {
240						el.html(response);
241					}
242				}
243			});
244		});
245	}
246	
247	window.w2dc_sort_terms = function() {
248		if (typeof w2dc_order_term_data != 'undefined') {
249			var base_index = parseInt(w2dc_order_term_data.paged) > 0 ? (parseInt(w2dc_order_term_data.paged) - 1) * parseInt($('#'+w2dc_order_term_data.per_page_id).val()) : 0;
250			var tax_table  = $('#the-list');
251		
252			// If the tax table contains items.
253			if (tax_table.length && !tax_table.find('tr:first-child').hasClass('no-items')) {
254				
255				tax_table.sortable({
256					placeholder: "w2dc-drag-drop-tax-placeholder",
257					axis: "y",
258		
259					// On start, set a height for the placeholder to prevent table jumps.
260					start: function(event, ui) {
261						const item  = $(ui.item[0]);
262						const index = item.index();
263						const colspan = item.children('th,td').filter(':visible').length;
264						$('.w2dc-drag-drop-tax-placeholder')
265						.css('height', item.css('height'))
266						.css('display', 'flex')
267						.css('width', '0');
268					},
269					update: function(event, ui) {
270						var item = $(ui.item[0]);
271						var taxonomy_ordering_data = [];
272		
273						tax_table.find('tr.ui-sortable-handle').each(function() {
274							var ele = $(this);
275							var term_data = {
276								term_id: ele.attr('id').replace('tag-', ''),
277								order: parseInt(ele.index()) + 1
278							}
279							taxonomy_ordering_data.push(term_data);
280						});
281						
282						var data = {
283							'action': 'w2dc_update_tax_order',
284							'taxonomy_ordering_data': taxonomy_ordering_data,
285							'base_index': base_index,
286							'term_order_nonce': w2dc_order_term_data.term_order_nonce
287						};
288						
289						$.ajax({
290							type: 'POST',
291							url: w2dc_js_objects.ajaxurl,
292							data: data,
293							dataType: 'JSON',
294							success: function(response) {
295								item.find('input[type="checkbox"]').show();
296							}
297						});
298					}
299				});
300			}
301		}
302	}
303	
304	window.w2dc_upload_image = function() {
305		$(document).on("click", ".w2dc-reset-image-button", function(e) {
306			e.preventDefault();
307			
308			var form = $(this).parents(".w2dc-upload-image-form");
309			form.parent().find(".w2dc-upload-image").css("background-image", "");
310			form.parent().find('.w2dc-upload-image-input-' + form.data('name')).val("");
311		});
312		if (w2dc_js_objects.is_admin) {
313			$(document).on('click', '.w2dc-upload-image-button', function(event) {
314				event.preventDefault();
315		
316				var form = $(this).parents(".w2dc-upload-image-form");
317				var frame = wp.media({
318					title : w2dc_js_objects.media_dialog_title,
319					multiple : false,
320					library : { type : 'image'},
321					button : { text : w2dc_js_objects.media_dialog_button_text},
322				});
323				frame.on('select', function() {
324					var selected_images = [];
325					var selection = frame.state().get('selection');
326					selection.each(function(attachment) {
327						attachment = attachment.toJSON();
328						if (attachment.type == 'image') {
329							
330							var image_url = attachment.sizes.full.url;
331							var attachment_id = attachment.id;
332							form.find('.w2dc-upload-image').css("background-image", "url(" + image_url + ")");
333							form.find('.w2dc-upload-image-input-' + form.data('name')).val(attachment_id);
334						}
335					
336					});
337				});
338				frame.open();
339			});
340		} else {
341			$(document).on("click", ".w2dc-upload-image-button", function(e) {
342				e.preventDefault();
343				
344				$(this).parent().find("input").trigger('click');
345			});
346			$('.w2dc-upload-image-form').each(function() {
347				var form = $(this);
348				var action_url = form.data('action-url');
349				form.fileupload({
350					dataType: 'json',
351					url: action_url,
352					send: function (e, data) {
353						w2dc_add_iloader_on_element(form);
354					},
355					done: function(e, data) {
356						var result = data.result;
357						if (result.uploaded_file) {
358							var size = result.metadata.size;
359							var width = result.metadata.width;
360							var height = result.metadata.height;
361							form.find('.w2dc-upload-image').css("background-image", "url(" + result.uploaded_file + ")");
362							form.find('.w2dc-upload-image-input-' + form.data('name')).val(result.attachment_id);
363						} else {
364							form.find('.w2dc-upload-image').append("<p>"+result.error_msg+"</p>");
365						}
366						w2dc_delete_iloader_from_element(form);
367					}
368				});
369			});
370		}
371	}
372
373	window.w2dc_add_term_links = function() {
374		$(document).on("click", ".w2dc-add-term-link", function(e) {
375			e.preventDefault();
376			
377			var el = $(this);
378			var tax = el.data('tax');
379			var uid = el.data('uid');
380			var exact_terms = el.data('exact-terms');
381			var parent_id = el.data('parent');
382			var nonce = el.data('nonce');
383			var label = el.html();
384			var saved_html = el[0].outerHTML;
385
386			var add_form = $('<form class="w2dc-add-term-form"><input name="w2dc_add_term_input" class="w2dc-form-control w2dc-add-term-input" value="" /><a class="w2dc-btn w2dc-btn-primary w2dc-add-term-button">'+label+'</a> <a class="w2dc-btn w2dc-btn-primary w2dc-add-term-cancel">'+w2dc_js_objects.cancel_button+'</a></form>');
387			add_form.on("submit", function(e) {
388				e.preventDefault();
389				
390				$(add_form).find('.w2dc-add-term-button').trigger('click');
391			});
392			el.replaceWith(add_form);
393			
394			$(add_form).find('.w2dc-add-term-input').focus();
395			
396			$(add_form).on("click", ".w2dc-add-term-cancel", function(e) {
397				e.preventDefault();
398				
399				$(this).parent().replaceWith(saved_html);
400			});
401			
402			$(add_form).on("click", ".w2dc-add-term-button", function(e) {
403				e.preventDefault();
404				
405				var input = $(this).parent().find('.w2dc-add-term-input');
406				if (input.val()) {
407					w2dc_ajax_loader_show();
408					
409					$.ajax({
410						type: "POST",
411						url: w2dc_js_objects.ajaxurl,
412						data: { 
413							'action': 'w2dc_add_term',
414							'tax': tax,
415							'parent_id': parent_id,
416							'val': input.val(),
417							'security': nonce
418						},
419						success: function(term_id){
420							
421							term_id = $.trim(term_id);
422							
423							if (term_id != 0) {
424								$(add_form).find('.w2dc-add-term-cancel').trigger('click');
425								
426								w2dc_update_tax_wrapper(tax, uid, exact_terms, term_id);
427							}
428						},
429						complete: function() {
430							
431						}
432					});
433				}
434			});
435		});
436	}
437	
438	window.w2dc_update_tax_wrapper = function(tax, uid, exact_terms, selected_term) {
439		var wrapper = $('div.'+tax);
440		
441		$.ajax({
442			type: "POST",
443			url: w2dc_js_objects.ajaxurl,
444			data: { 'action': 'w2dc_update_tax_wrapper', 'tax': tax, 'exact_terms': exact_terms, 'selected_term': selected_term, 'uid': uid },
445			success: function(response_from_the_action_function){
446				if (response_from_the_action_function != 0) {
447					wrapper.html('').append(response_from_the_action_function);
448				}
449			},
450			complete: function() {
451				w2dc_ajax_loader_hide();
452			}
453		});
454	}
455	
456	window.w2dc_expiration_date_metabox = function() {
457		if (typeof w2dc_expiration_date_metabox_attrs != 'undefined') {
458			$("#expiration_date").datepicker({
459				changeMonth: true,
460				changeYear: true,
461				isRTL: w2dc_expiration_date_metabox_attrs.isRTL,
462				showButtonPanel: true,
463				dateFormat: w2dc_expiration_date_metabox_attrs.dateFormat,
464				firstDay: w2dc_expiration_date_metabox_attrs.firstDay,
465				onSelect: function(dateText) {
466					var tmstmp_str;
467					var sDate = $("#expiration_date").datepicker("getDate");
468					if (sDate) {
469						sDate.setMinutes(sDate.getMinutes() - sDate.getTimezoneOffset());
470						tmstmp_str = $.datepicker.formatDate('@', sDate)/1000;
471					} else {
472						tmstmp_str = 0;
473					}
474	
475					$("input[name=expiration_date_tmstmp]").val(tmstmp_str);
476				}
477			});
478			if (w2dc_expiration_date_metabox_attrs.lang_code) {
479				$("#expiration_date").datepicker($.datepicker.regional[w2dc_expiration_date_metabox_attrs.lang_code]);
480			}
481	
482			$("#expiration_date").datepicker('setDate', $.datepicker.parseDate('dd/mm/yy', w2dc_expiration_date_metabox_attrs.expiration_date_formatted));
483		}
484	}
485	
486	window.w2dc_order_date_metabox = function() {
487		if (typeof w2dc_order_date_metabox_attrs != 'undefined') {
488			$("#order_date").datepicker({
489				changeMonth: true,
490				changeYear: true,
491				isRTL: w2dc_order_date_metabox_attrs.isRTL,
492				showButtonPanel: true,
493				dateFormat: w2dc_order_date_metabox_attrs.dateFormat,
494				firstDay: w2dc_order_date_metabox_attrs.firstDay,
495				onSelect: function(dateText) {
496					var tmstmp_str;
497					var sDate = $("#order_date").datepicker("getDate");
498					if (sDate) {
499						sDate.setMinutes(sDate.getMinutes() - sDate.getTimezoneOffset());
500						tmstmp_str = $.datepicker.formatDate('@', sDate)/1000;
501					} else {
502						tmstmp_str = 0;
503					}
504					
505					$("input[name=order_date_tmstmp]").val(tmstmp_str);
506				}
507			});
508			if (w2dc_order_date_metabox_attrs.lang_code) {
509				$("#order_date").datepicker($.datepicker.regional[w2dc_order_date_metabox_attrs.lang_code]);
510			}
511			
512			$("#order_date").datepicker('setDate', $.datepicker.parseDate('dd/mm/yy', w2dc_order_date_metabox_attrs.order_date_formatted));
513		}
514	}
515	
516	window.w2dc_datetime_input = function() {
517		if (typeof w2dc_datetime_input_attrs != 'undefined') {
518			
519			$.each(w2dc_datetime_input_attrs, function (index, field_attrs) {
520				var field_id = field_attrs.field_id;
521				
522				$("#w2dc-field-input-" + field_id + "-start").datepicker({
523					changeMonth: true,
524					changeYear: true,
525					isRTL: field_attrs.isRTL,
526					showButtonPanel: true,
527					dateFormat: field_attrs.dateFormat,
528					firstDay: field_attrs.firstDay,
529					onSelect: function(dateText) {
530						var tmstmp_str;
531						var sDate = $("#w2dc-field-input-" + field_id + "-start").datepicker("getDate");
532						var set_min_date = $("#w2dc-field-input-" + field_id + "-start").datepicker("getDate");
533						if (sDate) {
534							sDate.setMinutes(sDate.getMinutes() - sDate.getTimezoneOffset());
535							tmstmp_str = $.datepicker.formatDate('@', sDate)/1000;
536						} else {
537							tmstmp_str = 0;
538						}
539						$("#w2dc-field-input-" + field_id + "-end").datepicker('option', 'minDate', set_min_date);
540		
541						$("input[name=w2dc-field-input-" + field_id + "-start]").val(tmstmp_str);
542					},
543					onClose: function() {
544						// this is workaround to prevent an issue when changing year-month on the end datepicker 
545						setTimeout(function() {
546							$("#w2dc-field-input-" + field_id + "-end").focus();
547						}, 0);
548					}
549				});
550				if (field_attrs.lang_code) {
551					$("#w2dc-field-input-" + field_id + "-start").datepicker($.datepicker.regional[field_attrs.lang_code]);
552				}
553				
554				$("#w2dc-field-input-" + field_id + "-end").datepicker({
555					changeMonth: true,
556					changeYear: true,
557					isRTL: field_attrs.isRTL,
558					showButtonPanel: true,
559					dateFormat: field_attrs.dateFormat,
560					firstDay: field_attrs.firstDay,
561					onSelect: function(dateText) {
562						var tmstmp_str;
563						var sDate = $("#w2dc-field-input-" + field_id + "-end").datepicker("getDate");
564						var set_max_date = $("#w2dc-field-input-" + field_id + "-end").datepicker("getDate");
565						if (sDate) {
566							sDate.setMinutes(sDate.getMinutes() - sDate.getTimezoneOffset());
567							tmstmp_str = $.datepicker.formatDate('@', sDate)/1000;
568						} else {
569							tmstmp_str = 0;
570						}
571						$("#w2dc-field-input-" + field_id + "-start").datepicker('option', 'maxDate', set_max_date);
572		
573						$("input[name=w2dc-field-input-" + field_id + "-end]").val(tmstmp_str);
574					}
575				});
576				if (field_attrs.lang_code) {
577					$("#w2dc-field-input-" + field_id + "-end").datepicker($.datepicker.regional[field_attrs.lang_code]);
578				}
579
580				if (field_attrs.date_end) {
581					$("#w2dc-field-input-" + field_id + "-end").datepicker('setDate', $.datepicker.parseDate('dd/mm/yy', field_attrs.date_end_formatted));
582					$("#w2dc-field-input-" + field_id + "-start").datepicker('option', 'maxDate', $("#w2dc-field-input-" + field_id + "-end").datepicker('getDate'));
583				}
584				$('body').on('click', "#w2dc-reset-date-" + field_id + "-end", function() {
585					$.datepicker._clearDate("#w2dc-field-input-" + field_id + "-end");
586				})
587
588				if (field_attrs.date_start) {
589					$("#w2dc-field-input-" + field_id + "-start").datepicker('setDate', $.datepicker.parseDate('dd/mm/yy', field_attrs.date_start_formatted));
590					$("#w2dc-field-input-" + field_id + "-end").datepicker('option', 'minDate', $("#w2dc-field-input-" + field_id + "-start").datepicker('getDate'));
591				}
592				$('body').on('click', "#w2dc-reset-date-" + field_id + "-start", function() {
593					$.datepicker._clearDate("#w2dc-field-input-" + field_id + "-start");
594				})
595			});
596		}
597	}
598	
599	window.w2dc_locations_metabox = function() {
600		if (typeof w2dc_locations_metabox_attrs != 'undefined') {
601			if (w2dc_locations_metabox_attrs.is_map_markers) {
602				if (w2dc_maps_objects.map_markers_type == 'images') {
603					var map_icon_file_input;
604					$(document).on("click", ".w2dc-select-map-icon", function() {
605						map_icon_file_input = $(this).parents(".w2dc-location-input").find('.w2dc-map-icon-file');
606			
607						var dialog = $('<div id="w2dc-select-map-icon-dialog"></div>').dialog({
608							dialogClass: 'w2dc-content',
609							width: ($(window).width()*0.5),
610							height: ($(window).height()*0.8),
611							modal: true,
612							resizable: false,
613							draggable: false,
614							title: w2dc_locations_metabox_attrs.images_dialog_title,
615							open: function() {
616								w2dc_ajax_loader_show();
617								$.ajax({
618									type: "POST",
619									url: w2dc_js_objects.ajaxurl,
620									data: {'action': 'w2dc_select_map_icon'},
621									dataType: 'html',
622									success: function(response_from_the_action_function){
623										if (response_from_the_action_function != 0) {
624											$('#w2dc-select-map-icon-dialog').html(response_from_the_action_function);
625											if (map_icon_file_input.val())
626												$(".w2dc-icon[icon_file='"+map_icon_file_input.val()+"']").addClass("w2dc-selected-icon");
627										}
628									},
629									complete: function() {
630										w2dc_ajax_loader_hide();
631									}
632								});
633								$(document).on("click", ".ui-widget-overlay", function() { $('#w2dc-select-map-icon-dialog').remove(); });
634							},
635							close: function() {
636								$('#w2dc-select-map-icon-dialog').remove();
637							}
638						});
639					});
640					$(document).on("click", ".w2dc-icon", function() {
641						$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
642						if (map_icon_file_input) {
643							map_icon_file_input.val($(this).attr('icon_file'));
644							map_icon_file_input = false;
645							$(this).addClass("w2dc-selected-icon");
646							$('#w2dc-select-map-icon-dialog').remove();
647							w2dc_generateMap_backend();
648						}
649					});
650					$(document).on("click", "#reset_icon", function() {
651						if (map_icon_file_input) {
652							$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
653							map_icon_file_input.val('');
654							map_icon_file_input = false;
655							$('#w2dc-select-map-icon-dialog').remove();
656							w2dc_generateMap_backend();
657						}
658					});
659				} else {
660					var map_icon_file_input;
661					$(document).on("click", ".w2dc-select-map-icon", function() {
662						map_icon_file_input = $(this).parents(".w2dc-location-input").find('.w2dc-map-icon-file');
663		
664						var dialog = $('<div id="select_marker_icon_dialog"></div>').dialog({
665							dialogClass: 'w2dc-content',
666							width: ($(window).width()*0.5),
667							height: ($(window).height()*0.8),
668							modal: true,
669							resizable: false,
670							draggable: false,
671							title: w2dc_locations_metabox_attrs.icons_dialog_title,
672							open: function() {
673								w2dc_ajax_loader_show();
674								$.ajax({
675									type: "POST",
676									url: w2dc_js_objects.ajaxurl,
677									data: {'action': 'w2dc_select_fa_icon'},
678									dataType: 'html',
679									success: function(response_from_the_action_function){
680										if (response_from_the_action_function != 0) {
681											$('#select_marker_icon_dialog').html(response_from_the_action_function);
682											if (map_icon_file_input.val())
683												$("#"+map_icon_file_input.val()).addClass("w2dc-selected-icon");
684										}
685									},
686									complete: function() {
687										w2dc_ajax_loader_hide();
688									}
689								});
690								$(document).on("click", ".ui-widget-overlay", function() { $('#select_marker_icon_dialog').remove(); });
691							},
692							close: function() {
693								$('#select_marker_icon_dialog').remove();
694							}
695						});
696					});
697					$(document).on("click", ".w2dc-fa-icon", function() {
698						$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
699						if (map_icon_file_input) {
700							map_icon_file_input.val($(this).attr('id'));
701							map_icon_file_input = false;
702							$(this).addClass("w2dc-selected-icon");
703							$('#select_marker_icon_dialog').remove();
704							w2dc_generateMap_backend();
705						}
706					});
707					$(document).on("click", "#w2dc-reset-fa-icon", function() {
708						if (map_icon_file_input) {
709							$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
710							map_icon_file_input.val('');
711							map_icon_file_input = false;
712							$('#select_marker_icon_dialog').remove();
713							w2dc_generateMap_backend();
714						}
715					});
716				}
717			}
718			
719			$('body').on('click', ".add_address", function() {
720				w2dc_ajax_loader_show();
721				$.ajax({
722					type: "POST",
723					url: w2dc_js_objects.ajaxurl,
724					data: { 'action': 'w2dc_add_location_in_metabox', 'post_id': w2dc_locations_metabox_attrs.post_id },
725					success: function(response_from_the_action_function){
726						if (response_from_the_action_function != 0) {
727							$("#w2dc-locations-wrapper").append(response_from_the_action_function);
728							$(".w2dc-delete-address").show();
729							if (w2dc_locations_metabox_attrs.locations_number == $(".w2dc-location-in-metabox").length) {
730								$(".add_address").hide();
731							}
732							if (w2dc_maps_objects.address_autocomplete && w2dc_js_objects.is_maps_used) {
733								w2dc_setupAutocomplete();
734							}
735						}
736					},
737					complete: function() {
738						w2dc_ajax_loader_hide();
739					}
740				});
741			});
742			$(document).on("click", ".w2dc-delete-address", function() {
743				$(this).parents(".w2dc-location-in-metabox").remove();
744				if ($(".w2dc-location-in-metabox").length == 1)
745					$(".w2dc-delete-address").hide();
746	
747				if (w2dc_locations_metabox_attrs.is_map) {
748					w2dc_generateMap_backend();
749				}
750	
751				if (w2dc_locations_metabox_attrs.locations_number > $(".w2dc-location-in-metabox").length)
752					$(".add_address").show();
753			});
754	
755			$(document).on("click", ".w2dc-manual-coords", function() {
756	        	if ($(this).is(":checked"))
757	        		$(this).parents(".w2dc-manual-coords-wrapper").find(".w2dc-manual-coords-block").slideDown(200);
758	        	else
759	        		$(this).parents(".w2dc-manual-coords-wrapper").find(".w2dc-manual-coords-block").slideUp(200);
760	        });
761	
762	        if (w2dc_locations_metabox_attrs.locations_number > $(".w2dc-location-in-metabox").length) {
763				$(".add_address").show();
764	        }
765		}
766	}
767	
768	window.w2dc_media_metabox = function() {
769		if ($('#w2dc-images-upload-wrapper').length) {
770
771			window.w2dc_image_attachment_tpl = function(attachment_id, uploaded_file, title, size, width, height) {
772				var image_attachment_tpl = '<div class="w2dc-attached-item w2dc-move-label">' +
773						'<input type="hidden" name="attached_image_id[]" class="w2dc-attached-item-id" value="'+attachment_id+'" />' +
774						'<a href="'+uploaded_file+'" data-w2dc_lightbox="listing_images" class="w2dc-attached-item-img" style="background-image: url('+uploaded_file+')"></a>' +
775						'<div class="w2dc-attached-item-input">' +
776							'<input type="text" name="attached_image_title[]" class="w2dc-form-control" value="" placeholder="' + w2dc_media_metabox_attrs.images_input_placeholder + '" />' +
777						'</div>';
778						if (w2dc_media_metabox_attrs.images_logo_enabled) {
779							image_attachment_tpl = image_attachment_tpl + '<div class="w2dc-attached-item-logo w2dc-radio">' +
780							'<label>' +
781								'<input type="radio" name="attached_image_as_logo" value="'+attachment_id+'"> ' + w2dc_media_metabox_attrs.images_input_label +
782							'</label>' +
783							'</div>';
784						}
785						image_attachment_tpl = image_attachment_tpl + '<div class="w2dc-attached-item-delete w2dc-fa w2dc-fa-trash-o" title="' + w2dc_media_metabox_attrs.images_remove_title + '"></div>' +
786						'<div class="w2dc-attached-item-metadata">'+size+' ('+width+' x '+height+')</div>' +
787					'</div>';
788
789				return image_attachment_tpl;
790			};
791
792			window.w2dc_update_images_attachments_order = function() {
793				$("#w2dc-attached-images-order").val($(".w2dc-attached-item-id").map(function() {
794					return $(this).val();
795				}).get());
796			}
797			window.w2dc_check_images_attachments_number = function() {
798				if (w2dc_media_metabox_attrs.images_number > $("#w2dc-images-upload-wrapper .w2dc-attached-item").length) {
799					if (w2dc_js_objects.is_admin) {
800						$("#w2dc-admin-upload-functions").show();
801					} else {
802						$(".w2dc-upload-item").show();
803					}
804					return true;
805				} else {
806					if (w2dc_js_objects.is_admin) {
807						$("#w2dc-admin-upload-functions").hide();
808					} else {
809						$(".w2dc-upload-item").hide();
810					}
811					return false;
812				}
813			}
814
815			
816		    var sortable_images = $("#w2dc-attached-images-wrapper").sortable({
817			    delay: 50,
818		    	placeholder: "ui-sortable-placeholder",
819		    	items: ".w2dc-attached-item",
820				helper: function(e, ui) {
821					ui.children().each(function() {
822						$(this).width($(this).width());
823					});
824					return ui;
825				},
826				start: function(e, ui){
827					ui.placeholder.width(ui.item.width());
828					ui.placeholder.height(ui.item.height());
829				},
830				update: function( event, ui ) {
831					w2dc_update_images_attachments_order();
832				}
833			});
834
835		    // disable sortable on android, otherwise it breaks click events on image, radio and delete button
836		    var ua = navigator.userAgent.toLowerCase();
837		    if (ua.indexOf("android") > -1) {
838				sortable_images.sortable("disable");
839			};
840
841			w2dc_check_images_attachments_number();
842
843			$("#w2dc-attached-images-wrapper").on("click", ".w2dc-attached-item-delete", function() {
844				$(this).parents(".w2dc-attached-item").remove();
845				
846				$.ajax({
847					url: w2dc_js_objects.ajaxurl,
848					type: "POST",
849					dataType: "json",
850					data: {
851						action: 'w2dc_remove_image',
852						post_id: w2dc_media_metabox_attrs.object_id,
853						attachment_id: $(this).parent().find(".w2dc-attached-item-id").val(),
854						_wpnonce: w2dc_media_metabox_attrs.images_remove_image_nonce
855					}
856				});
857		
858				w2dc_check_images_attachments_number();
859				w2dc_update_images_attachments_order();
860			});
861
862			if (!w2dc_js_objects.is_admin) {
863				$(document).on("click", ".w2dc-upload-item-button", function(e){
864					e.preventDefault();
865					
866					$(this).parent().find("input").trigger('click');
867				});
868	
869				$('.w2dc-upload-item').fileupload({
870					sequentialUploads: true,
871					dataType: 'json',
872					url: w2dc_media_metabox_attrs.images_fileupload_url,
873					dropZone: $('.w2dc-drop-attached-item'),
874					add: function (e, data) {
875						if (w2dc_check_images_attachments_number()) {
876							var jqXHR = data.submit();
877						} else {
878							return false;
879						}
880					},
881					send: function (e, data) {
882						w2dc_add_iloader_on_element($(this).find(".w2dc-drop-attached-item"));
883					},
884					done: function(e, data) {
885						var result = data.result;
886						if (result.uploaded_file) {
887							var size = result.metadata.size;
888							var width = result.metadata.width;
889							var height = result.metadata.height;
890							$(this).before(w2dc_image_attachment_tpl(result.attachment_id, result.uploaded_file, data.files[0].name, size, width, height));
891							w2dc_custom_input_controls();
892						} else {
893							$(this).find(".w2dc-drop-attached-item").append("<p>"+result.error_msg+"</p>");
894						}
895						$(this).find(".w2dc-drop-zone").show();
896						w2dc_delete_iloader_from_element($(this).find(".w2dc-drop-attached-item"));
897						
898						w2dc_check_images_attachments_number();
899						w2dc_update_images_attachments_order();
900					}
901				});
902			}
903			
904			if (w2dc_media_metabox_attrs.images_is_admin) {
905				$('body').on('click', '#w2dc-admin-upload-image', function(event) {
906					event.preventDefault();
907			
908					var frame = wp.media({
909						title : w2dc_media_metabox_attrs.images_upload_image_title,
910						multiple : true,
911						library : { type : 'image'},
912						button : { text : w2dc_media_metabox_attrs.images_upload_image_button},
913					});
914					frame.on('select', function() {
915						var selected_images = [];
916						var selection = frame.state().get('selection');
917						selection.each(function(attachment) {
918							attachment = attachment.toJSON();
919							if (attachment.type == 'image') {
920					
921								if (w2dc_check_images_attachments_number()) {
922									w2dc_ajax_loader_show();
923			
924									$.ajax({
925										type: "POST",
926										async: false,
927										url: w2dc_js_objects.ajaxurl,
928										data: {
929											'action': 'w2dc_upload_media_image',
930											'attachment_id': attachment.id,
931											'post_id': w2dc_media_metabox_attrs.object_id,
932											'_wpnonce': w2dc_media_metabox_attrs.images_upload_image_nonce,
933										},
934										attachment_id: attachment.id,
935										attachment_url: attachment.sizes.full.url,
936										attachment_title: attachment.title,
937										dataType: "json",
938										success: function (response_from_the_action_function) {
939											if (response_from_the_action_function != 0) {
940												var size = response_from_the_action_function.metadata.size;
941												var width = response_from_the_action_function.metadata.width;
942												var height = response_from_the_action_function.metadata.height;
943												$("#w2dc-attached-images-wrapper").append(w2dc_image_attachment_tpl(this.attachment_id, this.attachment_url, this.attachment_title, size, width, height));
944												w2dc_check_images_attachments_number();
945												w2dc_update_images_attachments_order();
946											}
947												
948											w2dc_ajax_loader_hide();
949										}
950									});
951								}
952							}
953						
954						});
955					});
956					frame.open();
957				});
958			}
959		}
960		
961		if ($('#w2dc-attach-videos-functions').length) {
962			window.w2dc_video_attachment_tpl = function(video_id, image_url) {
963				var video_attachment_tpl = '<div class="w2dc-attached-item">' +
964					'<input type="hidden" name="attached_video_id[]" value="'+video_id+'" />' +
965					'<div class="w2dc-attached-item-img" style="background-image: url('+image_url+')"></div>' +
966					'<div class="w2dc-attached-item-delete w2dc-fa w2dc-fa-trash-o" title="' + w2dc_media_metabox_attrs.videos_delete_title + '"></div>' +
967				'</div>';
968
969				return video_attachment_tpl;
970			};
971
972			window.w2dc_check_videos_attachments_number = function() {
973				if (w2dc_media_metabox_attrs.videos_number > $("#w2dc-attached-videos-wrapper .w2dc-attached-item").length) {
974					$("#w2dc-attach-videos-functions").show();
975				} else {
976					$("#w2dc-attach-videos-functions").hide();
977				}
978			}
979
980			w2dc_check_videos_attachments_number();
981
982			$("#w2dc-attached-videos-wrapper").on("click", ".w2dc-attached-item-delete", function() {
983				$(this).parents(".w2dc-attached-item").remove();
984	
985				w2dc_check_videos_attachments_number();
986			});
987			
988			window.attachVideo = function() {
989				if ($("#w2dc-attach-video-input").val()) {
990					var regExp_youtube = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
991					var regExp_vimeo = /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/;
992					var matches_youtube = $("#w2dc-attach-video-input").val().match(regExp_youtube);
993					var matches_vimeo = $("#w2dc-attach-video-input").val().match(regExp_vimeo);
994					if (matches_youtube && matches_youtube[2].length == 11) {
995						var video_id = matches_youtube[2];
996						var image_url = 'http://i.ytimg.com/vi/'+video_id+'/0.jpg';
997						$("#w2dc-attached-videos-wrapper").append(w2dc_video_attachment_tpl(video_id, image_url));
998
999						w2dc_check_videos_attachments_number();
1000					} else if (matches_vimeo && (matches_vimeo[3].length == 8 || matches_vimeo[3].length == 9)) {
1001						var video_id = matches_vimeo[3];
1002						var url = "//vimeo.com/api/v2/video/" + video_id + ".json?callback=showVimeoThumb";
1003					    var script = document.createElement('script');
1004					    script.src = url;
1005					    $("#w2dc-attach-videos-functions").before(script);
1006					} else {
1007						alert(w2dc_media_metabox_attrs.videos_error_alert);
1008					}
1009				}
1010			};
1011
1012			window.showVimeoThumb = function(data){
1013				var video_id = data[0].id;
1014			    var image_url = data[0].thumbnail_medium;
1015			    $("#w2dc-attached-videos-wrapper").append(w2dc_video_attachment_tpl(video_id, image_url));
1016
1017			    w2dc_check_videos_attachments_number();
1018			};
1019		}
1020	}
1021	
1022	window.w2dc_my_location_buttons = function() {
1023		if (w2dc_maps_objects.enable_my_location_button) {
1024			$(".w2dc-get-location").attr("title", w2dc_maps_objects.my_location_button);
1025			$("body").on("click", ".w2dc-get-location", function() {
1026				if (!$(this).hasClass('w2dc-search-input-reset')) {
1027					var input = $(this).parent().find("input");
1028					w2dc_geocodeField(input, w2dc_maps_objects.my_location_button_error);
1029				} else {
1030					$(this).removeClass('w2dc-search-input-reset');
1031				}
1032			});
1033		}
1034	}
1035	
1036	window.w2dc_tokenizer = function() {
1037		function getUnique(value, index, self) { 
1038			return self.indexOf(value) === index;
1039		}
1040		
1041		var tokenizer = $(".w2dc-tokenizer").tokenize({
1042			onAddToken: function(value, text, e) {
1043				if (!w2dc_tags_metabox_attrs.unlimited_tags && tokenizer.toArray().filter(getUnique).length > w2dc_tags_metabox_attrs.tags_number) {
1044					tokenizer.tokenRemove(value);
1045					alert(w2dc_tags_metabox_attrs.tags_limit_message);
1046				}
1047			}
1048		});
1049	}
1050
1051	window.w2dc_add_body_classes = function() {
1052		if ("ontouchstart" in document.documentElement)
1053			$("body").addClass("w2dc-touch");
1054		else
1055			$("body").addClass("w2dc-no-touch");
1056	}
1057
1058	window.w2dc_listing_tabs = function() {
1059		var el = $('.w2dc-listing-tabs');
1060		var map = {};
1061
1062		if (el.length) {
1063			$('.w2dc-listing-tabs li').each(function() { 
1064				var el = $(this);
1065				map[el.find('a').data('tab')] = el;
1066			});
1067	
1068			if (w2dc_js_objects.listing_tabs_order.length) {
1069				for (var i = 0, l = w2dc_js_objects.listing_tabs_order.length; i < l; i ++) {
1070					var tab = w2dc_js_objects.listing_tabs_order[i];
1071					
1072					if (map['#'+tab]) {
1073						el.append(map['#'+tab]);
1074					}
1075				}
1076				
1077				for (var i = 0, l = w2dc_js_objects.listing_tabs_order.length; i < l; i ++) {
1078					var tab = w2dc_js_objects.listing_tabs_order[i];
1079					
1080					if ($('#'+tab).length) {
1081						w2dc_show_tab($('.w2dc-listing-tabs a[data-tab="#'+tab+'"]'));
1082						break;
1083					}
1084				}
1085			} else {
1086				w2dc_show_tab($('.w2dc-listing-tabs a:first'));
1087			}
1088			
1089			$(document).on('click', '.w2dc-listing-tabs a', function(e) {	  
1090				e.preventDefault();
1091				w2dc_show_tab($(this));
1092				history.replaceState({}, "", $(this).data('tab'));
1093			});
1094			var hash = window.location.hash.substring(1);
1095			var searchParams = new URLSearchParams(window.location.search)
1096			if (hash == 'respond' || hash == 'comments' || searchParams.has('reviews_order_by') || hash.indexOf('comment-', 0) >= 0) {
1097				w2dc_show_tab($('.w2dc-listing-tabs a[data-tab="#comments-tab"]'));
1098			} else if (hash && $('.w2dc-listing-tabs a[data-tab="#'+hash+'"]').length) {
1099				w2dc_show_tab($('.w2dc-listing-tabs a[data-tab="#'+hash+'"]'));
1100			}
1101		}
1102	}
1103	// open reviews on click on reviews counter link
1104	$("a.w2rr-counter-reviews-link").on("click", function() {
1105		var anchor;
1106		if (anchor = $(this).attr("href").split("#").pop()) {
1107			if (anchor == "comments-tab" && $('.w2dc-listing-tabs a[data-tab="#'+anchor+'"]').length) {
1108				w2dc_show_tab($('.w2dc-listing-tabs a[data-tab="#'+anchor+'"]'));
1109			}
1110		}
1111	});
1112	window.w2dc_show_tab = function(tab) {
1113		$('.w2dc-listing-tabs li').removeClass('w2dc-active');
1114		tab.parent().addClass('w2dc-active');
1115		$('.w2dc-tab-content .w2dc-tab-pane').removeClass('w2dc-in w2dc-active');
1116		$('.w2dc-tab-content '+tab.data('tab')).addClass('w2dc-in w2dc-active');
1117		if (tab.data('tab') == '#addresses-tab') {
1118			w2dc_reload_maps();
1119		}
1120		tab.trigger("w2dc:show_tab");
1121	};
1122	window.w2dc_reload_maps = function() {
1123		for (var key in w2dc_maps) {
1124			if (typeof w2dc_maps[key] == 'object') {
1125				w2dc_reloadMap(key);
1126			}
1127		}
1128	};
1129	
1130	window.w2dc_radius_slider = function () {
1131		$('.w2dc-radius-slider').each(function() {
1132			var id = $(this).data("id");
1133			$('#radius_slider_'+id).slider({
1134				isRTL: w2dc_js_objects.is_rtl,
1135				min: parseInt(slider_params.min),
1136				max: parseInt(slider_params.max),
1137				range: "min",
1138				value: $("#radius_"+id).val(),
1139				slide: function(event, ui) {
1140					$("#radius_label_"+id).html(ui.value);
1141				},
1142				stop: function(event, ui) {
1143					$("#radius_"+id).val(ui.value);
1144					if (
1145						$("#radius_"+id).val() > 0 &&
1146						$(this).parents("form").find("input[name='address']").length &&
1147						$(this).parents("form").find("input[name='address']").val()
1148					) {
1149						$("#radius_"+id).trigger("change");
1150					}
1151				}
1152			});
1153		});
1154	}
1155
1156	window.w2dc_hint = function () {
1157		$("a.w2dc-hint-icon").each(function() {
1158			$(this).w2dc_popover({
1159				trigger: "hover",
1160				container: $(this).parents(".w2dc-content")
1161			});
1162		});
1163	}
1164	
1165	window.w2dc_favourites = function () {
1166		// Place listings to/from favourites list
1167		if ($(".add_to_favourites").length) {
1168			$('body').on('click', ".add_to_favourites", function() {
1169				var listing_id = $(this).attr("listingid");
1170
1171				if ($.cookie("favourites") != null) {
1172					var favourites_array = $.cookie("favourites").split('*');
1173				} else {
1174					var favourites_array = new Array();
1175				}
1176				if (w2dc_in_array(listing_id, favourites_array) === false) {
1177					favourites_array.push(listing_id);
1178					$(this).find('span.w2dc-glyphicon').removeClass(w2dc_js_objects.not_in_favourites_icon).addClass(w2dc_js_objects.in_favourites_icon);
1179					$(this).find('span.w2dc-bookmark-button').text(w2dc_js_objects.not_in_favourites_msg);
1180				} else {
1181					for (var count=0; count<favourites_array.length; count++) {
1182						if (favourites_array[count] == listing_id) {
1183							delete favourites_array[count];
1184						}
1185					}
1186					$(this).find('span.w2dc-glyphicon').removeClass(w2dc_js_objects.in_favourites_icon).addClass(w2dc_js_objects.not_in_favourites_icon);
1187					$(this).find('span.w2dc-bookmark-button').text(w2dc_js_objects.in_favourites_msg);
1188				}
1189				$.cookie("favourites", favourites_array.join('*'), {expires: 365, path: "/"});
1190				return false;
1191			});
1192		}
1193	}
1194	
1195	window.w2dc_week_day_input = function () {
1196		// Set the same hours for all further selectboxes
1197		$('.w2dc-week-day-input-from-hour, .w2dc-week-day-input-to-hour, .w2dc-week-day-input-from-am-pm, .w2dc-week-day-input-to-am-pm').on('change', function() {
1198			var select_class = $(this).attr('class').replace('w2dc-week-day-input ', '');
1199			var index = $(this).index('.'+select_class);
1200			var val = $(this).val();
1201			
1202			$('.'+select_class).each(function(i, select) {
1203				if ($(this).index('.'+select_class) > index && !$(this).attr('disabled') && $(select).val() == "00:00") {
1204					$(this).val(val);
1205				}
1206			});
1207		});
1208	}
1209	
1210	window.w2dc_check_is_week_day_closed = function () {
1211		$('.closed_cb').each(function() {
1212			_w2dc_check_is_week_day_closed($(this));
1213		});
1214		$('body').on('click', '.closed_cb', function() {
1215			_w2dc_check_is_week_day_closed($(this));
1216		});
1217	}
1218
1219	window._w2dc_check_is_week_day_closed = function (cb) {
1220		if (cb.is(":checked"))
1221			cb.parent().find(".w2dc-week-day-input").attr('disabled', 'disabled');
1222    	else
1223    		cb.parent().find(".w2dc-week-day-input").removeAttr('disabled');
1224	}
1225	
1226	if (!(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))) {
1227		// refresh page on page back button (except safari)
1228		$(window).on('popstate', function() {
1229			
1230		});
1231	}
1232	
1233	window.w2dc_dashboard_tabs = function() {
1234		$('body').on('click', ".w2dc-dashboard-tabs.nav-tabs li", function(e) {
1235			window.location = $(this).find("a").attr("href");
1236		});
1237	}
1238	
1239	window.w2dc_sticky_scroll = function() {
1240		$('.w2dc-sticky-scroll').each(function() {
1241			var element = $(this);
1242			var id = element.data("id");
1243			var toppadding = (element.data("toppadding")) ? element.data("toppadding") : 0;
1244			var height = (element.data("height")) ? element.data("height") : null;
1245			
1246			if (toppadding == 0 && $("body").hasClass("admin-bar")) {
1247				toppadding = 32;
1248			}
1249			
1250			if ($('.site-header.header-fixed').length) {
1251				var headerHeight = $('.site-header.header-fixed').outerHeight();
1252				toppadding = toppadding + headerHeight;
1253			}
1254
1255			if (!$("#w2dc-scroller-anchor-"+id).length) {
1256				var anchor = $("<div>", {
1257					id: 'w2dc-scroller-anchor-'+id
1258				});
1259				element.before(anchor);
1260	
1261				var background = $("<div>", {
1262					id: 'w2dc-sticky-scroll-background-'+id,
1263					style: {position: 'relative'}
1264				});
1265				element.after(background);
1266			}
1267				
1268			window["w2dc_sticky_scroll_toppadding_"+id] = toppadding;
1269	
1270			$("#w2dc-sticky-scroll-background-"+id).position().left = element.position().left;
1271			$("#w2dc-sticky-scroll-background-"+id).position().top = element.position().top;
1272			$("#w2dc-sticky-scroll-background-"+id).width(element.width());
1273			$("#w2dc-sticky-scroll-background-"+id).height(element.height());
1274
1275			var w2dc_scroll_function = function(e) {
1276				var id = e.data.id;
1277				var toppadding = e.data.toppadding;
1278				var b = $(document).scrollTop();
1279				var d = $("#w2dc-scroller-anchor-"+id).offset().top - toppadding;
1280				var c = e.data.obj;
1281				var e = $("#w2dc-sticky-scroll-background-"+id);
1282				
1283				c.width(c.parent().width()).css({ 'z-index': 2 });
1284		
1285				// .w2dc-scroller-bottom - this is special class used to restrict the area of scroll of map canvas
1286				if ($(".w2dc-scroller-bottom").length) {
1287					var f = $(".w2dc-scroller-bottom").offset().top - (c.height() + toppadding);
1288				} else {
1289					var f = $(document).height();
1290				}
1291		
1292				if (f > c.height()) {
1293					if (b >= d && b < f) {
1294						c.css({ position: "fixed", top: toppadding });
1295						e.css({ position: "relative" });
1296					} else {
1297						if (b <= d) {
1298							c.stop().css({ position: "relative", top: "" });
1299							e.css({ position: "absolute" });
1300						}
1301						if (b >= f) {
1302							c.css({ position: "absolute" });
1303							c.stop().offset({ top: f + toppadding });
1304							e.css({ position: "relative" });
1305						}
1306					}
1307				} else {
1308					c.css({ position: "relative", top: "" });
1309					e.css({ position: "absolute" });
1310				}
1311			};
1312			if ($(document).width() >= 768) {
1313				var args = {id: id, obj: $(this), toppadding: toppadding};
1314				$(window).scroll(args, w2dc_scroll_function);
1315				w2dc_scroll_function({data: args});
1316			}
1317
1318			$("#w2dc-sticky-scroll-background-"+id).css({ position: "relative" });
1319		});
1320	}
1321	
1322	window.w2dc_full_height_maps = function() {
1323		$('.w2dc-map-canvas-wrapper').each(function() {
1324			var element = $(this);
1325			var height = (element.data("height")) ? element.data("height") : null;
1326			
1327			if (height == '100%') {
1328				var toppadding = (element.data("toppadding")) ? element.data("toppadding") : 0;
1329				
1330				if (toppadding == 0 && $("body").hasClass("admin-bar")) {
1331					toppadding = 32;
1332				}
1333				
1334				if ($('.site-header.header-fixed').length) {
1335					var headerHeight = $('.site-header.header-fixed').outerHeight();
1336					toppadding = toppadding + headerHeight;
1337				}
1338
1339				element.height(function(index, height) {
1340					return window.innerHeight - toppadding;
1341				});
1342				$(window).on('resize', function() {
1343					element.height(function(index, height) {
1344						return window.innerHeight - toppadding;
1345					});
1346				});
1347			}
1348		});
1349	}
1350	
1351	window.w2dc_tooltips = function() {
1352		$('[data-toggle="w2dc-tooltip"]').w2dc_tooltip({
1353			 trigger : 'hover'
1354		});
1355	}
1356	
1357	window.w2dc_ratings = function() {
1358		$('body').on('click', '.w2dc-rating-active .w2dc-rating-icon', function() {
1359			var rating = $(this).parent(".w2dc-rating-stars");
1360			var rating_wrapper = $(this).parents(".w2dc-rating");
1361			
1362			if (!rating.hasClass('w2dc-rating-active-noajax')) {
1363				rating_wrapper.fadeTo(2000, 0.3);
1364				
1365				$.ajax({
1366		        	url: w2dc_js_objects.ajaxurl,
1367		        	type: "POST",
1368		        	dataType: "json",
1369		            data: {
1370		            	action: 'w2dc_save_rating',
1371		            	rating: $(this).data("rating"),
1372		            	post_id: rating.data("listing"),
1373		            	_wpnonce: rating.data("nonce")
1374		            },
1375		            rating_wrapper: rating_wrapper,
1376		            success: function(response_from_the_action_function){
1377		            	if (response_from_the_action_function != 0 && response_from_the_action_function.html) {
1378		            		this.rating_wrapper
1379		            		.replaceWith(response_from_the_action_function.html)
1380		            		.fadeIn("fast");
1381		            	}
1382		            }
1383		        });
1384			} else {
1385				var rating_value = $(this).data("rating");
1386				rating.find('.w2dc-rating-noajax-value').val(rating_value);
1387				rating.find('.w2dc-rating-icon').each(function() {
1388					$(this).removeClass('w2dc-fa-star w2dc-fa-star-o')
1389					if ($(this).data("rating") <= rating_value) {
1390						$(this).addClass('w2dc-fa-star');
1391					} else {
1392						$(this).addClass('w2dc-fa-star-o');
1393					}
1394				});
1395			}
1396		});
1397	}
1398
1399	window.w2dc_hours_content_field = function() {
1400		function close_option(option) {
1401			if (option.is(":checked")) {
1402				option.parents(".w2dc-week-day-wrap").find("select").attr("disabled", "disabled");
1403			} else {
1404				option.parents(".w2dc-week-day-wrap").find("select").removeAttr("disabled");
1405			}
1406		}
1407		$(".w2dc-closed-day-option").each(function() {
1408			close_option($(this));
1409		});
1410		$("body").on("change", ".w2dc-closed-day-option", function() {
1411			close_option($(this));
1412		});
1413		
1414		$("body").on("click", ".w2dc-clear-hours", function() {
1415			$(this).parents(".w2dc-field-input-block").find("select").each( function() { $(this).val($(this).find("option:first").val()).removeAttr('disabled'); });
1416			$(this).parents(".w2dc-field-input-block").find('input[type="checkbox"]').each( function() { $(this).prop("checked", false); });
1417			return false;
1418		});
1419	}
1420
1421	window.w2dc_custom_input_controls = function() {
1422		// Custom input controls
1423		$(".w2dc-checkbox label, .w2dc-radio label").each(function() {
1424			if (!$(this).find(".w2dc-control-indicator").length) {
1425				$(this).append($("<div>").addClass("w2dc-control-indicator"));
1426			}
1427		});
1428	}
1429	$(document).ajaxComplete(function(event, xhr, settings) {
1430		if (settings.url === w2dc_js_objects.ajaxurl) {
1431			w2dc_custom_input_controls();
1432		}
1433	});
1434
1435	window.w2dc_get_rid_of_select2_choosen = function() {
1436		$("select.w2dc-form-control, select.vp-input, select.w2dc-week-day-input, select.w2dc-tokenizer").each(function (i, obj) {
1437			// get rid of select2
1438			if ($(obj).hasClass('select2-hidden-accessible') || $('#s2id_' + $(obj).attr('id')).length) {
1439				$(obj).select2('destroy');
1440			}
1441			// get rid of chosen
1442			if ($('#' + $(obj).attr('id') + '_chosen').length) {
1443				$(obj).chosen('destroy');
1444			}
1445		});
1446	}
1447
1448	window.w2dc_equalColumnsHeightEvent = function() {
1449		$(window).on('orientationchange resize', w2dc_equalColumnsHeight);
1450	}
1451		
1452	window.w2dc_equalColumnsHeight = function() {
1453		setTimeout(function(){
1454			$(".w2dc-listings-grid .w2dc-listing, .w2dc-mobile-listings-grid-2 .w2dc-listing").css('height', '');
1455
1456			var currentTallest = 0;
1457			var currentRowStart = 0;
1458			var rowDivs = new Array();
1459			var $el;
1460			var topPosition = 0;
1461			$(".w2dc-listings-grid .w2dc-listing, .w2dc-mobile-listings-grid-2 .w2dc-listing").each(function() {
1462				$el = $(this);
1463				if ($(document).width() >= 768 && !$el.hasClass("w2dc-mobile-listings-grid-1")) {
1464					var topPostion = $el.position().top;
1465					if (currentRowStart != topPostion) {
1466						for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
1467							rowDivs[currentDiv].height(currentTallest);
1468						}
1469						rowDivs.length = 0;
1470						currentRowStart = topPostion;
1471						currentTallest = $el.height();
1472						rowDivs.push($el);
1473					} else {
1474						rowDivs.push($el);
1475						currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
1476					}
1477					for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
1478						rowDivs[currentDiv].height(currentTallest);
1479					}
1480				}
1481			});
1482		}, 500);
1483	}
1484	
1485	window.w2dc_isSidebarOpen = function(map_id) {
1486		return ($("#w2dc-map-wrapper-"+map_id).length && $("#w2dc-map-wrapper-"+map_id).hasClass("w2dc-map-sidebar-open"));
1487	}
1488	
1489	$.fn.swipeDetector = function (options) {
1490		// States: 0 - no swipe, 1 - swipe started, 2 - swipe released
1491		var swipeState = 0;
1492		// Coordinates when swipe started
1493		var startX = 0;
1494		var startY = 0;
1495		// Distance of swipe
1496		var pixelOffsetX = 0;
1497		var pixelOffsetY = 0;
1498		// Target element which should detect swipes.
1499		var swipeTarget = this;
1500		var defaultSettings = {
1501				// Amount of pixels, when swipe don't count.
1502				swipeThreshold: 70,
1503				// Flag that indicates that plugin should react only on touch events.
1504				// Not on mouse events too.
1505				useOnlyTouch: false
1506		};
1507
1508		// Initializer
1509		(function init() {
1510			options = $.extend(defaultSettings, options);
1511			// Support touch and mouse as well.
1512			swipeTarget.on('mousedown touchstart', swipeStart);
1513			$('html').on('mouseup touchend', swipeEnd);
1514			$('html').on('mousemove touchmove', swiping);
1515		})();
1516
1517		function swipeStart(event) {
1518			if (options.useOnlyTouch && !event.originalEvent.touches)
1519				return;
1520
1521			if (event.originalEvent.touches)
1522				event = event.originalEvent.touches[0];
1523
1524			if (swipeState === 0) {
1525				swipeState = 1;
1526				startX = event.clientX;
1527				startY = event.clientY;
1528			}
1529		}
1530
1531		function swipeEnd(event) {
1532			if (swipeState === 2) {
1533				swipeState = 0;
1534
1535				if (Math.abs(pixelOffsetX) > Math.abs(pixelOffsetY) &&
1536						Math.abs(pixelOffsetX) > options.swipeThreshold) { // Horizontal Swipe
1537					if (pixelOffsetX < 0) {
1538						swipeTarget.trigger($.Event('swipeLeft.sd'));
1539					} else {
1540						swipeTarget.trigger($.Event('swipeRight.sd'));
1541					}
1542				} else if (Math.abs(pixelOffsetY) > options.swipeThreshold) { // Vertical swipe
1543					if (pixelOffsetY < 0) {
1544						swipeTarget.trigger($.Event('swipeUp.sd'));
1545					} else {
1546						swipeTarget.trigger($.Event('swipeDown.sd'));
1547					}
1548				}
1549			}
1550		}
1551
1552		function swiping(event) {
1553			// If swipe don't occuring, do nothing.
1554			if (swipeState !== 1) 
1555				return;
1556
1557			if (event.originalEvent.touches) {
1558				event = event.originalEvent.touches[0];
1559			}
1560
1561			var swipeOffsetX = event.clientX - startX;
1562			var swipeOffsetY = event.clientY - startY;
1563
1564			if ((Math.abs(swipeOffsetX) > options.swipeThreshold) ||
1565					(Math.abs(swipeOffsetY) > options.swipeThreshold)) {
1566				swipeState = 2;
1567				pixelOffsetX = swipeOffsetX;
1568				pixelOffsetY = swipeOffsetY;
1569			}
1570		}
1571
1572		return swipeTarget; // Return element available for chaining.
1573	}
1574
1575	var w2dc_animation_finished = true;
1576	window.w2dc_listings_carousel = function() {
1577
1578		$(".w2dc-listings-carousel-wrapper").each(function() {
1579			var id = $(this).data("controller-hash");
1580			var currentTallest = 0;
1581			$(this).find("article.w2dc-listing").each(function() {
1582				currentTallest = (currentTallest < $(this).height()) ? ($(this).height()) : (currentTallest);
1583			});
1584			$(this).height(currentTallest);
1585			
1586			var content = $("#w2dc-controller-"+id+" .w2dc-listings-block-content");
1587			var carousel = $("#w2dc-controller-"+id+" .w2dc-listings-carousel");
1588			var button_prev = $("#w2dc-controller-"+id+" .w2dc-listings-carousel-button-left");
1589			var button_next = $("#w2dc-controller-"+id+" .w2dc-listings-carousel-button-right");
1590			var slide_width = content.find("article.w2dc-listing").outerWidth(true);
1591
1592			button_prev.on("click", function() {
1593				w2dc_prev_slide(content, slide_width);
1594			});
1595			
1596			button_next.on("click", function() {
1597				w2dc_next_slide(content, slide_width);
1598			});
1599			
1600			carousel.on("mousewheel", function(event, delta, deltaX, deltaY) {
1601				
1602				event.stopPropagation();
1603				event.preventDefault();
1604				
1605				if (delta > 0) {
1606					w2dc_prev_slide(content, slide_width);
1607				}
1608				if (deltaY < 0) {
1609					w2dc_next_slide(content, slide_width);
1610				}
1611			});
1612				
1613			$("#w2dc-controller-"+id+" .w2dc-listings-carousel")
1614			.swipeDetector({ swipeThreshold: 30 })
1615			.on("swipeRight.sd", function() {
1616				w2dc_prev_slide(content, slide_width);
1617			})
1618			.on("swipeLeft.sd", function() {
1619				w2dc_next_slide(content, slide_width);
1620			});
1621		});
1622	}
1623	window.w2dc_prev_slide = function(content, slide_width) {
1624		if (w2dc_animation_finished) {
1625			var listing = content.find("article.w2dc-listing:last");
1626			content
1627			.css({ "margin-left": -slide_width })
1628			.prepend(listing.clone());
1629			
1630			w2dc_animation_finished = false;
1631			content.animate({
1632				"margin-left": 0
1633			}, 300, function () { 
1634				listing.remove();
1635				w2dc_animation_finished = true;
1636			});
1637		}
1638	}
1639	window.w2dc_next_slide = function(content, slide_width) {
1640		if (w2dc_animation_finished) {
1641			var listing = content.find("article.w2dc-listing:first");
1642			content.append(listing.clone());
1643			
1644			w2dc_animation_finished = false;
1645			content.animate({
1646				"margin-left": -slide_width
1647			}, 300, function () { 
1648				listing.remove();
1649				content.css({ "margin-left": 0 })
1650				w2dc_animation_finished = true;
1651			});
1652		}
1653	}
1654	
1655	// AJAX Comments scripts
1656	window.w2dc_comments_ajax_load_template = function(params, my_global) {
1657        var my_global;
1658        var request_in_process = false;
1659
1660        params.action = "w2dc_comments_load_template";
1661
1662        $.ajax({
1663        	url: w2dc_js_objects.ajaxurl,
1664        	type: "POST",
1665        	dataType: "html",
1666            data: params,
1667            global: my_global,
1668            success: function( msg ){
1669                $(params.target_div).fadeIn().html(msg);
1670                request_in_process = false;
1671                if (typeof params.callback === "function") {
1672                    params.callback();
1673                }
1674            }
1675        });
1676    }
1677    $(document).on('submit', '#w2dc_default_add_comment_form', function(e) {
1678       e.preventDefault();
1679
1680       var $this = $(this);
1681       $this.css('opacity', '0.5');
1682
1683       var data = {
1684           action: "w2dc_comments_add_comment",
1685           post_id: $('#w2dc_comments_ajax_handle').data('post_id'),
1686           user_name: $('#w2dc_comments_user_name').val(),
1687           user_email: $('#w2dc_comments_user_email').val(),
1688           user_url: $('#w2dc_comments_user_url').val(),
1689           comment: $('#comment').val(),
1690           comment_parent: $('#comment_parent').val(),
1691           security: $('#w2dc_comments_nonce').val()
1692       };
1693
1694       $.ajax({
1695        	url: w2dc_js_objects.ajaxurl,
1696        	type: "POST",
1697        	dataType: "html",
1698            data: data,
1699            global: false,
1700            success: function( msg ){
1701                w2dc_comments_ajax_load_template({
1702                    "target_div": "#w2dc_comments_ajax_target",
1703                    "template": $('#w2dc_comments_ajax_handle').attr('data-template'),
1704                    "post_id": $('#w2dc_comments_ajax_handle').attr('data-post_id'),
1705                    "security": $('#w2dc_comments_nonce').val()
1706                }, false );
1707                $('textarea').val('');
1708                $this.css('opacity', '1');
1709            }
1710        });
1711    });
1712    $(document).on('keypress', '#w2dc_default_add_comment_form textarea, #w2dc_default_add_comment_form input', function(e) {
1713        if (e.keyCode == '13') {
1714            e.preventDefault();
1715            $('#w2dc_default_add_comment_form').trigger('submit');
1716        }
1717    });
1718    window.w2dc_load_comments = function() {
1719        if ($('#w2dc_comments_ajax_handle').length) {
1720
1721            var data = {
1722                "action": "w2dc_comments_load_template",
1723                "target_div": "#w2dc_comments_ajax_target",
1724                "template": $('#w2dc_comments_ajax_handle').data('template'),
1725                "post_id": $('#w2dc_comments_ajax_handle').data('post_id'),
1726                "security": $('#w2dc_comments_nonce').val()
1727            };
1728
1729            $.ajax({
1730            	url: w2dc_js_objects.ajaxurl,
1731            	type: "POST",
1732            	dataType: "html",
1733                data: data,
1734                success: function(msg){
1735                    $("#w2dc_comments_ajax_target").fadeIn().html(msg); // Give a smooth fade in effect
1736                    if (window.location.hash && $(window.location.hash).length){
1737                        $('html, body').animate({
1738                            scrollTop: $(window.location.hash).offset().top
1739                        });
1740                        $(window.location.hash).addClass('w2dc-comments-highlight');
1741                    }
1742                }
1743            });
1744
1745            $(document).on('click', '.w2dc-comments-time-handle', function(e) {
1746                $('.w2dc-comments-content').removeClass('w2dc-comments-highlight')
1747                comment_id = '#comment-' + $(this).attr('data-comment_id');
1748                $(comment_id).addClass('w2dc-comments-highlight');
1749            });
1750        }
1751    };
1752    $(document).on('click', '#w2dc_cancel_reply', function(e) {
1753    	$('#comment_parent').val(0);
1754    	$('#w2dc-comments-leave-comment-label').html(w2dc_js_objects.leave_comment);
1755    });
1756    $(document).on('click', '.w2dc-comment-reply', function(e) {
1757    	var comment_id = $(this).data("comment-id");
1758    	var comment_author = $(this).data("comment-author");
1759    	$('#comment_parent').val(comment_id);
1760    	$('#w2dc-comments-leave-comment-label').html(w2dc_js_objects.leave_reply+" "+comment_author+". <a id='w2dc_cancel_reply' href='javascript: void(0);'>"+w2dc_js_objects.cancel_reply+"</a>");
1761    });
1762    $(document).on('click', '.w2dc-comments-more-handle', function(e) {
1763        e.preventDefault();
1764        if ($(this).hasClass('w2dc-comments-more-open')) {
1765            $('a', this).html(w2dc_js_objects.more);
1766            $('#comment').css('height', '0');
1767        } else {
1768            $('a', this).html(w2dc_js_objects.less);
1769            $('#comment').css('height', '150');
1770        }
1771        $(this).toggleClass('w2dc-comments-more-open');
1772        $('.w2dc-comments-more-container').toggle();
1773    });
1774    
1775    window.w2dc_content_fields_metabox = function() {
1776    	hideShowFields_init();
1777    	
1778		$("input[name='tax_input\\[w2dc-category\\]\\[\\]']").change(function() { hideShowFields_onclick($(this)) });
1779		$("#w2dc-category-pop input[type=checkbox]").change(function() { hideShowFields_onclick($(this)) });
1780
1781		function hideShowFields_init() {
1782			var selected_categories_ids = [];
1783			$.each($("input[name='tax_input\\[w2dc-category\\]\\[\\]']:checked"), function() {
1784				selected_categories_ids.push($(this).val());
1785			});
1786
1787			$(".w2dc-content-fields-metabox").show();
1788			$(".w2dc-field-input-block").hide();
1789			$.each(w2dc_js_objects.fields_in_categories, function(index, value) {
1790				var show_field = false;
1791				if (value != undefined) {
1792					if (value.length > 0) {
1793						var key;
1794						for (key in value) {
1795							var key2;
1796							for (key2 in selected_categories_ids) {
1797								if (value[key] == selected_categories_ids[key2]) {
1798									show_field = true;
1799								}
1800							}
1801						}
1802					}
1803
1804					if ((value.length == 0 || show_field) && $(".w2dc-field-input-block-"+index).length) {
1805						$(".w2dc-field-input-block-"+index).show();
1806					}
1807				}
1808			});
1809			$.each($(".w2dc-content-fields-metabox"), function() {
1810				if ($(this).find(".w2dc-field-input-block").filter(function() { return $(this).css("display") != "none"; }).length) {
1811					$(this).show();
1812				} else {
1813					$(this).hide();
1814				}
1815			});
1816		}
1817		
1818		function hideShowFields_onclick(input) {
1819			var checked = input.prop('checked');
1820			var id = input.val();
1821			
1822			var fields_to_apply = [];
1823			$.each(w2dc_js_objects.fields_in_categories, function(index, value) {
1824				if (value != undefined) {
1825					if (value.length > 0) {
1826						var key;
1827						for (key in value) {
1828							if (value[key] == id) {
1829								fields_to_apply.push(index);
1830							}
1831						}
1832					}
1833				}
1834			});
1835			
1836			for (var key in fields_to_apply) {
1837				var index = fields_to_apply[key];
1838				if (checked) {
1839					$(".w2dc-field-input-block-"+index).parents(".w2dc-content-fields-metabox").slideDown(500);
1840					$(".w2dc-field-input-block-"+index).slideDown(500);
1841				} else {
1842					$(".w2dc-field-input-block-"+index).slideUp(300, function() {
1843						var metabox = $(this).parents(".w2dc-content-fields-metabox");
1844						if (!metabox.find(".w2dc-field-input-block:visible").length) {
1845							metabox.slideUp(500);
1846						}
1847					});
1848				}
1849			}
1850		}
1851    };
1852	
1853	window.w2dc_scroll_to_anchor = function(scroll_to_anchor, offest_top) {
1854		if (typeof scroll_to_anchor != 'undefined' && scroll_to_anchor) {
1855			if (typeof offest_top == 'undefined' || !offest_top) {
1856				var offest_top = 0;
1857			}
1858			$('html,body').animate({scrollTop: scroll_to_anchor.offset().top - offest_top}, 'slow');
1859		}
1860	}
1861	
1862	window.w2dc_ajax_loader_target_show = function(target, scroll_to_anchor, offest_top) {
1863		if (typeof scroll_to_anchor != 'undefined' && scroll_to_anchor) {
1864			if (typeof offest_top == 'undefined' || !offest_top) {
1865				var offest_top = 0;
1866			}
1867			$('html,body').animate({scrollTop: scroll_to_anchor.offset().top - offest_top}, 'slow');
1868		}
1869		var id = target.attr("id");
1870		if (!$("[data-loader-id='"+id+"']").length) {
1871			var loader = $('<div data-loader-id="'+id+'" class="w2dc-ajax-target-loading"><div class="w2dc-loader"></div></div>');
1872			target.prepend(loader);
1873			loader.css({
1874				width: target.outerWidth()+10,
1875				height: target.outerHeight()+10
1876			});
1877			if (target.outerHeight() > 600) {
1878				loader.find(".w2dc-loader").addClass("w2dc-loader-max-top");
1879			}
1880		}
1881	}
1882	window.w2dc_ajax_loader_target_hide = function(id) {
1883		$("[data-loader-id='"+id+"']").remove();
1884	}
1885	
1886	window.w2dc_ajax_loader_show = function(msg) {
1887		var overlay = $('<div id="w2dc-ajax-loader-overlay"><div class="w2dc-loader"></div></div>');
1888	    $('body').append(overlay);
1889	}
1890	
1891	window.w2dc_ajax_loader_hide = function() {
1892		$("#w2dc-ajax-loader-overlay").remove();
1893	}
1894
1895	window.w2dc_get_controller_args_array = function(hash) {
1896		if (typeof w2dc_controller_args_array != 'undefined' && Object.keys(w2dc_controller_args_array)) {
1897			for (var controller_hash in w2dc_controller_args_array) {
1898				if (controller_hash == hash) {
1899					return w2dc_controller_args_array[controller_hash];
1900				}
1901			}
1902		}
1903	}
1904
1905	window.w2dc_get_map_markers_attrs_array = function(hash) {
1906		if (typeof w2dc_map_markers_attrs_array != 'undefined' && Object.keys(w2dc_map_markers_attrs_array)) {
1907			for (var i=0; i<w2dc_map_markers_attrs_array.length; i++) {
1908				if (hash == w2dc_map_markers_attrs_array[i].map_id) {
1909					return w2dc_map_markers_attrs_array[i];
1910				}
1911			}
1912		}
1913	}
1914
1915	window.w2dc_get_original_map_markers_attrs_array = function(hash) {
1916		if (typeof _w2dc_map_markers_attrs_array != 'undefined' && Object.keys(_w2dc_map_markers_attrs_array)) {
1917			for (var i=0; i<_w2dc_map_markers_attrs_array.length; i++) {
1918				if (hash == _w2dc_map_markers_attrs_array[i].map_id) {
1919					return _w2dc_map_markers_attrs_array[i];
1920				}
1921			}
1922		}
1923	}
1924	
1925	window.w2dc_map_sidebar_scrollto = function(map_id, location_id) {
1926		if ($('#w2dc-map-listings-panel-'+map_id).length) {
1927			
1928			if ($('#w2dc-map-sidebar-'+map_id).hasClass('w2dc-map-sidebar-fixed')) {
1929				var sidebar_listings = $('#w2dc-map-sidebar-listings-wrapper-'+map_id);
1930			} else {
1931				var sidebar_listings = $('#w2dc-map-sidebar-'+map_id);
1932			}
1933			
1934			if (sidebar_listings.find('#post-'+location_id).length) {
1935				sidebar_listings.scrollTop(
1936						sidebar_listings.scrollTop()
1937						+
1938						sidebar_listings.find('#post-'+location_id).offset().top
1939						-
1940						sidebar_listings.offset().top
1941				);
1942			}
1943		}
1944	}
1945	
1946	window.w2dc_process_listings_ajax_response = function(response_from_the_action_function, do_replace, remove_shapes, do_replace_markers) {
1947		var response_hash = response_from_the_action_function.hash;
1948		if (response_from_the_action_function) {
1949			var listings_block = $('#w2dc-controller-'+response_hash);
1950			if (do_replace) {
1951				listings_block.replaceWith(response_from_the_action_function.html);
1952			} else {
1953				listings_block.find(".w2dc-listings-block-content").append(response_from_the_action_function.html);
1954			}
1955			
1956			w2dc_listings_carousel();
1957			
1958			if (response_from_the_action_function.map_markers && typeof w2dc_maps[response_hash] != 'undefined') {
1959				if (do_replace) {
1960					w2dc_clearMarkers(response_hash);
1961				}
1962				if (remove_shapes) {
1963					w2dc_removeShapes(response_hash);
1964					w2dc_removeCircles(response_hash);
1965				}
1966				w2dc_closeInfoWindow(response_hash);
1967				
1968				var markers_array = response_from_the_action_function.map_markers;
1969				
1970				var enable_radius_circle = 0;
1971				var enable_clusters = 0;
1972				var show_summary_button = 1;
1973				var show_readmore_button = 1;
1974				var is_ajax_markers = 0;
1975				var attrs_array;
1976				if (attrs_array = w2dc_get_map_markers_attrs_array(response_hash)) {
1977					var enable_radius_circle = attrs_array.enable_radius_circle;
1978					var enable_clusters = attrs_array.enable_clusters;
1979					var show_summary_button = attrs_array.show_summary_button;
1980					var show_readmore_button = attrs_array.show_readmore_button;
1981					var map_attrs = attrs_array.map_attrs;
1982					var is_ajax_markers = attrs_array.map_attrs.ajax_markers_loading;
1983
1984					if (do_replace_markers) {
1985						attrs_array.markers_array = eval(response_from_the_action_function.map_markers);
1986					}
1987				}
1988				
1989				var map_id = response_hash;
1990				var existing_locations = [];
1991				if (typeof w2dc_global_locations_array[map_id] != 'undefined') {
1992					for (var i=0; i<w2dc_global_locations_array[map_id].length; i++) {
1993						if (typeof w2dc_global_locations_array[map_id][i] == 'object') {
1994							existing_locations.push(w2dc_global_locations_array[map_id][i].id);
1995						}
1996					}
1997				}
1998
1999		    	for (var j=0; j<markers_array.length; j++) {
2000		    		if (!existing_locations.includes(markers_array[j][0])) {
2001		    			var map_coords_1 = markers_array[j][1];
2002				    	var map_coords_2 = markers_array[j][2];
2003				    	if ($.isNumeric(map_coords_1) && $.isNumeric(map_coords_2)) {
2004			    			var point = w2dc_buildPoint(map_coords_1, map_coords_2);
2005	
2006			    			var location_obj = new w2dc_glocation(markers_array[j][0], point, 
2007			    				markers_array[j][3],
2008			    				markers_array[j][4],
2009			    				markers_array[j][6],
2010			    				markers_array[j][7],
2011			    				markers_array[j][8],
2012			    				markers_array[j][9],
2013			    				markers_array[j][10],
2014			    				markers_array[j][11],
2015			    				show_summary_button,
2016			    				show_readmore_button,
2017			    				response_hash,
2018			    				is_ajax_markers
2019				    		);
2020				    		var marker = location_obj.w2dc_placeMarker(response_hash);
2021				    		w2dc_global_locations_array[response_hash].push(location_obj);
2022				    	}
2023		    		}
2024	    		}
2025		    	
2026		    	// fit bounds only when no AJAX map
2027		    	if (typeof attrs_array.map_attrs.ajax_map_loading == 'undefined' || attrs_array.map_attrs.ajax_map_loading == 0) {
2028		    		if (w2dc_global_markers_array[response_hash].length) {
2029			    		var bounds = w2dc_buildBounds();
2030			    		for (var j=0; j<w2dc_global_markers_array[response_hash].length; j++) {
2031			    			var marker = w2dc_global_markers_array[response_hash][j];
2032			    			var marker_position = w2dc_getMarkerPosition(marker);
2033			    			w2dc_extendBounds(bounds, marker_position);
2034			    		}
2035			    		w2dc_mapFitBounds(response_hash, bounds);
2036	
2037			    		if (w2dc_global_markers_array[response_hash].length == 1) {
2038			    			w2dc_setMapZoom(response_hash, ZOOM_FOR_SINGLE_MARKER);
2039			    		}
2040		    		}
2041		    	}
2042
2043	    		w2dc_setClusters(enable_clusters, response_hash, w2dc_global_markers_array[response_hash]);
2044
2045	    		w2dc_removeCircles(response_hash);
2046			    if (enable_radius_circle && typeof response_from_the_action_function.radius_params != 'undefined') {
2047			    	var radius_params = response_from_the_action_function.radius_params;
2048			    	
2049			    	// PanTo only on AJAX Map
2050			    	if (w2dc_hasChangedGeocodedCoordinates(radius_params, response_hash)) {
2051						var map_coords_1 = radius_params.map_coords_1;
2052						var map_coords_2 = radius_params.map_coords_2;
2053						
2054						w2dc_panTo(response_hash, map_coords_1, map_coords_2);
2055					}
2056					
2057					w2dc_saveGeocodedCoordinates(radius_params, response_hash);
2058			    	
2059					w2dc_drawRadius(radius_params, response_hash);
2060				}
2061			}
2062			if (typeof response_from_the_action_function.map_listings != 'undefined' && typeof w2dc_maps[response_hash] != 'undefined') {
2063				var map_listings_block = $('#w2dc-map-listings-panel-'+response_hash);
2064		    	if (map_listings_block.length) {
2065		    		if (do_replace) {
2066		    			map_listings_block.html(response_from_the_action_function.map_listings);
2067		    		} else {
2068		    			map_listings_block.append(response_from_the_action_function.map_listings);
2069		    		}
2070		    	}
2071			}
2072		}
2073		w2dc_equalColumnsHeight();
2074		if (w2dc_js_objects.is_maps_used) {
2075			w2dc_show_on_map_links();
2076		}
2077		w2dc_sticky_scroll();
2078	}
2079
2080	window.w2dc_load_ajax_initial_elements = function() {
2081		// We have to wait while Google Maps API will be completely loaded
2082		if (typeof w2dc_controller_args_array != 'undefined' && Object.keys(w2dc_controller_args_array)) {
2083			for (var controller_hash in w2dc_controller_args_array) {
2084				
2085				var post_params = { hash: controller_hash, from_ajax_map: 1 };
2086				post_params = w2dc_collectAJAXParams(post_params);
2087				post_params.ajax_action = 'ajax_initial_load';
2088				
2089				// ajax_map_loading=1 means that a map follows listings controller
2090				if (
2091						!(typeof post_params.ajax_map_loading != 'undefined' && post_params.ajax_map_loading == 1) &&
2092						(typeof post_params.ajax_initial_load != 'undefined' && post_params.ajax_initial_load == 1)
2093				) {
2094					post_params.ajax_initial_load = 0;
2095	
2096					$.post(
2097						w2dc_js_objects.ajaxurl,
2098						post_params,
2099						function(response_from_the_action_function) {
2100							w2dc_process_listings_ajax_response(response_from_the_action_function, true, true, true);
2101							
2102							var response_hash = response_from_the_action_function.hash;
2103							if (response_from_the_action_function.map_markers && typeof w2dc_maps[response_hash] != 'undefined') {
2104								if (typeof _w2dc_map_markers_attrs_array != 'undefined' && _w2dc_map_markers_attrs_array.length) {
2105									for (var i=0; i<_w2dc_map_markers_attrs_array.length; i++) {
2106										if (response_hash == _w2dc_map_markers_attrs_array[i].map_id) {
2107											_w2dc_map_markers_attrs_array[i].markers_array = eval(response_from_the_action_function.map_markers);
2108										}
2109									}
2110								}
2111							}
2112						},
2113						'json'
2114					);
2115				}
2116			}
2117		}
2118	}
2119	
2120	window.w2dc_ajax_iloader = $("<div>", { class: 'w2dc-ajax-iloader' }).html('<div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div>');
2121	window.w2dc_add_iloader_on_element = function(button) {
2122		button
2123		.attr('disabled', 'disabled')
2124		.wrapInner('<div class="w2dc-hidden"></div>')
2125		.append(w2dc_ajax_iloader);
2126	}
2127	window.w2dc_delete_iloader_from_element = function(button) {
2128		button.find(".w2dc-hidden").contents().unwrap();
2129		button.removeAttr('disabled').find(".w2dc-ajax-iloader").remove();
2130	}
2131	
2132	var w2dc_show_more_button_processing = false;
2133	$(window).scroll(function() {
2134		$('.w2dc-show-more-button.w2dc-scrolling-paginator:visible').each(function() {
2135			if ($(window).scrollTop() + $(window).height() > $(this).position().top) {
2136				if (!w2dc_show_more_button_processing) {
2137					w2dc_callShowMoreListings($(this));
2138				}
2139			}
2140		});
2141	});
2142	$('body').on('click', '.w2dc-show-more-button', function(e) {
2143		e.preventDefault();
2144		w2dc_callShowMoreListings($(this));
2145	});
2146	var w2dc_callShowMoreListings = function(button) {
2147		
2148		if (button.data("controller-hash")) {
2149			
2150			w2dc_add_iloader_on_element(button);
2151			
2152			var controller_hash = button.data("controller-hash");
2153			var post_params = w2dc_collectAJAXParams({ hash: controller_hash });
2154			post_params.ajax_action = 'show_more';
2155			
2156			if (typeof post_params.paged != 'undefined') {
2157				var paged = parseInt(post_params.paged)+1;
2158			} else {
2159				var paged = 2;
2160			}
2161			post_params.paged = paged;
2162			post_params.page = paged;
2163			post_params.do_append = 1;
2164			
2165			w2dc_show_more_button_processing = true;
2166			$.post(
2167				w2dc_js_objects.ajaxurl,
2168				post_params,
2169				w2dc_completeAJAXShowMore(button),
2170				'json'
2171			);
2172		}
2173	}
2174	var w2dc_completeAJAXShowMore = function(button) {
2175		return function(response_from_the_action_function) {
2176			var controller_hash = response_from_the_action_function.hash;
2177			
2178			w2dc_process_listings_ajax_response(response_from_the_action_function, false, false, false);
2179			
2180			if (typeof w2dc_controller_args_array[controller_hash].paged != 'undefined') {
2181				var paged = parseInt(w2dc_controller_args_array[controller_hash].paged)+1;
2182			} else {
2183				var paged = 2;
2184			}
2185			w2dc_controller_args_array[controller_hash].paged = paged;
2186			
2187			w2dc_show_more_button_processing = false;
2188			w2dc_delete_iloader_from_element(button);
2189			if (response_from_the_action_function.hide_show_more_listings_button) {
2190				button.hide();
2191			}
2192		}
2193	}
2194	
2195	window.w2dc_collectAJAXParams = function(post_params) {
2196		
2197		post_params.action = "w2dc_controller_request";
2198		
2199		var controller_hash = false;
2200		if (post_params.hash) {
2201			controller_hash = post_params.hash;
2202		} else {
2203			if ($(".w2dc-controller").length) {
2204				post_params.hash = $(".w2dc-controller").data("controller-hash");
2205				controller_hash = post_params.hash;
2206			} else {
2207				return post_params;
2208			}
2209		}
2210		
2211		w2dc_checkGeocodedCoordinates(controller_hash);
2212		
2213		// collect needed params from map FIRST OF ALL, then from listings, listings params can overwrite map's params
2214		var map_args_array;
2215		if (map_args_array = w2dc_get_map_markers_attrs_array(controller_hash)) {
2216			
2217			post_params = $.extend({}, post_params, map_args_array);
2218			post_params = $.extend({}, post_params, map_args_array.map_attrs);
2219			
2220			delete post_params.markers_array;
2221			delete post_params.map_attrs;
2222			
2223			post_params.with_map = 1;
2224			
2225			if (typeof map_args_array.map_attrs.ajax_map_loading != 'undefined' && map_args_array.map_attrs.ajax_map_loading == 1) {
2226				if (typeof post_params.from_ajax_map == 'undefined' || post_params.from_ajax_map == 0) {
2227					w2dc_setAjaxMarkers(w2dc_maps[controller_hash], controller_hash);
2228				}
2229			}
2230			
2231			if ($("#w2dc-map-listings-panel-"+controller_hash).length) {
2232				post_params.map_listings = 1;
2233			}
2234		}
2235		
2236		if ($("#w2dc-controller-"+controller_hash).length) {
2237			// collect needed params from listing block
2238			var listings_args_array;
2239			if (listings_args_array = w2dc_get_controller_args_array(controller_hash)) {
2240				post_params = $.extend({}, post_params, listings_args_array);
2241				
2242				var existing_listings = "";
2243				$("#w2dc-controller-"+controller_hash+" .w2dc-listings-block-content article[id^='post-']").each(function(index) {
2244					existing_listings = $(this).attr("id").replace("post-", "") + "," + existing_listings;
2245				});
2246				post_params.existing_listings = existing_listings;
2247			}
2248		} else {
2249			post_params.without_listings = 1;
2250		}
2251		
2252		// query string from wcsearch
2253		if (typeof wcsearch_query_string != "undefined") {
2254			post_params.query_string = wcsearch_query_string;
2255		}
2256		
2257		return post_params;
2258	}
2259	
2260	window.w2dc_callAJAXSearch = function(post_params) {
2261		post_params.from_ajax_map = 1;
2262		post_params = w2dc_collectAJAXParams(post_params);
2263		post_params.ajax_action = 'search';
2264		
2265		// set to first page after collection
2266		post_params.paged = 1;
2267		
2268		w2dc_startAJAXSearch(post_params);
2269	}
2270	
2271	window.w2dc_sendGeoPolyAJAX = function(map_id, geo_poly_ajax) {
2272		
2273		var post_params = { hash: map_id };
2274		post_params = w2dc_collectAJAXParams(post_params);
2275		post_params.geo_poly = geo_poly_ajax;
2276		// set to first page after collection
2277		post_params.paged = 1;
2278		post_params.ajax_action = 'geo_poly';
2279		
2280		$.post(
2281				w2dc_js_objects.ajaxurl,
2282				post_params,
2283				function(response_from_the_action_function) {
2284					w2dc_process_listings_ajax_response(response_from_the_action_function, true, false, false);
2285				},
2286				'json'
2287			);
2288	}
2289		
2290	var w2dc_search_requests_counter = 0;
2291	var w2dc_startAJAXSearch = function(post_params) {
2292		w2dc_search_requests_counter++;
2293		$.post(
2294				w2dc_js_objects.ajaxurl,
2295				post_params,
2296				w2dc_completeAJAXSearch(post_params),
2297				'json'
2298		);
2299	}
2300	
2301	var wcsearch_recount_attempts = 0;
2302	var wcsearch_max_counters = 200;
2303	var w2dc_completeAJAXSearch = function(post_params) {
2304		return function(response_from_the_action_function) {
2305			w2dc_search_requests_counter--;
2306			if (w2dc_search_requests_counter == 0) {
2307				
2308				if (typeof post_params.geo_poly != 'undefined' && post_params.geo_poly) {
2309					var remove_shapes = false;
2310				} else {
2311					var remove_shapes = true;
2312				}
2313				
2314				w2dc_process_listings_ajax_response(response_from_the_action_function, true, remove_shapes, true);
2315				
2316				var wcsearch_request_processing = false;
2317				
2318				// paginator clicked - do not need to recount
2319				var page = wcsearch_get_query_string_param('page');
2320				if (!page) {
2321					wcsearch_recount_attempts = 0;
2322					wcsearch_recount();
2323				}
2324			}
2325		}
2326	}
2327	
2328	if (w2dc_js_objects.ajax_load) {
2329
2330		$('body').on('click', '.w2dc-listings-orderby-link', function(e) {
2331			e.preventDefault();
2332			
2333			var href = $(this).attr('href');
2334			window.history.pushState("", "", href);
2335			
2336			var controller_hash = $(this).data('controller-hash');
2337			var order_by = $(this).data('orderby');
2338			var order = $(this).data('order');
2339			
2340			wcsearch_extend_query_string_params({ 'order_by': order_by, 'order': order });
2341			
2342			var post_params = w2dc_collectAJAXParams({ hash: controller_hash });
2343			post_params.order_by = order_by;
2344			post_params.order = order;
2345			post_params.paged = 1;
2346			post_params.ajax_action = 'order';
2347			
2348			$.post(
2349					w2dc_js_objects.ajaxurl,
2350					post_params,
2351					function(response_from_the_action_function) {
2352						w2dc_process_listings_ajax_response(response_from_the_action_function, true, false, true);
2353					},
2354					'json'
2355			);
2356		});
2357
2358		$('body').on('click', '.w2dc-pagination li.w2dc-active a', function(e) {
2359			e.preventDefault();
2360		});
2361		$('body').on('click', '.w2dc-listings-block .w2dc-pagination li a', function(e) {
2362			if ($(this).data('controller-hash')) {
2363				e.preventDefault();
2364				
2365				var href = $(this).attr('href');
2366				window.history.pushState("", "", href);
2367				
2368				var controller_hash = $(this).data('controller-hash');
2369				
2370				var anchor = $('#w2dc-controller-'+controller_hash);
2371				if (typeof window["w2dc_sticky_scroll_toppadding_"+controller_hash] != 'undefined') {
2372					var sticky_scroll_toppadding = window["w2dc_sticky_scroll_toppadding_"+controller_hash];
2373				} else {
2374					var sticky_scroll_toppadding = 0;
2375				}
2376				w2dc_scroll_to_anchor(anchor, sticky_scroll_toppadding);
2377				
2378				var post_params = w2dc_collectAJAXParams({ hash: controller_hash });
2379				post_params.paged = $(this).data('page');
2380				post_params.ajax_action = 'paginator';
2381				
2382				$.post(
2383						w2dc_js_objects.ajaxurl,
2384						post_params,
2385						function(response_from_the_action_function) {
2386							w2dc_process_listings_ajax_response(response_from_the_action_function, true, false, true);
2387						},
2388						'json'
2389				);
2390			}
2391		});
2392	}
2393	
2394	$('body').on('click', '.w2dc-map-search-toggle, .w2dc-map-sidebar-toggle-container, .w2dc-map-sidebar-toggle-container-mobile', function(e) {
2395		e.preventDefault();
2396		var id = $(this).data('id');
2397		
2398		if ($("#w2dc-map-wrapper-"+id).hasClass("w2dc-map-sidebar-open")) {
2399			w2dc_close_listings_sidebar(id);
2400		} else {
2401			w2dc_open_listings_sidebar(id);
2402		}
2403	});
2404	$('body').on('click', '.w2dc-map-directions-sidebar-close-button', function(e) {
2405		e.preventDefault();
2406		var id = $(this).data('id');
2407		
2408		w2dc_open_listings_sidebar(id);
2409	});
2410	
2411	window.w2dc_open_listings_sidebar = function(map_id) {
2412		$("#w2dc-map-wrapper-"+map_id).addClass("w2dc-map-sidebar-open");
2413		
2414		$("body").on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
2415			w2dc_callMapResize(map_id);
2416		});
2417	}
2418	window.w2dc_close_listings_sidebar = function(map_id) {
2419		$("#w2dc-map-wrapper-"+map_id).removeClass("w2dc-map-sidebar-open");
2420		
2421		$("body").on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
2422			w2dc_callMapResize(map_id);
2423		});
2424	}
2425	
2426	window.w2dc_hasChangedGeocodedCoordinates = function(radius_params, map_id) {
2427		var map_coords_1 = radius_params.map_coords_1;
2428		var map_coords_2 = radius_params.map_coords_2;
2429		
2430		if ($.isNumeric(map_coords_1) && $.isNumeric(map_coords_2)) {
2431			if (typeof w2dc_map_markers_attrs_array != 'undefined' && Object.keys(w2dc_map_markers_attrs_array)) {
2432				for (var i=0; i<w2dc_map_markers_attrs_array.length; i++) {
2433					if (w2dc_map_markers_attrs_array[i].map_id == map_id) {
2434						if (typeof w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params != 'undefined') {
2435							if (
2436									w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_1 == map_coords_1 &&
2437									w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_2 == map_coords_2
2438							) {
2439								return false;
2440							}
2441						}
2442					}
2443				}
2444			}
2445		}
2446		
2447		return true;
2448	}
2449	window.w2dc_saveGeocodedCoordinates = function(radius_params, map_id) {
2450		var map_coords_1 = radius_params.map_coords_1;
2451		var map_coords_2 = radius_params.map_coords_2;
2452		
2453		if ($.isNumeric(map_coords_1) && $.isNumeric(map_coords_2) && wcsearch_get_query_string_param('address')) {
2454			if (typeof w2dc_map_markers_attrs_array != 'undefined' && Object.keys(w2dc_map_markers_attrs_array)) {
2455				for (var i=0; i<w2dc_map_markers_attrs_array.length; i++) {
2456					if (w2dc_map_markers_attrs_array[i].map_id == map_id) {
2457						w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params = {};
2458						w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_1 = map_coords_1;
2459						w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_2 = map_coords_2;
2460						w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.address = wcsearch_get_query_string_param('address');
2461					}
2462				}
2463			}
2464		}
2465	}
2466	window.w2dc_checkGeocodedCoordinates = function(map_id) {
2467		
2468		if (typeof w2dc_map_markers_attrs_array != 'undefined' && Object.keys(w2dc_map_markers_attrs_array)) {
2469			for (var i=0; i<w2dc_map_markers_attrs_array.length; i++) {
2470				if (map_id == w2dc_map_markers_attrs_array[i].map_id) {
2471					if (typeof w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params != 'undefined') {
2472						var address_string = wcsearch_get_query_string_param('address');
2473						
2474						if (w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.address != address_string) {
2475							delete w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.address;
2476							delete w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_1;
2477							delete w2dc_map_markers_attrs_array[i].map_attrs.geocoded_params.map_coords_2;
2478						}
2479					}
2480				}
2481			}
2482		}
2483	}
2484
2485	$('body').on('click', '.w2dc-list-view-btn', function() {
2486		var button = $(this);
2487		var hash = button.data('shortcode-hash');
2488		var listings_block = $('#w2dc-controller-'+hash).find('.w2dc-listings-block');
2489		if (listings_block.hasClass('w2dc-listings-grid')) {
2490			listings_block.find('.w2dc-listings-block-content').fadeTo("fast", 0, function() {
2491				button.removeClass('w2dc-btn-default').addClass('w2dc-btn-primary');
2492				button.parents('.w2dc-views-links').find('.w2dc-grid-view-btn').removeClass('w2dc-btn-primary').addClass('w2dc-btn-default');
2493				listings_block.removeClass('w2dc-listings-grid w2dc-listings-grid-1 w2dc-listings-grid-2 w2dc-listings-grid-3 w2dc-listings-grid-4');
2494				listings_block.addClass('w2dc-listings-list-view');
2495				listings_block.find('article.w2dc-listing').each(function() {
2496					$(this).css('height', 'auto');
2497				});
2498				$.cookie("w2dc_listings_view_"+hash, 'list', {expires: 365, path: "/"});
2499			});
2500			listings_block.find('.w2dc-listings-block-content').fadeTo("fast", 1);
2501		}
2502	});
2503	$('body').on('click', '.w2dc-grid-view-btn', function() {
2504		var button = $(this);
2505		var hash = button.data('shortcode-hash');
2506		var listings_block = $('#w2dc-controller-'+hash).find('.w2dc-listings-block');
2507		if (!listings_block.hasClass('w2dc-listings-grid')) {
2508			listings_block.find('.w2dc-listings-block-content').fadeTo("fast", 0, function() {
2509				button.removeClass('w2dc-btn-default').addClass('w2dc-btn-primary');
2510				button.parents('.w2dc-views-links').find('.w2dc-list-view-btn').removeClass('w2dc-btn-primary').addClass('w2dc-btn-default');
2511				listings_block.removeClass('w2dc-listings-list-view');
2512				listings_block.addClass('w2dc-listings-grid').addClass('w2dc-listings-grid-'+button.data('grid-columns'));
2513				w2dc_equalColumnsHeight();
2514				$.cookie("w2dc_listings_view_"+hash, 'grid', {expires: 365, path: "/"});
2515			});
2516			listings_block.find('.w2dc-listings-block-content').fadeTo("fast", 1);
2517		}
2518	});
2519	
2520	$('body').on('click', ".w2dc-remove-from-favourites-list", function() {
2521		var listing_id = $(this).attr("listingid");
2522		
2523		if ($.cookie("favourites") != null) {
2524			var favourites_array = $.cookie("favourites").split('*');
2525		} else {
2526			var favourites_array = new Array();
2527		}
2528
2529		for (var count=0; count<favourites_array.length; count++) {
2530			if (favourites_array[count] == listing_id) {
2531				delete favourites_array[count];
2532			}
2533		}
2534
2535		$(".w2dc-listing#post-"+listing_id).remove();
2536		
2537		$.cookie("favourites", favourites_array.join('*'), {expires: 365, path: "/"});
2538		return false;
2539	});
2540	
2541	// Select FA icon dialog
2542	$(document).on("click", ".w2dc-select-fa-icon", function() {
2543		var dialog_title = $(this).text();
2544		var icon_image_name = $(this).data("icon-image-name");
2545		var icon_image_name_obj = $("#"+icon_image_name);
2546		var icon_tag = $(this).data("icon-tag");
2547		var icon_tag_obj = $("."+icon_tag);
2548		
2549		var icon_click_event;
2550		var reset_icon_click_event;
2551		
2552		var dialog_obj = $('<div id="w2dc-select-fa-icon-dialog"></div>');
2553		dialog_obj.dialog({
2554			dialogClass: 'w2dc-content',
2555			width: ($(window).width()*0.5),
2556			height: ($(window).height()*0.8),
2557			modal: true,
2558			resizable: false,
2559			draggable: false,
2560			title: dialog_title,
2561			open: function() {
2562				w2dc_ajax_loader_show();
2563				$.ajax({
2564					type: "POST",
2565					url: w2dc_js_objects.ajaxurl,
2566					data: {'action': 'w2dc_select_fa_icon'},
2567					dataType: 'html',
2568					success: function(response_from_the_action_function){
2569						if (response_from_the_action_function != 0) {
2570							dialog_obj.html(response_from_the_action_function);
2571							if (icon_image_name_obj.val()) {
2572								$("#"+icon_image_name_obj.val()).addClass("w2dc-selected-icon");
2573							}
2574
2575							icon_click_event = $(document).one("click", ".w2dc-fa-icon", function() {
2576								$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
2577								icon_image_name_obj.val($(this).attr('id'));
2578								icon_tag_obj.removeClass().addClass(icon_tag+' w2dc-icon-tag w2dc-fa '+icon_image_name_obj.val());
2579								icon_tag_obj.show();
2580								$(this).addClass("w2dc-selected-icon");
2581								reset_icon_click_event.off("click", "#w2dc-reset-fa-icon");
2582								dialog_obj.remove();
2583							});
2584							reset_icon_click_event = $(document).one("click", "#w2dc-reset-fa-icon", function() {
2585								$(".w2dc-selected-icon").removeClass("w2dc-selected-icon");
2586								icon_tag_obj.removeClass().addClass(icon_tag+' w2dc-icon-tag');
2587								icon_tag_obj.hide();
2588								icon_image_name_obj.val('');
2589								icon_click_event.off("click", ".w2dc-fa-icon");
2590								dialog_obj.remove();
2591							});
2592						}
2593					},
2594					complete: function() {
2595						w2dc_ajax_loader_hide();
2596					}
2597				});
2598				$(document).on("click", ".ui-widget-overlay", function() {
2599					icon_click_event.off("click", ".w2dc-fa-icon");
2600					reset_icon_click_event.off("click", "#w2dc-reset-fa-icon");
2601					dialog_obj.remove();
2602				});
2603			},
2604			close: function() {
2605				icon_click_event.off("click", ".w2dc-fa-icon");
2606				reset_icon_click_event.off("click", "#w2dc-reset-fa-icon");
2607				dialog_obj.remove();
2608			}
2609		});
2610	});
2611	
2612	// AJAX Contact form
2613	$(document).on('submit', '#w2dc_contact_form, #w2dc_report_form', function(e) {
2614		e.preventDefault();
2615
2616		var $this = $(this);
2617		
2618		if ($this.attr('id') == 'w2dc_contact_form') {
2619			var type = 'contact';
2620		} else if ($this.attr('id') == 'w2dc_report_form') {
2621			var type = 'report';
2622		}
2623		var warning = $this.find('#'+type+'_warning');
2624		var listing_id = $this.find('#'+type+'_listing_id');
2625		var nonce = $this.find('#'+type+'_nonce');
2626		var name = $this.find('#'+type+'_name');
2627		var email = $this.find('#'+type+'_email');
2628		var message = $this.find('#'+type+'_message');
2629		var button = $this.find('.w2dc-send-message-button');
2630		var recaptcha = ($this.find('#g-recaptcha-response').length ? $this.find('#g-recaptcha-response').val() : '');
2631		
2632		$this.css('opacity', '0.5');
2633		warning.hide();
2634		button.val(w2dc_js_objects.send_button_sending).attr('disabled', 'disabled');
2635
2636		var data = {
2637				action: "w2dc_contact_form",
2638				type: type,
2639				listing_id: listing_id.val(),
2640				name: name.val(),
2641				email: email.val(),
2642				message: message.val(),
2643				security: nonce.val(),
2644				'g-recaptcha-response': recaptcha
2645		};
2646
2647		$.ajax({
2648				url: w2dc_js_objects.ajaxurl,
2649				type: "POST",
2650				dataType: "json",
2651				data: data,
2652				global: false,
2653				success: function(response_from_the_action_function) {
2654					if (response_from_the_action_function != 0) {
2655						if (response_from_the_action_function.error == '') {
2656							name.val(''),
2657							email.val(''),
2658							message.val(''),
2659							warning.html(response_from_the_action_function.success).show();
2660						} else {
2661							var error;
2662							if (typeof response_from_the_action_function.error == 'object') {
2663								error = '<ul>';
2664								$.each(response_from_the_action_function.error, function(key, value) {
2665									error = error + '<li>' + value + '</li>';
2666								});
2667	            				error = error + '</ul>';
2668	            			} else {
2669	            				error = response_from_the_action_function.error;
2670	            			}
2671							warning.html(error).show();
2672	            		}
2673	            		$this.css('opacity', '1');
2674	            		button.val(w2dc_js_objects.send_button_text).removeAttr('disabled');
2675					}
2676				}
2677		});
2678	});
2679})(jQuery);
2680
2681
2682function w2dc_make_slug(name) {
2683	name = name.toLowerCase();
2684	
2685	var defaultDiacriticsRemovalMap = [
2686	                                   {'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
2687	                                   {'base':'AA','letters':/[\uA732]/g},
2688	                                   {'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
2689	                                   {'base':'AO','letters':/[\uA734]/g},
2690	                                   {'base':'AU','letters':/[\uA736]/g},
2691	                                   {'base':'AV','letters':/[\uA738\uA73A]/g},
2692	                                   {'base':'AY','letters':/[\uA73C]/g},
2693	                                   {'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
2694	                                   {'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
2695	                                   {'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},
2696	                                   {'base':'DZ','letters':/[\u01F1\u01C4]/g},
2697	                                   {'base':'Dz','letters':/[\u01F2\u01C5]/g},
2698	                                   {'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},
2699	                                   {'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},
2700	                                   {'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},
2701	                                   {'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},
2702	                                   {'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},
2703	                                   {'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g},
2704	                                   {'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},
2705	                                   {'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},
2706	                                   {'base':'LJ','letters':/[\u01C7]/g},
2707	                                   {'base':'Lj','letters':/[\u01C8]/g},
2708	                                   {'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},
2709	                                   {'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},
2710	                                   {'base':'NJ','letters':/[\u01CA]/g},
2711	                                   {'base':'Nj','letters':/[\u01CB]/g},
2712	                                   {'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},
2713	                                   {'base':'OI','letters':/[\u01A2]/g},
2714	                                   {'base':'OO','letters':/[\uA74E]/g},
2715	                                   {'base':'OU','letters':/[\u0222]/g},
2716	                                   {'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},
2717	                                   {'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},
2718	                                   {'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},
2719	                                   {'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u
2719015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},
2720	                                   {'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},
2721	                                   {'base':'TZ','letters':/[\uA728]/g},
2722	                                   {'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},
2723	                                   {'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},
2724	                                   {'base':'VY','letters':/[\uA760]/g},
2725	                                   {'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},
2726	                                   {'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},
2727	                                   {'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},
2728	                                   {'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},
2729	                                   {'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},
2730	                                   {'base':'aa','letters':/[\uA733]/g},
2731	                                   {'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g},
2732	                                   {'base':'ao','letters':/[\uA735]/g},
2733	                                   {'base':'au','letters':/[\uA737]/g},
2734	                                   {'base':'av','letters':/[\uA739\uA73B]/g},
2735	                                   {'base':'ay','letters':/[\uA73D]/g},
2736	                                   {'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},
2737	                                   {'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},
2738	                                   {'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},
2739	                                   {'base':'dz','letters':/[\u01F3\u01C6]/g},
2740	                                   {'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},
2741	                                   {'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},
2742	                                   {'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},
2743	                                   {'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},
2744	                                   {'base':'hv','letters':/[\u0195]/g},
2745	                                   {'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},
2746	                                   {'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},
2747	                                   {'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},
2748	                                   {'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},
2749	                                   {'base':'lj','letters':/[\u01C9]/g},
2750	                                   {'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},
2751	                                   {'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},
2752	                                   {'base':'nj','letters':/[\u01CC]/g},
2753	                                   {'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u
27531ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},
2754	                                   {'base':'oi','letters':/[\u01A3]/g},
2755	                                   {'base':'ou','letters':/[\u0223]/g},
2756	                                   {'base':'oo','letters':/[\uA74F]/g},
2757	                                   {'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},
2758	                                   {'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},
2759	                                   {'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},
2760	                                   {'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},
2761	                                   {'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},
2762	                                   {'base':'tz','letters':/[\uA729]/g},
2763	                                   {'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},
2764	                                   {'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},
2765	                                   {'base':'vy','letters':/[\uA761]/g},
2766	                                   {'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},
2767	                                   {'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},
2768	                                   {'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},
2769	                                   {'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}
2770	                               ];
2771	for(var i=0; i<defaultDiacriticsRemovalMap.length; i++)
2772		name = name.replace(defaultDiacriticsRemovalMap[i].letters, defaultDiacriticsRemovalMap[i].base);
2773
2774	//change spaces and other characters by '_'
2775	name = name.replace(/\W/gi, "_");
2776	// remove double '_'
2777	name = name.replace(/(\_)\1+/gi, "_");
2778	
2779	return name;
2780}
2781
2782function w2dc_in_array(val, arr) 
2783{
2784	for (var i = 0; i < arr.length; i++) {
2785		if (arr[i] == val)
2786			return i;
2787	}
2788	return false;
2789}
2790
2791function w2dc_find_get_parameter(parameterName) {
2792    var result = null,
2793        tmp = [];
2794    var items = location.search.substr(1).split("&");
2795    for (var index = 0; index < items.length; index++) {
2796        tmp = items[index].split("=");
2797        if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
2798    }
2799    return result;
2800}
2801
2802
2803/*!
2804 * jQuery Mousewheel 3.1.13 -------------------------------------------------------------------------------------------------------------------------------------------
2805 *
2806 * Copyright 2015 jQuery Foundation and other contributors
2807 * Released under the MIT license.
2808 * http://jquery.org/license
2809 */
2810!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>
2810n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.on("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
2811
2812
2813// tax_dropdowns.js -------------------------------------------------------------------------------------------------------------------------------------------
2814(function($) {
2815	"use strict";
2816
2817	$(document).on('change', '.w2dc-tax-dropdowns-wrap select', function() {
2818		var select_box = $(this).attr('id').split('_');
2819		var parent = $(this).val();
2820		var current_level = select_box[1];
2821		var uID = select_box[2];
2822
2823		var divclass = $(this).parents('.w2dc-tax-dropdowns-wrap').attr('class').split(' ');
2824		var tax = divclass[0];
2825		var count = divclass[1];
2826		var hide_empty = divclass[2];
2827
2828		w2dc_update_tax(parent, tax, current_level, count, hide_empty, uID, function() {});
2829	});
2830
2831	function w2dc_update_tax(parent, tax, current_level, count, hide_empty, uID, callback) {
2832		var current_level = parseInt(current_level);
2833		var next_level = current_level + 1;
2834		var prev_level = current_level - 1;
2835		var selects_length = $('#w2dc-tax-dropdowns-wrap-'+uID+' .w2dc-location-chainlist').length;
2836		
2837		if (parent)
2838			$('#selected_tax\\['+uID+'\\]').val(parent).trigger('change');
2839		else if (current_level > 1)
2840			$('#selected_tax\\['+uID+'\\]').val($('#chainlist_'+prev_level+'_'+uID).val()).trigger('change');
2841		else
2842			$('#selected_tax\\['+uID+'\\]').val(0).trigger('change');
2843
2844		var exact_terms = $('#exact_terms\\['+uID+'\\]').val();
2845
2846		for (var i=next_level; i<=selects_length; i++) {
2847			$('#wrap_chainlist_'+i+'_'+uID).remove();
2848		}
2849		
2850		if (parent && typeof w2dc_js_objects['tax_dropdowns_'+uID][uID] != undefined) {
2851			var labels_source = w2dc_js_objects['tax_dropdowns_'+uID][uID];
2852
2853			if (labels_source.labels[current_level] != undefined)
2854				var label = labels_source.labels[current_level];
2855			else
2856				var label = '';
2857			if (labels_source.titles[current_level] != undefined)
2858				var title = labels_source.titles[current_level];
2859			else
2860				var title = '';
2861			if (labels_source.allow_add_term[current_level] != undefined)
2862				var allow_add_term = labels_source.allow_add_term[current_level];
2863			else
2864				var allow_add_term = '';
2865
2866			$('#chainlist_'+current_level+'_'+uID).addClass('w2dc-ajax-loading').attr('disabled', 'disabled');
2867			$.post(
2868				w2dc_js_objects.ajaxurl,
2869				{
2870					'action': 'w2dc_tax_dropdowns_hook',
2871					'parentid': parent,
2872					'next_level': next_level,
2873					'tax': tax,
2874					'count': count,
2875					'hide_empty': hide_empty,
2876					'label': label,
2877					'title': title,
2878					'allow_add_term': allow_add_term,
2879					'exact_terms': exact_terms,
2880					'uID': uID
2881				},
2882				function(response_from_the_action_function){
2883					if (response_from_the_action_function != 0)
2884						$('#w2dc-tax-dropdowns-wrap-'+uID).append(response_from_the_action_function);
2885
2886					$('#chainlist_'+current_level+'_'+uID).removeClass('w2dc-ajax-loading').removeAttr('disabled');
2887					
2888					callback();
2889				}
2890			);
2891		}
2892	}
2893	
2894	function first(p){for(var i in p)return p[i];}
2895}(jQuery));
2896
2897
2898
2899// jquery.coo_kie.js -------------------------------------------------------------------------------------------------------------------------------------------
2900jQuery.cookie=function(e,i,o){if("undefined"==typeof i){var n=null;if(document.cookie&&""!=document.cookie)for(var r=document.cookie.split(";"),t=0;t<r.length;t++){var p=jQuery.trim(r[t]);if(p.substring(0,e.length+1)==e+"="){n=decodeURIComponent(p.substring(e.length+1));break}}return n}o=o||{},null===i&&(i="",o.expires=-1);var u="";if(o.expires&&("number"==typeof o.expires||o.expires.toUTCString)){var s;"number"==typeof o.expires?(s=new Date,s.setTime(s.getTime()+24*o.expires*60*60*1e3)):s=o.expires,u="; expires="+s.toUTCString()}var a=o.path?"; path="+o.path:"",c=o.domain?"; domain="+o.domain:"",m=o.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(i),u,a,c,m].join("")};
2901
2902
2903
2904// jquery.w2dc_bxslider.min.js -------------------------------------------------------------------------------------------------------------------------------------------
2905/**
2906 * w2dc_bxslider v4.2.1d
2907 * Copyright 2013-2017 Steven Wanderski
2908 * Written while drinking Belgian ales and listening to jazz
2909 * Licensed under MIT (http://opensource.org/licenses/MIT)
2910 * 
2911 * 22.09.2020 - added condition in if (slider.viewport.get(0).releasePointerCapture && typeof w2dc_lightbox == "undefined") {
2912 */
2913!function(R){var Z={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,wrapperClass:"w2dc-bx-wrapper",touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,ariaLive:!0,ariaHidden:!0,keyboardEnabled:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",stopAutoOnClick:!1,autoHover:!1,autoDelay:0,autoSlideForOnePage:!1,minSli
vendor: 14,479 bytes, line 2913
2913des:1,maxSlides:1,moveSlides:0,slideWidth:0,shrinkItems:!1,onSliderLoad:function(){return!0},onSlideBefore:function(){return!0},onSlideAfter:function(){return!0},onSlideNext:function(){return!0},onSlidePrev:function(){return!0},onSliderResize:function(){return!0},onAutoChange:function(){return!0}};R.fn.w2dc_bxslider=function(e){if(0===this.length)return this;if(1<this.length)return this.each(function(){R(this).w2dc_bxslider(e)}),this;var g={},p=this,n=R(window).width(),s=R(window).height();if(!R(p).data("w2dc_bxslider")){function o(){R(p).data("w2dc_bxslider")||(g.settings=R.extend({},Z,e),g.settings.slideWidth=parseInt(g.settings.slideWidth),g.children=p.children(g.settings.slideSelector),g.children.length<g.settings.minSlides&&(g.settings.minSlides=g.children.length),g.children.length<g.settings.maxSlides&&(g.settings.maxSlides=g.children.length),g.settings.randomStart&&(g.settings.startSlide=Math.floor(Math.random()*g.children.length)),g.active={index:g.settings.startSlide},g.carousel=1<g.settings.minSlides||1<g.settings.maxSlides,g.carousel&&(g.settings.preloadImages="all"),g.minThreshold=g.settings.minSlides*g.settings.slideWidth+(g.settings.minSlides-1)*g.settings.slideMargin,g.maxThreshold=g.settings.maxSlides*g.settings.slideWidth+(g.settings.maxSlides-1)*g.settings.slideMargin,g.working=!1,g.controls={},g.interval=null,g.animProp="vertical"===g.settings.mode?"top":"left",g.usingCSS=g.settings.useCSS&&"fade"!==g.settings.mode&&function(){for(var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"],i=0;i<e.length;i++)if(void 0!==t.style[e[i]])return g.cssPrefix=e[i].replace("Perspective","").toLowerCase(),g.animProp="-"+g.cssPrefix+"-transform",!0;return!1}(),"vertical"===g.settings.mode&&(g.settings.maxSlides=g.settings.minSlides),p.data("origStyle",p.attr("style")),p.children(g.settings.slideSelector).each(function(){R(this).data("origStyle",R(this).attr("style"))}),d())}function r(){var t=1,e=null;return"horizontal"===g.settings.mode&&0<g.settings.slideWidth?t=g.viewport.width()<g.minThreshold?g.settings.minSlides:g.viewport.width()>g.maxThreshold?g.settings.maxSlides:(e=g.children.first().width()+g.settings.slideMargin,Math.floor((g.viewport.width()+g.settings.slideMargin)/e)||1):"vertical"===g.settings.mode&&(t=g.settings.minSlides),t}function t(){for(var t="",e="",i=w(),n=0;n<i;n++)e="",g.settings.buildPager&&R.isFunction(g.settings.buildPager)||g.settings.pagerCustom?(e=g.settings.buildPager(n),g.pagerEl.addClass("w2dc-bx-custom-pager")):(e=n+1,g.pagerEl.addClass("w2dc-bx-default-pager")),t+='<div class="w2dc-bx-pager-item"><a href="" data-slide-index="'+n+'" class="w2dc-bx-pager-link">'+e+"</a></div>";g.pagerEl.html(t)}function a(){p.startAuto()}function l(){p.stopAuto()}function u(t){var e=r();g.settings.ariaHidden&&!g.settings.ticker&&(g.children.attr("aria-hidden","true"),g.children.slice(t,t+e).attr("aria-hidden","false"))}var d=function(){var t=g.children.eq(g.settings.startSlide);p.wrap('<div class="'+g.settings.wrapperClass+'"><div class="w2dc-bx-viewport"></div></div>'),g.viewport=p.parent(),g.settings.ariaLive&&!g.settings.ticker&&g.viewport.attr("aria-live","polite"),g.loader=R('<div class="w2dc-bx-loading" />'),g.viewport.prepend(g.loader),p.css({width:"horizontal"===g.settings.mode?1e3*g.children.length+215+"%":"auto",position:"relative"}),g.usingCSS&&g.settings.easing?p.css("-"+g.cssPrefix+"-transition-timing-function",g.settings.easing):g.settings.easing||(g.settings.easing="swing"),g.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),g.viewport.parent().css({maxWidth:f()}),g.children.css({float:"horizontal"===g.settings.mode?"left":"none",listStyle:"none",position:"relative"}),g.children.css("width",m()),"horizontal"===g.settings.mode&&0<g.settings.slideMargin&&g.children.css("marginRight",g.settings.slideMargin),"vertical"===g.settings.mode&&0<g.settings.slideMargin&&g.children.css("marginBottom",g.settings.slideMargin),"fade"===g.settings.mode&&(g.children.css({position:"absolute",zIndex:0,display:"none"}),g.children.eq(g.settings.startSlide).css({zIndex:g.settings.slideZIndex,display:"block"})),g.controls.el=R('<div class="w2dc-bx-controls" />'),g.settings.captions&&P(),g.active.last=g.settings.startSlide===w()-1,g.settings.video&&p.fitVids(),"none"===g.settings.preloadImages?t=null:"all"!==g.settings.preloadImages&&!g.settings.ticker||(t=g.children),g.settings.ticker?g.settings.pager=!1:(g.settings.controls&&T(),g.settings.auto&&g.settings.autoControls&&k(),g.settings.pager&&b(),(g.settings.controls||g.settings.autoControls||g.settings.pager)&&g.viewport.after(g.controls.el)),null===t?h():c(t,h)},c=function(t,e){var i=t.find('img:not([src=""]), iframe').length,n=0;0!==i?t.find('img:not([src=""]), iframe').each(function(){R(this).one("load error",function(){++n===i&&e()}).each(function(){!this.complete&&""!=this.src||R(this).trigger("load")})}):e()},h=function(){var t,e,i;g.settings.infiniteLoop&&"fade"!==g.settings.mode&&!g.settings.ticker&&(t="vertical"===g.settings.mode?g.settings.minSlides:g.settings.maxSlides,e=g.children.slice(0,t).clone(!0).addClass("w2dc-bx-clone"),i=g.children.slice(-t).clone(!0).addClass("w2dc-bx-clone"),g.settings.ariaHidden&&(e.attr("aria-hidden",!0),i.attr("aria-hidden",!0)),p.append(e).prepend(i)),g.loader.remove(),S(),"vertical"===g.settings.mode&&(g.settings.adaptiveHeight=!0),g.viewport.height(v()),p.redrawSlider(),g.settings.onSliderLoad.call(p,g.active.index),g.initialized=!0,g.settings.responsive&&R(window).on("resize",V),g.settings.auto&&g.settings.autoStart&&(1<w()||g.settings.autoSlideForOnePage)&&W(),g.settings.ticker&&L(),g.settings.pager&&A(g.settings.startSlide),g.settings.controls&&H(),g.settings.touchEnabled&&!g.settings.ticker&&_(),g.settings.keyboardEnabled&&!g.settings.ticker&&R(document).keydown(F)},v=function(){var e=0,t=R();if("vertical"===g.settings.mode||g.settings.adaptiveHeight)if(g.carousel){var n=1===g.settings.moveSlides?g.active.index:g.active.index*x(),t=g.children.eq(n);for(i=1;i<=g.settings.maxSlides-1;i++)t=n+i>=g.children.length?t.add(g.children.eq(i-1)):t.add(g.children.eq(n+i))}else t=g.children.eq(g.active.index);else t=g.children;return"vertical"===g.settings.mode?(t.each(function(t){e+=R(this).outerHeight()}),0<g.settings.slideMargin&&(e+=g.settings.slideMargin*(g.settings.minSlides-1))):e=Math.max.apply(Math,t.map(function(){return R(this).outerHeight(!1)}).get()),"border-box"===g.viewport.css("box-sizing")?e+=parseFloat(g.viewport.css("padding-top"))+parseFloat(g.viewport.css("padding-bottom"))+parseFloat(g.viewport.css("border-top-width"))+parseFloat(g.viewport.css("border-bottom-width")):"padding-box"===g.viewport.css("box-sizing")&&(e+=parseFloat(g.viewport.css("padding-top"))+parseFloat(g.viewport.css("padding-bottom"))),e},f=function(){var t="100%";return 0<g.settings.slideWidth&&(t="horizontal"===g.settings.mode?g.settings.maxSlides*g.settings.slideWidth+(g.settings.maxSlides-1)*g.settings.slideMargin:g.settings.slideWidth),t},m=function(){var t=g.settings.slideWidth,e=g.viewport.width();if(0===g.settings.slideWidth||g.settings.slideWidth>e&&!g.carousel||"vertical"===g.settings.mode)t=e;else if(1<g.settings.maxSlides&&"horizontal"===g.settings.mode){if(e>g.maxThreshold)return t;e<g.minThreshold?t=(e-g.settings.slideMargin*(g.settings.minSlides-1))/g.settings.minSlides:g.settings.shrinkItems&&(t=Math.floor((e+g.settings.slideMargin)/Math.ceil((e+g.settings.slideMargin)/(t+g.settings.slideMargin))-g.settings.slideMargin))}return t},w=function(){var t=0,e=0,i=0;if(0<g.settings.moveSlides){if(!g.settings.infiniteLoop){for(;e<g.children.length;)++t,e=i+r(),i+=g.settings.moveSlides<=r()?g.settings.moveSlides:r();return i}t=Math.ceil(g.children.length/x())}else t=Math.ceil(g.children.length/r());return t},x=function(){return 0<g.settings.moveSlides&&g.settings.moveSlides<=r()?g.settings.moveSlides:r()},S=function(){var t,e,i;g.children.length>g.settings.maxSlides&&g.active.last&&!g.settings.infiniteLoop?"horizontal"===g.settings.mode?(t=(e=g.children.last()).position(),C(-(t.left-(g.viewport.width()-e.outerWidth())),"reset",0)):"vertical"===g.settings.mode&&(i=g.children.length-g.settings.minSlides,t=g.children.eq(i).position(),C(-t.top,"reset",0)):(t=g.children.eq(g.active.index*x()).position(),g.active.index===w()-1&&(g.active.last=!0),void 0!==t&&("horizontal"===g.settings.mode?C(-t.left,"reset",0):"vertical"===g.settings.mode&&C(-t.top,"reset",0)))},C=function(t,e,i,n){var s,o;g.usingCSS?(o="vertical"===g.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)",p.css("-"+g.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"===e?(p.css(g.animProp,o),0!==i?p.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(t){R(t.target).is(p)&&(p.off("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),q())}):q()):"reset"===e?p.css(g.animProp,o):"ticker"===e&&(p.css("-"+g.cssPrefix+"-transition-timing-function","linear"),p.css(g.animProp,o),0!==i?p.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(t){R(t.target).is(p)&&(p.off("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),C(n.resetValue,"reset",0),O())}):(C(n.resetValue,"reset",0),O()))):((s={})[g.animProp]=t,"slide"===e?p.animate(s,i,g.settings.easing,function(){q()}):"reset"===e?p.css(g.animProp,t):"ticker"===e&&p.animate(s,i,"linear",function(){C(n.resetValue,"reset",0),O()}))},b=function(){g.settings.pagerCustom?g.pagerEl=R(g.settings.pagerCustom):(g.pagerEl=R('<div class="w2dc-bx-pager" />'),g.settings.pagerSelector?R(g.settings.pagerSelector).html(g.pagerEl):g.controls.el.addClass("w2dc-bx-has-pager").append(g.pagerEl),t()),g.pagerEl.on("click touchend","a",z)},T=function(){g.controls.next=R('<a class="w2dc-bx-next" href="">'+g.settings.nextText+"</a>"),g.controls.prev=R('<a class="w2dc-bx-prev" href="">'+g.settings.prevText+"</a>"),g.controls.next.on("click touchend",E),g.controls.prev.on("click touchend",M),g.settings.nextSelector&&R(g.settings.nextSelector).append(g.controls.next),g.settings.prevSelector&&R(g.settings.prevSelector).append(g.controls.prev),g.settings.nextSelector||g.settings.prevSelector||(g.controls.directionEl=R('<div class="w2dc-bx-controls-direction" />'),g.controls.directionEl.append(g.controls.prev).append(g.controls.next),g.controls.el.addClass("w2dc-bx-has-controls-direction").append(g.controls.directionEl))},k=function(){g.controls.start=R('<div class="w2dc-bx-controls-auto-item"><a class="w2dc-bx-start" href="">'+g.settings.startText+"</a></div>"),g.controls.stop=R('<div class="w2dc-bx-controls-auto-item"><a class="w2dc-bx-stop" href="">'+g.settings.stopText+"</a></div>"),g.controls.autoEl=R('<div class="w2dc-bx-controls-auto" />'),g.controls.autoEl.on("click",".w2dc-bx-start",y),g.controls.autoEl.on("click",".w2dc-bx-stop",I),g.settings.autoControlsCombine?g.controls.autoEl.append(g.controls.start):g.controls.autoEl.append(g.controls.start).append(g.controls.stop),g.settings.autoControlsSelector?R(g.settings.autoControlsSelector).html(g.controls.autoEl):g.controls.el.addClass("w2dc-bx-has-controls-auto").append(g.controls.autoEl),D(g.settings.autoStart?"stop":"start")},P=function(){g.children.each(function(t){var e=R(this).find("img:first").attr("title");void 0!==e&&(""+e).length&&R(this).append('<div class="w2dc-bx-caption"><span>'+e+"</span></div>")})},E=function(t){t.preventDefault(),g.controls.el.hasClass("disabled")||(g.settings.auto&&g.settings.stopAutoOnClick&&p.stopAuto(),p.goToNextSlide())},M=function(t){t.preventDefault(),g.controls.el.hasClass("disabled")||(g.settings.auto&&g.settings.stopAutoOnClick&&p.stopAuto(),p.goToPrevSlide())},y=function(t){p.startAuto(),t.preventDefault()},I=function(t){p.stopAuto(),t.preventDefault()},z=function(t){var e,i;t.preventDefault(),g.controls.el.hasClass("disabled")||(g.settings.auto&&g.settings.stopAutoOnClick&&p.stopAuto(),void 0!==(e=R(t.currentTarget)).attr("data-slide-index")&&(i=parseInt(e.attr("data-slide-index")))!==g.active.index&&p.goToSlide(i))},A=function(i){var t=g.children.length;if("short"===g.settings.pagerType)return 1<g.settings.maxSlides&&(t=Math.ceil(g.children.length/g.settings.maxSlides)),void g.pagerEl.html(i+1+g.settings.pagerShortSeparator+t);g.pagerEl.find("a").removeClass("active"),g.pagerEl.each(function(t,e){R(e).find("a").eq(i).addClass("active")})},q=function(){var t;g.settings.infiniteLoop&&(t="",0===g.active.index?t=g.children.eq(0).position():g.active.index===w()-1&&g.carousel?t=g.children.eq((w()-1)*x()).position():g.active.index===g.children.length-1&&(t=g.children.eq(g.children.length-1).position()),t&&("horizontal"===g.settings.mode?C(-t.left,"reset",0):"vertical"===g.settings.mode&&C(-t.top,"reset",0))),g.working=!1,g.settings.onSlideAfter.call(p,g.children.eq(g.active.index),g.oldIndex,g.active.index)},D=function(t){g.settings.autoControlsCombine?g.controls.autoEl.html(g.controls[t]):(g.controls.autoEl.find("a").removeClass("active"),g.controls.autoEl.find("a:not(.w2dc-bx-"+t+")").addClass("active"))},H=function(){1===w()?(g.controls.prev.addClass("disabled"),g.controls.next.addClass("disabled")):!g.settings.infiniteLoop&&g.settings.hideControlOnEnd&&(0===g.active.index?(g.controls.prev.addClass("disabled"),g.controls.next.removeClass("disabled")):g.active.index===w()-1?(g.controls.next.addClass("disabled"),g.controls.prev.removeClass("disabled")):(g.controls.prev.removeClass("disabled"),g.controls.next.removeClass("disabled")))},W=function(){0<g.settings.autoDelay?setTimeout(p.startAuto,g.settings.autoDelay):(p.startAuto(),R(window).focus(a).blur(l)),g.settings.autoHover&&p.on("mouseenter", function(){g.interval&&(p.stopAuto(!0),g.autoPaused=!0)},function(){g.autoPaused&&(p.startAuto(!0),g.autoPaused=null)})},L=function(){var t,e,i,n,s,o,r,a,l=0;"next"===g.settings.autoDirection?p.append(g.children.clone().addClass("w2dc-bx-clone")):(p.prepend(g.children.clone().addClass("w2dc-bx-clone")),t=g.children.first().position(),l="horizontal"===g.settings.mode?-t.left:-t.top),C(l,"reset",0),g.settings.pager=!1,g.settings.controls=!1,g.settings.autoControls=!1,g.settings.tickerHover&&(g.usingCSS?(n="horizontal"===g.settings.mode?4:5,g.viewport.on("mouseenter", function(){e=p.css("-"+g.cssPrefix+"-transform"),i=parseFloat(e.split(",")[n]),C(i,"reset",0)},function(){a=0,g.children.each(function(t){a+="horizontal"===g.settings.mode?R(this).outerWidth(!0):R(this).outerHeight(!0)}
2913),s=g.settings.speed/a,o="horizontal"===g.settings.mode?"left":"top",r=s*(a-Math.abs(parseInt(i))),O(r)})):g.viewport.on("mouseenter", function(){p.stop()},function(){a=0,g.children.each(function(t){a+="horizontal"===g.settings.mode?R(this).outerWidth(!0):R(this).outerHeight(!0)}),s=g.settings.speed/a,o="horizontal"===g.settings.mode?"left":"top",r=s*(a-Math.abs(parseInt(p.css(o)))),O(r)})),O()},O=function(t){var e,i,n=t||g.settings.speed,s={left:0,top:0},o={left:0,top:0};"next"===g.settings.autoDirection?s=p.find(".w2dc-bx-clone").first().position():o=g.children.first().position(),e="horizontal"===g.settings.mode?-s.left:-s.top,i="horizontal"===g.settings.mode?-o.left:-o.top,C(e,"ticker",n,{resetValue:i})},F=function(t){var e,i,n,s,o=document.activeElement.tagName.toLowerCase();if(null==new RegExp(o,["i"]).exec("input|textarea")&&(e=p,i=R(window),n={top:i.scrollTop(),left:i.scrollLeft()},s=e.offset(),n.right=n.left+i.width(),n.bottom=n.top+i.height(),s.right=s.left+e.outerWidth(),s.bottom=s.top+e.outerHeight(),!(n.right<s.left||n.left>s.right||n.bottom<s.top||n.top>s.bottom))){if(39===t.keyCode)return E(t),!1;if(37===t.keyCode)return M(t),!1}},_=function(){g.touch={start:{x:0,y:0},end:{x:0,y:0}},g.viewport.on("touchstart MSPointerDown pointerdown",N),g.viewport.on("click",".w2dc_bxslider a",function(t){g.viewport.hasClass("click-disabled")&&(t.preventDefault(),g.viewport.removeClass("click-disabled"))})},N=function(t){if("touchstart"===t.type||0===t.button)if(t.preventDefault(),g.controls.el.addClass("disabled"),g.working)g.controls.el.removeClass("disabled");else{g.touch.originalPos=p.position();var e=t.originalEvent,i=void 0!==e.changedTouches?e.changedTouches:[e];if("function"==typeof PointerEvent&&void 0===e.pointerId)return;g.touch.start.x=i[0].pageX,g.touch.start.y=i[0].pageY,g.viewport.get(0).setPointerCapture&&(g.pointerId=e.pointerId,g.viewport.get(0).setPointerCapture(g.pointerId)),g.originalClickTarget=e.originalTarget||e.target,g.originalClickButton=e.button,g.originalClickButtons=e.buttons,g.originalEventType=e.type,g.hasMove=!1,g.viewport.on("touchmove MSPointerMove pointermove",X),g.viewport.on("touchend MSPointerUp pointerup",Y),g.viewport.on("MSPointerCancel pointercancel",B)}},B=function(t){t.preventDefault(),C(g.touch.originalPos.left,"reset",0),g.controls.el.removeClass("disabled"),g.viewport.off("MSPointerCancel pointercancel",B),g.viewport.off("touchmove MSPointerMove pointermove",X),g.viewport.off("touchend MSPointerUp pointerup",Y),g.viewport.get(0).releasePointerCapture&&"undefined"==typeof w2dc_lightbox&&g.viewport.get(0).releasePointerCapture(g.pointerId)},X=function(t){var e=t.originalEvent,i=void 0!==e.changedTouches?e.changedTouches:[e],n=Math.abs(i[0].pageX-g.touch.start.x),s=Math.abs(i[0].pageY-g.touch.start.y),o=0,r=0;g.hasMove=!0,(s<3*n&&g.settings.preventDefaultSwipeX||n<3*s&&g.settings.preventDefaultSwipeY)&&t.preventDefault(),"touchmove"!==t.type&&t.preventDefault(),"fade"!==g.settings.mode&&g.settings.oneToOneTouch&&(o="horizontal"===g.settings.mode?(r=i[0].pageX-g.touch.start.x,g.touch.originalPos.left+r):(r=i[0].pageY-g.touch.start.y,g.touch.originalPos.top+r),C(o,"reset",0))},Y=function(t){t.preventDefault(),g.viewport.off("touchmove MSPointerMove pointermove",X),g.controls.el.removeClass("disabled");var e=t.originalEvent,i=void 0!==e.changedTouches?e.changedTouches:[e],n=0,s=0;g.touch.end.x=i[0].pageX,g.touch.end.y=i[0].pageY,"fade"===g.settings.mode?(s=Math.abs(g.touch.start.x-g.touch.end.x))>=g.settings.swipeThreshold&&(g.touch.start.x>g.touch.end.x?p.goToNextSlide():p.goToPrevSlide(),p.stopAuto()):(n="horizontal"===g.settings.mode?(s=g.touch.end.x-g.touch.start.x,g.touch.originalPos.left):(s=g.touch.end.y-g.touch.start.y,g.touch.originalPos.top),(g.settings.infiniteLoop||!(0===g.active.index&&0<s||g.active.last&&s<0))&&Math.abs(s)>=g.settings.swipeThreshold?(s<0?p.goToNextSlide():p.goToPrevSlide(),p.stopAuto()):C(n,"reset",200)),g.viewport.off("touchend MSPointerUp pointerup",Y),g.viewport.get(0).releasePointerCapture&&"undefined"==typeof w2dc_lightbox&&g.viewport.get(0).releasePointerCapture(g.pointerId),!1!==g.hasMove||0!==g.originalClickButton&&"touchstart"!==g.originalEventType||R(g.originalClickTarget).trigger({type:"click",button:g.originalClickButton,buttons:g.originalClickButtons})},V=function(t){var e,i;g.initialized&&(g.working?window.setTimeout(V,10):(e=R(window).width(),i=R(window).height(),n===e&&s===i||(n=e,s=i,p.redrawSlider(),g.settings.onSliderResize.call(p,g.active.index))))};return p.goToSlide=function(t,e){var i,n,s,o,r,a=!0,l=0,d={left:0,top:0},c=null;if(g.oldIndex=g.active.index,g.active.index=(r=t)<0?g.settings.infiniteLoop?w()-1:g.active.index:r>=w()?g.settings.infiniteLoop?0:g.active.index:r,!g.working&&g.active.index!==g.oldIndex){if(g.working=!0,void 0!==(a=g.settings.onSlideBefore.call(p,g.children.eq(g.active.index),g.oldIndex,g.active.index))&&!a)return g.active.index=g.oldIndex,void(g.working=!1);"next"===e?g.settings.onSlideNext.call(p,g.children.eq(g.active.index),g.oldIndex,g.active.index)||(a=!1):"prev"===e&&(g.
2913settings.onSlidePrev.call(p,g.children.eq(g.active.index),g.oldIndex,g.active.index)||(a=!1)),g.active.last=g.active.index>=w()-1,(g.settings.pager||g.settings.pagerCustom)&&A(g.active.index),g.settings.controls&&H(),"fade"===g.settings.mode?(g.settings.adaptiveHeight&&g.viewport.height()!==v()&&g.viewport.animate({height:v()},g.settings.adaptiveHeightSpeed),g.children.filter(":visible").fadeOut(g.settings.speed).css({zIndex:0}),g.children.eq(g.active.index).css("zIndex",g.settings.slideZIndex+1).fadeIn(g.settings.speed,function(){R(this).css("zIndex",g.settings.slideZIndex),q()})):(g.settings.adaptiveHeight&&g.viewport.height()!==v()&&g.viewport.animate({height:v()},g.settings.adaptiveHeightSpeed),!g.settings.infiniteLoop&&g.carousel&&g.active.last?"horizontal"===g.settings.mode?(d=(c=g.children.eq(g.children.length-1)).position(),l=g.viewport.width()-c.outerWidth()):(i=g.children.length-g.settings.minSlides,d=g.children.eq(i).position()):g.carousel&&g.active.last&&"prev"===e?(n=1===g.settings.moveSlides?g.settings.maxSlides-x():(w()-1)*x()-(g.children.length-g.settings.maxSlides),d=(c=p.children(".w2dc-bx-clone").eq(n)).position()):"next"===e&&0===g.active.index?(d=p.find("> .w2dc-bx-clone").eq(g.settings.maxSlides).position(),g.active.last=!1):0<=t&&(o=t*parseInt(x()),d=g.children.eq(o).position()),void 0!==d&&(s="horizontal"===g.settings.mode?-(d.left-l):-d.top,C(s,"slide",g.settings.speed)),g.working=!1),g.settings.ariaHidden&&u(g.active.index*x())}},p.goToNextSlide=function(){var t;!g.settings.infiniteLoop&&g.active.last||!0!==g.working&&(t=parseInt(g.active.index)+1,p.goToSlide(t,"next"))},p.goToPrevSlide=function(){var t;!g.settings.infiniteLoop&&0===g.active.index||!0===g.working||(t=parseInt(g.active.index)-1,p.goToSlide(t,"prev"))},p.startAuto=function(t){g.interval||(g.interval=setInterval(function(){"next"===g.settings.autoDirection?p.goToNextSlide():p.goToPrevSlide()},g.settings.pause),g.settings.onAutoChange.call(p,!0),g.settings.autoControls&&!0!==t&&D("stop"))},p.stopAuto=function(t){g.autoPaused&&(g.autoPaused=!1),g.interval&&(clearInterval(g.interval),g.interval=null,g.settings.onAutoChange.call(p,!1),g.settings.autoControls&&!0!==t&&D("start"))},p.getCurrentSlide=function(){return g.active.index},p.getCurrentSlideElement=function(){return g.children.eq(g.active.index)},p.getSlideElement=function(t){return g.children.eq(t)},p.getSlideCount=function(){return g.children.length},p.isWorking=function(){return g.working},p.redrawSlider=function(){g.children.add(p.find(".w2dc-bx-clone")).outerWidth(m()),g.viewport.css("height",v()),g.settings.ticker||S(),g.active.last&&(g.active.index=w()-1),g.active.index>=w()&&(g.active.last=!0),g.settings.pager&&!g.settings.pagerCustom&&(t(),A(g.active.index)),g.settings.ariaHidden&&u(g.active.index*x())},p.destroySlider=function(){g.initialized&&(g.initialized=!1,R(".w2dc-bx-clone",this).remove(),g.children.each(function(){void 0!==R(this).data("origStyle")?R(this).attr("style",R(this).data("origStyle")):R(this).removeAttr("style")}),void 0!==R(this).data("origStyle")?this.attr("style",R(this).data("origStyle")):R(this).removeAttr("style"),R(this).unwrap().unwrap(),g.controls.el&&g.controls.el.remove(),g.controls.next&&g.controls.next.remove(),g.controls.prev&&g.controls.prev.remove(),g.pagerEl&&g.settings.controls&&!g.settings.pagerCustom&&g.pagerEl.remove(),R(".w2dc-bx-caption",this).remove(),g.controls.autoEl&&g.controls.autoEl.remove(),clearInterval(g.interval),g.settings.responsive&&R(window).off("resize",V),g.settings.keyboardEnabled&&R(document).off("keydown",F),R(this).removeData("w2dc_bxslider"),R(window).off("blur",l).off("focus",a))},p.reloadSlider=function(t){void 0!==t&&(e=t),p.destroySlider(),o(),R(p).data("w2dc_bxslider",this)},o(),R(p).data("w2dc_bxslider",this),this}}}(jQuery);
2914
2915
2916
2917
2918
2919
2920/* ========================================================================
2921 * Bootstrap: tooltip.js v3.3.5
2922 * http://getbootstrap.com/javascript/#tooltip
2923 * Inspired by the original jQuery.tipsy by Jason Frame
2924 * ========================================================================
2925 * Copyright 2011-2015 Twitter, Inc.
2926 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2927 * ======================================================================== */
2928+function ($) {
2929  'use strict';
2930
2931  // TOOLTIP PUBLIC CLASS DEFINITION
2932  // ===============================
2933
2934  var Tooltip = function (element, options) {
2935    this.type       = null
2936    this.options    = null
2937    this.enabled    = null
2938    this.timeout    = null
2939    this.hoverState = null
2940    this.$element   = null
2941    this.inState    = null
2942
2943    this.init('w2dc_tooltip', element, options)
2944  }
2945
2946  Tooltip.VERSION  = '3.3.5'
2947
2948  Tooltip.TRANSITION_DURATION = 150
2949
2950  Tooltip.DEFAULTS = {
2951    animation: true,
2952    placement: 'top',
2953    selector: false,
2954    template: '<div class="w2dc-tooltip" role="tooltip"><div class="w2dc-tooltip-arrow"></div><div class="w2dc-tooltip-inner"></div></div>',
2955    trigger: 'hover focus',
2956    title: '',
2957    delay: 0,
2958    html: false,
2959    container: false,
2960    viewport: {
2961      selector: 'body',
2962      padding: 0
2963    }
2964  }
2965
2966  Tooltip.prototype.init = function (type, element, options) {
2967    this.enabled   = true
2968    this.type      = type
2969    this.$element  = $(element)
2970    this.options   = this.getOptions(options)
2971    this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
2972    this.inState   = { click: false, hover: false, focus: false }
2973
2974    if (this.$element[0] instanceof document.constructor && !this.options.selector) {
2975      throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
2976    }
2977
2978    var triggers = this.options.trigger.split(' ')
2979
2980    for (var i = triggers.length; i--;) {
2981      var trigger = triggers[i]
2982
2983      if (trigger == 'click') {
2984        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
2985      } else if (trigger != 'manual') {
2986        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
2987        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
2988
2989        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
2990        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
2991      }
2992    }
2993
2994    this.options.selector ?
2995      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
2996      this.fixTitle()
2997  }
2998
2999  Tooltip.prototype.getDefaults = function () {
3000    return Tooltip.DEFAULTS
3001  }
3002
3003  Tooltip.prototype.getOptions = function (options) {
3004    options = $.extend({}, this.getDefaults(), this.$element.data(), options)
3005
3006    if (options.delay && typeof options.delay == 'number') {
3007      options.delay = {
3008        show: options.delay,
3009        hide: options.delay
3010      }
3011    }
3012
3013    return options
3014  }
3015
3016  Tooltip.prototype.getDelegateOptions = function () {
3017    var options  = {}
3018    var defaults = this.getDefaults()
3019
3020    this._options && $.each(this._options, function (key, value) {
3021      if (defaults[key] != value) options[key] = value
3022    })
3023
3024    return options
3025  }
3026
3027  Tooltip.prototype.enter = function (obj) {
3028    var self = obj instanceof this.constructor ?
3029      obj : $(obj.currentTarget).data('bs.' + this.type)
3030
3031    if (!self) {
3032      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
3033      $(obj.currentTarget).data('bs.' + this.type, self)
3034    }
3035
3036    if (obj instanceof $.Event) {
vendor: 17,930 bytes, lines 3037-3541
3037      self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
3038    }
3039
3040    if (self.tip().hasClass('w2dc-in') || self.hoverState == 'in') {
3041      self.hoverState = 'in'
3042      return
3043    }
3044
3045    clearTimeout(self.timeout)
3046
3047    self.hoverState = 'in'
3048
3049    if (!self.options.delay || !self.options.delay.show) return self.show()
3050
3051    self.timeout = setTimeout(function () {
3052      if (self.hoverState == 'in') self.show()
3053    }, self.options.delay.show)
3054  }
3055
3056  Tooltip.prototype.isInStateTrue = function () {
3057    for (var key in this.inState) {
3058      if (this.inState[key]) return true
3059    }
3060
3061    return false
3062  }
3063
3064  Tooltip.prototype.leave = function (obj) {
3065    var self = obj instanceof this.constructor ?
3066      obj : $(obj.currentTarget).data('bs.' + this.type)
3067
3068    if (!self) {
3069      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
3070      $(obj.currentTarget).data('bs.' + this.type, self)
3071    }
3072
3073    if (obj instanceof $.Event) {
3074      self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
3075    }
3076
3077    if (self.isInStateTrue()) return
3078
3079    clearTimeout(self.timeout)
3080
3081    self.hoverState = 'out'
3082
3083    if (!self.options.delay || !self.options.delay.hide) return self.hide()
3084
3085    self.timeout = setTimeout(function () {
3086      if (self.hoverState == 'out') self.hide()
3087    }, self.options.delay.hide)
3088  }
3089
3090  Tooltip.prototype.show = function () {
3091    var e = $.Event('show.bs.' + this.type)
3092
3093    if (this.hasContent() && this.enabled) {
3094      this.$element.trigger(e)
3095
3096      var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
3097      if (e.isDefaultPrevented() || !inDom) return
3098      var that = this
3099
3100      var $tip = this.tip()
3101
3102      var tipId = this.getUID(this.type)
3103
3104      this.setContent()
3105      $tip.attr('id', tipId)
3106      this.$element.attr('aria-describedby', tipId)
3107
3108      if (this.options.animation) $tip.addClass('w2dc-fade')
3109
3110      var placement = typeof this.options.placement == 'function' ?
3111        this.options.placement.call(this, $tip[0], this.$element[0]) :
3112        this.options.placement
3113
3114      var autoToken = /\s?auto?\s?/i
3115      var autoPlace = autoToken.test(placement)
3116      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
3117
3118      $tip
3119        .detach()
3120        .css({ top: 0, left: 0, display: 'block' })
3121        .addClass('w2dc-'+placement)
3122        .data('bs.' + this.type, this)
3123
3124      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
3125      this.$element.trigger('inserted.bs.' + this.type)
3126
3127      var pos          = this.getPosition()
3128      var actualWidth  = $tip[0].offsetWidth
3129      var actualHeight = $tip[0].offsetHeight
3130
3131      if (autoPlace) {
3132        var orgPlacement = placement
3133        var viewportDim = this.getPosition(this.$viewport)
3134
3135        placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top'    :
3136                    placement == 'top'    && pos.top    - actualHeight < viewportDim.top    ? 'bottom' :
3137                    placement == 'right'  && pos.right  + actualWidth  > viewportDim.width  ? 'left'   :
3138                    placement == 'left'   && pos.left   - actualWidth  < viewportDim.left   ? 'right'  :
3139                    placement
3140
3141        $tip
3142          .removeClass(orgPlacement)
3143          .addClass(placement)
3144      }
3145
3146      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
3147
3148      this.applyPlacement(calculatedOffset, placement)
3149
3150      var complete = function () {
3151        var prevHoverState = that.hoverState
3152        that.$element.trigger('shown.bs.' + that.type)
3153        that.hoverState = null
3154
3155        if (prevHoverState == 'out') that.leave(that)
3156      }
3157
3158      $.support.transition && this.$tip.hasClass('w2dc-fade') ?
3159        $tip
3160          .one('bsTransitionEnd', complete)
3161          .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
3162        complete()
3163    }
3164  }
3165
3166  Tooltip.prototype.applyPlacement = function (offset, placement) {
3167    var $tip   = this.tip()
3168    var width  = $tip[0].offsetWidth
3169    var height = $tip[0].offsetHeight
3170
3171    // manually read margins because getBoundingClientRect includes difference
3172    var marginTop = parseInt($tip.css('margin-top'), 10)
3173    var marginLeft = parseInt($tip.css('margin-left'), 10)
3174
3175    // we must check for NaN for ie 8/9
3176    if (isNaN(marginTop))  marginTop  = 0
3177    if (isNaN(marginLeft)) marginLeft = 0
3178
3179    offset.top  += marginTop
3180    offset.left += marginLeft
3181
3182    // $.fn.offset doesn't round pixel values
3183    // so we use setOffset directly with our own function B-0
3184    $.offset.setOffset($tip[0], $.extend({
3185      using: function (props) {
3186        $tip.css({
3187          top: Math.round(props.top),
3188          left: Math.round(props.left)
3189        })
3190      }
3191    }, offset), 0)
3192
3193    $tip.addClass('w2dc-in')
3194
3195    // check to see if placing tip in new offset caused the tip to resize itself
3196    var actualWidth  = $tip[0].offsetWidth
3197    var actualHeight = $tip[0].offsetHeight
3198
3199    if (placement == 'top' && actualHeight != height) {
3200      offset.top = offset.top + height - actualHeight
3201    }
3202
3203    var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
3204
3205    if (delta.left) offset.left += delta.left
3206    else offset.top += delta.top
3207
3208    var isVertical          = /top|bottom/.test(placement)
3209    var arrowDelta          = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
3210    var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
3211
3212    $tip.offset(offset)
3213    this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
3214  }
3215
3216  Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
3217    this.arrow()
3218      .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
3219      .css(isVertical ? 'top' : 'left', '')
3220  }
3221
3222  Tooltip.prototype.setContent = function () {
3223    var $tip  = this.tip()
3224    var title = this.getTitle()
3225
3226    $tip.find('.w2dc-tooltip-inner')[this.options.html ? 'html' : 'text'](title)
3227    $tip.removeClass('w2dc-fade w2dc-in w2dc-top w2dc-bottom w2dc-left w2dc-right')
3228  }
3229
3230  Tooltip.prototype.hide = function (callback) {
3231    var that = this
3232    var $tip = $(this.$tip)
3233    var e    = $.Event('hide.bs.' + this.type)
3234
3235    function complete() {
3236      if (that.hoverState != 'in') $tip.detach()
3237      that.$element
3238        .removeAttr('aria-describedby')
3239        .trigger('hidden.bs.' + that.type)
3240      callback && callback()
3241    }
3242
3243    this.$element.trigger(e)
3244
3245    if (e.isDefaultPrevented()) return
3246
3247    $tip.removeClass('w2dc-in')
3248
3249    $.support.transition && $tip.hasClass('w2dc-fade') ?
3250      $tip
3251        .one('bsTransitionEnd', complete)
3252        .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
3253      complete()
3254
3255    this.hoverState = null
3256
3257    return this
3258  }
3259
3260  Tooltip.prototype.fixTitle = function () {
3261    var $e = this.$element
3262    if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
3263      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
3264    }
3265  }
3266
3267  Tooltip.prototype.hasContent = function () {
3268    return this.getTitle()
3269  }
3270
3271  Tooltip.prototype.getPosition = function ($element) {
3272    $element   = $element || this.$element
3273
3274    var el     = $element[0]
3275    var isBody = el.tagName == 'BODY'
3276
3277    var elRect    = el.getBoundingClientRect()
3278    if (elRect.width == null) {
3279      // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
3280      elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
3281    }
3282    var elOffset  = isBody ? { top: 0, left: 0 } : $element.offset()
3283    var scroll    = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
3284    var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
3285
3286    return $.extend({}, elRect, scroll, outerDims, elOffset)
3287  }
3288
3289  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
3290    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2 } :
3291           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
3292           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
3293           							{ top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
3294
3295  }
3296
3297  Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
3298    var delta = { top: 0, left: 0 }
3299    if (!this.$viewport) return delta
3300
3301    var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
3302    var viewportDimensions = this.getPosition(this.$viewport)
3303
3304    if (/right|left/.test(placement)) {
3305      var topEdgeOffset    = pos.top - viewportPadding - viewportDimensions.scroll
3306      var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
3307      if (topEdgeOffset < viewportDimensions.top) { // top overflow
3308        delta.top = viewportDimensions.top - topEdgeOffset
3309      } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
3310        delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
3311      }
3312    } else {
3313      var leftEdgeOffset  = pos.left - viewportPadding
3314      var rightEdgeOffset = pos.left + viewportPadding + actualWidth
3315      if (leftEdgeOffset < viewportDimensions.left) { // left overflow
3316        delta.left = viewportDimensions.left - leftEdgeOffset
3317      } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
3318        delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
3319      }
3320    }
3321
3322    return delta
3323  }
3324
3325  Tooltip.prototype.getTitle = function () {
3326    var title
3327    var $e = this.$element
3328    var o  = this.options
3329
3330    title = $e.attr('data-original-title')
3331      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
3332
3333    return title
3334  }
3335
3336  Tooltip.prototype.getUID = function (prefix) {
3337    do prefix += ~~(Math.random() * 1000000)
3338    while (document.getElementById(prefix))
3339    return prefix
3340  }
3341
3342  Tooltip.prototype.tip = function () {
3343    if (!this.$tip) {
3344      this.$tip = $(this.options.template)
3345      if (this.$tip.length != 1) {
3346        throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
3347      }
3348    }
3349    return this.$tip
3350  }
3351
3352  Tooltip.prototype.arrow = function () {
3353    return (this.$arrow = this.$arrow || this.tip().find('.w2dc-tooltip-arrow'))
3354  }
3355
3356  Tooltip.prototype.enable = function () {
3357    this.enabled = true
3358  }
3359
3360  Tooltip.prototype.disable = function () {
3361    this.enabled = false
3362  }
3363
3364  Tooltip.prototype.toggleEnabled = function () {
3365    this.enabled = !this.enabled
3366  }
3367
3368  Tooltip.prototype.toggle = function (e) {
3369    var self = this
3370    if (e) {
3371      self = $(e.currentTarget).data('bs.' + this.type)
3372      if (!self) {
3373        self = new this.constructor(e.currentTarget, this.getDelegateOptions())
3374        $(e.currentTarget).data('bs.' + this.type, self)
3375      }
3376    }
3377
3378    if (e) {
3379      self.inState.click = !self.inState.click
3380      if (self.isInStateTrue()) self.enter(self)
3381      else self.leave(self)
3382    } else {
3383      self.tip().hasClass('w2dc-in') ? self.leave(self) : self.enter(self)
3384    }
3385  }
3386
3387  Tooltip.prototype.destroy = function () {
3388    var that = this
3389    clearTimeout(this.timeout)
3390    this.hide(function () {
3391      that.$element.off('.' + that.type).removeData('bs.' + that.type)
3392      if (that.$tip) {
3393        that.$tip.detach()
3394      }
3395      that.$tip = null
3396      that.$arrow = null
3397      that.$viewport = null
3398    })
3399  }
3400
3401
3402  // TOOLTIP PLUGIN DEFINITION
3403  // =========================
3404
3405  function Plugin(option) {
3406    return this.each(function () {
3407      var $this   = $(this)
3408      var data    = $this.data('bs.w2dc_tooltip')
3409      var options = typeof option == 'object' && option
3410
3411      if (!data && /destroy|hide/.test(option)) return
3412      if (!data) $this.data('bs.w2dc_tooltip', (data = new Tooltip(this, options)))
3413      if (typeof option == 'string') data[option]()
3414    })
3415  }
3416
3417  var old = $.fn.w2dc_tooltip
3418
3419  $.fn.w2dc_tooltip             = Plugin
3420  $.fn.w2dc_tooltip.Constructor = Tooltip
3421
3422
3423  // TOOLTIP NO CONFLICT
3424  // ===================
3425
3426  $.fn.w2dc_tooltip.noConflict = function () {
3427    $.fn.w2dc_tooltip = old
3428    return this
3429  }
3430
3431}(jQuery);
3432
3433/* ========================================================================
3434 * Bootstrap: popover.js v3.3.5
3435 * http://getbootstrap.com/javascript/#popovers
3436 * ========================================================================
3437 * Copyright 2011-2015 Twitter, Inc.
3438 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
3439 * ======================================================================== */
3440+function ($) {
3441  'use strict';
3442
3443  // POPOVER PUBLIC CLASS DEFINITION
3444  // ===============================
3445
3446  var Popover = function (element, options) {
3447    this.init('w2dc_popover', element, options)
3448  }
3449
3450  if (!$.fn.w2dc_tooltip) throw new Error('Popover requires tooltip.js')
3451
3452  Popover.VERSION  = '3.3.5'
3453
3454  Popover.DEFAULTS = $.extend({}, $.fn.w2dc_tooltip.Constructor.DEFAULTS, {
3455    placement: 'right',
3456    trigger: 'click',
3457    content: '',
3458    template: '<div class="w2dc-popover" role="tooltip"><div class="w2dc-arrow"></div><h3 class="w2dc-popover-title"></h3><div class="w2dc-popover-content"></div></div>'
3459  })
3460
3461
3462  // NOTE: POPOVER EXTENDS tooltip.js
3463  // ================================
3464
3465  Popover.prototype = $.extend({}, $.fn.w2dc_tooltip.Constructor.prototype)
3466
3467  Popover.prototype.constructor = Popover
3468
3469  Popover.prototype.getDefaults = function () {
3470    return Popover.DEFAULTS
3471  }
3472
3473  Popover.prototype.setContent = function () {
3474    var $tip    = this.tip()
3475    var title   = this.getTitle()
3476    var content = this.getContent()
3477
3478    $tip.find('.w2dc-popover-title')[this.options.html ? 'html' : 'text'](title)
3479    $tip.find('.w2dc-popover-content').children().detach().end()[ // we use append for html objects to maintain js events
3480      this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
3481    ](content)
3482
3483    $tip.removeClass('w2dc-fade w2dc-top w2dc-bottom w2dc-left w2dc-right w2dc-in')
3484
3485    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
3486    // this manually by checking the contents.
3487    if (!$tip.find('.w2dc-popover-title').html()) $tip.find('.w2dc-popover-title').hide()
3488  }
3489
3490  Popover.prototype.hasContent = function () {
3491    return this.getTitle() || this.getContent()
3492  }
3493
3494  Popover.prototype.getContent = function () {
3495    var $e = this.$element
3496    var o  = this.options
3497
3498    return $e.attr('data-content')
3499      || (typeof o.content == 'function' ?
3500            o.content.call($e[0]) :
3501            o.content)
3502  }
3503
3504  Popover.prototype.arrow = function () {
3505    return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
3506  }
3507  // POPOVER PLUGIN DEFINITION
3508  // =========================
3509
3510  function Plugin(option) {
3511    return this.each(function () {
3512      var $this   = $(this)
3513      var data    = $this.data('bs.w2dc_popover')
3514      var options = typeof option == 'object' && option
3515
3516      if (!data && /destroy|hide/.test(option)) return
3517      if (!data) $this.data('bs.w2dc_popover', (data = new Popover(this, options)))
3518      if (typeof option == 'string') data[option]()
3519    })
3520  }
3521
3522  var old = $.fn.w2dc_popover
3523
3524  $.fn.w2dc_popover             = Plugin
3525  $.fn.w2dc_popover.Constructor = Popover
3526
3527
3528  // POPOVER NO CONFLICT
3529  // ===================
3530
3531  $.fn.w2dc_popover.noConflict = function () {
3532    $.fn.popover = old
3533    return this
3534  }
3535
3536}(jQuery);
3537
3538
3539
3540// jquery.tokenize.js -------------------------------------------------------------------------------------------------------------------------------------------
3541!function(e){var t={BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,ARROW_UP:38,ARROW_DOWN:40},n=null,o="tokenize",s=function(t,n){if(!n.data(o)){var s=new e.tokenize(e.extend({},e.fn.tokenize.defaults,t));n.data(o,s),s.init(n)}return n.data(o)};e.tokenize=function(t){void 0==t&&(t=e.fn.tokenize.defaults),this.options=t},e.extend(e.tokenize.prototype,{init:function(t){var n=this;this.select=t.attr("multiple","multiple").css({margin:0,padding:0,border:0}).hide(),this.container=e("<div />").attr("class",this.select.attr("class")).addClass("Tokenize"),1==this.options.maxElements&&this.container.addClass("OnlyOne"),this.dropdown=e("<ul />").addClass("Dropdown"),this.tokensContainer=e("<ul />").addClass("TokensContainer"),this.options.autosize&&this.tokensContainer.addClass("Autosize"),this.searchToken=e("<li />").addClass("TokenSearch").appendTo(this.tokensContainer),this.searchInput=e("<input />").appendTo(this.searchToken),this.options.searchMaxLength>0&&this.searchInput.attr("maxlength",this.options.searchMaxLength),this.select.prop("disabled")&&this.disable(),this.options.sortable&&("undefined"!=typeof e.ui?this.tokensContainer.sortable({items:"li.Token",cursor:"move",placeholder:"Token MovingShadow",forcePlaceholderSize:!0,update:function(){n.updateOrder()},start:function(){n.searchToken.hide()},stop:function(){n.searchToken.show()}}
3541).disableSelection():(this.options.sortable=!1,console.log("jQuery UI is not loaded, sortable option has been disabled"))),this.container.append(this.tokensContainer).append(this.dropdown).insertAfter(this.select),this.tokensContainer.on("click",function(e){e.stopImmediatePropagation(),n.searchInput.get(0).focus(),n.updatePlaceholder(),n.dropdown.is(":hidden")&&""!=n.searchInput.val()&&n.search()}),this.searchInput.on("blur",function(){n.tokensContainer.removeClass("Focused")}),this.searchInput.on("focus click",function(){n.tokensContainer.addClass("Focused"),n.options.displayDropdownOnFocus&&"select"==n.options.datas&&n.search()}),this.searchInput.on("keydown",function(e){n.resizeSearchInput(),n.keydown(e)}),this.searchInput.on("keyup",function(e){n.keyup(e)}),this.searchInput.on("keypress",function(e){n.keypress(e)}),this.searchInput.on("paste",function(){setTimeout(function(){n.resizeSearchInput()},10),setTimeout(function(){var t=n.searchInput.val().split(",");t.length>1&&e.each(t,function(e,t){n.tokenAdd(t.trim(),"")})},20)}),e(document).on("click",function(){n.dropdownHide(),1==n.options.maxElements&&n.searchInput.val()&&n.tokenAdd(n.searchInput.val(),"")}),this.resizeSearchInput(),this.remap(!0),this.updatePlaceholder()},updateOrder:function(){if(this.options.sortable){var t,n,o=this;e.each(this.tokensContainer.sortable("toArray",{attribute:"data-value"}),function(s,i){n=e('option[value="'+i+'"]',o.select),void 0==t?n.prependTo(o.select):t.after(n),t=n}),this.options.onReorder(this)}},updatePlaceholder:function(){0!=this.options.placeholder&&(void 0==this.placeholder&&(this.placeholder=e("<li />").addClass("Placeholder").html(this.options.placeholder),this.placeholder.insertBefore(e("li:first-child",this.tokensContainer))),0==this.searchInput.val().length&&0==e("li.Token",this.tokensContainer).length?this.placeholder.show():this.placeholder.hide())},dropdownShow:function(){this.dropdown.show()},dropdownPrev:function(){e("li.Hover",this.dropdown).length>0?e("li.Hover",this.dropdown).is("li:first-child")?(e("li.Hover",this.dropdown).removeClass("Hover"),e("li:last-child",this.dropdown).addClass("Hover")):e("li.Hover",this.dropdown).removeClass("Hover").prev().addClass("Hover"):e("li:first",this.dropdown).addClass("Hover")},dropdownNext:function(){e("li.Hover",this.dropdown).length>0?e("li.Hover",this.dropdown).is("li:last-child")?(e("li.Hover",this.dropdown).removeClass("Hover"),e("li:first-child",this.dropdown).addClass("Hover")):e("li.Hover",this.dropdown).removeClass("Hover").next().addClass("Hover"):e("li:first",this.dropdown).addClass("Hover")},dropdownAddItem:function(t,n,o){if(void 0==o&&(o=n),!e('li[data-value="'+t+'"]',this.tokensContainer).length){var s=this,i=e("<li />").attr("data-value",t).attr("data-text",n).html(o).on("click",function(t){t.stopImmediatePropagation(),s.tokenAdd(e(this).attr("data-value"),e(this).attr("data-text"))}).on("mouseover",function(){e(this).addClass("Hover")}).on("mouseout",function(){e("li",s.dropdown).removeClass("Hover")});this.dropdown.append(i),this.options.onDropdownAddItem(t,n,o,this)}return this},dropdownHide:function(){this.dropdownReset(),this.dropdown.hide()},dropdownReset:function(){this.dropdown.html("")},resizeSearchInput:function(){this.searchInput.attr("size",Number(this.searchInput.val().length)+5),this.updatePlaceholder()},resetSearchInput:function(){this.searchInput.val(""),this.resizeSearchInput()},resetPendingTokens:function(){e("li.PendingDelete",this.tokensContainer).removeClass("PendingDelete")},keypress:function(e){String.fromCharCode(e.which)==this.options.delimiter&&(e.preventDefault(),this.tokenAdd(this.searchInput.val(),""))},keydown:function(n){switch(n.keyCode){case t.BACKSPACE:0==this.searchInput.val().length&&(n.preventDefault(),e("li.Token.PendingDelete",this.tokensContainer).length?this.tokenRemove(e("li.Token.PendingDelete").attr("data-value")):e("li.Token:last",this.tokensContainer).addClass("PendingDelete"),this.dropdownHide());break;case t.TAB:case t.ENTER:if(e("li.Hover",this.dropdown).length){var o=e("li.Hover",this.dropdown);n.preventDefault(),this.tokenAdd(o.attr("data-value"),o.attr("data-text"))}else this.searchInput.val()&&(n.preventDefault(),this.tokenAdd(this.searchInput.val(),""));this.resetPendingTokens();break;case t.ESCAPE:this.resetSearchInput(),this.dropdownHide(),this.resetPendingTokens();break;case t.ARROW_UP:n.preventDefault(),this.dropdownPrev();break;case t.ARROW_DOWN:n.preventDefault(),this.dropdownNext();break;default:this.resetPendingTokens()}},keyup:function(e){switch(this.updatePlaceholder(),e.keyCode){case t.TAB:case t.ENTER:case t.ESCAPE:case t.ARROW_UP:case t.ARROW_DOWN:break;case t.BACKSPACE:this.searchInput.val()?this.search():this.dropdownHide();break;default:this.searchInput.val()&&this.search()}},search:function(){var t=this,n=1;if(this.options.maxElements>0&&e("li.Token",this.tokensContainer).length>=this.options.maxElements)return!1;if("select"==this.options.datas){var o=!1,s=new RegExp(this.searchInput.val().replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i");this.dropdownReset(),e("option",this.select).not(":selected, :disabled").each(function(){return n<=t.options.nbDropdownElements?void(s.test(e(this).html())&&(t.dropdownAddItem(e(this).attr("value"),e(this).html()),o=!0,n++)):!1}),o?(e("li:first",this.dropdown).addClass("Hover"),this.dropdownShow()):this.dropdownHide()}else this.debounce(function(){e.ajax({url:t.options.datas,data:t.options.searchParam+"="+t.searchInput.val(),dataType:t.options.dataType,success:function(o){return o&&(t.dropdownReset(),e.each(o,function(e,o){if(!(n<=t.options.nbDropdownElements))return!1;var s=void 0;o[t.options.htmlField]&&(s=o[t.options.htmlField]),t.dropdownAddItem(o[t.options.valueField],o[t.options.textField],s),n++}),e("li",t.dropdown).length)?(e("li:first",t.dropdown).addClass("Hover"),t.dropdownShow(),!0):void t.dropdownHide()},error:function(e,t){console.log("Error : "+t)}})},this.options.debounce)},debounce:function(e,t){var o=this,s=arguments,i=function(){e.apply(o,s),n=null};n&&clearTimeout(n),n=setTimeout(i,t||this.options.debounce)},tokenAdd:function(t,n,o){if(t=this.escape(t),void 0==t||""==t)return this;if((void 0==n||""==n)&&(n=t),void 0==o&&(o=!1),this.options.maxElements>0&&e("li.Token",this.tokensContainer).length>=this.options.maxElements)return this.resetSearchInput(),this;var s=this,i=e("<a />").addClass("Close").html("&#215;").on("click",function(e){e.stopImmediatePropagation(),s.tokenRemove(t)});if(e('option[value="'+t+'"]',this.select).length)e('option[value="'+t+'"]',this.select).attr("selected",!0).prop("selected",!0);else{if(!(this.options.newElements||!this.options.newElements&&e('li[data-value="'+t+'"]',this.dropdown).length>0))return this.resetSearchInput(),this;var a=e("<option />").attr("selected",!0).attr("value",t).attr("data-type","custom").prop("selected",!0).html(n);this.select.append(a)}return e('li.Token[data-value="'+t+'"]',this.tokensContainer).length>0?this:(e("<li />").addClass("Token").attr("data-value",t).append("<span>"+n+"</span>").prepend(i).insertBefore(this.searchToken),o||this.options.onAddToken(t,n,this),this.resetSearchInput(),this.dropdownHide(),this.updateOrder(),this)},tokenRemove:function(t){var n=e('option[value="'+t+'"]',this.select);return"custom"==n.attr("data-type")?n.remove():n.removeAttr("selected").prop("selected",!1),e('li.Token[data-value="'+t+'"]',this.tokensContainer).remove(),this.options.onRemoveToken(t,this),this.resizeSearchInput(),this.dropdownHide(),this.updateOrder(),this},clear:function(){var t=this;return e("li.Token",this.tokensContainer).each(function(){t.tokenRemove(e(this).attr("data-value"))}),this.options.onClear(this),this.dropdownHide(),this},disable:function(){return this.select.prop("disabled",!0),this.searchInput.prop("disabled",!0),this.container.addClass("Disabled"),this.options.sortable&&this.tokensContainer.sortable("disable"),this},enable:function(){return this.select.prop("disabled",!1),this.searchInput.prop("disabled",!1),this.container.removeClass("Disabled"),this.options.sortable&&this.tokensContainer.sortable("enable"),this},remap:function(t){var n=this,o=e("option:selected",this.select);return void 0==t&&(t=!1),this.clear(),o.each(function(){n.tokenAdd(e(this).val(),e(this).html(),t)}),this},toArray:function(){var t=[];return e("option:selected",this.select).each(function(){t.push(e(this).val())}),t},escape:function(e){return String(e).replace(/["]/g,function(){return""})}}),e.fn.tokenize=function(t){void 0==t&&(t={});var n=this.filter("select");return n.length>1?(n.each(function(){s(t,e(this))}),n):s(t,e(this))},e.fn.tokenize.defaults={datas:"select",placeholder:!1,searchParam:"search",searchMaxLength:0,debounce:0,delimiter:",",newElements:!0,autosize:!1,nbDropdownElements:10,displayDropdownOnFocus:!1,maxElements:0,sortable:!1,dataType:"json",valueField:"value",textField:"text",htmlField:"html",onAddToken:function(){},onRemoveToken:function(){},onClear:function(){},onReorder:function(){},onDropdownAddItem:function(){}}}(jQuery,"tokenize");

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.