PageSourceSearch

https://infaport.ru/bitrix/templates/mediapro_main/components/bitrix/catalog.element/content/script.js

js infaport.ru collected 2026-09-30 02:56:28 UTC 75,095 bytes, 2,965 lines download raw bytes

1(function (window) {
2
3if (!!window.JCCatalogElement)
4{
5	return;
6}
7
8var BasketButton = function(params)
9{
10	BasketButton.superclass.constructor.apply(this, arguments);
11	this.nameNode = BX.create('span', {
12		props : { className : 'bx_medium bx_bt_button', id : this.id },
13		style: typeof(params.style) === 'object' ? params.style : {},
14		text: params.text
15	});
16	this.buttonNode = BX.create('span', {
17		attrs: { className: params.ownerClass },
18		children: [this.nameNode],
19		events : this.contextEvents
20	});
21	if (BX.browser.IsIE())
22	{
23		this.buttonNode.setAttribute("hideFocus", "hidefocus");
24	}
25};
26BX.extend(BasketButton, BX.PopupWindowButton);
27
28window.JCCatalogElement = function (arParams)
29{
30	this.productType = 0;
31
32	this.config = {
33		useCatalog: true,
34		showQuantity: true,
35		showPrice: true,
36		showAbsent: true,
37		showOldPrice: false,
38		showPercent: false,
39		showSkuProps: false,
40		showOfferGroup: false,
41		useCompare: false,
42		useStickers: false,
43		mainPictureMode: 'IMG',
44		showBasisPrice: false,
45		basketAction: ['BUY'],
46		showClosePopup: false
47	};
48
49	this.checkQuantity = false;
50	this.maxQuantity = 0;
51	this.stepQuantity = 1;
52	this.isDblQuantity = false;
53	this.canBuy = true;
54	this.isGift = false;
55	this.currentBasisPrice = {};
56	this.canSubscription = true;
57	this.currentIsSet = false;
58	this.updateViewedCount = false;
59
60	this.precision = 6;
61	this.precisionFactor = Math.pow(10,this.precision);
62
63	this.listID = {
64		main: ['PICT_ID', 'BIG_SLIDER_ID', 'BIG_IMG_CONT_ID'],
65		stickers: ['STICKER_ID'],
66		productSlider: ['SLIDER_CONT', 'SLIDER_LIST', 'SLIDER_LEFT', 'SLIDER_RIGHT'],
67		offerSlider: ['SLIDER_CONT_OF_ID', 'SLIDER_LIST_OF_ID', 'SLIDER_LEFT_OF_ID', 'SLIDER_RIGHT_OF_ID'],
68		offers: ['TREE_ID', 'TREE_ITEM_ID', 'DISPLAY_PROP_DIV', 'OFFER_GROUP'],
69		quantity: ['QUANTITY_ID', 'QUANTITY_UP_ID', 'QUANTITY_DOWN_ID', 'QUANTITY_MEASURE', 'QUANTITY_LIMIT', 'BASIS_PRICE'],
70		price: ['PRICE_ID'],
71		oldPrice: ['OLD_PRICE_ID', 'DISCOUNT_VALUE_ID'],
72		discountPerc: ['DISCOUNT_PERC_ID'],
73		basket: ['BASKET_PROP_DIV', 'BUY_ID', 'ADD_BASKET_ID', 'BASKET_ACTIONS_ID', 'NOT_AVAILABLE_MESS'],
74		magnifier: ['MAGNIFIER_ID', 'MAGNIFIER_AREA_ID'],
75		compare: ['COMPARE_LINK_ID']
76	};
77
78	this.visualPostfix = {
79		// main pict
80		PICT_ID: '_pict',
81		BIG_SLIDER_ID: '_big_slider',
82		BIG_IMG_CONT_ID: '_bigimg_cont',
83		// stickers
84		STICKER_ID: '_sticker',
85		// product pict slider
86		SLIDER_CONT: '_slider_cont',
87		SLIDER_LIST: '_slider_list',
88		SLIDER_LEFT: '_slider_left',
89		SLIDER_RIGHT: '_slider_right',
90		// offers sliders
91		SLIDER_CONT_OF_ID: '_slider_cont_',
92		SLIDER_LIST_OF_ID: '_slider_list_',
93		SLIDER_LEFT_OF_ID: '_slider_left_',
94		SLIDER_RIGHT_OF_ID: '_slider_right_',
95		// offers
96		TREE_ID: '_skudiv',
97		TREE_ITEM_ID: '_prop_',
98		DISPLAY_PROP_DIV: '_sku_prop',
99		// quantity
100		QUANTITY_ID: '_quantity',
101		QUANTITY_UP_ID: '_quant_up',
102		QUANTITY_DOWN_ID: '_quant_down',
103		QUANTITY_MEASURE: '_quant_measure',
104		QUANTITY_LIMIT: '_quant_limit',
105		BASIS_PRICE: '_basis_price',
106		// price and discount
107		PRICE_ID: '_price',
108		OLD_PRICE_ID: '_old_price',
109		DISCOUNT_VALUE_ID: '_price_discount',
110		DISCOUNT_PERC_ID: '_dsc_pict',
111		// basket
112		BASKET_PROP_DIV: '_basket_prop',
113		BUY_ID: '_buy_link',
114		ADD_BASKET_ID: '_add_basket_link',
115		BASKET_ACTIONS_ID: '_basket_actions',
116		NOT_AVAILABLE_MESS: '_not_avail',
117		// magnifier
118		MAGNIFIER_ID: '_magnifier',
119		MAGNIFIER_AREA_ID: '_magnifier_area',
120		// offer groups
121		OFFER_GROUP: '_set_group_',
122		// compare
123		COMPARE_LINK_ID: '_compare_link'
124	};
125
126	this.visual = {};
127
128	this.basketMode = '';
129	this.product = {
130		checkQuantity: false,
131		maxQuantity: 0,
132		stepQuantity: 1,
133		startQuantity: 1,
134		isDblQuantity: false,
135		canBuy: true,
136		canSubscription: true,
137		name: '',
138		pict: {},
139		id: 0,
140		addUrl: '',
141		buyUrl: '',
142		slider: {},
143		sliderCount: 0,
144		useSlider: false,
145		sliderPict: []
146	};
147	this.mess = {};
148
149	this.basketData = {
150		useProps: false,
151		emptyProps: false,
152		quantity: 'quantity',
153		props: 'prop',
154		basketUrl: '',
155		sku_props: '',
156		sku_props_var: 'basket_props',
157		add_url: '',
158		buy_url: ''
159	};
160	this.compareData = {
161		compareUrl: '',
162		comparePath: ''
163	};
164
165	this.defaultPict = {
166		preview: null,
167		detail: null
168	};
169
170	this.offers = [];
171	this.offerNum = 0;
172	this.treeProps = [];
173	this.obTreeRows = [];
174	this.showCount = [];
175	this.showStart = [];
176	this.selectedValues = {};
177	this.sliders = [];
178
179	this.obProduct = null;
180	this.obQuantity = null;
181	this.obQuantityUp = null;
182	this.obQuantityDown = null;
183	this.obBasisPrice = null;
184	this.obPict = null;
185	this.obPictAligner = null;
186	this.obPrice = {
187		price: null,
188		full: null,
189		discount: null,
190		percent: null
191	};
192	this.obTree = null;
193	this.obBuyBtn = null;
194	this.obAddToBasketBtn = null;
195	this.obBasketActions = null;
196	this.obNotAvail = null;
197	this.obSkuProps = null;
198	this.obSlider = null;
199	this.obMeasure = null;
200	this.obQuantityLimit = {
201		all: null,
202		value: null
203	};
204	this.obCompare = null;
205
206	this.viewedCounter = {
207		path: '/bitrix/components/bitrix/catalog.element/ajax.php',
208		params: {
209			AJAX: 'Y',
210			SITE_ID: '',
211			PRODUCT_ID: 0,
212			PARENT_ID: 0
213		}
214	};
215
216	this.currentImg = {
217		src: '',
218		width: 0,
219		height: 0,
220		screenWidth: 0,
221		screenHeight: 0,
222		screenOffsetX: 0,
223		screenOffsetY: 0,
224		scale: 1
225	};
226
227	this.obPopupWin = null;
228	this.basketUrl = '';
229	this.basketParams = {};
230
231	this.obPopupPict = null;
232	this.magnify = {
233		obMagnifier: null,
234		obMagnifyPict: null,
235		obMagnifyArea: null,
236		obBigImg: null,
237		obBigSlider: null,
238		magnifyShow: false,
239		areaParams : {
240			width: 100,
241			height: 130,
242			left: 0,
243			top: 0,
244			scaleFactor: 1,
245			globalLeft: 0,
246			globalTop: 0,
247			globalRight: 0,
248			globalBottom: 0
249		},
250		magnifierParams: {
251			top: 0,
252			left: 0,
253			width: 0,
254			height: 0,
255			ratioX: 10,
256			ratioY: 13,
257			defaultScale: 1
258		},
259		magnifyPictParams: {
260			marginTop: 0,
261			marginLeft: 0,
262			width: 0,
263			height: 0
264		}
265	};
266
267	this.treeRowShowSize = 5;
268	this.treeEnableArrow = { display: '', cursor: 'pointer', opacity: 1 };
269	this.treeDisableArrow = { display: '', cursor: 'default', opacity: 0.2 };
270	this.sliderRowShowSize = 5;
271	this.sliderEnableArrow = { display: '', cursor: 'pointer', opacity: 1 };
272	this.sliderDisableArrow = { display: '', cursor: 'default', opacity: 0.2 };
273
274	this.errorCode = 0;
275
276	if (typeof arParams === 'object')
277	{
278		this.params = arParams;
279		this.initConfig();
280
281		if (!!this.params.MESS)
282		{
283			this.mess = this.params.MESS;
284		}
285		switch (this.productType)
286		{
287			case 0:// no catalog
288			case 1://product
289			case 2://set
290				this.initProductData();
291				break;
292			case 3://sku
293				this.initOffersData();
294				break;
295			default:
296				this.errorCode = -1;
297		}
298		this.initBasketData();
299		this.initCompareData();
300	}
301	if (0 === this.errorCode)
302	{
303		BX.ready(BX.delegate(this.Init,this));
304	}
305	this.params = {};
306
307	BX.addCustomEvent('onSaleProductIsGift', BX.delegate(this.onSaleProductIsGift, this));
308	BX.addCustomEvent('onSaleProductIsNotGift', BX.delegate(this.onSaleProductIsNotGift, this));
309};
310
311window.JCCatalogElement.prototype.onSaleProductIsGift = function(productId, offerId)
312{
313	var findOfferById = function(offers, offerId)
314	{
315		for (var i = 0; i < offers.length; i++)
316		{
317			if(offers[i] && offers[i].ID == offerId)
318			{
319				return offers[i];
320			}
321		}
322
323		return null;
324	};
325
326	if(!!offerId && this.offers && this.offers[this.offerNum].ID == offerId)
327	{
328		this.setGift();
329	}
330};
331
332window.JCCatalogElement.prototype.onSaleProductIsNotGift = function(productId, offerId)
333{
334	if(!!offerId && this.offers && this.offers[this.offerNum].ID == offerId)
335	{
336		this.restoreSticker();
337		this.isGift = false;
338		this.setPrice(BX.clone(this.offers[this.offerNum].PRICE, true));
339	}
340};
341
342window.JCCatalogElement.prototype.reloadGiftInfo = function()
343{
344	if(this.productType === 3)
345	{
346		this.checkQuantity = true;
347		this.maxQuantity = 1;
348
349		this.setPrice(BX.clone(this.offers[this.offerNum].PRICE, true));
350		BX.hide(this.obBasisPrice);
351		this.redrawSticker({text: BX.message('PRODUCT_GIFT_LABEL')});
352	}
353};
354
355window.JCCatalogElement.prototype.setGift = function()
356{
357	if(this.productType === 3)
358	{
359		//sku
360		this.isGift = true;
361	}
362	if(this.productType === 1 || this.productType === 2)
363	{
364		//simple
365		this.isGift = true;
366	}
367	if(this.productType === 0)
368	{
369		this.isGift = false;
370	}
371	this.reloadGiftInfo();
372};
373
374window.JCCatalogElement.prototype.Init = function()
375{
376	var i = 0,
377		j = 0,
378		strPrefix = '',
379		SliderImgs = null,
380		TreeItems = null;
381
382	this.obProduct = BX(this.visual.ID);
383	if (!this.obProduct)
384	{
385		this.errorCode = -1;
386	}
387	this.obPict = BX(this.visual.PICT_ID);
388	if (!this.obPict)
389	{
390		this.errorCode = -2;
391	}
392	else
393	{
394		this.obPictAligner = this.obPict.parentNode;
395	}
396
397	if (this.config.showPrice)
398	{
399		this.obPrice.price = BX(this.visual.PRICE_ID);
400		if (!this.obPrice.price && this.config.useCatalog)
401		{
402			this.errorCode = -16;
403		}
404		else
405		{
406			if (this.config.showOldPrice)
407			{
408				this.obPrice.full = BX(this.visual.OLD_PRICE_ID);
409				this.obPrice.discount = BX(this.visual.DISCOUNT_VALUE_ID);
410				if (!this.obPrice.full || !this.obPrice.discount)
411				{
412					this.config.showOldPrice = false;
413				}
414			}
415			if (this.config.showPercent)
416			{
417				this.obPrice.percent = BX(this.visual.DISCOUNT_PERC_ID);
418				if (!this.obPrice.percent)
419				{
420					this.config.showPercent = false;
421				}
422			}
423		}
424		this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID);
425		if (!!this.obBasketActions)
426		{
427			if (BX.util.in_array('BUY', this.config.basketAction))
428			{
429				this.obBuyBtn = BX(this.visual.BUY_ID);
430			}
431			if (BX.util.in_array('ADD', this.config.basketAction))
432			{
433				this.obAddToBasketBtn = BX(this.visual.ADD_BASKET_ID);
434			}
435		}
436		this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS);
437	}
438
439	if (this.config.showQuantity)
440	{
441		this.obQuantity = BX(this.visual.QUANTITY_ID);
442		if (!!this.visual.QUANTITY_UP_ID)
443		{
444			this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID);
445		}
446		if (!!this.visual.QUANTITY_DOWN_ID)
447		{
448			this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID);
449		}
450		if (this.config.showBasisPrice)
451		{
452			this.obBasisPrice = BX(this.visual.BASIS_PRICE);
453		}
454	}
455	if (3 === this.productType)
456	{
457		if (!!this.visual.TREE_ID)
458		{
459			this.obTree = BX(this.visual.TREE_ID);
460			if (!this.obTree)
461			{
462				this.errorCode = -256;
463			}
464			strPrefix = this.visual.TREE_ITEM_ID;
465			for (i = 0; i < this.treeProps.length; i++)
466			{
467				this.obTreeRows[i] = {
468					LEFT: BX(strPrefix+this.treeProps[i].ID+'_left'),
469					RIGHT: BX(strPrefix+this.treeProps[i].ID+'_right'),
470					LIST: BX(strPrefix+this.treeProps[i].ID+'_list'),
471					CONT: BX(strPrefix+this.treeProps[i].ID+'_cont')
472				};
473				if (!this.obTreeRows[i].LEFT || !this.obTreeRows[i].RIGHT || !this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT)
474				{
475					this.errorCode = -512;
476					break;
477				}
478			}
479		}
480		if (!!this.visual.QUANTITY_MEASURE)
481		{
482			this.obMeasure = BX(this.visual.QUANTITY_MEASURE);
483		}
484		if (!!this.visual.QUANTITY_LIMIT)
485		{
486			this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT);
487			if (!!this.obQuantityLimit.all)
488			{
489				this.obQuantityLimit.value = BX.findChild(this.obQuantityLimit.all, {tagName: 'span'}, false, false);
490				if (!this.obQuantityLimit.value)
491				{
492					this.obQuantityLimit.all = null;
493				}
494			}
495		}
496	}
497
498	if (this.config.showSkuProps)
499	{
500		if (!!this.visual.DISPLAY_PROP_DIV)
501		{
502			this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV);
503		}
504	}
505
506	if (this.config.useCompare)
507	{
508		this.obCompare = BX(this.visual.COMPARE_LINK_ID);
509	}
510
511	if (0 === this.errorCode)
512	{
513		if (this.config.showQuantity)
514		{
515			if (!!this.obQuantityUp)
516			{
517				BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this));
518			}
519			if (!!this.obQuantityDown)
520			{
521				BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this));
522			}
523			if (!!this.obQuantity)
524			{
525				BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this));
526			}
527		}
528		switch (this.productType)
529		{
530			case 0://no catalog
531			case 1://product
532			case 2://set
533				if (this.product.useSlider)
534				{
535					this.product.slider = {
536						COUNT: this.product.sliderCount,
537						ID: this.visual.SLIDER_CONT,
538						CONT: BX(this.visual.SLIDER_CONT),
539						LIST: BX(this.visual.SLIDER_LIST),
540						LEFT: BX(this.visual.SLIDER_LEFT),
541						RIGHT: BX(this.visual.SLIDER_RIGHT),
542						START: 0
543					};
544					SliderImgs = BX.findChildren(this.product.slider.LIST, {tagName: 'li'}, true);
545					if (!!SliderImgs && 0 < SliderImgs.length)
546					{
547						for (j = 0; j < SliderImgs.length; j++)
548						{
549							BX.bind(SliderImgs[j], 'click', BX.delegate(this.ProductSelectSliderImg, this));
550						}
551					}
552					if (!!this.product.slider.LEFT)
553					{
554						BX.bind(this.product.slider.LEFT, 'click', BX.delegate(this.ProductSliderRowLeft, this));
555						BX.adjust(this.product.slider.LEFT, { style: this.sliderDisableArrow } );
556
557					}
558					if (!!this.product.slider.RIGHT)
559					{
560						BX.bind(this.product.slider.RIGHT, 'click', BX.delegate(this.ProductSliderRowRight, this));
561						BX.adjust(this.product.slider.RIGHT, { style: this.sliderEnableArrow } );
562					}
563					this.setCurrentImg(this.product.sliderPict[0], true);
564				}
565				break;
566			case 3://sku
567				TreeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true);
568				if (!!TreeItems && 0 < TreeItems.length)
569				{
570					for (i = 0; i < TreeItems.length; i++)
571					{
572						BX.bind(TreeItems[i], 'click', BX.delegate(this.SelectOfferProp, this));
573					}
574				}
575				for (i = 0; i < this.obTreeRows.length; i++)
576				{
577					BX.bind(this.obTreeRows[i].LEFT, 'click', BX.delegate(this.RowLeft, this));
578					BX.bind(this.obTreeRows[i].RIGHT, 'click', BX.delegate(this.RowRight, this));
579				}
580				for (i = 0; i < this.offers.length; i++)
581				{
582					this.offers[i].SLIDER_COUNT = parseInt(this.offers[i].SLIDER_COUNT, 10);
583					if (isNaN(this.offers[i].SLIDER_COUNT))
584					{
585						this.offers[i].SLIDER_COUNT = 0;
586					}
587					if (0 === this.offers[i].SLIDER_COUNT)
588					{
589						this.sliders[i] = {
590							COUNT: this.offers[i].SLIDER_COUNT,
591							ID: ''
592						};
593					}
594					else
595					{
596						for (j = 0; j < this.offers[i].SLIDER.length; j++)
597						{
598							this.offers[i].SLIDER[j].WIDTH = parseInt(this.offers[i].SLIDER[j].WIDTH, 10);
599							this.offers[i].SLIDER[j].HEIGHT = parseInt(this.offers[i].SLIDER[j].HEIGHT, 10);
600						}
601						this.sliders[i] = {
602							COUNT: this.offers[i].SLIDER_COUNT,
603							OFFER_ID: this.offers[i].ID,
604							ID: this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID,
605							CONT: BX(this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID),
606							LIST: BX(this.visual.SLIDER_LIST_OF_ID+this.offers[i].ID),
607							LEFT: BX(this.visual.SLIDER_LEFT_OF_ID+this.offers[i].ID),
608							RIGHT: BX(this.visual.SLIDER_RIGHT_OF_ID+this.offers[i].ID),
609							START: 0
610						};
611						SliderImgs = BX.findChildren(this.sliders[i].LIST, {tagName: 'li'}, true);
612						if (!!SliderImgs && 0 < SliderImgs.length)
613						{
614							for (j = 0; j < SliderImgs.length; j++)
615							{
616								BX.bind(SliderImgs[j], 'click', BX.delegate(this.SelectSliderImg, this));
617							}
618						}
619						if (!!this.sliders[i].LEFT)
620						{
621							BX.bind(this.sliders[i].LEFT, 'click', BX.delegate(this.SliderRowLeft, this));
622						}
623						if (!!this.sliders[i].RIGHT)
624						{
625							BX.bind(this.sliders[i].RIGHT, 'click', BX.delegate(this.SliderRowRight, this));
626						}
627					}
628				}
629				this.SetCurrent();
630				break;
631		}
632
633		if (!!this.obBuyBtn)
634		{
635			BX.bind(this.obBuyBtn, 'click', BX.proxy(this.BuyBasket, this));
636		}
637		if (!!this.obAddToBasketBtn)
638		{
639			BX.bind(this.obAddToBasketBtn, 'click', BX.proxy(this.Add2Basket, this));
640		}
641		if (!!this.obCompare)
642		{
643			BX.bind(this.obCompare, 'click', BX.proxy(this.Compare, this));
644		}
645
646		this.setMainPictHandler();
647	}
648};
649
650window.JCCatalogElement.prototype.initConfig = function()
651{
652	this.productType = parseInt(this.params.PRODUCT_TYPE, 10);
653	if (!!this.params.CONFIG && typeof(this.params.CONFIG) === 'object')
654	{
655		if (this.params.CONFIG.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.CONFIG.USE_CATALOG))
656		{
657			this.config.useCatalog = this.params.CONFIG.USE_CATALOG;
658		}
659		this.config.showQuantity = !!this.params.CONFIG.SHOW_QUANTITY;
660		this.config.showPrice = !!this.params.CONFIG.SHOW_PRICE;
661		this.config.showPercent = !!this.params.CONFIG.SHOW_DISCOUNT_PERCENT;
662		this.config.showOldPrice = !!this.params.CONFIG.SHOW_OLD_PRICE;
663		this.config.showSkuProps = !!this.params.CONFIG.SHOW_SKU_PROPS;
664		this.config.showOfferGroup = !!this.params.CONFIG.OFFER_GROUP;
665		this.config.useCompare = !!this.params.CONFIG.DISPLAY_COMPARE;
666		this.config.useStickers = !!this.params.CONFIG.USE_STICKERS;
667		if (!!this.params.CONFIG.MAIN_PICTURE_MODE)
668		{
669			this.config.mainPictureMode = this.params.CONFIG.MAIN_PICTURE_MODE;
670		}
671		this.config.showBasisPrice = !!this.params.CONFIG.SHOW_BASIS_PRICE;
672		if (!!this.params.CONFIG.ADD_TO_BASKET_ACTION)
673		{
674			this.config.basketAction = this.params.CONFIG.ADD_TO_BASKET_ACTION;
675		}
676		this.config.showClosePopup = !!this.params.CONFIG.SHOW_CLOSE_POPUP;
677	}
678	else
679	{
680		// old version
681		if (this.params.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.USE_CATALOG))
682		{
683			this.config.useCatalog = this.params.USE_CATALOG;
684		}
685		this.config.showQuantity = !!this.params.SHOW_QUANTITY;
686		this.config.showPrice = !!this.params.SHOW_PRICE;
687		this.config.showPercent = !!this.params.SHOW_DISCOUNT_PERCENT;
688		this.config.showOldPrice = !!this.params.SHOW_OLD_PRICE;
689		this.config.showSkuProps = !!this.params.SHOW_SKU_PROPS;
690		this.config.showOfferGroup = !!this.params.OFFER_GROUP;
691		this.config.useCompare = !!this.params.DISPLAY_COMPARE;
692		if (!!this.params.MAIN_PICTURE_MODE)
693		{
694			this.config.mainPictureMode = this.params.MAIN_PICTURE_MODE;
695		}
696		this.config.showBasisPrice = !!this.params.SHOW_BASIS_PRICE;
697		if (!!this.params.ADD_TO_BASKET_ACTION)
698		{
699			this.config.basketAction = this.params.ADD_TO_BASKET_ACTION;
700		}
701		this.config.showClosePopup = !!this.params.SHOW_CLOSE_POPUP;
702	}
703
704	if (!this.params.VISUAL || typeof(this.params.VISUAL) !== 'object' || !this.params.VISUAL.ID)
705	{
706		this.errorCode = -1;
707		return;
708	}
709	this.visual.ID = this.params.VISUAL.ID;
710	this.initVisualParams('main');
711	if (this.config.showQuantity)
712	{
713		this.initVisualParams('quantity');
714	}
715	if (this.config.showPrice)
716	{
717		this.initVisualParams('price');
718	}
719	if (this.config.showOldPrice)
720	{
721		this.initVisualParams('oldPrice');
722	}
723	if (this.config.showPercent)
724	{
725		this.initVisualParams('discountPerc');
726	}
727	this.initVisualParams('basket');
728	if (this.config.mainPictureMode === 'MAGNIFIER')
729	{
730		this.initVisualParams('magnifier');
731	}
732	if (this.config.useCompare)
733	{
734		this.initVisualParams('compare');
735	}
736	if (this.config.useStickers)
737	{
738		this.initVisualParams('stickers');
739	}
740};
741
742window.JCCatalogElement.prototype.initVisualParams = function(ID)
743{
744	var i = 0,
745		key = '';
746
747	if (!this.listID[ID])
748	{
749		this.errorCode = -1;
750		return;
751	}
752	for (i = 0; i < this.listID[ID].length; i++)
753	{
754		key = this.listID[ID][i];
755		this.visual[key] = (!!this.params.VISUAL[key] ? this.params.VISUAL[key] : this.visual.ID+this.visualPostfix[key]);
756	}
757};
758
759window.JCCatalogElement.prototype.initProductData = function()
760{
761	var j = 0;
762	this.initVisualParams('productSlider');
763	if (!!this.params.PRODUCT && 'object' === typeof(this.params.PRODUCT))
764	{
765		if (this.config.showQuantity)
766		{
767			this.product.checkQuantity = this.params.PRODUCT.CHECK_QUANTITY;
768			this.product.isDblQuantity = this.params.PRODUCT.QUANTITY_FLOAT;
769			if (this.product.checkQuantity)
770			{
771				this.product.maxQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.MAX_QUANTITY) : parseInt(this.params.PRODUCT.MAX_QUANTITY, 10));
772			}
773			this.product.stepQuantity = (this.product.isDblQuantity ? parseFloat(this.params.PRODUCT.STEP_QUANTITY) : parseInt(this.params.PRODUCT.STEP_QUANTITY, 10));
774
775			this.checkQuantity = this.product.checkQuantity;
776			this.isDblQuantity = this.product.isDblQuantity;
777			this.maxQuantity = this.product.maxQuantity;
778			this.stepQuantity = this.product.stepQuantity;
779			if (this.isDblQuantity)
780			{
781				this.stepQuantity = Math.round(this.stepQuantity*this.precisionFactor)/this.precisionFactor;
782			}
783		}
784		this.product.canBuy = this.params.PRODUCT.CAN_BUY;
785		this.product.canSubscription = this.params.PRODUCT.SUBSCRIPTION;
786		if (this.config.showPrice)
787		{
788			this.currentBasisPrice = this.params.PRODUCT.BASIS_PRICE;
789		}
790
791		this.canBuy = this.product.canBuy;
792		this.canSubscription = this.product.canSubscription;
793
794		this.product.name = this.params.PRODUCT.NAME;
795		this.product.pict = this.params.PRODUCT.PICT;
796		this.product.id = this.params.PRODUCT.ID;
797
798		if (!!this.params.PRODUCT.ADD_URL)
799		{
800			this.product.addUrl = this.params.PRODUCT.ADD_URL;
801		}
802		if (!!this.params.PRODUCT.BUY_URL)
803		{
804			this.product.buyUrl = this.params.PRODUCT.BUY_URL;
805		}
806
807		if (!!this.params.PRODUCT.SLIDER_COUNT)
808		{
809			this.product.sliderCount = parseInt(this.params.PRODUCT.SLIDER_COUNT, 10);
810			if (isNaN(this.product.sliderCount))
811			{
812				this.product.sliderCount = 0;
813			}
814			if (0 < this.product.sliderCount && !!this.params.PRODUCT.SLIDER.length && 0 < this.params.PRODUCT.SLIDER.length)
815			{
816				for (j = 0; j < this.params.PRODUCT.SLIDER.length; j++)
817				{
818					this.product.useSlider = true;
819					this.params.PRODUCT.SLIDER[j].WIDTH = parseInt(this.params.PRODUCT.SLIDER[j].WIDTH, 10);
820					this.params.PRODUCT.SLIDER[j].HEIGHT = parseInt(this.params.PRODUCT.SLIDER[j].HEIGHT, 10);
821				}
822				this.product.sliderPict = this.params.PRODUCT.SLIDER;
823				this.setCurrentImg(this.product.sliderPict[0], false);
824			}
825		}
826		this.currentIsSet = true;
827	}
828	else
829	{
830		this.errorCode = -1;
831	}
832};
833
834window.JCCatalogElement.prototype.initOffersData = function()
835{
836	this.initVisualParams('offerSlider');
837	this.initVisualParams('offers');
838	if (!!this.params.OFFERS && BX.type.isArray(this.params.OFFERS))
839	{
840		this.offers = this.params.OFFERS;
841		this.offerNum = 0;
842		if (!!this.params.OFFER_SELECTED)
843		{
844			this.offerNum = parseInt(this.params.OFFER_SELECTED, 10);
845		}
846		if (isNaN(this.offerNum))
847		{
848			this.offerNum = 0;
849		}
850		if (!!this.params.TREE_PROPS)
851		{
852			this.treeProps = this.params.TREE_PROPS;
853		}
854		if (!!this.params.DEFAULT_PICTURE)
855		{
856			this.defaultPict.preview = this.params.DEFAULT_PICTURE.PREVIEW_PICTIRE;
857			this.defaultPict.detail = this.params.DEFAULT_PICTURE.DETAIL_PICTURE;
858		}
859		if (!!this.params.PRODUCT && typeof(this.params.PRODUCT) === 'object')
860		{
861			this.product.id = parseInt(this.params.PRODUCT.ID, 10);
862			this.product.name = this.params.PRODUCT.NAME;
863		}
864	}
865	else
866	{
867		this.errorCode = -1;
868	}
869};
870
871window.JCCatalogElement.prototype.initBasketData = function()
872{
873	if (!!this.params.BASKET && 'object' === typeof(this.params.BASKET))
874	{
875		if (1 === this.productType || 2 === this.productType)
876		{
877			this.basketData.useProps = !!this.params.BASKET.ADD_PROPS;
878			this.basketData.emptyProps = !!this.params.BASKET.EMPTY_PROPS;
879		}
880
881		if (!!this.params.BASKET.QUANTITY)
882		{
883			this.basketData.quantity = this.params.BASKET.QUANTITY;
884		}
885		if (!!this.params.BASKET.PROPS)
886		{
887			this.basketData.props = this.params.BASKET.PROPS;
888		}
889		if (!!this.params.BASKET.BASKET_URL)
890		{
891			this.basketData.basketUrl = this.params.BASKET.BASKET_URL;
892		}
893		if (3 === this.productType)
894		{
895			if (!!this.params.BASKET.SKU_PROPS)
896			{
897				this.basketData.sku_props = this.params.BASKET.SKU_PROPS;
898			}
899		}
900		if (!!this.params.BASKET.ADD_URL_TEMPLATE)
901		{
902			this.basketData.add_url = this.params.BASKET.ADD_URL_TEMPLATE;
903		}
904		if (!!this.params.BASKET.BUY_URL_TEMPLATE)
905		{
906			this.basketData.buy_url = this.params.BASKET.BUY_URL_TEMPLATE;
907		}
908		if (this.basketData.add_url === '' && this.basketData.buy_url === '')
909		{
910			this.errorCode = -1024;
911		}
912	}
913};
914
915window.JCCatalogElement.prototype.initCompareData = function()
916{
917	if (this.config.useCompare)
918	{
919		if (!!this.params.COMPARE && typeof(this.params.COMPARE) === 'object')
920		{
921			if (!!this.params.COMPARE.COMPARE_PATH)
922			{
923				this.compareData.comparePath = this.params.COMPARE.COMPARE_PATH;
924			}
925			if (!!this.params.COMPARE.COMPARE_URL_TEMPLATE)
926			{
927				this.compareData.compareUrl = this.params.COMPARE.COMPARE_URL_TEMPLATE;
928			}
929			else
930			{
931				this.config.useCompare = false;
932			}
933		}
934		else
935		{
936			this.config.useCompare = false;
937		}
938	}
939};
940
941window.JCCatalogElement.prototype.setMainPictHandler = function()
942{
943	switch (this.config.mainPictureMode)
944	{
945		case 'GALLERY':
946			break;
947		case 'MAGNIFIER':
948			this.magnify.obBigImg = BX(this.visual.BIG_IMG_CONT_ID);
949			this.magnify.obBigSlider = BX(this.visual.BIG_SLIDER_ID);
950			if (!!this.magnify.obBigImg && !!this.magnify.obBigSlider)
951			{
952				this.magnify.obMagnifyArea = this.obPictAligner.appendChild(BX.create(
953					'DIV',
954					{
955						props: {
956							id: this.visual.MAGNIFIER_AREA_ID,
957							className: 'bx_item_slider_lupe_small'
958						},
959						style: {
960							display: 'none',
961							top: 0,
962							left: 0,
963							width: '100px',
964							height: '130px'
965						},
966						events: {
967							mouseover: BX.delegate(this.onMagnifierArea, this),
968							mouseout: BX.delegate(function(){this.outMagnifierArea(); this.hideMagnifier(); }, this)
969						}
970					}
971				));
972
973				this.magnify.obMagnifier = this.magnify.obBigSlider.appendChild(BX.create(
974					'DIV',
975					{
976						props: {
977							id: this.visual.MAGNIFIER_ID,
978							className: 'bx_item_slider_lupe'
979						},
980						style: {
981							display: 'none'
982						}
983					}
984				));
985				this.magnify.obMagnifyPict = this.magnify.obMagnifier.appendChild(BX.create(
986					'IMG',
987					{
988						props: {
989							src: this.currentImg.src
990						}
991					}
992				));
993				BX.bind(this.obPict, 'mouseover', BX.delegate(this.showMagnifier, this));
994			}
995			break;
996		case 'POPUP':
997			this.obPopupPict = new BX.PopupWindow('CatalogElementPopup_'+this.visual.ID, null, {
998				autoHide: false,
999				offsetLeft: 0,
1000				offsetTop: 0,
1001				overlay : false,
1002				closeByEsc: true,
1003				titleBar: true,
1004				closeIcon: {top: '10px', right: '10px'}
1005			});
1006			BX.bind(this.obPict, 'click', BX.delegate(this.showMainPictPopup, this));
1007			BX.adjust(this.obPict, { style: { cursor: 'pointer' } });
1008			BX.addCustomEvent(this.obPopupPict, "onAfterPopupShow", BX.proxy(this.onPopupWindowShow, this));
1009			BX.addCustomEvent(this.obPopupPict, "onPopupClose", BX.proxy(this.onPopupWindowClose, this));
1010			break;
1011		default:
1012			break;
1013	}
1014};
1015
1016window.JCCatalogElement.prototype.setCurrentImg = function(img, showImage)
1017{
1018	showImage = !!showImage;
1019	this.currentImg.src = img.SRC;
1020	this.currentImg.width = img.WIDTH;
1021	this.currentImg.height = img.HEIGHT;
1022	if (showImage && !!this.obPict)
1023	{
1024		if (this.config.mainPictureMode === 'MAGNIFIER')
1025		{
1026			this.outMagnifierArea();
1027			this.hideMagnifier();
1028		}
1029		BX.adjust(this.obPict, { props: { src: this.currentImg.src } });
1030		var dest = {
1031				width: parseInt(this.obPictAligner.offsetWidth, 10),
1032				height: parseInt(this.obPictAligner.offsetHeight, 10)
1033			},
1034			result,
1035			newMarginTop;
1036		result = this.scaleImg(this.currentImg, dest);
1037
1038		newMarginTop = (result.height < dest.height ? (dest.height - result.height) >>> 1 : 0);
1039		if (newMarginTop !== this.currentImg.screenOffsetY)
1040		{
1041			BX.style(this.obPictAligner, 'marginTop', newMarginTop+'px');
1042			this.currentImg.screenOffsetY = newMarginTop;
1043		}
1044		this.currentImg.screenOffsetX = (result.width < dest.width ? (dest.width - result.width) >>> 1 : 0);
1045		this.currentImg.screenWidth = result.width;
1046		this.currentImg.screenHeight = result.height;
1047	}
1048};
1049
1050window.JCCatalogElement.prototype.scaleImg = function(src, dest)
1051{
1052	var
1053		scaleX,
1054		scaleY,
1055		scale,
1056		result = {};
1057
1058	if (dest.width >= src.width && dest.height >= src.height)
1059	{
1060		result.width = src.width;
1061		result.height = src.height;
1062	}
1063	else
1064	{
1065		scaleX = dest.width/src.width;
1066		scaleY = dest.height/src.height;
1067		scale =  Math.min(scaleX, scaleY);
1068		result.width = Math.max(1, parseInt(scale*src.width , 10));
1069		result.height = Math.max(1, parseInt(scale*src.height , 10));
1070	}
1071	return result;
1072};
1073
1074window.JCCatalogElement.prototype.showMagnifier = function(e)
1075{
1076	if (!this.magnify.magnifyShow)
1077	{
1078		this.calcMagnifierParams();
1079		this.calcMagnifyAreaSize();
1080		this.calcMagnifyAreaPos(e);
1081		this.calcMagnifyPictSize();
1082		this.calcMagnifyPictPos();
1083		this.setMagnifyAreaParams(true);
1084		this.setMagnifyPictParams(true);
1085		this.setMagnifierParams(true);
1086		BX.bind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this));
1087	}
1088};
1089
1090window.JCCatalogElement.prototype.hideMagnifier = function()
1091{
1092	if (!this.magnify.magnifyShow)
1093	{
1094		if (!!this.magnify.obMagnifier)
1095		{
1096			BX.adjust(this.magnify.obMagnifier, { style: { display: 'none' } });
1097		}
1098		if (!!this.magnify.obMagnifyArea)
1099		{
1100			BX.adjust(this.magnify.obMagnifyArea, { style: { display: 'none' } });
1101		}
1102		BX.unbind(document, 'mousemove', BX.proxy(this.moveMagnifierArea, this));
1103	}
1104};
1105
1106window.JCCatalogElement.prototype.moveMagnifierArea = function(e)
1107{
1108	var
1109		currentPos,
1110		posBigImg = BX.pos(this.obPict),
1111		intersect = {},
1112		params = {},
1113		paramsPict = {};
1114
1115	currentPos = this.inRect(e, posBigImg);
1116	if (this.inBound(posBigImg, currentPos))
1117	{
1118		intersect = this.intersectArea(currentPos, posBigImg);
1119		switch (intersect.X)
1120		{
1121			case -1:
1122				this.magnify.areaParams.left = this.currentImg.screenOffsetX;
1123				break;
1124			case 0:
1125				this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1);
1126				break;
1127			case 1:
1128				this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width;
1129				break;
1130		}
1131		switch (intersect.Y)
1132		{
1133			case -1:
1134				this.magnify.areaParams.top = 0;
1135				break;
1136			case 0:
1137				this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1);
1138				break;
1139			case 1:
1140				this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height;
1141				break;
1142		}
1143		this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left-this.currentImg.screenOffsetX)*this.currentImg.scale), 10);
1144		this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top)*this.currentImg.scale), 10);
1145		params.left = this.magnify.areaParams.left+'px';
1146		params.top = this.magnify.areaParams.top+'px';
1147		BX.adjust(this.magnify.obMagnifyArea, { style: params });
1148		paramsPict.marginLeft = this.magnify.magnifyPictParams.marginLeft+'px';
1149		paramsPict.marginTop = this.magnify.magnifyPictParams.marginTop+'px';
1150		BX.adjust(this.magnify.obMagnifyPict, { style: paramsPict });
1151	}
1152	else
1153	{
1154		this.outMagnifierArea();
1155		this.hideMagnifier();
1156	}
1157};
1158
1159window.JCCatalogElement.prototype.onMagnifierArea = function()
1160{
1161	this.magnify.magnifyShow = true;
1162};
1163
1164window.JCCatalogElement.prototype.outMagnifierArea = function()
1165{
1166	this.magnify.magnifyShow = false;
1167};
1168
1169window.JCCatalogElement.prototype.calcMagnifierParams = function()
1170{
1171	if (!!this.magnify.obBigImg)
1172	{
1173		var pos = BX.pos(this.magnify.obBigImg, true);
1174
1175		this.magnify.magnifierParams.width = pos.width;
1176		this.magnify.magnifierParams.height = pos.height;
1177		this.magnify.magnifierParams.top = pos.top;
1178		this.magnify.magnifierParams.left = pos.left + pos.width + 2;
1179	}
1180};
1181
1182window.JCCatalogElement.prototype.setMagnifierParams = function(show)
1183{
1184	if (!!this.magnify.obMagnifier)
1185	{
1186		show = !!show;
1187		var params = {
1188			top: this.magnify.magnifierParams.top+'px',
1189			left: this.magnify.magnifierParams.left+'px',
1190			width: this.magnify.magnifierParams.width+'px',
1191			height: this.magnify.magnifierParams.height+'px'
1192		};
1193		if (show)
1194		{
1195			params.display = '';
1196		}
1197		BX.adjust(this.magnify.obMagnifier, { style: params });
1198	}
1199};
1200
1201window.JCCatalogElement.prototype.setMagnifyAreaParams = function(show)
1202{
1203	if (!!this.magnify.obMagnifier)
1204	{
1205		show = !!show;
1206		var params = {
1207			top: this.magnify.areaParams.top+'px',
1208			left: this.magnify.areaParams.left+'px',
1209			width: this.magnify.areaParams.width+'px',
1210			height: this.magnify.areaParams.height+'px'
1211		};
1212		if (show)
1213		{
1214			params.display = '';
1215		}
1216		BX.adjust(this.magnify.obMagnifyArea, { style: params });
1217	}
1218};
1219
1220window.JCCatalogElement.prototype.calcMagnifyAreaPos = function(e)
1221{
1222	var currentPos,
1223		posBigImg,
1224		intersect;
1225
1226	posBigImg = BX.pos(this.obPict);
1227	currentPos = this.inRect(e, posBigImg);
1228	if (this.inBound(posBigImg, currentPos))
1229	{
1230		intersect = this.intersectArea(currentPos, posBigImg);
1231		switch (intersect.X)
1232		{
1233			case -1:
1234				this.magnify.areaParams.left = this.currentImg.screenOffsetX;
1235				break;
1236			case 0:
1237				this.magnify.areaParams.left = this.currentImg.screenOffsetX + currentPos.X - (this.magnify.areaParams.width >>> 1);
1238				break;
1239			case 1:
1240				this.magnify.areaParams.left = this.currentImg.screenOffsetX + posBigImg.width - this.magnify.areaParams.width;
1241				break;
1242		}
1243		switch (intersect.Y)
1244		{
1245			case -1:
1246				this.magnify.areaParams.top = 0;
1247				break;
1248			case 0:
1249				this.magnify.areaParams.top = currentPos.Y - (this.magnify.areaParams.height >>> 1);
1250				break;
1251			case 1:
1252				this.magnify.areaParams.top = posBigImg.height - this.magnify.areaParams.height;
1253				break;
1254		}
1255	}
1256};
1257
1258window.JCCatalogElement.prototype.inBound = function(rect, point)
1259{
1260	return ((0 <= point.Y && rect.height >= point.Y) && (0 <= point.X && rect.width >= point.X));
1261};
1262
1263window.JCCatalogElement.prototype.inRect = function(e, rect)
1264{
1265	var wndSize = BX.GetWindowSize(),
1266		currentPos = {
1267			X: 0,
1268			Y: 0,
1269			globalX: 0,
1270			globalY: 0
1271		};
1272
1273	currentPos.globalX = e.clientX + wndSize.scrollLeft;
1274	if (e.offsetX && e.offsetX < 0)
1275		currentPos.globalX -= e.offsetX;
1276	currentPos.X = currentPos.globalX - rect.left;
1277	currentPos.globalY = e.clientY + wndSize.scrollTop;
1278	if (e.offsetY && e.offsetY < 0)
1279		currentPos.globalY -= e.offsetY;
1280	currentPos.Y = currentPos.globalY - rect.top;
1281	return currentPos;
1282};
1283
1284window.JCCatalogElement.prototype.intersectArea = function(currentPos, rect)
1285{
1286	var intersect = {
1287			X: 0,
1288			Y: 0
1289		},
1290		halfX = this.magnify.areaParams.width >>> 1,
1291		halfY = this.magnify.areaParams.height >>> 1;
1292
1293	if (currentPos.X <= halfX)
1294	{
1295		intersect.X = -1;
1296	}
1297	else if (currentPos.X >= (rect.width - halfX))
1298	{
1299		intersect.X = 1;
1300	}
1301	else
1302	{
1303		intersect.X = 0;
1304	}
1305	if (currentPos.Y <= halfY)
1306	{
1307		intersect.Y = -1;
1308	}
1309	else if (currentPos.Y >= (rect.height - halfY))
1310	{
1311		intersect.Y = 1;
1312	}
1313	else
1314	{
1315		intersect.Y = 0;
1316	}
1317
1318	return intersect;
1319};
1320
1321window.JCCatalogElement.prototype.calcMagnifyAreaSize = function()
1322{
1323	var scaleX,
1324		scaleY,
1325		scale;
1326
1327	if (
1328		this.magnify.magnifierParams.width < this.currentImg.width &&
1329			this.magnify.magnifierParams.height < this.currentImg.height
1330		)
1331	{
1332		scaleX = this.magnify.obBigImg.offsetWidth/this.currentImg.width;
1333		scaleY = this.magnify.obBigImg.offsetHeight/this.currentImg.height;
1334		scale =  Math.min(scaleX, scaleY);
1335		this.currentImg.scale = 1/scale;
1336		this.magnify.areaParams.width = Math.max(1, parseInt(scale*this.magnify.magnifierParams.width , 10));
1337		this.magnify.areaParams.height = Math.max(1, parseInt(scale*this.magnify.magnifierParams.height , 10));
1338		this.magnify.areaParams.scaleFactor = this.magnify.magnifierParams.defaultScale;
1339	}
1340	else
1341	{
1342		scaleX = this.obPict.offsetWidth/this.magnify.obBigImg.offsetWidth;
1343		scaleY = this.obPict.offsetHeight/this.magnify.obBigImg.offsetHeight;
1344		scale =  Math.min(scaleX, scaleY);
1345		this.currentImg.scale = 1/scale;
1346		this.magnify.areaParams.width = Math.max(1, parseInt(scale*this.magnify.magnifierParams.width , 10));
1347		this.magnify.areaParams.height = Math.max(1, parseInt(scale*this.magnify.magnifierParams.height , 10));
1348
1349		scaleX = this.magnify.magnifierParams.width/this.currentImg.width;
1350		scaleY = this.magnify.magnifierParams.height/this.currentImg.height;
1351		scale = Math.max(scaleX, scaleY);
1352		this.magnify.areaParams.scaleFactor = scale;
1353	}
1354};
1355
1356window.JCCatalogElement.prototype.calcMagnifyPictSize = function()
1357{
1358	this.magnify.magnifyPictParams.width = this.currentImg.width*this.magnify.areaParams.scaleFactor;
1359	this.magnify.magnifyPictParams.height = this.currentImg.height*this.magnify.areaParams.scaleFactor;
1360};
1361
1362window.JCCatalogElement.prototype.calcMagnifyPictPos = function()
1363{
1364	this.magnify.magnifyPictParams.marginLeft = -parseInt(((this.magnify.areaParams.left-this.currentImg.screenOffsetX)*this.currentImg.scale), 10);
1365	this.magnify.magnifyPictParams.marginTop = -parseInt(((this.magnify.areaParams.top)*this.currentImg.scale), 10);
1366};
1367
1368window.JCCatalogElement.prototype.setMagnifyPictParams = function(show)
1369{
1370	if (!!this.magnify.obMagnifier)
1371	{
1372		show = !!show;
1373		var params = {
1374			width: this.magnify.magnifyPictParams.width+'px',
1375			height: this.magnify.magnifyPictParams.height+'px',
1376			marginTop: this.magnify.magnifyPictParams.marginTop+'px',
1377			marginLeft: this.magnify.magnifyPictParams.marginLeft+'px'
1378		};
1379		if (show)
1380		{
1381			params.display = '';
1382		}
1383		BX.adjust(this.magnify.obMagnifyPict, { style: params, props: { src: this.currentImg.src } });
1384	}
1385};
1386
1387window.JCCatalogElement.prototype.ProductSliderRowLeft = function()
1388{
1389	var target = BX.proxy_context;
1390	if (!!target)
1391	{
1392		if (this.sliderRowShowSize < this.product.slider.COUNT)
1393		{
1394			if (0 > this.product.slider.START)
1395			{
1396				this.product.slider.START++;
1397				BX.adjust(this.product.slider.LIST, { style: { marginLeft: this.product.slider.START*20+'%' }});
1398				BX.adjust(this.product.slider.RIGHT, { style: this.sliderEnableArrow });
1399			}
1400
1401			if (0 <= this.product.slider.START)
1402			{
1403				BX.adjust(this.product.slider.LEFT, { style: this.sliderDisableArrow });
1404			}
1405		}
1406	}
1407};
1408
1409window.JCCatalogElement.prototype.ProductSliderRowRight = function()
1410{
1411	var target = BX.proxy_context;
1412	if (!!target)
1413	{
1414		if (this.sliderRowShowSize < this.product.slider.COUNT)
1415		{
1416			if ((this.sliderRowShowSize - this.product.slider.START) < this.product.slider.COUNT)
1417			{
1418				this.product.slider.START--;
1419				BX.adjust(this.product.slider.LIST, { style: { marginLeft: this.product.slider.START*20+'%' }});
1420				BX.adjust(this.product.slider.LEFT, { style: this.sliderEnableArrow } );
1421			}
1422
1423			if ((this.sliderRowShowSize - this.product.slider.START) >= this.product.slider.COUNT)
1424			{
1425				BX.adjust(this.product.slider.RIGHT, { style: this.sliderDisableArrow } );
1426			}
1427		}
1428	}
1429};
1430
1431window.JCCatalogElement.prototype.ProductSelectSliderImg = function()
1432{
1433	var strValue = '',
1434		target = BX.proxy_context;
1435	if (!!target && target.hasAttribute('data-value'))
1436	{
1437		strValue = target.getAttribute('data-value');
1438		this.SetProductMainPict(strValue);
1439	}
1440};
1441
1442window.JCCatalogElement.prototype.SetProductMainPict = function(intPict)
1443{
1444	var indexPict = -1,
1445		i = 0,
1446		j = 0,
1447		value = '',
1448		strValue = '',
1449		RowItems = null;
1450
1451	if (0 < this.product.sliderCount)
1452	{
1453		for (j = 0; j < this.product.sliderPict.length; j++)
1454		{
1455			if (intPict === this.product.sliderPict[j].ID)
1456			{
1457				indexPict = j;
1458				break;
1459			}
1460		}
1461		if (-1 < indexPict)
1462		{
1463			if (!!this.product.sliderPict[indexPict])
1464			{
1465				this.setCurrentImg(this.product.sliderPict[indexPict], true);
1466			}
1467			RowItems = BX.findChildren(this.product.slider.LIST, {tagName: 'li'}, false);
1468			if (!!RowItems && 0 < RowItems.length)
1469			{
1470				strValue = intPict;
1471				for (i = 0; i < RowItems.length; i++)
1472				{
1473					value = RowItems[i].getAttribute('data-value');
1474					if (value === strValue)
1475					{
1476						BX.addClass(RowItems[i], 'bx_active');
1477					}
1478					else
1479					{
1480						BX.removeClass(RowItems[i], 'bx_active');
1481					}
1482				}
1483			}
1484		}
1485	}
1486};
1487
1488window.JCCatalogElement.prototype.SliderRowLeft = function()
1489{
1490	var strValue = '',
1491		index = -1,
1492		i,
1493		target = BX.proxy_context;
1494	if (!!target && target.hasAttribute('data-value'))
1495	{
1496		strValue = target.getAttribute('data-value');
1497		for (i = 0; i < this.sliders.length; i++)
1498		{
1499			if (this.sliders[i].OFFER_ID === strValue)
1500			{
1501				index = i;
1502				break;
1503			}
1504		}
1505		if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT)
1506		{
1507			if (0 > this.sliders[index].START)
1508			{
1509				this.sliders[index].START++;
1510				BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }});
1511				BX.adjust(this.sliders[index].RIGHT, { style: this.sliderEnableArrow });
1512			}
1513
1514			if (0 <= this.sliders[index].START)
1515			{
1516				BX.adjust(this.sliders[index].LEFT, { style: this.sliderDisableArrow });
1517			}
1518		}
1519	}
1520};
1521
1522window.JCCatalogElement.prototype.SliderRowRight = function()
1523{
1524	var strValue = '',
1525		index = -1,
1526		i,
1527		target = BX.proxy_context;
1528	if (!!target && target.hasAttribute('data-value'))
1529	{
1530		strValue = target.getAttribute('data-value');
1531		for (i = 0; i < this.sliders.length; i++)
1532		{
1533			if (this.sliders[i].OFFER_ID === strValue)
1534			{
1535				index = i;
1536				break;
1537			}
1538		}
1539		if (-1 < index && this.sliderRowShowSize < this.sliders[index].COUNT)
1540		{
1541			if ((this.sliderRowShowSize - this.sliders[index].START) < this.sliders[index].COUNT)
1542			{
1543				this.sliders[index].START--;
1544				BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }});
1545				BX.adjust(this.sliders[index].LEFT, { style: this.sliderEnableArrow } );
1546			}
1547
1548			if ((this.sliderRowShowSize - this.sliders[index].START) >= this.sliders[index].COUNT)
1549			{
1550				BX.adjust(this.sliders[index].RIGHT, { style: this.sliderDisableArrow } );
1551			}
1552		}
1553	}
1554};
1555
1556window.JCCatalogElement.prototype.SelectSliderImg = function()
1557{
1558	var strValue = '',
1559		arItem = [],
1560		target = BX.proxy_context;
1561	if (!!target && target.hasAttribute('data-value'))
1562	{
1563		strValue = target.getAttribute('data-value');
1564		arItem = strValue.split('_');
1565		this.SetMainPict(arItem[0], arItem[1]);
1566	}
1567};
1568
1569window.JCCatalogElement.prototype.SetMainPict = function(intSlider, intPict)
1570{
1571	var index = -1,
1572		indexPict = -1,
1573		i,
1574		j,
1575		value = '',
1576		RowItems = null,
1577		strValue = '';
1578
1579	for (i = 0; i < this.offers.length; i++)
1580	{
1581		if (intSlider === this.offers[i].ID)
1582		{
1583			index = i;
1584			break;
1585		}
1586	}
1587	if (-1 < index)
1588	{
1589		if (0 < this.offers[index].SLIDER_COUNT)
1590		{
1591			for (j = 0; j < this.offers[index].SLIDER.length; j++)
1592			{
1593				if (intPict === this.offers[index].SLIDER[j].ID)
1594				{
1595					indexPict = j;
1596					break;
1597				}
1598			}
1599			if (-1 < indexPict)
1600			{
1601				if (!!this.offers[index].SLIDER[indexPict])
1602				{
1603					this.setCurrentImg(this.offers[index].SLIDER[indexPict], true);
1604				}
1605				RowItems = BX.findChildren(this.sliders[index].LIST, {tagName: 'li'}, false);
1606				if (!!RowItems && 0 < RowItems.length)
1607				{
1608					strValue = intSlider+'_'+intPict;
1609					for (i = 0; i < RowItems.length; i++)
1610					{
1611						value = RowItems[i].getAttribute('data-value');
1612						if (value === strValue)
1613						{
1614							BX.addClass(RowItems[i], 'bx_active');
1615						}
1616						else
1617						{
1618							BX.removeClass(RowItems[i], 'bx_active');
1619						}
1620					}
1621				}
1622			}
1623		}
1624	}
1625};
1626
1627window.JCCatalogElement.prototype.SetMainPictFromItem = function(index)
1628{
1629	if (!!this.obPict)
1630	{
1631		var boolSet = false,
1632			obNewPict = {};
1633
1634		if (!!this.offers[index])
1635		{
1636			if (!!this.offers[index].DETAIL_PICTURE)
1637			{
1638				obNewPict = this.offers[index].DETAIL_PICTURE;
1639				boolSet = true;
1640			}
1641			else if (!!this.offers[index].PREVIEW_PICTURE)
1642			{
1643				obNewPict = this.offers[index].PREVIEW_PICTURE;
1644				boolSet = true;
1645			}
1646		}
1647		if (!boolSet)
1648		{
1649			if (!!this.defaultPict.detail)
1650			{
1651				obNewPict = this.defaultPict.detail;
1652				boolSet = true;
1653			}
1654			else if (!!this.defaultPict.preview)
1655			{
1656				obNewPict = this.defaultPict.preview;
1657				boolSet = true;
1658			}
1659		}
1660		if (boolSet)
1661		{
1662			this.setCurrentImg(obNewPict, true);
1663		}
1664	}
1665};
1666
1667window.JCCatalogElement.prototype.showMainPictPopup = function(e)
1668{
1669	var pictContent = '';
1670
1671	pictContent = '<div style="text-align: center;"><img src="'+
1672		this.currentImg.src+
1673		'" width="'+this.currentImg.width+'" height="'+this.currentImg.height+'" name=""></div>';
1674	this.obPopupPict.setContent(pictContent);
1675	this.obPopupPict.show();
1676	return BX.PreventDefault(e);
1677};
1678
1679window.JCCatalogElement.prototype.QuantityUp = function()
1680{
1681	var curValue = 0,
1682		boolSet = true,
1683		calcPrice;
1684
1685	if (0 === this.errorCode && this.config.showQuantity && this.canBuy && !this.isGift)
1686	{
1687		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1688		if (!isNaN(curValue))
1689		{
1690			curValue += this.stepQuantity;
1691			if (this.checkQuantity)
1692			{
1693				if (curValue > this.maxQuantity)
1694				{
1695					boolSet = false;
1696				}
1697			}
1698
1699			if (boolSet)
1700			{
1701				if (this.isDblQuantity)
1702				{
1703					curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor;
1704				}
1705				this.obQuantity.value = curValue;
1706				calcPrice = {
1707					DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue,
1708					VALUE: this.currentBasisPrice.VALUE * curValue,
1709					DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue,
1710					DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1711					CURRENCY: this.currentBasisPrice.CURRENCY
1712				};
1713				this.setPrice(calcPrice);
1714			}
1715		}
1716	}
1717};
1718
1719window.JCCatalogElement.prototype.QuantityDown = function()
1720{
1721	var curValue = 0,
1722		boolSet = true,
1723		calcPrice;
1724
1725	if (0 === this.errorCode && this.config.showQuantity && this.canBuy && !this.isGift)
1726	{
1727		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1728		if (!isNaN(curValue))
1729		{
1730			curValue -= this.stepQuantity;
1731			if (curValue < this.stepQuantity)
1732			{
1733				boolSet = false;
1734			}
1735			if (boolSet)
1736			{
1737				if (this.isDblQuantity)
1738				{
1739					curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor;
1740				}
1741				this.obQuantity.value = curValue;
1742				calcPrice = {
1743					DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * curValue,
1744					VALUE: this.currentBasisPrice.VALUE * curValue,
1745					DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * curValue,
1746					DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1747					CURRENCY: this.currentBasisPrice.CURRENCY
1748				};
1749				this.setPrice(calcPrice);
1750			}
1751		}
1752	}
1753};
1754
1755window.JCCatalogElement.prototype.QuantityChange = function()
1756{
1757	var curValue = 0,
1758		calcPrice,
1759		intCount,
1760		count;
1761
1762	if (0 === this.errorCode && this.config.showQuantity)
1763	{
1764		if (this.canBuy)
1765		{
1766			curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
1767			if (!isNaN(curValue))
1768			{
1769				if (this.checkQuantity)
1770				{
1771					if (curValue > this.maxQuantity)
1772					{
1773						curValue = this.maxQuantity;
1774					}
1775				}
1776				if (curValue < this.stepQuantity)
1777				{
1778					curValue = this.stepQuantity;
1779				}
1780				else
1781				{
1782					count = Math.round((curValue*this.precisionFactor)/this.stepQuantity)/this.precisionFactor;
1783					intCount = parseInt(count, 10);
1784					if (isNaN(intCount))
1785					{
1786						intCount = 1;
1787						count = 1.1;
1788					}
1789					if (count > intCount)
1790					{
1791						curValue = (intCount <= 1 ? this.stepQuantity : intCount*this.stepQuantity);
1792						curValue = Math.round(curValue*this.precisionFactor)/this.precisionFactor;
1793					}
1794				}
1795				this.obQuantity.value = curValue;
1796			}
1797			else
1798			{
1799				this.obQuantity.value = this.stepQuantity;
1800			}
1801		}
1802		else
1803		{
1804			this.obQuantity.value = this.stepQuantity;
1805		}
1806		calcPrice = {
1807			DISCOUNT_VALUE: this.currentBasisPrice.DISCOUNT_VALUE * this.obQuantity.value,
1808			VALUE: this.currentBasisPrice.VALUE * this.obQuantity.value,
1809			DISCOUNT_DIFF: this.currentBasisPrice.DISCOUNT_DIFF * this.obQuantity.value,
1810			DISCOUNT_DIFF_PERCENT: this.currentBasisPrice.DISCOUNT_DIFF_PERCENT,
1811			CURRENCY: this.currentBasisPrice.CURRENCY
1812		};
1813		this.setPrice(calcPrice);
1814	}
1815};
1816
1817window.JCCatalogElement.prototype.QuantitySet = function(index)
1818{
1819	var basisPrice = '',
1820		strLimit;
1821	if (this.errorCode === 0)
1822	{
1823		this.canBuy = this.offers[index].CAN_BUY;
1824		if (this.canBuy)
1825		{
1826			if (!!this.obBasketActions)
1827			{
1828				BX.style(this.obBasketActions, 'display', '');
1829			}
1830			if (!!this.obNotAvail)
1831			{
1832				BX.style(this.obNotAvail, 'display', 'none');
1833			}
1834		}
1835		else
1836		{
1837			if (!!this.obBasketActions)
1838			{
1839				BX.style(this.obBasketActions, 'display', 'none');
1840			}
1841			if (!!this.obNotAvail)
1842			{
1843				BX.style(this.obNotAvail, 'display', '');
1844			}
1845		}
1846		if (this.config.showQuantity)
1847		{
1848			this.isDblQuantity = this.offers[index].QUANTITY_FLOAT;
1849			this.checkQuantity = this.offers[index].CHECK_QUANTITY;
1850			if (this.isDblQuantity)
1851			{
1852				this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY);
1853				this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY)*this.precisionFactor)/this.precisionFactor;
1854			}
1855			else
1856			{
1857				this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10);
1858				this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10);
1859			}
1860			this.obQuantity.value = this.stepQuantity;
1861			this.obQuantity.disabled = !this.canBuy;
1862			if (!!this.obMeasure)
1863			{
1864				if (!!this.offers[index].MEASURE)
1865				{
1866					BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE});
1867				}
1868				else
1869				{
1870					BX.adjust(this.obMeasure, { html : ''});
1871				}
1872			}
1873			if (!!this.obQuantityLimit.all)
1874			{
1875				if (!this.checkQuantity)
1876				{
1877					BX.adjust(this.obQuantityLimit.value, { html: '' });
1878					BX.adjust(this.obQuantityLimit.all, { style: {display: 'none'} });
1879				}
1880				else
1881				{
1882					strLimit = this.offers[index].MAX_QUANTITY;
1883					if (!!this.offers[index].MEASURE)
1884					{
1885						strLimit += (' '+this.offers[index].MEASURE);
1886					}
1887					BX.adjust(this.obQuantityLimit.value, { html: strLimit});
1888					BX.adjust(this.obQuantityLimit.all, { style: {display: ''} });
1889				}
1890			}
1891			if (!!this.obBasisPrice)
1892			{
1893				if (!!this.offers[index].BASIS_PRICE)
1894				{
1895					basisPrice = BX.message('BASIS_PRICE_MESSAGE');
1896					basisPrice = basisPrice.replace(
1897						'#PRICE#',
1898						BX.Currency.currencyFormat(this.offers[index].BASIS_PRICE.DISCOUNT_VALUE, this.offers[index].BASIS_PRICE.CURRENCY, true)
1899					);
1900					basisPrice = basisPrice.replace('#MEASURE#', this.offers[index].MEASURE);
1901					BX.adjust(this.obBasisPrice, { style: { display: '' }, html: basisPrice });
1902				}
1903				else
1904				{
1905					BX.adjust(this.obBasisPrice, { style: { display: 'none' }, html: '' });
1906				}
1907			}
1908		}
1909		this.currentBasisPrice = this.offers[index].BASIS_PRICE;
1910	}
1911};
1912
1913window.JCCatalogElement.prototype.SelectOfferProp = function()
1914{
1915	var i = 0,
1916		strTreeValue = '',
1917		arTreeItem = [],
1918		RowItems = null,
1919		target = BX.proxy_context;
1920
1921	if (!!target && target.hasAttribute('data-treevalue'))
1922	{
1923		if (typeof(document.activeElement) === 'object')
1924			document.activeElement.blur();
1925		strTreeValue = target.getAttribute('data-treevalue');
1926		arTreeItem = strTreeValue.split('_');
1927		this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
1928		RowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false);
1929		if (!!RowItems && 0 < RowItems.length)
1930		{
1931			for (i = 0; i < RowItems.length; i++)
1932			{
1933				BX.removeClass(RowItems[i], 'bx_active');
1934			}
1935		}
1936		BX.addClass(target, 'bx_active');
1937	}
1938};
1939
1940window.JCCatalogElement.prototype.SearchOfferPropIndex = function(strPropID, strPropValue)
1941{
1942	var strName = '',
1943		arShowValues = false,
1944		arCanBuyValues = [],
1945		allValues = [],
1946		index = -1,
1947		i, j,
1948		arFilter = {},
1949		tmpFilter = [];
1950
1951	for (i = 0; i < this.treeProps.length; i++)
1952	{
1953		if (this.treeProps[i].ID === strPropID)
1954		{
1955			index = i;
1956			break;
1957		}
1958	}
1959
1960	if (-1 < index)
1961	{
1962		for (i = 0; i < index; i++)
1963		{
1964			strName = 'PROP_'+this.treeProps[i].ID;
1965			arFilter[strName] = this.selectedValues[strName];
1966		}
1967		strName = 'PROP_'+this.treeProps[index].ID;
1968		arFilter[strName] = strPropValue;
1969		for (i = index+1; i < this.treeProps.length; i++)
1970		{
1971			strName = 'PROP_'+this.treeProps[i].ID;
1972			arShowValues = this.GetRowValues(arFilter, strName);
1973			if (!arShowValues)
1974			{
1975				break;
1976			}
1977			allValues = [];
1978			if (this.config.showAbsent)
1979			{
1980				arCanBuyValues = [];
1981				tmpFilter = [];
1982				tmpFilter = BX.clone(arFilter, true);
1983				for (j = 0; j < arShowValues.length; j++)
1984				{
1985					tmpFilter[strName] = arShowValues[j];
1986					allValues[allValues.length] = arShowValues[j];
1987					if (this.GetCanBuy(tmpFilter))
1988						arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
1989				}
1990			}
1991			else
1992			{
1993				arCanBuyValues = arShowValues;
1994			}
1995			if (!!this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues))
1996			{
1997				arFilter[strName] = this.selectedValues[strName];
1998			}
1999			else
2000			{
2001				if (this.config.showAbsent)
2002					arFilter[strName] = (arCanBuyValues.length > 0 ? arCanBuyValues[0] : allValues[0]);
2003				else
2004					arFilter[strName] = arCanBuyValues[0];
2005			}
2006			this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
2007		}
2008		this.selectedValues = arFilter;
2009		this.ChangeInfo();
2010	}
2011};
2012
2013window.JCCatalogElement.prototype.RowLeft = function()
2014{
2015	var strTreeValue = '',
2016		index = -1,
2017		i,
2018		target = BX.proxy_context;
2019	if (!!target && target.hasAttribute('data-treevalue'))
2020	{
2021		strTreeValue = target.getAttribute('data-treevalue');
2022		for (i = 0; i < this.treeProps.length; i++)
2023		{
2024			if (this.treeProps[i].ID === strTreeValue)
2025			{
2026				index = i;
2027				break;
2028			}
2029		}
2030		if (-1 < index && this.treeRowShowSize < this.showCount[index])
2031		{
2032			if (0 > this.showStart[index])
2033			{
2034				this.showStart[index]++;
2035				BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }});
2036				BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeEnableArrow });
2037			}
2038
2039			if (0 <= this.showStart[index])
2040			{
2041				BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeDisableArrow });
2042			}
2043		}
2044	}
2045};
2046
2047window.JCCatalogElement.prototype.RowRight = function()
2048{
2049	var strTreeValue = '',
2050		index = -1,
2051		i,
2052		target = BX.proxy_context;
2053	if (!!target && target.hasAttribute('data-treevalue'))
2054	{
2055		strTreeValue = target.getAttribute('data-treevalue');
2056		for (i = 0; i < this.treeProps.length; i++)
2057		{
2058			if (this.treeProps[i].ID === strTreeValue)
2059			{
2060				index = i;
2061				break;
2062			}
2063		}
2064		if (-1 < index && this.treeRowShowSize < this.showCount[index])
2065		{
2066			if ((this.treeRowShowSize - this.showStart[index]) < this.showCount[index])
2067			{
2068				this.showStart[index]--;
2069				BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }});
2070				BX.adjust(this.obTreeRows[index].LEFT, { style: this.treeEnableArrow });
2071			}
2072
2073			if ((this.treeRowShowSize - this.showStart[index]) >= this.showCount[index])
2074			{
2075				BX.adjust(this.obTreeRows[index].RIGHT, { style: this.treeDisableArrow });
2076			}
2077		}
2078	}
2079};
2080
2081window.JCCatalogElement.prototype.UpdateRow = function(intNumber, activeID, showID, canBuyID)
2082{
2083	var i = 0,
2084		showI = 0,
2085		value = '',
2086		countShow = 0,
2087		strNewLen = '',
2088		obData = {},
2089		RowItems = null,
2090		pictMode = false,
2091		extShowMode = false,
2092		isCurrent = false,
2093		selectIndex = 0,
2094		obLeft = this.treeEnableArrow,
2095		obRight = this.treeEnableArrow,
2096		currentShowStart = 0;
2097
2098	if (-1 < intNumber && intNumber < this.obTreeRows.length)
2099	{
2100		RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: 'li'}, false);
2101		if (!!RowItems && 0 < RowItems.length)
2102		{
2103			pictMode = ('PICT' === this.treeProps[intNumber].SHOW_MODE);
2104			countShow = showID.length;
2105			extShowMode = this.treeRowShowSize < countShow;
2106			strNewLen = (this.treeRowShowSize < countShow ? (100/countShow)+'%' : '20%');
2107			obData = {
2108				props: { className: '' },
2109				style: {
2110					width: strNewLen
2111				}
2112			};
2113			if (pictMode)
2114			{
2115				obData.style.paddingTop = strNewLen;
2116			}
2117			for (i = 0; i < RowItems.length; i++)
2118			{
2119				value = RowItems[i].getAttribute('data-onevalue');
2120				isCurrent = (value === activeID);
2121				if (BX.util.in_array(value, canBuyID))
2122				{
2123					obData.props.className = (isCurrent ? 'bx_active' : '');
2124				}
2125				else
2126				{
2127					obData.props.className = (isCurrent ? 'bx_active bx_missing' : 'bx_missing');
2128				}
2129				obData.style.display = 'none';
2130				if (BX.util.in_array(value, showID))
2131				{
2132					obData.style.display = '';
2133					if (isCurrent)
2134					{
2135						selectIndex = showI;
2136					}
2137					showI++;
2138				}
2139				BX.adjust(RowItems[i], obData);
2140			}
2141
2142			obData = {
2143				style: {
2144					width: (extShowMode ? 20*countShow : 100)+'%',
2145					marginLeft: '0%'
2146				}
2147			};
2148
2149			if (pictMode)
2150			{
2151				BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode ? 'bx_item_detail_scu full' : 'bx_item_detail_scu')}});
2152			}
2153			else
2154			{
2155				BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (extShowMode < countShow ? 'bx_item_detail_size full' : 'bx_item_detail_size')}});
2156			}
2157			if (extShowMode)
2158			{
2159				if (selectIndex +1 === countShow)
2160				{
2161					obRight = this.treeDisableArrow;
2162				}
2163				if (this.treeRowShowSize <= selectIndex)
2164				{
2165					currentShowStart = this.treeRowShowSize - selectIndex - 1;
2166					obData.style.marginLeft = currentShowStart*20+'%';
2167				}
2168				if (0 === currentShowStart)
2169				{
2170					obLeft = this.treeDisableArrow;
2171				}
2172				BX.adjust(this.obTreeRows[intNumber].LEFT, {style: obLeft });
2173				BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: obRight });
2174			}
2175			else
2176			{
2177				BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: 'none'}});
2178				BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: 'none'}});
2179			}
2180			BX.adjust(this.obTreeRows[intNumber].LIST, obData);
2181			this.showCount[intNumber] = countShow;
2182			this.showStart[intNumber] = currentShowStart;
2183		}
2184	}
2185};
2186
2187window.JCCatalogElement.prototype.GetRowValues = function(arFilter, index)
2188{
2189	var arValues = [],
2190		i = 0,
2191		j = 0,
2192		boolSearch = false,
2193		boolOneSearch = true;
2194
2195	if (0 === arFilter.length)
2196	{
2197		for (i = 0; i < this.offers.length; i++)
2198		{
2199			if (!BX.util.in_array(this.offers[i].TREE[index], arValues))
2200			{
2201				arValues[arValues.length] = this.offers[i].TREE[index];
2202			}
2203		}
2204		boolSearch = true;
2205	}
2206	else
2207	{
2208		for (i = 0; i < this.offers.length; i++)
2209		{
2210			boolOneSearch = true;
2211			for (j in arFilter)
2212			{
2213				if (arFilter[j] !== this.offers[i].TREE[j])
2214				{
2215					boolOneSearch = false;
2216					break;
2217				}
2218			}
2219			if (boolOneSearch)
2220			{
2221				if (!BX.util.in_array(this.offers[i].TREE[index], arValues))
2222				{
2223					arValues[arValues.length] = this.offers[i].TREE[index];
2224				}
2225				boolSearch = true;
2226			}
2227		}
2228	}
2229	return (boolSearch ? arValues : false);
2230};
2231
2232window.JCCatalogElement.prototype.GetCanBuy = function(arFilter)
2233{
2234	var i = 0,
2235		j = 0,
2236		boolOneSearch = true,
2237		boolSearch = false;
2238
2239	for (i = 0; i < this.offers.length; i++)
2240	{
2241		boolOneSearch = true;
2242		for (j in arFilter)
2243		{
2244			if (arFilter[j] !== this.offers[i].TREE[j])
2245			{
2246				boolOneSearch = false;
2247				break;
2248			}
2249		}
2250		if (boolOneSearch)
2251		{
2252			if (this.offers[i].CAN_BUY)
2253			{
2254				boolSearch = true;
2255				break;
2256			}
2257		}
2258	}
2259	return boolSearch;
2260};
2261
2262window.JCCatalogElement.prototype.SetCurrent = function()
2263{
2264	var i = 0,
2265		j = 0,
2266		strName = '',
2267		arShowValues = false,
2268		arCanBuyValues = [],
2269		arFilter = {},
2270		tmpFilter = [],
2271		current = this.offers[this.offerNum].TREE;
2272
2273	for (i = 0; i < this.treeProps.length; i++)
2274	{
2275		strName = 'PROP_'+this.treeProps[i].ID;
2276		arShowValues = this.GetRowValues(arFilter, strName);
2277		if (!arShowValues)
2278		{
2279			break;
2280		}
2281		if (BX.util.in_array(current[strName], arShowValues))
2282		{
2283			arFilter[strName] = current[strName];
2284		}
2285		else
2286		{
2287			arFilter[strName] = arShowValues[0];
2288			this.offerNum = 0;
2289		}
2290		if (this.config.showAbsent)
2291		{
2292			arCanBuyValues = [];
2293			tmpFilter = [];
2294			tmpFilter = BX.clone(arFilter, true);
2295			for (j = 0; j < arShowValues.length; j++)
2296			{
2297				tmpFilter[strName] = arShowValues[j];
2298				if (this.GetCanBuy(tmpFilter))
2299				{
2300					arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
2301				}
2302			}
2303		}
2304		else
2305		{
2306			arCanBuyValues = arShowValues;
2307		}
2308		this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
2309	}
2310	this.selectedValues = arFilter;
2311	this.ChangeInfo();
2312};
2313
2314window.JCCatalogElement.prototype.ChangeInfo = function()
2315{
2316	var index = -1,
2317		i,
2318		j = 0,
2319		boolOneSearch = true,
2320		eventData = {
2321			currentId: (this.offerNum > -1 ? this.offers[this.offerNum].ID : 0),
2322			newId: 0
2323		};
2324
2325	for (i = 0; i < this.offers.length; i++)
2326	{
2327		boolOneSearch = true;
2328		for (j in this.selectedValues)
2329		{
2330			if (this.selectedValues[j] !== this.offers[i].TREE[j])
2331			{
2332				boolOneSearch = false;
2333				break;
2334			}
2335		}
2336		if (boolOneSearch)
2337		{
2338			index = i;
2339			break;
2340		}
2341	}
2342	if (-1 < index)
2343	{
2344		if(index != this.offerNum)
2345		{
2346			this.isGift = false;
2347		}
2348
2349		this.setPrice(this.offers[index].PRICE);
2350		for (i = 0; i < this.offers.length; i++)
2351		{
2352			if (this.config.showOfferGroup && this.offers[i].OFFER_GROUP)
2353			{
2354				if (i !== index)
2355				{
2356					BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[i].ID), { style: {display: 'none'} });
2357				}
2358			}
2359			if (!!this.sliders[i].ID)
2360			{
2361				if (i === index)
2362				{
2363					this.sliders[i].START = 0;
2364					BX.adjust(this.sliders[i].LIST, {style: { marginLeft: '0%' }});
2365					BX.adjust(this.sliders[i].CONT, {style: { display: ''}});
2366					BX.adjust(this.sliders[i].LEFT, { style: this.sliderDisableArrow } );
2367					BX.adjust(this.sliders[i].RIGHT, { style: this.sliderEnableArrow } );
2368				}
2369				else
2370				{
2371					BX.adjust(this.sliders[i].CONT, {style: { display: 'none'}});
2372				}
2373			}
2374		}
2375		if (this.config.showOfferGroup && this.offers[index].OFFER_GROUP)
2376		{
2377			BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[index].ID), { style: {display: ''} });
2378		}
2379		if (0 < this.offers[index].SLIDER_COUNT)
2380		{
2381			this.SetMainPict(this.offers[index].ID, this.offers[index].SLIDER[0].ID);
2382		}
2383		else
2384		{
2385			this.SetMainPictFromItem(index);
2386		}
2387
2388		if (this.config.showSkuProps && !!this.obSkuProps)
2389		{
2390			if (!this.offers[index].DISPLAY_PROPERTIES || this.offers[index].DISPLAY_PROPERTIES.length === 0)
2391			{
2392				BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''});
2393			}
2394			else
2395			{
2396				BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES});
2397			}
2398		}
2399		this.offerNum = index;
2400		this.QuantitySet(this.offerNum);
2401
2402		this.incViewedCounter();
2403		eventData.newId = this.offers[this.offerNum].ID;
2404		// only for compatible catalog.store.amout custom templates
2405		BX.onCustomEvent('onCatalogStoreProductChange', [this.offers[this.offerNum].ID]);
2406		// new event
2407		BX.onCustomEvent('onCatalogElementChangeOffer', eventData);
2408		eventData = null;
2409	}
2410};
2411
2412window.JCCatalogElement.prototype.restoreSticker = function()
2413{
2414	if(this.previousStickerText)
2415	{
2416		this.redrawSticker({text: this.previousStickerText});
2417	}
2418	else
2419	{
2420		this.hideSticker();
2421	}
2422};
2423
2424window.JCCatalogElement.prototype.hideSticker = function()
2425{
2426	BX.hide(BX(this.visual.STICKER_ID));
2427};
2428
2429window.JCCatalogElement.prototype.redrawSticker = function(stickerData)
2430{
2431	stickerData = stickerData || {};
2432	var text = stickerData.text || '';
2433
2434	var sticker = BX(this.visual.STICKER_ID);
2435	if(!sticker)
2436	{
2437		return;
2438	}
2439	BX.show(BX(this.visual.STICKER_ID), 'block');
2440
2441	var previousStickerText = sticker.getAttribute('title');
2442	if(previousStickerText && previousStickerText != text)
2443	{
2444		this.previousStickerText = previousStickerText;
2445	}
2446	BX.adjust(sticker, {
2447		text: text,
2448		attrs: {
2449			title: text
2450		}
2451	})
2452};
2453
2454window.JCCatalogElement.prototype.setPrice = function(price)
2455{
2456	var economyInfo = '';
2457
2458	if(this.isGift)
2459	{
2460		price.DISCOUNT_VALUE = 0;
2461		price.DISCOUNT_DIFF = price.VALUE;
2462		price.DISCOUNT_DIFF_PERCENT = -100;
2463	}
2464
2465	if (!!this.obPrice.price)
2466	{
2467		BX.adjust(this.obPrice.price, {html: BX.Currency.currencyFormat(price.DISCOUNT_VALUE, price.CURRENCY, true)});
2468		if (price.DISCOUNT_VALUE !== price.VALUE)
2469		{
2470			if (this.config.showOldPrice)
2471			{
2472				if (!!this.obPrice.full)
2473				{
2474					BX.adjust(this.obPrice.full, {style: {display: ''}, html: BX.Currency.currencyFormat(price.VALUE, price.CURRENCY, true)});
2475				}
2476				if (!!this.obPrice.discount)
2477				{
2478					economyInfo = BX.message('ECONOMY_INFO_MESSAGE');
2479					economyInfo = economyInfo.replace('#ECONOMY#', BX.Currency.currencyFormat(price.DISCOUNT_DIFF, price.CURRENCY, true));
2480					BX.adjust(this.obPrice.discount, {style: {display: ''}, html: economyInfo });
2481				}
2482			}
2483			if (this.config.showPercent)
2484			{
2485				if (!!this.obPrice.percent)
2486				{
2487					BX.adjust(this.obPrice.percent, {style: {display: ''}, html: price.DISCOUNT_DIFF_PERCENT+'%'});
2488				}
2489			}
2490		}
2491		else
2492		{
2493			if (this.config.showOldPrice)
2494			{
2495				if (!!this.obPrice.full)
2496				{
2497					BX.adjust(this.obPrice.full, {style: {display: 'none'}, html: ''});
2498				}
2499				if (!!this.obPrice.discount)
2500				{
2501					BX.adjust(this.obPrice.discount, {style: {display: 'none'}, html: ''});
2502				}
2503			}
2504			if (this.config.showPercent)
2505			{
2506				if (!!this.obPrice.percent)
2507				{
2508					BX.adjust(this.obPrice.percent, {style: {display: 'none'}, html: ''});
2509				}
2510			}
2511		}
2512	}
2513};
2514
2515window.JCCatalogElement.prototype.Compare = function()
2516{
2517	var compareParams, compareLink;
2518	if (!!this.compareData.compareUrl)
2519	{
2520		switch (this.productType)
2521		{
2522			case 0://no catalog
2523			case 1://product
2524			case 2://set
2525				compareLink = this.compareData.compareUrl.replace('#ID#', this.product.id.toString());
2526				break;
2527			case 3://sku
2528				compareLink = this.compareData.compareUrl.replace('#ID#', this.offers[this.offerNum].ID);
2529				break;
2530		}
2531		compareParams = {
2532			ajax_action: 'Y'
2533		};
2534		BX.ajax.loadJSON(
2535			compareLink,
2536			compareParams,
2537			BX.proxy(this.CompareResult, this)
2538		);
2539	}
2540};
2541
2542window.JCCatalogElement.prototype.CompareResult = function(result)
2543{
2544	var popupContent, popupButtons, popupTitle;
2545	if (!!this.obPopupWin)
2546		this.obPopupWin.close();
2547
2548	if (typeof result !== 'object')
2549		return false;
2550
2551	this.InitPopupWindow();
2552	popupTitle = {
2553		content: BX.create('div', {
2554			style: { marginRight: '30px', whiteSpace: 'nowrap' },
2555			text: BX.message('COMPARE_TITLE')
2556		})
2557	};
2558	if (result.STATUS === 'OK')
2559	{
2560		BX.onCustomEvent('OnCompareChange');
2561		popupContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><p>'+BX.message('COMPARE_MESSAGE_OK')+'</p></div>';
2562		if (this.config.showClosePopup)
2563		{
2564			popupButtons = [
2565				new BasketButton({
2566					ownerClass: this.obProduct.className,
2567					text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
2568					events: {
2569						click: BX.delegate(this.CompareRedirect, this)
2570					},
2571					style: {marginRight: '10px'}
2572				}),
2573				new BasketButton({
2574					ownerClass: this.obProduct.className,
2575					text: BX.message('BTN_MESSAGE_CLOSE_POPUP'),
2576					events: {
2577						click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2578					}
2579				})
2580			];
2581		}
2582		else
2583		{
2584			popupButtons = [
2585				new BasketButton({
2586					ownerClass: this.obProduct.className,
2587					text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
2588					events: {
2589						click: BX.delegate(this.CompareRedirect, this)
2590					}
2591				})
2592			];
2593		}
2594	}
2595	else
2596	{
2597		popupContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><p>'+(!!result.MESSAGE ? result.MESSAGE : BX.message('COMPARE_UNKNOWN_ERROR'))+'</p></div>';
2598		popupButtons = [
2599			new BasketButton({
2600				ownerClass: this.obProduct.className,
2601				text: BX.message('BTN_MESSAGE_CLOSE'),
2602				events: {
2603					click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2604				}
2605
2606			})
2607		];
2608	}
2609	this.obPopupWin.setTitleBar(popupTitle);
2610	this.obPopupWin.setContent(popupContent);
2611	this.obPopupWin.setButtons(popupButtons);
2612	this.obPopupWin.show();
2613	return false;
2614};
2615
2616window.JCCatalogElement.prototype.CompareRedirect = function()
2617{
2618	if (!!this.compareData.comparePath)
2619		location.href = this.compareData.comparePath;
2620	else
2621		this.obPopupWin.close();
2622};
2623
2624window.JCCatalogElement.prototype.InitBasketUrl = function()
2625{
2626	this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url);
2627	switch (this.productType)
2628	{
2629		case 1://product
2630		case 2://set
2631			this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString());
2632			break;
2633		case 3://sku
2634			this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID);
2635			break;
2636	}
2637	this.basketParams = {
2638		'ajax_basket': 'Y'
2639	};
2640	if (this.config.showQuantity)
2641	{
2642		this.basketParams[this.basketData.quantity] = this.obQuantity.value;
2643	}
2644	if (!!this.basketData.sku_props)
2645	{
2646		this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props;
2647	}
2648};
2649
2650window.JCCatalogElement.prototype.FillBasketProps = function()
2651{
2652	if (!this.visual.BASKET_PROP_DIV)
2653		return;
2654
2655	var
2656		i = 0,
2657		propCollection = null,
2658		foundValues = false,
2659		obBasketProps = null;
2660	if (this.basketData.useProps && !this.basketData.emptyProps)
2661	{
2662		if (!!this.obPopupWin && !!this.obPopupWin.contentContainer)
2663			obBasketProps = this.obPopupWin.contentContainer;
2664	}
2665	else
2666	{
2667		obBasketProps = BX(this.visual.BASKET_PROP_DIV);
2668	}
2669	if (!!obBasketProps)
2670	{
2671		propCollection = obBasketProps.getElementsByTagName('select');
2672		if (!!propCollection && !!propCollection.length)
2673		{
2674			for (i = 0; i < propCollection.length; i++)
2675			{
2676				if (!propCollection[i].disabled)
2677				{
2678					switch(propCollection[i].type.toLowerCase())
2679					{
2680						case 'select-one':
2681							this.basketParams[propCollection[i].name] = propCollection[i].value;
2682							foundValues = true;
2683							break;
2684						default:
2685							break;
2686					}
2687				}
2688			}
2689		}
2690		propCollection = obBasketProps.getElementsByTagName('input');
2691		if (!!propCollection && !!propCollection.length)
2692		{
2693			for (i = 0; i < propCollection.length; i++)
2694			{
2695				if (!propCollection[i].disabled)
2696				{
2697					switch(propCollection[i].type.toLowerCase())
2698					{
2699						case 'hidden':
2700							this.basketParams[propCollection[i].name] = propCollection[i].value;
2701							foundValues = true;
2702							break;
2703						case 'radio':
2704							if (propCollection[i].checked)
2705							{
2706								this.basketParams[propCollection[i].name] = propCollection[i].value;
2707								foundValues = true;
2708							}
2709							break;
2710						default:
2711							break;
2712					}
2713				}
2714			}
2715		}
2716	}
2717	if (!foundValues)
2718	{
2719		this.basketParams[this.basketData.props] = [];
2720		this.basketParams[this.basketData.props][0] = 0;
2721	}
2722};
2723
2724window.JCCatalogElement.prototype.SendToBasket = function()
2725{
2726	if (!this.canBuy)
2727		return;
2728
2729	this.InitBasketUrl();
2730	this.FillBasketProps();
2731	BX.ajax.loadJSON(
2732		this.basketUrl,
2733		this.basketParams,
2734		BX.proxy(this.BasketResult, this)
2735	);
2736};
2737
2738window.JCCatalogElement.prototype.Add2Basket = function()
2739{
2740	this.basketMode = 'ADD';
2741	this.Basket();
2742};
2743
2744window.JCCatalogElement.prototype.BuyBasket = function()
2745{
2746	this.basketMode = 'BUY';
2747	this.Basket();
2748};
2749
2750window.JCCatalogElement.prototype.Basket = function()
2751{
2752	var contentBasketProps = '';
2753	if (!this.canBuy)
2754		return;
2755
2756	switch (this.productType)
2757	{
2758	case 1://product
2759	case 2://set
2760		if (this.basketData.useProps && !this.basketData.emptyProps)
2761		{
2762			this.InitPopupWindow();
2763			this.obPopupWin.setTitleBar({
2764				content: BX.create('div', {
2765					style: { marginRight: '30px', whiteSpace: 'nowrap' },
2766					text: BX.message('TITLE_BASKET_PROPS')
2767				})
2768			});
2769			if (BX(this.visual.BASKET_PROP_DIV))
2770			{
2771				contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML;
2772			}
2773			this.obPopupWin.setContent(contentBasketProps);
2774			this.obPopupWin.setButtons([
2775				new BasketButton({
2776					ownerClass: this.obProduct.className,
2777					text: BX.message('BTN_SEND_PROPS'),
2778					events: {
2779						click: BX.delegate(this.SendToBasket, this)
2780					}
2781				})
2782			]);
2783			this.obPopupWin.show();
2784		}
2785		else
2786		{
2787			this.SendToBasket();
2788		}
2789		break;
2790	case 3://sku
2791		this.SendToBasket();
2792		break;
2793	}
2794};
2795
2796window.JCCatalogElement.prototype.BasketResult = function(arResult)
2797{
2798	var popupContent, popupButtons, popupTitle, productPict;
2799	if (!!this.obPopupWin)
2800		this.obPopupWin.close();
2801
2802	if (typeof arResult !== 'object')
2803		return false;
2804
2805	if (arResult.STATUS === 'OK' && this.basketMode === 'BUY')
2806	{
2807		this.BasketRedirect();
2808	}
2809	else
2810	{
2811		this.InitPopupWindow();
2812		popupTitle = {
2813			content: BX.create('div', {
2814				style: { marginRight: '30px', whiteSpace: 'nowrap' },
2815				text: (arResult.STATUS === 'OK' ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR'))
2816			})
2817		};
2818		if (arResult.STATUS === 'OK')
2819		{
2820			BX.onCustomEvent('OnBasketChange');
2821			switch (this.productType)
2822			{
2823				case 1://
2824				case 2://
2825					productPict = this.product.pict.SRC;
2826					break;
2827				case 3:
2828					productPict = (!!this.offers[this.offerNum].PREVIEW_PICTURE ?
2829						this.offers[this.offerNum].PREVIEW_PICTURE.SRC :
2830						this.defaultPict.pict.SRC
2831						);
2832					break;
2833			}
2834			popupContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><img src="'+productPict+'" height="130" style="max-height:130px"><p>'+this.product.name+'</p></div>';
2835			if (this.config.showClosePopup)
2836			{
2837				popupButtons = [
2838					new BasketButton({
2839						ownerClass: this.obProduct.className,
2840						text: BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2841						events: {
2842							click: BX.delegate(this.BasketRedirect, this)
2843						},
2844						style: {marginRight: '10px'}
2845					}),
2846					new BasketButton({
2847						ownerClass: this.obProduct.className,
2848						text: BX.message('BTN_MESSAGE_CLOSE_POPUP'),
2849						events: {
2850							click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2851						}
2852					})
2853				];
2854			}
2855			else
2856			{
2857				popupButtons = [
2858					new BasketButton({
2859						ownerClass: this.obProduct.className,
2860						text: BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2861						events: {
2862							click: BX.delegate(this.BasketRedirect, this)
2863						}
2864					})
2865				];
2866			}
2867		}
2868		else
2869		{
2870			popupContent = '<div style="width: 96%; margin: 10px 2%; text-align: center;"><p>'+(!!arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR'))+'</p></div>';
2871			popupButtons = [
2872				new BasketButton({
2873					ownerClass: this.obProduct.className,
2874					text: BX.message('BTN_MESSAGE_CLOSE'),
2875					events: {
2876						click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2877					}
2878
2879				})
2880			];
2881		}
2882		this.obPopupWin.setTitleBar(popupTitle);
2883		this.obPopupWin.setContent(popupContent);
2884		this.obPopupWin.setButtons(popupButtons);
2885		this.obPopupWin.show();
2886	}
2887	return false;
2888};
2889
2890window.JCCatalogElement.prototype.BasketRedirect = function()
2891{
2892	location.href = (!!this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL'));
2893};
2894
2895window.JCCatalogElement.prototype.InitPopupWindow = function()
2896{
2897	if (!!this.obPopupWin)
2898		return;
2899
2900	this.obPopupWin = BX.PopupWindowManager.create('CatalogElementBasket_'+this.visual.ID, null, {
2901		autoHide: false,
2902		offsetLeft: 0,
2903		offsetTop: 0,
2904		overlay : true,
2905		closeByEsc: true,
2906		titleBar: true,
2907		closeIcon: {top: '10px', right: '10px'}
2908	});
2909};
2910
2911window.JCCatalogElement.prototype.onPopupWindowShow = function(popup)
2912{
2913	BX.bind(document, 'click', BX.proxy(this.popupWindowClick, this));
2914};
2915
2916window.JCCatalogElement.prototype.onPopupWindowClose = function(popup, event)
2917{
2918	BX.unbind(document, 'click', BX.proxy(this.popupWindowClick, this));
2919};
2920
2921window.JCCatalogElement.prototype.popupWindowClick = function()
2922{
2923	if (!!this.obPopupPict && typeof (this.obPopupPict) === 'object')
2924	{
2925		if (this.obPopupPict.isShown())
2926			this.obPopupPict.close();
2927	}
2928};
2929
2930window.JCCatalogElement.prototype.incViewedCounter = function()
2931{
2932	if (this.currentIsSet && !this.updateViewedCount)
2933	{
2934		switch (this.productType)
2935		{
2936			case 1:
2937			case 2:
2938				this.viewedCounter.params.PRODUCT_ID = this.product.id;
2939				this.viewedCounter.params.PARENT_ID = this.product.id;
2940				break;
2941			case 3:
2942				this.viewedCounter.params.PARENT_ID = this.product.id;
2943				this.viewedCounter.params.PRODUCT_ID = this.offers[this.offerNum].ID;
2944				break;
2945			default:
2946				return;
2947		}
2948		this.viewedCounter.params.SITE_ID = BX.message('SITE_ID');
2949		this.updateViewedCount = true;
2950		BX.ajax.post(
2951			this.viewedCounter.path,
2952			this.viewedCounter.params,
2953			BX.delegate(function(){ this.updateViewedCount = false; }, this)
2954		);
2955	}
2956};
2957
2958window.JCCatalogElement.prototype.allowViewedCount = function(update)
2959{
2960	update = !!update;
2961	this.currentIsSet = true;
2962	if (update)
2963		this.incViewedCounter();
2964};
2965})(window);

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.