
; /* Start:"a:4:{s:4:"full";s:128:"/bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default/script.js?155022351128815";s:6:"source";s:112:"/bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
function JCSmartFilter(ajaxURL, viewMode, params)
{
	var self = this;
	this.params = params;
	this.ajaxURL = ajaxURL;
	this.form = document.getElementById('smartfilter') || null;
	this.timer = null;
	this.cacheKey = '';
	this.cache = [];
	this.viewMode = viewMode;
	if (params && params.SEF_SET_FILTER_URL)
	{
		this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL);
		this.sef = true;
	}
	if (params && params.SEF_DEL_FILTER_URL)
	{
		this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL);
	}

	// init
	;(function () {
		cui.clickOff($('.citrus-sf-field'), function ($el) {
			self.toggleValues();
		});
		$(document).on('keyup', function (event) {
			if (event.key === 'Escape') self.toggleValues();
		});
		//update values
		self.updateLabelValues($(self.form).find('.citrus-sf-field'));
	
		if (typeof currency !== 'undefined')
			currency.updateHtml($(self.form));
	
		//update duplicate values
		self.updateDuplicate();

		$(self.form).on('submit', function(event) {
			$(self.form).find('[data-real-value]').each(function (index, item) {
				$(item).val($(item).data('real-value'));
			});
			return true;
		});

		$(document).on('change', '.sf-duplicate__checkbox', function(event) {
		    event.preventDefault();

		    var propertyCode = $(this).data('property-code-for'),
			    arInputId = $(this).data('id').split(';'),
			    $primaryInput = $('#' + arInputId.join(',#')),
		        $primaryBlock = $('[data-property-code="'+propertyCode+'"]'),
		        template = $primaryBlock.data('template'),
		        needUpdate = true;

		    switch (template) {
			    case 'NUMBERS':
				    $primaryInput.val('');
				    $primaryInput.trigger('input');
				    needUpdate = false;
				    break;
			    case 'DROPDOWN':
			    case 'LINE_CHECKBOX':
			    default:
				    $primaryInput.prop('checked', false).trigger('change');
		            break;
		    }
		    if (needUpdate) {
			    self.updateLabelValues($primaryBlock);
		    }
			self.click($primaryInput.get(0));
		});


	}());
}

JCSmartFilter.prototype.keyup = function(input)
{
	var $fieldBlock = $(input).parents('.citrus-sf-field');
	this.updateLabelValues($fieldBlock);

	this.click(input);
};

JCSmartFilter.prototype.clickLabel = function(event, labelNode)
{
	event.preventDefault();
	var $label = $(labelNode),
		$fieldBlock = $label.parents('.citrus-sf-field'),
		$input = $label.find('input');

	if ($label.hasClass('disabled') && !$input.prop('checked')) return;
	$input.prop('checked', !$input.prop('checked'));

	this.updateLabelValues($fieldBlock);
	this.click($input.get(0));
};

JCSmartFilter.prototype.click = function(input)
{
	this.updateDuplicate();
	if(!!this.timer) {
		clearTimeout(this.timer);
	}

	this.timer = setTimeout(BX.delegate(function(){
		this.reload(input);
	}, this), 500);
};

JCSmartFilter.prototype.reload = function(input)
{
	var input = input || $(this.form).find('')
	if (this.cacheKey !== '')
	{
		//Postprone backend query
		if(!!this.timer)
		{
			clearTimeout(this.timer);
		}
		this.timer = setTimeout(BX.delegate(function(){
			this.reload(input);
		}, this), 1000);
		return;
	}
	this.cacheKey = '|';

	this.position = BX.pos(input, true);
	//this.form = BX.findParent(input, {'tag':'form'});

	if (this.form)
	{
		var values = [];
		values[0] = {name: 'ajax', value: 'y'};
		this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true));

		for (var i = 0; i < values.length; i++)
			this.cacheKey += values[i].name + ':' + values[i].value + '|';

		if (this.cache[this.cacheKey])
		{
			this.curFilterinput = input;
			this.postHandler(this.cache[this.cacheKey], true);
		}
		else
		{
			if (this.sef)
			{
				var set_filter = BX('set_filter');
				set_filter.disabled = true;
			}

			this.curFilterinput = input;
			BX.ajax.loadJSON(
				this.ajaxURL,
				this.values2post(values),
				BX.delegate(this.postHandler, this)
			);
		}
	}
};

JCSmartFilter.prototype.updateItem = function (PID, arItem)
{
	if (arItem.PROPERTY_TYPE === 'N' || arItem.PRICE)
	{
		var trackBar = window['smartFilterNumbers' + arItem.ID];
		if (!trackBar && arItem.ENCODED_ID)
			trackBar = window['smartFilterNumbers' + arItem.ENCODED_ID];

		if (trackBar && arItem.VALUES)
		{
			if (arItem.VALUES.MIN)
			{
				if (arItem.VALUES.MIN.FILTERED_VALUE)
					trackBar.setMinFilteredValue(+arItem.VALUES.MIN.FILTERED_VALUE);
				else
					trackBar.setMinFilteredValue(null);
			}

			if (arItem.VALUES.MAX)
			{
				if (arItem.VALUES.MAX.FILTERED_VALUE)
					trackBar.setMaxFilteredValue(+arItem.VALUES.MAX.FILTERED_VALUE);
				else
					trackBar.setMaxFilteredValue(null);
			}
            trackBar.updateFilteredInterval();
		}
	}
	else if (arItem.VALUES)
	{
		for (var i in arItem.VALUES)
		{
			if (arItem.VALUES.hasOwnProperty(i))
			{
				var value = arItem.VALUES[i];
				var control = BX(value.CONTROL_ID);

				if (!!control)
				{
					var label = document.querySelector('[data-role="label_'+value.CONTROL_ID+'"]') || control.parentNode;
					$(label)[(value.DISABLED && !control.checked) ? 'addClass': 'removeClass']('no-clicked');
					if (value.DISABLED)
					{
						if (label) BX.addClass(label, 'disabled');
					}
					else
					{
						if (label) BX.removeClass(label, 'disabled');
					}

					if (value.hasOwnProperty('ELEMENT_COUNT'))
					{
						label = document.querySelector('[data-role="count_'+value.CONTROL_ID+'"]');
						if (label)
							label.innerHTML = value.ELEMENT_COUNT;
					}
				}
			}
		}
	}
};

JCSmartFilter.prototype.postHandler = function (result, fromCache)
{
	var hrefFILTER, url;
	var modef_num = BX('modef_num');

	if (!!result && !!result.ITEMS)
	{
		for(var PID in result.ITEMS)
		{
			if (result.ITEMS.hasOwnProperty(PID))
			{
				this.updateItem(PID, result.ITEMS[PID]);
			}
		}

		if (!!modef_num)
		{
			modef_num.innerHTML = result.ELEMENT_COUNT;

			if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID)
			{
				url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
				BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
			}
			else
			{
				if (result.SEF_SET_FILTER_URL)
				{
					this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL);
				}
			}
		}
	}

	if (this.sef)
	{
		var set_filter = BX('set_filter');
		set_filter.disabled = false;
	}

	if (!fromCache && this.cacheKey !== '')
	{
		this.cache[this.cacheKey] = result;
	}
	this.cacheKey = '';
};

JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url)
{
	var button = BX(buttonId);
	if (button)
	{
		var proxy = function(j, func)
		{
			return function()
			{
				return func(j);
			}
		};

		if (button.type == 'submit')
			button.type = 'button';

		BX.bind(button, 'click', proxy(url, function(url)
		{
			window.location.href = url;
			return false;
		}));
	}
};

JCSmartFilter.prototype.gatherInputsValues = function (values, elements)
{
	if(elements)
	{
		for(var i = 0; i < elements.length; i++)
		{
			var el = elements[i];
			if (el.disabled || !el.type || !el.name)
				continue;

			switch(el.type.toLowerCase())
			{
				case 'text':
				case 'textarea':
				case 'password':
				case 'hidden':
				case 'select-one':
					var val = el.value;
					
					if ($(el).data('real-value')) {
						val = $(el).data('real-value');
					}
					
					if(el.value.length)
						values[values.length] = {name : el.name, value : val};
					break;
				case 'radio':
				case 'checkbox':
					if(el.checked)
						values[values.length] = {name : el.name, value : el.value};
					break;
				case 'select-multiple':
					for (var j = 0; j < el.options.length; j++)
					{
						if (el.options[j].selected)
							values[values.length] = {name : el.name, value : el.options[j].value};
					}
					break;
				default:
					break;
			}
		}
	}
};

JCSmartFilter.prototype.values2post = function (values)
{
	var post = [];
	var current = post;
	var i = 0;

	while(i < values.length)
	{
		var p = values[i].name.indexOf('[');
		if(p == -1)
		{
			current[values[i].name] = values[i].value;
			current = post;
			i++;
		}
		else
		{
			var name = values[i].name.substring(0, p);
			var rest = values[i].name.substring(p+1);
			if(!current[name])
				current[name] = [];

			var pp = rest.indexOf(']');
			if(pp == -1)
			{
				//Error - not balanced brackets
				current = post;
				i++;
			}
			else if(pp == 0)
			{
				//No index specified - so take the next integer
				current = current[name];
				values[i].name = '' + current.length;
			}
			else
			{
				//Now index name becomes and name and we go deeper into the array
				current = current[name];
				values[i].name = rest.substring(0, pp) + rest.substring(pp+1);
			}
		}
	}
	return post;
};

JCSmartFilter.prototype.hideFilterProps = function(element)
{
	var obj = element.parentNode,
		filterBlock = obj.querySelector("[data-role='bx_filter_block']"),
		propAngle = obj.querySelector("[data-role='prop_angle']");

	if(BX.hasClass(obj, "bx-active"))
	{
		new BX.easing({
			duration : 300,
			start : { opacity: 1,  height: filterBlock.offsetHeight },
			finish : { opacity: 0, height:0 },
			transition : BX.easing.transitions.quart,
			step : function(state){
				filterBlock.style.opacity = state.opacity;
				filterBlock.style.height = state.height + "px";
			},
			complete : function() {
				filterBlock.setAttribute("style", "");
				BX.removeClass(obj, "bx-active");
			}
		}).animate();

		BX.addClass(propAngle, "fa-angle-down");
		BX.removeClass(propAngle, "fa-angle-up");
	}
	else
	{
		filterBlock.style.display = "block";
		filterBlock.style.opacity = 0;
		filterBlock.style.height = "auto";

		var obj_children_height = filterBlock.offsetHeight;
		filterBlock.style.height = 0;

		new BX.easing({
			duration : 300,
			start : { opacity: 0,  height: 0 },
			finish : { opacity: 1, height: obj_children_height },
			transition : BX.easing.transitions.quart,
			step : function(state){
				filterBlock.style.opacity = state.opacity;
				filterBlock.style.height = state.height + "px";
			},
			complete : function() {
			}
		}).animate();

		BX.addClass(obj, "bx-active");
		BX.removeClass(propAngle, "fa-angle-down");
		BX.addClass(propAngle, "fa-angle-up");
	}
};



/**
 * citrus custom function
 * */
