PageSourceSearch

http://unitednews.sr/wp-content/plugins/w2dc/resources/js/js_functions.js?ver=2.9.12

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