PageSourceSearch

https://24naukowa.com.pl/js/page.js?ver=2.0

js 24naukowa.com.pl collected 2026-10-05 18:06:19 UTC 41,772 bytes, 1,280 lines download raw bytes

1function _$(id){var D=document;return D.getElementById?D.getElementById(id):D.all?D.all[id]:null;}
2function floatval(v){var p=parseFloat(v);return (isNaN(p))?0:p;}
3function trim(s){return jQuery.trim(s);}
4function spr_mail(s){return check_mail(s);}
5function clickProductNotification(){
6	if(typeof($.fancybox.open)==='undefined'){
7		$.fancybox({href: '#formNotification', autoDimensions: false, width: 400, height: 300});
8	}
9	else {
10		$.fancybox.open({src: '#formNotification', type: 'inline'});
11	}
12	return false;
13}
14function submitFormNotification(){
15	var f=_$('formNotification');
16	if(!check_mail(f.email.value)){
17		alert(_t('Proszę wpisać prawiłowy adres e-mail'));
18		f.email.focus();
19		return;
20	}
21	if(!f.zgoda.checked){
22		alert(_t('Proszę zaznaczyć zgodę na przesłanie informacji'));
23		return;
24	}
25	$.ajax({
26		type: 'POST',
27		url: './?a=portal.saveProductNotification',
28		data: $(f).serialize(),
29		dataType: 'html',
30		cache: false,
31		beforeSend: function(request){cart_ajax_sending=true;},
32		error: function(request,textStatus,errorThrown){cart_ajax_sending=false;alert(_t('Błąd przy odczycie danych z serwera'));},
33		success: function(response){
34			cart_ajax_sending=false;
35			if(response===''){
36				$.fancybox.close();
37				alert(_t('Dane zostały zapisane'));
38			}
39			else{
40				alert(response);
41			}
42		}
43	});
44}
45function clickAddToClipboard(e){
46	if((typeof(googleAnalytics4)==='number')&&(typeof(ga4ProductParams)!=='undefined')){
47		gtag('event','add_to_wishlist',ga4ProductParams);
48	}
49	return true;
50}
51function clickAddProductToClipboard(pid){
52	if(typeof(googleAnalytics4)==='number'){
53		gtag('event','add_to_wishlist',{items:[{item_id:{pid}}]});
54	}
55	return true;
56}
57function submitFormPay(f){
58	if((typeof(googleAnalytics4)==='number')&&(typeof(ga4EventParams)!=='undefined')){
59		gtag('event','begin_checkout',ga4EventParams);
60	}
61	return true;
62}
63function _t(s){ // funkcja do tłumaczeń
64	if((typeof(i18n)!='undefined') && i18n.hasOwnProperty(s)){
65		return i18n[s];
66	}
67	return s;
68}
69
70/**
71 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
72 * Dual licensed under the MIT and GPL licenses
73 */
74jQuery.cookie = function(name, value, options) {
75	if (typeof value != 'undefined') { // name and value given, set cookie
76		options = options || {};
77		if (value === null) {
78			value = '';
79			options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
80			options.expires = -1;
81		}
82		var expires = '';
83		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
84			var date;
85			if (typeof options.expires == 'number') {
86				date = new Date();
87				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
88			}
89			else {
90				date = options.expires;
91			}
92			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
93		}
94		var path = options.path ? '; path=' + (options.path) : '';
95		var domain = options.domain ? '; domain=' + (options.domain) : '';
96		var secure = options.secure ? '; secure' : '';
97		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
98	}
99	else { // only name given, get cookie
100		var cookieValue = null;
101		if (document.cookie && document.cookie != '') {
102			var cookies = document.cookie.split(';');
103			for (var i = 0; i < cookies.length; ++i) {
104				var cookie = jQuery.trim(cookies[i]);
105				if (cookie.substring(0, name.length + 1) == (name + '=')) {
106					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
107					break;
108				}
109			}
110		}
111		return cookieValue;
112	}
113};
114
115if (jQuery.cookie('selly_cookies')===null){
116		$(document).ready(function(){ 
117			$("#selly-cookies").show(); 
118			$("#selly-cookies .cont").children("a.close").click(function(){
119				jQuery.cookie('selly_cookies',1,{ expires: 365 });
120			$("#selly-cookies").hide();
121			return false;
122			});
123	});
124	}
125
126
127$(document).ready(function(){
128if((document.getElementById("popup-page")!== null) && (document.getElementById("popup-page").innerHTML.trim().length !== 0)){
129	if ((jQuery.cookie('selly_pagepopup')===null) && ($.fn.fancybox)) {
130		setTimeout(function () {$.fancybox.open({src:'#popup-page'});}, 3000);
131		jQuery.cookie('selly_pagepopup',1);
132	}
133}
134if(document.getElementById("popup-newsletter")!== null){
135   if ((jQuery.cookie('selly_newsletter')===null) && ($.fn.fancybox)) {
136		setTimeout(function () {$.fancybox.open({src:'#popup-newsletter'});}, 3000);
137		jQuery.cookie('selly_newsletter',1);
138	}
139}
140});
141 // exitintent
142(function($){'use strict';var timer;function trackLeave(ev){if(ev.clientY>0){return;}
143if(timer){clearTimeout(timer);}
144if($.exitIntent.settings.sensitivity<=0){$.event.trigger('exitintent');return;}
145timer=setTimeout(function(){timer=null;if(ev.target.length===undefined){$.event.trigger('exitintent');}},$.exitIntent.settings.sensitivity);}
146function trackEnter(){if(timer){clearTimeout(timer);timer=null;}}
147$.exitIntent=function(enable,options){$.exitIntent.settings=$.extend($.exitIntent.settings,options);if(enable=='enable'){$(window).mouseleave(trackLeave);$(window).mouseenter(trackEnter);}else if(enable=='disable'){trackEnter();$(window).unbind('mouseleave',trackLeave);$(window).unbind('mouseenter',trackEnter);}else{throw"Invalid parameter to jQuery.exitIntent -- should be 'enable'/'disable'";}}
148$.exitIntent.settings={'sensitivity':500};})(jQuery);
149$(document).ready(function(){
150if((document.getElementById("popup-exit")!== null) && (document.getElementById("popup-exit").innerHTML.trim().length !== 0)){
151	if ((jQuery.cookie('selly_popupexit')===null) && ($.fn.fancybox)) {
152		$(function() {
153			$.exitIntent('enable');
154			$(document).on('exitintent', function() {	$.fancybox.open({src:'#popup-exit'});
155			jQuery.cookie('selly_popupexit',1);
156			$.exitIntent('disable');
157			});
158		});
159	}
160}
161});
162
163function noweokno(plik,wdth,hght,scrollbrs){
164var wx = Math.ceil((window.screen.width-wdth) / 2 );
165var wy = Math.ceil((window.screen.height-hght) / 2 );
166var nwo;
167if(scrollbrs==1){nwo=window.open(plik,'','width='+wdth+',height='+hght+',resizable=0,scrollbars=yes,menubar=no');}
168else{nwo=window.open(plik,'','width='+wdth+',height='+hght+',resizable=0,scrollbars=no,menubar=no');}
169}
170
171function infoOpisCechy(id){
172	$.fancybox.open({src: './?a=sklep.informacjaOpisCechy&id='+id, type: 'iframe',
173	toolbar  : false,
174	smallBtn : true,
175    iframe : {
176        css : {
177            width : '300px'
178        }
179    }	
180	});
181	return false
182}
183function infoOpisWartosc(wid){
184	$.fancybox.open({src: './?a=sklep.informacjaOpisCechy&wid='+wid, type: 'iframe',
185	toolbar  : false,
186	smallBtn : true,
187    iframe : {
188        css : {
189            width : '300px'
190        }
191    }	
192	});
193	return false	
194}
195
196function addStyleSheet(filename){
197 var head = document.getElementsByTagName('head')[0];
198 var style = document.createElement('link');
199 style.href = filename;
200 style.type = 'text/css';
201 style.rel = 'stylesheet';
202 head.append(style);
203}
204
205$(document).ready(function(){
206	$("#startbox").children(".product-list:first").show();
207	$("#startbox-header ul li").children("a").click(function(){
208			var sbox = $(this).parent("li").attr("id");
209			$("#startbox-header .startbox-header-item").children("a."+sbox).show();
210			$("#startbox-header .startbox-header-item").children("a").not("a."+sbox).hide();
211			$("#startbox").children("div."+sbox).show();
212			$("#startbox").children("div.product-list").not("div."+sbox).hide();
213			$(this).parent("li").addClass("active");
214			$("#startbox-header ul li").children("a").not(this).parent("li").removeClass("active");
215			return false;
216	});
217
218	if($('#startbox div.product-list').is('.sbox1') == false){ $("#startbox-header ul").children("li#sbox1").hide(); }	
219	if($('#startbox div.product-list').is('.sbox2') == false){ $("#startbox-header ul").children("li#sbox2").hide(); }
220	if($('#startbox div.product-list').is('.sbox3') == false){ $("#startbox-header ul").children("li#sbox3").hide(); }	
221	
222	$("#startbox-header ul").children("li:visible").eq(0).addClass("active");
223	
224	$("#startbox-header ul").children("li.active").show(function(){
225		var sbox2 = $(this).attr("id");
226		$("#startbox-header .startbox-header-item").children("a."+sbox2).show();
227	});
228
229	$('#viewing-options select').each(function() {
230		if($(this).prop('selectedIndex') == '0') { $(this).removeClass("active") } else { $(this).addClass("active"); $(".filters-remove").show(); }    
231	});
232	$("#viewing-options .filters-options-radio").each(function() {
233   if ($(this).children("label").children("input[type='radio']").is("input:checked") == true) {
234		 $(this).prev(".show-options").addClass("active"); 
235		 $(".filters-remove").show();
236   	}
237	});	
238	$("#viewing-options .filters-options-checkbox").each(function() {
239    if ($(this).children("div").children("label").children("input[type='checkbox']").is(':checked') == true) {
240		 $(this).prev(".show-options").addClass("active");
241		 $(".filters-remove").show();  
242   	}
243	});
244	
245	$('html').click(function() { $(".filters-options").removeClass("filters-options-show"); });
246	$('.filters-item').click(function(event){ event.stopPropagation(); });
247	$(".filters-item").children(".show-options").click(function(){
248		$(this).next(".filters-options").toggleClass("filters-options-show");
249		$(".filters-item").children(".show-options").not(this).next(".filters-options").removeClass("filters-options-show");
250	});
251
252	$(".shopping-box .item-box").children("a.ask2").click(function(){
253			$(".product-tabs").children(".tab7").show();
254			$(".product-tabs").children(".tab-content").not(".tab7").hide();
255			$(".product-tabs ul.tabs").children("li#tab7").addClass("active");
256			$(".product-tabs ul.tabs").children("li").not("#tab7").removeClass("active");
257	});	
258	
259	$(".product-tabs").children(".tab-content:first").show();
260	$(".product-tabs ul.tabs").children("li:first").addClass("active");
261	$(".product-tabs ul.tabs li").children("a").click(function(){
262			var karta = $(this).parent("li").attr("id");
263			$(".product-tabs").children("div."+karta).show();
264			$(".product-tabs").children(".tab-content").not("."+karta).hide();
265			$(this).parent("li").addClass("active");
266			$(".product-tabs ul.tabs li").children("a").not(this).parent("li").removeClass("active");
267			return false;
268	});
269	
270	$(".cart-tabs li").children("a").click(function(){
271			var ckarta = $(this).parent("li").attr("id");
272			$("#step2").children("."+ckarta).show();
273			$("#step2").children(".ctab-content").not("."+ckarta).hide();
274				if($(this).parent("li").is("#ctab1b") == true){
275					$(".ctab-content .tab1").hide();
276					$(".ctab-content .tab2").show();
277				}
278				else {
279					$(".ctab-content .tab1").show();
280					$(".ctab-content .tab2").hide();
281				}			
282			$(this).parent("li").addClass("active");
283			$(".cart-tabs li").children("a").not(this).parent("li").removeClass("active");
284			return false;
285	});
286	$(".cart-show-list").children("span").click(function(){
287		$(this).toggleClass("act");
288		$(this).parent(".cart-show-list").next(".cart-box").slideToggle("fast");  
289	});
290
291	$("#lnewsletter").hide();
292	$("input#fdaneinvoice").click(function(){
293		if($(this).is("input:checked") == true){
294			$("#invoiceForm").hide();
295		}
296		else {
297			$("#invoiceForm").show();
298		}
299	});
300
301	$(".container-bottom .box-bottom").children(".title").click(function(){ $(this).next(".cont").toggle("fast").toggleClass("active"); });
302	
303	$('.info-tbl-mod table tbody').each(function(){
304		$(this).children('tr').each(function(t){
305			$(this).addClass('item-'+t%2);
306		});
307	});
308	
309	function updateAiBadge() {
310    const currentImg = $('#image-href > a:visible img');
311    const badge = document.querySelector('.product-card__ai-badge');
312
313    if (!currentImg.length || !badge) return;
314
315    switch (String(currentImg.data('ai'))) {
316        case "1":
317            badge.innerHTML = `
318                <img src="/img/layout/AI-modified.svg"
319                     alt="{#@zmodyfikowane przez AI#}"
320                     title="{#@zmodyfikowane przez AI#}">
321            `;
322            break;
323
324        case "2":
325            badge.innerHTML = `
326                <img src="/img/layout/AI-generated.svg"
327                     alt="{#@wygenerowane przez AI#}"
328                     title="{#@wygenerowane przez AI#}">
329            `;
330            break;
331
332        default:
333            badge.innerHTML = "";
334    }
335}
336
337	/* Przeładowanie i powiększanie zdjęć na karcie produktu */
338	if(_$('image-href')){
339		var root = $('#image-href'),
340			chain = $(document).find('.gallery'),
341			chainItem = chain.children('li'),
342			root_img_href = $(root).children('a').attr('href'), img_main_counter=0;
343		root.children('a').eq(0).attr('callback',0);
344		// wyznaczenie indeksu głównego obrazka
345		chainItem.each(function(cnt){
346			if($(this).children('a').attr('href')==root_img_href){
347				img_main_counter=cnt;
348				return false;
349			}
350		});
351		/* dobiera się do każdego zdjęcia z galerii */
352		chainItem.each(function(cnt){
353			var iLink = $(this).children('a'),
354				iHref = iLink.attr('href'),
355				iSrc = iLink.children().attr('rel'),
356				iAlt = iLink.children().attr('alt');
357				var iAi = iLink.children().data('ai');
358			/* wstawia średnie zdjęcia do pośredniego powiekszenia */
359			if(cnt!=img_main_counter){
360				var lcnt=(cnt<img_main_counter) ? cnt+1 : cnt;
361				root.append('<a class="product-img-link" href="'+iHref+'" callback="'+lcnt+'" style="display:none"><img data-ai="'+iAi+'" src="'+iSrc+'" alt="'+iAlt+'" /></a>\n');
362			}
363			/* wywołuje średniej wielkości zdjęcia */
364			iLink.mouseover(function(){
365				root.children('a').hide();
366				var lcnt=(cnt==img_main_counter) ? 0 : ((cnt<img_main_counter) ? cnt+1 : cnt);
367				root.children('a').eq(lcnt).show();
368				updateAiBadge();
369			});
370		});
371		/* wywołuje powiększenie na zdjęcie z galerii */
372		root.children('a').click(function(e){
373			e.preventDefault();
374			var cnt = parseInt($(this).attr('callback'),10);
375			var lcnt=(cnt==img_main_counter) ? 0 : ((cnt<img_main_counter) ? cnt+1 : cnt);
376			chainItem.eq(lcnt).children('a').trigger('click');
377		});
378		updateAiBadge();
379	}
380	if($.fn.fancybox){
381	$(".fb-frame").fancybox({
382	toolbar  : false,
383	smallBtn : true,
384    iframe : {
385        css : {
386            width : '600px'
387        }
388    }
389	});
390	}	
391			
392	if($.fn.fancybox){
393		$(".rata-window").fancybox({
394			'width'				: '60%',
395			'height'			: '100%',
396        	'autoScale'     	: false,
397        	'transitionIn'		: 'none',
398			'transitionOut'		: 'none',
399			'titleShow'			: false,
400			'type'				: 'iframe'
401		});
402		}
403
404	if($.fn.fancybox){
405		$("a.zoom").fancybox({
406			toolbar  : false,
407			smallBtn : true
408		});
409		}
410
411    /* wykrywa na iOS przeglądarkę osadzoną w innej aplikacji - UIWebView, która nie pozwala na otwarcie nowej karty */
412    if (document.querySelector("form.box-payment[target='_blank']")) {
413        const standalone = window.navigator.standalone;
414        const userAgent = window.navigator.userAgent.toLowerCase();
415        const safari = /safari/.test(userAgent);
416        const ios = /iphone|ipod|ipad/.test(userAgent);
417
418        if(ios && !standalone && !safari) {
419            document.querySelector("form.box-payment[target='_blank']").removeAttribute("target");
420        }
421    }
422	
423
424});
425
426
427function dotb(title, url){
428	$(document).ready(function(){tb_show(title, url, null);});
429}
430
431function cartWindowDisplay(s){
432	var h=_$('windowcart-head');
433	if(h&&_$('windowcart')){
434		h.innerHTML=s;
435		$.fancybox.open(_$('windowcart').innerHTML);
436	}
437	else{
438		alert(s);
439	}
440}
441var cart_ajax_sending=false;
442function cartAddAjax(action,product_id){
443	if(cart_ajax_sending){
444		return false;
445	}
446	var i,n,el,fr=document.forms['fparametry'],v=0,p='';
447	var edrone_cid='';
448	if(window.localStorage&&(typeof(window._edrone)!=='undefined')){
449		i=localStorage.getItem('cId');
450		if(i!==null){
451			edrone_cid='&edrone_cid='+encodeURIComponent(i);
452		}
453	}
454	if((typeof(fr)!='undefined')&&(typeof(fr.produkt_id)!='undefined')&&(fr.produkt_id.value==product_id)){
455		p+='&form=1';
456		//warianty i atrybuty składników zestawu
457		for(i=0,n=fr.elements.length;i<n;++i){
458			if(fr.elements[i].name!=undefined){
459				if((fr.elements[i].name.indexOf('swid[')>-1) || (fr.elements[i].name.indexOf('sattr')>-1)){
460					p+='&'+fr.elements[i].name+'='+fr.elements[i].options[fr.elements[i].selectedIndex].value;
461				}
462				// ilość składników
463				if(fr.elements[i].name.indexOf('squantity[')>-1){
464					p+='&'+fr.elements[i].name+'='+fr.elements[i].value;
465				}
466			}
467		}
468		if(typeof(fr.wariant_id)!='undefined'){
469			el=fr.wariant_id;
470			if((typeof(el.type)=='string')&&(el.type=='select-one')){ //select
471				v=el.options[el.selectedIndex].value;
472			}
473			else if(el.type=='hidden'){
474				v=el.value;
475			}
476			else{ // radio
477				v=$("#fparametry input[name='wariant_id']:checked").val();
478			}
479			if(v=='-1'){
480				alert(_t('Wybrana kombinacja atrybutów produktu jest niedostępna.\nProszę wybrać inną kombinację'));
481				return false;
482			}
483			p+='&wariant_id='+v;
484		}
485		if(typeof(fr.ilosc)!='undefined'){
486			v=floatval(fr.ilosc.value.replace(',', '.'));
487			if(v<=0){
488				alert(_t('Proszę wpisać prawidłową liczbę'));
489				fr.ilosc.focus();
490				return false;
491			}
492			p+='&ilosc='+v;
493		}
494		if(typeof(fr.komentarz)!='undefined'){
495            v=fr.komentarz.value.replace(/[\r\n]/g, ' ');
496            if(typeof(encodeURIComponent)=='function'){
497                v=encodeURIComponent(v);
498            }
499            p+='&komentarz='+v;
500        }
501        // kształt i wymiary produktu
502		if(typeof(shapes)!=='undefined'){
503			var shape_id=parseInt(get_radio_value(fr.shape_id),10);
504			if(shape_id>0){
505				p+='&shape_id='+shape_id;
506				v=$(fr.elements['shape_'+shape_id+'_p1']).val();
507				if(typeof(v)!=='undefined'){
508					p+='&shape_'+shape_id+'_p1='+v;
509				}
510				if(typeof(fr.elements['shape_'+shape_id+'_p2'])!=='undefined'){
511					v=$(fr.elements['shape_'+shape_id+'_p2']).val();
512					if(typeof(v)!=='undefined'){
513						p+='&shape_'+shape_id+'_p2='+v;
514					}
515				}
516			}
517		}
518		if((typeof(fr.leasing_siemens)!=='undefined')&&(fr.leasing_siemens.value==='1')){ // leasing Siemens
519			p+='&leasing_siemens=1';
520		}
521		// gwarancja
522		if(_$('formWarranty')&&(typeof(_$('formWarranty').warranty)!=='undefined')){
523			v=$('#formWarranty input[name="warranty"]:checked').val();
524			if(v>0){
525				p+='&warranty='+v;
526			}
527		}
528		// atrybuty produktu
529		if(typeof(attributes_groups_ids)!='undefined'){
530			var fe=fr.elements;
531			for(i=0,n=attributes_groups_ids.length;i<n;++i){
532				if(fe['pattr'+attributes_groups_ids[i]].type=='select-one'){
533					id=fe['pattr'+attributes_groups_ids[i]].options[fe['pattr'+attributes_groups_ids[i]].selectedIndex].value;
534				}
535				else{ // radio
536					id=$("#fparametry input[name='pattr"+attributes_groups_ids[i]+"']:checked").val();
537				}
538				id=parseInt(id,10);
539				if(!isNaN(id) && (id>0)){
540					p+='&pattr'+attributes_groups_ids[i]+'='+id;
541				}
542			}
543		}
544	}
545	else{
546		if(_$('ilosc'+product_id)){
547			if(_$('ilosc'+product_id).type=='select-one'){
548				p+='&ilosc='+$('#ilosc'+product_id).val();
549			}
550			else{
551				v=floatval(_$('ilosc'+product_id).value.replace(',', '.'));
552				if(v<=0){
553					alert(_t('Proszę wpisać prawidłową liczbę'));
554					_$('ilosc'+product_id).focus();
555					return false;
556				}
557				p+='&ilosc='+v;
558			}
559		}
560	}
561	$.ajax({
562		type: 'GET',
563		url: './',
564		data: 'a=cart.'+action+'Ajax&produkt='+product_id+p+edrone_cid,
565		dataType: 'xml',
566		cache: false,
567		beforeSend: function(request){cart_ajax_sending=true;},
568		error: function(request,textStatus,errorThrown){cart_ajax_sending=false;cartWindowDisplay(_t('Błąd przy odczycie danych z serwera'));},
569		success: function(response){
570			cart_ajax_sending=false;
571			var e,odp=response.getElementsByTagName('odp'),ct=$('#cart_top');
572			if(odp){
573				e=response.getElementsByTagName('blad');
574				switch (e[0].childNodes[0].nodeValue){
575					case '1':
576						cartWindowDisplay(_t('Błąd'));
577						break;
578					case '2': // przekierowanie na stronę produktu
579						e=response.getElementsByTagName('komunikat');
580						window.location.href=e[0].childNodes[0].nodeValue;
581						break;
582					case '8': // brak produktów w magazynie
583						cartWindowDisplay(_t('Brak produktów w magazynie'));
584						break;
585					default:
586						if(ct){
587							ct.addClass('active');
588							e=response.getElementsByTagName('koszyk');
589							ct.html(e[0].childNodes[0].nodeValue);
590						}
591						if(typeof(fbq)==='function'){//facebook pixel
592							e=response.getElementsByTagName('js_facebook');
593							if((e.length>0)&&(typeof(e[0].childNodes[0])!=='undefined')&&(typeof(e[0].childNodes[0].nodeValue)!=='undefined')){
594								try{
595									let facebook_params=JSON.parse(e[0].childNodes[0].nodeValue);
596									fbq('track', 'AddToCart', facebook_params);
597								}
598								catch(err){
599									fbq('track', 'AddToCart', {content_ids:[product_id], content_type: 'product'});
600								}
601							}
602							else{
603								fbq('track', 'AddToCart', {content_ids:[product_id], content_type: 'product'});
604							}
605						}
606						if(typeof(googleEnhancedEcommerce)!=='undefined'){
607							var productQty=1;
608							if((typeof(fr)!='undefined')&&(typeof(fr.ilosc)!='undefined')){
609								productQty=floatval(fr.ilosc.value.replace(',', '.'));
610							}
611							dataLayer.push({'event': 'addToCart', 'ecommerce': {'add': {'products': [{'id': "'"+product_id+"'",'quantity': productQty}]}}});
612						}
613						if(typeof(googleAnalytics4)==='number'){
614							e=response.getElementsByTagName('gtagParams');
615							if((e.length>0)&&(typeof(e[0].childNodes[0].nodeValue)!=='undefined')){
616								try{
617									var gtagEventParams=JSON.parse(e[0].childNodes[0].nodeValue);
618									gtag('event','add_to_cart',gtagEventParams);
619								}catch(err){}
620							}
621						}
622						if((typeof(response.getElementsByTagName('komunikat'))!='undefined')&&(response.getElementsByTagName('komunikat').length>0)){
623							e=response.getElementsByTagName('komunikat');
624							cartWindowDisplay(e[0].childNodes[0].nodeValue);
625						}
626						else{
627							cartWindowDisplay(_t('Dodano produkt do koszyka'));
628						}
629				}
630			}
631		}
632	});
633	return false;
634}
635function addProductToCompare(id){
636	var i,n,c=[],tc=jQuery.cookie('to_compare');
637	if(tc!=null){c=tc.split('.');}else{tc='';}
638	if(c.length>=3){for(i=c.length;i>=3;--i){n=c.shift();}tc=c.join('.');}
639	for(i=0,n=c.length;i<n;++i){if(c[i]==id){id='';break;}}
640	if((c.length>=3)&&(id!='')){alert(_t('Można wybrać maksymalnie 3 produkty do porównania'));}
641	else{if(tc!=''){tc+='.';}tc+=id;jQuery.cookie('to_compare',tc);window.location.href='./?a=sklep.porownaj&prid='+tc;}
642	return false;
643}
644// strona glowna
645function changeProducer(e){
646	if(e.selectedIndex > 0){
647		var v=e.options[e.selectedIndex].value.split(' ');
648		window.location.href='sklep,'+v[0]+','+v[1]+'.html';
649	}
650}
651function testSearch(f){
652	if(jQuery.trim(f.q.value).length<2){alert(_t('Proszę wpisać co najmniej 2 znaki'));f.q.focus();return false;}
653	return true;
654}
655// strona produktu
656function money_format(n,sep) {
657	var p,l,r=Math.round(n * 100)+'';
658	while(r.length < 3){r='0'+r;}
659	l=r.length;
660	r=r.substring(0,l-2) + "." + r.substring(l-2,l);
661	if(sep!=undefined){
662		r=r.split('.');
663		return (r[0].split('').reverse().join('').replace(/\d{3}/g,'$&'+sep).split('').reverse().join('') + '.' + r[1]);
664	}
665	else{
666		return r;
667	} 
668}
669function get_radio_value(e){
670	var i,n=e.length,v=null;
671	if(n==undefined){
672		if(e.checked){v=e.value}
673	}
674	else{
675		for(i=0;i<n;++i){if(e[i].checked){v=e[i].value;break;}}
676	}
677	return v;
678}
679// wyznaczenie ceny przy zmianie atrybutów
680function calculate_product_price(){
681	var i,j,n,p,pl,pw,vat,id,f=_$('fparametry'),fe=f.elements;
682	if(js_product_price>0){
683		p=js_product_price;
684		pw=js_wholesale_price;
685		vat=js_product_vat
686		if(typeof(variants)!='undefined'){ // zmiana ceny i stawki VAT jeżeli wybrano wariant
687			id=parseInt(f.wariant_id.value,10);
688			if(id>0){
689				for(i=0,n=variants.length;i<n;++i){
690					if(variants[i].id==id){
691						p=parseFloat(variants[i].price);
692						pw=parseFloat(variants[i].user_price);
693						vat=parseFloat(variants[i].vat);
694						break;
695					}
696				}
697			}
698		}
699		if((typeof(attributes_groups_ids)!='undefined') && (typeof(pattr)!='undefined')){
700			pl=pattr.length;
701			for(i=0,n=attributes_groups_ids.length;i<n;++i){
702				if(fe['pattr'+attributes_groups_ids[i]].type=='select-one'){
703					id=fe['pattr'+attributes_groups_ids[i]].options[fe['pattr'+attributes_groups_ids[i]].selectedIndex].value;
704				}
705				else{ // radio
706					id=$("#fparametry input[name='pattr"+attributes_groups_ids[i]+"']:checked").val();
707				}
708				id=parseInt(id,10);
709				if(!isNaN(id) && (id>0)){ // zmiana ceny jeżeli wybrano atrybut
710					for(j=0;j<pl;++j){
711						if(pattr[j].id==id){
712							p+=pattr[j].surcharge;
713							pw+=pattr[j].surcharge;
714							break;
715						}
716					}
717				}
718			}
719		}
720		if(p<0){p=0}
721		if(pw<0){pw=0}
722		$('#product_price').html(money_format(p) + js_currency);
723		if(_$('net_price')){
724			$('#net_price').html(money_format(p / (1 + vat/100)) + js_currency);
725		}
726		if(_$('wholesale_price') && (js_wholesale_price>0)){
727			$('#wholesale_price').html(money_format(pw) + js_currency);
728		}
729		if(_$('wholesale_net_price') && (js_wholesale_price>0)){
730			if((typeof(clientVATUE)!=='undefined')&&(clientVATUE===1)){
731				$('#wholesale_net_price').html(money_format(pw) + js_currency);
732			}
733			else {
734				$('#wholesale_net_price').html(money_format(pw / (1 + vat/100)) + js_currency);
735			}
736		}
737	}
738}
739//wyznaczenie ceny zestawu jeżeli cena zależna od składników
740function calculate_set_price(){
741	var c,i,j,n,r,id,idx,sl,fe=_$('fparametry').elements,p,pwo; // pwo - price without options
742	var cprice,cquantity;
743	if((typeof(set_fixed_price)==='undefined')||(set_fixed_price==1)){
744		return;
745	}
746	if(typeof(components)==='undefined'){
747		return;
748	}
749	p=0;
750	for(i=0,n=components.length;i<n;++i){
751		if(typeof(components[i])!=='undefined'){
752			if(typeof(fe['squantity['+i+']'])!=='undefined'){
753				cquantity=floatval(fe['squantity['+i+']'].value.replace(',', '.'));
754				if(cquantity<=0){
755					cquantity=components[i].quantity;
756					fe['squantity['+i+']'].value=cquantity;
757				}
758			}
759			else{
760				cquantity=components[i].quantity;
761			}
762			// wyznaczenie ceny
763			if(typeof(components_variants_prices[i])!=='undefined'){
764				idx=fe['swid['+i+']'].selectedIndex;
765				cprice=components_variants_prices[i][idx];
766			}
767			else{
768				cprice=components[i].price;
769			}
770			p+=cprice*cquantity;
771		}
772	}
773	pwo=p;
774	js_product_price=p;
775	// atrybuty składników
776	if((typeof(components_groups_ids)!='undefined') && (typeof(sattr)!='undefined') && (components_groups_ids.length > 0)){
777		sl=sattr.length;
778		for(i=0,n=components_groups_ids.length;i<n;++i){
779			if(fe['sattr'+components_groups_ids[i]].type=='select-one'){
780				id=fe['sattr'+components_groups_ids[i]].options[fe['sattr'+components_groups_ids[i]].selectedIndex].value;
781			}
782			else{
783				id=-1;
784			}
785			id=parseInt(id,10);
786			if(!isNaN(id) && (id>0)){ // zmiana ceny jeżeli wybrano atrybut
787				for(j=0;j<sl;++j){
788					if((sattr[j].component_id==components_groups_ids[i]) && (sattr[j].attr_id==id)){
789						p+=sattr[j].surcharge*sattr[j].quantity;
790						break;
791					}
792				}
793			}
794		}
795	}
796	if(p<0){p=0}
797	r=set_price_discount_value;
798	if ((set_price_discount_value>0) && (set_price_discount_type=='procent')) {
799		r=p*(set_price_discount_value/100);
800	}
801	c=p-r;
802	if (c<0){c=0;}
803	$('#product_price').html(money_format(c)+js_currency);
804	if(_$('zestaw_cena_roznica')){
805		$('#zestaw_cena_roznica').html((r>0) ? money_format(r)+js_currency : '-');
806	}
807}
808function change_variant(e){
809	var i,n,wid,w=false;
810	if(e.type=='radio'){
811		wid=get_radio_value(e.form.wariant_id); // $("#fparametry input[name='wariant_id']:checked").val();
812	}
813	else{ // 'select-one'
814		wid=e.options[e.selectedIndex].value
815	}
816	for(i=0,n=variants.length;i<n;++i){
817		if(variants[i].id==wid){
818			w=true;
819			if(js_product_price>0){
820				$('#product_price').html(money_format(variants[i].price) + js_currency);
821				if(_$('net_price')){
822					$('#net_price').html(money_format(variants[i].price / (1 + variants[i].vat/100)) + js_currency);
823				}
824			}
825			if(_$('wholesale_price') && (js_wholesale_price>0)){
826				$('#wholesale_price').html(money_format(variants[i].user_price) + js_currency);
827			}
828			if(_$('wholesale_net_price') && (js_wholesale_price>0)){
829				if((typeof(clientVATUE)!=='undefined')&&(clientVATUE===1)){
830					$('#wholesale_net_price').html(money_format(variants[i].user_price) + js_currency);
831				}
832				else {
833					$('#wholesale_net_price').html(money_format(variants[i].user_price / (1 + variants[i].vat/100)) + js_currency);
834				}
835			}
836			$('.gallery img').removeClass('imgSelected');
837			if(variants[i].photo_no>0){
838				$('#pphoto'+variants[i].photo_no).addClass('imgSelected').mouseover();
839			}
840
841            const changeVariantEvent = new CustomEvent('variantChanged', { detail: variants[i] });
842            document.dispatchEvent(changeVariantEvent);
843
844            break;
845        }
846    }
847    if (!w) {
848		$('.gallery img').removeClass('imgSelected');
849		if(js_product_price>0){
850			$('#product_price').html(money_format(js_product_price) + js_currency);
851			if(_$('net_price')){
852				$('#net_price').html(money_format(js_product_price / (1 + js_product_vat/100)) + js_currency);
853			}
854		}
855		if(_$('wholesale_price') && (js_wholesale_price>0)){
856			$('#wholesale_price').html(money_format(js_wholesale_price) + js_currency);
857		}
858		if(_$('wholesale_net_price') && (js_wholesale_price>0)){
859			if((typeof(clientVATUE)!=='undefined')&&(clientVATUE===1)){
860				$('#wholesale_net_price').html(money_format(js_wholesale_price) + js_currency);
861			}
862			else{
863				$('#wholesale_net_price').html(money_format(js_wholesale_price / (1 + js_product_vat/100)) + js_currency);
864			}
865		}
866
867        const changeVariantEvent = new CustomEvent('variantChanged', { detail: null });
868        document.dispatchEvent(changeVariantEvent);
869    }
870    calculate_product_price();
871}
872function change_variant_group(e, id) {
873	var i,j,k,l,n,m,fe=e.form.elements,ids=[],idx=-1,gid;
874	// wyznaczenie identyfikatorów atrybutów dla grup
875	for(i=0,n=variants_groups_ids.length; i<n; ++i){
876		if(fe['wariant_grupa'+variants_groups_ids[i]].type=='select-one'){ // select
877			ids[i]=fe['wariant_grupa'+variants_groups_ids[i]].options[fe['wariant_grupa'+variants_groups_ids[i]].selectedIndex].value;
878		}
879		else{ // radio
880			ids[i]=get_radio_value(fe['wariant_grupa'+variants_groups_ids[i]]);
881			if(ids[i]==null){
882				ids[i]=0;
883			}
884		}
885	}
886	loop1: for(i=0,n=variants.length;i<n;++i){
887		loop2: for(j=0,m=ids.length;j<m;++j){
888			gid=-1;
889			// znalezienie grupy
890			for(k=0,l=variants[i].group_attributes.length;k<l;++k){
891				if(variants[i].group_attributes[k][0]==variants_groups_ids[j]){
892					gid=k;
893					break;
894				}
895			}
896			if(gid==-1){ // nie ma grupy
897				if(ids[j]!=0){
898					continue loop1;
899				}
900				else{
901					if(j==m-1){
902						idx=i;
903						break loop1;
904					}
905				}
906			}
907			else{ // jest grupa, sprawdzenie czy jest odpowiednia wartość atrybutu
908				if(ids[j]==0){
909					continue loop1;
910				}
911				else {
912					for(k=1,l=variants[i].group_attributes[gid].length;k<l;++k){
913						if(variants[i].group_attributes[gid][k]==ids[j]){
914							if(j==m-1){
915								idx=i;
916								break loop1;
917							}
918							continue loop2;
919						}
920					}
921					continue loop1;
922				}
923			}
924		}
925	}
926	if(idx==-1){ // nie znaleziono wariantu
927		fe['wariant_id'].value=-1;
928		$('#no_variant').show();
929		$('.gallery img').removeClass('imgSelected');
930		if(js_product_price>0){
931			$('#product_price').html(money_format(js_product_price) + js_currency);
932			if(_$('net_price')){
933				$('#net_price').html(money_format(js_product_price / (1 + js_product_vat/100)) + js_currency);
934			}
935		}
936		if(_$('wholesale_price') && (js_wholesale_price>0)){
937			$('#wholesale_price').html(money_format(js_wholesale_price) + js_currency);
938		}
939		if(_$('wholesale_net_price') && (js_wholesale_price>0)){
940			if((typeof(clientVATUE)!=='undefined')&&(clientVATUE===1)){
941				$('#wholesale_net_price').html(money_format(js_wholesale_price) + js_currency);
942			}
943			else{
944				$('#wholesale_net_price').html(money_format(js_wholesale_price / (1 + js_product_vat/100)) + js_currency);
945			}
946        }
947
948        const changeVariantGroupEvent = new CustomEvent('variantChanged', { detail: null });
949        document.dispatchEvent(changeVariantGroupEvent);
950    } else { // jest wariant
951		fe['wariant_id'].value=variants[idx].id;
952		$('#no_variant').hide();
953		if(js_product_price>0){
954			$('#product_price').html(money_format(variants[idx].price) + js_currency);
955			if(_$('net_price')){
956				$('#net_price').html(money_format(variants[idx].price / (1 + variants[idx].vat/100)) + js_currency);
957			}
958		}
959		if(_$('wholesale_price') && (js_wholesale_price>0)){
960			$('#wholesale_price').html(money_format(variants[idx].user_price) + js_currency);
961		}
962		if(_$('wholesale_net_price') && (js_wholesale_price>0)){
963			if((typeof(clientVATUE)!=='undefined')&&(clientVATUE===1)){
964				$('#wholesale_net_price').html(money_format(variants[idx].user_price) + js_currency);
965			}
966			else {
967				$('#wholesale_net_price').html(money_format(variants[idx].user_price / (1 + variants[idx].vat/100)) + js_currency);
968			}
969		}
970		$('.gallery img').removeClass('imgSelected');
971		if(variants[idx].photo_no>0){
972			$('#pphoto'+variants[idx].photo_no).addClass('imgSelected').mouseover();
973		}
974	const changeVariantGroupEvent = new CustomEvent('variantChanged', { detail: variants[idx] });
975        document.dispatchEvent(changeVariantGroupEvent);
976}
977	calculate_product_price();
978}
979
980function check_mail(mail){var re=/^[^\s@]+@[\w\.-]+\.[a-z]{2,}$/; return re.test(jQuery.trim(mail));}
981function click_unsubscribe(){
982	var f=_$('newsletter-form');
983	if(f){
984		if(!check_mail(f.email.value)){
985			alert(_t('Proszę wpisać prawidłowy adres e-mail'));f.email.focus();return;
986		}
987		f.force_action.value='unsubscribe';f.action='./?a=portal.newsletter';f.submit();
988	}
989	return;
990}
991function test_fnewsletter(f){
992	if(!check_mail(f.email.value)){
993		alert(_t('Proszę wpisać prawidłowy adres e-mail'));f.email.focus();return false;
994	}
995	if((typeof(f.zapis)!=='undefined')&&!f.zapis.checked){alert(_t('Proszę wyrazić zgodę na zapis danych'));return false;}
996	if((typeof(f.zgoda)!=='undefined')&&!f.zgoda.checked){alert(_t('Proszę wyrazić zgodę na przetwarzanie danych'));return false;}
997	f.force_action.value='subscribe';f.action='./?a=portal.newsletter';return true;
998}
999
1000/* kształty i wymiary produktu */
1001function clickShape(e){
1002	var v=e.value;
1003	$('#fparametry .productShapeParams').hide();
1004	$('#productShapeParams'+v).show();
1005	calcuatePriceShape();
1006}
1007function inputShapeValue(e){
1008	$('#'+e.name+'value').text(e.value);
1009}
1010function checkShapeParameter(e,pmin,pmax,pstep){ // pomocnicza przy obliczaniu wymiarów dla kształtów
1011	var v,factor,min,max,step,num,changed=false;
1012	v=jQuery.trim(e.value.replace(',','.'));
1013	if(!jQuery.isNumeric(v)){
1014		v=pmin;
1015		changed=true;
1016	}
1017	else{
1018		v=parseFloat(v);
1019		if(v<pmin){
1020			v=pmin;
1021			changed=true;
1022		}
1023		else if(v>pmax){
1024			v=pmax;
1025			changed=true;
1026		}
1027		else{ // mieści się w przedziale, sprawdzenie czy prawidłowa wartość
1028			factor=Math.pow(10,shapes.precision);
1029			min=Math.floor(pmin*factor);
1030			max=Math.floor(pmax*factor);
1031			step=Math.floor(pstep*factor);
1032			v=Math.floor(v*factor);
1033			num=Math.ceil((v-min)/step);
1034			if(min+step*num!=v){
1035				v=(min+step*num)/factor;
1036				if(v>pmax){
1037					v=pmax;
1038				}
1039				changed=true;
1040			}
1041		}
1042	}
1043	if(changed){
1044		e.value=v.toFixed(shapes.precision);
1045	}
1046}
1047function changeInputRectangle(e){
1048	var i,n,p,v,f=_$('fparametry'),fe=f.elements,shape_element=null;
1049	for(i=0,n=shapes.elements.length;i<n;++i){
1050		if(shapes.elements[i].id===2){ // prostokąt
1051			shape_element=shapes.elements[i];
1052			break;
1053		}
1054	}
1055	if(shape_element===null){
1056		return;
1057	}
1058	if(e.name==='shape_2_p1'){ // zmieniono szerokość
1059		checkShapeParameter(e,shape_element.p1_min,shape_element.p1_max,shape_element.p1_step);
1060		v=parseFloat(e.value);
1061		v=v*shape_element.p2_min/shape_element.p1_min;
1062		fe['shape_2_p2'].value=v.toFixed(shapes.precision);
1063	}
1064	else if(e.name==='shape_2_p2'){ // zmieniono długość
1065		checkShapeParameter(e,shape_element.p2_min,shape_element.p2_max,shape_element.p2_step);
1066		v=parseFloat(e.value);
1067		v=v*shape_element.p1_min/shape_element.p2_min;
1068		fe['shape_2_p1'].value=v.toFixed(shapes.precision);
1069	}
1070	calcuatePriceShape();
1071}
1072function calcuatePriceShape(){
1073	var i,n,v,p1,p2=1,f=_$('fparametry'),fe=f.elements,shape_element=null;
1074	var shape_id=parseInt(get_radio_value(f.shape_id),10);
1075	for(i=0,n=shapes.elements.length;i<n;++i){
1076		if(shapes.elements[i].id===shape_id){
1077			shape_element=shapes.elements[i];
1078			if(shape_element.display==='select'){
1079				p1=parseFloat(fe['shape_'+shape_id+'_p1'].options[fe['shape_'+shape_id+'_p1'].selectedIndex].value);
1080				if(typeof(fe['shape_'+shape_id+'_p2'])!=='undefined'){
1081					p2=parseFloat(fe['shape_'+shape_id+'_p2'].options[fe['shape_'+shape_id+'_p2'].selectedIndex].value);
1082				}
1083				break;
1084			}
1085			checkShapeParameter(fe['shape_'+shape_id+'_p1'],shape_element.p1_min,shape_element.p1_max,shape_element.p1_step);
1086			p1=parseFloat(fe['shape_'+shape_id+'_p1'].value);
1087			if(typeof(fe['shape_'+shape_id+'_p2'])!=='undefined'){
1088				checkShapeParameter(fe['shape_'+shape_id+'_p2'],shape_element.p2_min,shape_element.p2_max,shape_element.p2_step);
1089				p2=parseFloat(fe['shape_'+shape_id+'_p2'].value);
1090			}
1091			break;
1092		}
1093	}
1094	if(shape_element!==null){ // obliczenie ceny
1095		if (shapes.priceUnit==='m2'){
1096			v=shape_element.area(p1,p2);
1097			if(shapes.unit==='cm'){
1098				v=v/10000;
1099			}
1100			else if(shapes.unit==='mm'){
1101				v=v/1000000;
1102			}
1103		}
1104		else{ // shapes.priceUnit==='mb'
1105			if(typeof(fe['shape_'+shape_id+'_p2'])!=='undefined'){
1106				if(shapes.priceOf==1){
1107					if((p2>=shape_element.p1_min) && (p2<=shape_element.p1_max) && (p1>=shape_element.p2_min) && (p1<=shape_element.p2_max)){
1108						v=p1;
1109					}
1110					else{
1111						v=p2;
1112					}
1113				}
1114				else{
1115					v=p2;
1116				}
1117			}
1118			else { // tylko jeden parametr
1119				v=p1;
1120			}
1121			if (shapes.unit==='cm') {
1122				v=v/100;
1123			}
1124			else if (shapes.unit==='mm') {
1125				v=v/1000;
1126			}
1127		}
1128		if(v>0){
1129			js_product_price=+(v*shapes.price).toFixed(2);
1130			if(js_wholesale_price>0){
1131				$.get('./?a=cart.wholesalePriceForShape&pid='+f.produkt_id.value+'&sid='+shape_id+'&p1='+p1+'&p2='+p2,'',function(data){
1132					if(jQuery.isNumeric(data)){
1133						js_wholesale_price=+data;
1134						calculate_product_price();
1135					}
1136					else{
1137						$('wholesale_price').text('');
1138						js_wholesale_price=0;
1139					}
1140				});
1141			}
1142		}
1143	}
1144	calculate_product_price();
1145}
1146
1147function click_pack_status(pack_code){
1148	if(cart_ajax_sending){
1149		return false;
1150	}
1151	$.ajax({
1152		type: 'GET',
1153		url: './',
1154		data: 'a=klient.paczkomatyPaczkaStatus&kod='+pack_code,
1155		dataType: 'html',
1156		cache: false,
1157		beforeSend: function(request){cart_ajax_sending=true;},
1158		error: function(request,textStatus,errorThrown){cart_ajax_sending=false;alert(_t('Błąd przy odczycie danych z serwera'));},
1159		success: function(response){
1160			cart_ajax_sending=false;
1161			if(response.length<1000){
1162				alert(response);
1163			}
1164		}
1165	});
1166	return false;
1167}
1168
1169/* porownanie.js */
1170var doPorownania = new Array(),to_compare=jQuery.cookie('to_compare');
1171if((to_compare != '') && (to_compare != null)){
1172	doPorownania = to_compare.split('.');
1173}
1174
1175function addPorownanie(el){
1176	var i,n,e,el_exists=false,v=el.value,f=el.form;
1177	if (el.checked) {
1178		for (i=0,n=doPorownania.length; i < n; ++i) {
1179			if (doPorownania[i] == v) {
1180				el_exists=true;
1181				break;
1182			}
1183		}
1184		if (!el_exists) {
1185			if (doPorownania.length >= 3) {
1186				for(i=doPorownania.length; i>=3; --i){
1187					e=doPorownania.shift();
1188					if((typeof(_$('porownaj'+e))=='object') && (_$('porownaj'+e)!=null) && (_$('porownaj'+e).type=='checkbox')){
1189						_$('porownaj'+e).checked=false;
1190					}
1191				}
1192			}
1193			doPorownania.push(v);
1194		}
1195	}
1196	else {
1197		var copy = new Array();
1198		for (i=0,n=doPorownania.length; i<n; ++i) {
1199			if (doPorownania[i] != v) {
1200				copy.push(doPorownania[i]);
1201			}
1202		}
1203		doPorownania = copy;
1204	}
1205	jQuery.cookie('to_compare', doPorownania.join('.'));
1206}
1207
1208function porownaj(){
1209	var n=doPorownania.length;
1210	if(n<2){alert(_t('Proszę wybrać co najmniej dwa produkty do porównania'));return false;}
1211	if(n>3){alert(_t('Można wybrać maksymalnie 3 produkty do porównania'));return false;}
1212	window.location.href='./porownanie.html?prid='+doPorownania.join('.');
1213	return false;
1214}
1215
1216function isValidNip(nip) {
1217    if(typeof nip !== 'string')
1218        return false;
1219
1220    nip = nip.replace(/[\ \-]/gi, '');
1221
1222    let weight = [6, 5, 7, 2, 3, 4, 5, 6, 7];
1223    let sum = 0;
1224    let controlNumber = parseInt(nip.substring(9, 10));
1225    let weightCount = weight.length;
1226    for (let i = 0; i < weightCount; i++) {
1227        sum += (parseInt(nip.substr(i, 1)) * weight[i]);
1228    }
1229    
1230    return sum % 11 === controlNumber;
1231}
1232
1233jQuery(document).ready(function($){
1234	var $buttons = $('.js_fetchNip');
1235	var fetching = false;
1236	$buttons.on('click', function(event){
1237		event.preventDefault();
1238		var $parent = $buttons.parents('#invoiceForm');
1239		
1240		if(fetching){
1241			return false;
1242		}
1243		$buttons.attr('disabled', 'disabled');
1244		var nip = $('#fnip').val();
1245		nip = nip.replace(/[\ \-]/gi, '');
1246		$('#fnip').val(nip);
1247		if (!isValidNip(nip)) {
1248			alert(_t('Podaj poprawny nip.'));
1249			$buttons.attr('disabled', null);
1250			return false;
1251		}
1252		fetching = true;
1253		$.ajax({
1254			type: 'GET',
1255			url: './',
1256			data: 'a=options.fetchCompanyDataByNipJSON&nip='+nip,
1257			dataType: 'json',
1258			cache: false,
1259			error: function(){
1260				fetching=false;alert(_t('Błąd przy odczycie danych z serwera'));
1261				$buttons.attr('disabled', null);
1262			},
1263			success: function(response){
1264				if (!response.success) {
1265					alert(_t('Błąd przy odczycie danych z serwera'));
1266					fetching = false;
1267					$buttons.attr('disabled', null);
1268					return false;
1269				}
1270				$parent.find('#ffirma').val(response.data.name);
1271				$parent.find('#fkod').val(response.data.zipCode);
1272				$parent.find('#fmiejscowosc').val(response.data.city);
1273				$parent.find('#fadres').val(response.data.street);
1274				$buttons.attr('disabled', null);
1275				fetching = false;
1276			}
1277		});
1278	});
1279});
1280

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.