//add values to label
JCSmartFilter.prototype.updateLabelValues = function ($fieldBlock) {
	if (!$fieldBlock.length) return;

	$fieldBlock.each(function () {
		var $block = $(this),
			template = $block.data('template'),
			$labelValue = $block.find('.citrus-sf-label_value');

		var addValue = function (value) {
			var html = '';
			if (value) html = '('+value+')';
			$block[value ? 'addClass' : 'removeClass']('has-value');

			$labelValue.html(html);
		};

		switch(template){
			case 'DROPDOWN':
				var $checkedText = $block.find('input:checked').parent().find('.citrus-select__item-name');
				var arText = [];
				$checkedText.each(function (index, item) {
					var text = $(item).html().trim();
					if (text.length) arText.push(text);
				});
				addValue(arText.join(', '));
				break;
			case 'LINE_CHECKBOX':
				var $checkedText = $block.find('input:checked').next('.line-checkbox__item-label');
				var arText = [];
				$checkedText.each(function (index, item) {
					var text = $(item).html().trim();
					if (text.length) arText.push(text);
				});
				addValue(arText.join(', '));
				break;
      case 'NUMBERS':
				var text = '',
					$minInput = $block.find('.filter-numbers_input._min'),
					$maxInput = $block.find('.filter-numbers_input._max'),
					minValue = $minInput.val(),
					maxValue = $maxInput.val();
				if (minValue || maxValue) {
					text += minValue ? minValue : $minInput.data('default-value');
					text += ' &ndash; ';
					text += maxValue ? maxValue : $maxInput.data('default-value');
				}
				addValue(text);
				break;
		}
		var $label = $block.find('.citrus-sf-label');
	});
};
//dropdown search
JCSmartFilter.prototype.searchDropdownItem = function (event, el) {
	var $searchInput = $(el),
		$container = $searchInput.parents('.citrus-sf-field'),
		searchText = $searchInput.val().trim(),
		searchParts = searchText.toLowerCase().replace(/,/g, "").split(' '),
		$items = $container.find('.citrus-select__item'),
		$selectAllLink = $container.find('.citrus-select__chose-all'),
		foundItems = 0;
	
	if (searchText.length && searchParts.length) {
		$items.each(function (index, item) {
			
			var $item = $(item),
				matched = searchParts.reduce(function(matched, searchPart) {
					return matched && $item.find('.citrus-select__item-name').text().toLocaleLowerCase().indexOf(searchPart) > -1;
				}, true);
			
			$item[matched ? 'removeClass' : 'addClass']('_search-filtered');
			if (matched) foundItems++;
		});
	}
	else {
		$items.removeClass('_search-filtered');
	}
	
	$selectAllLink[foundItems && searchText.length ? 'removeClass' : 'addClass']('hidden');
};
JCSmartFilter.prototype.choseAllDropdownItems = function(event, el){
	var $link = $(el),
		$container = $link.parents('.citrus-sf-field'),
		$foundItemCheckbox = $container.find('.citrus-select__item:not(._search-filtered):not(.disabled) input'),
		alreadyChecked = $foundItemCheckbox.length === $foundItemCheckbox.filter(':checked').length;
	
	$foundItemCheckbox.prop('checked', !alreadyChecked);
	this.click($foundItemCheckbox.first().get(0));
	this.updateLabelValues($container);
};
JCSmartFilter.prototype.toggleExpanded = function (e) {
	$(this.form).toggleClass("_open");
};
JCSmartFilter.prototype.clearField = function($fieldBlock){
	$fieldBlock.find('input:checkbox').prop('checked', false).trigger('clear');
	$fieldBlock.find('input:text').val('').trigger('clear');
	if ($fieldBlock.find('.citrus-select__search-input').length) $fieldBlock.find('.citrus-select__search-input').trigger('keyup');

	this.click($fieldBlock.find('input:first').get(0));
};
JCSmartFilter.prototype.toggleValues = function (el, event) {
	var $clearFieldBtn = $('.citrus-sf-label_close');
	var $field = $(el).parents('.citrus-sf-field');

	if (cui.ifdefined(event) && ($clearFieldBtn.is(event.target) || $clearFieldBtn.has(event.target).length)) {
		this.clearField($field);
		this.updateLabelValues($field);
		return;
	}

	if(cui.ifdefined(el)) {
		$('.citrus-sf-field').not($field).removeClass('_open');
		$field.toggleClass('_open');

		if ($field.hasClass('_open') && $field.find('.citrus-select__search-input').length ) $field.find('.citrus-select__search-input').focus();
	} else {
		$('.citrus-sf-field._open').removeClass('_open');
	}

};

