PageSourceSearch

https://totalcharm.ru/bitrix/cache/js/s1/concept_phoenix_s1/page_7…b16dc08fa5292b63d587_v1.js?1789986139286444

js totalcharm.ru collected 2026-10-08 20:47:25 UTC 286,444 bytes, 9,795 lines download raw bytes

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

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.