PageSourceSearch

https://hanketissue.pl/core/common.js

js hanketissue.pl collected 2026-10-08 11:55:14 UTC 12,109 bytes, 399 lines download raw bytes

1/*
2* Common JS scripts
3*/
4
5function gEBI( objId ){
6  return document.getElementById( objId );
7}
8
9function createCookie( sName, sValue, iDays ){
10  sValue = escape( sValue );
11  if( iDays ){
12    var oDate = new Date();
13    oDate.setTime( oDate.getTime() + ( iDays*24*60*60*1000 ) );
14    var sExpires = "; expires="+oDate.toGMTString();
15  }
16  else
17    var sExpires = "";
18  document.cookie = sName+"="+sValue+sExpires+"; path=/";
19}
20
21function throwCookie( sName ){
22  var sNameEQ = sName + "=";
23  var aCookies = document.cookie.split( ';' );
24  for( var i=0; i < aCookies.length; i++ ){
25    var c = aCookies[i];
26    while( c.charAt(0) == ' ' )
27      c = c.substring( 1, c.length );
28    if( c.indexOf( sNameEQ ) == 0 )
29      return unescape( c.substring( sNameEQ.length, c.length ) );
30  }
31  return null;
32}
33
34function delCookie( sName ){
35  createCookie( sName, "", -1 );
36}
37
38function isset( sVar ){
39  return( typeof( window[sVar] ) != 'undefined' );
40}
41
42_bUa=navigator.userAgent.toLowerCase();
43_bOp=(_bUa.indexOf("opera")!=-1?true:false);
44_bIe=(_bUa.indexOf("msie")!=-1&&!_bOp?true:false);
45_bIe4=(_bIe&&(_bUa.indexOf("msie 2.")!=-1||_bUa.indexOf("msie 3.")!=-1||_bUa.indexOf("msie 4.")!=-1)&&!_bOp?true:false)
46isIe=function(){return _bIe;}
47isOldIe=function(){return _bIe4;}
48var olArray=[];
49
50function AddOnload( f ){
51  if( isIe() && isOldIe() ){
52    window.onload = ReadOnload;
53    olArray[olArray.length] = f;
54  }
55  else if( window.onload ){
56    if( window.onload != ReadOnload ){
57      olArray[0] = window.onload;
58      window.onload = ReadOnload;
59    }
60    olArray[olArray.length] = f;
61  }
62  else
63    window.onload=f;
64}
65function ReadOnload(){
66  for( var i=0; i < olArray.length; i++ ){
67    olArray[i]();
68  }
69}
70
71function previewImage( oObj, sImage, iImage ){
72  gEBI( 'imgPreview' ).src = sFilesDir + sPreviewDir + sImage;
73  gEBI( 'imgPreview' ).alt = oObj.title;
74  gEBI( 'previewLink' ).href = sFilesDir + sImage;
75  gEBI( 'previewLink' ).title = oObj.title;
76  if( gEBI( 'defaultDescription' ) )
77    gEBI( 'defaultDescription' ).innerHTML = oObj.title;
78  $( '#previewLink' ).unbind( 'click' );
79  $( '#previewLink' ).click( {iImage: iImage}, function( e ){ e.preventDefault(); $( '#imagesListPreview a' ).eq(e.data.iImage).click(); } );
80} // end function previewImage
81
82/*
83* Orders
84*/
85
86function fix( f ){
87	f	= f.toString( );
88	var re	= /\,/gi;
89	f	= f.replace( re, "\." );
90
91	f = Math.round( f * 100 );
92	f = f.toString( );
93	var sMinus = f.slice( 0, 1 );
94	if( sMinus == '-' ){
95	 f = f.slice( 1, f.length )
96	}
97	else
98	 sMinus = '';
99	if( f.length < 3 ) {
100		while( f.length < 3 )
101			f = '0' + f;
102	}
103
104	var w = sMinus + f.slice( 0, f.length-2 ) + "." + f.slice( f.length-2, f.length );
105
106  var checkFloat = /^-?[0-9]{1,}[.]{1}[0-9]{1,}$/i;
107	if( w.search( checkFloat ) == -1 )
108		w = '0.00';
109	return w;
110}
111
112function changePriceFormat( fPrice ){
113  // config start
114  var sDecimalSeparator = '.';
115  var sThousandSeparator = '';
116  // config end
117
118  fPrice = fix( fPrice );
119  var aPrice = fPrice.split( '.' );
120  var iPriceFull = aPrice[0];
121  var aPriceFull = new Array( );
122
123  var j = 0;
124  for( var i = iPriceFull.length - 1; i >= 0; i-- ){
125    if( j > 0 && j%3 == 0 )
126      aPriceFull[j] = iPriceFull.substr( i, 1 )+''+sThousandSeparator;
127    else
128      aPriceFull[j] = iPriceFull.substr( i, 1 );
129    j++;
130  } // end for
131
132  aPriceFull.reverse( );
133  sPriceFull = aPriceFull.join( '' );
134  sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];
135  return sPrice;
136} // end function changePriceFormat
137
138var iLastPayment = null;
139function countShippingPrice( oObj ){
140
141  if( oObj.value != '' )
142    aShipping = oObj.value.split( ";" );
143  else
144    aShipping = Array( 0, 0, '0.00' );
145
146  fShippingCost = fix( aShipping[2] ) * 1;
147  if( iLastPayment && gEBI( 'oPaymentChannel'+iLastPayment ) )
148    gEBI( 'oPaymentChannel'+iLastPayment ).style.display = 'none';
149  if( gEBI( 'oPaymentChannel'+aShipping[1] ) ){
150    gEBI( 'oPaymentChannel'+aShipping[1] ).style.display = 'inline';
151    iLastPayment = aShipping[1];
152  }
153  try{
154    gEBI( 'iZagielAccept' ).alt = "";
155  } catch(e){}
156  try{
157    if( gEBI( 'oPaymentChannel'+aShipping[1] ).className == 'zagielInfo' ){
158      gEBI( 'iZagielAccept' ).alt = "box;"+sPaymentZagielCheckboxRequire;
159    }
160  } catch(e){}
161
162  gEBI( 'shippingPaymentCost' ).innerHTML = changePriceFormat( fShippingCost );
163  gEBI( 'orderSummary' ).innerHTML = changePriceFormat( +fOrderSummary + fShippingCost )
164
165} // end function 
166
167var aUserDataNames = new Array( 'sFirstName', 'sLastName', 'sCompanyName', 'sStreet', 'sZipCode', 'sCity', 'sPhone', 'sEmail', 'sVrn', 'sLoginReg' );
168
169function saveUserData( sName, sValue ){
170  createCookie( sName, sValue );
171}
172
173function checkSavedUserData( ){
174  var iCount = aUserDataNames.length;
175  var sCookie = null;
176  var oForm = gEBI( "orderForm" );
177  for( var i = 0; i < iCount; i++ ){
178    sCookie = throwCookie( aUserDataNames[i] );
179    if( sCookie && sCookie != '' ){
180      if( gEBI( aUserDataNames[i] ) )
181        gEBI( aUserDataNames[i] ).value = unescape( sCookie );
182      else if( oForm[aUserDataNames[i]] )
183        oForm[aUserDataNames[i]].value = unescape( sCookie );
184    }
185  } // end for
186} // end function checkSavedUserData
187
188function delSavedUserData( ){
189  var iCount = aUserDataNames.length;
190  var sCookie = null;
191  for( var i = 0; i < iCount; i++ ){
192    delCookie( aUserDataNames[i] );
193  } // end for
194} // end function delSavedUserData
195
196function saveRating( iRate ){
197  gEBI( 'oRating' ).className = 'rating stars'+iRate;
198  gEBI( 'oVote' ).value = iRate;
199  return false;
200} // end function saveRating
201
202function windowNew( sAdres, iWidth, iHeight, sTitle, iReturn ){
203  if ( !sTitle )
204    sTitle = '';
205  if( !iReturn )
206    iReturn = false;
207
208	if( !iWidth )
209		var iWidth = 750;
210	if( !iHeight )
211		var iHeight = 530;
212
213	if( +iWidth > 750 )
214		iWidth = 750;
215	else
216		iWidth = +iWidth + 40;
217
218	if( +iHeight > 600 )
219		iHeight = 600
220	else
221		iHeight = +iHeight + 40;
222
223	var iX = ( screen.availWidth - iWidth ) / 2;
224	var iY = ( screen.availHeight - iHeight ) / 2;
225
226  var refOpen = window.open( sAdres, sTitle, "height="+iHeight+",width="+iWidth+",top="+iY+",left="+iX+",resizable=yes,scrollbars=yes,status=0;" );
227  
228  if( iReturn == true )
229  	return refOpen
230} // end function windowNew
231
232function hasClassName(oObj, sName){
233  var aList = oObj.className.split(" ");
234  for( var i = 0; i < aList.length; i++ )
235    if( aList[i] == sName )
236      return true;
237  return false;
238}
239
240function addClassName(oObj, sName){
241  if( oObj.className == null )
242    return;
243  if( hasClassName( oObj, sName ) )
244    return;
245  oObj.className = oObj.className+' '+sName;
246}
247
248function removeClassName( oObj, sName ){
249  if( oObj.className == null )
250    return;
251  var aNewList = new Array();
252  var aCurList = oObj.className.split(" ");
253  for( var i = 0; i < aCurList.length; i++ )
254    if( aCurList[i] != sName )
255      aNewList.push( aCurList[i] );
256  oObj.className = aNewList.join(" ");
257}
258
259/* PLUGINS */
260function simpleNotice( sNotice, sClose, sLocation, bOnce ){
261  jQuery(document).ready(function(){
262    var bCookiesNoticeClosed = throwCookie( 'bCookiesNoticeClosed' );
263    if( !bCookiesNoticeClosed && sNotice != '' ){
264      if( !sClose )
265        sClose = 'x'
266      $( 'body' ).prepend( '<div id="noticeAboutCookies" class="'+sLocation+'">'+sNotice+'<a href="#" class="close">'+sClose+'</a></div>' );
267      jQuery("#noticeAboutCookies").delay(1000).slideToggle("slow");
268      jQuery("#noticeAboutCookies .close").click(function(){
269        jQuery("#noticeAboutCookies").delay(500).slideUp("slow")
270        createCookie( 'bCookiesNoticeClosed', true );
271        return false;
272      });
273      if( bOnce )
274        createCookie( 'bCookiesNoticeClosed', true );
275    }
276  });
277} // end function simpleNotice
278AddOnload( function(){
279  if( gEBI( 'fbSideTab' ) ){
280    $(function(){
281      var sPosition = ( $('#fbSideTab').css('right') == '0px' || $('#fbSideTab').css('left') == 'auto' ) ? 'right' : 'left';
282      var aAnimate = Array( );
283      $('#fbSideTab').css(sPosition,'-'+iFbSideTabWidth+'px');
284      $('#fbSideTab').css('top',iFbSideTabTop+'px');
285      $('#fbSideTab .button, #fbSideTab .fb').hover(
286        function(){
287          $('#fbSideTab').stop();
288          aAnimate[sPosition] = '0px';
289          $('#fbSideTab').animate(aAnimate, 500 );
290        },
291        function(){
292          $('#fbSideTab').stop();
293          aAnimate[sPosition] = '-'+iFbSideTabWidth+'px';
294          $('#fbSideTab').animate(aAnimate, 300 );
295        }
296      );
297    });
298  }
299});
300function changeAttributesPrice( ){
301  var fPriceAdd = 0;
302  var aSelects = gEBI( 'attributesSelects' ).getElementsByTagName( 'select' );
303  for( var i = 0; i < aSelects.length; i++ ){
304    var aSelect = aSelects[i];
305    var aSelectValue = aSelect.options[aSelect.options.selectedIndex].value;
306    if( aSelectValue != '' )
307      var aAttribute = aSelectValue.split( "|" );
308    else
309      var aAttribute = Array( 0, 0 );
310    if( aAttribute[1] != '' ){
311      fPriceAdd += ( generatePrice( fPrice, aAttribute[1] ) - fPrice );
312    }
313
314 sIdSelect = aSelect.getAttribute("class");
315
316    var sGalleryId = $('#image_' + sIdSelect);
317    
318   if(sGalleryId.length && aAttribute[2] != '' && typeof aAttribute[2] !== "undefined") {
319        $(sGalleryId).html("<img src='files/300/" + aAttribute[2] + "' alt='' />");
320      }else if(aAttribute[2] != '' && typeof aAttribute[2] !== "undefined"){
321        $( "#box" ).before( "<div id='image_" + sIdSelect +"' class='images_atr'><img src='files/180/" + aAttribute[2] + "' alt='' /></div>" );
322      }else if(sGalleryId.length)
323        $(sGalleryId).remove();
324
325  } // end for
326  gEBI( 'priceValue' ).innerHTML = changePriceFormat( fix( fPrice * 1 + fPriceAdd ) );
327  if( isset( 'fVat' ) )
328    gEBI( 'priceValueNetto' ).innerHTML = changePriceFormat( fix( gEBI( 'priceValue' ).innerHTML / fVat ) );
329} // end function changeAttributesPrice
330
331function generatePrice( fPrice1, fPrice2 ){
332  fPrice1 = fix( fPrice1 );
333  fPrice2 = fPrice2.toString();
334  if( fPrice2.match( /\%/ ) ){
335    fPrice2 = fix( fPrice2.replace( /\%/, '' ) );
336    if( fPrice2 < 0 ){
337      return fPrice1 - ( fPrice1 * ( -fPrice2 / 100 ) );
338    }
339    else
340      return +fPrice1 + ( fPrice1 * ( fPrice2 / 100 ) );
341  }
342  else{
343    fPrice2 = fix( fPrice2 ) * 1;
344    return +fPrice1 + fPrice2;
345  }
346} // end function generatePrice
347function backToTop(){
348  $('#backToTop').hide();
349  $(window).scroll( function(){
350    if( $(this).scrollTop() > 100 )
351      $('#backToTop').fadeIn();
352    else
353      $('#backToTop').fadeOut();
354  } );
355  $('#backToTop a').click( function(){
356    $('body,html').animate( {scrollTop:0}, 600 );
357    return false;
358  } );
359}
360
361var sDefaultTab = null;
362function checkDefaultTab( ){
363  if( gEBI( 'orderRegisterForm' ) ){
364    iDefaultTab = 0;
365    changeTab( iDefaultTab );
366  }
367  else if( gEBI( 'orderLoginForm' ) ){
368    iDefaultTab = 1;
369    changeTab( iDefaultTab );
370  }
371}
372
373function changeTab( iTab ){
374  aTabs = Array( aTabNames[iTab], aTabNames[Math.abs( iTab-1 )] );
375  if( gEBI( 'order'+aTabs[0]+'Form' ) ){
376    gEBI( 'order'+aTabs[0]+'Form' ).style.display = 'block';
377    gEBI('order'+aTabs[0]+'Tab').children[0].className = 'selected';
378    }
379  if( gEBI( 'order'+aTabs[1]+'Form' ) ){
380    gEBI( 'order'+aTabs[1]+'Form' ).style.display = 'none';
381    gEBI('order'+aTabs[1]+'Tab').children[0].className = '';
382  }
383  return false;
384}
385
386function checkUserDataForm( oObj ){
387  if( gEBI( 'orderRegisterForm' ) && gEBI( 'sLoginReg' ).value != '' ){
388    if( gEBI( 'sPassReg' ).value != '' && gEBI( 'sPassReg' ).value != gEBI( 'sPassReg2' ).value ){
389      alert( sPasswordDontMatch );
390      gEBI( 'sPassReg' ).focus( );
391      return false;
392    }
393    else if( gEBI( 'sPassReg' ).value == '' ){
394      alert( aCF['sWarning'] );
395      gEBI( 'sPassReg' ).focus( );
396      return false;
397    }
398  }
399} // end function checkUserDataForm

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.