JCSmartFilter.prototype.updateDuplicate = function () {
	var self = this;
	var $fieldBlock = $(this.form).find('.citrus-sf-field'),
		selectedPropertyValues = [],
		$duplicate = $('#sf-duplicate');

	var updateView = function (data) {
		$duplicate[ data.length ? 'removeClass':'addClass']('hidden');
		var html = '<div class="sf-duplicate__property-list">';
		
		$(data).each(function (index, property) {
			
			if (property.items.length > 10) {
				property.items = [
					{
						'name': self.params.LANG.VALUES + ' <b>'+property.items.length+'</b>',
						'id': property.items.reduce(function (str, item) {
							if (str.length) str += ';';
							return str+=item.id
						},'')
					}
				]
			}
			
			html +=
			'<div class="sf-duplicate__property-item">' +
				'<div class="sf-duplicate__property-name">'+property.title+':</div>' +
				'<div class="sf-duplicate__value-list">';

				$(property.items).each(function (index, item) {
					html +=
						'<div class="sf-duplicate__value-item">'+
							'<label class="sf-duplicate__value-label">'+
								'<input class="hidden sf-duplicate__checkbox" type="checkbox" data-id="'+item.id+'" checked="checked" data-property-code-for="'+property.code+'"/>'+
								'<span class="filter-checkmark"></span>'+
								'<div class="sf-duplicate__value-name">'+item.name+'</div>'+
							'</label>'+
						'</div>';
				});
			html +=
				'</div>' +
			'</div>';
		});
		html += '</div>';
		$duplicate.html(html);
	};

	var addValues = function (index, item) {
		var $item = $(item),
			isCombine = $item.data('combine');

		if (isCombine) {
			$item.find('[data-property-code]').each(addValues);
			return;
		}

		var propertyCode = $item.data('property-code'),
			template = $item.data('template'),
			itemSelectedPropertyValues = {
				code: propertyCode,
				title: $item.data('name') || $item.find('.citrus-sf-label_name').html(),
				items: []
			};

		switch (template) {
			case 'NUMBERS':
				var $minInput = $item.find('.filter-numbers_input._min'),
					$maxInput = $item.find('.filter-numbers_input._max'),
					minValue = $minInput.val(),
					maxValue = $maxInput.val();

				if (minValue) {
					itemSelectedPropertyValues.items.push({
						id: $minInput.prop('id'),
						name: self.params.LANG.FROM+' '+minValue
					});
				}
				if (maxValue) {
					itemSelectedPropertyValues.items.push({
						id: $maxInput.prop('id'),
						name: self.params.LANG.TO+' '+maxValue
					});
				}
				break;
			default:
				var $checkedInputs = $item.find('input:checked');
				$checkedInputs.each(function (index, checkbox) {
					var selectedItem = {
						id: $(checkbox).prop('id'),
						name: ($(checkbox).data('name')+'').trim()
					};
					itemSelectedPropertyValues.items.push(selectedItem);
				});
				break;
		}
		if (itemSelectedPropertyValues.items.length) selectedPropertyValues.push(itemSelectedPropertyValues);
	};

	$fieldBlock.each(addValues);
	updateView(selectedPropertyValues);
};



