PageSourceSearch

https://aeroscreen.ru/bitrix/templates/concept_phoenix_s1/componen…/sale.order.ajax/basket_order/order_ajax.js

js aeroscreen.ru collected 2026-10-08 23:51:13 UTC 250,804 bytes, 9,326 lines download raw bytes

1BX.namespace('BX.Sale.OrderAjaxComponent');
2
3(function() {
4	'use strict';
5
6	/**
7	 * Show empty default property value to multiple properties without default values
8	 */
9	if (BX.Sale && BX.Sale.Input && BX.Sale.Input.Utils)
10	{
11		BX.Sale.Input.Utils.asMultiple = function (value)
12		{
13			if (value === undefined || value === null || value === '')
14			{
15				return [];
16			}
17			else if (value.constructor === Array)
18			{
19				var i = 0, length = value.length, val;
20
21				for (; i < length;)
22				{
23					val = value[i];
24
25					if (val === undefined || val === null || val === '')
26					{
27						value.splice(i, 1);
28						--length;
29					}
30					else
31					{
32						++i;
33					}
34				}
35
36				return value.length ? value : [''];
37			}
38			else
39			{
40				return [value];
41			}
42		};
43	}
44
45	BX.Sale.OrderAjaxComponent = {
46
47		initializePrimaryFields: function()
48		{
49			this.BXFormPosting = false;
50			this.regionBlockNotEmpty = false;
51			this.showZip = "N";
52			this.locationsInitialized = false;
53			this.locations = {};
54			this.cleanLocations = {};
55			this.locationsTemplate = '';
56			this.pickUpMapFocused = false;
57			this.options = {};
58			this.activeSectionId = '';
59			this.firstLoad = true;
60			this.initialized = {};
61			this.mapsReady = false;
62			this.lastSelectedDelivery = 0;
63			this.deliveryLocationInfo = {};
64			this.deliveryPagination = {};
65			this.deliveryCachedInfo = [];
66			this.paySystemPagination = {};
67			this.validation = {};
68			this.hasErrorSection = {};
69			this.pickUpPagination = {};
70			this.timeOut = {};
71			this.isMobile = BX.browser.IsMobile();
72			this.isHttps = window.location.protocol === "https:";
73			this.orderSaveAllowed = false;
74			this.socServiceHiddenNode = false;
75		},
76
77		/**
78		 * Initialization of sale.order.ajax component js
79		 */
80		init: function(parameters)
81		{
82			this.initializePrimaryFields();
83
84			this.result = parameters.result || {};
85			this.prepareLocations(parameters.locations);
86			this.params = parameters.params || {};
87			this.signedParamsString = parameters.signedParamsString || '';
88			this.siteId = parameters.siteID || '';
89			this.ajaxUrl = parameters.ajaxUrl || '';
90			this.templateFolder = parameters.templateFolder || '';
91			this.defaultBasketItemLogo = this.templateFolder + "/images/product_logo.png";
92			this.defaultStoreLogo = this.templateFolder + "/images/pickup_logo.png";
93			this.defaultDeliveryLogo = this.templateFolder + "/images/delivery_logo.png";
94			this.defaultPaySystemLogo = this.templateFolder + "/images/pay_system_logo.png";
95
96			this.orderBlockNode = BX(parameters.orderBlockId);
97			this.totalBlockNode = BX(parameters.totalBlockId);
98			this.mobileTotalBlockNode = BX(parameters.totalBlockId + '-mobile');
99			this.savedFilesBlockNode = BX('bx-soa-saved-files');
100			this.orderSaveBlockNode = BX('bx-soa-orderSave');
101			this.mainErrorsNode = BX('bx-soa-main-notifications');
102
103			this.authBlockNode = BX(parameters.authBlockId);
104			this.authHiddenBlockNode = BX(parameters.authBlockId + '-hidden');
105			this.basketBlockNode = BX(parameters.basketBlockId);
106			this.basketHiddenBlockNode = BX(parameters.basketBlockId + '-hidden');
107			this.regionBlockNode = BX(parameters.regionBlockId);
108			this.regionHiddenBlockNode = BX(parameters.regionBlockId + '-hidden');
109			this.paySystemBlockNode = BX(parameters.paySystemBlockId);
110			this.paySystemHiddenBlockNode = BX(parameters.paySystemBlockId + '-hidden');
111			this.deliveryBlockNode = BX(parameters.deliveryBlockId);
112			this.deliveryHiddenBlockNode = BX(parameters.deliveryBlockId + '-hidden');
113			this.pickUpBlockNode = BX(parameters.pickUpBlockId);
114			this.pickUpHiddenBlockNode = BX(parameters.pickUpBlockId + '-hidden');
115			this.propsBlockNode = BX(parameters.propsBlockId);
116			this.propsHiddenBlockNode = BX(parameters.propsBlockId + '-hidden');
117			this.minSum = BX(parameters.minSumId);
118			this.minSumValue = null;
119
120			if(this.minSum)
121				this.minSumValue = parseFloat(this.minSum.value);
122
123			/*if (this.result.SHOW_AUTH)
124			{
125				this.authBlockNode.style.display = '';
126				BX.addClass(this.authBlockNode, 'bx-active');
127				this.authGenerateUser = this.result.AUTH.new_user_registration_email_confirmation !== 'Y' && this.result.AUTH.new_user_phone_required !== 'Y';
128			}*/
129
130			this.showZip = parameters.params.SHOW_ZIP_INPUT;
131
132			
133
134			/*if (this.totalBlockNode)
135			{
136				this.totalInfoBlockNode = this.totalBlockNode.querySelector('.bx-soa-cart-total');
137				this.totalGhostBlockNode = this.totalBlockNode.querySelector('.bx-soa-cart-total-ghost');
138			}*/
139
140			this.options.deliveriesPerPage = parseInt(parameters.params.DELIVERIES_PER_PAGE);
141			this.options.paySystemsPerPage = parseInt(parameters.params.PAY_SYSTEMS_PER_PAGE);
142			this.options.pickUpsPerPage = parseInt(parameters.params.PICKUPS_PER_PAGE);
143
144			this.options.showWarnings = !!parameters.showWarnings;
145			this.options.propertyValidation = !!parameters.propertyValidation;
146			this.options.priceDiffWithLastTime = false;
147
148			this.options.pickUpMap = parameters.pickUpMap;
149			this.options.propertyMap = parameters.propertyMap;
150
151			this.options.totalPriceChanged = false;
152
153			if (!this.result.IS_AUTHORIZED || typeof this.result.LAST_ORDER_DATA.FAIL !== 'undefined')
154					this.initFirstSection();
155
156			this.initOptions();
157			
158			
159			this.editOrder();
160			this.bindEvents();
161
162			this.orderBlockNode.removeAttribute('style');
163			this.basketBlockScrollCheck();
164
165			if (this.params.USE_ENHANCED_ECOMMERCE === 'Y')
166			{
167				this.setAnalyticsDataLayer('checkout');
168			}
169
170			if (this.params.USER_CONSENT === 'Y')
171			{
172				this.initUserConsent();
173			}
174		},
175
176		/**
177		 * Send ajax request with order data and executes callback by action
178		 */
179		sendRequest: function(action, actionData)
180		{
181			var form;
182
183			if (!this.startLoader())
184				return;
185
186			
187
188			this.firstLoad = false;
189
190			action = BX.type.isNotEmptyString(action) ? action : 'refreshOrderAjax';
191
192
193
194			if (action === 'saveOrderAjax')
195			{
196				form = BX('bx-soa-order-form');
197				if (form)
198				{
199					form.querySelector('input[type=hidden][name=sessid]').value = BX.bitrix_sessid();
200				}
201
202				BX.ajax.submitAjax(
203					BX('bx-soa-order-form'),
204					{
205						url: this.ajaxUrl,
206						method: 'POST',
207						dataType: 'json',
208						data: {
209							via_ajax: 'Y',
210							action: 'saveOrderAjax',
211							sessid: BX.bitrix_sessid(),
212							SITE_ID: this.siteId,
213							signedParamsString: this.signedParamsString
214						},
215						onsuccess: BX.proxy(this.saveOrderWithJson, this),
216						onfailure: BX.proxy(this.handleNotRedirected, this)
217					}
218				);
219			}
220			else
221			{
222				BX.ajax({
223					method: 'POST',
224					dataType: 'json',
225					url: this.ajaxUrl,
226					data: this.getData(action, actionData),
227					onsuccess: BX.delegate(function(result) {
228						/*if (result.redirect && result.redirect.length && actionData != "noRedirect")
229							document.location.href = result.redirect;*/
230
231						if(result.success != 'N')
232						{
233							this.saveFiles();
234							switch (action)
235							{
236								case 'refreshOrderAjax':
237									this.refreshOrder(result);
238									break;
239								case 'confirmSmsCode':
240								case 'showAuthForm':
241									this.firstLoad = true;
242									this.refreshOrder(result);
243									break;
244								case 'enterCoupon':
245									if (result && result.order)
246									{
247										this.deliveryCachedInfo = [];
248										this.refreshOrder(result);
249									}
250									else
251									{
252										this.addCoupon(result);
253									}
254
255									break;
256								case 'removeCoupon':
257									if (result && result.order)
258									{
259										this.deliveryCachedInfo = [];
260										this.refreshOrder(result);
261									}
262									else
263									{
264										this.removeCoupon(result);
265									}
266
267									break;
268							}
269							BX.cleanNode(this.savedFilesBlockNode);
270
271							$('.date-group').datetimepicker({
272				                timepicker: false,
273				                format: 'd.m.Y',
274				                scrollMonth: false,
275				                scrollInput: false,
276				                dayOfWeekStart: 1
277				            });
278
279
280							if($(window).width()>767)
281							{
282								$('[data-toggle="tooltip"]').tooltip({
283						            html:true
284						        });
285							}
286				            
287
288					        if($("#btnOrderSaveFly").length>0)
289							{
290								if($("#btnOrderSaveFly").hasClass('first-click'))
291								{
292								    $(window).scroll(function() {
293								        if($(document).scrollTop() > $("#bx-soa-order").offset().top && $("#btnOrderSaveFly").hasClass('first-click'))
294								            $("#btnOrderSaveFly").removeClass('first-click');
295								    });
296								}
297							}
298
299							this.bindEvents();
300
301							initPhoneMask();
302							
303						}
304						else
305						{
306							this.emptyBasketHTML(0);
307						}
308						this.endLoader();
309					}, this),
310					onfailure: BX.delegate(function(){
311						this.endLoader();
312					}, this)
313				});
314			}
315		},
316
317		getData: function(action, actionData)
318		{
319			var data = {
320				order: this.getAllFormData(),
321				sessid: BX.bitrix_sessid(),
322				via_ajax: 'Y',
323				SITE_ID: this.siteId,
324				signedParamsString: this.signedParamsString
325			};
326
327			data[this.params.ACTION_VARIABLE] = action;
328
329			if (action === 'enterCoupon' || action === 'removeCoupon')
330				data.coupon = actionData;
331
332			return data;
333		},
334
335		getAllFormData: function()
336		{
337			var form = BX('bx-soa-order-form'),
338				prepared = BX.ajax.prepareForm(form),
339				i;
340
341			for (i in prepared.data)
342			{
343				if (prepared.data.hasOwnProperty(i) && i == '')
344				{
345					delete prepared.data[i];
346				}
347			}
348
349			return !!prepared && prepared.data ? prepared.data : {};
350		},
351
352		/**
353		 * Refreshes order via json data from ajax request
354		 */
355		refreshOrder: function(result)
356		{
357			if (result.error)
358			{
359				this.showError(this.mainErrorsNode, result.error);
360				this.animateScrollTo(this.mainErrorsNode, 800, 20);
361			}
362			/*else if (result.order.SHOW_AUTH)
363			{
364				var animation = result.order.OK_MESSAGE && result.order.OK_MESSAGE.length || result.order.SMS_AUTH.TYPE === 'OK' ? 'bx-step-good' : 'bx-step-bad';
365				this.addAnimationEffect(this.authBlockNode, animation);
366				BX.merge(this.result, result.order);
367				this.editAuthBlock();
368				this.showAuthBlock();
369				this.showErrors(result.order.ERROR, false);
370				this.animateScrollTo(this.authBlockNode);
371			}*/
372			else
373			{
374				this.isPriceChanged(result);
375
376				if (this.activeSectionId !== this.deliveryBlockNode.id)
377					this.deliveryCachedInfo = [];
378
379				this.result = result.order;
380				this.prepareLocations(result.locations);
381				this.locationsInitialized = false;
382				this.maxWaitTimeExpired = false;
383				this.pickUpMapFocused = false;
384				this.deliveryLocationInfo = {};
385
386				this.initialized = {};
387				this.clearHiddenBlocks();
388
389				this.initOptions();
390				this.editOrder();
391				
392				this.mapsReady && this.initMaps();
393				BX.saleOrderAjax && BX.saleOrderAjax.initDeferredControl();
394			}
395
396			return true;
397		},
398
399		saveOrderWithJson: function(result)
400		{
401			var redirected = false;
402
403			if (result && result.order)
404			{
405				result = result.order;
406
407				if (result.REDIRECT_URL)
408				{
409					if (this.params.USE_ENHANCED_ECOMMERCE === 'Y')
410					{
411						this.setAnalyticsDataLayer('purchase', result.ID);
412					}
413
414					redirected = true;
415					location.href = result.REDIRECT_URL;
416				}
417				else if (result.SHOW_AUTH)
418				{
419					this.result.SHOW_AUTH = result.SHOW_AUTH;
420					this.result.AUTH = result.AUTH;
421					this.result.SMS_AUTH = result.SMS_AUTH;
422
423					this.editAuthBlock();
424					this.showAuthBlock();
425					this.animateScrollTo(this.authBlockNode);
426				}
427				else
428				{
429					this.showErrors(result.ERROR, true, true);
430				}
431			}
432
433			if (!redirected)
434			{
435				this.handleNotRedirected();
436			}
437		},
438
439		handleNotRedirected: function()
440		{
441			this.endLoader();
442			this.disallowOrderSave();
443		},
444
445		/**
446		 * Showing loader image with overlay.
447		 */
448		startLoader: function()
449		{
450			if (this.BXFormPosting === true)
451				return false;
452
453			this.BXFormPosting = true;
454
455			showProcessLoad();
456
457			/*if (!this.loadingScreen)
458			{
459				this.loadingScreen = new BX.PopupWindow('loading_screen', null, {
460					overlay: {backgroundColor: 'white', opacity: 1},
461					events: {
462						onAfterPopupShow: BX.delegate(function(){
463							BX.cleanNode(this.loadingScreen.popupContainer);
464							BX.removeClass(this.loadingScreen.popupContainer, 'popup-window');
465							this.loadingScreen.popupContainer.appendChild(
466								BX.create('IMG', {props: {src: this.templateFolder + '/images/loader.gif'}})
467							);
468							this.loadingScreen.popupContainer.removeAttribute('style');
469							this.loadingScreen.popupContainer.style.display = 'block';
470						}, this)
471					}
472				});
473				BX.addClass(this.loadingScreen.overlay.element, 'bx-step-opacity');
474			}
475
476			this.loadingScreen.overlay.element.style.opacity = '0';
477			this.loadingScreen.show();
478			this.loadingScreen.overlay.element.style.opacity = '0.6';*/
479
480			return true;
481		},
482
483		/**
484		 * Hiding loader image with overlay.
485		 */
486		endLoader: function()
487		{
488			this.BXFormPosting = false;
489
490			closeProcessLoad();
491		},
492
493		htmlspecialcharsEx: function(str)
494		{
495			return str.replace(/&amp;/g, '&amp;amp;')
496				.replace(/&lt;/g, '&amp;lt;').replace(/&gt;/g, '&amp;gt;')
497				.replace(/&quot;/g, '&amp;quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
498		},
499
500		saveFiles: function()
501		{
502			if (this.result.ORDER_PROP && this.result.ORDER_PROP.properties)
503			{
504				var props = this.result.ORDER_PROP.properties, i, prop;
505				for (i = 0; i < props.length; i++)
506				{
507					if (props[i].TYPE == 'FILE')
508					{
509						prop = this.orderBlockNode.querySelector('div[data-property-id-row="' + props[i].ID + '"]');
510						if (prop)
511							this.savedFilesBlockNode.appendChild(prop);
512					}
513				}
514			}
515		},
516
517		/**
518		 * Animating scroll to certain node
519		 */
520		animateScrollTo: function(node, duration, shiftToTop)
521		{
522			if (!node)
523				return;
524
525			var scrollTop = BX.GetWindowScrollPos().scrollTop,
526				orderBlockPos = BX.pos(this.orderBlockNode),
527				ghostTop = BX.pos(node).top - (this.isMobile ? 50 : 0);
528
529			if (shiftToTop)
530				ghostTop -= parseInt(shiftToTop);
531
532			if (ghostTop + window.innerHeight > orderBlockPos.bottom)
533				ghostTop = orderBlockPos.bottom - window.innerHeight + 17;
534
535			new BX.easing({
536				duration: duration || 800,
537				start: {scroll: scrollTop},
538				finish: {scroll: ghostTop},
539				transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
540				step: BX.delegate(function(state){
541					window.scrollTo(0, state.scroll);
542				}, this)
543			}).animate();
544		},
545
546		checkKeyPress: function(event)
547		{
548			if (event.keyCode == 13)
549			{
550				var target = event.target || event.srcElement,
551					send = target.getAttribute('data-send'),
552					nextAttr, next;
553
554				if (!send)
555				{
556					nextAttr = target.getAttribute('data-next');
557					if (nextAttr)
558					{
559						next = this.orderBlockNode.querySelector('input[name=' + nextAttr + ']');
560						next && next.focus();
561					}
562
563					return BX.PreventDefault(event);
564				}
565			}
566		},
567
568		getSizeString: function(maxSize, len)
569		{
570			var gbDivider = 1024 * 1024 * 1024,
571				mbDivider = 1024 * 1024,
572				kbDivider = 1024,
573				str;
574
575			maxSize = parseInt(maxSize);
576			len = parseInt(len);
577
578			if (maxSize > gbDivider)
579				str = parseFloat(maxSize / gbDivider).toFixed(len) + ' Gb';
580			else if (maxSize > mbDivider)
581				str = parseFloat(maxSize / mbDivider).toFixed(len) + ' Mb';
582			else if (maxSize > kbDivider)
583				str = parseFloat(maxSize / kbDivider).toFixed(len) + ' Kb';
584			else
585				str = maxSize + ' B';
586
587			return str;
588		},
589
590		getFileAccepts: function(accepts)
591		{
592			var arr = [],
593				arAccepts = accepts.split(','),
594				i, currentAccept;
595
596			var mimeTypesMap = {
597				json: 'application/json', javascript: 'application/javascript', 'octet-stream': 'application/octet-stream',
598				ogg: 'application/ogg', pdf: 'application/pdf', zip: 'application/zip', gzip: 'application/gzip',
599				aac: 'audio/aac', mp3: 'audio/mpeg', gif: 'image/gif', jpeg: 'image/jpeg', png: 'image/png', svg: 'image/svg+xml',
600				tiff: 'image/tiff', css: 'text/css', csv: 'text/csv', html: 'text/html', plain: 'text/plain',
601				php: 'text/php', xml: 'text/xml', mpeg: 'video/mpeg', mp4: 'video/mp4', quicktime: 'video/quicktime',
602				flv: 'video/x-flv', doc: 'application/msword', docx: 'application/msword',
603				xls: 'application/vnd.ms-excel', xlsx: 'application/vnd.ms-excel'
604			};
605
606			for (i = 0; i < arAccepts.length; i++)
607			{
608				currentAccept = BX.util.trim(arAccepts[i]);
609				currentAccept = mimeTypesMap[currentAccept] || currentAccept;
610				arr.push(currentAccept);
611			}
612
613			return arr.join(',');
614		},
615
616		uniqueText: function(text, separator)
617		{
618			var phrases, i, output = [];
619
620			text = text || '';
621			separator = separator || '<br>';
622
623			phrases = text.split(separator);
624			phrases = BX.util.array_unique(phrases);
625
626			for (i = 0; i < phrases.length; i++)
627			{
628				if (phrases[i] == '')
629					continue;
630
631				output.push(BX.util.trim(phrases[i]));
632			}
633
634			return output.join(separator);
635		},
636
637		getImageSources: function(item, key)
638		{
639			if (!item || !key || !item[key])
640				return false;
641
642			return {
643				src_1x: item[key + '_SRC'],
644				src_2x: item[key + '_SRC_2X'],
645				src_orig: item[key + '_SRC_ORIGINAL']
646			};
647		},
648
649		getErrorContainer: function(node)
650		{
651			if (!node)
652				return;
653
654			node.appendChild(
655				BX.create('DIV', {props: {className: 'alert alert-danger'}, style: {display: 'none'}})
656			);
657		},
658
659		showError: function(node, msg, border)
660		{
661			if (BX.type.isArray(msg))
662				msg = msg.join('<br>');
663
664			var errorContainer = node.querySelector('.alert.alert-danger'), animate;
665			if (errorContainer && msg.length)
666			{
667				BX.cleanNode(errorContainer);
668				errorContainer.appendChild(BX.create('DIV', {html: msg}));
669
670				animate = !this.hasErrorSection[node.id];
671				if (animate)
672				{
673					errorContainer.style.opacity = 0;
674					errorContainer.style.display = '';
675					new BX.easing({
676						duration: 300,
677						start: {opacity: 0},
678						finish: {opacity: 100},
679						transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
680						step: function(state){
681							errorContainer.style.opacity = state.opacity / 100;
682						},
683						complete: function(){
684							errorContainer.removeAttribute('style');
685						}
686					}).animate();
687				}
688				else
689					errorContainer.style.display = '';
690
691				if (!!border)
692					BX.addClass(node, 'bx-step-error');
693			}
694		},
695
696		showErrors: function(errors, scroll, showAll)
697		{
698			var errorNodes = this.orderBlockNode.querySelectorAll('div.alert.alert-danger'),
699				section, k, blockErrors;
700
701			for (k = 0; k < errorNodes.length; k++)
702			{
703				section = BX.findParent(errorNodes[k], {className: 'bx-soa-section'});
704				BX.removeClass(section, 'bx-step-error');
705				errorNodes[k].style.display = 'none';
706				BX.cleanNode(errorNodes[k]);
707			}
708
709			if (!errors || BX.util.object_keys(errors).length < 1)
710				return;
711
712			for (k in errors)
713			{
714				if (!errors.hasOwnProperty(k))
715					continue;
716
717				blockErrors = errors[k];
718				switch (k.toUpperCase())
719				{
720					case 'MAIN':
721						this.showError(this.mainErrorsNode, blockErrors);
722						this.animateScrollTo(this.mainErrorsNode, 800, 20);
723						scroll = false;
724						break;
725					case 'AUTH':
726						if (this.authBlockNode.style.display == 'none')
727						{
728							this.showError(this.mainErrorsNode, blockErrors, true);
729							this.animateScrollTo(this.mainErrorsNode, 800, 20);
730							scroll = false;
731						}
732						else
733							this.showError(this.authBlockNode, blockErrors, true);
734						break;
735					case 'REGION':
736						if (showAll || this.regionBlockNode.getAttribute('data-visited') === 'true')
737						{
738							this.showError(this.regionBlockNode, blockErrors, true);
739							this.showError(this.regionHiddenBlockNode, blockErrors);
740						}
741						break;
742					case 'DELIVERY':
743						if (showAll || this.deliveryBlockNode.getAttribute('data-visited') === 'true')
744						{
745							this.showError(this.deliveryBlockNode, blockErrors, true);
746							this.showError(this.deliveryHiddenBlockNode, blockErrors);
747						}
748						break;
749					case 'PAY_SYSTEM':
750						if (showAll || this.paySystemBlockNode.getAttribute('data-visited') === 'true')
751						{
752							this.showError(this.paySystemBlockNode, blockErrors, true);
753							this.showError(this.paySystemHiddenBlockNode, blockErrors);
754						}
755						break;
756					case 'PROPERTY':
757						if (showAll || this.propsBlockNode.getAttribute('data-visited') === 'true')
758						{
759							this.showError(this.propsBlockNode, blockErrors, true);
760							this.showError(this.propsHiddenBlockNode, blockErrors);
761						}
762						break;
763				}
764			}
765
766			!!scroll && this.scrollToError();
767		},
768
769		showBlockErrors: function(node)
770		{
771			var errorNode = node.querySelector('div.alert.alert-danger'),
772				hiddenNode, errors;
773
774			if (!errorNode)
775				return;
776
777			BX.removeClass(node, 'bx-step-error');
778			errorNode.style.display = 'none';
779			BX.cleanNode(errorNode);
780
781			switch (node.id)
782			{
783				case this.regionBlockNode.id:
784					hiddenNode = this.regionHiddenBlockNode;
785					errors = this.result.ERROR.REGION;
786					break;
787				case this.deliveryBlockNode.id:
788					hiddenNode = this.deliveryHiddenBlockNode;
789					errors = this.result.ERROR.DELIVERY;
790					break;
791				case this.paySystemBlockNode.id:
792					hiddenNode = this.paySystemHiddenBlockNode;
793					errors = this.result.ERROR.PAY_SYSTEM;
794					break;
795				case this.propsBlockNode.id:
796					hiddenNode = this.propsHiddenBlockNode;
797					errors = this.result.ERROR.PROPERTY;
798					break;
799			}
800
801			if (errors && BX.util.object_keys(errors).length)
802			{
803				this.showError(node, errors, true);
804				this.showError(hiddenNode, errors);
805			}
806		},
807
808		checkNotifications: function()
809		{
810			/*var informer = this.mainErrorsNode.querySelector('[data-type="informer"]'),
811				success, sections, className, text, scrollTop, informerPos;
812
813			if (informer)
814			{
815				if (this.firstLoad && this.result.IS_AUTHORIZED && typeof this.result.LAST_ORDER_DATA.FAIL === 'undefined')
816				{
817					sections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active');
818					success = sections.length && sections[sections.length - 1].getAttribute('data-visited') == 'true';
819					className = success ? 'success' : 'warning';
820					text = (success ? this.params.MESS_SUCCESS_PRELOAD_TEXT : this.params.MESS_FAIL_PRELOAD_TEXT).split('#ORDER_BUTTON#').join(this.params.MESS_ORDER);
821
822					informer.appendChild(
823						BX.create('DIV', {
824							props: {className: 'row'},
825							children: [
826								BX.create('DIV', {
827									props: {className: 'col-xs-12'},
828									style: {position: 'relative', paddingLeft: '48px'},
829									children: [
830										BX.create('DIV', {props: {className: 'icon-' + className}}),
831										BX.create('DIV', {html: text})
832									]
833								})
834							]
835						})
836					);
837					BX.addClass(informer, 'alert alert-' + className);
838					informer.style.display = '';
839				}
840				else if (BX.hasClass(informer, 'alert'))
841				{
842					scrollTop = BX.GetWindowScrollPos().scrollTop;
843					informerPos = BX.pos(informer);
844
845					new BX.easing({
846						duration: 300,
847						start: {opacity: 100},
848						finish: {opacity: 0},
849						transition: BX.easing.transitions.linear,
850						step: function(state){
851							informer.style.opacity = state.opacity / 100;
852						},
853						complete: function(){
854							if (scrollTop > informerPos.top)
855								window.scrollBy(0, -(informerPos.height + 20));
856
857							informer.style.display = 'none';
858							BX.cleanNode(informer);
859							informer.removeAttribute('class');
860							informer.removeAttribute('style');
861						}
862					}).animate();
863				}
864			}*/
865		},
866
867		/**
868		 * Returns status of preloaded data from back-end for certain block
869		 */
870		checkPreload: function(node)
871		{
872			var status;
873
874			switch (node.id)
875			{
876				case this.regionBlockNode.id:
877					status = this.result.LAST_ORDER_DATA && this.result.LAST_ORDER_DATA.PERSON_TYPE;
878					break;
879				case this.paySystemBlockNode.id:
880					status = this.result.LAST_ORDER_DATA && this.result.LAST_ORDER_DATA.PAY_SYSTEM;
881					break;
882				case this.deliveryBlockNode.id:
883					status = this.result.LAST_ORDER_DATA && this.result.LAST_ORDER_DATA.DELIVERY;
884					break;
885				case this.pickUpBlockNode.id:
886					status = this.result.LAST_ORDER_DATA && this.result.LAST_ORDER_DATA.PICK_UP;
887					break;
888				default:
889					status = true;
890			}
891
892			return status;
893		},
894
895		checkBlockErrors: function(node)
896		{
897			var hiddenNode, errorNode, showError, showWarning, errorTooltips, i;
898
899			if (hiddenNode = BX(node.id + '-hidden'))
900			{
901				errorNode = hiddenNode.querySelector('div.alert.alert-danger');
902				showError = errorNode && errorNode.style.display != 'none';
903				showWarning = hiddenNode.querySelector('div.alert.alert-warning.alert-show');
904
905				if (!showError)
906				{
907					errorTooltips = hiddenNode.querySelectorAll('div.tooltip');
908					for (i = 0; i < errorTooltips.length; i++)
909					{
910						if (errorTooltips[i].getAttribute('data-state') == 'opened')
911						{
912							showError = true;
913							break;
914						}
915					}
916				}
917			}
918
919			if (showError)
920				BX.addClass(node, 'bx-step-error');
921			else if (showWarning)
922				BX.addClass(node, 'bx-step-warning');
923			else
924				BX.removeClass(node, 'bx-step-error bx-step-warning');
925
926			return !showError;
927		},
928
929		scrollToError: function()
930		{
931			var sections = this.orderBlockNode.querySelectorAll('div.bx-soa-section.bx-active'),
932				i, errorNode;
933
934			for (i in sections)
935			{
936				if (sections.hasOwnProperty(i))
937				{
938					errorNode = sections[i].querySelector('.alert.alert-danger');
939					if (errorNode && errorNode.style.display != 'none')
940					{
941						this.animateScrollTo(sections[i]);
942						break;
943					}
944				}
945			}
946		},
947
948		showWarnings: function()
949		{
950			var sections = this.orderBlockNode.querySelectorAll('div.bx-soa-section.bx-active'),
951				currentDelivery = this.getSelectedDelivery(),
952				k,  warningString;
953
954			for (k = 0; k < sections.length; k++)
955			{
956				BX.removeClass(sections[k], 'bx-step-warning');
957
958				if (sections[k].getAttribute('data-visited') == 'false')
959					BX.removeClass(sections[k], 'bx-step-completed');
960			}
961
962			if (currentDelivery && currentDelivery.CALCULATE_ERRORS)
963			{
964				BX.addClass(this.deliveryBlockNode, 'bx-step-warning');
965
966				warningString = '<strong>' + this.params.MESS_DELIVERY_CALC_ERROR_TITLE + '</strong>';
967				if (this.params.MESS_DELIVERY_CALC_ERROR_TEXT.length)
968					warningString += '<br><small>' + this.params.MESS_DELIVERY_CALC_ERROR_TEXT + '</small>';
969
970				this.showBlockWarning(this.deliveryBlockNode, warningString);
971				this.showBlockWarning(this.deliveryHiddenBlockNode, warningString);
972
973				if (this.activeSectionId != this.deliveryBlockNode.id)
974				{
975					BX.addClass(this.deliveryBlockNode, 'bx-step-completed');
976					BX.bind(this.deliveryBlockNode.querySelector('.alert.alert-warning'), 'click', BX.proxy(this.showByClick, this));
977				}
978			}
979			else if (BX.hasClass(this.deliveryBlockNode, 'bx-step-warning') && this.activeSectionId != this.deliveryBlockNode.id)
980			{
981				BX.removeClass(this.deliveryBlockNode, 'bx-step-warning');
982			}
983
984			if (!this.result.WARNING || !this.options.showWarnings)
985				return;
986
987			for (k in this.result.WARNING)
988			{
989				if (this.result.WARNING.hasOwnProperty(k))
990				{
991					switch (k.toUpperCase())
992					{
993						case 'DELIVERY':
994							if (this.deliveryBlockNode.getAttribute('data-visited') === 'true')
995							{
996								this.showBlockWarning(this.deliveryBlockNode, this.result.WARNING[k], true);
997								this.showBlockWarning(this.deliveryHiddenBlockNode, this.result.WARNING[k], true);
998							}
999
1000							break;
1001						case 'PAY_SYSTEM':
1002							if (this.paySystemBlockNode.getAttribute('data-visited') === 'true')
1003							{
1004								this.showBlockWarning(this.paySystemBlockNode, this.result.WARNING[k], true);
1005								this.showBlockWarning(this.paySystemHiddenBlockNode, this.result.WARNING[k], true);
1006							}
1007
1008							break;
1009					}
1010				}
1011			}
1012		},
1013
1014		notifyAboutWarnings: function(node)
1015		{
1016			if (!BX.type.isDomNode(node))
1017				return;
1018
1019			switch (node.id)
1020			{
1021				case this.deliveryBlockNode.id:
1022					this.showBlockWarning(this.deliveryBlockNode, this.result.WARNING.DELIVERY, true);
1023					break;
1024				case this.paySystemBlockNode.id:
1025					this.showBlockWarning(this.paySystemBlockNode, this.result.WARNING.PAY_SYSTEM, true);
1026					break;
1027			}
1028		},
1029
1030		showBlockWarning: function(node, warnings, hide)
1031		{
1032			var errorNode = node.querySelector('.alert.alert-danger'),
1033				warnStr = '',
1034				i, warningNode, existedWarningNodes;
1035
1036			if (errorNode)
1037			{
1038				if (BX.type.isString(warnings))
1039				{
1040					warnStr = warnings;
1041				}
1042				else
1043				{
1044					for (i in warnings)
1045					{
1046						if (warnings.hasOwnProperty(i) && warnings[i])
1047						{
1048							warnStr += warnings[i] + '<br>';
1049						}
1050					}
1051				}
1052
1053				if (!warnStr)
1054				{
1055					return;
1056				}
1057
1058				existedWarningNodes = node.querySelectorAll('.alert.alert-warning');
1059				for (i in existedWarningNodes)
1060				{
1061					if (existedWarningNodes.hasOwnProperty(i) && BX.type.isDomNode(existedWarningNodes[i]))
1062					{
1063						if (existedWarningNodes[i].innerHTML.indexOf(warnStr) !== -1)
1064						{
1065							return;
1066						}
1067					}
1068				}
1069
1070				warningNode = BX.create('DIV', {
1071					props: {className: 'alert alert-warning' + (!!hide ? ' alert-hide' : ' alert-show')},
1072					html: warnStr
1073				});
1074				BX.prepend(warningNode, errorNode.parentNode);
1075				BX.addClass(node, 'bx-step-warning');
1076			}
1077		},
1078
1079		showPagination: function(entity, node)
1080		{
1081			if (!node || !entity)
1082				return;
1083
1084			var pagination, navigation = [], i,
1085				pageCounter, active,
1086				colorTheme, paginationNode;
1087
1088			switch (entity)
1089			{
1090				case 'delivery':
1091					pagination = this.deliveryPagination; break;
1092				case 'paySystem':
1093					pagination = this.paySystemPagination; break;
1094				case 'pickUp':
1095					pagination = this.pickUpPagination; break;
1096			}
1097
1098
1099			if (pagination.pages.length > 1)
1100			{
1101				navigation.push(
1102					BX.create('LI', {
1103						attrs: {
1104							'data-action': 'prev',
1105							'data-entity': entity
1106						},
1107						props: {className: 'bx-pag-prev'},
1108						html: pagination.pageNumber == 1
1109							? '<span></span>'
1110							: '<a href=""><span></span></a>',
1111						events: {click: BX.proxy(this.doPagination, this)}
1112					})
1113				);
1114				for (i = 0; i < pagination.pages.length; i++)
1115				{
1116					pageCounter = parseInt(i) + 1;
1117					active = pageCounter == pagination.pageNumber ? 'bx-active' : '';
1118
1119					navigation.push(
1120						BX.create('LI', {
1121							attrs: {
1122								'data-action': pageCounter,
1123								'data-entity': entity
1124							},
1125							props: {className: active},
1126							html: '<a href=""><span>' + pageCounter  + '</span></a>',
1127							events: {click: BX.proxy(this.doPagination, this)}
1128						})
1129					);
1130				}
1131
1132				navigation.push(
1133					BX.create('LI', {
1134						attrs: {
1135							'data-action': 'next',
1136							'data-entity': entity
1137						},
1138						props: {className: 'bx-pag-next'},
1139						html: pagination.pageNumber == pagination.pages.length
1140							? '<span></span>'
1141							: '<a><span></span></a>',
1142						events: {click: BX.proxy(this.doPagination, this)}
1143					})
1144				);
1145				colorTheme = this.params.TEMPLATE_THEME || '';
1146				paginationNode = BX.create('DIV', {
1147					props: {className: 'bx-pagination cpt-pagination col-12'},
1148					children: [
1149						BX.create('DIV', {
1150							props: {className: 'bx-pagination-container'},
1151							children: [BX.create('UL', {children: navigation})]
1152						})
1153					]
1154				});
1155
1156				/*node.appendChild(BX.create('DIV', {style: {clear: 'both'}}));*/
1157				node.appendChild(paginationNode);
1158			}
1159		},
1160
1161		doPagination: function(e)
1162		{
1163			var target = e.target || e.srcElement,
1164				node = target.tagName == 'LI' ? target : BX.findParent(target, {tagName: 'LI'}),
1165				page = node.getAttribute('data-action'),
1166				entity = node.getAttribute('data-entity'),
1167				pageNum;
1168
1169			if (BX.hasClass(node, 'bx-active'))
1170				return BX.PreventDefault(e);
1171
1172			if (page == 'prev' || page == 'next')
1173			{
1174				pageNum = parseInt(BX.findParent(node).querySelector('.bx-active').getAttribute('data-action'));
1175				page = page == 'next' ? ++pageNum : --pageNum;
1176			}
1177
1178			if (entity == 'delivery')
1179				this.showDeliveryItemsPage(page);
1180			else if (entity == 'paySystem')
1181				this.showPaySystemItemsPage(page);
1182			else if (entity == 'pickUp')
1183				this.showPickUpItemsPage(page);
1184
1185			return BX.PreventDefault(e);
1186		},
1187
1188		showDeliveryItemsPage: function(page)
1189		{
1190			this.getCurrentPageItems('delivery', page);
1191
1192			var selectedDelivery = this.getSelectedDelivery(), hidden,
1193				deliveryItemsContainer, k, deliveryItemNode;
1194
1195			if (selectedDelivery && selectedDelivery.ID)
1196			{
1197				hidden = this.deliveryBlockNode.querySelector('input[type=hidden][name=DELIVERY_ID]');
1198				if (!hidden)
1199				{
1200					hidden = BX.create('INPUT', {
1201						props: {
1202							type: 'hidden',
1203							name: 'DELIVERY_ID',
1204							value: selectedDelivery.ID
1205						}
1206					})
1207				}
1208			}
1209
1210
1211
1212			deliveryItemsContainer = this.deliveryBlockNode.querySelector('.bx-soa-pp-item-container');
1213			BX.cleanNode(deliveryItemsContainer);
1214			if (BX.type.isDomNode(hidden))
1215				BX.prepend(hidden, BX.findParent(deliveryItemsContainer));
1216
1217			for (k = 0; k < this.deliveryPagination.currentPage.length; k++)
1218			{
1219				deliveryItemNode = this.createDeliveryItem(this.deliveryPagination.currentPage[k]);
1220				deliveryItemsContainer.appendChild(deliveryItemNode);
1221			}
1222
1223			this.showPagination('delivery', deliveryItemsContainer);
1224		},
1225
1226		showPaySystemItemsPage: function(page)
1227		{
1228			this.getCurrentPageItems('paySystem', page);
1229
1230			var selectedPaySystem = this.getSelectedPaySystem(), hidden,
1231				paySystemItemsContainer, k, paySystemItemNode;
1232
1233			if (selectedPaySystem && selectedPaySystem.ID)
1234			{
1235				hidden = this.paySystemBlockNode.querySelector('input[type=hidden][name=PAY_SYSTEM_ID]');
1236
1237				if (!hidden)
1238				{
1239					hidden = BX.create('INPUT', {
1240						props: {
1241							type: 'hidden',
1242							name: 'PAY_SYSTEM_ID',
1243							value: selectedPaySystem.ID
1244						}
1245					})
1246				}
1247			}
1248
1249			paySystemItemsContainer = this.paySystemBlockNode.querySelector('.bx-soa-pp-item-container');
1250
1251			BX.cleanNode(paySystemItemsContainer);
1252
1253			if (BX.type.isDomNode(hidden))
1254				BX.prepend(hidden, BX.findParent(paySystemItemsContainer));
1255
1256
1257			for (k = 0; k < this.paySystemPagination.currentPage.length; k++)
1258			{
1259				paySystemItemNode = this.createPaySystemItem(this.paySystemPagination.currentPage[k]);
1260				paySystemItemsContainer.appendChild(paySystemItemNode);
1261			}
1262
1263
1264			this.showPagination('paySystem', paySystemItemsContainer);
1265		},
1266
1267		showPickUpItemsPage: function(page)
1268		{
1269			this.getCurrentPageItems('pickUp', page);
1270			this.editPickUpList(false);
1271		},
1272
1273		getCurrentPageItems: function(entity, page)
1274		{
1275			if (!entity || typeof page === 'undefined')
1276				return;
1277
1278			var pagination, perPage;
1279
1280			switch (entity)
1281			{
1282				case 'delivery':
1283					pagination = this.deliveryPagination;
1284					perPage = this.options.deliveriesPerPage;
1285					break;
1286				case 'paySystem':
1287					pagination = this.paySystemPagination;
1288					perPage = this.options.paySystemsPerPage;
1289					break;
1290				case 'pickUp':
1291					pagination = this.pickUpPagination;
1292					perPage = this.options.pickUpsPerPage;
1293					break;
1294			}
1295
1296			if (pagination && perPage > 0)
1297			{
1298				if (page <= 0 || page > pagination.pages.length)
1299					return;
1300
1301				pagination.pageNumber = page;
1302				pagination.currentPage = pagination.pages.slice(pagination.pageNumber - 1, pagination.pageNumber)[0];
1303			}
1304		},
1305
1306		initPropsListForLocation: function()
1307		{
1308			if (BX.saleOrderAjax && this.result.ORDER_PROP && this.result.ORDER_PROP.properties)
1309			{
1310				var i, k, curProp, attrObj;
1311
1312				BX.saleOrderAjax.cleanUp();
1313
1314				for (i = 0; i < this.result.ORDER_PROP.properties.length; i++)
1315				{
1316					curProp = this.result.ORDER_PROP.properties[i];
1317
1318					if (curProp.TYPE == 'LOCATION' && curProp.MULTIPLE == 'Y' && curProp.IS_LOCATION != 'Y')
1319					{
1320						for (k = 0; k < this.locations[curProp.ID].length; k++)
1321						{
1322							BX.saleOrderAjax.addPropertyDesc({
1323								id: curProp.ID + '_' + k,
1324								attributes: {
1325									id: curProp.ID + '_' + k,
1326									type: curProp.TYPE,
1327									valueSource: curProp.SOURCE == 'DEFAULT' ? 'default' : 'form'
1328								}
1329							});
1330						}
1331					}
1332					else
1333					{
1334						attrObj = {
1335							id: curProp.ID,
1336							type: curProp.TYPE,
1337							valueSource: curProp.SOURCE == 'DEFAULT' ? 'default' : 'form'
1338						};
1339
1340						if (!this.deliveryLocationInfo.city && parseInt(curProp.INPUT_FIELD_LOCATION) > 0)
1341						{
1342							attrObj.altLocationPropId = parseInt(curProp.INPUT_FIELD_LOCATION);
1343							this.deliveryLocationInfo.city = curProp.INPUT_FIELD_LOCATION;
1344						}
1345
1346						if (!this.deliveryLocationInfo.loc && curProp.IS_LOCATION == 'Y')
1347							this.deliveryLocationInfo.loc = curProp.ID;
1348
1349						if (!this.deliveryLocationInfo.zip && curProp.IS_ZIP == 'Y')
1350						{
1351							attrObj.isZip = true;
1352							this.deliveryLocationInfo.zip = curProp.ID;
1353						}
1354
1355						BX.saleOrderAjax.addPropertyDesc({
1356							id: curProp.ID,
1357							attributes: attrObj
1358						});
1359					}
1360				}
1361			}
1362		},
1363
1364		/**
1365		 * Binds main events for scrolling/resizing
1366		 */
1367		bindEvents: function()
1368		{
1369			/*BX.bind(this.orderSaveBlockNode.querySelector('[data-save-button]'), 'click', BX.proxy(this.clickOrderSaveAction, this));*/
1370
1371			BX.bind(BX("btnOrderSaveFly"), 'click', BX.proxy(this.clickOrderSaveAction, this));
1372			BX.bind(BX("btnOrderSave"), 'click', BX.proxy(this.clickOrderSaveAction, this));
1373
1374			/*BX.bind(window, 'scroll', BX.proxy(this.totalBlockScrollCheck, this));*/
1375			BX.bind(window, 'resize', BX.throttle(function(){
1376				/*this.totalBlockResizeCheck();*/
1377				this.alignBasketColumns();
1378				this.basketBlockScrollCheck();
1379				this.mapsReady /*&& this.resizeMapContainers();*/
1380			}, 50, this));
1381			BX.addCustomEvent('onDeliveryExtraServiceValueChange', BX.proxy(this.sendRequest, this));
1382		},
1383
1384		initFirstSection: function()
1385		{
1386			var firstSection = this.orderBlockNode.querySelector('.bx-soa-section.bx-active');
1387			BX.addClass(firstSection, 'bx-selected');
1388			this.activeSectionId = firstSection.id;
1389		},
1390
1391		initOptions: function()
1392		{
1393			var headers, i, total;
1394
1395			this.initPropsListForLocation();
1396
1397			this.propertyCollection = new BX.Sale.PropertyCollection(BX.merge
1397({publicMode: true}, this.result.ORDER_PROP));
1398			this.fadedPropertyCollection = new BX.Sale.PropertyCollection(BX.merge({publicMode: true}, this.result.ORDER_PROP));
1399
1400			if (this.options.propertyValidation)
1401				this.initValidation();
1402
1403			this.initPagination();
1404
1405			this.options.showPreviewPicInBasket = false;
1406			this.options.showDetailPicInBasket = false;
1407			this.options.showPropsInBasket = false;
1408			this.options.showPriceNotesInBasket = false;
1409
1410			if (this.result.GRID && this.result.GRID.HEADERS)
1411			{
1412				headers = this.result.GRID.HEADERS;
1413				for (i = 0; i < headers.length; i++)
1414				{
1415					if (headers[i].id === 'PREVIEW_PICTURE')
1416						this.options.showPreviewPicInBasket = true;
1417
1418					if (headers[i].id === 'DETAIL_PICTURE')
1419						this.options.showDetailPicInBasket = true;
1420
1421					if (headers[i].id === 'PROPS')
1422						this.options.showPropsInBasket = true;
1423
1424					if (headers[i].id === 'NOTES')
1425						this.options.showPriceNotesInBasket = true;
1426				}
1427			}
1428
1429			if (this.result.TOTAL)
1430			{
1431				total = this.result.TOTAL;
1432				this.options.showOrderWeight = total.ORDER_WEIGHT && parseFloat(total.ORDER_WEIGHT) > 0;
1433				this.options.showPriceWithoutDiscount = parseFloat(total.ORDER_PRICE) < parseFloat(total.PRICE_WITHOUT_DISCOUNT_VALUE);
1434				this.options.showDiscountPrice = total.DISCOUNT_PRICE && parseFloat(total.DISCOUNT_PRICE) > 0;
1435				this.options.showTaxList = total.TAX_LIST && total.TAX_LIST.length;
1436				this.options.showPayedFromInnerBudget = total.PAYED_FROM_ACCOUNT_FORMATED && total.PAYED_FROM_ACCOUNT_FORMATED.length;
1437			}
1438		},
1439
1440		reachGoal: function(goal, section)
1441		{
1442			var counter = this.params.YM_GOALS_COUNTER || '',
1443				useGoals = this.params.USE_YM_GOALS == 'Y' && typeof window['yaCounter' + counter] !== 'undefined',
1444				goalId;
1445
1446			if (useGoals)
1447			{
1448				goalId = this.getGoalId(goal, section);
1449				window['yaCounter' + counter].reachGoal(goalId);
1450			}
1451		},
1452
1453		getGoalId: function(goal, section)
1454		{
1455			if (!goal)
1456				return '';
1457
1458			if (goal == 'initialization')
1459				return this.params.YM_GOALS_INITIALIZE;
1460
1461			if (goal == 'order')
1462				return this.params.YM_GOALS_SAVE_ORDER;
1463
1464			var goalId = '',
1465				isEdit = goal == 'edit';
1466
1467			if (!section || !section.id)
1468				return '';
1469
1470			switch (section.id)
1471			{
1472				case this.basketBlockNode.id:
1473					goalId = isEdit ? this.params.YM_GOALS_EDIT_BASKET : this.params.YM_GOALS_NEXT_BASKET; break;
1474				case this.regionBlockNode.id:
1475					goalId = isEdit ? this.params.YM_GOALS_EDIT_REGION : this.params.YM_GOALS_NEXT_REGION; break;
1476				case this.paySystemBlockNode.id:
1477					goalId = isEdit ? this.params.YM_GOALS_EDIT_PAY_SYSTEM : this.params.YM_GOALS_NEXT_PAY_SYSTEM; break;
1478				case this.deliveryBlockNode.id:
1479					goalId = isEdit ? this.params.YM_GOALS_EDIT_DELIVERY : this.params.YM_GOALS_NEXT_DELIVERY; break;
1480				case this.pickUpBlockNode.id:
1481					goalId = isEdit ? this.params.YM_GOALS_EDIT_PICKUP : this.params.YM_GOALS_NEXT_PICKUP; break;
1482				case this.propsBlockNode.id:
1483					goalId = isEdit ? this.params.YM_GOALS_EDIT_PROPERTIES : this.params.YM_GOALS_NEXT_PROPERTIES; break;
1484			}
1485
1486			return goalId;
1487		},
1488
1489		isPriceChanged: function(result)
1490		{
1491			
1492
1493			var priceBefore = this.result.TOTAL.ORDER_TOTAL_LEFT_TO_PAY === null || this.result.TOTAL.ORDER_TOTAL_LEFT_TO_PAY === ''
1494					? this.result.TOTAL.ORDER_TOTAL_PRICE
1495					: this.result.TOTAL.ORDER_TOTAL_LEFT_TO_PAY,
1496				priceAfter = result.order.TOTAL.ORDER_TOTAL_LEFT_TO_PAY === null ? result.order.TOTAL.ORDER_TOTAL_PRICE : result.order.TOTAL.ORDER_TOTAL_LEFT_TO_PAY;
1497
1498			this.options.totalPriceChanged = parseFloat(priceBefore) != parseFloat(priceAfter);
1499		},
1500
1501		initValidation: function()
1502		{
1503			if (!this.result.ORDER_PROP || !this.result.ORDER_PROP.properties)
1504				return;
1505
1506			var properties = this.result.ORDER_PROP.properties,
1507				obj = {}, i;
1508
1509			for (i in properties)
1510			{
1511				if (properties.hasOwnProperty(i))
1512					obj[properties[i].ID] = properties[i];
1513			}
1514
1515			this.validation.properties = obj;
1516		},
1517
1518		initPagination: function()
1519		{
1520			var arReserve, pages, arPages, i;
1521
1522			if (this.result.DELIVERY)
1523			{
1524				this.result.DELIVERY = this.getDeliverySortedArray(this.result.DELIVERY);
1525
1526				if (this.options.deliveriesPerPage > 0 && this.result.DELIVERY.length > this.options.deliveriesPerPage)
1527				{
1528					arReserve = this.result.DELIVERY.slice();
1529					pages = Math.ceil(arReserve.length / this.options.deliveriesPerPage);
1530					arPages = [];
1531
1532					for (i = 0; i < pages; i++)
1533					{
1534						arPages.push(arReserve.splice(0, this.options.deliveriesPerPage));
1535					}
1536					this.deliveryPagination.pages = arPages;
1537
1538					for (i = 0; i < this.result.DELIVERY.length; i++)
1539					{
1540						if (this.result.DELIVERY[i].CHECKED == 'Y')
1541						{
1542							this.deliveryPagination.pageNumber = Math.ceil(++i / this.options.deliveriesPerPage);
1543							break;
1544						}
1545					}
1546
1547					this.deliveryPagination.pageNumber = this.deliveryPagination.pageNumber || 1;
1548					this.deliveryPagination.currentPage = arPages.slice(this.deliveryPagination.pageNumber - 1, this.deliveryPagination.pageNumber)[0];
1549					this.deliveryPagination.show = true
1550				}
1551				else
1552				{
1553					this.deliveryPagination.pageNumber = 1;
1554					this.deliveryPagination.currentPage = this.result.DELIVERY;
1555					this.deliveryPagination.show = false;
1556				}
1557			}
1558
1559			if (this.result.PAY_SYSTEM)
1560			{
1561				if (this.options.paySystemsPerPage > 0 && this.result.PAY_SYSTEM.length > this.options.paySystemsPerPage)
1562				{
1563					arReserve = this.result.PAY_SYSTEM.slice();
1564					pages = Math.ceil(arReserve.length / this.options.paySystemsPerPage);
1565					arPages = [];
1566
1567					for (i = 0; i < pages; i++)
1568					{
1569						arPages.push(arReserve.splice(0, this.options.paySystemsPerPage));
1570					}
1571					this.paySystemPagination.pages = arPages;
1572
1573					for (i = 0; i < this.result.PAY_SYSTEM.length; i++)
1574					{
1575						if (this.result.PAY_SYSTEM[i].CHECKED == 'Y')
1576						{
1577							this.paySystemPagination.pageNumber = Math.ceil(++i / this.options.paySystemsPerPage);
1578							break;
1579						}
1580					}
1581
1582					this.paySystemPagination.pageNumber = this.paySystemPagination.pageNumber || 1;
1583					this.paySystemPagination.currentPage = arPages.slice(this.paySystemPagination.pageNumber - 1, this.paySystemPagination.pageNumber)[0];
1584					this.paySystemPagination.show = true
1585				}
1586				else
1587				{
1588					this.paySystemPagination.pageNumber = 1;
1589					this.paySystemPagination.currentPage = this.result.PAY_SYSTEM;
1590					this.paySystemPagination.show = false;
1591				}
1592			}
1593		},
1594
1595		initPickUpPagination: function()
1596		{
1597			var usePickUpPagination = false,
1598				usePickUp = false,
1599				stores, i = 0,
1600				arReserve, pages, arPages;
1601
1602			if (this.options.pickUpsPerPage >= 0 && this.result.DELIVERY)
1603			{
1604				for (i = 0; i < this.result.DELIVERY.length; i++)
1605				{
1606					if (this.result.DELIVERY[i].CHECKED === 'Y' && this.result.DELIVERY[i].STORE_MAIN)
1607					{
1608						usePickUp = this.result.DELIVERY[i].STORE_MAIN.length > 0;
1609						usePickUpPagination = this.result.DELIVERY[i].STORE_MAIN.length > this.options.pickUpsPerPage;
1610						if (usePickUp)
1611							stores = this.getPickUpInfoArray(this.result.DELIVERY[i].STORE_MAIN);
1612						break;
1613					}
1614				}
1615			}
1616
1617			if (usePickUp)
1618			{
1619				if (this.options.pickUpsPerPage > 0 && usePickUpPagination)
1620				{
1621					arReserve = stores.slice();
1622					pages = Math.ceil(arReserve.length / this.options.pickUpsPerPage);
1623					arPages = [];
1624
1625					for (i = 0; i < pages; i++)
1626						arPages.push(arReserve.splice(0, this.options.pickUpsPerPage));
1627
1628					this.pickUpPagination.pages = arPages;
1629
1630					for (i = 0; i < stores.length; i++)
1631					{
1632						if (!this.result.BUYER_STORE || stores[i].ID == this.result.BUYER_STORE)
1633						{
1634							this.pickUpPagination.pageNumber = Math.ceil(++i / this.options.pickUpsPerPage);
1635							break;
1636						}
1637					}
1638
1639					if (!this.pickUpPagination.pageNumber)
1640						this.pickUpPagination.pageNumber = 1;
1641
1642					this.pickUpPagination.currentPage = arPages.slice(this.pickUpPagination.pageNumber - 1, this.pickUpPagination.pageNumber)[0];
1643					this.pickUpPagination.show = true
1644				}
1645				else
1646				{
1647					this.pickUpPagination.pageNumber = 1;
1648					this.pickUpPagination.currentPage = stores;
1649					this.pickUpPagination.show = false;
1650				}
1651			}
1652		},
1653
1654		prepareLocations: function(locations)
1655		{
1656			this.locations = {};
1657			this.cleanLocations = {};
1658
1659			var temporaryLocations,
1660				i, k, output;
1661
1662			if (BX.util.object_keys(locations).length)
1663			{
1664				for (i in locations)
1665				{
1666					if (!locations.hasOwnProperty(i))
1667						continue;
1668
1669
1670					this.locationsTemplate = locations[i].template || '';
1671					temporaryLocations = [];
1672					output = locations[i].output;
1673
1674					if (output.clean)
1675					{
1676						this.cleanLocations[i] = BX.processHTML(output.clean, false);
1677						delete output.clean;
1678					}
1679
1680					for (k in output)
1681					{
1682						if (output.hasOwnProperty(k))
1683						{
1684							temporaryLocations.push({
1685								output: BX.processHTML(output[k], false),
1686								showAlt: locations[i].showAlt,
1687								lastValue: locations[i].lastValue,
1688								coordinates: locations[i].coordinates || false
1689							});
1690						}
1691					}
1692
1693					this.locations[i] = temporaryLocations;
1694				}
1695			}
1696
1697		},
1698
1699		locationsCompletion: function()
1700		{
1701			var i, locationNode, clearButton, inputStep, inputSearch,
1702				arProperty, data, section;
1703
1704			this.locationsInitialized = true;
1705			this.fixLocationsStyle(this.regionBlockNode, this.regionHiddenBlockNode);
1706			this.fixLocationsStyle(this.propsBlockNode, this.propsHiddenBlockNode);
1707
1708			for (i in this.locations)
1709			{
1710				if (!this.locations.hasOwnProperty(i))
1711					continue;
1712
1713				locationNode = this.orderBlockNode.querySelector('div[data-property-id-row="' + i + '"]');
1714				if (!locationNode)
1715					continue;
1716
1717				clearButton = locationNode.querySelector('div.bx-ui-sls-clear');
1718				inputStep = locationNode.querySelector('div.bx-ui-slst-pool');
1719				inputSearch = locationNode.querySelector('input.bx-ui-sls-fake[type=text]');
1720
1721				locationNode.removeAttribute('style');
1722				this.bindValidation(i, locationNode);
1723				if (clearButton)
1724				{
1725					BX.bind(clearButton, 'click', function(e){
1726						var target = e.target || e.srcElement,
1727							parent = BX.findParent(target, {tagName: 'DIV', className: 'bx-form-group'}),
1728							locationInput;
1729
1730						if (parent)
1731							locationInput = parent.querySelector('input.bx-ui-sls-fake[type=text]');
1732
1733						if (locationInput)
1734							BX.fireEvent(locationInput, 'keyup');
1735					});
1736				}
1737
1738				if (!this.firstLoad && this.options.propertyValidation)
1739				{
1740					if (inputStep)
1741					{
1742						arProperty = this.validation.properties[i];
1743						data = this.getValidationData(arProperty, locationNode);
1744						section = BX.findParent(locationNode, {className: 'bx-soa-section'});
1745
1746						if (section && section.getAttribute('data-visited') == 'true')
1747							this.isValidProperty(data);
1748					}
1749
1750					if (inputSearch)
1751						BX.fireEvent(inputSearch, 'keyup');
1752				}
1753			}
1754
1755			if (this.firstLoad && this.result.IS_AUTHORIZED && typeof this.result.LAST_ORDER_DATA.FAIL === 'undefined')
1756			{
1757				this.showActualBlock();
1758			}
1759			else if (!this.result.SHOW_AUTH)
1760			{
1761				this.changeVisibleContent();
1762			}
1763
1764			this.checkNotifications();
1765
1766			/*if (this.activeSectionId !== this.regionBlockNode.id)
1767				this.editFadeRegionContent(this.regionBlockNode.querySelector('.bx-soa-section-content'));
1768
1769			if (this.activeSectionId != this.propsBlockNode.id)
1770				this.editFadePropsContent(this.propsBlockNode.querySelector('.bx-soa-section-content'));*/
1771		},
1772
1773		fixLocationsStyle: function(section, hiddenSection)
1774		{
1775			if (!section || !hiddenSection)
1776				return;
1777
1778			var regionActive = this.activeSectionId == section.id ? section : hiddenSection,
1779				locationSearchInputs, locationStepInputs, i;
1780
1781			locationSearchInputs = regionActive.querySelectorAll('div.bx-sls div.dropdown-block.bx-ui-sls-input-block');
1782			locationStepInputs = regionActive.querySelectorAll('div.bx-slst div.dropdown-block.bx-ui-slst-input-block');
1783
1784			if (locationSearchInputs.length)
1785				for (i = 0; i < locationSearchInputs.length; i++)
1786					BX.addClass(locationSearchInputs[i], 'bx-form-control');
1787
1788			if (locationStepInputs.length)
1789				for (i = 0; i < locationStepInputs.length; i++)
1790					BX.addClass(locationStepInputs[i], 'bx-form-control');
1791		},
1792
1793		/**
1794		 * Order saving action with validation. Doesn't send request while have errors
1795		 */
1796		clickOrderSaveAction: function(event)
1797		{
1798			
1799			
1800			if($(event.target).hasClass('first-click'))
1801			{
1802				$(event.target).removeClass('first-click');
1803				this.animateScrollTo(this.orderBlockNode, 800, 80);
1804			}
1805			else
1806			{
1807				if (this.isValidForm())
1808				{
1809					this.allowOrderSave();
1810
1811					if (this.params.USER_CONSENT === 'Y' && BX.UserConsent)
1812					{
1813						BX.onCustomEvent('bx-soa-order-save', []);
1814					}
1815					else
1816					{
1817						this.doSaveAction();
1818					}
1819				}
1820			}
1821			
1822
1823			return BX.PreventDefault(event);
1824		},
1825
1826		doSaveAction: function()
1827		{
1828			if (this.isOrderSaveAllowed())
1829			{
1830				this.reachGoal('order');
1831				this.sendRequest('saveOrderAjax');
1832			}
1833		},
1834
1835		/**
1836		 * Hiding current block node and showing next available block node
1837		 */
1838		clickNextAction: function(event)
1839		{
1840			var target = event.target || event.srcElement,
1841				actionSection = BX.findParent(target, {className : "bx-active"}),
1842				section = this.getNextSection(actionSection),
1843				allSections, titleNode, editStep;
1844
1845			this.reachGoal('next', actionSection);
1846
1847			if (
1848				(!this.result.IS_AUTHORIZED || typeof this.result.LAST_ORDER_DATA.FAIL !== 'undefined')
1849				&& section.next.getAttribute('data-visited') == 'false'
1850			)
1851			{
1852				titleNode = section.next.querySelector('.bx-soa-section-title-container');
1853				BX.bind(titleNode, 'click', BX.proxy(this.showByClick, this));
1854				editStep = section.next.querySelector('.bx-soa-editstep');
1855				if (editStep)
1856					editStep.style.display = '';
1857
1858				allSections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active');
1859				if (section.next.id == allSections[allSections.length - 1].id)
1860					this.switchOrderSaveButtons(true);
1861			}
1862
1863			this.fade(actionSection, section.next);
1864			/*this.show(section.next);*/
1865
1866			return BX.PreventDefault(event);
1867		},
1868
1869		/**
1870		 * Hiding current block node and showing previous available block node
1871		 */
1872		clickPrevAction: function(event)
1873		{
1874			var target = event.target || event.srcElement,
1875				actionSection = BX.findParent(target, {className: "bx-active"}),
1876				section = this.getPrevSection(actionSection);
1877
1878			this.fade(actionSection);
1879			/*this.show(section.next);*/
1880			this.animateScrollTo(section.next, 800);
1881			return BX.PreventDefault(event);
1882		},
1883
1884		/**
1885		 * Showing authentication block node
1886		 */
1887		showAuthBlock: function()
1888		{
1889			var showNode = this.authBlockNode,
1890				fadeNode = BX(this.activeSectionId);
1891
1892			if (!showNode || BX.hasClass(showNode, 'bx-selected'))
1893				return;
1894
1895			fadeNode && this.fade(fadeNode);
1896			/*this.show(showNode);*/
1897		},
1898
1899		/**
1900		 * Hiding authentication block node
1901		 */
1902		closeAuthBlock: function()
1903		{
1904			var actionSection = this.authBlockNode,
1905				nextSection = this.getNextSection(actionSection).next;
1906
1907			this.fade(actionSection);
1908			BX.cleanNode(BX(nextSection.id + '-hidden'));
1909			/*this.show(nextSection);*/
1910		},
1911
1912		/**
1913		 * Checks possibility to skip section
1914		 */
1915		shouldSkipSection: function(section)
1916		{
1917			var skip = false;
1918
1919			if (this.params.SKIP_USELESS_BLOCK === 'Y')
1920			{
1921				if (section.id === this.pickUpBlockNode.id)
1922				{
1923					var delivery = this.getSelectedDelivery();
1924					if (delivery)
1925					{
1926						skip = this.getPickUpInfoArray(delivery.STORE).length === 1;
1927					}
1928				}
1929
1930				if (section.id === this.deliveryBlockNode.id)
1931				{
1932					skip = this.result.DELIVERY && this.result.DELIVERY.length === 1
1933						&& this.result.DELIVERY[0].EXTRA_SERVICES.length === 0
1934						&& !this.result.DELIVERY[0].CALCULATE_ERRORS;
1935				}
1936
1937				if (section.id === this.paySystemBlockNode.id)
1938				{
1939					skip = this.result.PAY_SYSTEM && this.result.PAY_SYSTEM.length === 1 && this.result.PAY_FROM_ACCOUNT !== 'Y';
1940				}
1941			}
1942
1943			return skip;
1944		},
1945
1946		/**
1947		 * Returns next available block node (node skipped while have one pay system, delivery or pick up)
1948		 */
1949		getNextSection: function(actionSection, skippedSection)
1950		{
1951			if (!this.orderBlockNode || !actionSection)
1952				return {};
1953
1954			var allSections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'),
1955				nextSection, i;
1956
1957			for (i = 0; i < allSections.length; i++)
1958			{
1959				if (allSections[i].id === actionSection.id && allSections[i + 1])
1960				{
1961					nextSection = allSections[i + 1];
1962
1963					if (this.shouldSkipSection(nextSection))
1964					{
1965						this.markSectionAsCompleted(nextSection);
1966
1967						return this.getNextSection(nextSection, nextSection);
1968					}
1969
1970					return {
1971						prev: actionSection,
1972						next: nextSection,
1973						skip: skippedSection
1974					};
1975				}
1976			}
1977
1978			return {next: actionSection};
1979		},
1980
1981		markSectionAsCompleted: function(section)
1982		{
1983			var titleNode;
1984
1985			if (
1986				(!this.result.IS_AUTHORIZED || typeof this.result.LAST_ORDER_DATA.FAIL !== 'undefined')
1987				&& section.getAttribute('data-visited') === 'false'
1988			)
1989			{
1990				this.changeVisibleSection(section, true);
1991				titleNode = section.querySelector('.bx-soa-section-title-container');
1992				BX.bind(titleNode, 'click', BX.proxy(this.showByClick, this));
1993			}
1994
1995			section.setAttribute('data-visited', 'true');
1996			BX.addClass(section, 'bx-step-completed');
1997			BX.remove(section.querySelector('.alert.alert-warning.alert-hide'));
1998			this.checkBlockErrors(section);
1999		},
2000
2001		/**
2002		 * Returns previous available block node (node skipped while have one pay system, delivery or pick up)
2003		 */
2004		getPrevSection: function(actionSection)
2005		{
2006			if (!this.orderBlockNode || !actionSection)
2007				return {};
2008
2009			var allSections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'),
2010				prevSection, i;
2011
2012			for (i = 0; i < allSections.length; i++)
2013			{
2014				if (allSections[i].id === actionSection.id && allSections[i - 1])
2015				{
2016					prevSection = allSections[i - 1];
2017
2018					if (this.shouldSkipSection(prevSection))
2019					{
2020						this.markSectionAsCompleted(prevSection);
2021
2022						return this.getPrevSection(prevSection);
2023					}
2024
2025					return {
2026						prev: actionSection,
2027						next: prevSection
2028					};
2029				}
2030			}
2031
2032			return {next: actionSection};
2033		},
2034
2035		addAnimationEffect: function(node, className, timeout)
2036		{
2037			if (!node || !className)
2038				return;
2039
2040			if (this.timeOut[node.id])
2041			{
2042				clearTimeout(this.timeOut[node.id].timer);
2043				BX.removeClass(node, this.timeOut[node.id].className);
2044			}
2045
2046			setTimeout(function(){BX.addClass(node, className)}, 10);
2047			this.timeOut[node.id] = {
2048				className: className,
2049				timer: setTimeout(
2050					BX.delegate(function(){
2051						BX.removeClass(node, className);
2052						delete this.timeOut[node.id];
2053					}, this),
2054					timeout || 5000)
2055			};
2056		},
2057
2058		/**
2059		 * Replacing current active block node with generated fade block node
2060		 */
2061		fade: function(node, nextSection)
2062		{
2063			if (!node || !node.id || this.activeSectionId != node.id)
2064				return;
2065
2066			this.hasErrorSection[node.id] = false;
2067
2068			var objHeightOrig = node.offsetHeight,
2069				objHeight;
2070
2071			switch (node.id)
2072			{
2073				case this.authBlockNode.id:
2074					this.authBlockNode.style.display = 'none';
2075					BX.removeClass(this.authBlockNode, 'bx-active');
2076					break;
2077				case this.basketBlockNode.id:
2078					this.editFadeBasketBlock();
2079					break;
2080				case this.regionBlockNode.id:
2081					this.editFadeRegionBlock();
2082					break;
2083				case this.paySystemBlockNode.id:
2084					BX.remove(this.paySystemBlockNode.querySelector('.alert.alert-warning.alert-hide'));
2085					this.editFadePaySystemBlock();
2086					break;
2087				case this.deliveryBlockNode.id:
2088					BX.remove(this.deliveryBlockNode.querySelector('.alert.alert-warning.alert-hide'));
2089					this.editFadeDeliveryBlock();
2090					break;
2091				case this.pickUpBlockNode.id:
2092					/*this.editFadePickUpBlock();*/
2093					break;
2094				case this.propsBlockNode.id:
2095					this.editFadePropsBlock();
2096					break;
2097			}
2098
2099			BX.addClass(node, 'bx-step-completed');
2100			BX.removeClass(node, 'bx-selected');
2101
2102			objHeight = node.offsetHeight;
2103			node.style.height = objHeightOrig + 'px';
2104
2105			// calculations of scrolling animation
2106			if (nextSection)
2107			{
2108				var windowScrollTop = BX.GetWindowScrollPos().scrollTop,
2109					orderPos = BX.pos(this.orderBlockNode),
2110					nodePos = BX.pos(node),
2111					diff, scrollTo, nextSectionHeightBefore, nextSectionHeightAfter, nextSectionHidden, offset;
2112
2113				nextSectionHidden = BX(nextSection.id + '-hidden');
2114				nextSectionHidden.style.left = '-10000';
2115				nextSectionHidden.style.position = 'absolute';
2116				this.orderBlockNode.appendChild(nextSectionHidden);
2117				nextSectionHeightBefore = nextSection.offsetHeight;
2118				nextSectionHeightAfter = nextSectionHidden.offsetHeight + 57;
2119				BX(node.id + '-hidden').parentNode.appendChild(nextSectionHidden);
2120				nextSectionHidden.removeAttribute('style');
2121
2122				diff = objHeight + nextSectionHeightAfter - objHeightOrig - nextSectionHeightBefore;
2123
2124				offset = window.innerHeight - orderPos.height - diff;
2125				if (offset > 0)
2126					scrollTo = orderPos.top - offset/2;
2127				else
2128				{
2129					if (nodePos.top > windowScrollTop)
2130						scrollTo = nodePos.top;
2131					else
2132						scrollTo = nodePos.bottom + 6 - objHeightOrig + objHeight;
2133
2134					if (scrollTo + window.innerHeight > orderPos.bottom + 25 + diff)
2135						scrollTo = orderPos.bottom + 25 + diff - window.innerHeight;
2136				}
2137
2138				scrollTo -= this.isMobile ? 50 : 0;
2139			}
2140
2141			new BX.easing({
2142				duration: nextSection ? 800 : 600,
2143				start: {height: objHeightOrig, scrollTop: windowScrollTop},
2144				finish: {height: objHeight, scrollTop: scrollTo},
2145				transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
2146				step: function(state){
2147					node.style.height = state.height + "px";
2148					if (nextSection)
2149						window.scrollTo(0, state.scrollTop);
2150				},
2151				complete: function(){
2152					node.style.height = '';
2153				}
2154			}).animate();
2155
2156			this.checkBlockErrors(node);
2157		},
2158
2159		/**
2160		 * Showing active data in certain block node
2161		 */
2162		show: function(node)
2163		{
2164			if (!node || !node.id || this.activeSectionId == node.id)
2165				return;
2166
2167			this.activeSectionId = node.id;
2168			BX.removeClass(node, 'bx-step-error bx-step-warning');
2169
2170			switch (node.id)
2171			{
2172				case this.authBlockNode.id:
2173					this.authBlockNode.style.display = '';
2174					BX.addClass(this.authBlockNode, 'bx-active');
2175					break;
2176				case this.basketBlockNode.id:
2177					this.editActiveBasketBlock(true);
2178					this.alignBasketColumns();
2179					break;
2180				case this.regionBlockNode.id:
2181					this.editActiveRegionBlock(true);
2182					break;
2183				case this.deliveryBlockNode.id:
2184					this.editActiveDeliveryBlock(true);
2185					break;
2186				case this.paySystemBlockNode.id:
2187					this.editActivePaySystemBlock(true);
2188					break;
2189				case this.pickUpBlockNode.id:
2190					this.editActivePickUpBlock(true);
2191					break;
2192				case this.propsBlockNode.id:
2193					this.editActivePropsBlock(true);
2194					break;
2195			}
2196
2197			if (node.getAttribute('data-visited') === 'false')
2198			{
2199				this.showBlockErrors(node);
2200				this.notifyAboutWarnings(node);
2201			}
2202
2203			node.setAttribute('data-visited', 'true');
2204			BX.addClass(node, 'bx-selected');
2205			BX.removeClass(node, 'bx-step-completed');
2206		},
2207
2208		showByClick: function(event)
2209		{
2210			var target = event.target || event.srcElement,
2211				showNode = BX.findParent(target, {className: "bx-active"}),
2212				fadeNode = BX(this.activeSectionId),
2213				scrollTop = BX.GetWindowScrollPos().scrollTop;
2214
2215			if (!showNode || BX.hasClass(showNode, 'bx-selected'))
2216				return BX.PreventDefault(event);
2217
2218			this.reachGoal('edit', showNode);
2219
2220			fadeNode && this.fade(fadeNode);
2221			/*this.show(showNode);*/
2222
2223			setTimeout(BX.delegate(function(){
2224				if (BX.pos(showNode).top < scrollTop)
2225					this.animateScrollTo(showNode, 300);
2226			}, this), 320);
2227
2228			return BX.PreventDefault(event);
2229		},
2230
2231		/**
2232		 * Checks each active block from top to bottom for errors (showing first block with errors or last block)
2233		 */
2234		showActualBlock: function()
2235		{
2236			var allSections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'),
2237				i = 0;
2238
2239
2240
2241			while (allSections[i])
2242			{
2243				if (allSections[i].id === this.regionBlockNode.id)
2244					this.isValidRegionBlock();
2245
2246				if (allSections[i].id === this.propsBlockNode.id)
2247					this.isValidPropertiesBlock();
2248
2249				if (!this.checkBlockErrors(allSections[i]) || !this.checkPreload(allSections[i]))
2250				{
2251					if (this.activeSectionId !== allSections[i].id)
2252					{
2253						BX(this.activeSectionId) && this.fade(BX(this.activeSectionId));
2254						/*this.show(allSections[i]);*/
2255					}
2256
2257					break;
2258				}
2259
2260				BX.addClass(allSections[i], 'bx-step-completed');
2261				allSections[i].setAttribute('data-visited', 'true');
2262				i++;
2263			}
2264
2265
2266		},
2267
2268		/**
2269		 * Returns footer node with navigation buttons
2270		 */
2271		getBlockFooter: function(node)
2272		{
2273			var sections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'),
2274				firstSection = sections[0],
2275				lastSection = sections[sections.length - 1],
2276				currentSection = BX.findParent(node, {className: "bx-soa-section"}),
2277				isLastNode = false,
2278				buttons = [];
2279
2280			if (currentSection && currentSection.id.indexOf(firstSection.id) == '-1')
2281			{
2282				buttons.push(
2283					BX.create('A', {
2284						props: {
2285							href: 'javascript:void(0)',
2286							className: 'pull-left btn btn-default btn-md'
2287						},
2288						html: this.params.MESS_BACK,
2289						events: {
2290							click: BX.proxy(this.clickPrevAction, this)
2291						}
2292					})
2293				);
2294			}
2295
2296			if (currentSection && currentSection.id.indexOf(lastSection.id) != '-1')
2297				isLastNode = true;
2298
2299			if (!isLastNode)
2300			{
2301				buttons.push(
2302					BX.create('A', {
2303						props: {href: 'javascript:void(0)', className: 'pull-right btn btn-default btn-md'},
2304						html: this.params.MESS_FURTHER,
2305						events: {click: BX.proxy(this.clickNextAction, this)}
2306					})
2307				);
2308			}
2309
2310			/*node.appendChild(
2311				BX.create('DIV', {
2312					props: {className: 'row bx-soa-more'},
2313					children: [
2314						BX.create('DIV', {
2315							props: {className: 'bx-soa-more-btn col-xs-12'},
2316							children: buttons
2317						})
2318					]
2319				})
2320			);*/
2321		},
2322
2323		getNewContainer: function(notFluid)
2324		{
2325			/*return BX.create('DIV', {props: {className: 'bx-soa-section-content' + (!!notFluid ? '' : ' container-fluid')}});*/
2326			return BX.create('DIV', {props: {className: 'bx-soa-section-content'}});
2327		},
2328
2329		/**
2330		 * Showing/hiding order save buttons
2331		 */
2332		switchOrderSaveButtons: function(state)
2333		{
2334			var orderSaveNode = this.orderSaveBlockNode,
2335				totalButton = this.totalBlockNode.querySelector('.bx-soa-cart-total-button-container'),
2336				mobileButton = this.mobileTotalBlockNode.querySelector('.bx-soa-cart-total-button-container'),
2337				lastState = this.orderSaveBlockNode.style.display == '';
2338
2339			if (lastState != state)
2340			{
2341				if (state)
2342				{
2343					orderSaveNode.style.opacity = 0;
2344					orderSaveNode.style.display = '';
2345					if (totalButton)
2346					{
2347						totalButton.style.opacity = 0;
2348						totalButton.style.display = '';
2349					}
2350					if (mobileButton)
2351					{
2352						mobileButton.style.opacity = 0;
2353						mobileButton.style.display = '';
2354					}
2355
2356					new BX.easing({
2357						duration: 500,
2358						start: {opacity: 0},
2359						finish: {opacity: 100},
2360						transition: BX.easing.transitions.linear,
2361						step: function(state){
2362							orderSaveNode.style.opacity = state.opacity / 100;
2363							if (totalButton)
2364								totalButton.style.opacity = state.opacity / 100;
2365							if (mobileButton)
2366								mobileButton.style.opacity = state.opacity / 100;
2367						},
2368						complete: function(){
2369							orderSaveNode.removeAttribute('style');
2370							totalButton && totalButton.removeAttribute('style');
2371							mobileButton && mobileButton.removeAttribute('style');
2372						}
2373					}).animate();
2374				}
2375				else
2376				{
2377					orderSaveNode.style.display = 'none';
2378					if (totalButton)
2379						totalButton.setAttribute('style', 'display: none !important');
2380					if (mobileButton)
2381						mobileButton.setAttribute('style', 'display: none !important');
2382				}
2383			}
2384		},
2385
2386		/**
2387		 * Returns true if current section or next sections had already visited
2388		 */
2389		shouldBeSectionVisible: function(sections, currentPosition)
2390		{
2391			var state = false, editStepNode;
2392
2393			if (!sections || !sections.length)
2394				return state;
2395
2396			for (; currentPosition < sections.length; currentPosition++)
2397			{
2398				if (sections[currentPosition].getAttribute('data-visited') == 'true')
2399				{
2400					state = true;
2401					break;
2402				}
2403
2404				if (!this.firstLoad)
2405				{
2406					editStepNode = sections[currentPosition].querySelector('.bx-soa-editstep');
2407					if (editStepNode && editStepNode.style.display !== 'none')
2408					{
2409						state = true;
2410						break;
2411					}
2412				}
2413			}
2414
2415			return state;
2416		},
2417
2418		/**
2419		 * Showing/hiding blocks content if user authorized/unauthorized
2420		 */
2421		changeVisibleContent: function()
2422		{
2423			var sections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'),
2424				i, state;
2425
2426			var orderDataLoaded = !!this.result.IS_AUTHORIZED && this.params.USE_PRELOAD === 'Y' && this.result.LAST_ORDER_DATA.FAIL !== true,
2427				skipFlag = true;
2428
2429			for (i = 0; i < sections.length; i++)
2430			{
2431				/*state = this.firstLoad && orderDataLoaded;
2432
2433				state = state || this.shouldBeSectionVisible(sections, i);*/
2434
2435				state = true;
2436
2437				this.changeVisibleSection(sections[i], state);
2438
2439				if (this.firstLoad && skipFlag)
2440				{
2441					if (
2442						state
2443						&& sections[i + 1]
2444						&& this.checkBlockErrors(sections[i])
2445						&& (
2446							(orderDataLoaded && this.checkPreload(sections[i]))
2447							|| (!orderDataLoaded && this.shouldSkipSection(sections[i]))
2448						)
2449					)
2450					{
2451						this.fade(sections[i]);
2452						this.markSectionAsCompleted(sections[i]);
2453						/*this.show(sections[i + 1]);*/
2454					}
2455					else
2456					{
2457						skipFlag = false;
2458					}
2459				}
2460			}
2461
2462			if (
2463				(!this.result.IS_AUTHORIZED || typeof this.result.LAST_ORDER_DATA.FAIL !== 'undefined')
2464				&& this.params.SHOW_ORDER_BUTTON === 'final_step'
2465			)
2466			{
2467				this.switchOrderSaveButtons(this.shouldBeSectionVisible(sections, sections.length - 1));
2468			}
2469		},
2470
2471		changeVisibleSection: function(section, state)
2472		{
2473			var titleNode, content, editStep;
2474
2475			if (section.id !== this.basketBlockNode.id)
2476			{
2477				content = section.querySelector('.bx-soa-section-content');
2478				if (content)
2479					content.style.display = state ? '' : 'none';
2480			}
2481
2482			editStep = section.querySelector('.bx-soa-editstep');
2483			if (editStep)
2484				editStep.style.display = state ? '' : 'none';
2485
2486			titleNode = section.querySelector('.bx-soa-section-title-container');
2487			if (titleNode && !state)
2488				BX.unbindAll(titleNode);
2489		},
2490
2491		clearHiddenBlocks: function()
2492		{
2493			BX.remove(BX.lastChild(this.authHiddenBlockNode));
2494			BX.remove(BX.lastChild(this.basketHiddenBlockNode));
2495			BX.remove(BX.lastChild(this.regionHiddenBlockNode));
2496			BX.remove(BX.lastChild(this.paySystemHiddenBlockNode));
2497			BX.remove(BX.lastChild(this.deliveryHiddenBlockNode));
2498			BX.remove(BX.lastChild(this.pickUpHiddenBlockNode));
2499			BX.remove(BX.lastChild(this.propsHiddenBlockNode));
2500		},
2501
2502		/**
2503		 * Edit order block nodes with this.result/this.params data
2504		 */
2505		editOrder: function()
2506		{
2507			if (!this.orderBlockNode || !this.result)
2508				return;
2509
2510			if (this.result.DELIVERY.length > 0)
2511			{
2512				BX.addClass(this.deliveryBlockNode, 'bx-active');
2513				this.deliveryBlockNode.removeAttribute('style');
2514			}
2515			else
2516			{
2517				BX.removeClass(this.deliveryBlockNode, 'bx-active');
2518				this.deliveryBlockNode.style.display = 'none';
2519			}
2520
2521			this.orderSaveBlockNode.style.display = this.result.SHOW_AUTH ? 'none' : '';
2522			this.mobileTotalBlockNode.style.display = this.result.SHOW_AUTH ? 'none' : '';
2523
2524			this.checkPickUpShow();
2525
2526			var sections = this.orderBlockNode.querySelectorAll('.bx-soa-section.bx-active'), i;
2527			for (i in sections)
2528			{
2529				if (sections.hasOwnProperty(i))
2530				{
2531					this.editSection(sections[i]);
2532				}
2533			}
2534
2535
2536						
2537
2538			this.editTotalBlock();
2539			/*this.totalBlockFixFont();*/
2540
2541			this.showErrors(this.result.ERROR, false);
2542			this.showWarnings();
2543
2544			var editSteps = this.orderBlockNode.querySelectorAll('.bx-soa-editstep'), i;
2545				for (i in editSteps) {
2546 			 		if (editSteps.hasOwnProperty(i)) {
2547    					BX.remove(editSteps[i]);
2548  					  }
2549				  }
2550
2551			if($("#btnOrderSaveFly").length>0)
2552			{
2553				if($("#btnOrderSaveFly").hasClass('first-click'))
2554				{
2555				    $(window).scroll(function() {
2556				        if($(document).scrollTop() > $("#bx-soa-order").offset().top && $("#btnOrderSaveFly").hasClass('first-click'))
2557				            $("#btnOrderSaveFly").removeClass('first-click');
2558				    });
2559				}
2560			}
2561
2562			
2563		},
2564
2565		/**
2566		 * Edit certain block node
2567		 */
2568		editSection: function(section)
2569		{
2570			if (!section || !section.id)
2571				return;
2572
2573			if (this.result.SHOW_AUTH && section.id != this.authBlockNode.id && section.id != this.basketBlockNode.id)
2574				section.style.display = 'none';
2575			else if (section.id != this.pickUpBlockNode.id)
2576				section.style.display = '';
2577
2578			//var active = section.id == this.activeSectionId,
2579				var active = true,
2580				titleNode = section.querySelector('.bx-soa-section-title-container'),
2581				editButton, errorContainer;
2582
2583			/*BX.unbindAll(titleNode);
2584			if (this.result.SHOW_AUTH)
2585			{
2586				BX.bind(titleNode, 'click', BX.delegate(function(){
2587					this.animateScrollTo(this.authBlockNode);
2588					this.addAnimationEffect(this.authBlockNode, 'bx-step-good');
2589				}, this));
2590			}
2591			else
2592			{
2593				BX.bind(titleNode, 'click', BX.proxy(this.showByClick, this));
2594				editButton = titleNode.querySelector('.bx-soa-editstep');
2595				editButton && BX.bind(editButton, 'click', BX.proxy(this.showByClick, this));
2596			}*/
2597
2598			errorContainer = section.querySelector('.alert.alert-danger');
2599			this.hasErrorSection[section.id] = errorContainer && errorContainer.style.display != 'none';
2600
2601			switch (section.id)
2602			{
2603				case this.authBlockNode.id:
2604					this.editAuthBlock();
2605					break;
2606				case this.basketBlockNode.id:
2607					this.editBasketBlock(active);
2608					break;
2609				case this.regionBlockNode.id:
2610					this.editRegionBlock(active);
2611					break;
2612				case this.paySystemBlockNode.id:
2613					this.editPaySystemBlock(active);
2614					break;
2615				case this.deliveryBlockNode.id:
2616					this.editDeliveryBlock(active);
2617					break;
2618				case this.pickUpBlockNode.id:
2619					this.editPickUpBlock(active);
2620					break;
2621				case this.propsBlockNode.id:
2622					this.editPropsBlock(active);
2623					break;
2624			}
2625
2626			if (active)
2627				section.setAttribute('data-visited', 'true');
2628		},
2629
2630		editAuthBlock: function()
2631		{
2632			if (!this.authBlockNode)
2633				return;
2634
2635			var authContent = this.authBlockNode.querySelector('.bx-soa-section-content'),
2636				regContent, okMessageNode;
2637
2638			if (BX.hasClass(authContent, 'reg'))
2639			{
2640				regContent = authContent;
2641				authContent = BX.firstChild(this.authHiddenBlockNode);
2642			}
2643			else
2644				regContent = BX.firstChild(this.authHiddenBlockNode);
2645
2646			BX.cleanNode(authContent);
2647			BX.cleanNode(regContent);
2648
2649			if (this.result.SHOW_AUTH)
2650			{
2651				this.getErrorContainer(authContent);
2652				this.editAuthorizeForm(authContent);
2653				this.editSocialContent(authContent);
2654				this.getAuthReference(authContent);
2655
2656				this.getErrorContainer(regContent);
2657				this.editRegistrationForm(regContent);
2658				this.getAuthReference(regContent);
2659			}
2660			else
2661			{
2662				BX.onCustomEvent('OnBasketChange');
2663				this.closeAuthBlock();
2664			}
2665
2666			if (this.result.OK_MESSAGE && this.result.OK_MESSAGE.length)
2667			{
2668				this.toggleAuthForm({target: this.authBlockNode.querySelector('input[type=submit]')});
2669				okMessageNode = BX.create('DIV', {
2670					props: {className: 'alert alert-success'},
2671					text: this.result.OK_MESSAGE.join()
2672				});
2673				this.result.OK_MESSAGE = '';
2674				BX.prepend(okMessageNode, this.authBlockNode.querySelector('.bx-soa-section-content'));
2675			}
2676		},
2677
2678		editAuthorizeForm: function(authContent)
2679		{
2680			var login, password, remember, button, authFormNode;
2681
2682			login = this.createAuthFormInputContainer(
2683				BX.message('STOF_LOGIN'),
2684				BX.create('INPUT', {
2685					attrs: {'data-next': 'USER_PASSWORD'},
2686					props: {
2687						name: 'USER_LOGIN',
2688						type: 'text',
2689						value: this.result.AUTH.USER_LOGIN,
2690						maxlength: "30"
2691					},
2692					events: {keypress: BX.proxy(this.checkKeyPress, this)}
2693				})
2694			);
2695			password = this.createAuthFormInputContainer(
2696				BX.message('STOF_PASSWORD'),
2697				BX.create('INPUT', {
2698					attrs: {'data-send': true},
2699					props: {
2700						name: 'USER_PASSWORD',
2701						type: 'password',
2702						value: '',
2703						maxlength: "30"
2704					},
2705					events: {keypress: BX.proxy(this.checkKeyPress, this)}
2706				})
2707			);
2708			remember = BX.create('DIV', {
2709				props: {className: 'bx-authform-formgroup-container'},
2710				children: [
2711					BX.create('DIV', {
2712						props: {className: 'checkbox'},
2713						children: [
2714							BX.create('LABEL', {
2715								props: {className: 'bx-filter-param-label'},
2716								children: [
2717									BX.create('INPUT', {
2718										props: {
2719											type: 'checkbox',
2720											name: 'USER_REMEMBER',
2721											value: 'Y'
2722										}
2723									}),
2724									BX.create('SPAN', {props: {className: 'bx-filter-param-text'}, text: BX.message('STOF_REMEMBER')})
2725								]
2726							})
2727						]
2728					})
2729				]
2730			});
2731			button = BX.create('DIV', {
2732				props: {className: 'bx-authform-formgroup-container'},
2733				children: [
2734					BX.create('INPUT', {
2735						props: {
2736							id: 'do_authorize',
2737							type: 'hidden',
2738							name: 'do_authorize',
2739							value: 'N'
2740						}
2741					}),
2742					BX.create('INPUT', {
2743						props: {
2744							type: 'submit',
2745							className: 'btn btn-lg btn-default',
2746							value: BX.message('STOF_ENTER')
2747						},
2748						events: {
2749							click: BX.delegate(function(e){
2750								BX('do_authorize').value = 'Y';
2751								this.sendRequest('showAuthForm');
2752								return BX.PreventDefault(e);
2753							}, this)
2754						}
2755					})
2756				]
2757			});
2758			authFormNode = BX.create('DIV', {
2759				props: {className: 'bx-authform'},
2760				children: [
2761					BX.create('H3', {props: {className: 'bx-title'}, text: BX.message('STOF_AUTH_REQUEST')}),
2762					login,
2763					password,
2764					remember,
2765					button,
2766					BX.create('A', {
2767						props: {
2768							href: this.params.PATH_TO_AUTH + '?forgot_password=yes&back_url=' + encodeURIComponent(document.location.href)
2769						},
2770						text: BX.message('STOF_FORGET_PASSWORD')
2771					})
2772				]
2773			});
2774
2775			authContent.appendChild(BX.create('DIV', {props: {className: 'col-md-6'}, children: [authFormNode]}));
2776		},
2777
2778		createAuthFormInputContainer: function(labelText, inputNode, required)
2779		{
2780			var labelHtml = '';
2781
2782			if (required)
2783				labelHtml += '<span class="bx-authform-starrequired">*</span>';
2784
2785			labelHtml += labelText;
2786
2787			return BX.create('DIV', {
2788				props: {className: 'bx-authform-formgroup-container'},
2789				children: [
2790					BX.create('DIV', {props: {className: 'bx-authform-label-container'}, html: labelHtml}),
2791					BX.create('DIV', {props: {className: 'bx-authform-input-container'},  children: [inputNode]})
2792				]
2793			});
2794		},
2795
2796		activatePhoneAuth: function()
2797		{
2798			if (!this.result.SMS_AUTH)
2799				return;
2800
2801			new BX.PhoneAuth({
2802				containerId: 'bx_register_resend',
2803				errorContainerId: 'bx_register_error',
2804				interval: 60,
2805				data: {
2806					signedData: this.result.SMS_AUTH.SIGNED_DATA
2807				},
2808				onError: function(response)
2809				{
2810					var errorDiv = BX('bx_register_error');
2811					var errorNode = BX.findChildByClassName(errorDiv, 'errortext');
2812					errorNode.innerHTML = '';
2813
2814					for (var i = 0; i < response.errors.length; i++)
2815					{
2816						errorNode.innerHTML = errorNode.innerHTML + BX.util.htmlspecialchars(response.errors[i].message) + '<br>';
2817					}
2818
2819					errorDiv.style.display = '';
2820				}
2821			});
2822		},
2823
2824		editRegistrationForm: function(authContent)
2825		{
2826			if (!this.result.AUTH)
2827				return;
2828
2829			var authFormNodes = [];
2830			var showSmsConfirm = this.result.SMS_AUTH && this.result.SMS_AUTH.TYPE === 'OK';
2831
2832			if (showSmsConfirm)
2833			{
2834				authFormNodes.push(BX.create('DIV', {
2835					props: {className: 'alert alert-success'},
2836					text: BX.message('STOF_REG_SMS_REQUEST')
2837				}));
2838				authFormNodes.push(BX.create('INPUT', {
2839					props: {
2840						type: 'hidden',
2841						name: 'SIGNED_DATA',
2842						value: this.result.SMS_AUTH.SIGNED_DATA || ''
2843					}
2844				}));
2845				authFormNodes.push(this.createAuthFormInputContainer(
2846					BX.message('STOF_SMS_CODE'),
2847					BX.create('INPUT', {
2848						attrs: {'data-send': true},
2849						props: {
2850							name: 'SMS_CODE',
2851							type: 'text',
2852							size: 40,
2853							value: ''
2854						},
2855						events: {keypress: BX.proxy(this.checkKeyPress, this)}
2856					}),
2857					true
2858				));
2859				authFormNodes.push(BX.create('DIV', {
2860					props: {className: 'bx-authform-formgroup-container'},
2861					children: [
2862						BX.create('INPUT', {
2863							props: {
2864								name: 'code_submit_button',
2865								type: 'submit',
2866								className: 'btn btn-lg btn-default',
2867								value: BX.message('STOF_SEND')
2868							},
2869							events: {
2870								click: BX.delegate(function(e)
2871								{
2872									this.sendRequest('confirmSmsCode');
2873									return BX.PreventDefault(e);
2874								}, this)
2875							}
2876						})
2877					]
2878				}));
2879				authFormNodes.push(BX.create('DIV', {
2880					props: {className: 'bx-authform-formgroup-container'},
2881					children: [
2882						BX.create('DIV', {
2883							props: {id: 'bx_register_error'},
2884							style: {display: 'none'}
2885						}),
2886						BX.create('DIV', {
2887							props: {id: 'bx_register_resend'}
2888						})
2889					]
2890				}));
2891			}
2892			else
2893			{
2894				authFormNodes.push(BX.create('H3', {
2895					props: {className: 'bx-title'},
2896					text: BX.message('STOF_REG_REQUEST')
2897				}));
2898				authFormNodes.push(this.createAuthFormInputContainer(
2899					BX.message('STOF_NAME'),
2900					BX.create('INPUT', {
2901						attrs: {'data-next': 'NEW_LAST_NAME'},
2902						props: {
2903							name: 'NEW_NAME',
2904							type: 'text',
2905							size: 40,
2906							value: this.result.AUTH.NEW_NAME || ''
2907						},
2908						events: {keypress: BX.proxy(this.checkKeyPress, this)}
2909					}),
2910					true
2911				));
2912				authFormNodes.push(this.createAuthFormInputContainer(
2913					BX.message('STOF_LASTNAME'),
2914					BX.create('INPUT', {
2915						attrs: {'data-next': 'NEW_EMAIL'},
2916						props: {
2917							name: 'NEW_LAST_NAME',
2918							type: 'text',
2919							size: 40,
2920							value: this.result.AUTH.NEW_LAST_NAME || ''
2921						},
2922						events: {keypress: BX.proxy(this.checkKeyPress, this)}
2923					}),
2924					true
2925				));
2926				authFormNodes.push(this.createAuthFormInputContainer(
2927					BX.message('STOF_EMAIL'),
2928					BX.create('INPUT', {
2929						attrs: {'data-next': 'PHONE_NUMBER'},
2930						props: {
2931							name: 'NEW_EMAIL',
2932							type: 'text',
2933							size: 40,
2934							value: this.result.AUTH.NEW_EMAIL || ''
2935						},
2936						events: {keypress: BX.proxy(this.checkKeyPress, this)}
2937					}),
2938					this.result.AUTH.new_user_email_required == 'Y'
2939				));
2940
2941				if (this.result.AUTH.new_user_phone_auth === 'Y')
2942				{
2943					authFormNodes.push(this.createAuthFormInputContainer(
2944						BX.message('STOF_PHONE'),
2945						BX.create('INPUT', {
2946							attrs: {'data-next': 'captcha_word'},
2947							props: {
2948								name: 'PHONE_NUMBER',
2949								type: 'text',
2950								size: 40,
2951								value: this.result.AUTH.PHONE_NUMBER || ''
2952							},
2953							events: {keypress: BX.proxy(this.checkKeyPress, this)}
2954						}),
2955						this.result.AUTH.new_user_phone_required === 'Y'
2956					));
2957				}
2958
2959				if (this.authGenerateUser)
2960				{
2961					authFormNodes.push(
2962						BX.create('LABEL', {
2963							props: {for: 'NEW_GENERATE_N'},
2964							children: [
2965								BX.create('INPUT', {
2966									attrs: {checked: !this.authGenerateUser},
2967									props: {
2968										id: 'NEW_GENERATE_N',
2969										type: 'radio',
2970										name: 'NEW_GENERATE',
2971										value: 'N'
2972									}
2973								}),
2974								BX.message('STOF_MY_PASSWORD')
2975							],
2976							events: {
2977								change: BX.delegate(function(){
2978									var generated = this.authBlockNode.querySelector('.generated');
2979									generated.style.display = '';
2980									this.authGenerateUser = false;
2981								}, this)
2982							}
2983						})
2984					);
2985					authFormNodes.push(BX.create('BR'));
2986					authFormNodes.push(
2987						BX.create('LABEL', {
2988							props: {for: 'NEW_GENERATE_Y'},
2989							children: [
2990								BX.create('INPUT', {
2991									attrs: {checked: this.authGenerateUser},
2992									props: {
2993										id: 'NEW_GENERATE_Y',
2994										type: 'radio',
2995										name: 'NEW_GENERATE',
2996										value: 'Y'
2997									}
2998								}),
2999								BX.message('STOF_SYS_PASSWORD')
3000							],
3001							events: {
3002								change: BX.delegate(function(){
3003									var generated = this.authBlockNode.querySelector('.generated');
3004									generated.style.display = 'none';
3005									this.authGenerateUser = true;
3006								}, this)
3007							}
3008						})
3009					);
3010				}
3011
3012				authFormNodes.push(
3013					BX.create('DIV', {
3014						props: {className: 'generated'},
3015						style: {display: this.authGenerateUser ? 'none' : ''},
3016						children: [
3017							this.createAuthFormInputContainer(
3018								BX.message('STOF_LOGIN'),
3019								BX.create('INPUT', {
3020									props: {
3021										name: 'NEW_LOGIN',
3022										type: 'text',
3023										size: 30,
3024										value: this.result.AUTH.NEW_LOGIN || ''
3025									},
3026									events: {
3027										keypress: BX.proxy(this.checkKeyPress, this)
3028									}
3029								}),
3030								true
3031							),
3032							this.createAuthFormInputContainer(
3033								BX.message('STOF_PASSWORD'),
3034								BX.create('INPUT', {
3035									props: {
3036										name: 'NEW_PASSWORD',
3037										type: 'password',
3038										size: 30
3039									},
3040									events: {
3041										keypress: BX.proxy(this.checkKeyPress, this)
3042									}
3043								}),
3044								true
3045							),
3046							this.createAuthFormInputContainer(
3047								BX.message('STOF_RE_PASSWORD'),
3048								BX.create('INPUT', {
3049									props: {
3050										name: 'NEW_PASSWORD_CONFIRM',
3051										type: 'password',
3052										size: 30
3053									},
3054									events: {
3055										keypress: BX.proxy(this.checkKeyPress, this)
3056									}
3057								}),
3058								true
3059							)
3060						]
3061					})
3062				);
3063
3064				if (this.result.AUTH.captcha_registration == 'Y')
3065				{
3066					authFormNodes.push(BX.create('DIV', {
3067						props: {className: 'bx-authform-formgroup-container'},
3068						children: [
3069							BX.create('DIV', {
3070								props: {className: 'bx-authform-label-container'},
3071								children: [
3072									BX.create('SPAN', {props: {className: 'bx-authform-starrequired'}, text: '*'}),
3073									BX.message('CAPTCHA_REGF_PROMT'),
3074									BX.create('DIV', {
3075										props: {className: 'bx-captcha'},
3076										children: [
3077											BX.create('INPUT', {
3078												props: {
3079													name: 'captcha_sid',
3080													type: 'hidden',
3081													value: this.result.AUTH.capCode || ''
3082												}
3083											}),
3084											BX.create('IMG', {
3085												props: {
3086													src: '/bitrix/tools/captcha.php?captcha_sid=' + this.result.AUTH.capCode,
3087													alt: ''
3088												}
3089											})
3090										]
3091									})
3092								]
3093							}),
3094							BX.create('DIV', {
3095								props: {className: 'bx-authform-input-container'},
3096								children: [
3097									BX.create('INPUT', {
3098										attrs: {'data-send': true},
3099										props: {
3100											name: 'captcha_word',
3101											type: 'text',
3102											size: '30',
3103											maxlength: '50',
3104											value: ''
3105										},
3106										events: {keypress: BX.proxy(this.checkKeyPress, this)}
3107									})
3108								]
3109							})
3110						]
3111					}));
3112				}
3113				authFormNodes.push(
3114					BX.create('DIV', {
3115						props: {className: 'bx-authform-formgroup-container'},
3116						children: [
3117							BX.create('INPUT', {
3118								props: {
3119									id: 'do_register',
3120									name: 'do_register',
3121									type: 'hidden',
3122									value: 'N'
3123								}
3124							}),
3125							BX.create('INPUT', {
3126								props: {
3127									type: 'submit',
3128									className: 'btn btn-lg btn-default',
3129									value: BX.message('STOF_REGISTER')
3130								},
3131								events: {
3132									click: BX.delegate(function(e){
3133										BX('do_register').value = 'Y';
3134										this.sendRequest('showAuthForm');
3135										return BX.PreventDefault(e);
3136									}, this)
3137								}
3138							}),
3139							BX.create('A', {
3140								props: {className: 'btn btn-link', href: ''},
3141								text: BX.message('STOF_DO_AUTHORIZE'),
3142								events: {
3143									click: BX.delegate(function(e){
3144										this.toggleAuthForm(e);
3145										return BX.PreventDefault(e);
3146									}, this)
3147								}
3148							})
3149						]
3150					})
3151				);
3152			}
3153
3154			authContent.appendChild(
3155				BX.create('DIV', {
3156					props: {className: 'col-md-12'},
3157					children: [BX.create('DIV', {props: {className: 'bx-authform'}, children: authFormNodes})]
3158				})
3159			);
3160
3161			if (showSmsConfirm)
3162			{
3163				this.activatePhoneAuth();
3164			}
3165		},
3166
3167		editSocialContent: function(authContent)
3168		{
3169			if (!BX('bx-soa-soc-auth-services'))
3170				return;
3171
3172			var nodes = [];
3173
3174			if (this.socServiceHiddenNode === false)
3175			{
3176				var socServiceHiddenNode = BX('bx-soa-soc-auth-services').querySelector('.bx-authform-social');
3177
3178				if (BX.type.isDomNode(socServiceHiddenNode))
3179				{
3180					this.socServiceHiddenNode = socServiceHiddenNode.innerHTML;
3181					BX.remove(socServiceHiddenNode);
3182				}
3183			}
3184
3185			if (this.socServiceHiddenNode)
3186			{
3187				nodes.push(BX.create('DIV', {
3188					props: {className: 'bx-authform-social'},
3189					html: '<h3 class="bx-title">' + BX.message('SOA_DO_SOC_SERV') + '</h3>' + this.socServiceHiddenNode
3190				}));
3191				nodes.push(BX.create('hr', {props: {className: 'bxe-light'}}));
3192			}
3193
3194			if (this.result.AUTH.new_user_registration === 'Y')
3195			{
3196				nodes.push(BX.create('DIV', {
3197					props: {className: 'bx-soa-reg-block'},
3198					children: [
3199						BX.create('P', {html: this.params.MESS_REGISTRATION_REFERENCE}),
3200						BX.create('A', {
3201							props: {className: 'btn btn-default btn-lg'},
3202							text: BX.message('STOF_DO_REGISTER'),
3203							events: {
3204								click: BX.delegate(function(e){
3205									this.toggleAuthForm(e);
3206									return BX.PreventDefault(e);
3207								}, this)
3208							}
3209						})
3210					]
3211				}));
3212			}
3213
3214			authContent.appendChild(BX.create('DIV', {props: {className: 'col-md-6'}, children: nodes}));
3215		},
3216
3217		getAuthReference: function(authContent)
3218		{
3219			authContent.appendChild(
3220				BX.create('DIV', {
3221					props: {className: 'row'},
3222					children: [
3223						BX.create('DIV', {
3224							props: {className: 'bx-soa-reference col-12'},
3225							children: [
3226								this.params.MESS_AUTH_REFERENCE_1,
3227								BX.create('BR'),
3228								this.params.MESS_AUTH_REFERENCE_2,
3229								BX.create('BR'),
3230								this.params.MESS_AUTH_REFERENCE_3
3231							]
3232						})
3233					]
3234				})
3235			);
3236		},
3237
3238		toggleAuthForm: function(event)
3239		{
3240			if (!event)
3241				return;
3242
3243			var target = event.target || event.srcElement,
3244				section = BX.findParent(target, {className: 'bx-soa-section'}),
3245				container = BX.findParent(target, {className: 'bx-soa-section-content'}),
3246				insertContainer = BX.firstChild(this.authHiddenBlockNode);
3247
3248			new BX.easing({
3249				duration: 100,
3250				start: {opacity: 100},
3251				finish: {opacity: 0},
3252				transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
3253				step: function(state){
3254					container.style.opacity = state.opacity / 100;
3255				}
3256			}).animate();
3257
3258			this.authHiddenBlockNode.appendChild(container);
3259			BX.cleanNode(section);
3260			section.appendChild(
3261				BX.create('DIV', {
3262					props: {className: 'bx-soa-section-title-container'},
3263					children: [
3264						BX.create('h2', {
3265							props: {className: 'bx-soa-section-title col-xs-7 col-sm-9'},
3266							html: BX.hasClass(insertContainer, 'reg') ? this.params.MESS_REG_BLOCK_NAME : this.params.MESS_AUTH_BLOCK_NAME
3267						})
3268					]
3269				})
3270			);
3271			insertContainer.style.opacity = 0;
3272			section.appendChild(insertContainer);
3273
3274			setTimeout(function(){
3275				new BX.easing({
3276					duration: 100,
3277					start: {opacity: 0},
3278					finish: {opacity: 100},
3279					transition: BX.easing.makeEaseOut(BX.easing.transitions.quart),
3280					step: function(state){
3281						insertContainer.style.opacity = state.opacity / 100;
3282					},
3283					complete: function() {
3284						insertContainer.style.height = '';
3285						insertContainer.style.opacity = '';
3286					}
3287				}).animate();
3288			}, 110);
3289
3290			this.animateScrollTo(section);
3291		},
3292
3293		alignBasketColumns: function()
3294		{
3295			if (!this.basketBlockNode)
3296				return;
3297
3298			var i = 0, k, columns = 0, columnNodes,
3299				windowSize = BX.GetWindowInnerSize(),
3300				basketRows, percent;
3301
3302			if (windowSize.innerWidth > 580 && windowSize.innerWidth < 992)
3303			{
3304				basketRows = this.basketBlockNode.querySelectorAll('.bx-soa-basket-info');
3305				percent = 100;
3306
3307				if (basketRows.length)
3308				{
3309					columnNodes = basketRows[0].querySelectorAll('.bx-soa-item-properties');
3310
3311					if (columnNodes.length && columnNodes[0].style.width != '')
3312						return;
3313
3314					columns = columnNodes.length;
3315					if (columns > 0)
3316					{
3317						columns = columns > 4 ? 4 : columns;
3318						percent = parseInt(percent / columns);
3319						for (; i < basketRows.length; i++)
3320						{
3321							columnNodes = basketRows[i].querySelectorAll('.bx-soa-item-properties')
3322							for (k = 0; k < columnNodes.length; k++)
3323							{
3324								columnNodes[k].style.width = percent + '%';
3325							}
3326						}
3327					}
3328				}
3329			}
3330			else
3331			{
3332				columnNodes = this.basketBlockNode.querySelectorAll('.bx-soa-item-properties');
3333
3334				if (columnNodes.length && columnNodes[0].style.width == '')
3335					return;
3336
3337				for (; i < columnNodes.length; i++)
3338				{
3339					columnNodes[i].style.width = '';
3340				}
3341			}
3342		},
3343
3344		editBasketBlock: function(active)
3345		{
3346			if (!this.basketBlockNode || !this.basketHiddenBlockNode || !this.result.GRID)
3347				return;
3348
3349			/*BX.remove(BX.lastChild(this.basketBlockNode));
3350			BX.remove(BX.lastChild(this.basketHiddenBlockNode));*/
3351
3352			this.editActiveBasketBlock(active);
3353			/*this.editFadeBasketBlock(active);*/
3354
3355			/*this.initialized.basket = true;*/
3356		},
3357
3358		editActiveBasketBlock: function(activeNodeMode)
3359		{
3360			var node = !!activeNodeMode ? this.basketBlockNode : this.basketHiddenBlockNode,
3361				basketContent, basketTable;
3362
3363			if (this.initialized.basket)
3364			{
3365				this.basketHiddenBlockNode.appendChild(BX.lastChild(node));
3366				node.appendChild(BX.firstChild(this.basketHiddenBlockNode));
3367			}
3368			else
3369			{
3370				basketContent = node.querySelector('.bx-soa-section-content-node');
3371
3372				/*if (!basketContent)
3373				{
3374					basketContent = this.getNewContainer();
3375					node.appendChild(basketContent);
3376				}
3377				else
3378				{*/
3379					BX.cleanNode(basketContent);
3380				/*}*/
3381
3382
3383
3384				this.editBasketItems(basketContent, true);
3385
3386				/*basketContent.appendChild(basketTable);*/
3387
3388
3389				if (this.params.SHOW_COUPONS_BASKET === 'Y')
3390				{
3391					this.editCoupons(basketContent);
3392				}
3393				/*
3394
3395				this.getBlockFooter(basketContent);
3396
3397				BX.bind(
3398					basketContent.querySelector('div.bx-soa-table-fade').firstChild,
3399					'scroll',
3400					BX.proxy(this.basketBlockScrollCheckEvent, this)
3401				);*/
3402			}
3403
3404			this.alignBasketColumns();
3405		},
3406
3407		editFadeBasketBlock: function(activeNodeMode)
3408		{
3409			/*var node = !!activeNodeMode ? this.basketHiddenBlockNode : this.basketBlockNode,
3410				newContent, basketTable;
3411
3412			if (this.initialized.basket)
3413			{
3414				this.basketHiddenBlockNode.appendChild(node.querySelector('.bx-soa-section-content'));
3415				this.basketBlockNode.appendChild(BX.firstChild(this.basketHiddenBlockNode));
3416			}
3417			else
3418			{
3419				newContent = this.getNewContainer();
3420				basketTable = BX.create('DIV', {props: {className: 'bx-soa-item-table'}});
3421
3422				this.editBasketItems(basketTable, false);
3423
3424				newContent.appendChild(
3425					BX.create('DIV', {
3426						props: {className: 'bx-soa-table-fade'},
3427						children: [
3428							BX.create('DIV', {
3429								style: {overflowX: 'auto', overflowY: 'hidden'},
3430								children: [basketTable]
3431							})
3432						]
3433					})
3434				);
3435
3436				if (this.params.SHOW_COUPONS_BASKET === 'Y')
3437				{
3438					this.editCouponsFade(newContent);
3439				}
3440
3441				node.appendChild(newContent);
3442				this.alignBasketColumns();
3443				this.basketBlockScrollCheck();
3444
3445				BX.bind(
3446					this.basketBlockNode.querySelector('div.bx-soa-table-fade').firstChild,
3447					'scroll',
3448					BX.proxy(this.basketBlockScrollCheckEvent, this)
3449				);
3450			}
3451
3452			this.alignBasketColumns();*/
3453		},
3454
3455		editBasketItems: function(basketItemsNode, active)
3456		{
3457			if (!this.result.GRID.ROWS)
3458				return;
3459
3460			var index = 0, i;
3461
3462
3463			/*if (this.params.SHOW_BASKET_HEADERS === 'Y')
3464			{
3465				this.editBasketItemsHeader(basketItemsNode);
3466			}*/
3467
3468			for (i in this.result.GRID.ROWS)
3469			{
3470				if (this.result.GRID.ROWS.hasOwnProperty(i))
3471				{
3472					this.createBasketItem(basketItemsNode, this.result.GRID.ROWS[i], index++, !!active);
3473				}
3474			}
3475		},
3476
3477		editBasketItemsHeader: function(basketItemsNode)
3478		{
3479			/*if (!basketItemsNode)
3480				return;
3481
3482			var headers = [
3483					BX.create('DIV', {
3484						props: {className: 'bx-soa-item-td'},
3485						style: {paddingBottom: '5px'},
3486						children: [
3487							BX.create('DIV', {
3488								props: {className: 'bx-soa-item-td-title'},
3489								text: BX.message('SOA_SUM_NAME')
3490							})
3491						]
3492					})
3493				],
3494				toRight = false, column, basketColumnIndex = 0, i;
3495
3496			for (i = 0; i < this.result.GRID.HEADERS.length; i++)
3497			{
3498				column = this.result.GRID.HEADERS[i];
3499
3500				if (column.id === 'NAME' || column.id === 'PREVIEW_PICTURE' || column.id === 'PROPS' || column.id === 'NOTES')
3501					continue;
3502
3503				if (column.id === 'DETAIL_PICTURE' && !this.options.showPreviewPicInBasket)
3504					continue;
3505
3506				toRight = BX.util.in_array(column.id, ["QUANTITY", "PRICE_FORMATED", "DISCOUNT_PRICE_PERCENT_FORMATED", "SUM"]);
3507				headers.push(
3508					BX.create('DIV', {
3509						props: {className: 'bx-soa-item-td bx-soa-item-properties' + (toRight ? ' bx-text-right' : '')},
3510						style: {paddingBottom: '5px'},
3511						children: [
3512							BX.create('DIV', {
3513								props: {className: 'bx-soa-item-td-title'},
3514								text: column.name
3515							})
3516						]
3517					})
3518				);
3519
3520				++basketColumnIndex;
3521				if (basketColumnIndex == 4 && this.result.GRID.HEADERS[i + 1])
3522				{
3523					headers.push(BX.create('DIV', {props: {className: 'bx-soa-item-nth-4p1'}}));
3524					basketColumnIndex = 0;
3525				}
3526			}
3527
3528			basketItemsNode.appendChild(
3529				BX.create('DIV', {
3530					props: {className: 'bx-soa-item-tr hidden-sm hidden-xs'},
3531					children: headers
3532				})
3533			);*/
3534		},
3535
3536		createBasketItem: function(basketItemsNode, item, index, active)
3537		{
3538			/*var mainColumns = [],
3539				otherColumns = [],
3540				hiddenColumns = [],
3541				currentColumn, basketColumnIndex = 0,
3542				i, tr, cols;*/
3543				
3544
3545			var htmlPrice = "";
3546
3547			htmlPrice = '<div class="sum-price-product bold">'+item.data.SUM+'</div>';
3548
3549			if(parseInt(item.data.DISCOUNT_PRICE) > 0)
3550				htmlPrice += '<div class="sum-oldprice-product">'+item.data.SUM_BASE_FORMATED+'</div>';
3551
3552
3553			basketItemsNode.appendChild(
3554				BX.create('DIV', {
3555					props: {className: 'product order-product row'},
3556					children: [
3557						BX.create('DIV', {
3558							props: {className: 'col-sm-8 col-12'},
3559							children: [
3560								BX.create('DIV', {
3561									props: {className: 'img-name row no-gutters'},
3562									children: [
3563										this.createBasketItemImg(item.data),
3564										this.createBasketItemContent(item.data)
3565									]
3566
3567								}),
3568							]
3569
3570						}),
3571						BX.create('DIV', {
3572							props: {className: 'col-sm-2 col-5 wrapper-quantity'},
3573							html: item.data.QUANTITY + '&nbsp;' + item.data.MEASURE_TEXT
3574
3575						}),
3576						BX.create('DIV', {
3577							props: {className: 'col-sm-2 col-5 wrapper-sum'},
3578							html: htmlPrice
3579
3580						}),
3581					]
3582
3583				})
3584			);
3585
3586			
3587
3588			/*
3589			for (i = 0; i < this.result.GRID.HEADERS.length; i++)
3590			{
3591				currentColumn = this.result.GRID.HEADERS[i];
3592
3593				if (currentColumn.id === 'NAME' || currentColumn.id === 'PREVIEW_PICTURE' || currentColumn.id === 'PROPS' || currentColumn.id === 'NOTES')
3594					continue;
3595
3596				if (currentColumn.id === 'DETAIL_PICTURE' && !this.options.showPreviewPicInBasket)
3597					continue;
3598
3599				otherColumns.push(this.createBasketItemColumn(currentColumn, item, active));
3600
3601				++basketColumnIndex;
3602				if (basketColumnIndex == 4 && this.result.GRID.HEADERS[i + 1])
3603				{
3604					otherColumns.push(BX.create('DIV', {props: {className: 'bx-soa-item-nth-4p1'}}));
3605					basketColumnIndex = 0;
3606				}
3607			}
3608			
3609			if (active)
3610			{
3611				for (i = 0; i < this.result.GRID.HEADERS_HIDDEN.length; i++)
3612				{
3613					tr = this.createBasketItemHiddenColumn(this.result.GRID.HEADERS_HIDDEN[i], item);
3614					if (BX.type.isArray(tr))
3615						hiddenColumns = hiddenColumns.concat(tr);
3616					else if (tr)
3617						hiddenColumns.push(tr);
3618				}
3619			}
3620
3621			cols = [
3622				BX.create('DIV', {
3623					props: {className: 'bx-soa-item-td'},
3624					style: {minWidth: '300px'},
3625					children: [
3626						BX.create('DIV', {
3627							props: {className: 'bx-soa-item-block'},
3628							children: mainColumns
3629						})
3630					]
3631				})
3632			].concat(otherColumns);
3633
3634			basketItemsNode.appendChild(
3635				BX.create('DIV', {
3636					props: {className: 'bx-soa-item-tr bx-soa-basket-info'},
3637					children: cols
3638				})
3639			);*/
3640
3641			/*if (hiddenColumns.length)
3642			{
3643				basketItemsNode.appendChild(
3644					BX.create('DIV', {
3645						props: {className: 'bx-soa-item-tr bx-soa-item-info-container'},
3646						children: [
3647							BX.create('DIV', {
3648								props: {className: 'bx-soa-item-td'},
3649								children: [
3650									BX.create('A', {
3651										props: {href: '', className: 'bx-soa-info-shower'},
3652										html: this.params.MESS_ADDITIONAL_PROPS,
3653										events: {
3654											click: BX.proxy(this.showAdditionalProperties, this)
3655										}
3656									}),
3657									BX.create('DIV', {
3658										props: {className: 'bx-soa-item-info-block'},
3659										children: [
3660											BX.create('TABLE', {
3661												props: {className: 'bx-soa-info-block'},
3662												children: hiddenColumns
3663											})
3664										]
3665									})
3666								]
3667							})
3668						]
3669					})
3670				);
3671			}*/
3672		},
3673
3674		showAdditionalProperties: function(event)
3675		{
3676			var target = event.target || event.srcElement,
3677				infoContainer = target.nextSibling,
3678				parentContainer = BX.findParent(target, {className: 'bx-soa-item-tr bx-soa-item-info-container'}),
3679				parentHeight = parentContainer.offsetHeight;
3680
3681			if (BX.hasClass(infoContainer, 'bx-active'))
3682			{
3683				new BX.easing({
3684					duration: 300,
3685					start: {opacity: 100, height: parentHeight},
3686					finish: {opacity: 0, height: 35},
3687					transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
3688					step: function(state){
3689						infoContainer.style.opacity = state.opacity / 100;
3690						infoContainer.style.height = state.height + 'px';
3691						parentContainer.style.height = state.height + 'px';
3692					},
3693					complete: function(){
3694						BX.removeClass(infoContainer, 'bx-active');
3695						infoContainer.removeAttribute("style");
3696						parentContainer.removeAttribute("style");
3697					}
3698				}).animate();
3699			}
3700			else
3701			{
3702				infoContainer.style.opacity = 0;
3703				BX.addClass(infoContainer, 'bx-active');
3704				var height = infoContainer.offsetHeight + parentHeight;
3705				BX.removeClass(infoContainer, 'bx-active');
3706				infoContainer.style.paddingTop = '10px';
3707
3708				new BX.easing({
3709					duration: 300,
3710					start: {opacity: 0, height: parentHeight},
3711					finish: {opacity: 100, height: height},
3712					transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
3713					step: function(state){
3714						infoContainer.style.opacity = state.opacity / 100;
3715						infoContainer.style.height = state.height + 'px';
3716						parentContainer.style.height = state.height + 'px';
3717					},
3718					complete: function(){
3719						BX.addClass(infoContainer, 'bx-active');
3720						infoContainer.removeAttribute("style");
3721					}
3722				}).animate();
3723			}
3724
3725			return BX.PreventDefault(event);
3726		},
3727
3728		createBasketItemImg: function(data)
3729		{
3730			if (!data)
3731				return;
3732
3733			/*var logotype, imgSrc;
3734
3735	
3736
3737			if (data.PREVIEW_PICTURE_SRC && data.PREVIEW_PICTURE_SRC.length)
3738				logotype = this.getImageSources(data, 'PREVIEW_PICTURE');
3739			else if (data.DETAIL_PICTURE_SRC && data.DETAIL_PICTURE_SRC.length)
3740				logotype = this.getImageSources(data, 'DETAIL_PICTURE');
3741
3742			if (logotype && logotype.src_2x)
3743			{
3744				logoNode.setAttribute('style',
3745					'background-image: url(' + logotype.src_1x + ');' +
3746					'background-image: -webkit-image-set(url(' + logotype.src_1x + ') 1x, url(' + logotype.src_2x + ') 2x)'
3747				);
3748				imgSrc = logotype.src_1x;
3749			}
3750			else
3751			{
3752				logotype = logotype && logotype.src_1x || this.defaultBasketItemLogo;
3753				logoNode.setAttribute('style', 'background-image: url(' + logotype + ');');
3754				imgSrc = this.defaultBasketItemLogo;
3755			}*/
3756
3757
3758
3759			return BX.create('DIV', {
3760				props: {className: 'img col-3'},
3761				html: "<a class=\"link_style d-block\" target=\"_blank\" href=\""+globalProductsInfo[data.PRODUCT_ID].DETAIL_URL+"\"><img src=\""+globalProductsInfo[data.PRODUCT_ID].PREVIEW_PICTURE_SRC+"\" alt=\""+globalProductsInfo[data.PRODUCT_ID].NAME+"\"></a>"
3762			});
3763		},
3764
3765		createBasketItemContent: function(data)
3766		{
3767			/*var itemName = data.NAME || '',
3768				titleHtml = this.htmlspecialcharsEx(itemName),
3769				props = data.PROPS || [],
3770				propsNodes = [];
3771
3772			if (data.DETAIL_PAGE_URL && data.DETAIL_PAGE_URL.length)
3773				titleHtml = '<a href="' + data.DETAIL_PAGE_URL + '" class="d-block bold product-name">' + titleHtml + '</a>';
3774			
3775
3776			if (this.options.showPropsInBasket && props.length)
3777			{
3778				for (var i in props)
3779				{
3780					if (props.hasOwnProperty(i))
3781					{
3782						var name = props[i].NAME || '',
3783							value = props[i].VALUE || '';
3784
3785						propsNodes.push(
3786							BX.create('DIV', {
3787								props: {className: 'bx-soa-item-td-title'},
3788								style: {textAlign: 'left'},
3789								text: name
3790							})
3791						);
3792						propsNodes.push(
3793							BX.create('DIV', {
3794								props: {className: 'bx-soa-item-td-text'},
3795								style: {textAlign: 'left'},
3796								text: value
3797							})
3798						);
3799					}
3800				}
3801			}*/
3802
3803
3804			return BX.create('DIV', {
3805				props: {className: 'wr-name col-9 align-self-center'},
3806				html: globalProductsInfo[data.PRODUCT_ID].HTML
3807			});
3808		},
3809
3810		createBasketItemColumn: function(column, allData, active)
3811		{
3812			if (!column || !allData)
3813				return;
3814
3815			var data = allData.columns[column.id] ? allData.columns : allData.data,
3816				toRight = BX.util.in_array(column.id, ["QUANTITY", "PRICE_FORMATED", "DISCOUNT_PRICE_PERCENT_FORMATED", "SUM"]),
3817				textNode = BX.create('DIV', {props: {className: 'bx-soa-item-td-text'}}
3817),
3818				logotype, img;
3819
3820			if (column.id === 'PRICE_FORMATED')
3821			{
3822				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price'}, html: data.PRICE_FORMATED}));
3823				if (parseFloat(data.DISCOUNT_PRICE) > 0)
3824				{
3825					textNode.appendChild(BX.create('BR'));
3826					textNode.appendChild(BX.create('STRONG', {
3827						props: {className: 'bx-price-old'},
3828						html: data.BASE_PRICE_FORMATED
3829					}));
3830				}
3831
3832				if (this.options.showPriceNotesInBasket && active)
3833				{
3834					textNode.appendChild(BX.create('BR'));
3835					textNode.appendChild(BX.create('SMALL', {text: data.NOTES}));
3836				}
3837			}
3838			else if (column.id === 'SUM')
3839			{
3840				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price all'}, html: data.SUM}));
3841				if (parseFloat(data.DISCOUNT_PRICE) > 0)
3842				{
3843					textNode.appendChild(BX.create('BR'));
3844					textNode.appendChild(BX.create('STRONG', {
3845						props: {className: 'bx-price-old'},
3846						html: data.SUM_BASE_FORMATED
3847					}));
3848				}
3849			}
3850			else if (column.id === 'DISCOUNT')
3851			{
3852				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price'}, text: data.DISCOUNT_PRICE_PERCENT_FORMATED}));
3853			}
3854			else if (column.id === 'DETAIL_PICTURE')
3855			{
3856				logotype = this.getImageSources(allData.data, column.id),
3857				img = BX.create('IMG', {props: {src: logotype && logotype.src_1x || this.defaultBasketItemLogo}});
3858
3859				if (logotype && logotype.src_1x && logotype.src_orig)
3860				{
3861					BX.bind(img, 'click', BX.delegate(function(e){this.popupShow(e, logotype.src_orig);}, this));
3862				}
3863
3864				textNode.appendChild(img);
3865			}
3866			else if (BX.util.in_array(column.id, ["QUANTITY", "WEIGHT_FORMATED", "DISCOUNT_PRICE_PERCENT_FORMATED"]))
3867			{
3868				textNode.appendChild(BX.create('SPAN', {html: data[column.id]}));
3869			}
3870			else if (column.id === 'PREVIEW_TEXT')
3871			{
3872				if (data['PREVIEW_TEXT_TYPE'] === 'html')
3873				{
3874					textNode.appendChild(BX.create('SPAN', {html: data['PREVIEW_TEXT'] || ''}));
3875				}
3876				else
3877				{
3878					textNode.appendChild(BX.create('SPAN', {text: data['PREVIEW_TEXT'] || ''}));
3879				}
3880			}
3881			else
3882			{
3883				var columnData = data[column.id], val = [];
3884				if (BX.type.isArray(columnData))
3885				{
3886					for (var i in columnData)
3887					{
3888						if (columnData.hasOwnProperty(i))
3889						{
3890							if (columnData[i].type == 'image')
3891								val.push(this.getImageContainer(columnData[i].value, columnData[i].source));
3892							else if (columnData[i].type == 'linked')
3893							{
3894								textNode.appendChild(BX.create('SPAN', {html: columnData[i].value_format}));
3895								textNode.appendChild(BX.create('BR'));
3896							}
3897							else if (columnData[i].value)
3898							{
3899								textNode.appendChild(BX.create('SPAN', {html: columnData[i].value}));
3900								textNode.appendChild(BX.create('BR'));
3901							}
3902						}
3903					}
3904
3905					if (val.length)
3906					{
3907						textNode.appendChild(
3908							BX.create('DIV', {
3909								props: {className: 'bx-scu-list'},
3910								children: [BX.create('UL', {props: {className: 'bx-scu-itemlist'}, children: val})]
3911							})
3912						);
3913					}
3914				}
3915				else if (columnData)
3916				{
3917					textNode.appendChild(BX.create('SPAN', {html: BX.util.htmlspecialchars(columnData)}));
3918				}
3919			}
3920
3921			return BX.create('DIV', {
3922				props: {className: 'bx-soa-item-td bx-soa-item-properties' + (toRight ? ' bx-text-right' : '')},
3923				children: [
3924					BX.create('DIV', {
3925						props: {className: 'bx-soa-item-td-title visible-xs visible-sm'},
3926						text: column.name
3927					}),
3928					textNode
3929				]
3930			});
3931		},
3932
3933		createBasketItemHiddenColumn: function(column, allData)
3934		{
3935			if (!column || !allData)
3936				return;
3937
3938			var data = allData.columns[column.id] ? allData.columns : allData.data,
3939				textNode = BX.create('TD', {props: {className: 'bx-soa-info-text'}}
3939),
3940				logotype, img, i;
3941
3942			if (column.id === 'PROPS')
3943			{
3944				var propsNodes = [], props = allData.data.PROPS;
3945				if (props && props.length)
3946				{
3947					for (i in props)
3948					{
3949						if (props.hasOwnProperty(i))
3950						{
3951							var name = props[i].NAME || '',
3952								value = props[i].VALUE || '';
3953
3954							if (value.length == 0)
3955								continue;
3956
3957							propsNodes.push(
3958								BX.create('TR', {
3959									props: {className: 'bx-soa-info-line'},
3960									children: [
3961										BX.create('TD', {props: {className: 'bx-soa-info-title'}, text: name + ':'}),
3962										BX.create('TD', {props: {className: 'bx-soa-info-text'}, html: BX.util.htmlspecialchars(value)})
3963									]
3964								})
3965							);
3966						}
3967					}
3968
3969					return propsNodes;
3970				}
3971				else return;
3972			}
3973			else if (column.id === 'PRICE_FORMATED')
3974			{
3975				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price'}, html: data.PRICE_FORMATED}));
3976				if (parseFloat(data.DISCOUNT_PRICE) > 0)
3977				{
3978					textNode.appendChild(BX.create('BR'));
3979					textNode.appendChild(BX.create('STRONG', {
3980						props: {className: 'bx-price-old'},
3981						html: data.BASE_PRICE_FORMATED
3982					}));
3983				}
3984			}
3985			else if (column.id === 'SUM')
3986				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price all'}, text: data.SUM}));
3987			else if (column.id === 'DISCOUNT')
3988				textNode.appendChild(BX.create('STRONG', {props: {className: 'bx-price'}, text: data.DISCOUNT_PRICE_PERCENT_FORMATED}));
3989			else if (column.id === 'DETAIL_PICTURE' || column.id === 'PREVIEW_PICTURE')
3990			{
3991				logotype = this.getImageSources(allData.data, column.id),
3992				img = BX.create('IMG', {props: {src: logotype && logotype.src_1x || this.defaultBasketItemLogo}, style: {maxWidth: '50%'}});
3993
3994				if (logotype && logotype.src_1x && logotype.src_orig)
3995				{
3996					BX.bind(img, 'click', BX.delegate(function(e){this.popupShow(e, logotype.src_orig);}, this));
3997				}
3998
3999				textNode.appendChild(img);
4000			}
4001			else if (BX.util.in_array(column.id, ["QUANTITY", "WEIGHT_FORMATED", "DISCOUNT_PRICE_PERCENT_FORMATED"]))
4002			{
4003				textNode.appendChild(BX.create('SPAN', {html: data[column.id]}));
4004			}
4005			else if (column.id === 'PREVIEW_TEXT')
4006			{
4007				if (data['PREVIEW_TEXT_TYPE'] === 'html')
4008				{
4009					textNode.appendChild(BX.create('SPAN', {html: data['PREVIEW_TEXT'] || ''}));
4010				}
4011				else
4012				{
4013					textNode.appendChild(BX.create('SPAN', {text: data['PREVIEW_TEXT'] || ''}));
4014				}
4015			}
4016			else
4017			{
4018				var columnData = data[column.id], val = [];
4019				if (BX.type.isArray(columnData))
4020				{
4021					for (i in columnData)
4022					{
4023						if (columnData.hasOwnProperty(i))
4024						{
4025							if (columnData[i].type == 'image')
4026								val.push(this.getImageContainer(columnData[i].value, columnData[i].source));
4027							else if (columnData[i].type == 'linked')
4028							{
4029								textNode.appendChild(BX.create('SPAN', {html: columnData[i].value_format}));
4030								textNode.appendChild(BX.create('BR'));
4031							}
4032							else if (columnData[i].value)
4033							{
4034								textNode.appendChild(BX.create('SPAN', {html: columnData[i].value}));
4035								textNode.appendChild(BX.create('BR'));
4036							}
4037							else return;
4038						}
4039					}
4040
4041					if (val.length)
4042					{
4043						textNode.appendChild(
4044							BX.create('DIV', {
4045								props: {className: 'bx-scu-list'},
4046								children: [BX.create('UL', {props: {className: 'bx-scu-itemlist'}, children: val})]
4047							})
4048						);
4049					}
4050
4051				}
4052				else if (columnData)
4053				{
4054					textNode.appendChild(BX.create('SPAN', {html: BX.util.htmlspecialchars(columnData)}));
4055				}
4056				else
4057				{
4058					return;
4059				}
4060			}
4061
4062			return BX.create('TR', {
4063				props: {className: 'bx-soa-info-line'},
4064				children: [
4065					BX.create('TD', {
4066						props: {className: 'bx-soa-info-title'},
4067						text: column.name + ':'
4068					}),
4069					textNode
4070				]
4071			});
4072		},
4073
4074		popupShow: function(e, url, source)
4075		{
4076			if (this.popup)
4077				this.popup.destroy();
4078
4079			var that = this;
4080			this.popup = new BX.PopupWindow('bx-soa-image-popup', null, {
4081				lightShadow: true,
4082				offsetTop: 0,
4083				offsetLeft: 0,
4084				closeIcon: {top: '3px', right: '10px'},
4085				autoHide: true,
4086				bindOptions: {position: "bottom"},
4087				closeByEsc: true,
4088				zIndex: 100,
4089				events: {
4090					onPopupShow: function() {
4091						BX.create("IMG", {
4092							props: {src: source || url},
4093							events: {
4094								load: function() {
4095									var content = BX('bx-soa-image-popup-content');
4096									if (content)
4097									{
4098										var windowSize = BX.GetWindowInnerSize(),
4099											ratio = this.isMobile ? 0.5 : 0.9,
4100											contentHeight, contentWidth;
4101
4102										BX.cleanNode(content);
4103										content.appendChild(this);
4104
4105										contentHeight = content.offsetHeight;
4106										contentWidth = content.offsetWidth;
4107
4108										if (contentHeight > windowSize.innerHeight * ratio)
4109										{
4110											content.style.height = windowSize.innerHeight * ratio + 'px';
4111											content.style.width = contentWidth * (windowSize.innerHeight * ratio / contentHeight) + 'px';
4112											contentHeight = content.offsetHeight;
4113											contentWidth = content.offsetWidth;
4114										}
4115
4116										if (contentWidth > windowSize.innerWidth * ratio)
4117										{
4118											content.style.width = windowSize.innerWidth * ratio + 'px';
4119											content.style.height = contentHeight * (windowSize.innerWidth * ratio / contentWidth) + 'px';
4120										}
4121
4122										content.style.height = content.offsetHeight + 'px';
4123										content.style.width = content.offsetWidth + 'px';
4124
4125										that.popup.adjustPosition();
4126									}
4127								}
4128							}
4129						});
4130					},
4131					onPopupClose: function() {
4132						this.destroy();
4133					}
4134				},
4135				content: BX.create('DIV', {
4136					props: {id: 'bx-soa-image-popup-content'},
4137					children: [BX.create('IMG', {props: {src: this.templateFolder + "/images/loader.gif"}})]
4138				})
4139			});
4140			this.popup.show();
4141		},
4142
4143		getImageContainer: function(link, source)
4144		{
4145			return BX.create('LI', {
4146				props: {className: 'bx-img-item'},
4147				children: [
4148					BX.create('DIV', {
4149						props: {className: 'bx-scu-itemColorBlock'},
4150						children: [
4151							BX.create('DIV', {
4152								props: {className: 'bx-img-itemColor'},
4153								style: {backgroundImage: 'url(' + link + ')'}
4154							})
4155						],
4156						events: {
4157							click: BX.delegate(function(e){this.popupShow(e, link, source)}, this)
4158						}
4159					})
4160				]
4161			});
4162		},
4163
4164		editCoupons: function(basketItemsNode)
4165		{
4166
4167			if($("#basketPage").length>0)
4168			{
4169				if(!$.isEmptyObject(basketPoolQuantity))
4170					recalcBasketAjax({"action": "stopRefreshOrder"});
4171			}
4172			
4173			var couponsList = this.getCouponsList(true);
4174
4175			$(".coupons_block").html("");
4176
4177			if(couponsList.length>0)
4178			{
4179				for (var i = 0; i < couponsList.length; i++)
4180				{
4181					couponCreate(couponsList[i], true);
4182				}
4183			}
4184		},
4185
4186		getCouponsList: function(active)
4187		{
4188			var couponsList = [], i;
4189
4190			if(this.result.COUPON_LIST.length>0)
4191			{
4192
4193				for (i = 0; i < this.result.COUPON_LIST.length; i++)
4194				{
4195					if (active || (!active && this.result.COUPON_LIST[i].JS_STATUS == 'APPLIED'))
4196					{
4197						couponsList.push(this.getCouponNode({
4198							text: this.result.COUPON_LIST[i].COUPON,
4199							desc: this.result.COUPON_LIST[i].JS_CHECK_CODE,
4200							status: this.result.COUPON_LIST[i].JS_STATUS
4201						}, active));
4202					}
4203				}
4204			}
4205
4206			return couponsList;
4207		},
4208		
4209
4210		getCouponNode: function(coupon, active)
4211		{
4212			var couponName = BX.util.htmlspecialchars(coupon.text) || '',
4213				couponDesc = coupon.desc && coupon.desc.length
4214					? coupon.desc.charAt(0).toUpperCase() + coupon.desc.slice(1)
4215					: BX.message('SOA_NOT_FOUND'),
4216				couponStatus = coupon.status || 'BAD',
4217				couponItem, tooltip;
4218
4219			switch (couponStatus.toUpperCase())
4220			{
4221				case 'ENTERED': couponItem = 'used'; tooltip = 'warning'; break;
4222				case 'BAD': couponItem = tooltip = 'danger'; break;
4223				default: couponItem = tooltip  = 'success';
4224			}
4225
4226			return {
4227				JS_STATUS: couponStatus,
4228				COUPON: couponName,
4229			};
4230		},
4231
4232		addCoupon: function(coupon)
4233		{
4234			
4235			var couponListNodes = $(".coupons_block").find(".coupon-one"),
4236				addCoupon = true;
4237
4238			if(couponListNodes.length>0)
4239			{
4240				for (var i = 0; i < couponListNodes.length; i++)
4241				{
4242					if (couponListNodes[i].querySelector('[data-coupon="' + BX.util.htmlspecialchars(coupon) + '"]'))
4243					{
4244						addCoupon = false;
4245						break;
4246					}
4247				}
4248			}
4249
4250			if(addCoupon)
4251				couponCreate(this.getCouponNode({text: coupon}, true), true);
4252
4253		},
4254
4255		removeCoupon: function(coupon)
4256		{
4257			$(".remove-order-coupon[data-coupon='"+BX.util.htmlspecialchars(coupon)+"']").parents(".coupon-one").remove();
4258		},
4259
4260		editRegionBlock: function(active)
4261		{
4262			if (!this.regionBlockNode || !this.regionHiddenBlockNode || !this.result.PERSON_TYPE)
4263				return;
4264
4265			if (active)
4266			{
4267				this.editActiveRegionBlock(true);
4268				!this.regionBlockNotEmpty && this.editFadeRegionBlock();
4269			}
4270			else
4271				this.editFadeRegionBlock();
4272
4273			/*this.initialized.region = true;*/
4274		},
4275
4276		editActiveRegionBlock: function(activeNodeMode)
4277		{
4278			var node = activeNodeMode ? this.regionBlockNode : this.regionHiddenBlockNode,
4279				regionContent, regionNode;
4280
4281
4282			if (this.initialized.region)
4283			{
4284				BX.remove(BX.lastChild(node));
4285				node.appendChild(BX.firstChild(this.regionHiddenBlockNode));
4286			}
4287			else
4288			{
4289				regionContent = node.querySelector('.bx-soa-section-content-node');
4290
4291				if (!regionContent)
4292				{
4293					regionContent = this.getNewContainer();
4294					node.appendChild(regionContent);
4295				}
4296				else
4297					BX.cleanNode(regionContent);
4298
4299
4300				this.getErrorContainer(regionContent);
4301
4302
4303
4304				regionNode = BX.create('DIV', {props: {className: 'bx_soa_location'}});
4305
4306
4307				this.getPersonTypeControl(regionNode);
4308
4309				// this.getProfilesControl(regionNode);
4310
4311				this.getDeliveryLocationInput(regionNode);
4312
4313
4314
4315				if (!this.result.SHOW_AUTH)
4316				{
4317					if (this.regionBlockNotEmpty)
4318					{
4319						BX.addClass(this.regionBlockNode, 'bx-active');
4320						this.regionBlockNode.style.display = '';
4321					}
4322					else
4323					{
4324						BX.removeClass(this.regionBlockNode, 'bx-active');
4325						this.regionBlockNode.style.display = 'none';
4326
4327						if (!this.result.IS_AUTHORIZED || typeof this.result.LAST_ORDER_DATA.FAIL !== 'undefined')
4328							this.initFirstSection();
4329					}
4330				}
4331
4332			
4333
4334
4335				if(this.regionBlockNotEmpty)
4336				{
4337					node.classList.remove("d-none");
4338				}
4339				else
4340				{
4341					node.classList.add("d-none");
4342				}
4343
4344				//regionNode.appendChild(regionNode);
4345				regionContent.appendChild(regionNode);
4346				this.getBlockFooter(regionContent);
4347			}
4348		},
4349
4350		editFadeRegionBlock: function()
4351		{
4352			var regionContent = this.regionBlockNode.querySelector('.bx-soa-section-content'), newContent;
4353
4354			if (this.initialized.region)
4355			{
4356				this.regionHiddenBlockNode.appendChild(regionContent);
4357			}
4358			else
4359			{
4360				this.editActiveRegionBlock(false);
4361				BX.remove(BX.lastChild(this.regionBlockNode));
4362			}
4363
4364			newContent = this.getNewContainer(true);
4365			this.regionBlockNode.appendChild(newContent);
4366			this.editFadeRegionContent(newContent);
4367		},
4368
4369		editFadeRegionContent: function(node)
4370		{
4371			if (!node || !this.locationsInitialized)
4372				return;
4373
4374			var selectedPersonType = this.getSelectedPersonType(),
4375				errorNode = this.regionHiddenBlockNode.querySelector('.alert.alert-danger'),
4376				addedHtml = '', props = [], locationProperty,
4377				input, zipValue = '', zipProperty,
4378				fadeParamName, i, k, locationString, validRegionErrors;
4379
4380			BX.cleanNode(node);
4381
4382			if (errorNode)
4383				node.appendChild(errorNode.cloneNode(true));
4384
4385			if (selectedPersonType && selectedPersonType.NAME && this.result.PERSON_TYPE.length > 1)
4386			{
4387				addedHtml += '<strong>' + this.params.MESS_PERSON_TYPE + ':</strong> '
4388					+ BX.util.htmlspecialchars(selectedPersonType.NAME) + '<br>';
4389			}
4390
4391			if (selectedPersonType)
4392			{
4393				fadeParamName = 'PROPS_FADE_LIST_' + selectedPersonType.ID;
4394				props = this.params[fadeParamName] || [];
4395			}
4396
4397			for (i in this.result.ORDER_PROP.properties)
4398			{
4399				if (this.result.ORDER_PROP.properties.hasOwnProperty(i))
4400				{
4401					if (this.result.ORDER_PROP.properties[i].IS_LOCATION == 'Y'
4402						&& this.result.ORDER_PROP.properties[i].ID == this.deliveryLocationInfo.loc)
4403					{
4404						locationProperty = this.result.ORDER_PROP.properties[i];
4405					}
4406					else if (this.result.ORDER_PROP.properties[i].IS_ZIP == 'Y'
4407						&& this.result.ORDER_PROP.properties[i].ID == this.deliveryLocationInfo.zip)
4408					{
4409						zipProperty = this.result.ORDER_PROP.properties[i];
4410						for (k = 0; k < props.length; k++)
4411						{
4412							if (props[k] == zipProperty.ID)
4413							{
4414								input = BX('zipProperty');
4415								zipValue = input && input.value && input.value.length ? input.value : BX.message('SOA_NOT_SPECIFIED');
4416								break;
4417							}
4418						}
4419					}
4420				}
4421			}
4422
4423			locationString = this.getLocationString(this.regionHiddenBlockNode);
4424			if (locationProperty && locationString.length)
4425				addedHtml += '<strong>' + BX.util.htmlspecialchars(locationProperty.NAME) + ':</strong> '
4426					+ BX.util.htmlspecialchars(locationString) + '<br>';
4427
4428			if (zipProperty && zipValue.length)
4429				addedHtml += '<strong>' + BX.util.htmlspecialchars(zipProperty.NAME) + ':</strong> '
4430					+ BX.util.htmlspecialchars(zipValue);
4431
4432			node.innerHTML += addedHtml;
4433
4434			if (this.regionBlockNode.getAttribute('data-visited') == 'true')
4435			{
4436				validRegionErrors = this.isValidRegionBlock();
4437
4438				if (validRegionErrors.length)
4439				{
4440					BX.addClass(this.regionBlockNode, 'bx-step-error');
4441					this.showError(this.regionBlockNode, validRegionErrors);
4442				}
4443				else
4444					BX.removeClass(this.regionBlockNode, 'bx-step-error');
4445			}
4446
4447			BX.bind(node.querySelector('.alert.alert-danger'), 'click', BX.proxy(this.showByClick, this));
4448			BX.bind(node.querySelector('.alert.alert-warning'), 'click', BX.proxy(this.showByClick, this));
4449		},
4450
4451		getSelectedPersonType: function()
4452		{
4453			var personTypeInput, currentPersonType, personTypeId, i,
4454				personTypeLength = this.result.PERSON_TYPE.length;
4455
4456			if (personTypeLength == 1)
4457			{
4458				personTypeInput = this.regionBlockNode.querySelector('input[type=hidden][name=PERSON_TYPE]');
4459				if (!personTypeInput)
4460					personTypeInput = this.regionHiddenBlockNode.querySelector('input[type=hidden][name=PERSON_TYPE]');
4461			}
4462			else if (personTypeLength == 2)
4463			{
4464				personTypeInput = this.regionBlockNode.querySelector('input[type=radio][name=PERSON_TYPE]:checked');
4465				if (!personTypeInput)
4466					personTypeInput = this.regionHiddenBlockNode.querySelector('input[type=radio][name=PERSON_TYPE]:checked');
4467			}
4468			else
4469			{
4470				personTypeInput = this.regionBlockNode.querySelector('select[name=PERSON_TYPE] > option:checked');
4471				if (!personTypeInput)
4472					personTypeInput = this.regionHiddenBlockNode.querySelector('select[name=PERSON_TYPE] > option:checked');
4473			}
4474
4475			if (personTypeInput)
4476			{
4477				personTypeId = personTypeInput.value;
4478
4479				for (i in this.result.PERSON_TYPE)
4480				{
4481					if (this.result.PERSON_TYPE[i].ID == personTypeId)
4482					{
4483						currentPersonType = this.result.PERSON_TYPE[i];
4484						break;
4485					}
4486				}
4487			}
4488
4489			return currentPersonType;
4490		},
4491
4492		getDeliveryLocationInput: function(node)
4493		{
4494			var currentProperty, locationId, altId, location, k, altProperty,
4495				labelHtml, currentLocation, insertedLoc,
4496				labelTextHtml, label, input, altNode;
4497
4498			for (k in this.result.ORDER_PROP.properties)
4499			{
4500				if (this.result.ORDER_PROP.properties.hasOwnProperty(k))
4501				{
4502					currentProperty = this.result.ORDER_PROP.properties[k];
4503					if (currentProperty.IS_LOCATION == 'Y')
4504					{
4505						locationId = currentProperty.ID;
4506						altId = parseInt(currentProperty.INPUT_FIELD_LOCATION);
4507						break;
4508					}
4509				}
4510			}
4511
4512			location = this.locations[locationId];
4513
4514
4515			if (location && location[0] && location[0].output)
4516			{
4517				this.regionBlockNotEmpty = true;
4518
4519
4520				labelHtml = '<div class="section-title">'
4521					+ '<span class="text">'+currentProperty.NAME + '</span>'
4522					+ (currentProperty.REQUIRED == 'Y' ? '<span class="bx-authform-starrequired"> *</span> ' : '')
4523					+ (currentProperty.DESCRIPTION.length ? ' (' + BX.util.htmlspecialchars(currentProperty.DESCRIPTION) + ')' : '')
4524					+ '</div>';
4525
4526				currentLocation = location[0].output;
4527
4528
4529				insertedLoc = BX.create('DIV', {
4530					attrs: {'data-property-id-row': locationId},
4531					props: {className: 'bx-form-group bx-soa-location-input-container search-line-location'},
4532					style: {visibility: 'hidden'},
4533					html:  labelHtml + currentLocation.HTML
4534				});
4535
4536				node.appendChild(insertedLoc);
4537				node.appendChild(BX.create('INPUT', {
4538					props: {
4539						type: 'hidden',
4540						name: 'RECENT_DELIVERY_VALUE',
4541						value: location[0].lastValue
4542					}
4543				}));
4544
4545				for (k in currentLocation.SCRIPT)
4546					if (currentLocation.SCRIPT.hasOwnProperty(k))
4547						BX.evalGlobal(currentLocation.SCRIPT[k].JS);
4548			}
4549
4550			/*if (location && location[0])
4551			{
4552				node.appendChild(
4553					BX.create('DIV', {
4554						props: {className: 'bx-soa-reference wr-row'},
4555						html: this.params.MESS_REGION_REFERENCE
4556					})
4557				);
4558			}*/
4559
4560			if (location && location[0] && location[0].showAlt && altId > 0)
4561			{
4562				for (k in this.result.ORDER_PROP.properties)
4563				{
4564					if (parseInt(this.result.ORDER_PROP.properties[k].ID) == altId)
4565					{
4566						altProperty = this.result.ORDER_PROP.properties[k];
4567						break;
4568					}
4569				}
4570			}
4571
4572			if (altProperty)
4573			{
4574				altNode = BX.create('DIV', {
4575					attrs: {'data-property-id-row': altProperty.ID},
4576					props: {className: "bx-form-group bx-soa-location-input-container"}
4577				});
4578
4579				/*labelTextHtml = altProperty.REQUIRED == 'Y' ? '<span class="bx-authform-starrequired">*</span> ' : '';
4580				labelTextHtml += BX.util.htmlspecialchars(altProperty.NAME);*/
4581
4582
4583				label = BX.create('DIV', {
4584
4585					props: {
4586						className: "input-simple inp-small "+(altProperty.VALUE[0]!="" ? "in-focus": "")
4587					},
4588
4589					children:[
4590						BX.create('DIV', {
4591							props: 
4592							{
4593								className: "bg"
4594							},
4595						}),
4596						BX.create('SPAN', {
4597							props: 
4598							{
4599								className: "desc"
4600							},
4601							html: altProperty.NAME
4602						}),
4603						BX.create('INPUT', {
4604							props: {
4605								id: 'altProperty',
4606								type: 'text',
4607								autocomplete: 'city',
4608								className: 'bx-form-control bx-soa-customer-input bx-ios-fix focus-anim bord-1 b-ra '+(altProperty.REQUIRED == 'Y' ? "inp-require": ""),
4609								name: 'ORDER_PROP_' + altProperty.ID,
4610								value: altProperty.VALUE
4611							}
4612						})
4613					]
4614				});
4615
4616				/*label = BX.create('LABEL', {
4617					attrs: {for: 'altProperty'},
4618					props: {className: 'bx-soa-custom-label'},
4619					html: labelTextHtml
4620				});
4621
4622				input = BX.create('INPUT', {
4623					props: {
4624						id: 'altProperty',
4625						type: 'text',
4626						placeholder: altProperty.DESCRIPTION,
4627						autocomplete: 'city',
4628						className: 'bx-form-control bx-soa-customer-input bx-ios-fix',
4629						name: 'ORDER_PROP_' + altProperty.ID,
4630						value: altProperty.VALUE
4631					}
4632				});*/
4633
4634				altNode.appendChild(label);
4635				/*altNode.appendChild(input);*/
4636				node.appendChild(label);
4637
4638				this.bindValidation(altProperty.ID, altNode);
4639			}
4640
4641			this.getZipLocationInput(node);
4642
4643			
4644		},
4645
4646		getLocationString: function(node)
4647		{
4648			if (!node)
4649				return '';
4650
4651			var locationInputNode = node.querySelector('.bx-ui-sls-route'),
4652				locationString = '',
4653				locationSteps, i, altLoc;
4654
4655			if (locationInputNode && locationInputNode.value && locationInputNode.value.length)
4656				locationString = locationInputNode.value;
4657			else
4658			{
4659				locationSteps = node.querySelectorAll('.bx-ui-combobox-fake.bx-combobox-fake-as-input');
4660				for (i = locationSteps.length; i--;)
4661				{
4662					if (locationSteps[i].innerHTML.indexOf('...') >= 0)
4663						continue;
4664
4665					if (locationSteps[i].innerHTML.indexOf('---') >= 0)
4666					{
4667						altLoc = BX('altProperty');
4668						if (altLoc && altLoc.value.length)
4669							locationString += altLoc.value;
4670
4671						continue;
4672					}
4673
4674					if (locationString.length)
4675						locationString += ', ';
4676
4677					locationString += locationSteps[i].innerHTML;
4678				}
4679
4680				if (locationString.length == 0)
4681					locationString = BX.message('SOA_NOT_SPECIFIED');
4682			}
4683
4684			return locationString;
4685		},
4686
4687		getZipLocationInput: function(node)
4688		{
4689			var zipProperty, i, propsItemNode, labelTextHtml, label, input;
4690
4691			for (i in this.result.ORDER_PROP.properties)
4692			{
4693				if (this.result.ORDER_PROP.properties.hasOwnProperty(i) && this.result.ORDER_PROP.properties[i].IS_ZIP == 'Y')
4694				{
4695					zipProperty = this.result.ORDER_PROP.properties[i];
4696					break;
4697				}
4698			}
4699
4700			if (zipProperty)
4701			{
4702				if(!this.regionBlockNotEmpty && this.showZip == "Y")
4703				{
4704					this.regionBlockNotEmpty = true;
4705				}
4706
4707				var desc = [];
4708
4709				if(zipProperty.DESCRIPTION.length>0)
4710				{
4711					desc = BX.create('DIV', {
4712						props: 
4713						{
4714							className: "soa-description align-self-center col-md-6 col-12"
4715						},
4716						html: zipProperty.DESCRIPTION
4717					}
4718					);
4719				}
4720
4721
4722				propsItemNode = BX.create('DIV', {
4723					props: 
4724					{
4725						className: "bx-form-group bx-soa-location-input-container row " + (this.showZip == "Y" ?"":"d-none")
4726					},
4727					children:[
4728
4729						BX.create('DIV', {
4730
4731							props: {
4732									className: "col-md-6 col-12"
4733								},
4734
4735							children:[
4736
4737								BX.create('DIV', {
4738
4739									props: {
4740										className: "input-simple no-mg inp-small "+(zipProperty.VALUE ? "in-focus": "")
4741									},
4742
4743									children:[
4744										BX.create('DIV', {
4745											props: 
4746											{
4747												className: "bg"
4748											},
4749										}),
4750										BX.create('SPAN', {
4751											props: 
4752											{
4753												className: "desc"
4754											},
4755											html: zipProperty.NAME
4756										}),
4757										BX.create('INPUT', {
4758											props: {
4759												id: 'zipProperty',
4760												type: 'text',
4761												autocomplete: 'zip',
4762												className: 'focus-anim bord-1 b-ra '+(zipProperty.REQUIRED == 'Y' ? "inp-require": ""),
4763												name: 'ORDER_PROP_' + zipProperty.ID,
4764												value: zipProperty.VALUE
4765											}
4766										})
4767									]
4768								})
4769							]
4770						}),
4771						desc
4772						]
4773					}
4774				);
4775				propsItemNode.setAttribute('data-property-id-row', zipProperty.ID);
4776
4777				node.appendChild(propsItemNode);
4778				
4779				node.appendChild(
4780					BX.create('input', {
4781						props: {
4782							id: 'ZIP_PROPERTY_CHANGED',
4783							name: 'ZIP_PROPERTY_CHANGED',
4784							type: 'hidden',
4785							value: this.result.ZIP_PROPERTY_CHANGED || 'N'
4786						}
4787					})
4788				);
4789
4790				this.bindValidation(zipProperty.ID, propsItemNode);
4791			}
4792		},
4793
4794		getPersonTypeSortedArray: function(objPersonType)
4795		{
4796			var personTypes = [], k;
4797
4798			for (k in objPersonType)
4799			{
4800				if (objPersonType.hasOwnProperty(k))
4801				{
4802					personTypes.push(objPersonType[k]);
4803				}
4804			}
4805
4806			return personTypes.sort(function(a, b){return parseInt(a.SORT) - parseInt(b.SORT)});
4807		},
4808
4809		getPersonTypeControl: function(node)
4810		{
4811			if (!this.result.PERSON_TYPE)
4812				return;
4813
4814			this.result.PERSON_TYPE = this.getPersonTypeSortedArray(this.result.PERSON_TYPE);
4815
4816			var profilesLength = BX.util.object_keys(this.result.USER_PROFILES).length,
4817				personTypesCount = this.result.PERSON_TYPE.length,
4818				currentType, oldPersonTypeId, i, inputTypes, inputProfiles,
4819				input, options = [], label, delimiter = false;
4820
4821
4822
4823
4824			if (personTypesCount > 0)
4825			{
4826
4827				inputTypes = BX.create('DIV', {
4828					props: {className: 'row'}
4829				});
4830
4831				inputProfiles = BX.create('DIV', {
4832						props: {className: 'profiles col-12' + (profilesLength > 0 ? ' col-md-4' : ' d-none')},
4833					});
4834
4835				input = BX.create('DIV', {
4836					props: {
4837						className: 'wr-row row align-items-center'
4838					},
4839					children: [
4840						BX.create('DIV', {
4841							props: {className: 'col-12' + (profilesLength > 0 ? ' col-md-8':'') + (personTypesCount == 1 ? ' d-none':'')},
4842							children: [inputTypes]
4843						}),
4844						inputProfiles,
4845					]
4846				});
4847
4848				node.appendChild(input);
4849
4850				node = inputTypes;
4851
4852
4853				for (i in this.result.PERSON_TYPE)
4854				{
4855					if (this.result.PERSON_TYPE.hasOwnProperty(i))
4856					{
4857						currentType = this.result.PERSON_TYPE[i];
4858
4859						label = BX.create('LABEL', {
4860							props: {
4861								className: 'input-radio-css green-check'
4862							},
4863							children: [
4864								BX.create('INPUT', {
4865									attrs: {checked: currentType.CHECKED == 'Y'},
4866									props: {type: 'radio', name: 'PERSON_TYPE', value: currentType.ID}
4867								}),
4868								BX.create('SPAN'),
4869								BX.create('SPAN', {
4870									props: {className: 'text'},
4871									html: BX.util.htmlspecialchars(currentType.NAME)
4872								}),
4873								
4874							],
4875							events: {change: BX.proxy(this.sendRequest, this)},
4876
4877						});
4878
4879						node.appendChild(BX.create('DIV', {props: {className: 'col-auto'}, children: [label]}));
4880
4881						if (currentType.CHECKED == 'Y')
4882							oldPersonTypeId = currentType.ID;
4883					}
4884				}
4885
4886
4887
4888				if(personTypesCount>1)
4889					this.regionBlockNotEmpty = true;
4890
4891				if (oldPersonTypeId)
4892				{
4893					node.appendChild(
4894						BX.create('INPUT', {
4895							props: {
4896								type: 'hidden',
4897								name: 'PERSON_TYPE_OLD',
4898								value: oldPersonTypeId
4899
4900							}
4901						})
4902					);
4903				}
4904
4905				this.getProfilesControl(inputProfiles);
4906			}
4907
4908			
4909		},
4910
4911		getProfilesControl: function(node)
4912		{
4913			var profilesLength = BX.util.object_keys(this.result.USER_PROFILES).length,
4914				i, options = [],
4915				profileChangeInput, input;
4916
4917
4918			if (profilesLength)
4919			{
4920				if (
4921					this.params.ALLOW_USER_PROFILES === 'Y'
4922					&& (profilesLength > 1 || this.params.ALLOW_NEW_PROFILE === 'Y')
4923				)
4924				{
4925					this.regionBlockNotEmpty = true;
4926
4927					for (i in this.result.USER_PROFILES)
4928					{
4929						if (this.result.USER_PROFILES.hasOwnProperty(i))
4930						{
4931							options.unshift(
4932								BX.create('OPTION', {
4933									props: {
4934										value: this.result.USER_PROFILES[i].ID,
4935										selected: this.result.USER_PROFILES[i].CHECKED === 'Y'
4936									},
4937									html: this.result.USER_PROFILES[i].NAME
4938								})
4939							);
4940						}
4941					}
4942
4943					if (this.params.ALLOW_NEW_PROFILE === 'Y')
4944					{
4945						options.unshift(BX.create('OPTION', {props: {value: 0}, text: BX.message('SOA_PROP_NEW_PROFILE')}));
4946					}
4947
4948					profileChangeInput = BX.create('INPUT', {
4949						props: {
4950							type: 'hidden',
4951							value: 'N',
4952							id: 'profile_change',
4953							name: 'profile_change'
4954						}
4955					});
4956					input = BX.create('SELECT', {
4957						props: {className: 'bx-form-control simple-select', name: 'PROFILE_ID'},
4958						children: options,
4959						events:{
4960							change: BX.delegate(function(){
4961								BX('profile_change').value = 'Y';
4962								this.sendRequest();
4963							}, this)
4964						}
4965					});
4966
4967					node.appendChild(
4968						BX.create('DIV', {
4969							props: {className: 'bx-form-group bx-soa-location-input-container'},
4970							children: [profileChangeInput, input]
4971						})
4972					);
4973				}
4974				else
4975				{
4976					for (i in this.result.USER_PROFILES)
4977					{
4978						if (
4979							this.result.USER_PROFILES.hasOwnProperty(i)
4980							&& this.result.USER_PROFILES[i].CHECKED === 'Y'
4981						)
4982						{
4983							node.appendChild(
4984								BX.create('INPUT', {
4985									props: {
4986										name: 'PROFILE_ID',
4987										type: 'hidden',
4988										value: this.result.USER_PROFILES[i].ID}
4989								})
4990							);
4991						}
4992					}
4993				}
4994			}
4995		},
4996
4997		editPaySystemBlock: function(active)
4998		{
4999			if (!this.paySystemBlockNode || !this.paySystemHiddenBlockNode || !this.result.PAY_SYSTEM)
5000				return;
5001
5002			if (active)
5003				this.editActivePaySystemBlock(true);
5004			else
5005				this.editFadePaySystemBlock();
5006
5007			/*this.initialized.paySystem = true;*/
5008		},
5009
5010		editActivePaySystemBlock: function(activeNodeMode)
5011		{
5012			var node = activeNodeMode ? this.paySystemBlockNode : this.paySystemHiddenBlockNode,
5013				paySystemContent, paySystemNode;
5014
5015			if (this.initialized.paySystem)
5016			{
5017				BX.remove(BX.lastChild(node));
5018				node.appendChild(BX.firstChild(this.paySystemHiddenBlockNode));
5019			}
5020			else
5021			{
5022				paySystemContent = node.querySelector('.bx-soa-section-content-node');
5023				if (!paySystemContent)
5024				{
5025					paySystemContent = this.getNewContainer();
5026					node.appendChild(paySystemContent);
5027				}
5028				else
5029					BX.cleanNode(paySystemContent);
5030
5031				this.getErrorContainer(paySystemContent);
5032				paySystemNode = BX.create('DIV', {props: {className: 'bx-soa-pp'}});
5033				this.editPaySystemItems(paySystemNode);
5034				paySystemContent.appendChild(paySystemNode);
5035				this.editPaySystemInfo(paySystemNode);
5036
5037				/*if (this.params.SHOW_COUPONS_PAY_SYSTEM == 'Y')
5038					this.editCoupons(paySystemContent);*/
5039
5040				this.getBlockFooter(paySystemContent);
5041			}
5042		},
5043
5044		editFadePaySystemBlock: function()
5045		{
5046			var paySystemContent = this.paySystemBlockNode.querySelector('.bx-soa-section-content'), newContent;
5047
5048			if (this.initialized.paySystem)
5049			{
5050				this.paySystemHiddenBlockNode.appendChild(paySystemContent);
5051			}
5052			else
5053			{
5054				this.editActivePaySystemBlock(false);
5055				BX.remove(BX.lastChild(this.paySystemBlockNode));
5056			}
5057
5058			newContent = this.getNewContainer(true);
5059			this.paySystemBlockNode.appendChild(newContent);
5060
5061			this.editFadePaySystemContent(newContent);
5062
5063			/*if (this.params.SHOW_COUPONS_PAY_SYSTEM == 'Y')
5064				this.editCouponsFade(newContent);*/
5065		},
5066
5067		editPaySystemItems: function(paySystemNode)
5068		{
5069			if (!this.result.PAY_SYSTEM || this.result.PAY_SYSTEM.length <= 0)
5070				return;
5071
5072			var paySystemItemsContainer = BX.create('DIV', {props: {className: 'bx-soa-pp-item-container row-pay-list row'}}),
5073				paySystemItemNode, i;
5074
5075			for (i = 0; i < this.paySystemPagination.currentPage.length; i++)
5076			{
5077				paySystemItemNode = this.createPaySystemItem(this.paySystemPagination.currentPage[i]);
5078				paySystemItemsContainer.appendChild(paySystemItemNode);
5079			}
5080
5081			if (this.paySystemPagination.show)
5082				this.showPagination('paySystem', paySystemItemsContainer);
5083
5084			paySystemNode.appendChild(paySystemItemsContainer);
5085		},
5086
5087		createPaySystemItem: function(item)
5088		{
5089			var checked = item.CHECKED == 'Y',
5090				logotype, logoNode,
5091				paySystemId = parseInt(item.ID),
5092				title, label, itemNode;
5093
5094
5095			logoNode = BX.create('DIV', {props: {className: 'bx-soa-pp-company-image'}});
5096			logotype = this.getImageSources(item, 'PSA_LOGOTIP');
5097			var logotypeSrc = "";
5098
5099			if (logotype && logotype.src_2x)
5100			{
5101				/*logoNode.setAttribute('style',
5102					'background-image: url(' + logotype.src_1x + ');' +
5103					'background-image: -webkit-image-set(url(' + logotype.src_1x + ') 1x, url(' + logotype.src_2x + ') 2x)'
5104				);*/
5105				logotypeSrc = logotype.src_1x;
5106
5107			}
5108			else
5109			{
5110				/*logotype = logotype && logotype.src_1x || this.defaultPaySystemLogo;
5111				logoNode.setAttribute('style', 'background-image: url(' + logotype + ');');*/
5112				logotypeSrc = this.defaultPaySystemLogo;
5113			}
5114
5115
5116			var attrs = {};
5117
5118			if(item.DESCRIPTION)
5119			{
5120				attrs = {
5121					'data-toggle': 'tooltip',
5122					'data-placement': 'right',
5123					'data-original-title': item.DESCRIPTION
5124				};
5125			}
5126
5127			label = BX.create('LABEL', {
5128				props: {className: 'bx-soa-pp-company-graf-container pay-item'},
5129				children: [
5130					BX.create('INPUT', {
5131						props: {
5132							id: 'ID_PAY_SYSTEM_ID_' + paySystemId,
5133							name: 'PAY_SYSTEM_ID',
5134							type: 'checkbox',
5135							className: 'bx-soa-pp-company-checkbox',
5136							value: paySystemId,
5137							checked: checked
5138						}
5139					}),
5140					BX.create('DIV', {
5141						props: {
5142							className: 'item',
5143						},
5144						attrs: attrs,
5145						children: [
5146							BX.create('SPAN', {
5147								props: {
5148									className: 'check',
5149								}
5150							}),
5151							BX.create('DIV', {
5152								props: {
5153									className: 'wr-img row align-items-center',
5154								},
5155								children: [
5156									BX.create('DIV', {
5157										props: {
5158											className: 'col-12',
5159										},
5160										children: [
5161											BX.create('IMG', {
5162												props: {
5163													className: 'd-block mx-auto img-fluid',
5164													src: logotypeSrc
5165												},
5166											}),
5167										],
5168									}),
5169								],
5170							}),
5171							BX.create('DIV', {
5172								props: {
5173									className: 'text',
5174								},
5175								attrs: {
5176									"title": item.NAME
5177								},
5178								text: item.NAME
5179							}),
5180						]
5181					}),
5182				],
5183				events: {
5184					click: BX.proxy(this.selectPaySystem, this)
5185				}
5186			});
5187
5188			itemNode = BX.create('DIV', {
5189				props: {className: 'bx-soa-pp-company wr-pay-item col-md-3 col-6'},
5190				children: [label],
5191				
5192			});
5193
5194			if (checked)
5195				BX.addClass(itemNode, 'bx-selected');
5196
5197			return itemNode;
5198		},
5199
5200		editPaySystemInfo: function(paySystemNode)
5201		{
5202			if (!this.result.PAY_SYSTEM || (this.result.PAY_SYSTEM.length == 0 && this.result.PAY_FROM_ACCOUNT != 'Y'))
5203				return;
5204
5205
5206			var paySystemInfoContainer = BX.create('DIV', {
5207					props: {
5208						className: 'bx-soa-pp-desc-container'
5209					}
5210				}), innerPs;
5211
5212			BX.cleanNode(paySystemInfoContainer);
5213
5214			if (this.result.PAY_FROM_ACCOUNT == 'Y')
5215				innerPs = this.getInnerPaySystem(paySystemInfoContainer);
5216
5217			paySystemInfoContainer.appendChild(
5218				BX.create('DIV', {
5219					props: {className: 'bx-soa-pp-company'},
5220					children: [innerPs]
5221				})
5222			);
5223			paySystemNode.appendChild(paySystemInfoContainer);
5224		},
5225
5226		getInnerPaySystem: function()
5227		{
5228			if (!this.result.CURRENT_BUDGET_FORMATED || !this.result.PAY_CURRENT_ACCOUNT || !this.result.INNER_PAY_SYSTEM)
5229				return;
5230
5231			var accountOnly = this.params.ONLY_FULL_PAY_FROM_ACCOUNT && (this.params.ONLY_FULL_PAY_FROM_ACCOUNT == 'Y'),
5232				isSelected = this.result.PAY_CURRENT_ACCOUNT && (this.result.PAY_CURRENT_ACCOUNT == 'Y'),
5233				paySystem = this.result.INNER_PAY_SYSTEM,
5234				logotype, logoNode,subTitle, label, title, hiddenInput, htmlString, innerPsDesc;
5235
5236
5237			label = BX.create('LABEL', {
5238				props: {
5239					className: 'input-checkbox-css'
5240				},
5241				children: [
5242					BX.create('INPUT', {
5243						props: {
5244								type: 'checkbox',
5245								className: 'bx-soa-pp-company-checkbox',
5246								name: 'PAY_CURRENT_ACCOUNT',
5247								value: 'Y',
5248								checked: isSelected
5249							}
5250					}),
5251					BX.create('SPAN'),
5252					BX.create('SPAN', {
5253						props: {className: 'text'},
5254						html: BX.util.htmlspecialchars(BX.message('INNER_PAY_SYSTEM_TITLE'))+" ("+BX.message('INNER_PS_BALANCE_BEFORE')+this.result.CURRENT_BUDGET_FORMATED+")"
5255					}),
5256					
5257				],
5258				events: {change: BX.proxy(this.selectPaySystem, this)},
5259
5260			});
5261
5262
5263			hiddenInput = BX.create('INPUT', {
5264				props: {
5265					type: 'hidden',
5266					name: 'PAY_CURRENT_ACCOUNT',
5267					value: 'N'
5268				}
5269			});
5270
5271			/*htmlString = this.params.MESS_INNER_PS_BALANCE + ' <b class="wsnw">' + this.result.CURRENT_BUDGET_FORMATED
5272				+ '</b><br>
5272' + (accountOnly ? BX.message('SOA_PAY_ACCOUNT3') : '');
5273			innerPsDesc = BX.create('DIV', {props: {className: 'bx-soa-pp-company-desc'}, html: htmlString});*/
5274
5275			return BX.create('DIV', {
5276				props: {className: 'bx-soa-pp-inner-ps' + (isSelected ? ' bx-selected' : '')},
5277				children: [hiddenInput, label]
5278			});
5279		},
5280
5281		editFadePaySystemContent: function(node)
5282		{
5283			var selectedPaySystem = this.getSelectedPaySystem(),
5284				errorNode = this.paySystemHiddenBlockNode.querySelector('div.alert.alert-danger'),
5285				warningNode = this.paySystemHiddenBlockNode.querySelector('div.alert.alert-warning.alert-show'),
5286				addedHtml = '', logotype, imgSrc;
5287
5288			if (errorNode)
5289				node.appendChild(errorNode.cloneNode(true));
5290			else
5291				this.getErrorContainer(node);
5292
5293			if (warningNode && warningNode.innerHTML)
5294				node.appendChild(warningNode.cloneNode(true));
5295
5296			if (this.isSelectedInnerPayment())
5297			{
5298				logotype = this.getImageSources(this.result.INNER_PAY_SYSTEM, 'LOGOTIP');
5299				imgSrc = logotype && logotype.src_1x || this.defaultPaySystemLogo;
5300
5301				addedHtml += '<div class="bx-soa-pp-company-selected">';
5302				addedHtml += '<img src="' + imgSrc + '" style="height:18px;" alt="">';
5303				addedHtml += '<strong>' + this.result.INNER_PAY_SYSTEM.NAME + '</strong><br>';
5304				addedHtml += '</div>';
5305			}
5306
5307			if (selectedPaySystem && selectedPaySystem.NAME)
5308			{
5309				logotype = this.getImageSources(selectedPaySystem, 'PSA_LOGOTIP');
5310				imgSrc = logotype && logotype.src_1x || this.defaultPaySystemLogo;
5311
5312				addedHtml += '<div class="bx-soa-pp-company-selected">';
5313				addedHtml += '<img src="' + imgSrc + '" style="height:18px;" alt="">';
5314				addedHtml += '<strong>' + BX.util.htmlspecialchars(selectedPaySystem.NAME) + '</strong>';
5315				addedHtml += '</div>';
5316			}
5317
5318			if (!addedHtml.length)
5319				addedHtml = '<strong>' + BX.message('SOA_PS_SELECT_ERROR') + '</strong>';
5320
5321			node.innerHTML += addedHtml;
5322
5323			node.appendChild(BX.create('DIV', {style: {clear: 'both'}}));
5324			BX.bind(node.querySelector('.alert.alert-danger'), 'click', BX.proxy(this.showByClick, this));
5325			BX.bind(node.querySelector('.alert.alert-warning'), 'click', BX.proxy(this.showByClick, this));
5326		},
5327
5328		getSelectedPaySystem: function()
5329		{
5330			var paySystemCheckbox = this.paySystemBlockNode.querySelector('input[type=checkbox][name=PAY_SYSTEM_ID]:checked'),
5331				currentPaySystem = null, paySystemId, i;
5332
5333			if (!paySystemCheckbox)
5334				paySystemCheckbox = this.paySystemHiddenBlockNode.querySelector('input[type=checkbox][name=PAY_SYSTEM_ID]:checked');
5335
5336			if (!paySystemCheckbox)
5337				paySystemCheckbox = this.paySystemHiddenBlockNode.querySelector('input[type=hidden][name=PAY_SYSTEM_ID]');
5338
5339			if (paySystemCheckbox)
5340			{
5341				paySystemId = paySystemCheckbox.value;
5342
5343				for (i = 0; i < this.result.PAY_SYSTEM.length; i++)
5344				{
5345					if (this.result.PAY_SYSTEM[i].ID == paySystemId)
5346					{
5347						currentPaySystem = this.result.PAY_SYSTEM[i];
5348						break;
5349					}
5350				}
5351			}
5352
5353			return currentPaySystem;
5354		},
5355
5356		isSelectedInnerPayment: function()
5357		{
5358			var innerPaySystemCheckbox = this.paySystemBlockNode.querySelector('input[type=checkbox][name=PAY_CURRENT_ACCOUNT]');
5359
5360			if (!innerPaySystemCheckbox)
5361				innerPaySystemCheckbox = this.paySystemHiddenBlockNode.querySelector('input[type=checkbox][name=PAY_CURRENT_ACCOUNT]');
5362
5363			return innerPaySystemCheckbox && innerPaySystemCheckbox.checked;
5364		},
5365
5366		selectPaySystem: function(event)
5367		{
5368			if (!this.orderBlockNode || !event)
5369				return;
5370
5371			var target = event.target || event.srcElement,
5372				innerPaySystemSection = this.paySystemBlockNode.querySelector('div.bx-soa-pp-inner-ps'),
5373				innerPaySystemCheckbox = this.paySystemBlockNode.querySelector('input[type=checkbox][name=PAY_CURRENT_ACCOUNT]'),
5374				fullPayFromInnerPaySystem = this.result.TOTAL && parseFloat(this.result.TOTAL.ORDER_TOTAL_LEFT_TO_PAY) === 0;
5375
5376			var innerPsAction = BX.hasClass(target, 'bx-soa-pp-inner-ps') ? target : BX.findParent(target, {className: 'bx-soa-pp-inner-ps'}),
5377				actionSection = BX.hasClass(target, 'bx-soa-pp-company') ? target : BX.findParent(target, {className: 'bx-soa-pp-company'}),
5378				actionInput, selectedSection;
5379
5380				
5381
5382			if (innerPsAction)
5383			{
5384				if (target.nodeName == 'INPUT')
5385					innerPaySystemCheckbox.checked = !innerPaySystemCheckbox.checked;
5386
5387				if (innerPaySystemCheckbox.checked)
5388				{
5389					BX.removeClass(innerPaySystemSection, 'bx-selected');
5390					innerPaySystemCheckbox.checked = false;
5391				}
5392				else
5393				{
5394					BX.addClass(innerPaySystemSection, 'bx-selected');
5395					innerPaySystemCheckbox.checked = true;
5396				}
5397			}
5398			else if (actionSection)
5399			{
5400				if (BX.hasClass(actionSection, 'bx-selected'))
5401					return BX.PreventDefault(event);
5402
5403				if (innerPaySystemCheckbox && innerPaySystemCheckbox.checked && fullPayFromInnerPaySystem)
5404				{
5405					BX.addClass(actionSection, 'bx-selected');
5406					actionInput = actionSection.querySelector('input[type=checkbox]');
5407					actionInput.checked = true;
5408					BX.removeClass(innerPaySystemSection, 'bx-selected');
5409					innerPaySystemCheckbox.checked = false;
5410				}
5411				else
5412				{
5413					selectedSection = this.paySystemBlockNode.querySelector('.bx-soa-pp-company.bx-selected');
5414					BX.addClass(actionSection, 'bx-selected');
5415					actionInput = actionSection.querySelector('input[type=checkbox]');
5416					actionInput.checked = true;
5417
5418					if (selectedSection)
5419					{
5420						BX.removeClass(selectedSection, 'bx-selected');
5421						selectedSection.querySelector('input[type=checkbox]').checked = false;
5422					}
5423				}
5424			}
5425
5426
5427			this.sendRequest();
5428		},
5429
5430		editDeliveryBlock: function(active)
5431		{
5432			if (!this.deliveryBlockNode || !this.deliveryHiddenBlockNode || !this.result.DELIVERY)
5433				return;
5434
5435			if (active)
5436				this.editActiveDeliveryBlock(true);
5437			else
5438				this.editFadeDeliveryBlock();
5439
5440			this.checkPickUpShow();
5441
5442			/*this.initialized.delivery = true;*/
5443		},
5444
5445		editActiveDeliveryBlock: function(activeNodeMode)
5446		{
5447			var node = activeNodeMode ? this.deliveryBlockNode : this.deliveryHiddenBlockNode,
5448				deliveryContent, deliveryNode;
5449
5450			if (this.initialized.delivery)
5451			{
5452				BX.remove(BX.lastChild(node));
5453				node.appendChild(BX.firstChild(this.deliveryHiddenBlockNode));
5454			}
5455			else
5456			{
5457				deliveryContent = node.querySelector('.bx-soa-section-content-node');
5458				if (!deliveryContent)
5459				{
5460					deliveryContent = this.getNewContainer();
5461					node.appendChild(deliveryContent);
5462				}
5463				else
5464					BX.cleanNode(deliveryContent);
5465
5466				this.getErrorContainer(deliveryContent);
5467
5468				deliveryNode = BX.create('DIV', {props: {className: 'bx-soa-pp row'}});
5469				this.editDeliveryItems(deliveryNode);
5470				deliveryContent.appendChild(deliveryNode);
5471				this.editDeliveryInfo(deliveryNode);
5472
5473				/*if (this.params.SHOW_COUPONS_DELIVERY == 'Y')
5474					this.editCoupons(deliveryContent);*/
5475
5476				this.getBlockFooter(deliveryContent);
5477			}
5478		},
5479
5480		editDeliveryItems: function(deliveryNode)
5481		{
5482			if (!this.result.DELIVERY || this.result.DELIVERY.length <= 0)
5483				return;
5484
5485			var deliveryItemsContainer = BX.create('DIV', {props: {className: 'col-md-6 col-12 bx-soa-pp-item-container order-delivery-list'}}),
5486				deliveryItemNode, k;
5487
5488			for (k = 0; k < this.deliveryPagination.currentPage.length; k++)
5489			{
5490				deliveryItemNode = this.createDeliveryItem(this.deliveryPagination.currentPage[k]);
5491				deliveryItemsContainer.appendChild(deliveryItemNode);
5492			}
5493
5494			if (this.deliveryPagination.show)
5495				this.showPagination('delivery', deliveryItemsContainer);
5496
5497			deliveryNode.appendChild(deliveryItemsContainer);
5498		},
5499
5500		editDeliveryInfo: function(deliveryNode)
5501		{
5502			if (!this.result.DELIVERY)
5503				return;
5504
5505			var deliveryInfoContainer = BX.create('DIV', {props: {className: 'col-md-6 col-12 bx-soa-pp-desc-container'}}),
5506				currentDelivery, logotype, name, logoNode,
5507				subTitle, label, title, price, period,
5508				clear, infoList, extraServices, extraServicesNode;
5509
5510			BX.cleanNode(deliveryInfoContainer);
5511			currentDelivery = this.getSelectedDelivery();
5512
5513
5514			name = this.params.SHOW_DELIVERY_PARENT_NAMES != 'N' ? currentDelivery.NAME : currentDelivery.OWN_NAME;
5515
5516			/*if (this.params.SHOW_DELIVERY_INFO_NAME == 'Y')*/
5517			title = BX.create('DIV', {props: {className: 'title bold'}, text: name});
5518
5519
5520
5521
5522			
5523
5524			if (currentDelivery.PRICE >= 0)
5525			{
5526				price = BX.create('DIV', {
5527					props: {className: 'highlight-gray'},
5528					html: this.params.MESS_PRICE + ': ' + currentDelivery.PRICE_FORMATED/*this.getDeliveryPriceNodes(currentDelivery)*/
5529				});
5530
5531
5532				/*var priceDelive = BX.create('LI', {
5533					children: [
5534						BX.create('DIV', {
5535							props: {className: 'bx-soa-pp-list-termin'},
5536							html: this.params.MESS_PRICE + ':'
5537						}),
5538						BX.create('DIV', {
5539							props: {className: 'bx-soa-pp-list-description'},
5540							children: this.getDeliveryPriceNodes(currentDelivery)
5541						})
5542					]
5543				});*/
5544
5545
5546				if (currentDelivery.PERIOD_TEXT && currentDelivery.PERIOD_TEXT.length)
5547					infoList = BX.create('DIV', {props: {className: 'bx-soa-pp-list-description'}, html: '<span class="bold">
5547'+this.params.MESS_PERIOD + ': </span>'+currentDelivery.PERIOD_TEXT});
5548				
5549
5550
5551			}
5552
5553			subTitle = BX.create('DIV', {
5554				props: {className: 'bx-soa-pp-company-block'},
5555				children: [
5556					BX.create('DIV', {props: {className: 'delivery-text'}, html: currentDelivery.DESCRIPTION}),
5557					currentDelivery.CALCULATE_DESCRIPTION
5558						? BX.create('DIV', {props: {className: 'delivery-text'}, html: currentDelivery.CALCULATE_DESCRIPTION})
5559						: null,
5560					
5561					infoList
5562				]
5563			});
5564
5565			
5566
5567			var box1 = BX.create('DIV', {
5568					props: {className: 'wr-box'},
5569					children: [
5570						BX.create('DIV', {
5571							props: {className: 'wr-section'},
5572							children: [
5573								title,
5574								price,
5575								
5576							]
5577						}),
5578						BX.create('DIV', {
5579							props: {className: 'wr-section'},
5580							children: [
5581								subTitle
5582							]
5583							}
5584						),
5585						BX.create('DIV', {
5586							props: {className: 'wr-section'},
5587							children: [
5588								BX.create('DIV', {
5589									props: {className: 'bx-soa-pp-company-desc'},
5590								}),
5591
5592							]
5593							}
5594						),
5595					]
5596				});
5597
5598
5599			var box2 = null;
5600
5601			extraServices = this.getDeliveryExtraServices(currentDelivery);
5602
5603			if (extraServices.length)
5604			{
5605				box2 = BX.create('DIV', {
5606					props: {className: 'wr-box'},
5607					children: extraServices
5608				});
5609			}
5610
5611			
5612
5613			
5614
5615			deliveryInfoContainer.appendChild(
5616				BX.create('DIV', {
5617					props: {className: 'bx-soa-pp-company order-delivery-item-info delivery-id-'+currentDelivery.ID+''},
5618					children: [box1, box2]
5619				})
5620			);
5621
5622			deliveryNode.appendChild(deliveryInfoContainer);
5623
5624			if (this.params.DELIVERY_NO_AJAX != 'Y')
5625				this.deliveryCachedInfo[currentDelivery.ID] = currentDelivery;
5626
5627			/*
5628
5629			if (currentDelivery.PRICE >= 0)
5630			{
5631				price = BX.create('LI', {
5632					children: [
5633						BX.create('DIV', {
5634							props: {className: 'bx-soa-pp-list-termin'},
5635							html: this.params.MESS_PRICE + ':'
5636						}),
5637						BX.create('DIV', {
5638							props: {className: 'bx-soa-pp-list-description'},
5639							children: this.getDeliveryPriceNodes(currentDelivery)
5640						})
5641					]
5642				});
5643			}
5644
5645			if (currentDelivery.PERIOD_TEXT && currentDelivery.PERIOD_TEXT.length)
5646			{
5647				period = BX.create('LI', {
5648					children: [
5649						BX.create('DIV', {props: {className: 'bx-soa-pp-list-termin'}, html: this.params.MESS_PERIOD + ':'}),
5650						BX.create('DIV', {props: {className: 'bx-soa-pp-list-description'}, html: currentDelivery.PERIOD_TEXT})
5651					]
5652				});
5653			}
5654
5655			clear = BX.create('DIV', {style: {clear: 'both'}});
5656			infoList = BX.create('UL', {props: {className: 'bx-soa-pp-list'}, children: [price, period]});
5657			
5658
5659			*/
5660		},
5661
5662		getDeliveryPriceNodes: function(delivery)
5663		{
5664			var priceNodesArray;
5665
5666			if (typeof delivery.DELIVERY_DISCOUNT_PRICE !== 'undefined'
5667				&& parseFloat(delivery.DELIVERY_DISCOUNT_PRICE) != parseFloat(delivery.PRICE))
5668			{
5669				if (parseFloat(delivery.DELIVERY_DISCOUNT_PRICE) > parseFloat(delivery.PRICE))
5670					priceNodesArray = [delivery.DELIVERY_DISCOUNT_PRICE_FORMATED];
5671				else
5672					priceNodesArray = [
5673						delivery.DELIVERY_DISCOUNT_PRICE_FORMATED,
5674						BX.create('BR'),
5675						BX.create('SPAN', {props: {className: 'bx-price-old'}, html: delivery.PRICE_FORMATED})
5676					];
5677			}
5678			else
5679			{
5680				priceNodesArray = [delivery.PRICE_FORMATED];
5681			}
5682
5683			return priceNodesArray;
5684		},
5685
5686		getDeliveryExtraServices: function(delivery)
5687		{
5688			var extraServices = [],
5689				i, currentService, serviceNode, serviceName, comment, input, type = "text";
5690
5691
5692
5693			for (i in delivery.EXTRA_SERVICES)
5694			{
5695				if (!delivery.EXTRA_SERVICES.hasOwnProperty(i))
5696					continue;
5697
5698				currentService = delivery.EXTRA_SERVICES[i];
5699
5700				if (!currentService.canUserEditValue)
5701					continue;
5702
5703				type = null;
5704
5705				if (currentService.editControl.indexOf('this.checked') == -1)
5706				{
5707
5708					
5709					serviceNode = BX.create('DIV', {
5710						html: currentService.editControl
5711					});
5712
5713
5714					/*BX.prepend(serviceName, serviceNode);*/
5715
5716					/*BX.prepend(serviceName, serviceNode);*/
5717
5718
5719					input = serviceNode.querySelector('input[type=text]');
5720
5721					if(input)
5722						type = "text";
5723
5724					else
5725					{
5726						input = serviceNode.querySelector('select');
5727
5728						if (input)
5729							type = "select";
5730						else
5731							type = null;
5732					}
5733
5734					if (input)
5735					{
5736						serviceName = BX.create('DIV', {
5737							props: {
5738								className: 'small-title'
5739							},
5740							html: '<span class="bold">'+BX.util.htmlspecialchars(currentService.name)+'</span>'
5741							+ (currentService.price ? ' <span class="delivery-price">(' + currentService.priceFormatted + ')</span>' : '')
5742						});
5743
5744						if(currentService.description && currentService.description.length)
5745						{
5746							comment = BX.create('DIV', {
5747								props: {
5748									className: 'delivery-comment'
5749								},
5750								html: BX.util.htmlspecialchars(currentService.description)
5751							});
5752						}
5753
5754						if(type == "text")
5755						{
5756							BX.addClass(input, "bord-1 b-ra");
5757							serviceNode = BX.create('DIV', {
5758								props: {className: "bx-form-group input-simple no-mg inp-small no-desc"},
5759								children:[input]
5760							});
5761
5762						}
5763						else if(type == "select")
5764						{
5765							BX.addClass(input, 'simple-select bx-form-control');
5766							serviceNode = input;
5767							
5768
5769						}
5770
5771
5772						serviceNode = BX.create('DIV', {
5773							props: {className: 'wr-section'},
5774							children:[serviceName, serviceNode, comment]
5775						});
5776						
5777					}
5778
5779
5780					
5781				}
5782				else
5783				{
5784					serviceNode = 
5785						BX.create('DIV', {
5786							props: {
5787									className: 'wr-section'
5788								},
5789							children:
5790							[
5791								BX.create('LABEL', {
5792									props: {
5793										className: 'input-checkbox-css'
5794									},
5795									html: currentService.editControl + "<span></span>" 
5796									+ "<span class=\"text\">"
5797									+ "<span class=\"bold\">"+BX.util.htmlspecialchars(currentService.name)+"</span>"
5798									+ (currentService.price ? ' <span class=\"delivery-price\">
5798(' + currentService.priceFormatted + ')</span>' : '')
5799									+ "</span>"
5800									+ (currentService.description && currentService.description.length
5801										? '<div class="delivery-comment">' + BX.util.htmlspecialchars(currentService.description) + '</div>'
5802										: '')
5803								}
5804							)]
5805						});
5806				}
5807
5808				extraServices.push(serviceNode);
5809			}
5810
5811			/*brake && extraServices.unshift(BX.create('BR'));*/
5812
5813
5814
5815			return extraServices;
5816		},
5817
5818		editFadeDeliveryBlock: function()
5819		{
5820			var deliveryContent = this.deliveryBlockNode.querySelector('.bx-soa-section-content'), newContent;
5821
5822			if (this.initialized.delivery)
5823			{
5824				this.deliveryHiddenBlockNode.appendChild(deliveryContent);
5825			}
5826			else
5827			{
5828				this.editActiveDeliveryBlock(false);
5829				BX.remove(BX.lastChild(this.deliveryBlockNode));
5830			}
5831
5832			newContent = this.getNewContainer(true);
5833			this.deliveryBlockNode.appendChild(newContent);
5834
5835			this.editFadeDeliveryContent(newContent);
5836
5837			/*if (this.params.SHOW_COUPONS_DELIVERY == 'Y')
5838				this.editCouponsFade(newContent);*/
5839		},
5840
5841		createDeliveryItem: function(item)
5842		{
5843			var checked = item.CHECKED == 'Y',
5844				deliveryId = parseInt(item.ID),
5845				deliveryCached = this.deliveryCachedInfo[deliveryId],
5846				logotype, label, title, itemNode;
5847
5848
5849			logotype = this.getImageSources(item, 'LOGOTIP');
5850
5851			var logotypeSrc = "";
5852
5853			if (logotype && logotype.src_2x)
5854			{
5855				/*logoNode.setAttribute('style',
5856					'background-image: url(' + logotype.src_1x + ');' +
5857					'background-image: -webkit-image-set(url(' + logotype.src_1x + ') 1x, url(' + logotype.src_2x + ') 2x)'
5858				);*/
5859				logotypeSrc = logotype.src_1x;
5860			}
5861			else
5862			{
5863				/*logotype = logotype && logotype.src_1x || this.defaultDeliveryLogo;
5864				logoNode.setAttribute('style', 'background-image: url(' + logotype + ');');*/
5865				logotypeSrc = this.defaultPaySystemLogo;
5866			}
5867
5868			var img = BX.create('DIV', {
5869					props: {
5870						className: 'img'
5871					},
5872				});
5873			img.setAttribute('style', 'background-image: url(' + logotypeSrc + ');');
5874
5875
5876			itemNode = BX.create('LABEL', {
5877				props: {className: 'bx-soa-pp-company order-delivery-item'},
5878				children: [
5879					BX.create('INPUT', {
5880						props: {
5881							id: 'ID_DELIVERY_ID_' + deliveryId,
5882							name: 'DELIVERY_ID',
5883							type: 'checkbox',
5884							className: 'bx-soa-pp-company-checkbox',
5885							value: deliveryId,
5886							checked: checked
5887						}
5888					}),
5889					BX.create('DIV', {
5890						props: {
5891							className: 'item row no-gutters align-items-center',
5892						},
5893						children:[
5894							BX.create('SPAN', {
5895								props: {
5896									className: 'check',
5897								},
5898							}),
5899							BX.create('DIV', {
5900								props: {
5901									className: 'col-auto wr-img',
5902								},
5903								children:[img]
5904							}),
5905							BX.create('DIV', {
5906								props: {
5907									className: 'col text'
5908								},
5909								text: this.params.SHOW_DELIVERY_PARENT_NAMES != 'N' ? item.NAME : item.OWN_NAME
5910							}),
5911						]
5912					})
5913
5914
5915
5916				],
5917				events: {click: BX.proxy(this.selectDelivery, this)}
5918			});
5919			checked && BX.addClass(itemNode, 'bx-selected');
5920
5921			if (checked && this.result.LAST_ORDER_DATA.PICK_UP)
5922				this.lastSelectedDelivery = deliveryId;
5923
5924
5925
5926
5927			/*var logoNode = BX.create('DIV', {props: {className: 'bx-soa-pp-company-image'}});*/
5928
5929			
5930
5931			/*labelNodes.push(logoNode);*/
5932
5933			/*if (item.PRICE >= 0 || typeof item.DELIVERY_DISCOUNT_PRICE !== 'undefined')
5934			{
5935				labelNodes.push(
5936					BX.create('DIV', {
5937						props: {className: 'bx-soa-pp-delivery-cost'},
5938						html: typeof item.DELIVERY_DISCOUNT_PRICE !== 'undefined'
5939							? item.DELIVERY_DISCOUNT_PRICE_FORMATED
5940							: item.PRICE_FORMATED})
5941				);
5942			}
5943			else if (deliveryCached && (deliveryCached.PRICE >= 0 || typeof deliveryCached.DELIVERY_DISCOUNT_PRICE !== 'undefined'))
5944			{
5945				labelNodes.push(
5946					BX.create('DIV', {
5947						props: {className: 'bx-soa-pp-delivery-cost'},
5948						html: typeof deliveryCached.DELIVERY_DISCOUNT_PRICE !== 'undefined'
5949							? deliveryCached.DELIVERY_DISCOUNT_PRICE_FORMATED
5950							: deliveryCached.PRICE_FORMATED})
5951				);
5952			}
5953
5954			label = BX.create('DIV', {
5955				props: {
5956					className: 'bx-soa-pp-company-graf-container'
5957					+ (item.CALCULATE_ERRORS || deliveryCached && deliveryCached.CALCULATE_ERRORS ? ' bx-bd-waring' : '')},
5958				children: labelNodes
5959			});
5960
5961			if (this.params.SHOW_DELIVERY_LIST_NAMES == 'Y')
5962			{
5963				title = BX.create('DIV', {
5964					props: {className: 'bx-soa-pp-company-smalltitle'},
5965					text: this.params.SHOW_DELIVERY_PARENT_NAMES != 'N' ? item.NAME : item.OWN_NAME
5966				});
5967			}*/
5968
5969			
5970
5971			return itemNode;
5972		},
5973
5974		editFadeDeliveryContent: function(node)
5975		{
5976			var selectedDelivery = this.getSelectedDelivery(),
5977				name = this.params.SHOW_DELIVERY_PARENT_NAMES != 'N' ? selectedDelivery.NAME : selectedDelivery.OWN_NAME,
5978				errorNode = this.deliveryHiddenBlockNode.querySelector('div.alert.alert-danger'),
5979				warningNode = this.deliveryHiddenBlockNode.querySelector('div.alert.alert-warning.alert-show'),
5980				extraService, logotype, imgSrc, arNodes, i;
5981
5982			if (errorNode && errorNode.innerHTML)
5983				node.appendChild(errorNode.cloneNode(true));
5984			else
5985				this.getErrorContainer(node);
5986
5987			if (warningNode && warningNode.innerHTML)
5988				node.appendChild(warningNode.cloneNode(true));
5989
5990			if (selectedDelivery && selectedDelivery.NAME)
5991			{
5992				logotype = this.getImageSources(selectedDelivery, 'LOGOTIP');
5993				imgSrc = logotype && logotype.src_1x || this.defaultDeliveryLogo;
5994				arNodes = [
5995					BX.create('IMG', {props: {src: imgSrc, alt: ''}, style: {height: '18px'}}),
5996					BX.create('STRONG', {text: name})
5997				];
5998
5999				if (this.params.DELIVERY_FADE_EXTRA_SERVICES == 'Y' && BX.util.object_keys(selectedDelivery.EXTRA_SERVICES).length)
6000				{
6001					arNodes.push(BX.create('BR'));
6002
6003					for (i in selectedDelivery.EXTRA_SERVICES)
6004					{
6005						if (selectedDelivery.EXTRA_SERVICES.hasOwnProperty(i))
6006						{
6007							extraService = selectedDelivery.EXTRA_SERVICES[i];
6008							if (extraService.value && extraService.value != 'N' && extraService.canUserEditValue)
6009							{
6010								arNodes.push(BX.create('BR'));
6011								arNodes.push(BX.create('STRONG', {text: extraService.name + ': '}));
6012								arNodes.push(extraService.viewControl);
6013							}
6014						}
6015					}
6016				}
6017
6018				node.appendChild(
6019					BX.create('DIV', {
6020						props: {className: 'col-sm-9 bx-soa-pp-company-selected'},
6021						children: arNodes
6022					})
6023				);
6024				node.appendChild(
6025					BX.create('DIV', {
6026						props: {className: 'col-sm-3 bx-soa-pp-price'},
6027						children: this.getDeliveryPriceNodes(selectedDelivery)
6028					})
6029				);
6030			}
6031			else
6032				node.appendChild(BX.create('STRONG', {text: BX.message('SOA_DELIVERY_SELECT_ERROR')}));
6033
6034			node.appendChild(BX.create('DIV', {style: {clear: 'both'}}));
6035			BX.bind(node.querySelector('.alert.alert-danger'), 'click', BX.proxy(this.showByClick, this));
6036			BX.bind(node.querySelector('.alert.alert-warning'), 'click', BX.proxy(this.showByClick, this));
6037		},
6038
6039		selectDelivery: function(event)
6040		{
6041			if (!this.orderBlockNode)
6042				return;
6043
6044			var target = event.target || event.srcElement,
6045				actionSection =  BX.hasClass(target, 'bx-soa-pp-company') ? target : BX.findParent(target, {className: 'bx-soa-pp-company'}),
6046				selectedSection = this.deliveryBlockNode.querySelector('.bx-soa-pp-company.bx-selected'),
6047				actionInput, selectedInput;
6048
6049			if (BX.hasClass(actionSection, 'bx-selected'))
6050				return BX.PreventDefault(event);
6051
6052			if (actionSection)
6053			{
6054				actionInput = actionSection.querySelector('input[type=checkbox]');
6055				BX.addClass(actionSection, 'bx-selected');
6056				actionInput.checked = true;
6057			}
6058			if (selectedSection)
6059			{
6060				selectedInput = selectedSection.querySelector('input[type=checkbox]');
6061				BX.removeClass(selectedSection, 'bx-selected');
6062				selectedInput.checked = false;
6063			}
6064
6065			this.sendRequest();
6066		},
6067
6068		getSelectedDelivery: function()
6069		{
6070			var deliveryCheckbox = this.deliveryBlockNode.querySelector('input[type=checkbox][name=DELIVERY_ID]:checked'),
6071				currentDelivery = false,
6072				deliveryId, i;
6073
6074			if (!deliveryCheckbox)
6075				deliveryCheckbox = this.deliveryHiddenBlockNode.querySelector('input[type=checkbox][name=DELIVERY_ID]:checked');
6076
6077			if (!deliveryCheckbox)
6078				deliveryCheckbox = this.deliveryHiddenBlockNode.querySelector('input[type=hidden][name=DELIVERY_ID]');
6079
6080			if (deliveryCheckbox)
6081			{
6082				deliveryId = deliveryCheckbox.value;
6083
6084				for (i in this.result.DELIVERY)
6085				{
6086					if (this.result.DELIVERY[i].ID == deliveryId)
6087					{
6088						currentDelivery = this.result.DELIVERY[i];
6089						break;
6090					}
6091				}
6092			}
6093
6094			return currentDelivery;
6095		},
6096
6097		activatePickUp: function(deliveryName)
6098		{
6099			if (!this.pickUpBlockNode || !this.pickUpHiddenBlockNode)
6100				return;
6101
6102			this.pickUpBlockNode.style.display = '';
6103			this.pickUpBlockNode.querySelector('.bx-soa-section-title').innerHTML = BX.util.htmlspecialchars(deliveryName);
6104
6105			if (BX.hasClass(this.pickUpBlockNode, 'bx-active'))
6106				return;
6107
6108			BX.addClass(this.pickUpBlockNode, 'bx-active');
6109			this.pickUpBlockNode.style.display = '';
6110		},
6111
6112		deactivatePickUp: function()
6113		{
6114			if (!this.pickUpBlockNode || !this.pickUpHiddenBlockNode)
6115				return;
6116
6117			if (!BX.hasClass(this.pickUpBlockNode, 'bx-active'))
6118				return;
6119
6120			BX.removeClass(this.pickUpBlockNode, 'bx-active');
6121			this.pickUpBlockNode.style.display = 'none';
6122		},
6123
6124		editPickUpBlock: function(active)
6125		{
6126			if (!this.pickUpBlockNode || !this.pickUpHiddenBlockNode || !BX.hasClass(this.pickUpBlockNode, 'bx-active') || !this.result.DELIVERY)
6127				return;
6128
6129			this.initialized.pickup = false;
6130
6131			if (active)
6132				this.editActivePickUpBlock(true);
6133			/*else
6134				this.editFadePickUpBlock();*/
6135
6136			/*this.initialized.pickup = true;*/
6137		},
6138
6139		editActivePickUpBlock: function(activeNodeMode)
6140		{
6141			var node = activeNodeMode ? this.pickUpBlockNode : this.pickUpHiddenBlockNode,
6142				pickUpContent, pickUpContentCol;
6143
6144			
6145			if (this.initialized.pickup)
6146			{
6147				BX.remove(BX.lastChild(node));
6148				node.appendChild(BX.firstChild(this.pickUpHiddenBlockNode));
6149
6150				if (
6151					this.params.SHOW_NEAREST_PICKUP === 'Y'
6152					&& this.maps
6153					&& !this.maps.maxWaitTimeExpired
6154				)
6155				{
6156					this.maps.maxWaitTimeExpired = true;
6157					this.initPickUpPagination();
6158					this.editPickUpList(true);
6159					this.pickUpFinalAction();
6160				}
6161
6162				if (this.maps && !this.pickUpMapFocused)
6163				{
6164					this.pickUpMapFocused = true;
6165					setTimeout(BX.proxy(this.maps.pickUpMapFocusWaiter, this.maps), 200);
6166				}
6167
6168			}
6169			else
6170			{
6171				pickUpContent = node.querySelector('.bx-soa-section-content-node');
6172
6173				/*if (!pickUpContent)
6174				{
6175					pickUpContent = this.getNewContainer();
6176					node.appendChild(pickUpContent);
6177				}*/
6178
6179				BX.cleanNode(pickUpContent);
6180
6181				pickUpContentCol = BX.create('DIV', {props: {className: 'col-md-6 col-12 order-2'}});
6182				this.editPickUpMap(pickUpContentCol);
6183				this.editPickUpLoader(pickUpContentCol);
6184
6185				pickUpContent.appendChild(
6186					BX.create('DIV', {
6187						props: {className: 'bx_soa_pickup row'},
6188						children: [pickUpContentCol]
6189					})
6190				);
6191
6192
6193				if (this.params.SHOW_PICKUP_MAP != 'Y' || this.params.SHOW_NEAREST_PICKUP != 'Y')
6194				{
6195					this.initPickUpPagination();
6196					this.editPickUpList(true);
6197					this.pickUpFinalAction();
6198				}
6199
6200				this.getBlockFooter(pickUpContent);
6201
6202			}
6203		},
6204
6205		/*editFadePickUpBlock: function()
6206		{
6207			var pickUpContent = this.pickUpBlockNode.querySelector('.bx-soa-section-content'), newContent;
6208
6209			if (this.initialized.pickup)
6210			{
6211				this.pickUpHiddenBlockNode.appendChild(pickUpContent);
6212			}
6213			else
6214			{
6215				this.editActivePickUpBlock(true);
6216				BX.remove(BX.lastChild(this.pickUpBlockNode));
6217			}
6218
6219			newContent = this.getNewContainer();
6220			this.pickUpBlockNode.appendChild(newContent);
6221
6222			this.editFadePickUpContent(newContent);
6223		},*/
6224
6225		editFadePickUpContent: function(pickUpContainer)
6226		{
6227			var selectedPickUp = this.getSelectedPickUp(), html = '', logotype, imgSrc;
6228
6229			if (selectedPickUp)
6230			{
6231				if (this.params.SHOW_STORES_IMAGES == 'Y')
6232				{
6233					logotype = this.getImageSources(selectedPickUp, 'IMAGE_ID');
6234					imgSrc = logotype.src_1x || this.defaultStoreLogo;
6235
6236					html += '<img src="' + imgSrc + '" class="bx-soa-pickup-preview-img">';
6237				}
6238
6239				html += '<strong>' + BX.util.htmlspecialchars(selectedPickUp.TITLE) + '</strong>';
6240				if (selectedPickUp.ADDRESS)
6241					html += '<br><strong>' + BX.message('SOA_PICKUP_ADDRESS') + ':</strong> ' + BX.util.htmlspecialchars(selectedPickUp.ADDRESS);
6242
6243				if (selectedPickUp.PHONE)
6244					html += '<br><strong>' + BX.message('SOA_PICKUP_PHONE') + ':</strong> ' + BX.util.htmlspecialchars(selectedPickUp.PHONE);
6245
6246				if (selectedPickUp.SCHEDULE)
6247					html += '<br><strong>' + BX.message('SOA_PICKUP_WORK') + ':</strong> ' + BX.util.htmlspecialchars(selectedPickUp.SCHEDULE);
6248
6249				if (selectedPickUp.DESCRIPTION)
6250					html += '<br><strong>' + BX.message('SOA_PICKUP_DESC') + ':</strong> ' + BX.util.htmlspecialchars(selectedPickUp.DESCRIPTION);
6251
6252				pickUpContainer.innerHTML = html;
6253
6254				if (this.params.SHOW_STORES_IMAGES == 'Y')
6255				{
6256					BX.bind(pickUpContainer.querySelector('.bx-soa-pickup-preview-img'), 'click', BX.delegate(function(e){
6257						this.popupShow(e, logotype && logotype.src_orig || imgSrc);
6258					}, this));
6259				}
6260			}
6261		},
6262
6263		getPickUpInfoArray: function(storeIds)
6264		{
6265			if (!storeIds || storeIds.length <= 0)
6266				return [];
6267
6268			var arr = [], i;
6269
6270			for (i = 0; i < storeIds.length; i++)
6271				if (this.result.STORE_LIST[storeIds[i]])
6272					arr.push(this.result.STORE_LIST[storeIds[i]]);
6273
6274			return arr;
6275		},
6276
6277		getSelectedPickUp: function()
6278		{
6279			var pickUpInput = BX('BUYER_STORE'),
6280				currentPickUp, pickUpId,
6281				allStoresList = this.result.STORE_LIST,
6282				stores, i;
6283
6284			if (pickUpInput)
6285			{
6286				pickUpId = pickUpInput.value;
6287				currentPickUp = allStoresList[pickUpId];
6288
6289				if (!currentPickUp)
6290				{
6291					stores = this.getSelectedDelivery().STORE;
6292					if (stores)
6293					{
6294						for (i in stores)
6295						{
6296							if (stores.hasOwnProperty(i))
6297							{
6298								currentPickUp = allStoresList[stores[i]];
6299								pickUpInput.setAttribute('value', stores[i]);
6300								break;
6301							}
6302						}
6303					}
6304				}
6305			}
6306
6307			return currentPickUp;
6308		},
6309
6310		/**
6311		 * Checking delivery for pick ups. Displaying/hiding pick up block node.
6312		 */
6313		checkPickUpShow: function()
6314		{
6315			var currentDelivery = this.getSelectedDelivery(), name, stores;
6316
6317			if (currentDelivery && currentDelivery.STORE && currentDelivery.STORE.length)
6318				stores = this.getPickUpInfoArray(currentDelivery.STORE);
6319
6320	
6321
6322			if (stores && stores.length)
6323			{
6324				name = this.params.SHOW_DELIVERY_PARENT_NAMES != 'N' ? currentDelivery.NAME : currentDelivery.OWN_NAME;
6325				currentDelivery.STORE_MAIN = currentDelivery.STORE;
6326				this.activatePickUp(name);
6327				this.editSection(this.pickUpBlockNode);
6328			}
6329			else
6330			{
6331				this.deactivatePickUp();
6332			}
6333		},
6334
6335		geoLocationSuccessCallback: function(result)
6336		{
6337			var activeStores,
6338				currentDelivery = this.getSelectedDelivery();
6339
6340			if (currentDelivery && currentDelivery.STORE)
6341			{
6342				activeStores = this.getPickUpInfoArray(currentDelivery.STORE);
6343			}
6344
6345			if (activeStores && activeStores.length >= this.options.pickUpMap.minToShowNearestBlock)
6346			{
6347				this.editPickUpRecommendList(result.geoObjects.get(0));
6348			}
6349
6350			this.initPickUpPagination();
6351			this.editPickUpList(true);
6352			this.pickUpFinalAction();
6353		},
6354
6355		geoLocationFailCallback: function()
6356		{
6357			this.initPickUpPagination();
6358			this.editPickUpList(true);
6359			this.pickUpFinalAction();
6360		},
6361
6362		initMaps: function()
6363		{
6364			
6365			this.maps = BX.Sale.OrderAjaxComponent.Maps.init(this);
6366
6367			if (this.maps)
6368			{
6369				this.mapsReady = true;
6370
6371				/*this.resizeMapContainers();*/
6372
6373				if (this.params.SHOW_PICKUP_MAP === 'Y' && BX('pickUpMap'))
6374				{
6375					var currentDelivery = this.getSelectedDelivery();
6376					if (currentDelivery && currentDelivery.STORE && currentDelivery.STORE.length)
6377					{
6378						var activeStores = this.getPickUpInfoArray(currentDelivery.STORE);
6379					}
6380
6381					if (activeStores && activeStores.length)
6382					{
6383						var selected = this.getSelectedPickUp();
6384						this.maps.initializePickUpMap(selected);
6385						
6386						if (this.params.SHOW_NEAREST_PICKUP === 'Y')
6387						{
6388							this.maps.showNearestPickups(BX.proxy(this.geoLocationSuccessCallback, this), BX.proxy(this.geoLocationFailCallback, this));
6389						}
6390
6391						this.maps.buildBalloons(activeStores);
6392					}
6393				}
6394
6395				if (this.params.SHOW_MAP_IN_PROPS === 'Y' && BX('propsMap'))
6396				{
6397					var propsMapData = this.getPropertyMapData();
6398					this.maps.initializePropsMap(propsMapData);
6399				}
6400			}
6401			
6402		},
6403
6404		getPropertyMapData: function()
6405		{
6406			var currentProperty, locationId, k;
6407			var data = this.options.propertyMap.defaultMapPosition;
6408
6409			for (k in this.result.ORDER_PROP.properties)
6410			{
6411				if (this.result.ORDER_PROP.properties.hasOwnProperty(k))
6412				{
6413					currentProperty = this.result.ORDER_PROP.properties[k];
6414					if (currentProperty.IS_LOCATION == 'Y')
6415					{
6416						locationId = currentProperty.ID;
6417						break;
6418					}
6419				}
6420			}
6421
6422			if (this.locations[locationId] && this.locations[locationId][0] && this.locations[locationId][0].coordinates)
6423			{
6424				currentProperty = this.locations[locationId][0].coordinates;
6425
6426				var long = parseFloat(currentProperty.LONGITUDE),
6427					lat = parseFloat(currentProperty.LATITUDE);
6428
6429				if (!isNaN(long) && !isNaN(lat) && long != 0 && lat != 0)
6430				{
6431					data.lon = long;
6432					data.lat = lat;
6433				}
6434			}
6435
6436			return data;
6437		},
6438
6439		resizeMapContainers: function()
6440		{
6441			/*var pickUpMapContainer = BX('pickUpMap'),
6442				propertyMapContainer = BX('propsMap'),
6443				resizeBy = this.propsBlockNode,
6444				width, height;
6445
6446			if (resizeBy && (pickUpMapContainer || propertyMapContainer))
6447			{
6448				width = resizeBy.clientWidth;
6449				height = parseInt(width / 16 * 9);
6450
6451				if (this.params.SHOW_PICKUP_MAP === 'Y' && pickUpMapContainer)
6452				{
6453					pickUpMapContainer.style.height = height + 'px';
6454				}
6455
6456				if (this.params.SHOW_MAP_IN_PROPS === 'Y' && propertyMapContainer)
6457				{
6458					propertyMapContainer.style.height = height + 'px';
6459				}
6460			}*/
6461		},
6462
6463		editPickUpMap: function(pickUpContent)
6464		{
6465			pickUpContent.appendChild(BX.create('DIV', {
6466				props: {id: 'pickUpMap'},
6467				style: {width: '100%', marginBottom: '10px'}
6468			}));
6469		},
6470
6471		editPickUpLoader: function(pickUpContent)
6472		{
6473			pickUpContent.appendChild(
6474				BX.create('DIV', {
6475					props: {id: 'pickUpLoader', className: 'text-center'},
6476					children: [BX.create('IMG', {props: {src: this.templateFolder + '/images/loader.gif'}})]
6477				})
6478			);
6479		},
6480
6481		editPickUpList: function(isNew)
6482		{
6483			if (!this.pickUpPagination.currentPage || !this.pickUpPagination.currentPage.length)
6484				return;
6485
6486			BX.remove(BX('pickUpLoader'));
6487
6488			var pickUpList = BX.create('DIV', {props: {className: 'bx-soa-pickup-list main'}}),
6489				buyerStoreInput = BX('BUYER_STORE'),
6490				selectedStore,
6491				container, i, found = false,
6492				recommendList, selectedDelivery, currentStore, storeNode;
6493
6494			if (buyerStoreInput)
6495				selectedStore = buyerStoreInput.value;
6496
6497			recommendList = this.pickUpBlockNode.querySelector('.bx-soa-pickup-list.recommend');
6498			if (!recommendList)
6499				recommendList = this.pickUpHiddenBlockNode.querySelector('.bx-soa-pickup-list.recommend');
6500
6501			if (!recommendList || !recommendList.querySelector('.bx-soa-pickup-list-item.bx-selected'))
6502			{
6503				selectedDelivery = this.getSelectedDelivery();
6504				if (selectedDelivery && selectedDelivery.STORE)
6505				{
6506					for (i = 0; i < selectedDelivery.STORE.length; i++)
6507						if (selectedDelivery.STORE[i] == selectedStore)
6508							found = true;
6509				}
6510			}
6511			else
6512				found = true;
6513
6514			for (i = 0; i < this.pickUpPagination.currentPage.length; i++)
6515			{
6516				currentStore = this.pickUpPagination.currentPage[i];
6517
6518				if (currentStore.ID == selectedStore || parseInt(selectedStore) == 0 || !found)
6519				{
6520					selectedStore = buyerStoreInput.value = currentStore.ID;
6521					found = true;
6522				}
6523
6524				storeNode = this.createPickUpItem(currentStore, {selected: currentStore.ID == selectedStore});
6525				pickUpList.appendChild(storeNode);
6526			}
6527
6528			if (!!isNew)
6529			{
6530				/*container = this.pickUpHiddenBlockNode.querySelector('.bx_soa_pickup>.col-12');
6531				if (!container)*/
6532
6533				container = this.pickUpBlockNode.querySelector('.bx_soa_pickup');
6534
6535				container.appendChild(
6536					BX.create('DIV', {
6537						props: {className: 'col-md-6 col-12 order-1'},
6538						children: [
6539							pickUpList
6540						]
6541					})
6542				);
6543			}
6544			else
6545			{
6546				container = this.pickUpBlockNode.querySelector('.bx-soa-pickup-list.main');
6547				
6548				BX.insertAfter(pickUpList, container);
6549				BX.remove(container);
6550			}
6551
6552
6553			this.pickUpPagination.show && this.showPagination('pickUp', pickUpList);
6554		},
6555
6556		pickUpFinalAction: function()
6557		{
6558			var selectedDelivery = this.getSelectedDelivery(),
6559				deliveryChanged;
6560
6561			if (selectedDelivery)
6562			{
6563				deliveryChanged = this.lastSelectedDelivery !== parseInt(selectedDelivery.ID);
6564				this.lastSelectedDelivery = parseInt(selectedDelivery.ID);
6565			}
6566
6567			if (deliveryChanged && this.pickUpBlockNode.id !== this.activeSectionId)
6568			{
6569				/*if (this.pickUpBlockNode.id !== this.activeSectionId)
6570				{
6571					this.editFadePickUpContent(BX.lastChild(this.pickUpBlockNode));
6572				}
6573
6574				BX.removeClass(this.pickUpBlockNode, 'bx-step-completed');*/
6575			}
6576
6577			this.maps && this.maps.pickUpFinalAction();
6578		},
6579
6580		getStoreInfoNode: function(currentStore)
6581		{
6582			var children = [], item = null, logotype, imgSrc, imgSrcOrig;
6583
6584
6585			if (currentStore.PHONE)
6586			{
6587				children.push(
6588					BX.create('DIV', {
6589						props: {className: 'detail-item bold'},
6590						html: BX.util.htmlspecialchars(currentStore.PHONE)
6591					})
6592				);
6593			}
6594
6595			if (currentStore.ADDRESS)
6596			{
6597				children.push(
6598					BX.create('DIV', {
6599						props: {className: 'detail-item'},
6600						html: BX.util.htmlspecialchars(currentStore.ADDRESS)
6601					})
6602				);
6603			}
6604
6605			if (currentStore.SCHEDULE)
6606			{
6607				children.push(
6608					BX.create('DIV', {
6609						props: {className: 'detail-item'},
6610						html: BX.message('SOA_PICKUP_WORK') + ': ' + BX.util.htmlspecialchars(currentStore.SCHEDULE)
6611					})
6612				);
6613				
6614			}
6615
6616			if (this.params.SHOW_STORES_IMAGES === 'Y')
6617			{
6618				logotype = this.getImageSources(currentStore, 'IMAGE_ID');
6619				imgSrc = logotype && logotype.src_1x;
6620				imgSrcOrig = logotype.src_orig || "";
6621			}
6622
6623		
6624
6625			if(imgSrc)
6626			{
6627				children.push( 
6628
6629					BX.create('DIV', {
6630						props: {className: 'detail-item margin-md'},
6631						children: [
6632							BX.create('A', {
6633								props: {
6634									className: 'd-inline-block cursor-loop'
6635								},
6636								attrs: {
6637									href: imgSrcOrig,
6638									'data-gallery': 'pickup-'+currentStore.ID
6639								},
6640								children: [
6641									BX.create('IMG', {
6642										props: {
6643											src: imgSrc,
6644											className: 'bx-soa-pickup-l-item-img'
6645										},
6646									})
6647								]
6648							})
6649						]
6650					})
6651				);
6652			
6653			}
6654
6655
6656			children.push(BX.create('DIV', {
6657				props: {className: "detail-item margin-md wr-btn"},
6658				children: [
6659					BX.create('A', {
6660						props: {className: 'btn btn-md main-color'},
6661						html: this.params.MESS_SELECT_PICKUP,
6662						events: {
6663							click: BX.delegate(function(event){
6664								this.selectStore(event);
6665							}, this)
6666						}
6667					})
6668				]
6669			}));
6670
6671
6672			return children;
6673		},
6674
6675		createPickUpItem: function(currentStore, options)
6676		{
6677			options = options || {};
6678
6679			var imgClassName = 'bx-soa-pickup-l-item-detail',
6680				buttonClassName = 'bx-soa-pickup-l-item-btn',
6681				storeNode;
6682
6683
6684			storeNode = BX.create('DIV', {
6685				props: {className: 'bx-soa-pickup-list-item show-hidden-parent', id: 'store-' + currentStore.ID},
6686				children: [
6687
6688					BX.create('DIV', {
6689						props: {className: 'check'},
6690						events: {
6691							click: BX.proxy(this.selectStore, this)
6692						}
6693					}),
6694					BX.create('DIV', {
6695						props: {className: 'bx-soa-pickup-l-item-name bold'}, 
6696						text: currentStore.TITLE,
6697						events: {
6698							click: BX.proxy(this.selectStore, this)
6699						}
6700					}
6701					),
6702					BX.create('DIV', {props: {className: 'bx-soa-pickup-l-item-desc'}, text: currentStore.DESCRIPTION}),
6703					
6704					/*BX.create('DIV', {
6705						props: {className: imgClassName},
6706						children: [
6707							logoNode,
6708							BX.create('DIV', {props: {className: 'bx-soa-pickup-l-item-name bold'}, text: currentStore.TITLE}),
6709						]
6710					}),*/
6711
6712					BX.create('DIV', {
6713						props: {
6714								className: 'show-hidden-child hidden'
6715							},
6716							children: this.getStoreInfoNode(currentStore),
6717						}
6718						
6719					),
6720
6721					BX.create('DIV', {
6722						props: {
6723								className: 'show-hidden-wrap mode-toogle'
6724							},
6725							html: "<div class=\"show-hidden\"><span class=\"bord-bot white\">"
6726								+ "<span class = \"s\">" +BX.message('ORDER_PICKUP_BTN_DETAIL') + '</span>'
6727								+ "<span class = \"h\">" +BX.message('ORDER_PICKUP_BTN_DETAIL_HIDE') + '</span>'
6728								+"</span></div>"
6729						}
6730					),
6731
6732					/*BX.create('DIV', {
6733						props: {className: 'bx-soa-pickup-l-item-adress'},
6734						children: options.distance ? [
6735							BX.util.htmlspecialchars(currentStore.ADDRESS),
6736							' ( ~' + options.distance + ' ' + BX.message('SOA_DISTANCE_KM') + ' ) '
6737						] : [BX.util.htmlspecialchars(currentStore.ADDRESS)]
6738					}),*/
6739
6740					/*BX.create('DIV', {
6741						props: {className: buttonClassName},
6742						children: [
6743							BX.create('A', {
6744								props: {href: '', className: 'btn btn-sm btn-default'},
6745								html: this.params.MESS_SELECT_PICKUP,
6746								events: {
6747									click: BX.delegate(function(event){
6748										this.selectStore(event);
6749										this.clickNextAction(event)
6750									}, this)
6751								}
6752							})
6753						]
6754					})*/
6755				]
6756			});
6757
6758			if (options.selected)
6759				BX.addClass(storeNode, 'bx-selected');
6760
6761			return storeNode;
6762		},
6763
6764		editPickUpRecommendList: function(geoLocation)
6765		{
6766			/*if (!this.maps || !this.maps.canUseRecommendList() || !geoLocation)
6767			{
6768				return;
6769			}
6770
6771			BX.remove(BX('pickUpLoader'));
6772
6773			var recommendList = BX.create('DIV', {props: {className: 'bx-soa-pickup-list recommend'}}),
6774				buyerStoreInput = BX('BUYER_STORE'),
6775				selectedDelivery = this.getSelectedDelivery();
6776
6777			var i, currentStore, currentStoreId, distance, storeNode, container;
6778
6779			var recommendedStoreIds = this.maps.getRecommendedStoreIds(geoLocation);
6780			for (i = 0; i < recommendedStoreIds.length; i++)
6781			{
6782				currentStoreId = recommendedStoreIds[i];
6783				currentStore = this.getPickUpInfoArray([currentStoreId])[0];
6784
6785				if (i === 0 && parseInt(selectedDelivery.ID) !== this.lastSelectedDelivery)
6786				{
6787					buyerStoreInput.value = parseInt(currentStoreId);
6788				}
6789
6790				distance = this.maps.getDistance(geoLocation, currentStoreId);
6791				storeNode = this.createPickUpItem(currentStore, {
6792					selected: buyerStoreInput.value === currentStoreId,
6793					distance: distance
6794				});
6795				recommendList.appendChild(storeNode);
6796
6797				if (selectedDelivery.STORE_MAIN)
6798				{
6799					selectedDelivery.STORE_MAIN.splice(selectedDelivery.STORE_MAIN.indexOf(currentStoreId), 1);
6800				}
6801			}
6802
6803			container = this.pickUpHiddenBlockNode.querySelector('.bx_soa_pickup>.col-12');
6804			if (!container)
6805			{
6806				container = this.pickUpBlockNode.querySelector('.bx_soa_pickup>.col-12');
6807			}
6808
6809			container.appendChild(
6810				BX.create('DIV', {
6811					props: {className: 'bx-soa-pickup-subTitle bold'},
6812					html: this.params.MESS_NEAREST_PICKUP_LIST
6813				})
6814			);
6815			container.appendChild(recommendList);*/
6816		},
6817
6818		selectStore: function(event)
6819		{
6820			var storeItem,
6821				storeInput = BX('BUYER_STORE'),
6822				selectedPickUp, storeItemId, i, k, page,
6823				target, h1, h2;
6824
6825			if (BX.type.isString(event))
6826			{
6827				storeItem = BX('store-' + event);
6828				if (!storeItem)
6829				{
6830					for (i = 0; i < this.pickUpPagination.pages.length; i++)
6831					{
6832						page = this.pickUpPagination.pages[i];
6833						for (k = 0; k < page.length; k++)
6834						{
6835							if (page[k].ID == event)
6836							{
6837								this.showPickUpItemsPage(++i);
6838								break;
6839							}
6840						}
6841					}
6842					storeItem = BX('store-' + event);
6843				}
6844			}
6845			else
6846			{
6847				target = event.target || event.srcElement;
6848				storeItem = BX.hasClass(target, 'bx-soa-pickup-list-item')
6849					? target
6850					: BX.findParent(target, {className: 'bx-soa-pickup-list-item'});
6851			}
6852
6853			if (storeItem && storeInput)
6854			{
6855				if (BX.hasClass(storeItem, 'bx-selected'))
6856					return;
6857
6858				selectedPickUp = this.pickUpBlockNode.querySelector('.bx-selected');
6859				storeItemId = storeItem.id.substr('store-'.length);
6860
6861				BX.removeClass(selectedPickUp, 'bx-selected');
6862
6863				h1 = storeItem.clientHeight;
6864				storeItem.style.overflow = 'hidden';
6865				BX.addClass(storeItem, 'bx-selected');
6866				h2 = storeItem.clientHeight;
6867				storeItem.style.height = h1 + 'px';
6868
6869				new BX.easing({
6870					duration: 300,
6871					start: {height: h1, opacity: 0},
6872					finish: {height: h2, opacity: 100},
6873					transition: BX.easing.transitions.quad,
6874					step: function(state){
6875						storeItem.style.height = state.height + "px";
6876					},
6877					complete: function(){
6878						storeItem.removeAttribute('style');
6879					}
6880				}).animate();
6881
6882				storeInput.setAttribute('value', storeItemId);
6883				this.maps && this.maps.selectBalloon(storeItemId);
6884			}
6885		},
6886
6887		getDeliverySortedArray: function(objDelivery)
6888		{
6889			var deliveries = [],
6890				problemDeliveries = [],
6891				sortFunc = function(a, b){
6892					var sort = parseInt(a.SORT) - parseInt(b.SORT);
6893					if (sort === 0)
6894					{
6895						return a.OWN_NAME.toLowerCase() > b.OWN_NAME.toLowerCase()
6896							? 1
6897							: (a.OWN_NAME.toLowerCase() < b.OWN_NAME.toLowerCase() ? -1 : 0);
6898					}
6899					else
6900					{
6901						return sort;
6902					}
6903				},
6904				k;
6905
6906			for (k in objDelivery)
6907			{
6908				if (objDelivery.hasOwnProperty(k))
6909				{
6910					if (this.params.SHOW_NOT_CALCULATED_DELIVERIES === 'L' && objDelivery[k].CALCULATE_ERRORS)
6911					{
6912						problemDeliveries.push(objDelivery[k]);
6913					}
6914					else
6915					{
6916						deliveries.push(objDelivery[k]);
6917					}
6918				}
6919			}
6920
6921			deliveries.sort(sortFunc);
6922			problemDeliveries.sort(sortFunc);
6923
6924			return deliveries.concat(problemDeliveries);
6925		},
6926
6927		editPropsBlock: function(active)
6928		{
6929			if (!this.propsBlockNode || !this.propsHiddenBlockNode || !this.result.ORDER_PROP)
6930				return;
6931
6932			if (active)
6933				this.editActivePropsBlock(true);
6934			else
6935				this.editFadePropsBlock();
6936
6937			/*this.initialized.props = true;*/
6938		},
6939
6940		editActivePropsBlock: function(activeNodeMode)
6941		{
6942			var node = activeNodeMode ? this.propsBlockNode : this.propsHiddenBlockNode,
6943				propsContent, propsNode, selectedDelivery, showPropMap = false, i, validationErrors;
6944
6945			if (this.initialized.props)
6946			{
6947				BX.remove(BX.lastChild(node));
6948				node.appendChild(BX.firstChild(this.propsHiddenBlockNode));
6949				this.maps && setTimeout(BX.proxy(this.maps.propsMapFocusWaiter, this.maps), 200);
6950			}
6951			else
6952			{
6953				propsContent = node.querySelector('.bx-soa-section-content-node');
6954				if (!propsContent)
6955				{
6956					propsContent = this.getNewContainer();
6957					node.appendChild(propsContent);
6958				}
6959				else
6960					BX.cleanNode(propsContent);
6961
6962				this.getErrorContainer(propsContent);
6963
6964				propsNode = BX.create('DIV', {props: {className: 'row'}});
6965				selectedDelivery = this.getSelectedDelivery();
6966
6967				if (
6968					selectedDelivery && this.params.SHOW_MAP_IN_PROPS === 'Y'
6969					&& this.params.SHOW_MAP_FOR_DELIVERIES && this.params.SHOW_MAP_FOR_DELIVERIES.length
6970				)
6971				{
6972					for (i = 0; i < this.params.SHOW_MAP_FOR_DELIVERIES.length; i++)
6973					{
6974						if (parseInt(selectedDelivery.ID) === parseInt(this.params.SHOW_MAP_FOR_DELIVERIES[i]))
6975						{
6976							showPropMap = true;
6977							break;
6978						}
6979					}
6980				}
6981
6982				this.editPropsItems(propsNode);
6983				showPropMap = true;
6984				showPropMap && this.editPropsMap(propsNode);
6985
6986				if (this.params.HIDE_ORDER_DESCRIPTION !== 'Y')
6987				{
6988					this.editPropsComment(propsNode);
6989				}
6990
6991				propsContent.appendChild(propsNode);
6992				this.getBlockFooter(propsContent);
6993
6994				if (this.propsBlockNode.getAttribute('data-visited') === 'true')
6995				{
6996					validationErrors = this.isValidPropertiesBlock(true);
6997					if (validationErrors.length)
6998						BX.addClass(this.propsBlockNode, 'bx-step-error');
6999					else
7000						BX.removeClass(this.propsBlockNode, 'bx-step-error');
7001				}
7002			}
7003		},
7004
7005		editFadePropsBlock: function()
7006		{
7007			var propsContent = this.propsBlockNode.querySelector('.bx-soa-section-content'), newContent;
7008
7009			if (this.initialized.props)
7010			{
7011				this.propsHiddenBlockNode.appendChild(propsContent);
7012			}
7013			else
7014			{
7015				this.editActivePropsBlock(false);
7016				BX.remove(BX.lastChild(this.propsBlockNode));
7017			}
7018
7019			newContent = this.getNewContainer();
7020			this.propsBlockNode.appendChild(newContent);
7021
7022			this.editFadePropsContent(newContent);
7023		},
7024
7025		editFadePropsContent: function(node)
7026		{
7027			if (!node || !this.locationsInitialized)
7028				return;
7029
7030			var errorNode = this.propsHiddenBlockNode.querySelector('.alert'),
7031				personType = this.getSelectedPersonType(),
7032				fadeParamName, props,
7033				group, property, groupIterator, propsIterator, i, validPropsErrors;
7034
7035			BX.cleanNode(node);
7036
7037			if (errorNode)
7038				node.appendChild(errorNode.cloneNode(true));
7039
7040			if (personType)
7041			{
7042				fadeParamName = 'PROPS_FADE_LIST_' + personType.ID;
7043				props = this.params[fadeParamName];
7044			}
7045
7046			if (!props || props.length === 0)
7047			{
7048				node.innerHTML += '<strong>' + BX.message('SOA_ORDER_PROPS') + '</strong>';
7049			}
7050			else
7051			{
7052				groupIterator = this.fadedPropertyCollection.getGroupIterator();
7053				while (group = groupIterator())
7054				{
7055					propsIterator = group.getIterator();
7056					while (property = propsIterator())
7057					{
7058						c
7059						for (i = 0; i < props.length; i++)
7060							if (props[i] == property.getId() && property.getSettings()['IS_ZIP'] != 'Y')
7061								this.getPropertyRowNode(property, node, true);
7062					}
7063				}
7064			}
7065
7066			if (this.propsBlockNode.getAttribute('data-visited') === 'true')
7067			{
7068				validPropsErrors = this.isValidPropertiesBlock();
7069				if (validPropsErrors.length)
7070					this.showError(this.propsBlockNode, validPropsErrors);
7071			}
7072
7073			BX.bind(node.querySelector('.alert.alert-danger'), 'click', BX.proxy(this.showByClick, this));
7074			BX.bind(node.querySelector('.alert.alert-warning'), 'click', BX.proxy(this.showByClick, this));
7075		},
7076
7077		editPropsItems: function(propsNode)
7078		{
7079			if (!this.result.ORDER_PROP || !this.propertyCollection)
7080				return;
7081
7082
7083			var propsItemsContainer = BX.create('DIV', {props: {className: 'col-12 bx-soa-customer'}}),
7084				group, property, groupIterator = this.propertyCollection.getGroupIterator(), propsIterator;
7085
7086			if (!propsItemsContainer)
7087				propsItemsContainer = this.propsBlockNode.querySelector('.col-12.bx-soa-customer');
7088
7089
7090
7091			while (group = groupIterator())
7092			{
7093				propsIterator =  group.getIterator();
7094
7095				while (property = propsIterator())
7096				{
7097
7098					if (
7099						this.deliveryLocationInfo.loc == property.getId()
7100						|| this.deliveryLocationInfo.zip == property.getId()
7101						|| this.deliveryLocationInfo.city == property.getId()
7102					)
7103						continue;
7104
7105					this.getPropertyRowNode(property, propsItemsContainer, false);
7106				}
7107			}
7108
7109
7110
7111			propsNode.appendChild(propsItemsContainer);
7112		},
7113
7114		getPropertyRowNode: function(property, propsItemsContainer, disabled)
7115		{
7116			var propsItemNode = BX.create('DIV'),
7117				textHtml = '',
7118				propertyType = property.getType() || '',
7119				propertyDesc = property.getDescription() || '',
7120				label;
7121
7122
7123
7124			if (disabled)
7125			{
7126				propsItemNode.innerHTML = '<strong>' + BX.util.htmlspecialchars(property.getName()) + ':</strong> ';
7127			}
7128			else
7129			{
7130				BX.addClass(propsItemNode, "bx-form-group bx-soa-customer-field");
7131
7132				/*if (property.isRequired())
7133					textHtml += '<span class="bx-authform-starrequired">*</span> ';
7134
7135				textHtml += BX.util.htmlspecialchars(property.getName());
7136				if (propertyDesc.length && propertyType != 'STRING' && propertyType != 'NUMBER' && propertyType != 'DATE')
7137					textHtml += ' <small>(' + BX.util.htmlspecialchars(propertyDesc) + ')</small>';
7138
7139				label = BX.create('LABEL', {
7140					attrs: {'for': 'soa-property-' + property.getId()},
7141					props: {className: 'bx-soa-custom-label'},
7142					html: textHtml
7143				});
7144				propsItemNode.appendChild(label);
7145				*/
7146
7147				propsItemNode.setAttribute('data-property-id-row', property.getId());
7148				
7149			}
7150
7151			switch (propertyType)
7152			{
7153				case 'LOCATION':
7154					this.insertLocationProperty(property, propsItemNode, disabled);
7155					break;
7156				case 'DATE':
7157					this.insertDateProperty(property, propsItemNode, disabled);
7158					break;
7159				case 'FILE':
7160					this.insertFileProperty(property, propsItemNode, disabled);
7161					break;
7162				case 'STRING':
7163					this.insertStringProperty(property, propsItemNode, disabled);
7164					break;
7165				case 'ENUM':
7166					this.insertEnumProperty(property, propsItemNode, disabled);
7167					break;
7168				case 'Y/N':
7169					this.insertYNProperty(property, propsItemNode, disabled);
7170					break;
7171				case 'NUMBER':
7172					this.insertNumberProperty(property, propsItemNode, disabled);
7173			}
7174
7175
7176
7177			propsItemsContainer.appendChild(propsItemNode);
7178		},
7179
7180		insertLocationProperty: function(property, propsItemNode, disabled)
7181		{
7182			var propRow, propNodes, locationString, currentLocation, insertedLoc, propContainer, i, k, values = [];
7183
7184
7185			if (property.getId() in this.locations)
7186			{
7187				if (disabled)
7188				{
7189					propRow = this.propsHiddenBlockNode.querySelector('[data-property-id-row="' + property.getId() + '"]');
7190					if (propRow)
7191					{
7192						propNodes = propRow.querySelectorAll('div.bx-soa-loc');
7193						for (i = 0; i < propNodes.length; i++)
7194						{
7195							locationString = this.getLocationString(propNodes[i]);
7196							values.push(locationString.length ? BX.util.htmlspecialchars(locationString) : BX.message('SOA_NOT_SELECTED'));
7197						}
7198					}
7199					propsItemNode.innerHTML += values.join('<br>');
7200				}
7201				else
7202				{
7203					propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7204					propRow = this.locations[property.getId()];
7205					for (i = 0; i < propRow.length; i ++)
7206					{
7207						currentLocation = propRow[i] ? propRow[i].output : {};
7208						insertedLoc = BX.create('DIV', {props: {className: 'bx-soa-loc search-line-location'}, html: currentLocation.HTML});
7209
7210						if (property.isMultiple())
7211							insertedLoc.style.marginBottom = this.locationsTemplate == 'search' ? '5px' : '20px';
7212
7213						propContainer.appendChild(insertedLoc);
7214
7215						for (k in currentLocation.SCRIPT)
7216						{
7217							if (currentLocation.SCRIPT.hasOwnProperty(k))
7218								BX.evalGlobal(currentLocation.SCRIPT[k].JS);
7219						}
7220					}
7221
7222					if (property.isMultiple())
7223					{
7224						propContainer.appendChild(
7225							BX.create('DIV', {
7226								attrs: {'data-prop-id': property.getId()},
7227								props: {className: 'btn btn-sm btn-default'},
7228								text: BX.message('ADD_DEFAULT'),
7229								events: {
7230									click: BX.proxy(this.addLocationProperty, this)
7231								}
7232							})
7233						);
7234					}
7235
7236					propsItemNode.appendChild(propContainer);
7237
7238					this.remakeInputs(property.getSettings(), propContainer);
7239				}
7240			}
7241		},
7242
7243		addLocationProperty: function(e)
7244		{
7245			var target = e.target || e.srcElement,
7246				propId = target.getAttribute('data-prop-id'),
7247				lastProp = BX.previousSibling(target),
7248				insertedLoc, k, input, index = 0,
7249				prefix = 'sls-',
7250				randomStr = BX.util.getRandomString(5);
7251
7252			if (BX.hasClass(lastProp, 'bx-soa-loc'))
7253			{
7254				if (this.locationsTemplate == 'search')
7255				{
7256					input = lastProp.querySelector('input[type=text][class=dropdown-field]');
7257					if (input)
7258						index = parseInt(input.name.substring(input.name.indexOf('[') + 1, input.name.indexOf(']'))) + 1;
7259				}
7260				else
7261				{
7262					input = lastProp.querySelectorAll('input[type=hidden]');
7263					if (input.length)
7264					{
7265						input = input[input.length - 1];
7266						index = parseInt(input.name.substring(input.name.indexOf('[') + 1, input.name.indexOf(']'))) + 1;
7267					}
7268				}
7269			}
7270
7271			if (this.cleanLocations[propId])
7272			{
7273				insertedLoc = BX.create('DIV', {
7274					props: {className: 'bx-soa-loc'},
7275					style: {marginBottom: this.locationsTemplate == 'search' ? '5px' : '20px'},
7276					html: this.cleanLocations[propId].HTML.split('#key#').join(index).replace(/sls-\d{5}/g, prefix + randomStr)
7277				});
7278				target.parentNode.insertBefore(insertedLoc, target);
7279
7280				BX.saleOrderAjax.addPropertyDesc({
7281					id: propId + '_' + index,
7282					attributes: {
7283						id: propId + '_' + index,
7284						type: 'LOCATION',
7285						valueSource: 'form'
7286					}
7287				});
7288
7289
7290				for (k in this.cleanLocations[propId].SCRIPT)
7291					if (this.cleanLocations[propId].SCRIPT.hasOwnProperty(k))
7292						BX.evalGlobal(this.cleanLocations[propId].SCRIPT[k].JS.split('_key__').join('_' + index).replace(/sls-\d{5}/g, prefix + randomStr));
7293
7294				BX.saleOrderAjax.initDeferredControl();
7295			}
7296		},
7297
7298		insertDateProperty: function(property, propsItemNode, disabled)
7299		{
7300			var prop, dateInputs, values, i,
7301				propContainer, inputText;
7302
7303			if (disabled)
7304			{
7305				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7306				if (prop)
7307				{
7308					values = [];
7309					dateInputs = prop.querySelectorAll('input[type=text]');
7310
7311					for (i = 0; i < dateInputs.length; i++)
7312						if (dateInputs[i].value && dateInputs[i].value.length)
7313							values.push(dateInputs[i].value);
7314
7315					propsItemNode.innerHTML += this.valuesToString(values);
7316				}
7317			}
7318			else
7319			{
7320				propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7321				property.appendTo(propContainer);
7322				propsItemNode.appendChild(propContainer);
7323				inputText = propContainer.querySelectorAll('input[type=text]');
7324
7325				for (i = 0; i < inputText.length; i++)
7326					this.alterDateProperty(property.getSettings(), inputText[i]);
7327
7328				this.alterProperty(property.getSettings(), propContainer);
7329				this.bindValidation(property.getId(), propContainer);
7330				this.remakeInputs(property.getSettings(), propContainer);
7331			}
7332		},
7333
7334		insertFileProperty: function(property, propsItemNode, disabled)
7335		{
7336			var prop, fileLinks, values, i, html,
7337				saved, propContainer;
7338
7339			if (disabled)
7340			{
7341				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7342				if (prop)
7343				{
7344					values = [];
7345					fileLinks = prop.querySelectorAll('a');
7346
7347					for (i = 0; i < fileLinks.length; i++)
7348					{
7349						html = fileLinks[i].innerHTML;
7350						if (html.length)
7351							values.push(html);
7352					}
7353
7354					propsItemNode.innerHTML += this.valuesToString(values);
7355				}
7356			}
7357			else
7358			{
7359				saved = this.savedFilesBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7360				if (saved)
7361					propContainer = saved.querySelector('div.soa-property-container');
7362
7363				if (propContainer)
7364					propsItemNode.appendChild(propContainer);
7365				else
7366				{
7367					propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7368					property.appendTo(propContainer);
7369					propsItemNode.appendChild(propContainer);
7370					this.alterProperty(property.getSettings(), propContainer);
7371					this.remakeInputs(property.getSettings(), propContainer);
7372				}
7373			}
7374		},
7375
7376		insertStringProperty: function(property, propsItemNode, disabled)
7377		{
7378			var prop, inputs, values, i, propContainer;
7379
7380			if (disabled)
7381			{
7382				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7383				if (prop)
7384				{
7385					values = [];
7386					inputs = prop.querySelectorAll('input[type=text]');
7387					if (inputs.length == 0)
7388						inputs = prop.querySelectorAll('textarea');
7389
7390					if (inputs.length)
7391					{
7392						for (i = 0; i < inputs.length; i++)
7393						{
7394							if (inputs[i].value.length)
7395								values.push(inputs[i].value);
7396						}
7397					}
7398
7399					propsItemNode.innerHTML += this.valuesToString(values);
7400				}
7401			}
7402			else
7403			{
7404				propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7405
7406
7407				property.appendTo(propContainer);
7408				propsItemNode.appendChild(propContainer);
7409				this.alterProperty(property.getSettings(), propContainer);
7410				this.bindValidation(property.getId(), propContainer);
7411
7412				this.remakeInputs(property.getSettings(), propContainer);
7413
7414			}
7415
7416		},
7417
7418		remakeInputs: function(settings, propContainer){
7419
7420			var i, inputs, label, inputsHidden, inputsFile;
7421
7422
7423			if(settings.TYPE == "STRING")
7424			{
7425
7426				inputs = propContainer.querySelectorAll('input[type=text]');
7427
7428
7429				if(inputs)
7430				{
7431					for (i = 0; i < inputs.length; i++)
7432					{
7433
7434						propContainer.appendChild(
7435							BX.create('DIV', {
7436
7437								props: {
7438										className: "col-md-6 col-12 parent-add-row"
7439									},
7440
7441								children:[
7442
7443									BX.create('DIV', {
7444
7445										props: {
7446											className: "input-simple no-mg inp-small"+(settings.VALUE[0] ? " in-focus ": "")
7447										},
7448
7449										children:[
7450											BX.create('SPAN', {
7451												props: 
7452												{
7453													className: "desc"
7454												},
7455												html: settings.NAME
7456											}),
7457											inputs[i]
7458										]
7459									})
7460								]
7461							})
7462						);
7463						
7464
7465						if(settings.DESCRIPTION)
7466						{
7467							if(settings.DESCRIPTION.length>0)
7468							{
7469								propContainer.appendChild(
7470									BX.create('DIV', {
7471										props: 
7472										{
7473											className: "soa-description align-self-center col-md-6 col-12"
7474										},
7475										html: settings.DESCRIPTION
7476									})
7477								);
7478							}
7479						}
7480					}
7481				}
7482			
7483
7484				inputs = propContainer.querySelectorAll('textarea');
7485
7486				if(inputs)
7487				{
7488
7489					for (i = 0; i < inputs.length; i++)
7490					{
7491
7492						
7493						propContainer.appendChild(
7494							BX.create('DIV', {
7495
7496								props: {
7497										className: "col-12 parent-add-row"
7498									},
7499
7500								children:[
7501
7502									BX.create('DIV', {
7503
7504										props: {
7505											className: "textarea-simple inp-small no-mg "+(settings.VALUE[0] ? "in-focus": "")
7506										},
7507
7508										children:[
7509											BX.create('DIV', {
7510												props: 
7511												{
7512													className: "bg"
7513												},
7514											}),
7515											BX.create('SPAN', {
7516												props: 
7517												{
7518													className: "desc"
7519												},
7520												html: settings.NAME
7521											}),
7522											inputs[i]
7523										]
7524									})
7525								]
7526							})
7527						);
7528
7529						if(settings.DESCRIPTION)
7530						{
7531							if(settings.DESCRIPTION.length>0)
7532							{
7533								propContainer.appendChild(
7534									BX.create('DIV', {
7535										props: 
7536										{
7537											className: "soa-description under-input align-self-center col-12"
7538										},
7539										html: settings.DESCRIPTION
7540									})
7541								);
7542							}
7543						}
7544					}
7545				}
7546
7547			}
7548
7549			else if(settings.TYPE == "NUMBER")
7550			{
7551
7552				inputs = propContainer.querySelectorAll('input[type=text]');
7553
7554
7555				if(inputs)
7556				{
7557					for (i = 0; i < inputs.length; i++)
7558					{
7559
7560						propContainer.appendChild(
7561							BX.create('DIV', {
7562
7563								props: {
7564										className: "col-md-6 col-12 parent-add-row"
7565									},
7566
7567								children:[
7568
7569									BX.create('DIV', {
7570
7571										props: {
7572											className: "input-simple no-mg inp-small "+(settings.VALUE[0] ? "in-focus": "")
7573										},
7574
7575										children:[
7576											BX.create('SPAN', {
7577												props: 
7578												{
7579													className: "desc"
7580												},
7581												html: settings.NAME
7582											}),
7583											inputs[i]
7584										]
7585									})
7586								]
7587							})
7588						);
7589
7590
7591						if(settings.DESCRIPTION)
7592						{
7593							if(settings.DESCRIPTION.length>0)
7594							{
7595								propContainer.appendChild(
7596									BX.create('DIV', {
7597										props: 
7598										{
7599											className: "soa-description align-self-center col-md-6 col-12"
7600										},
7601										html: settings.DESCRIPTION
7602									})
7603								);
7604							}
7605						}
7606					}
7607				}
7608
7609			}
7610
7611			else if(settings.TYPE == "Y/N")
7612			{
7613				inputs = propContainer.querySelectorAll('input[type=checkbox]');
7614				inputsHidden = propContainer.querySelectorAll('input[type=hidden]');
7615
7616				if(inputs)
7617				{
7618					for (i = 0; i < inputs.length; i++)
7619					{
7620						label = BX.create('LABEL', {
7621							props: {
7622								className: 'input-checkbox-css'
7623							},
7624							children: [
7625								inputsHidden[i],
7626								inputs[i],
7627								BX.create('SPAN'),
7628								BX.create('SPAN', {
7629									props: {className: 'text'},
7630									html: settings.NAME
7631								})
7632								
7633							]
7634						});
7635
7636						propContainer.appendChild(
7637							BX.create('DIV', {
7638
7639								props: {
7640										className: "col-md-6 col-12 parent-add-row"
7641									},
7642
7643								children:[label]
7644							})
7645						);
7646
7647
7648						if(settings.DESCRIPTION)
7649						{
7650							if(settings.DESCRIPTION.length>0)
7651							{
7652								propContainer.appendChild(
7653									BX.create('DIV', {
7654										props: 
7655										{
7656											className: "soa-description align-self-center col-md-6 col-12"
7657										},
7658										html: settings.DESCRIPTION
7659									})
7660								);
7661							}
7662						}
7663					}
7664				}
7665
7666			}
7667
7668			else if(settings.TYPE == "LOCATION")
7669			{
7670				inputs = propContainer.querySelectorAll('.search-line-location');
7671
7672
7673				if(inputs)
7674				{
7675					for (i = 0; i < inputs.length; i++)
7676					{
7677
7678						propContainer.appendChild(
7679							BX.create('DIV', {
7680
7681								props: {
7682										className: "col-md-6 col-12 parent-add-row"
7683									},
7684
7685								children:[inputs[i]]
7686							})
7687						);
7688						
7689						if(settings.DESCRIPTION)
7690						{
7691							if(settings.DESCRIPTION.length>0)
7692							{
7693								propContainer.appendChild(
7694									BX.create('DIV', {
7695										props: 
7696										{
7697											className: "soa-description align-self-center col-md-6 col-12"
7698										},
7699										html: settings.DESCRIPTION
7700									})
7701								);
7702							}
7703						}
7704					}
7705				}
7706				
7707			}
7708
7709			else if(settings.TYPE == "ENUM")
7710			{
7711
7712				inputs = propContainer.querySelectorAll('select');
7713
7714				if(inputs)
7715				{
7716					for (i = 0; i < inputs.length; i++)
7717					{
7718						BX.addClass(inputs[i], "simple-select");
7719
7720						propContainer.appendChild(
7721							BX.create('DIV', {
7722
7723								props: {
7724										className: "col-md-6 col-12 parent-add-row"
7725									},
7726
7727								children:[inputs[i]]
7728							})
7729						);
7730						
7731
7732						if(settings.DESCRIPTION)
7733						{
7734							if(settings.DESCRIPTION.length>0)
7735							{
7736								propContainer.appendChild(
7737									BX.create('DIV', {
7738										props: 
7739										{
7740											className: "soa-description align-self-center col-md-6 col-12"
7741										},
7742										html: settings.DESCRIPTION
7743									})
7744								);
7745							}
7746						}
7747					}
7748				}
7749				
7750			}
7751
7752			else if(settings.TYPE == "FILE")
7753			{
7754				inputs = propContainer.querySelectorAll('input[type=button]');
7755				inputsHidden = propContainer.querySelectorAll('input[type=hidden]');
7756				inputsFile = propContainer.querySelectorAll('input[type=file]');
7757				var nodeA = propContainer.querySelectorAll('a');
7758
7759				if(inputs)
7760				{
7761					for (i = 0; i < inputs.length; i++)
7762					{
7763						inputs[i].style.margin = "0";
7764						
7765						BX.removeClass(inputs[i], "btn btn-default btn-sm");
7766						BX.addClass(inputs[i], "soa-file-btn file-simple b-ra");
7767
7768						inputs[i].value = settings.NAME;
7769						
7770
7771						propContainer.appendChild(
7772							BX.create('DIV', {
7773
7774								props: {
7775										className: "col-md-6 col-12 parent-add-row"
7776									},
7777
7778								children:[
7779
7780									BX.create('DIV', {
7781
7782										props: {
7783											className: "wr-file-input " + (settings.REQUIRED == 'Y' ? "text-require": "")
7784										},
7785										children:[inputs[i], nodeA[i], inputsHidden[i],inputsFile[i]]
7786									}
7787								)]
7788							})
7789						);
7790
7791
7792						if(settings.DESCRIPTION)
7793						{
7794							if(settings.DESCRIPTION.length>0)
7795							{
7796								propContainer.appendChild(
7797									BX.create('DIV', {
7798										props: 
7799										{
7800											className: "soa-description align-self-center col-md-6 col-12"
7801										},
7802										html: settings.DESCRIPTION
7803									})
7804								);
7805							}
7806						}
7807					}
7808				}
7809			}
7810
7811			else if(settings.TYPE == "DATE")
7812			{
7813				inputs = propContainer.querySelectorAll('input[type=text]');
7814
7815				if(inputs)
7816				{
7817					for (i = 0; i < inputs.length; i++)
7818					{
7819						BX.addClass(inputs[i], "date-group");
7820
7821						propContainer.appendChild(
7822							BX.create('DIV', {
7823
7824								props: {
7825										className: "col-md-6 col-12 parent-add-row"
7826									},
7827
7828								children:[
7829
7830									BX.create('DIV', {
7831
7832										props: {
7833											className: "input-simple no-mg inp-small "+(settings.VALUE[0] ? "in-focus": "")
7834										},
7835
7836										children:[
7837											BX.create('SPAN', {
7838												props: 
7839												{
7840													className: "desc"
7841												},
7842												html: settings.NAME
7843											}),
7844											inputs[i],
7845											BX.create('SPAN', {
7846												props: 
7847												{
7848													className: "bg-icon"
7849												},
7850											}),
7851										]
7852									})
7853								]
7854							})
7855						);
7856
7857						if(settings.DESCRIPTION)
7858						{
7859							if(settings.DESCRIPTION.length>0)
7860							{
7861								propContainer.appendChild(
7862									BX.create('DIV', {
7863										props: 
7864										{
7865											className: "soa-description align-self-center col-md-6 col-12"
7866										},
7867										html: settings.DESCRIPTION
7868									})
7869								);
7870							}
7871						}
7872					}
7873				}
7874			}
7875
7876			
7877		},
7878
7879		insertEnumProperty: function(property, propsItemNode, disabled)
7880		{
7881			var prop, inputs, values, i, propContainer;
7882
7883			if (disabled)
7884			{
7885				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7886				if (prop)
7887				{
7888					values = [];
7889					inputs = prop.querySelectorAll('input[type=radio]');
7890					if (inputs.length)
7891					{
7892						for (i = 0; i < inputs.length; i++)
7893						{
7894							if (inputs[i].checked)
7895								values.push(inputs[i].nextSibling.nodeValue);
7896						}
7897					}
7898					inputs = prop.querySelectorAll('option');
7899					if (inputs.length)
7900					{
7901						for (i = 0; i < inputs.length; i++)
7902						{
7903							if (inputs[i].selected)
7904								values.push(inputs[i].innerHTML);
7905						}
7906					}
7907
7908					propsItemNode.innerHTML += this.valuesToString(values);
7909				}
7910			}
7911			else
7912			{
7913				propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7914				property.appendTo(propContainer);
7915				propsItemNode.appendChild(propContainer);
7916				this.bindValidation(property.getId(), propContainer);
7917				this.remakeInputs(property.getSettings(), propContainer);
7918			}
7919		},
7920
7921		insertYNProperty: function(property, propsItemNode, disabled)
7922		{
7923			var prop, inputs, values, i, propContainer;
7924
7925			if (disabled)
7926			{
7927				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7928				if (prop)
7929				{
7930					values = [];
7931					inputs = prop.querySelectorAll('input[type=checkbox]');
7932
7933					for (i = 0; i < inputs.length; i+=2)
7934						values.push(inputs[i].checked ? BX.message('SOA_YES') : BX.message('SOA_NO'));
7935
7936					propsItemNode.innerHTML += this.valuesToString(values);
7937				}
7938			}
7939			else
7940			{
7941				propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7942				property.appendTo(propContainer);
7943				propsItemNode.appendChild(propContainer);
7944				this.alterProperty(property.getSettings(), propContainer);
7945				this.bindValidation(property.getId(), propContainer);
7946				this.remakeInputs(property.getSettings(), propContainer);
7947			}
7948		},
7949
7950		insertNumberProperty: function(property, propsItemNode, disabled)
7951		{
7952			var prop, inputs, values, i, propContainer;
7953
7954			if (disabled)
7955			{
7956				prop = this.propsHiddenBlockNode.querySelector('div[data-property-id-row="' + property.getId() + '"]');
7957				if (prop)
7958				{
7959					values = [];
7960					inputs = prop.querySelectorAll('input[type=text]');
7961
7962					for (i = 0; i < inputs.length; i++)
7963						if (inputs[i].value.length)
7964							values.push(inputs[i].value);
7965
7966					propsItemNode.innerHTML += this.valuesToString(values);
7967				}
7968			}
7969			else
7970			{
7971				propContainer = BX.create('DIV', {props: {className: 'soa-property-container row'}});
7972				property.appendTo(propContainer);
7973				propsItemNode.appendChild(propContainer);
7974				this.alterProperty(property.getSettings(), propContainer);
7975				this.bindValidation(property.getId(), propContainer);
7976				this.remakeInputs(property.getSettings(), propContainer);
7977			}
7978		},
7979
7980		valuesToString: function(values)
7981		{
7982			var str = values.join(', ');
7983
7984			return str.length ? BX.util.htmlspecialchars(str) : BX.message('SOA_NOT_SELECTED');
7985		},
7986
7987		alterProperty: function(settings, propContainer)
7988		{
7989			var divs = BX.findChildren(propContainer, {tagName: 'DIV'}),
7990				i, textNode, inputs, del, add,
7991				fileInputs, accepts, fileTitles;
7992
7993			/*if (divs && divs.length)
7994			{
7995				for (i = 0; i < divs.length; i++)
7996				{
7997					divs[i].style.margin = '5px 0';
7998				}
7999			}*/
8000
8001			textNode = propContainer.querySelector('input[type=text]');
8002			if (!textNode)
8003				textNode = propContainer.querySelector('textarea');
8004
8005
8006
8007			if (textNode)
8008			{
8009				textNode.id = 'soa-property-' + settings.ID;
8010				if (settings.IS_ADDRESS == 'Y')
8011					textNode.setAttribute('autocomplete', 'address');
8012				if (settings.IS_EMAIL == 'Y')
8013					textNode.setAttribute('autocomplete', 'email');
8014				if (settings.IS_PAYER == 'Y')
8015					textNode.setAttribute('autocomplete', 'name');
8016				if (settings.IS_PHONE == 'Y')
8017					textNode.setAttribute('autocomplete', 'tel');
8018
8019				if (settings.PATTERN && settings.PATTERN.length)
8020				{
8021					textNode.removeAttribute('pattern');
8022				}
8023			}
8024
8025			inputs = propContainer.querySelectorAll('input[type=text]');
8026			for (i = 0; i < inputs.length; i++)
8027			{
8028				/*inputs[i].placeholder = settings.DESCRIPTION;*/
8029				BX.addClass(inputs[i], 'bx-form-control bx-soa-customer-input bx-ios-fix focus-anim bord-1 b-ra ' + (settings.REQUIRED == 'Y' ? 'text-require': '') + (settings.IS_PHONE == "Y" ? ' phone ': ''));
8030			}
8031
8032			inputs = propContainer.querySelectorAll('select');
8033			for (i = 0; i < inputs.length; i++)
8034				BX.addClass(inputs[i], 'bx-form-control');
8035
8036			inputs = propContainer.querySelectorAll('textarea');
8037			for (i = 0; i < inputs.length; i++)
8038			{
8039				/*inputs[i].placeholder = settings.DESCRIPTION;*/
8040				BX.addClass(inputs[i], 'bx-form-control bx-ios-fix focus-anim bord-1 b-ra ' +(settings.REQUIRED == 'Y' ? "text-require": ""));
8041			}
8042
8043			del = propContainer.querySelectorAll('label');
8044			for (i = 0; i < del.length; i++)
8045				BX.remove(del[i]);
8046
8047			if (settings.TYPE == 'FILE')
8048			{
8049				if (settings.ACCEPT && settings.ACCEPT.length)
8050				{
8051					fileInputs = propContainer.querySelectorAll('input[type=file]');
8052					accepts = this.getFileAccepts(settings.ACCEPT);
8053					for (i = 0; i < fileInputs.length; i++)
8054						fileInputs[i].setAttribute('accept', accepts);
8055				}
8056
8057				fileTitles = propContainer.querySelectorAll('a');
8058				for (i = 0; i < fileTitles.length; i++)
8059				{
8060					BX.bind(fileTitles[i], 'click', function(e){
8061						var target = e.target || e.srcElement,
8062							fileInput = target && target.nextSibling && target.nextSibling.nextSibling;
8063
8064						if (fileInput)
8065							BX.fireEvent(fileInput, 'change');
8066					});
8067				}
8068			}
8069
8070			add = propContainer.querySelectorAll('input[type=button]');
8071			for (i = 0; i < add.length; i++)
8072			{
8073				BX.addClass(add[i], 'btn btn-default btn-sm');
8074
8075				if (settings.MULTIPLE == 'Y' && i == add.length - 1)
8076					continue;
8077
8078				if (settings.TYPE == 'FILE')
8079				{
8080					BX.prepend(add[i], add[i].parentNode);
8081					add[i].style.marginRight = '10px';
8082				}
8083			}
8084
8085			if (add.length)
8086			{
8087				add = add[add.length - 1];
8088				BX.bind(add, 'click', BX.delegate(function(e){
8089					var target = e.target || e.srcElement,
8090						targetContainer = BX.findParent(target, {tagName: 'div', className: 'soa-property-container'}),
8091						del = targetContainer.querySelector('label'),
8092						add = targetContainer.querySelectorAll('input[type=button]'),
8093						textInputs = targetContainer.querySelectorAll('input[type=text]'),
8094						textAreas = targetContainer.querySelectorAll('textarea'),
8095						divs = BX.findChildren(targetContainer, {tagName: 'DIV'});
8096
8097
8098
8099					var i, fileTitles, fileInputs, accepts;
8100
8101					/*if (divs && divs.length)
8102					{
8103						for (i = 0; i < divs.length; i++)
8104						{
8105							divs[i].style.margin = '5px 0';
8106						}
8107					}*/
8108
8109					this.bindValidation(settings.ID, targetContainer);
8110
8111					if (add.length && add[add.length - 2])
8112					{
8113						BX.prepend(add[add.length - 2], add[add.length - 2].parentNode);
8114						/*add[add.length - 2].style.marginRight = '10px';*/
8115						BX.addClass(add[add.length - 2], 'btn btn-default btn-sm');
8116					}
8117
8118					del && BX.remove(del);
8119					if (textInputs.length)
8120					{
8121						/*textInputs[textInputs.length - 1].placeholder = settings.DESCRIPTION;*/
8122						BX.addClass(textInputs[textInputs.length - 1], 'bx-form-control bx-soa-customer-input bx-ios-fix');
8123
8124						if (settings.TYPE == 'DATE')
8125							this.alterDateProperty(settings, textInputs[textInputs.length - 1]);
8126
8127						if (settings.PATTERN && settings.PATTERN.length)
8128							textInputs[textInputs.length - 1].removeAttribute('pattern');
8129					}
8130
8131					if (textAreas.length)
8132					{
8133						/*textAreas[textAreas.length - 1].placeholder = settings.DESCRIPTION;*/
8134						BX.addClass(textAreas[textAreas.length - 1], 'bx-form-control bx-ios-fix');
8135					}
8136
8137					if (settings.TYPE == 'FILE')
8138					{
8139						if (settings.ACCEPT && settings.ACCEPT.length)
8140						{
8141							fileInputs = propContainer.querySelectorAll('input[type=file]');
8142							accepts = this.getFileAccepts(settings.ACCEPT);
8143							for (i = 0; i < fileInputs.length; i++)
8144								fileInputs[i].setAttribute('accept', accepts);
8145						}
8146
8147						fileTitles = targetContainer.querySelectorAll('a');
8148						BX.bind(fileTitles[fileTitles.length - 1], 'click', function(e){
8149							var target = e.target || e.srcElement,
8150								fileInput = target && target.nextSibling && target.nextSibling.nextSibling;
8151
8152							if (fileInput)
8153								setTimeout(function(){BX.fireEvent(fileInput, 'change');}, 10);
8154						});
8155					}
8156				}, this));
8157			}
8158		},
8159
8160		alterDateProperty: function(settings, inputText)
8161		{
8162
8163
8164			var parentNode = BX.findParent(inputText, {tagName: 'DIV'}),
8165				addon;
8166
8167			/*BX.addClass(parentNode, 'soa-input-group');
8168			addon = BX.create('DIV', {
8169				props: {className: 'input-group-addon'},
8170			});
8171
8172			BX.insertAfter(addon, inputText);*/
8173			BX.remove(parentNode.querySelector('input[type=button]'));
8174			/*BX.bind(addon, 'click', BX.delegate(function(e){
8175				var target = e.target || e.srcElement,
8176					parentNode = BX.findParent(target, {tagName: 'DIV', className: 'soa-input-group'});
8177
8178				BX.calendar({
8179					node: parentNode.querySelector('.input-group-addon'),
8180					field: parentNode.querySelector('input[type=text]').name,
8181					form: '',
8182					bTime: settings.TIME == 'Y',
8183					bHideTime: false
8184				});
8185			}, this));*/
8186		},
8187
8188		isValidForm: function()
8189		{
8190			if (!this.options.propertyValidation)
8191				return true;
8192
8193			var consent = $("#bx-soa-orderSave").find("input.agreecheck");
8194
8195			if (consent.length>0 && !consent.prop("checked")) {
8196	            consent.parents("div.wrap-agree").addClass("has-error");
8197
8198	            formAttentionScroll(consent.parents("div.wrap-agree").offset().top - 140, 
8199            	"html:not(:animated), body:not(:animated)");
8200
8201	            return false;
8202	        }
8203
8204			validForm($('#bx-soa-order-form'));
8205			       
8206
8207			var regionErrors = this.isValidRegionBlock(),
8208				propsErrors = this.isValidPropertiesBlock(),
8209				navigated = false, tooltips, i;
8210
8211			if (regionErrors.length)
8212			{
8213				navigated = true;
8214				this.animateScrollTo(this.regionBlockNode, 800, 50);
8215			}
8216
8217			if (propsErrors.length && !navigated)
8218			{
8219				if (this.activeSectionId == this.propsBlockNode.id)
8220				{
8221					tooltips = this.propsBlockNode.querySelectorAll('div.tooltip');
8222					for (i = 0; i < tooltips.length; i++)
8223					{
8224						if (tooltips[i].getAttribute('data-state') == 'opened')
8225						{
8226							this.animateScrollTo(BX.findParent(tooltips[i], {className: 'bx-form-group bx-soa-customer-field'}), 800, 50);
8227							break;
8228						}
8229					}
8230				}
8231				else
8232					this.animateScrollTo(this.propsBlockNode, 800, 50);
8233			}
8234
8235			if (regionErrors.length)
8236			{
8237				this.showError(this.regionBlockNode, regionErrors);
8238				BX.addClass(this.regionBlockNode, 'bx-step-error');
8239			}
8240
8241			if (propsErrors.length)
8242			{
8243				if (this.activeSectionId !== this.propsBlockNode.id)
8244					this.showError(this.propsBlockNode, propsErrors);
8245
8246				BX.addClass(this.propsBlockNode, 'bx-step-error');
8247			}
8248
8249			return !(regionErrors.length + propsErrors.length);
8250		},
8251
8252		isValidRegionBlock: function()
8253		{
8254			if (!this.options.propertyValidation)
8255				return [];
8256
8257			var regionProps = this.orderBlockNode.querySelectorAll('.bx-soa-location-input-container[data-
8257property-id-row]'),
8258				regionErrors = [],
8259				id, arProperty, data, i;
8260
8261			for (i = 0; i < regionProps.length; i++)
8262			{
8263				id = regionProps[i].getAttribute('data-property-id-row');
8264				arProperty = this.validation.properties[id];
8265				data = this.getValidationData(arProperty, regionProps[i]);
8266
8267				regionErrors = regionErrors.concat(this.isValidProperty(data, true));
8268			}
8269
8270			return regionErrors;
8271		},
8272
8273		isValidPropertiesBlock: function(excludeLocation)
8274		{
8275			if (!this.options.propertyValidation)
8276				return [];
8277
8278			var props = this.orderBlockNode.querySelectorAll('.bx-soa-customer-field[data-property-id-row]'),
8279				propsErrors = [],
8280				id, propContainer, arProperty, data, i;
8281
8282			for (i = 0; i < props.length; i++)
8283			{
8284				id = props[i].getAttribute('data-property-id-row');
8285
8286				if (!!excludeLocation && this.locations[id])
8287					continue;
8288
8289				propContainer = props[i].querySelector('.soa-property-container');
8290				if (propContainer)
8291				{
8292					arProperty = this.validation.properties[id];
8293					data = this.getValidationData(arProperty, propContainer);
8294					propsErrors = propsErrors.concat(this.isValidProperty(data, true));
8295				}
8296			}
8297
8298			return propsErrors;
8299		},
8300
8301		isValidProperty: function(data, fieldName)
8302		{
8303			var propErrors = [], inputErrors, i;
8304
8305			if (!data || !data.inputs)
8306				return propErrors;
8307
8308			for (i = 0; i < data.inputs.length; i++)
8309			{
8310				inputErrors = data.func(data.inputs[i], !!fieldName);
8311				if (inputErrors.length)
8312					propErrors[i] = inputErrors.join('<br>');
8313			}
8314
8315			this.showValidationResult(data.inputs, propErrors);
8316
8317			return propErrors;
8318		},
8319
8320		bindValidation: function(id, propContainer)
8321		{
8322			if (!this.validation.properties || !this.validation.properties[id])
8323				return;
8324
8325			var arProperty = this.validation.properties[id],
8326				data = this.getValidationData(arProperty, propContainer),
8327				i, k;
8328
8329			if (data && data.inputs && data.action)
8330			{
8331				for (i = 0; i < data.inputs.length; i++)
8332				{
8333					if (BX.type.isElementNode(data.inputs[i]))
8334						BX.bind(data.inputs[i], data.action, BX.delegate(function(){
8335							this.isValidProperty(data);
8336						}, this));
8337					else
8338						for (k = 0; k < data.inputs[i].length; k++)
8339							BX.bind(data.inputs[i][k], data.action, BX.delegate(function(){
8340								this.isValidProperty(data);
8341							}, this));
8342				}
8343			}
8344		},
8345
8346		getValidationData: function(arProperty, propContainer)
8347		{
8348			if (!arProperty || !propContainer)
8349				return;
8350
8351			var data = {}, inputs;
8352
8353			switch (arProperty.TYPE)
8354			{
8355				case 'STRING':
8356					data.action = 'change';
8357					data.func = BX.delegate(function(input, fieldName){
8358						return this.validateString(input, arProperty, fieldName);
8359					}, this);
8360
8361					inputs = propContainer.querySelectorAll('input[type=text]');
8362					if (inputs.length)
8363					{
8364						data.inputs = inputs;
8365						break;
8366					}
8367					inputs = propContainer.querySelectorAll('textarea');
8368					if (inputs.length)
8369						data.inputs = inputs;
8370					break;
8371				case 'LOCATION':
8372					data.func = BX.delegate(function(input, fieldName){
8373						return this.validateLocation(input, arProperty, fieldName);
8374					}, this);
8375
8376					inputs = propContainer.querySelectorAll('input.bx-ui-sls-fake[type=text]');
8377					if (inputs.length)
8378					{
8379						data.inputs = inputs;
8380						data.action = 'keyup';
8381						break;
8382					}
8383					inputs = propContainer.querySelectorAll('div.bx-ui-slst-pool');
8384					if (inputs.length)
8385					{
8386						data.inputs = inputs;
8387					}
8388					break;
8389				case 'Y/N':
8390					data.inputs = propContainer.querySelectorAll('input[type=checkbox]');
8391					data.action = 'change';
8392					data.func = BX.delegate(function(input, fieldName){
8393						return this.validateCheckbox(input, arProperty, fieldName);
8394					}, this);
8395					break;
8396				case 'NUMBER':
8397					data.inputs = propContainer.querySelectorAll('input[type=text]');
8398					data.action = 'blur';
8399					data.func = BX.delegate(function(input, fieldName){
8400						return this.validateNumber(input, arProperty, fieldName);
8401					}, this);
8402					break;
8403				case 'ENUM':
8404					inputs = propContainer.querySelectorAll('input[type=radio]');
8405					if (!inputs.length)
8406						inputs = propContainer.querySelectorAll('input[type=checkbox]');
8407
8408					if (inputs.length)
8409					{
8410						data.inputs = [inputs];
8411						data.action = 'change';
8412						data.func = BX.delegate(function(input, fieldName){
8413							return this.validateEnum(input, arProperty, fieldName);
8414						}, this);
8415						break;
8416					}
8417
8418					inputs = propContainer.querySelectorAll('option');
8419					if (inputs.length)
8420					{
8421						data.inputs = [inputs];
8422						data.action = 'click';
8423						data.func = BX.delegate(function(input, fieldName){
8424							return this.validateSelect(input, arProperty, fieldName);
8425						}, this);
8426					}
8427					break;
8428				case 'FILE':
8429					data.inputs = propContainer.querySelectorAll('input[type=file]');
8430					data.action = 'change';
8431					data.func = BX.delegate(function(input, fieldName){
8432						return this.validateFile(input, arProperty, fieldName);
8433					}, this);
8434					break;
8435				case 'DATE':
8436					data.inputs = propContainer.querySelectorAll('input[type=text]');
8437					data.action = 'change';
8438					data.func = BX.delegate(function(input, fieldName){
8439						return this.validateDate(input, arProperty, fieldName);
8440					}, this);
8441					break;
8442			}
8443
8444			return data;
8445		},
8446
8447		showErrorTooltip: function(tooltipId, targetNode, text)
8448		{
8449			if (!tooltipId || !targetNode || !text)
8450				return;
8451
8452			var tooltip = BX('tooltip-' + tooltipId),
8453				tooltipInner, quickLocation;
8454
8455			text = this.uniqueText(text, '<br>');
8456
8457			if (tooltip)
8458			{
8459				tooltipInner = tooltip.querySelector('div.tooltip-inner');
8460			}
8461			else
8462			{
8463				tooltipInner = BX.create('DIV', {props: {className: 'tooltip-inner'}});
8464				tooltip = BX.create('DIV', {
8465					props: {
8466						id: 'tooltip-' + tooltipId,
8467						className: 'bx-soa-tooltip bx-soa-tooltip-static bx-soa-tooltip-danger tooltip top'
8468					},
8469					children: [
8470						BX.create('DIV', {props: {className: 'tooltip-arrow'}}),
8471						tooltipInner
8472					]
8473				});
8474
8475				quickLocation = targetNode.parentNode.querySelector('div.quick-locations');
8476				if (quickLocation)
8477					targetNode = quickLocation;
8478
8479				BX.insertAfter(tooltip, targetNode);
8480			}
8481
8482			tooltipInner.innerHTML = text;
8483
8484			if (tooltip.getAttribute('data-state') != 'opened')
8485			{
8486				tooltip.setAttribute('data-state', 'opened');
8487				tooltip.style.opacity = 0;
8488				tooltip.style.display = 'block';
8489
8490				new BX.easing({
8491					duration: 150,
8492					start: {opacity: 0},
8493					finish: {opacity: 100},
8494					transition: BX.easing.transitions.quad,
8495					step: function(state){
8496						tooltip.style.opacity = state.opacity / 100;
8497					}
8498				}).animate();
8499			}
8500		},
8501
8502		closeErrorTooltip: function(tooltipId)
8503		{
8504			var tooltip = BX('tooltip-' + tooltipId);
8505			if (tooltip)
8506			{
8507				tooltip.setAttribute('data-state', 'closed');
8508
8509				new BX.easing({
8510					duration: 150,
8511					start: {opacity: 100},
8512					finish: {opacity: 0},
8513					transition: BX.easing.transitions.quad,
8514					step: function(state){
8515						tooltip.style.opacity = state.opacity / 100;
8516					},
8517					complete: function(){
8518						tooltip.style.display = 'none';
8519					}
8520				}).animate();
8521			}
8522		},
8523
8524		showValidationResult: function(inputs, errors)
8525		{
8526			if (!inputs || !inputs.length || !errors)
8527				return;
8528
8529			var input0 = BX.type.isElementNode(inputs[0]) ? inputs[0] : inputs[0][0],
8530				formGroup = BX.findParent(input0, {tagName: 'DIV', className: 'bx-form-group'}),
8531				label = formGroup.querySelector('label'),
8532				tooltipId, inputDiv, i;
8533
8534			if (label)
8535				tooltipId = label.getAttribute('for');
8536
8537			for (i = 0; i < inputs.length; i++)
8538			{
8539				inputDiv = BX.findParent(inputs[i], {tagName: 'DIV', className: 'bx-form-group'});
8540				if (errors[i] && errors[i].length)
8541					BX.addClass(inputDiv, 'has-error');
8542				else
8543					BX.removeClass(inputDiv, 'has-error');
8544			}
8545
8546			if (errors.length)
8547				this.showErrorTooltip(tooltipId, label, errors.join('<br>'));
8548			else
8549				this.closeErrorTooltip(tooltipId);
8550		},
8551
8552		validateString: function(input, arProperty, fieldName)
8553		{
8554			if (!input || !arProperty)
8555				return [];
8556
8557			var value = input.value,
8558				errors = [],
8559				name = BX.util.htmlspecialchars(arProperty.NAME),
8560				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + name + '"' : BX.message('SOA_FIELD'),
8561				re;
8562
8563			if (arProperty.MULTIPLE === 'Y')
8564				return errors;
8565
8566			if (arProperty.REQUIRED === 'Y' && value.length === 0)
8567				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8568
8569			if (value.length)
8570			{
8571				if (arProperty.MINLENGTH && arProperty.MINLENGTH > value.length)
8572					errors.push(BX.message('SOA_MIN_LENGTH') + ' "' + name + '" ' + BX.message('SOA_LESS') + ' ' + arProperty.MINLENGTH + ' ' + BX.message('SOA_SYMBOLS'));
8573
8574				if (arProperty.MAXLENGTH && arProperty.MAXLENGTH < value.length)
8575					errors.push(BX.message('SOA_MAX_LENGTH') + ' "' + name + '" ' + BX.message('SOA_MORE') + ' ' + arProperty.MAXLENGTH + ' ' + BX.message('SOA_SYMBOLS'));
8576
8577				if (arProperty.IS_EMAIL === 'Y')
8578				{
8579					input.value = value = BX.util.trim(value);
8580					if (value.length)
8581					{
8582						re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
8583						if (!re.test(value))
8584						{
8585							errors.push(BX.message('SOA_INVALID_EMAIL'));
8586						}
8587					}
8588				}
8589
8590				if (value.length > 0 && arProperty.PATTERN && arProperty.PATTERN.length)
8591				{
8592					re = new RegExp(arProperty.PATTERN);
8593					if (!re.test(value))
8594						errors.push(field + ' ' + BX.message('SOA_INVALID_PATTERN'));
8595				}
8596			}
8597
8598			return errors;
8599		},
8600
8601		validateLocation: function(input, arProperty, fieldName)
8602		{
8603			if (!input || !arProperty)
8604				return [];
8605
8606			var parent = BX.findParent(input, {tagName: 'DIV', className: 'bx-form-group'}),
8607				value = this.getLocationString(parent),
8608				errors = [],
8609				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + BX.util.htmlspecialchars(arProperty.NAME) + '"' : BX.message('SOA_FIELD');
8610
8611			if (arProperty.MULTIPLE == 'Y' && arProperty.IS_LOCATION !== 'Y')
8612				return errors;
8613
8614			if (arProperty.REQUIRED == 'Y' && (value.length == 0 || value == BX.message('SOA_NOT_SPECIFIED')))
8615				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8616
8617			return errors;
8618		},
8619
8620		validateCheckbox: function(input, arProperty, fieldName)
8621		{
8622			if (!input || !arProperty)
8623				return [];
8624
8625			var errors = [],
8626				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + BX.util.htmlspecialchars(arProperty.NAME) + '"' : BX.message('SOA_FIELD');
8627
8628			if (arProperty.MULTIPLE == 'Y')
8629				return errors;
8630
8631			if (arProperty.REQUIRED == 'Y' && !input.checked)
8632				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8633
8634			return errors;
8635		},
8636
8637		validateNumber: function(input, arProperty, fieldName)
8638		{
8639			if (!input || !arProperty)
8640				return [];
8641
8642			var value = input.value,
8643				errors = [],
8644				name = BX.util.htmlspecialchars(arProperty.NAME),
8645				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + name + '"' : BX.message('SOA_FIELD'),
8646				num, del;
8647
8648			if (arProperty.MULTIPLE == 'Y')
8649				return errors;
8650
8651			if (arProperty.REQUIRED == 'Y' && value.length == 0)
8652				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8653
8654			if (value.length)
8655			{
8656				if (!/[0-9]|\./.test(value))
8657					errors.push(field + ' ' + BX.message('SOA_NOT_NUMERIC'));
8658
8659				if (arProperty.MIN && parseFloat(arProperty.MIN) > parseFloat(value))
8660					errors.push(BX.message('SOA_MIN_VALUE') + ' "' + name + '" ' + parseFloat(arProperty.MIN));
8661
8662				if (arProperty.MAX && parseFloat(arProperty.MAX) < parseFloat(value))
8663					errors.push(BX.message('SOA_MAX_VALUE') + ' "' + name + '" ' + parseFloat(arProperty.MAX));
8664
8665				if (arProperty.STEP && parseFloat(arProperty.STEP) > 0)
8666				{
8667					num = Math.abs(parseFloat(value) - (arProperty.MIN && parseFloat(arProperty.MIN) > 0 ? parseFloat(arProperty.MIN) : 0));
8668					del = (num / parseFloat(arProperty.STEP)).toPrecision(12);
8669					if (del != parseInt(del))
8670						errors.push(field + ' ' + BX.message('SOA_NUM_STEP') + ' ' + arProperty.STEP);
8671				}
8672			}
8673
8674			return errors;
8675		},
8676
8677		validateEnum: function(inputs, arProperty, fieldName)
8678		{
8679			if (!inputs || !arProperty)
8680				return [];
8681
8682			var values = [], errors = [], i,
8683				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + BX.util.htmlspecialchars(arProperty.NAME) + '"' : BX.message('SOA_FIELD');
8684
8685			if (arProperty.MULTIPLE == 'Y')
8686				return errors;
8687
8688			for (i = 0; i < inputs.length; i++)
8689				if (inputs[i].checked || inputs[i].selected)
8690					values.push(i);
8691
8692			if (arProperty.REQUIRED == 'Y' && values.length == 0)
8693				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8694
8695			return errors;
8696		},
8697
8698		validateSelect: function(inputs, arProperty, fieldName)
8699		{
8700			if (!inputs || !arProperty)
8701				return [];
8702
8703			var values = [], errors = [], i,
8704				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + BX.util.htmlspecialchars(arProperty.NAME) + '"' : BX.message('SOA_FIELD');
8705
8706			if (arProperty.MULTIPLE == 'Y')
8707				return errors;
8708
8709			for (i = 0; i < inputs.length; i++)
8710				if (inputs[i].selected)
8711					values.push(i);
8712
8713			if (arProperty.REQUIRED == 'Y' && values.length == 0)
8714				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8715
8716			return errors;
8717		},
8718
8719		validateFile: function(inputs, arProperty, fieldName)
8720		{
8721			if (!inputs || !arProperty)
8722				return [];
8723
8724			var errors = [], i,
8725				files = inputs.files || [],
8726				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + BX.util.htmlspecialchars(arProperty.NAME) + '"' : BX.message('SOA_FIELD'),
8727				defaultValue = inputs.previousSibling.value,
8728				file, fileName, splittedName, fileExtension;
8729
8730			if (arProperty.MULTIPLE == 'Y')
8731				return errors;
8732
8733			if (
8734				arProperty.REQUIRED == 'Y' && files.length == 0 && defaultValue == ''
8735				&& (!arProperty.DEFAULT_VALUE || !arProperty.DEFAULT_VALUE.length)
8736			)
8737			{
8738				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8739			}
8740			else
8741			{
8742				for (i = 0; i < files.length; i++)
8743				{
8744					file = files[i];
8745					fileName = BX.util.htmlspecialchars(file.name);
8746					splittedName = file.name.split('.');
8747					fileExtension = splittedName.length > 1 ? splittedName[splittedName.length - 1].toLowerCase() : '';
8748
8749					if (arProperty.ACCEPT.length > 0 && (fileExtension.length == 0 || arProperty.ACCEPT.indexOf(fileExtension) == '-1'))
8750						errors.push(BX.message('SOA_BAD_EXTENSION') + ' "' + fileName + '" (' + BX.util.htmlspecialchars(arProperty.ACCEPT) + ')');
8751
8752					if (file.size > parseInt(arProperty.MAXSIZE))
8753						errors.push(BX.message('SOA_MAX_SIZE') + ' "' + fileName + '" (' + this.get
8753SizeString(arProperty.MAXSIZE, 1) + ')');
8754				}
8755			}
8756
8757			return errors;
8758		},
8759
8760		validateDate: function(input, arProperty, fieldName)
8761		{
8762			if (!input || !arProperty)
8763				return [];
8764
8765			var value = input.value,
8766				errors = [],
8767				name = BX.util.htmlspecialchars(arProperty.NAME),
8768				field = !!fieldName ? BX.message('SOA_FIELD') + ' "' + name + '"' : BX.message('SOA_FIELD');
8769
8770			if (arProperty.MULTIPLE == 'Y')
8771				return errors;
8772
8773			if (arProperty.REQUIRED == 'Y' && value.length == 0)
8774				errors.push(field + ' ' + BX.message('SOA_REQUIRED'));
8775
8776			return errors;
8777		},
8778
8779		editPropsMap: function(propsNode)
8780		{
8781			var propsMapContainer = BX.create('DIV', {props: {className: 'col-12'}, style: {marginBottom: '0'}}),
8782				map = BX.create('DIV', {props: {id: 'propsMap'}, style: {width: '100%'}});
8783
8784			propsMapContainer.appendChild(map);
8785			propsNode.appendChild(propsMapContainer);
8786		},
8787
8788		editPropsComment: function(propsNode)
8789		{
8790			var propsCommentContainer, label, input, div;
8791
8792
8793			propsCommentContainer = BX.create('DIV', {props: {className: 'col-12'}});
8794
8795			
8796			
8797			input = BX.create('TEXTAREA', {
8798				props: {
8799					id: 'orderDescription',
8800					className: 'bx-form-control bx-soa-customer-textarea bx-ios-fix focus-anim bord-1 b-ra',
8801					name: 'ORDER_DESCRIPTION'
8802				},
8803				text: this.result.ORDER_DESCRIPTION ? this.result.ORDER_DESCRIPTION : ''
8804			});
8805			div = BX.create('DIV', {
8806				props: {className: 'bx-form-group bx-soa-customer-field textarea-simple inp-small no-mg '+(this.result.ORDER_DESCRIPTION ? 'in-focus': '')},
8807				children: [
8808					BX.create('DIV', {
8809						props: {className: 'bg'},
8810					}),
8811					BX.create('SPAN', {
8812						props: {className: 'desc'},
8813						html: this.params.MESS_ORDER_DESC
8814					}),
8815					input
8816				]
8817			});
8818
8819			propsCommentContainer.appendChild(div);
8820			propsNode.appendChild(propsCommentContainer);
8821		},
8822
8823		emptyBasketHTML: function(countProduct){
8824			if(countProduct <= 0)
8825			{
8826				$("#bx-soa-total").find(".group-info").addClass('d-none');
8827				$("#bx-soa-total").find(".wr-price").addClass('d-none');
8828				$("#bx-soa-total").find(".wr-coupon-container").addClass('d-none');
8829				$("#bx-soa-total").find(".basket-buttons").addClass('d-none');
8830
8831				if(this.minSumValue)
8832					$("#bx-soa-total").find(".alert-message-min-sum").removeClass('d-none');
8833				
8834
8835				
8836			}
8837			
8838			else{
8839				$("#bx-soa-total").find(".group-info").removeClass('d-none');
8840				$("#bx-soa-total").find(".wr-price").removeClass('d-none');
8841				$("#bx-soa-total").find(".wr-coupon-container").removeClass('d-none');
8842				$("#bx-soa-total").find(".basket-buttons").removeClass('d-none');
8843
8844				if(this.minSumValue)
8845					$("#bx-soa-total").find(".alert-message-min-sum").addClass('d-none');
8846				
8847
8848				
8849			}
8850		},
8851
8852		editTotalBlock: function()
8853		{
8854			/*if (!this.totalInfoBlockNode || !this.result.TOTAL)
8855				return;*/
8856
8857			var total = this.result.TOTAL,
8858				priceHtml, params = {},
8859				discText, valFormatted, i,
8860				curDelivery, deliveryError, deliveryValue,
8861				showOrderButton = this.params.SHOW_TOTAL_ORDER_BUTTON === 'Y',
8862				tmpNode, tmpHTML;
8863
8864			var countProduct = 0;
8865
8866			for (i in this.result.GRID.ROWS)
8867			{
8868				countProduct++;
8869			} 
8870
8871			this.emptyBasketHTML(countProduct);
8872			
8873
8874			total.ORDER_PRICE = parseFloat(total.ORDER_PRICE);
8875			total.DISCOUNT_PRICE = parseFloat(total.DISCOUNT_PRICE);
8876			total.ORDER_WEIGHT = parseFloat(total.ORDER_WEIGHT);
8877			total.DELIVERY_PRICE = parseFloat(total.DELIVERY_PRICE);
8878
8879
8880
8881			tmpNode = null;
8882			tmpHTML = "";
8883
8884
8885
8886			tmpHTML = "<div class=\"item row no-gutters no-margin side-sum-row\">"
8887						+ "<div class=\"col-auto\"><div class=\"name\">"+BX.message("ORDER_SIDE_SUM_PRODUCTS")+"</div></div>"
8888						+ "<div class=\"col\"><div class=\"h-100 dotts\"></div></div>"
8889						+ "<div class=\"col-auto bold\"><div class=\"value\">"+total.PRICE_WITHOUT_DISCOUNT+"</div></div>"
8890						+ "</div>";
8891
8892
8893			if(total.DISCOUNT_PRICE > 0)
8894			{
8895				tmpHTML += "<div class=\"item row no-gutters no-margin discount-row\">"
8896						+ "<div class=\"col-auto\"><div class=\"name\">"+BX.message("ORDER_SIDE_DISCOUNT_SUM_PRODUCTS")+"</div></div>"
8897						+ "<div class=\"col\"><div class=\"h-100 dotts\"></div></div>"
8898						+ "<div class=\"col-auto bold\"><div class=\"value txt-green\">&minus;"+total.DISCOUNT_PRICE_FORMATED+"</div></div>"
8899						+ "</div>";
8900			}
8901
8902
8903			curDelivery = this.getSelectedDelivery();
8904
8905			if(curDelivery)
8906			{
8907				deliveryError = curDelivery && curDelivery.CALCULATE_ERRORS && curDelivery.CALCULATE_ERRORS.length;
8908
8909				if (deliveryError)
8910				{
8911					deliveryValue = BX.message('SOA_NOT_CALCULATED');
8912				}
8913				else
8914				{
8915					if (parseFloat(total.DELIVERY_PRICE) === 0)
8916					{
8917						deliveryValue = "<span class=\"bold txt-green\">"+this.params.MESS_PRICE_FREE+"</span>";
8918					}
8919					else
8920					{
8921						deliveryValue = "<span class=\"bold\">"+total.DELIVERY_PRICE_FORMATED+"</span>";
8922					}
8923
8924					if (
8925						curDelivery && typeof curDelivery.DELIVERY_DISCOUNT_PRICE !== 'undefined'
8926						&& parseFloat(curDelivery.PRICE) > parseFloat(curDelivery.DELIVERY_DISCOUNT_PRICE)
8927					)
8928					{
8929						deliveryValue = "<span class=\"txt-strike\">"+curDelivery.PRICE_FORMATED + "</span>&nbsp&nbsp" + deliveryValue;
8930					}
8931				}
8932
8933				
8934				tmpHTML += "<div class=\"item row no-gutters no-margin delivery-row\">"
8935						+ "<div class=\"col-auto\"><div class=\"name\">"+BX.message("ORDER_SIDE_SUM_DELIVERY")+"</div></div>"
8936						+ "<div class=\"col\"><div class=\"h-100 dotts\"></div></div>"
8937						+ "<div class=\"col-auto\"><div class=\"value\">"+deliveryValue+"</div></div>"
8938						+ "</div>";
8939				
8940
8941			}
8942
8943			if (this.options.showPayedFromInnerBudget)
8944			{
8945				tmpHTML += "<div class=\"item row no-gutters no-margin sum-it-row\">"
8946						+ "<div class=\"col-auto\"><div class=\"name\">"+BX.message("SOA_SUM_IT")+"</div></div>"
8947						+ "<div class=\"col\"><div class=\"h-100 dotts\"></div></div>"
8948						+ "<div class=\"col-auto bold\"><div class=\"value\">"+total.ORDER_TOTAL_PRICE_FORMATED+"</div></div>"
8949						+ "</div>";
8950
8951				tmpHTML += "<div class=\"item row no-gutters no-margin sum-payed-row\">"
8952						+ "<div class=\"col-auto\"><div class=\"name\">"+BX.message("SOA_SUM_PAYED")+"</div></div>"
8953						+ "<div class=\"col\"><div class=\"h-100 dotts\"></div></div>"
8954						+ "<div class=\"col-auto bold\"><div class=\"value\">"+total.PAYED_FROM_ACCOUNT_FORMATED+"</div></div>"
8955						+ "</div>";
8956
8957				$("#bx-soa-total").find(".total-price").html(total.ORDER_TOTAL_LEFT_TO_PAY_FORMATED);
8958
8959			}
8960			else
8961			{
8962				$("#bx-soa-total").find(".total-price").html(total.ORDER_TOTAL_PRICE_FORMATED);
8963			}
8964
8965			tmpNode = $("#bx-soa-total").find(".group-info");
8966
8967			
8968
8969			tmpNode.html(tmpHTML);
8970
8971
8972
8973			tmpNode = null;
8974			tmpHTML = null;
8975
8976			tmpNode = $("#bx-soa-total").find(".pre-desc");
8977			tmpNode.text("");
8978
8979			if (this.options.showPayedFromInnerBudget)
8980			{
8981				tmpHTML = BX.message("SOA_SUM_LEFT_TO_PAY");
8982			}
8983			else
8984			{
8985				tmpHTML = BX.message("ORDER_TOTAL_TITLE");
8986			}
8987
8988			tmpNode.html(tmpHTML);
8989			
8990
8991			tmpNode = null;
8992			tmpHTML = null;
8993
8994			tmpNode = $("#bx-soa-total").find(".buttons");
8995
8996			if(this.minSumValue)
8997			{
8998				if(this.minSumValue <= total.ORDER_PRICE)
8999				{
9000					tmpNode.removeClass('d-none');
9001					$("#bx-soa-total").find(".alert-message-min-sum").addClass("d-none");
9002					$("#bx-soa-orderSave").removeClass("d-none");
9003					$(".clear-basket-node-control").removeClass('hidden');
9004					$("#bx-soa-order").removeClass('d-none');
9005				}
9006				
9007				else
9008				{
9009					tmpNode.addClass('d-none');
9010					$("#bx-soa-total").find(".alert-message-min-sum").removeClass("d-none");
9011					$("#bx-soa-orderSave").addClass("d-none");
9012					$(".clear-basket-node-control").addClass('hidden');
9013					$("#bx-soa-order").addClass('d-none');
9014				}
9015			}
9016			else
9017			{
9018				tmpNode.removeClass('d-none');
9019				$("#bx-soa-orderSave").removeClass("d-none");
9020			}
9021
9022
9023			tmpNode = null;
9024			if(this.result.SHOW_AUTH)
9025			{
9026				$("#bx-soa-total").find(".basket-buttons").addClass('d-none');
9027				$(".callFastOrder").addClass('d-none');
9028			}
9029			
9030			
9031		},
9032
9033		editMobileTotalBlock: function()
9034		{
9035			if (this.result.SHOW_AUTH)
9036				BX.removeClass(this.mobileTotalBlockNode, 'visible-xs');
9037			else
9038				BX.addClass(this.mobileTotalBlockNode, 'visible-xs');
9039
9040			BX.cleanNode(this.mobileTotalBlockNode);
9041			this.mobileTotalBlockNode.appendChild(this.totalInfoBlockNode.cloneNode(true));
9042			BX.bind(this.mobileTotalBlockNode.querySelector('a.bx-soa-price-not-calc'), 'click', BX.delegate(function(){
9043				this.animateScrollTo(this.deliveryBlockNode);
9044			}, this));
9045			BX.bind(this.mobileTotalBlockNode.querySelector('a.btn-order-save'), 'click', BX.proxy(this.clickOrderSaveAction, this));
9046		},
9047
9048		createTotalUnit: function(name, value, params)
9049		{
9050			var totalValue, className = 'bx-soa-cart-total-line';
9051
9052			name = name || '';
9053			value = value || '';
9054			params = params || {};
9055
9056			if (params.error)
9057			{
9058				totalValue = [BX.create('A', {
9059					props: {className: 'bx-soa-price-not-calc'},
9060					html: value,
9061					events: {
9062						click: BX.delegate(function(){
9063							this.animateScrollTo(this.deliveryBlockNode);
9064						}, this)
9065					}
9066				})];
9067			}
9068			else if (params.free)
9069			{
9070				totalValue = [BX.create('SPAN', {
9071					props: {className: 'bx-soa-price-free'},
9072					html: value
9073				})];
9074			}
9075			else
9076			{
9077				totalValue = [value];
9078			}
9079
9080			if (params.total)
9081			{
9082				className += ' bx-soa-cart-total-line-total';
9083			}
9084
9085			if (params.highlighted)
9086			{
9087				className += ' bx-soa-cart-total-line-highlighted';
9088			}
9089
9090			return BX.create('DIV', {
9091				props: {className: className},
9092				children: [
9093					BX.create('SPAN', {props: {className: 'bx-soa-cart-t'}, text: name}),
9094					BX.create('SPAN', {
9095						props: {
9096							className: 'bx-soa-cart-d' + (!!params.total && this.options.totalPriceChanged ? ' bx-soa-changeCostSign' : '')
9097						},
9098						children: totalValue
9099					})
9100				]
9101			});
9102		},
9103
9104		basketBlockScrollCheckEvent: function(e)
9105		{
9106			var target = e.target || e.srcElement,
9107				scrollLeft = target.scrollLeft,
9108				scrollRight = target.scrollWidth - (scrollLeft + target.clientWidth),
9109				parent = target.parentNode;
9110
9111			if (scrollLeft == 0)
9112				BX.removeClass(parent, 'bx-soa-table-fade-left');
9113			else
9114				BX.addClass(parent, 'bx-soa-table-fade-left');
9115
9116			if (scrollRight == 0)
9117				BX.removeClass(parent, 'bx-soa-table-fade-right');
9118			else
9119				BX.addClass(parent, 'bx-soa-table-fade-right');
9120		},
9121
9122		basketBlockScrollCheck: function()
9123		{
9124			var scrollableNodes = this.orderBlockNode.querySelectorAll('div.bx-soa-table-fade'),
9125				parentNode, parentWidth, tableNode, tableWidth,
9126				i, scrollNode, scrollLeft, scrollRight, scrollable = false;
9127
9128			for (i = 0; i < scrollableNodes.length; i++)
9129			{
9130				parentNode = scrollableNodes[i];
9131				tableNode = parentNode.querySelector('div.bx-soa-item-table');
9132				parentWidth = parentNode.clientWidth;
9133				tableWidth = tableNode.clientWidth || 0;
9134				scrollable = scrollable || tableWidth > parentWidth;
9135
9136				if (scrollable)
9137				{
9138					scrollNode = BX.firstChild(parentNode);
9139					scrollLeft = scrollNode.scrollLeft;
9140					scrollRight = scrollNode.scrollWidth - (scrollLeft + scrollNode.clientWidth);
9141
9142					if (scrollLeft == 0)
9143						BX.removeClass(parentNode, 'bx-soa-table-fade-left');
9144					else
9145						BX.addClass(parentNode, 'bx-soa-table-fade-left');
9146
9147					if (scrollRight == 0)
9148						BX.removeClass(parentNode, 'bx-soa-table-fade-right');
9149					else
9150						BX.addClass(parentNode, 'bx-soa-table-fade-right');
9151
9152					if (scrollLeft == 0 && scrollRight == 0)
9153						BX.addClass(parentNode, 'bx-soa-table-fade-right');
9154				}
9155				else
9156					BX.removeClass(parentNode, 'bx-soa-table-fade-left bx-soa-table-fade-right');
9157			}
9158		},
9159
9160		/*totalBlockScrollCheck: function()
9161		{
9162			if (!this.totalInfoBlockNode || !this.totalGhostBlockNode)
9163				return;
9164
9165			var scrollTop = BX.GetWindowScrollPos().scrollTop,
9166				ghostTop = BX.pos(this.totalGhostBlockNode).top,
9167				ghostBottom = BX.pos(this.orderBlockNode).bottom,
9168				width;
9169
9170			if (ghostBottom - this.totalBlockNode.offsetHeight < scrollTop + 20)
9171				BX.addClass(this.totalInfoBlockNode, 'bx-soa-cart-total-bottom');
9172			else
9173				BX.removeClass(this.totalInfoBlockNode, 'bx-soa-cart-total-bottom');
9174
9175			if (scrollTop > ghostTop && !BX.hasClass(this.totalInfoBlockNode, 'bx-soa-cart-total-fixed'))
9176			{
9177				width = this.totalInfoBlockNode.offsetWidth;
9178				BX.addClass(this.totalInfoBlockNode, 'bx-soa-cart-total-fixed');
9179				this.totalGhostBlockNode.style.paddingTop = this.totalInfoBlockNode.offsetHeight + 'px';
9180				this.totalInfoBlockNode.style.width = width + 'px';
9181			}
9182			else if (scrollTop < ghostTop && BX.hasClass(this.totalInfoBlockNode, 'bx-soa-cart-total-fixed'))
9183			{
9184				BX.removeClass(this.totalInfoBlockNode, 'bx-soa-cart-total-fixed');
9185				this.totalGhostBlockNode.style.paddingTop = 0;
9186				this.totalInfoBlockNode.style.width = '';
9187			}
9188		},*/
9189
9190		/*totalBlockResizeCheck: function()
9191		{
9192			if (!this.totalInfoBlockNode || !this.totalGhostBlockNode)
9193				return;
9194
9195			if (BX.hasClass(this.totalInfoBlockNode, 'bx-soa-cart-total-fixed'))
9196				this.totalInfoBlockNode.style.width = this.totalGhostBlockNode.offsetWidth + 'px';
9197		},*/
9198
9199		/*totalBlockFixFont: function()
9200		{
9201			var totalNode = this.totalInfoBlockNode.querySelector('.bx-soa-cart-total-line.bx-soa-cart-total-line-total'),
9202				buttonNode, target, objList = [];
9203
9204			if (totalNode)
9205			{
9206				target = BX.lastChild(totalNode);
9207				objList.push({
9208					node: target,
9209					maxFontSize: 28,
9210					smallestValue: false,
9211					scaleBy: target.parentNode
9212				});
9213			}
9214
9215			if (this.params.SHOW_TOTAL_ORDER_BUTTON == 'Y')
9216			{
9217				buttonNode = this.totalInfoBlockNode.querySelector('.bx-soa-cart-total-button-container');
9218				if (buttonNode)
9219				{
9220					target = BX.lastChild(buttonNode);
9221					objList.push({
9222						node: target,
9223						maxFontSize: 18,
9224						smallestValue: false
9225					});
9226				}
9227			}
9228
9229			if (objList.length)
9230				BX.FixFontSize.init({objList: objList, onAdaptiveResize: true});
9231		},*/
9232
9233		setAnalyticsDataLayer: function(action, id)
9234		{
9235			if (!this.params.DATA_LAYER_NAME)
9236				return;
9237
9238			var info, i;
9239			var products = [],
9240				dataVariant, item;
9241
9242			for (i in this.result.GRID.ROWS)
9243			{
9244				if (this.result.GRID.ROWS.hasOwnProperty(i))
9245				{
9246					item = this.result.GRID.ROWS[i];
9247					dataVariant = [];
9248
9249					for (i = 0; i < item.data.PROPS.length; i++)
9250					{
9251						dataVariant.push(item.data.PROPS[i].VALUE);
9252					}
9253
9254					products.push({
9255						'id': item.data.PRODUCT_ID,
9256						'name': item.data.NAME,
9257						'price': item.data.PRICE,
9258						'brand': (item.data[this.params.BRAND_PROPERTY + '_VALUE'] || '').split(', ').join('/'),
9259						'variant': dataVariant.join('/'),
9260						'quantity': item.data.QUANTITY
9261					});
9262				}
9263			}
9264
9265			switch (action)
9266			{
9267				case 'checkout':
9268					info = {
9269						'event': 'checkout',
9270						'ecommerce': {
9271							'checkout': {
9272								'products': products
9273							}
9274						}
9275					};
9276					break;
9277				case 'purchase':
9278					info = {
9279						'event': 'purchase',
9280						'ecommerce': {
9281							'purchase': {
9282								'actionField': {
9283									'id': id,
9284									'revenue': this.result.TOTAL.ORDER_TOTAL_PRICE,
9285									'tax': this.result.TOTAL.TAX_PRICE,
9286									'shipping': this.result.TOTAL.DELIVERY_PRICE
9287								},
9288								'products': products
9289							}
9290						}
9291					};
9292					break;
9293			}
9294
9295			window[this.params.DATA_LAYER_NAME] = window[this.params.DATA_LAYER_NAME] || [];
9296			window[this.params.DATA_LAYER_NAME].push(info);
9297		},
9298
9299		isOrderSaveAllowed: function()
9300		{
9301			return this.orderSaveAllowed === true;
9302		},
9303
9304		allowOrderSave: function()
9305		{
9306			this.orderSaveAllowed = true;
9307		},
9308
9309		disallowOrderSave: function()
9310		{
9311			this.orderSaveAllowed = false;
9312		},
9313
9314		initUserConsent: function()
9315		{
9316			BX.ready(BX.delegate(function(){
9317				var control = BX.UserConsent && BX.UserConsent.load(this.orderBlockNode);
9318				if (control)
9319				{
9320					BX.addCustomEvent(control, BX.UserConsent.events.save, BX.proxy(this.doSaveAction, this));
9321					BX.addCustomEvent(control, BX.UserConsent.events.refused, BX.proxy(this.disallowOrderSave, this));
9322				}
9323			}, this));
9324		}
9325	};
9326})();

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.