BX.namespace("BX.Iblock.SmartFilter");
BX.Iblock.SmartFilter = (function()
{
	var SmartFilter = function(arParams)
	{
		if (typeof arParams === 'object')
		{
			this.leftSlider = BX(arParams.leftSlider);
			this.rightSlider = BX(arParams.rightSlider);
			this.tracker = BX(arParams.tracker);
			this.trackerWrap = BX(arParams.trackerWrap);

			this.minInput = BX(arParams.minInputId);
			this.maxInput = BX(arParams.maxInputId);

			this.minPrice = parseFloat(arParams.minPrice);
			this.maxPrice = parseFloat(arParams.maxPrice);

			this.curMinPrice = parseFloat(arParams.curMinPrice);
			this.curMaxPrice = parseFloat(arParams.curMaxPrice);

			this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice);
			this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice);

			this.precision = arParams.precision || 0;

			this.priceDiff = this.maxPrice - this.minPrice;

			this.leftPercent = 0;
			this.rightPercent = 0;

			this.fltMinPercent = 0;
			this.fltMaxPercent = 0;

			this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray
			this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue
			this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue

			this.isTouch = false;

			this.init();

			if ('ontouchstart' in document.documentElement)
			{
				this.isTouch = true;

				BX.bind(this.leftSlider, "touchstart", BX.proxy(function(event){
					this.onMoveLeftSlider(event)
				}, this));

				BX.bind(this.rightSlider, "touchstart", BX.proxy(function(event){
					this.onMoveRightSlider(event)
				}, this));
			}
			else
			{
				BX.bind(this.leftSlider, "mousedown", BX.proxy(function(event){
					this.onMoveLeftSlider(event)
				}, this));

				BX.bind(this.rightSlider, "mousedown", BX.proxy(function(event){
					this.onMoveRightSlider(event)
				}, this));
			}

			BX.bind(this.minInput, "keyup", BX.proxy(function(event){
				this.onInputChange();
			}, this));

			BX.bind(this.maxInput, "keyup", BX.proxy(function(event){
				this.onInputChange();
			}, this));
		}
	};

	SmartFilter.prototype.init = function()
	{
		var priceDiff;

		if (this.curMinPrice > this.minPrice)
		{
			priceDiff = this.curMinPrice - this.minPrice;
			this.leftPercent = (priceDiff*100)/this.priceDiff;

			this.leftSlider.style.left = this.leftPercent + "%";
			this.colorUnavailableActive.style.left = this.leftPercent + "%";
		}

		this.setMinFilteredValue(this.fltMinPrice);

		if (this.curMaxPrice < this.maxPrice)
		{
			priceDiff = this.maxPrice - this.curMaxPrice;
			this.rightPercent = (priceDiff*100)/this.priceDiff;

			this.rightSlider.style.right = this.rightPercent + "%";
			this.colorUnavailableActive.style.right = this.rightPercent + "%";
		}

		this.setMaxFilteredValue(this.fltMaxPrice);
	};

	// @todo
	SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice)
	{
		this.fltMinPrice = parseFloat(fltMinPrice);
		if (this.fltMinPrice >= this.minPrice)
		{
			var priceDiff = this.fltMinPrice - this.minPrice;
			this.fltMinPercent = (priceDiff*100)/this.priceDiff;

			if (this.leftPercent > this.fltMinPercent)
				this.colorAvailableActive.style.left = this.leftPercent + "%";
			else
				this.colorAvailableActive.style.left = this.fltMinPercent + "%";

			this.colorAvailableInactive.style.left = this.fltMinPercent + "%";
		}
		else
		{
			this.colorAvailableActive.style.left = "0%";
			this.colorAvailableInactive.style.left = "0%";
		}
	};

    // @todo
	SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice)
	{
		this.fltMaxPrice = parseFloat(fltMaxPrice);
		if (this.fltMaxPrice <= this.maxPrice)
		{
			var priceDiff = this.maxPrice - this.fltMaxPrice;
			this.fltMaxPercent = (priceDiff*100)/this.priceDiff;

			if (this.rightPercent > this.fltMaxPercent)
				this.colorAvailableActive.style.right = this.rightPercent + "%";
			else
				this.colorAvailableActive.style.right = this.fltMaxPercent + "%";

			this.colorAvailableInactive.style.right = this.fltMaxPercent + "%";
		}
		else
		{
			this.colorAvailableActive.style.right = "0%";
			this.colorAvailableInactive.style.right = "0%";
		}
	};

	SmartFilter.prototype.getXCoord = function(elem)
	{
		var box = elem.getBoundingClientRect();
		var body = document.body;
		var docElem = document.documentElement;

		var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
		var clientLeft = docElem.clientLeft || body.clientLeft || 0;
		var left = box.left + scrollLeft - clientLeft;

		return Math.round(left);
	};

	SmartFilter.prototype.getPageX = function(e)
	{
		e = e || window.event;
		var pageX = null;

		if (this.isTouch && event.targetTouches[0] != null)
		{
			pageX = e.targetTouches[0].pageX;
		}
		else if (e.pageX != null)
		{
			pageX = e.pageX;
		}
		else if (e.clientX != null)
		{
			var html = document.documentElement;
			var body = document.body;

			pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0);
			pageX -= html.clientLeft || 0;
		}

		return pageX;
	};

	SmartFilter.prototype.recountMinPrice = function()
	{
		var newMinPrice = (this.priceDiff*this.leftPercent)/100;
		newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision);

		if (newMinPrice != this.minPrice)
			this.minInput.value = newMinPrice;
		else
			this.minInput.value = "";
		smartFilter.keyup(this.minInput);
	};

	SmartFilter.prototype.recountMaxPrice = function()
	{
		var newMaxPrice = (this.priceDiff*this.rightPercent)/100;
		newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision);

		if (newMaxPrice != this.maxPrice)
			this.maxInput.value = newMaxPrice;
		else
			this.maxInput.value = "";
		smartFilter.keyup(this.maxInput);
	};

	SmartFilter.prototype.onInputChange = function ()
	{
		var priceDiff;
		if (this.minInput.value)
		{
			var leftInputValue = this.minInput.value;
			if (leftInputValue < this.minPrice)
				leftInputValue = this.minPrice;

			if (leftInputValue > this.maxPrice)
				leftInputValue = this.maxPrice;

			priceDiff = leftInputValue - this.minPrice;
			this.leftPercent = (priceDiff*100)/this.priceDiff;

			this.makeLeftSliderMove(false);
		}

		if (this.maxInput.value)
		{
			var rightInputValue = this.maxInput.value;
			if (rightInputValue < this.minPrice)
				rightInputValue = this.minPrice;

			if (rightInputValue > this.maxPrice)
				rightInputValue = this.maxPrice;

			priceDiff = this.maxPrice - rightInputValue;
			this.rightPercent = (priceDiff*100)/this.priceDiff;

			this.makeRightSliderMove(false);
		}
	};

	SmartFilter.prototype.makeLeftSliderMove = function(recountPrice)
	{
		recountPrice = (recountPrice !== false);

		this.leftSlider.style.left = this.leftPercent + "%";
		this.colorUnavailableActive.style.left = this.leftPercent + "%";

		var areBothSlidersMoving = false;
		if (this.leftPercent + this.rightPercent >= 100)
		{
			areBothSlidersMoving = true;
			this.rightPercent = 100 - this.leftPercent;
			this.rightSlider.style.right = this.rightPercent + "%";
			this.colorUnavailableActive.style.right = this.rightPercent + "%";
		}

		if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100-this.fltMaxPercent))
		{
			this.colorAvailableActive.style.left = this.leftPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.right = 100 - this.leftPercent + "%";
			}
		}
		else if(this.leftPercent <= this.fltMinPercent)
		{
			this.colorAvailableActive.style.left = this.fltMinPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%";
			}
		}
		else if(this.leftPercent >= this.fltMaxPercent)
		{
			this.colorAvailableActive.style.left = 100-this.fltMaxPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
			}
		}

		if (recountPrice)
		{
			this.recountMinPrice();
			if (areBothSlidersMoving)
				this.recountMaxPrice();
		}
	};

	SmartFilter.prototype.countNewLeft = function(event)
	{
		var pageX = this.getPageX(event);

		var trackerXCoord = this.getXCoord(this.trackerWrap);
		var rightEdge = this.trackerWrap.offsetWidth;

		var newLeft = pageX - trackerXCoord;

		if (newLeft < 0)
			newLeft = 0;
		else if (newLeft > rightEdge)
			newLeft = rightEdge;

		return newLeft;
	};

	SmartFilter.prototype.onMoveLeftSlider = function(e)
	{
		if (!this.isTouch)
		{
			this.leftSlider.ondragstart = function() {
				return false;
			};
		}

		if (!this.isTouch)
		{
			document.onmousemove = BX.proxy(function(event) {
				this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
				this.makeLeftSliderMove();
			}, this);

			document.onmouseup = function() {
				document.onmousemove = document.onmouseup = null;
			};
		}
		else
		{
			document.ontouchmove = BX.proxy(function(event) {
				this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
				this.makeLeftSliderMove();
			}, this);

			document.ontouchend = function() {
				document.ontouchmove = document.touchend = null;
			};
		}

		return false;
	};

	SmartFilter.prototype.makeRightSliderMove = function(recountPrice)
	{
		recountPrice = (recountPrice !== false);

		this.rightSlider.style.right = this.rightPercent + "%";
		this.colorUnavailableActive.style.right = this.rightPercent + "%";

		var areBothSlidersMoving = false;
		if (this.leftPercent + this.rightPercent >= 100)
		{
			areBothSlidersMoving = true;
			this.leftPercent = 100 - this.rightPercent;
			this.leftSlider.style.left = this.leftPercent + "%";
			this.colorUnavailableActive.style.left = this.leftPercent + "%";
		}

		if ((100-this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent)
		{
			this.colorAvailableActive.style.right = this.rightPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.left = 100 - this.rightPercent + "%";
			}
		}
		else if(this.rightPercent <= this.fltMaxPercent)
		{
			this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%";
			}
		}
		else if((100-this.rightPercent) <= this.fltMinPercent)
		{
			this.colorAvailableActive.style.right = 100-this.fltMinPercent + "%";
			if (areBothSlidersMoving)
			{
				this.colorAvailableActive.style.left = this.fltMinPercent + "%";
			}
		}

		if (recountPrice)
		{
			this.recountMaxPrice();
			if (areBothSlidersMoving)
				this.recountMinPrice();
		}
	};

	SmartFilter.prototype.onMoveRightSlider = function(e)
	{
		if (!this.isTouch)
		{
			this.rightSlider.ondragstart = function() {
				return false;
			};
		}

		if (!this.isTouch)
		{
			document.onmousemove = BX.proxy(function(event) {
				this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth));
				this.makeRightSliderMove();
			}, this);

			document.onmouseup = function() {
				document.onmousemove = document.onmouseup = null;
			};
		}
		else
		{
			document.ontouchmove = BX.proxy(function(event) {
				this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth));
				this.makeRightSliderMove();
			}, this);

			document.ontouchend = function() {
				document.ontouchmove = document.ontouchend = null;
			};
		}

		return false;
	};

	return SmartFilter;
})();

/* End */
;
; /* Start:"a:4:{s:4:"full";s:150:"/bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default//field_template/METRO/script.js?155022351110200";s:6:"source";s:134:"/bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default//field_template/METRO/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/

;(function(){
	"use strict";
	
	/**
	 * @type object
	 * @property {array} c.stations - Станции метро
	 * @property {array} c.lines - Линии метро
	 * @property {object} c.popup - Всплывающие списки в поиске или селекте
	 * @property {string} c.searchText - Строка поиска
	 * @property {array} c.result - Результат выбора метро
	 */
	var c;
	Vue.component('metro', {
		template: "#metro-template",
		props: ['stations', 'lines', 'lang', 'checkbox'],
		data: function () {
			return {
				popup: {
					'metro-lines': false,
					'metro-search-result': false
				},
				searchText: '',
				maxSearchResult: 10,
				searchHighlightIndex: -1,
				selectedStations: [],
				result: [],
				backupResult: [],
				activeTippy: {}
			}
		},
		created: function(){c = this;},
		computed: {
			searchStations: function () {
				if (!c.searchText.length) return [];
				var searchStations = c.stations.filter(function (station) {
					var stationName = station.NAME.toLowerCase();
					return stationName.indexOf(c.searchText.toLowerCase()) > -1 ||
						stationName.indexOf(c.autoReplaceKeyboard(c.searchText.toLowerCase())) > -1
					
				});
				if (searchStations.length > c.maxSearchResult)
					searchStations.splice(c.maxSearchResult-1, searchStations.length-c.maxSearchResult);
				
				return searchStations
			},
			activeSearchStations: function () {
				return c.searchStations.filter(function (station) {
					return station.isActive;
				});
			},
			// если все станции ветки выбраны то выбираем ветку
			// и удаляем из результата все станции ветки
			formatResult: function () {
				var checkedLineIds = [];
				var result = [];
				var excludeStations = [];
				
				c.result.forEach(function (station, resultKey) {
					
					station.LINE.forEach(function (lineId) {
						if (checkedLineIds.indexOf(lineId) > -1) return;
						
						checkedLineIds.push(lineId);
						
						var lineStation = c.getStationsByLineId(lineId);
						var resultLineStation = c.result.filter(function (station1) {
							return station1.LINE.indexOf(lineId) > -1 && station1.isActive;
						});
						if (lineStation.length === resultLineStation.length && lineStation.length >= 1) {
							result = result.concat(c.getLinesById(lineId));
							excludeStations = excludeStations.concat(lineStation)
						}
					});
					if (excludeStations.indexOf(station) === -1) result.push(station);
				});
				return result;
			},
			activeStations: function () {
				return c.stations.filter(function(stantion){
					return (c.checkbox.filter(function (cb) {
						return cb.VALUE === stantion.NAME;
					}).length > 0);
				});
			},
			activeLines: function () {
				return c.lines.map(function(line){
					line.disable = (c.getStationsByLineId(line.ID).length < 1);
					return line;
				});
			},
		},
		methods: {
			/**
			 * Добавляет активные станции на карту
			 * @param {object} item - станция или ветка
			 */
			addToSvg: function(item) {
				item = [].concat(item);
				item.forEach(function (oneItem) {
					if (oneItem.isStation) {
						$(oneItem.mapGroup).addClass('_active');
					} else {
						c.addToSvg(c.getStationsByLineId(oneItem.ID));
					}
				});
			},
			removeFromSvg: function(item) {
				item = [].concat(item);
				item.forEach(function (oneItem) {
					if (oneItem.isStation) {
						$(oneItem.mapGroup).removeClass('_active');
					} else {
						c.removeFromSvg(c.getStationsByLineId(oneItem.ID));
					}
				});
			},
			
			removeFromResult: function(arItems) {
				arItems = [].concat(arItems);
				arItems.forEach(function (oneItem) {
					if (oneItem.isStation) {
						c.removeFromSvg(oneItem);
						c.$delete(c.result, c.result.indexOf(oneItem));
					} else {
						var lineStations = c.getStationsByLineId(oneItem.ID);
						// удаляются только станции которых нет в других выбранных ветках
						// (для станций в нескольких группах)
						// но станций должно быть больше 1
						lineStations = lineStations.filter(function (station) {
							var result = c.formatResult.filter(function(resultLine) {
								return !resultLine.isStation &&
									resultLine.ID !== oneItem.ID &&
									(station.LINE.indexOf(resultLine.ID) > -1);
							});
							return result.length <= 1;
						});
						c.removeFromResult(lineStations);
					}
				});
			},
			addToResult: function (arItems) {
				arItems = [].concat(arItems);
				arItems.forEach(function (oneItem) {
					if (c.inResult(oneItem)) return;
					if (oneItem.isStation) {
						c.result.unshift(oneItem);
						c.addToSvg(oneItem);
					} else {
						if (!oneItem.disable) c.addToResult(c.getStationsByLineId(oneItem.ID));
					}
				});
			},
			inResult: function (item){
				return c.result.indexOf(item) > -1 || c.formatResult.indexOf(item) > -1;
			},
			/**
			 * добавляет в результат
			 * @param {object} item - станция или ветка
			 */
			toggleResult: function (item) {
				c[c.inResult(item) ? 'removeFromResult' : 'addToResult'](item);
			},
			
			/* выбор станции из поиска */
			onClickSearchResult: function (station, event) {
				if (!station.isActive) {
					if (c.activeTippy.destroyAll) {
						c.activeTippy.destroyAll();
						c.activeTippy = {};
					}
					
					var o = event.target;
					station.tippy = c.activeTippy = tippy(o, {
						placement: 'bottom-start',
						performance: true,
						trigger: 'custom',
						zIndex: 9999,
					});
					setTimeout(function () {
						o._tippy.show();
					}, 0);
					setTimeout(function () {
						station.tippy.destroyAll();
					}, 1000);
					return;
				}
				
				c.searchText = '';
				c.searchHighlightIndex = -1;
				
				if (typeof station !== 'undefined') c.addToResult(station);
			},
			highlightSearchResult: function(index) {
				var resultLength = c.activeSearchStations.length;
				
				if (!resultLength) return;
				
				var startSearchIndex = c.searchHighlightIndex;
				c.searchHighlightIndex += index;
				
				if (index < 0 && startSearchIndex === -1) {
					c.searchHighlightIndex = resultLength - 1;
				}
				
				if (c.searchHighlightIndex > resultLength) c.searchHighlightIndex = -1;
				if (c.searchHighlightIndex < -1) c.searchHighlightIndex = -1;
			},
			clickHighlightResultItem: function() {
				c.onClickSearchResult(c.activeSearchStations.length === 1 ?
					c.activeSearchStations[0] : c.activeSearchStations[c.searchHighlightIndex]);
			},
			
			getLinesById: function (arId) {
				arId = [].concat(arId);
				return c.lines.filter(function (line) {
					return arId.indexOf(line.ID) > -1;
				});
			},
			getStationsByLineId: function (lineId) {
				return c.activeStations.filter(function (station) {
					return station.LINE.indexOf(lineId) > -1;
				});
			},
			
			togglePopup: function (popupName) {
				c.popup[popupName] = !c.popup[popupName];
			},
			openPopup: function (popupName) {
				c.popup[popupName] = true;
			},
			hidePopup: function(popupName) {
				c.popup[popupName] = false;
			},

			saveBackUpResult: function(){
				c.backupResult = c.result.reduce(function (ar, resultItem) {
					ar.push(resultItem);
					return ar;
				}, []);
			},
			resetResult: function(){
				c.removeFromResult(c.result);
				c.addToResult(c.backupResult);
			},
			saveResult: function () {
				c.saveBackUpResult();
				$.magnificPopup.close();
				smartFilter.updateDuplicate();
				smartFilter.reload();
			},
			
			inResultStationName: function(stationName){
				return (c.result.filter(function(resultItem){
					return resultItem.NAME === stationName;
				}).length > 0);
			},
			
			autoReplaceKeyboard: function( str ) {
				var replacer = c.lang['AUTO_REPLACE_EN_RU'];
				
				return str.replace(/[A-z/,.;\'\]\[]/g, function ( x ){
					return x == x.toLowerCase() ? replacer[ x ] : replacer[ x.toLowerCase() ].toUpperCase();
				});
			},
			getStationsByName: function (name) {
				return c.stations.filter(function(station){
					return station.NAME === name;
				});
			}
		},
		mounted: function(){
			cui.clickOff($(c.$refs.popupLinesLabel).add($(c.$refs.popupLines)), function () {
				c.hidePopup('metro-lines');
			});
			
			cui.clickOff($(c.$refs.searchInput).add($(c.$refs.searchResult)), function () {
				c.hidePopup('metro-search-result');
			});
			
			c.$map = $('#metro-map-container');
			
			// привязка станций к точкам из справочника
			c.stations.map(function (stantion) {
				var id = stantion.SVG_ID;
				
				stantion.isStation = true;
				
				stantion.isActive = (c.checkbox.filter(function (cb) {
					return cb.VALUE === stantion.NAME;
				}).length > 0);

				var $mapGroup = $(c.$map).find('#'+id)
					.addClass('metro-map-group')
					.on('click', function(event) {
						if(stantion.isActive) c.toggleResult(stantion);
					});
				
				stantion.mapGroup = $mapGroup.get(0);
				
				if (stantion.isActive)
					$mapGroup.addClass('_clickable');
				$mapGroup.find('text').addClass('metro-map-name');

				var grouppedStations = $mapGroup.find('g');

				var $stationGroup = grouppedStations.length ?
                    	grouppedStations : $(stantion.mapGroup);
				
				$stationGroup.each(function () {
					$(this).find('circle,ellipse').last().addClass('metro-map-point');
				});
				
				return stantion;
			});
			
			// сортируем станции по активности
			c.stations.sort(function (a, b) {
				return b.isActive - a.isActive;
			});
			
			c.checkbox.forEach(function (cb) {
				if (cb.CHECKED) {
					c.addToResult(c.getStationsByName(cb.VALUE));
				}
			});
			
			$(this.$refs.checkbox).on('change', function () {
				c[$(this).prop('checked') ? 'addToResult' : 'removeFromResult'](c.getStationsByName($(this).data('name')));
			});

			c.saveBackUpResult();
		},
	});
	
	window.SMARTFILTER_LOCATION = function (id) {
		var self = this;
		
		var $label = $('#filter-label-'+id);
		var $values = $('#filter-values-'+id);
		var districtGroupSliderSelector = '#district-group-slider-'+id;
		
		//popup
		$label.on('click', function(event) {
			event.preventDefault();
			$.magnificPopup.open({
				items: {
					src: '#filter-values-'+id
				},
				type: 'inline',
				midClick: true,
				callbacks: {
					'open': function () {
					
					},
					'close': function () {
						c.resetResult();
					},
				}
			});
		});
		
		
	};
}());
/* End */
;
; /* Start:"a:4:{s:4:"full";s:120:"/bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/script.js?1550223511102";s:6:"source";s:106:"/bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
/*
$(function () {
    $('#masonry-container').masonry({
        itemSelector: '.item'
    });
});
*/

/* End */
;
; /* Start:"a:4:{s:4:"full";s:135:"/bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/js/masonry.pkgd.min.js?155022351125250";s:6:"source";s:119:"/bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/js/masonry.pkgd.min.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
/*!
 * Masonry PACKAGED v3.1.5
 * Cascading grid layout library
 * http://masonry.desandro.com
 * MIT License
 * by David DeSandro
 */

!function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}return this.each(function(){var d=a.data(this,b);d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d))})}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],c):c(a.jQuery)}(window),function(a){function b(b){var c=a.event;return c.target=c.target||c.srcElement||b,c}var c=document.documentElement,d=function(){};c.addEventListener?d=function(a,b,c){a.addEventListener(b,c,!1)}:c.attachEvent&&(d=function(a,c,d){a[c+d]=d.handleEvent?function(){var c=b(a);d.handleEvent.call(d,c)}:function(){var c=b(a);d.call(a,c)},a.attachEvent("on"+c,a[c+d])});var e=function(){};c.removeEventListener?e=function(a,b,c){a.removeEventListener(b,c,!1)}:c.detachEvent&&(e=function(a,b,c){a.detachEvent("on"+b,a[b+c]);try{delete a[b+c]}catch(d){a[b+c]=void 0}});var f={bind:d,unbind:e};"function"==typeof define&&define.amd?define("eventie/eventie",f):"object"==typeof exports?module.exports=f:a.eventie=f}(this),function(a){function b(a){"function"==typeof a&&(b.isReady?a():f.push(a))}function c(a){var c="readystatechange"===a.type&&"complete"!==e.readyState;if(!b.isReady&&!c){b.isReady=!0;for(var d=0,g=f.length;g>d;d++){var h=f[d];h()}}}function d(d){return d.bind(e,"DOMContentLoaded",c),d.bind(e,"readystatechange",c),d.bind(a,"load",c),b}var e=a.document,f=[];b.isReady=!1,"function"==typeof define&&define.amd?(b.isReady="function"==typeof requirejs,define("doc-ready/doc-ready",["eventie/eventie"],d)):a.docReady=d(a.eventie)}(this),function(){function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return a}):"object"==typeof module&&module.exports?module.exports=a:this.EventEmitter=a}.call(this),function(a){function b(a){if(a){if("string"==typeof d[a])return a;a=a.charAt(0).toUpperCase()+a.slice(1);for(var b,e=0,f=c.length;f>e;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):"object"==typeof exports?module.exports=b:a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function c(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}return a}function d(a){function d(a){if("string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var d=f(a);if("none"===d.display)return c();var e={};e.width=a.offsetWidth,e.height=a.offsetHeight;for(var k=e.isBorderBox=!(!j||!d[j]||"border-box"!==d[j]),l=0,m=g.length;m>l;l++){var n=g[l],o=d[n];o=h(a,o);var p=parseFloat(o);e[n]=isNaN(p)?0:p}var q=e.paddingLeft+e.paddingRight,r=e.paddingTop+e.paddingBottom,s=e.marginLeft+e.marginRight,t=e.marginTop+e.marginBottom,u=e.borderLeftWidth+e.borderRightWidth,v=e.borderTopWidth+e.borderBottomWidth,w=k&&i,x=b(d.width);x!==!1&&(e.width=x+(w?0:q+u));var y=b(d.height);return y!==!1&&(e.height=y+(w?0:r+v)),e.innerWidth=e.width-(q+u),e.innerHeight=e.height-(r+v),e.outerWidth=e.width+s,e.outerHeight=e.height+t,e}}function h(a,b){if(e||-1===b.indexOf("%"))return b;var c=a.style,d=c.left,f=a.runtimeStyle,g=f&&f.left;return g&&(f.left=a.currentStyle.left),c.left=b,b=c.pixelLeft,c.left=d,g&&(f.left=g),b}var i,j=a("boxSizing");return function(){if(j){var a=document.createElement("div");a.style.width="200px",a.style.padding="1px 2px 3px 4px",a.style.borderStyle="solid",a.style.borderWidth="1px 2px 3px 4px",a.style[j]="border-box";var c=document.body||document.documentElement;c.appendChild(a);var d=f(a);i=200===b(d.width),c.removeChild(a)}}(),d}var e=a.getComputedStyle,f=e?function(a){return e(a,null)}:function(a){return a.currentStyle},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],d):"object"==typeof exports?module.exports=d(require("get-style-property")):a.getSize=d(a.getStyleProperty)}(window),function(a,b){function c(a,b){return a[h](b)}function d(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}function e(a,b){d(a);for(var c=a.parentNode.querySelectorAll(b),e=0,f=c.length;f>e;e++)if(c[e]===a)return!0;return!1}function f(a,b){return d(a),c(a,b)}var g,h=function(){if(b.matchesSelector)return"matchesSelector";for(var a=["webkit","moz","ms","o"],c=0,d=a.length;d>c;c++){var e=a[c],f=e+"MatchesSelector";if(b[f])return f}}();if(h){var i=document.createElement("div"),j=c(i,"div");g=j?c:f}else g=e;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return g}):window.matchesSelector=g}(this,Element.prototype),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){for(var b in a)return!1;return b=null,!0}function d(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function e(a,e,f){function h(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}var i=f("transition"),j=f("transform"),k=i&&j,l=!!f("perspective"),m={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[i],n=["transform","transition","transitionDuration","transitionProperty"],o=function(){for(var a={},b=0,c=n.length;c>b;b++){var d=n[b],e=f(d);e&&e!==d&&(a[d]=e)}return a}();b(h.prototype,a.prototype),h.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},h.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},h.prototype.getSize=function(){this.size=e(this.element)},h.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=o[c]||c;b[d]=a[c]}},h.prototype.getPosition=function(){var a=g(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=parseInt(a[c?"left":"right"],10),f=parseInt(a[d?"top":"bottom"],10);e=isNaN(e)?0:e,f=isNaN(f)?0:f;var h=this.layout.size;e-=c?h.paddingLeft:h.paddingRight,f-=d?h.paddingTop:h.paddingBottom,this.position.x=e,this.position.y=f},h.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={};b.isOriginLeft?(c.left=this.position.x+a.paddingLeft+"px",c.right=""):(c.right=this.position.x+a.paddingRight+"px",c.left=""),b.isOriginTop?(c.top=this.position.y+a.paddingTop+"px",c.bottom=""):(c.bottom=this.position.y+a.paddingBottom+"px",c.top=""),this.css(c),this.emitEvent("layout",[this])};var p=l?function(a,b){return"translate3d("+a+"px, "+b+"px, 0)"}:function(a,b){return"translate("+a+"px, "+b+"px)"};h.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),f=parseInt(b,10),g=e===this.position.x&&f===this.position.y;if(this.setPosition(a,b),g&&!this.isTransitioning)return void this.layoutPosition();var h=a-c,i=b-d,j={},k=this.layout.options;h=k.isOriginLeft?h:-h,i=k.isOriginTop?i:-i,j.transform=p(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},h.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},h.prototype.moveTo=k?h.prototype._transitionTo:h.prototype.goTo,h.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},h.prototype._nonTransition=function(a){this.css(a.to),a.isCleaning&&this._removeStyles(a.to);for(var b in a.onTransitionEnd)a.onTransitionEnd[b].call(this)},h.prototype._transition=function(a){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(a);var b=this._transn;for(var c in a.onTransitionEnd)b.onEnd[c]=a.onTransitionEnd[c];for(c in a.to)b.ingProperties[c]=!0,a.isCleaning&&(b.clean[c]=!0);if(a.from){this.css(a.from);var d=this.element.offsetHeight;d=null}this.enableTransition(a.to),this.css(a.to),this.isTransitioning=!0};var q=j&&d(j)+",opacity";h.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:q,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(m,this,!1))},h.prototype.transition=h.prototype[i?"_transition":"_nonTransition"],h.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},h.prototype.onotransitionend=function(a){this.ontransitionend(a)};var r={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};h.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,d=r[a.propertyName]||a.propertyName;if(delete b.ingProperties[d],c(b.ingProperties)&&this.disableTransition(),d in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[d]),d in b.onEnd){var e=b.onEnd[d];e.call(this),delete b.onEnd[d]}this.emitEvent("transitionEnd",[this])}},h.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(m,this,!1),this.isTransitioning=!1},h.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var s={transitionProperty:"",transitionDuration:""};return h.prototype.removeTransitionStyles=function(){this.css(s)},h.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.emitEvent("remove",[this])},h.prototype.remove=function(){if(!i||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.on("transitionEnd",function(){return a.removeElem(),!0}),this.hide()},h.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options;this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0})},h.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options;this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:{opacity:function(){this.isHidden&&this.css({display:"none"})}}})},h.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},h}var f=a.getComputedStyle,g=f?function(a){return f(a,null)}:function(a){return a.currentStyle};"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property"],e):(a.Outlayer={},a.Outlayer.Item=e(a.EventEmitter,a.getSize,a.getStyleProperty))}(window),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){return"[object Array]"===l.call(a)}function d(a){var b=[];if(c(a))b=a;else if(a&&"number"==typeof a.length)for(var d=0,e=a.length;e>d;d++)b.push(a[d]);else b.push(a);return b}function e(a,b){var c=n(b,a);-1!==c&&b.splice(c,1)}function f(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()}function g(c,g,l,n,o,p){function q(a,c){if("string"==typeof a&&(a=h.querySelector(a)),!a||!m(a))return void(i&&i.error("Bad "+this.constructor.namespace+" element: "+a));this.element=a,this.options=b({},this.constructor.defaults),this.option(c);var d=++r;this.element.outlayerGUID=d,s[d]=this,this._create(),this.options.isInitLayout&&this.layout()}var r=0,s={};return q.namespace="outlayer",q.Item=p,q.defaults={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,isResizingContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},b(q.prototype,l.prototype),q.prototype.option=function(a){b(this.options,a)},q.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),b(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},q.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},q.prototype._itemize=function(a){for(var b=this._filterFindItemElements(a),c=this.constructor.Item,d=[],e=0,f=b.length;f>e;e++){var g=b[e],h=new c(g,this);d.push(h)}return d},q.prototype._filterFindItemElements=function(a){a=d(a);for(var b=this.options.itemSelector,c=[],e=0,f=a.length;f>e;e++){var g=a[e];if(m(g))if(b){o(g,b)&&c.push(g);for(var h=g.querySelectorAll(b),i=0,j=h.length;j>i;i++)c.push(h[i])}else c.push(g)}return c},q.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},q.prototype.layout=function(){this._resetLayout(),this._manageStamps();var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,a),this._isLayoutInited=!0},q.prototype._init=q.prototype.layout,q.prototype._resetLayout=function(){this.getSize()},q.prototype.getSize=function(){this.size=n(this.element)},q.prototype._getMeasurement=function(a,b){var c,d=this.options[a];d?("string"==typeof d?c=this.element.querySelector(d):m(d)&&(c=d),this[a]=c?n(c)[b]:d):this[a]=0},q.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},q.prototype._getItemsForLayout=function(a){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];e.isIgnored||b.push(e)}return b},q.prototype._layoutItems=function(a,b){function c(){d.emitEvent("layoutComplete",[d,a])}var d=this;if(!a||!a.length)return void c();this._itemsOn(a,"layout",c);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f],i=this._getItemLayoutPosition(h);i.item=h,i.isInstant=b||h.isLayoutInstant,e.push(i)}this._processLayoutQueue(e)},q.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},q.prototype._processLayoutQueue=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];this._positionItem(d.item,d.x,d.y,d.isInstant)}},q.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},q.prototype._postLayout=function(){this.resizeContainer()},q.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},q.prototype._getContainerSize=k,q.prototype._setContainerMeasure=function(a,b){if(void 0!==a){var c=this.size;c.isBorderBox&&(a+=b?c.paddingLeft+c.paddingRight+c.borderLeftWidth+c.borderRightWidth:c.paddingBottom+c.paddingTop+c.borderTopWidth+c.borderBottomWidth),a=Math.max(a,0),this.element.style[b?"width":"height"]=a+"px"}},q.prototype._itemsOn=function(a,b,c){function d(){return e++,e===f&&c.call(g),!0}for(var e=0,f=a.length,g=this,h=0,i=a.length;i>h;h++){var j=a[h];j.on(b,d)}},q.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},q.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored},q.prototype.stamp=function(a){if(a=this._find(a)){this.stamps=this.stamps.concat(a);for(var b=0,c=a.length;c>b;b++){var d=a[b];this.ignore(d)}}},q.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e(d,this.stamps),this.unignore(d)}},q.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=d(a)):void 0},q.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var a=0,b=this.stamps.length;b>a;a++){var c=this.stamps[a];this._manageStamp(c)}}},q.prototype._getBoundingRect=function(){var a=this.element.getBoundingClientRect(),b=this.size;this._boundingRect={left:a.left+b.paddingLeft+b.borderLeftWidth,top:a.top+b.paddingTop+b.borderTopWidth,right:a.right-(b.paddingRight+b.borderRightWidth),bottom:a.bottom-(b.paddingBottom+b.borderBottomWidth)}},q.prototype._manageStamp=k,q.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,d=n(a),e={left:b.left-c.left-d.marginLeft,top:b.top-c.top-d.marginTop,right:c.right-b.right-d.marginRight,bottom:c.bottom-b.bottom-d.marginBottom};return e},q.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},q.prototype.bindResize=function(){this.isResizeBound||(c.bind(a,"resize",this),this.isResizeBound=!0)},q.prototype.unbindResize=function(){this.isResizeBound&&c.unbind(a,"resize",this),this.isResizeBound=!1},q.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},q.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},q.prototype.needsResizeLayout=function(){var a=n(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},q.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},q.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},q.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){var c=this.items.slice(0);this.items=b.concat(c),this._resetLayout(),this._manageStamps(),this.layoutItems(b,!0),this.reveal(b),this.layoutItems(c)}},q.prototype.reveal=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.reveal()}},q.prototype.hide=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.hide()}},q.prototype.getItem=function(a){for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];if(d.element===a)return d}},q.prototype.getItems=function(a){if(a&&a.length){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c],f=this.getItem(e);f&&b.push(f)}return b}},q.prototype.remove=function(a){a=d(a);var b=this.getItems(a);if(b&&b.length){this._itemsOn(b,"remove",function(){this.emitEvent("removeComplete",[this,b])});for(var c=0,f=b.length;f>c;c++){var g=b[c];g.remove(),e(g,this.items)}}},q.prototype.destroy=function(){var a=this.element.style;a.height="",a.position="",a.width="";for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];d.destroy()}this.unbindResize(),delete this.element.outlayerGUID,j&&j.removeData(this.element,this.constructor.namespace)},q.data=function(a){var b=a&&a.outlayerGUID;return b&&s[b]},q.create=function(a,c){function d(){q.apply(this,arguments)}return Object.create?d.prototype=Object.create(q.prototype):b(d.prototype,q.prototype),d.prototype.constructor=d,d.defaults=b({},q.defaults),b(d.defaults,c),d.prototype.settings={},d.namespace=a,d.data=q.data,d.Item=function(){p.apply(this,arguments)},d.Item.prototype=new p,g(function(){for(var b=f(a),c=h.querySelectorAll(".js-"+b),e="data-"+b+"-options",g=0,k=c.length;k>g;g++){var l,m=c[g],n=m.getAttribute(e);try{l=n&&JSON.parse(n)}catch(o){i&&i.error("Error parsing "+e+" on "+m.nodeName.toLowerCase()+(m.id?"#"+m.id:"")+": "+o);continue}var p=new d(m,l);j&&j.data(m,a,p)}}),j&&j.bridget&&j.bridget(a,d),d},q.Item=p,q}var h=a.document,i=a.console,j=a.jQuery,k=function(){},l=Object.prototype.toString,m="object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1===a.nodeType&&"string"==typeof a.nodeName},n=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1};"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","doc-ready/doc-ready","eventEmitter/EventEmitter","get-size/get-size","matches-selector/matches-selector","./item"],g):a.Outlayer=g(a.eventie,a.docReady,a.EventEmitter,a.getSize,a.matchesSelector,a.Outlayer.Item)}(window),function(a){function b(a,b){var d=a.create("masonry");return d.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0);this.maxY=0},d.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var a=this.items[0],c=a&&a.element;this.columnWidth=c&&b(c).outerWidth||this.containerWidth}this.columnWidth+=this.gutter,this.cols=Math.floor((this.containerWidth+this.gutter)/this.columnWidth),this.cols=Math.max(this.cols,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);this.containerWidth=c&&c.innerWidth},d.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth%this.columnWidth,d=b&&1>b?"round":"ceil",e=Math[d](a.size.outerWidth/this.columnWidth);e=Math.min(e,this.cols);for(var f=this._getColGroup(e),g=Math.min.apply(Math,f),h=c(f,g),i={x:this.columnWidth*h,y:g},j=g+a.size.outerHeight,k=this.cols+1-f.length,l=0;k>l;l++)this.colYs[h+l]=j;return i},d.prototype._getColGroup=function(a){if(2>a)return this.colYs;for(var b=[],c=this.cols+1-a,d=0;c>d;d++){var e=this.colYs.slice(d,d+a);b[d]=Math.max.apply(Math,e)}return b},d.prototype._manageStamp=function(a){var c=b(a),d=this._getElementOffset(a),e=this.options.isOriginLeft?d.left:d.right,f=e+c.outerWidth,g=Math.floor(e/this.columnWidth);g=Math.max(0,g);var h=Math.floor(f/this.columnWidth);h-=f%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var i=(this.options.isOriginTop?d.top:d.bottom)+c.outerHeight,j=g;h>=j;j++)this.colYs[j]=Math.max(i,this.colYs[j])},d.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var a={height:this.maxY};return this.options.isFitWidth&&(a.width=this._getContainerFitWidth()),a},d.prototype._getContainerFitWidth=function(){for(var a=0,b=this.cols;--b&&0===this.colYs[b];)a++;return(this.cols-a)*this.columnWidth-this.gutter},d.prototype.needsResizeLayout=function(){var a=this.containerWidth;return this.getContainerWidth(),a!==this.containerWidth},d}var c=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e===b)return c}return-1};"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size"],b):a.Masonry=b(a.Outlayer,a.getSize)}(window);
/* End */
;
; /* Start:"a:4:{s:4:"full";s:103:"/local/templates/citrus_arealty2/components/citrus/realty.favourites/block/script.min.js?15502236501668";s:6:"source";s:84:"/local/templates/citrus_arealty2/components/citrus/realty.favourites/block/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/
var rootFolder="/bitrix/components/citrus/realty.favourites/templates/block/",popupOnOpen=function(){$(".closebutton").click(function(){$.fancybox.close()}),$("button[data-url]").click(function(){window.location=$(this).data("url")})};$(function(){window.citrusRealtyMark=function(t,e){if("add"==e){var o="CITRUS_REALTY_GO_2FAV";t.parents(".favorites_page").length&&(o="CITRUS_REALTY_FAV_REMOVE_TITLE"),t.addClass("added").find(".control-link-label").html(BX.message(o)).attr("title",BX.message(o))}else{var o="CITRUS_REALTY_GO_2FAV";t.parents(".favorites_page").length&&(o="CITRUS_REALTY_2FAV"),t.removeClass("added").find(".control-link-label").html(BX.message(o)).removeAttr("title")}},$(".add2favourites[data-id]").on("click",function(t){if(t.preventDefault(),$(this).hasClass("added")&&!$(this).parents(".favorites_page").length)return void(window.location.href=$("a.realty-favourites").attr("href"));var e=$(this),o=e.data("id"),a=e.hasClass("added")?"remove":"add";0>=o||$.getJSON(rootFolder+"json.php",{type:a,id:o},function(t){"object"==typeof t&&("undefined"!=typeof t.error?alert(t.error):("undefined"!=typeof updateFavoriteCount&&updateFavoriteCount(t.count),window.citrusRealtyMark(e,t.type),"undefined"!=typeof t.popup&&$.fancybox.open(t.popup,{autoSize:!1,fitToView:!1,scrolling:"no",closeBtn:!1,width:750,minHeight:666,margin:0,padding:0,afterShow:popupOnOpen})))})})}),BX.ready(function(){BX.bind(document.querySelector(".js-citrus-fav-print"),"click",function(){for(var t=[],e=0,o=window.citrusRealtyFav.length;o>e;e++)t.push("id[]="+window.citrusRealtyFav[e]);var a=BX.message("CITRUS_AREALTY_PDF_SEND_SITE_DIR")+"?"+t.join("&");location.href=a})});
/* End */
;; /* /bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default/script.js?155022351128815*/
; /* /bitrix/components/citrus.arealty/smart.filter/templates/.default/bitrix/catalog.smart.filter/.default//field_template/METRO/script.js?155022351110200*/
; /* /bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/script.js?1550223511102*/
; /* /bitrix/components/citrus/realty.catalog/templates/.default/bitrix/catalog.section.list/.default/js/masonry.pkgd.min.js?155022351125250*/
; /* /local/templates/citrus_arealty2/components/citrus/realty.favourites/block/script.min.js?15502236501668*/
