PageSourceSearch

https://www.suavia-gesundheitszentrum.de/kliniken-wGlobal/wGlobal/layout/scripts/optimized/ui.js

js suavia-gesundheitszentrum.de collected 2026-10-09 22:38:34 UTC 124,787 bytes, 2,888 lines download raw bytes

1/*
2////////////////////////////////////////////////////////////////
3//
4// UI JavaScript Funktionen
5//
6// Weblication CMS
7// erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de
8// erstellt mit Weblication Content Management System, www.weblication.de
9//
10////////////////////////////////////////////////////////////////
11//                                                            //
12//                   BITTE NICHT ANPASSEN!                    //
13//           JS-Anpassungen können in der design.js           //
14//                    durchgeführt werden.                    //
15//                                                            //
16////////////////////////////////////////////////////////////////
17*/
18
19wUiVersion     = '1.0.13';
20wAllowMinimize = false;
21wUiTmp         = {};
22
23var scriptTags = document.getElementsByTagName('script');
24wUiTmp['wGlobalProjectPath'] = scriptTags[scriptTags.length - 1].getAttribute('src').replace(/^(\/[^\/]*)[^\?]*/, '$1');
25
26devicePixelRatio = window.devicePixelRatio || 1;
27hdLimitDpr       = 2;
28
29if(document.documentElement){
30  document.documentElement.className = document.documentElement.className + (!/MSIE (6|7|8)/.test(navigator.appVersion) ? ' pagestatus-uiloaded' : '');
31}
32
33jQuery(document).ready(function(){
34
35  wCssClassesToAddGlobal   = typeof(wCssClassesToAddGlobal) != 'undefined' ? wCssClassesToAddGlobal : {};
36  wCssDataToAddGlobal      = typeof(wCssDataToAddGlobal) != 'undefined' ? wCssDataToAddGlobal : {};
37  wCssEventsToAddGlobal    = typeof(wCssEventsToAddGlobal) != 'undefined' ? wCssEventsToAddGlobal : {};
38  wCssJQuery               = typeof(wCssJQuery) != 'undefined' ? wCssJQuery : {};
39  wCssDOM                  = typeof(wCssDOM) != 'undefined' ? wCssDOM : {};
40  wMediaqueriesToAddGlobal = typeof(wMediaqueriesToAddGlobal) != 'undefined' ? wMediaqueriesToAddGlobal : {};
41
42  var htmlAdditionalClasses = '';
43
44  if(navigator.appVersion.match(/MSIE (\d+\..)/)){
45    htmlAdditionalClasses += ' ie' + String(navigator.appVersion.match(/MSIE (\d+\..)/)[1]).replace(/\..*/, '');
46  }
47
48  if(parent != self){
49    if(location.href.indexOf('viewmode=blank') != -1){
50      htmlAdditionalClasses += ' lightbox';
51    }
52  }
53
54  if(/mobile/i.test(navigator.userAgent)) htmlAdditionalClasses += ' mobile';
55  if(/iPad/i.test(navigator.userAgent)) htmlAdditionalClasses += ' ipad';
56  if(/iPhone/i.test(navigator.userAgent)) htmlAdditionalClasses += ' iphone';
57  if(/iPod/i.test(navigator.userAgent)) htmlAdditionalClasses += ' ipod';
58  if(/(iPod|iPhone|iPad)/i.test(navigator.userAgent)){
59    htmlAdditionalClasses += ' ios';
60    wUiTmp['isIOS'] = true;
61    if(/CriOs/i.test(navigator.userAgent)){
62      htmlAdditionalClasses += ' crios';
63    }
64    else if(/Safari/i.test(navigator.userAgent)){
65      wUiTmp['isSafari'] = true;
66      htmlAdditionalClasses += ' saios';
67    }
68  }
69
70  htmlAdditionalClasses += ' viewmode-' + (/viewmode=([^&]+)/.test(location.href) ? RegExp.$1 : 'default');
71  htmlAdditionalClasses += (/targetPreview=embed/.test(location.href) ? ' wpreview' : '');
72
73  htmlAdditionalClasses += (('ontouchstart' in window)|| navigator.msMaxTouchPoints  || window.DocumentTouch && document instanceof DocumentTouch ? ' touch' : ' no-touch');
74
75  htmlAdditionalClasses += jQuery(window).scrollTop() == 0 ? ' scrolled-top' : '';
76
77  if(document.documentElement){
78    if(document.documentElement.getAttribute('lang')){
79      htmlAdditionalClasses += ' lang-' + document.documentElement.getAttribute('lang');
80    }
81
82    var documentElementClassName = document.documentElement.className;
83
84    if(jQuery(window).scrollTop() != 0){
85      documentElementClassName = documentElementClassName.replace(' scrolled-top', '');
86    }
87    documentElementClassName = (documentElementClassName.replace('no-js', '') + ' js' + htmlAdditionalClasses).replace(/^\s+/, '');
88    if(typeof(wEditor) == 'undefined'){
89      documentElementClassName = documentElementClassName.replace('weditor', '') + ' no-weditor';
90    }
91    else{
92      documentElementClassName = documentElementClassName.replace('no-weditor', '') + ' weditor';
93    }
94    documentElementClassName = documentElementClassName + (!/MSIE (6|7|8)/.test(navigator.appVersion) ? ' pagestatus-ready' : '');
95    if(/MSIE (6|7|8)/.test(navigator.appVersion)){
96      documentElementClassName = documentElementClassName.replace(/pagestatus-\w+/g, '');
97    }
98    document.documentElement.className = documentElementClassName;
99  }
100
101  if(document.cookie.indexOf('websitezoom=l') != -1){
102    document.body.className = document.body.className + ' zoom-l';
103  }
104
105  for(var addClassSelector in wCssClassesToAddGlobal){
106    jQuery(addClassSelector).each(function(index){
107      var classesToAdd = wCssClassesToAddGlobal[addClassSelector];
108      for(var i = 0, arrayLength = classesToAdd.length; i < arrayLength; i++){
109        var classData = classesToAdd[i].split('=');
110        if(classData.length == 2){
111          var selector = jQuery.trim(classData[0]);
112          if(selector == '.'){
113            jQuery(this).addClass(jQuery.trim(classData[1]));
114          }
115          else if(selector == 'parent'){
116            jQuery(this).parent().addClass(jQuery.trim(classData[1]));
117          }
118          else{
119            jQuery(this).find(selector).addClass(jQuery.trim(classData[1]));
120          }
121        }
122        else{
123          jQuery(this).addClass(jQuery.trim(classData[0]));
124        }
125      }
126    });
127  }
128
129  for(var addDataSelector in wCssDataToAddGlobal){
130    jQuery(addDataSelector).each(function(index){
131      var dataToAdd = wCssDataToAddGlobal[addDataSelector];
132      for(var i = 0, arrayLength = dataToAdd.length; i < arrayLength; i++){
133        var data = dataToAdd[i].split('=');
134        jQuery(this).attr('data-' + jQuery.trim(data[0]), jQuery.trim(data[1]));
135      }
136    });
137  }
138
139  jQuery('*[data-w-addclasses]').each(function(index){
140
141    var classesToAdd = jQuery(this).data('w-addclasses').split(',');
142    jQuery(this).removeAttr('data-w-addclasses');
143    for(var i = 0, arrayLength = classesToAdd.length; i < arrayLength; i++){
144      var classData = classesToAdd[i].split('=');
145      var selector = jQuery.trim(classData[0]);
146      if(selector == '.'){
147        jQuery(this).addClass(jQuery.trim(classData[1]));
148      }
149      else{
150        jQuery(this).find(selector).addClass(jQuery.trim(classData[1]));
151      }
152    }
153  });
154
155  for(var addEventSelector in wCssEventsToAddGlobal){
156    jQuery(addEventSelector).each(function(index){
157      var eventsToAdd = wCssEventsToAddGlobal[addEventSelector];
158      for(var i = 0, arrayLength = eventsToAdd.length; i < arrayLength; i++){
159        var eventData = eventsToAdd[i].split('=');
160        if(eventData.length == 2){
161          var eventType     = jQuery.trim(eventData[0]).replace(/^on/, '');
162          var eventFunction = jQuery.trim(eventData[1]);
163          jQuery(this).bind(eventType, (new Function('event', eventFunction + '(this, event.originalEvent);')));
164        }
165      }
166    });
167  }
168
169  for(var wCssJQueryEntry in wCssJQuery){
170    jQuery(wCssJQueryEntry).each(function(index){
171      if(!wCssJQuery[wCssJQueryEntry]['event'] || wCssJQuery[wCssJQueryEntry]['event'] == 'document.ready'){
172        eval(wCssJQuery[wCssJQueryEntry]['jQuery']);
173      }
174    });
175  }
176
177  for(var wCssDOMEntry in wCssDOM){
178    jQuery(wCssDOMEntry).each(function(index){
179      domActions = {'prependto' : 'prependTo', 'appendto' : 'appendTo', 'insertbefore' : 'insertBefore', 'insertafter' : 'insertAfter'};
180      if(/^(\w+)\(/.test(wCssDOM[wCssDOMEntry]['path'])){
181        eval('jQuery(this).' + domActions[wCssDOM[wCssDOMEntry]['action'].toLowerCase()] + '(jQuery(this).' + wCssDOM[wCssDOMEntry]['path'].replace(/\*\/$/, '') + ');');
182      }
183      else{
184        if(wCssDOM[wCssDOMEntry]['action'] == 'prependto'){
185          jQuery(this).prependTo(wCssDOM[wCssDOMEntry]['path']);
186        }
187        else if(wCssDOM[wCssDOMEntry]['action'] == 'appendto'){
188          jQuery(this).appendTo(wCssDOM[wCssDOMEntry]['path']);
189        }
190        else if(wCssDOM[wCssDOMEntry]['action'] == 'insertbefore'){
191          jQuery(this).insertBefore(wCssDOM[wCssDOMEntry]['path']);
192        }
193        else if(wCssDOM[wCssDOMEntry]['action'] == 'insertafter'){
194          jQuery(this).insertAfter(wCssDOM[wCssDOMEntry]['path']);
195        }
196      }
197    });
198  }
199
200  var mediaQueriesTmpToAdd = '<div id="wMediaqueriesTmp">';
201
202  for(var wMediaqueryToAddGlobal in wMediaqueriesToAddGlobal){
203    mediaQueriesTmpToAdd += '<div id="wMediaqueryTmp_' + wMediaqueryToAddGlobal + '"/>'
204  }
205  mediaQueriesTmpToAdd += '</div>';
206
207  jQuery('body').append(mediaQueriesTmpToAdd);
208
209  jQuery('.wglBannerSlider').wBannerSlider();
210  jQuery('.wglPictureGallery').wPictureGallery();
211  jQuery('.wglTabcontainer').wTabcontainer();
212  jQuery('.wglAccordion').wAccordion();
213
214  jQuery('label').each(function(index){
215    var nameFor     = jQuery(this).attr('for');
216    if(nameFor && nameFor != ''){
217      var currentForm = jQuery(this).closest('form').get(0);
218      if(currentForm){
219        var elementFor  = currentForm.elements[nameFor];
220        if(elementFor && elementFor.length){
221          elementFor = elementFor[0];
222        }
223
224        if(!elementFor){
225          elementFor = jQuery(this).closest('form').find('#' + nameFor).get(0);
226        }
227
228        if(elementFor && typeof(elementFor.getAttribute('placeholder')) == 'string' && (elementFor.className.indexOf('wglIsInvalid') == -1 || elementFor.value == '')){
229          if(elementFor.getAttribute('data-showlabelifhasplaceholder') != '1' && typeof(elementFor.placeholder) != 'undefined'){
230            jQuery(this).css({'display' : 'none'});
231          }
232        }
233      }
234    }
235  });
236
237  wPrepareHTML();
238
239  jQuery(window).load(function(){
240
241    for(var wCssJQueryEntry in wCssJQuery){
242      jQuery(wCssJQueryEntry).each(function(index){
243        if(wCssJQuery[wCssJQueryEntry]['event'] && wCssJQuery[wCssJQueryEntry]['event'] == 'window.load'){
244          eval(wCssJQuery[wCssJQueryEntry]['jQuery']);
245        }
246      });
247    }
248
249    jQuery("img[data-srchover]").each(function(){
250      var thisElement         = jQuery(this);
251      var hoverTriggerElement = thisElement;
252      var hoverTriggerPath    = thisElement.data('hovertrigger');
253      if(hoverTriggerPath){
254        eval('hoverTriggerElement = hoverTriggerElement.' + hoverTriggerPath);
255      }
256      hoverTriggerElement.bind('mouseover', function (event){
257        thisElement.data('srcbeforehover', thisElement.attr('src'));
258        if(thisElement.data('ishd') == '1'){
259          thisElement.attr('src', thisElement.data('srchover2x'));
260        }
261        else{
262          thisElement.attr('src', thisElement.data('srchover'));
263        }
264      });
265      hoverTriggerElement.bind('mouseout', function (event){
266        thisElement.attr('src', thisElement.data('srcbeforehover'));
267      });
268    });
269
270    window.setTimeout(function(){
271      var jQueryHashId = location.hash;
272      if(jQueryHashId != '' && (jQueryHashId.indexOf('#anchor') == 0 || jQueryHashId.indexOf('#tab') == 0)){
273        var anchor = jQuery(jQueryHashId.replace(/\./g, '\\.').replace(/\:/g, '\\:'));        
274        if(anchor.length > 0 && jQuery('.wglContainerInsideTopOnScroll').length > 0){
275          var offsetTopAnchor = (anchor.offset())['top'];
276          var windowScrollTop = jQuery(window).scrollTop();
277          var heightInsideTop = jQuery('.wglContainerInsideTopOnScroll').height();
278          if(offsetTopAnchor < windowScrollTop + heightInsideTop){
279            offsetTopAnchor = offsetTopAnchor - heightInsideTop;
280            jQuery('body, html').animate({scrollTop: offsetTopAnchor});
281          }
282        }
283      }
284    }, 120);
285  });
286
287  jQuery(window).bind('mousewheel DOMMouseScroll', function (event){
288    jQuery('body, html').stop(true, true);
289  });
290
291  if(window.matchMedia){
292    window.matchMedia('print').addListener(function(){
293      wUiTmp['isMediaPrint'] = true;
294      jQuery(window).trigger('resize');
295    });
296  }
297  else{
298    window.onbeforeprint = function(event){
299      wUiTmp['isMediaPrint'] = true;
300      jQuery(window).trigger('resize');
301    };
302  }
303
304  if(/viewmode=print/.test(location.search)){
305    wUiTmp['isViewmodePrint'] = true;
306  }
307
308  jQuery(window).bind('load resize scroll', function(event){
309
310    var winScrollTop = jQuery(window).scrollTop();
311
312    if(wUiTmp['lastScrollTop']){
313      if(winScrollTop <= 0){
314        if(wUiTmp['lastScrollStatus'] != 'top'){
315          document.documentElement.className = document.documentElement.className.replace(' scrolldirection-down', '').replace(' scrolldirection-up', '') + ' scrolled-top';
316        }
317        wUiTmp['lastScrollStatus'] = 'top';
318      }
319      else if(winScrollTop < wUiTmp['lastScrollTop']){
320        if(wUiTmp['lastScrollStatus'] != 'scrollup'){
321          document.documentElement.className = document.documentElement.className.replace(' scrolled-top', '').replace(' scrolldirection-down', '') + ' scrolldirection-up';
322        }
323        wUiTmp['lastScrollStatus'] = 'scrollup';
324      }
325      else if(winScrollTop > wUiTmp['lastScrollTop']){
326        if(wUiTmp['lastScrollStatus'] != 'scrolldown'){
327          document.documentElement.className = document.documentElement.className.replace('scrolled-top', '').replace(' scrolldirection-up', '') + ' scrolldirection-down';
328        }
329        wUiTmp['lastScrollStatus'] = 'scrolldown';
330      }
331    }
332
333    wUiTmp['lastScrollTop'] = winScrollTop;
334
335    var winHeight    = jQuery(window).height();
336    jQuery('img.wglLazyLoadInit').each(function(index){
337
338      var currentImg   = jQuery(this);
339      var offsetTop    = parseInt(currentImg.offset().top);
340      var srcMin       = currentImg.data('srcmin') ? currentImg.data('srcmin') : '';
341      var widthCurrent = parseInt(currentImg.width());
342      var attrWidthCur = parseInt(typeof(currentImg.attr('width')) != 'undefined' ? currentImg.attr('width') : 0);
343      var widthMin     = parseInt(srcMin.replace(/.*@min/, '').replace(/\..*/, ''));
344
345      var isVisibleComponent = true;
346
347      if(currentImg.attr('data-maxwidthifinvisible') && currentImg.attr('data-maxwidthifinvisible') > widthCurrent){
348        widthCurrent = currentImg.attr('data-maxwidthifinvisible');
349      }
350
351      //console.log(widthCurrent);
352      //console.log(srcMin)
353      //console.log(currentImg.get(0));
354
355      //if(currentImg.hasClass('listEntryImage')){
356        if(!currentImg.is(':visible')){
357          isVisibleComponent = false;
358          closestElement = currentImg.closest('.elementList');
359          if(closestElement.length > 0 && closestElement.is(':visible')){
360            if(closestElement.offset().top < winScrollTop + winHeight){
361              isVisibleComponent = true;
362            }
363          }
364        }
365      //}
366
367      if(isVisibleComponent || wUiTmp['isMediaPrint'] || wUiTmp['isViewmodePrint']){
368        if((offsetTop < winScrollTop + winHeight ) || wUiTmp['isMediaPrint'] || wUiTmp['isViewmodePrint']){
369          if(devicePixelRatio >= hdLimitDpr && typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && attrWidthCur < widthCurrent * 2 && currentImg.attr('data-ishd') != '1'){
370            currentImg.attr('src', currentImg.data('src2x'));
371            currentImg.attr('data-ishd', '1');
372          }
373          else if(typeof(currentImg.attr('data-srcmin')) != 'undefined' && currentImg.attr('data-srcmin') != '' && widthCurrent < widthMin && widthMin < attrWidthCur && currentImg.attr('data-ismin') != '1' && currentImg.attr('data-ishd') != '1' && currentImg.attr('data-isld') != '1'){
374            currentImg.attr('src', currentImg.data('srcmin'));
375            currentImg.attr('data-ismin', '1');
376          }
377          else if(typeof(currentImg.attr('data-src')) != 'undefined' && currentImg.attr('data-src') != '' && currentImg.attr('data-ishd') != '1' && currentImg.attr('data-isld') != '1'){
378            if(currentImg.data('src').indexOf('@px') != -1){
379              try{
380                if(currentImg.get(0).getBoundingClientRect()['width'] - widthCurrent == -0.5){
381                  currentImg.get(0).style.width    = 'calc(100% + 0.5px)';
382                  currentImg.get(0).style.maxWidth = 'calc(100% + 0.5px)';
383                }
384              }
385              catch(e){console.log(e)}
386              currentImg.attr('src', currentImg.data('src').replace('@px', '@' + (devicePixelRatio >= hdLimitDpr ? widthCurrent * 2 : widthCurrent) + 'px'));
387            }
388            else{
389              currentImg.attr('src', currentImg.data('src'));
390              currentImg.attr('data-isld', '1');
391            }
392          }
393          if(currentImg.parent().prop('tagName') == 'PICTURE'){
394            currentImg.parent().children('source').each(function(){
395              jQuery(this).attr('media', jQuery(this).attr('media').replace('wlazyload and ', ''));
396            });
397          }
398          currentImg.removeClass('wglLazyLoadInit');
399        }
400      }
401    });
402
403    jQuery('.wglAnimateIfVisibleOnce').each(function(index){
404      var currentElement = jQuery(this);
405      var offsetTop      = parseInt(currentElement.offset().top);
406      if(offsetTop < winScrollTop + winHeight || location.href.indexOf('viewmode=print') != -1){
407        currentElement.addClass('wglAnimateIfVisibleOnceVisible');
408        currentElement.removeClass('wglAnimateIfVisibleOnce');
409      }
410    });
411
412    jQuery('.wglAnimateIfVisible').each(function(index){
413      var currentElement = jQuery(this);
414      var offsetTop      = parseInt(currentElement.offset().top);
415      var offsetHeight   = parseInt(currentElement.outerHeight());
416      if((offsetTop < winScrollTop + winHeight && offsetTop + offsetHeight > winScrollTop) || location.href.indexOf('viewmode=print') != -1){
417        currentElement.addClass('isVisibleOnce');
418        currentElement.addClass('isVisible');
419        currentElement.removeClass('isInvisible');
420      }
421      else{
422        currentElement.addClass('isInvisible');
423        currentElement.removeClass('isVisible');
424      }
425    });
426
427    jQuery('.wglSearchSuggest').each(function(index){
428      var currentElement = jQuery(this);
429      currentElement.attr('autocomplete', 'off');
430      currentElement.bind('keydown', function(event){
431        if(event.keyCode == 27){
432          jQuery('#searchSuggestOuter').remove();
433        }
434        else if(event.keyCode == 40 || event.keyCode == 38){
435          event.preventDefault();
436          var positionSuggestSelected = 0;
437          if(event.target.getAttribute('data-positionsuggestedselected')){
438            positionSuggestSelected = positionSuggestSelected + parseInt(event.target.getAttribute('data-positionsuggestedselected'));
439          }
440
441          positionSuggestSelected = event.keyCode == 40 ? positionSuggestSelected + 1 : positionSuggestSelected - 1;
442          if(positionSuggestSelected > jQuery('#searchSuggestOuter .searchSuggestEntry').length){
443            positionSuggestSelected = jQuery('#searchSuggestOuter .searchSuggestEntry').length;
444          }
445          else if(positionSuggestSelected < 1){
446            positionSuggestSelected = 1
447          }
448
449          event.target.setAttribute('data-positionsuggestedselected', positionSuggestSelected);
450          event.target.value = jQuery('#searchSuggestOuter .searchSuggestEntry:nth-child(' + positionSuggestSelected + ')').data('word');
451
452          jQuery('#searchSuggestOuter .searchSuggestEntry').removeClass('selected');
453          jQuery('#searchSuggestOuter .searchSuggestEntry:nth-child(' + positionSuggestSelected + ')').addClass('selected');
454        }
455      });
456      currentElement.bind('keyup', function(event){
457        event.preventDefault();
458        var searchTerm = jQuery(this).val();
459
460        if(typeof(wUiTmp['searchTermNumberResults']) == 'undefined'){
461          wUiTmp['searchTermNumberResults'] = {};
462        }
463
464        if(searchTerm != '' && searchTerm != wUiTmp['lastSearchTerm']){
465          if(event.keyCode == 40 || event.keyCode == 38){
466            event.preventDefault();
467            return;
468          }
469
470          if(wUiTmp['lastSearchTerm'] && searchTerm.indexOf(wUiTmp['lastSearchTerm']) == 0 && wUiTmp['lastSearchTermNumberResults'] == 0){
471            return;
472          }
473
474          if(wUiTmp['searchTermNumberResults'][searchTerm] && wUiTmp['searchTermNumberResults'][searchTerm] == 0){
475            return;
476          }
477          var project       = location.pathname.replace(/[^\/]*$/, '').replace(/^(\/[^\/]*)[^\?]*/, '$1');
478          if(currentElement.data('project-search')){
479            projectSearch = currentElement.data('project-search');
480            if(project == '/'){
481              project = projectSearch;
482            }  
483            else if(projectSearch.indexOf('!important') != -1){
484              project = projectSearch.replace(/\s*\!important/, '');              
485            }
486          }
487          var projectGlobal = wUiTmp['wGlobalProjectPath'];
488          var search        = 'default';
489          if(currentElement.data('id-search')){
490            search = currentElement.data('id-search');
491          }
492          var url = projectGlobal + '/wGlobal/scripts/php/wSearchSuggest.php?searchTerm=' + encodeURIComponent(searchTerm) + '&project=' + project + '&search=' + search;
493          if(currentElement.data('usecache') == '1'){
494            url = project + '/weblication/wSearchSuggest/searchTerm=' + encodeURIComponent(searchTerm).replace(/~/g, '_WT-IL_').replace(/%/g, '~').toLowerCase() + '.html';
495          }
496
497          jQuery.ajax({type: "GET", url: url, dataType: 'json', success: function(resultData){
498            var numberResults = 0;
499            var innerHTMLSuggest = '<div id="searchSuggestOuter"><div id="searchSuggestInner">';
500            for(word in resultData){
501              innerHTMLSuggest += '<div class="searchSuggestEntry" data-word="' + word + '">' + word + '</div>';
502              numberResults++;
503            }
504            wUiTmp['lastSearchTermNumberResults'] = numberResults;
505            wUiTmp['searchTermNumberResults'][searchTerm] = numberResults;
506
507            innerHTMLSuggest += '</div></div>';
508            jQuery('#searchSuggestOuter').remove();
509            if(numberResults > 0){
510              currentElement.after(innerHTMLSuggest);
511              jQuery('.searchSuggestEntry').bind('mousedown', function(){
512                jQuery(this).closest('#searchSuggestOuter').prev('input').val(jQuery(this).data('word'));
513                jQuery(this).closest('form').submit();
514                jQuery('#searchSuggestOuter').remove();
515              });
516            }
517          }});
518        }
519        else if(searchTerm != wUiTmp['lastSearchTerm']){
520          jQuery('#searchSuggestOuter').remove();
521        }
522        wUiTmp['lastSearchTerm'] = searchTerm;
523      });
524    });
525
526    jQuery('.wglKeepInsideTopOnScroll').each(function(index){
527      var currentElement = jQuery(this);
528      var elementMoved   = null;
529      var offsetTop      = parseInt(currentElement.offset().top);
530      var diffTop        = offsetTop - winScrollTop;
531      var moveID         = '';
532
533      if(diffTop < 0){
534        if(currentElement.attr('data-hasmoved') != '1'){
535          if(!jQuery('.wglContainerInsideTopOnScroll').length){
536            jQuery('body').prepend('<div class="wglContainerInsideTopOnScroll"></div>');
537          }
538          currentElement.attr('data-hasmoved', '1');
539          moveID = String(parseInt(Math.random() * 1000000));
540
541          if(typeof(currentElement.attr('data-moveidsource')) == 'undefined'){
542            currentElement.attr('data-moveidsource', moveID);
543          }
544          else{
545            moveID = currentElement.attr('data-moveidsource');
546          }
547
548          currentElement.before('<div id="moveidsource-' + moveID + '" class="wglKeepInsideTopOnScroll" data-hasmoved="1" data-moveidsource="' + moveID + '"></div>');
549          currentElement.removeAttr('data-moveidsource').attr('data-moveidtarget', moveID).attr('data-moveidtarget', moveID).appendTo('.wglContainerInsideTopOnScroll').addClass('moved-init').removeClass('wglKeepInsideTopOnScroll').removeClass('restored-init').removeClass('restored-ready');
550          window.setTimeout(function(){
551            currentElement.removeClass('moved-init').addClass('moved-ready');
552          }, 10);
553          height = currentElement.height();
554          jQuery('#' + 'moveidsource-' + moveID).css('height', String(height) + 'px');
555        }
556        else{
557          height = jQuery(".wglContainerInsideTopOnScroll *[data-moveidtarget='" + currentElement.attr('data-moveidsource') + "']").height();
558          currentElement.css('height', String(height) + 'px');
559        }
560      }
561      else if(currentElement.attr('data-hasmoved') == '1'){
562        if(currentElement.parent().attr('id') == 'blockMainInner') currentElement.css('display', 'none');
563        moveID = currentElement.attr('data-moveidsource');
564        elementMoved = jQuery(".wglContainerInsideTopOnScroll *[data-moveidtarget='" + moveID + "']");
565        currentElement.before(elementMoved.addClass('wglKeepInsideTopOnScroll').removeClass('moved-init').removeClass('moved-ready').addClass('restored-init').removeAttr('data-hasmoved'));
566        window.setTimeout(function(){
567          if(currentElement.html() == ''){
568            currentElement.remove();
569          }            
570          elementMoved.removeClass('restored-init').addClass('restored-ready');
571        }, 10);
572      }
573    });
574
575    var idTopSection = '', titleSection = '', currentElement, nearestPositionTop = 100000, elementPositionTop = 0;
576
577    var offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').outerHeight();
578
579    jQuery('.elementSection').each(function(index){
580      currentElement = jQuery(this);
581      elementPositionTop  = parseInt(currentElement.offset().top) - winScrollTop - offsetTopFixed;
582      if(elementPositionTop < winHeight - 128 && (elementPositionTop >= 0 && elementPositionTop < nearestPositionTop || elementPositionTop < 0 && elementPositionTop * -1 < nearestPositionTop)){
583        nearestPositionTop = (elementPositionTop > 0 ? elementPositionTop : - elementPositionTop);
584        titleSection       = currentElement.attr('id');
585      }
586    });
587
588    if(titleSection != '' && titleSection != wUiTmp['lastSectionSelected']){
589      jQuery(".elementNavigationSections li").removeClass('selected');
590      jQuery(".elementNavigationSections li > a[href='#" + titleSection + "']").parent().addClass('selected');
591      wUiTmp['lastSectionSelected'] = titleSection;
592    }
593  });
594
595  window.setTimeout(function(event){
596    wAdaptParallax(event);
597  }, 320);
598
599  jQuery(window).bind("load resize scroll", function(event){
600    wAdaptParallax(event);
601  });
602
603  jQuery('body').bind("load touchmove", function(event){
604    wAdaptParallax(event);
605  });
606
607  jQuery(window).bind("touchend", function(event){
608    wAdaptParallax(event);
609  });
610
611  jQuery(window).bind('load resize', function(){
612
613    wOptimizePictureSizes();
614
615    var hasChangedMediaQuery = false;
616
617    jQuery('#wMediaqueriesTmp > div').each(function(index){
618      if(window.getComputedStyle){
619        try{
620          var computedStyle  = window.getComputedStyle(jQuery(this).get(0));
621          var fontFamily     = computedStyle.fontFamily.replace(/"/g, '');
622          var lastMediaQuery = jQuery(this).data('lastmediaquery') || '';
623          if(fontFamily != lastMediaQuery){
624            if(fontFamily.indexOf('mediaquery_') == 0){
625              eval('if(typeof(' + fontFamily + '_onactivate) == \'function\'){' + fontFamily + '_onactivate();}');
626            }
627            else if(lastMediaQuery.indexOf('mediaquery_') == 0){
628              eval('if(typeof(' + lastMediaQuery + '_ondeactivate) == \'function\'){' + lastMediaQuery + '_ondeactivate();}');
629            }
630            jQuery(this).data('lastmediaquery', fontFamily);
631            hasChangedMediaQuery = true;
632          }
633        }
634        catch(e){};
635      }
636    });
637
638    if(hasChangedMediaQuery){
639      jQuery("img[data-srcmin]").each(function(){
640        var currentImg    = jQuery(this);
641        var widthOrig     = parseInt(typeof(currentImg.attr('widthorig')) != 'undefined' ? currentImg.attr('data-widthorig') : currentImg.attr('width'));
642        var srcMin        = currentImg.data('srcmin') ? currentImg.data('srcmin') : '';
643        var widthCurrent  = parseInt(currentImg.width());
644        var attrWidthCur = parseInt(typeof(currentImg.attr('width')) != 'undefined' ? currentImg.attr('width') : 0);
645        var widthMin      = parseInt(srcMin.replace(/.*@min/, '').replace(/\..*/, ''));
646        //var widthOuter    = parseInt(currentImg.closest('.elementStandard').width());
647        var widthOuter    = parseInt(currentImg.parent().width());
648
649        var diffWidthFrame = 0;
650        if(currentImg.parent().parent().parent().parent().hasClass('picture')){
651          diffWidthFrame = currentImg.parent().parent().parent().parent().outerWidth() - widthCurrent;
652        }
653        else if(currentImg.parent().parent().hasClass('picture')){
654          diffWidthFrame = currentImg.parent().parent().outerWidth() - widthCurrent;
655        }
656
657        if(widthCurrent > widthOrig && widthOuter > widthOrig + diffWidthFrame + 1 && widthMin > widthOrig){
658          currentImg.attr('src', srcMin);
659          if(typeof(currentImg.attr('width')) != 'undefined' && currentImg.attr('width') != ''){
660            currentImg.attr('data-widthorig', currentImg.attr('width'));
661            currentImg.removeAttr('width');
662            currentImg.attr('height', 'auto');
663          }
664        }
665      });
666    }
667
668    jQuery('.wglExpandToHeighestChild').each(function(index){
669
670      var currentElement = jQuery(this);
671      var maxHeight      = 0;
672      currentElement.children('*').each(function(index){
673        if(jQuery(this).attr('data-adjusttoheighestchild') != 'no' && jQuery(this).outerHeight(true) > maxHeight){
674          maxHeight = jQuery(this).outerHeight(true);
675        }
676      });
677      if(maxHeight > 0){
678        currentElement.css('height', String(maxHeight) + 'px');
679      }
680    });
681
682    jQuery('.wglCheckWidthParent').each(function(index){
683
684      var currentElement = jQuery(this);
685      var widthSelf      = currentElement.attr('data-width-init') || currentElement.outerWidth();
686      var widthParent    = currentElement.parent().width();
687
688      if(currentElement.parent().hasClass('isToSmall') && !currentElement.parent().is(":visible")){
689        currentElement.parent().removeClass('isToSmall');
690        widthParent    = currentElement.parent().width();
691        currentElement.parent().addClass('isToSmall');
692      }
693
694      if(!currentElement.attr('data-width-init')){
695        currentElement.attr('data-width-init', widthSelf);
696      }
697
698      if(widthParent > widthSelf){
699        currentElement.parent().removeClass('isToSmall');
700      }
701      else{
702        currentElement.parent().addClass('isToSmall');
703      }
704    });
705
706    jQuery('.wglExpandToParent').each(function(index){
707
708      var currentElement = jQuery(this);
709      var height         = currentElement.parent().height();
710      currentElement.css('height', String(height) + 'px');
711    });
712    wProcessWglAdjustHeightMax();
713  });
714
715  jQuery('.wglAddScrollTop').each(function(index){
716
717    var currentElement = jQuery(this);
718    if(currentElement.context.tagName.toLowerCase() == 'body'){
719      currentElement.append('<div id="scrollTopOuter"><div id="scrollTop"><div class="scrollTopInner"></div></div></div');
720    }
721    else{
722      currentElement.after('<div id="scrollTopOuter"><div id="scrollTop"><div class="scrollTopInner"></div></div></div');
723    }
724    jQuery('#scrollTop').bind('mousedown touchstart', function (event){
725      event.preventDefault();
726		  jQuery('body, html').animate({scrollTop:0});
727		});
728    jQuery(window).scroll(function(){
729      var scrollTop  = jQuery(this).scrollTop();
730      if(scrollTop > 200){
731        jQuery('#scrollTop').fadeIn();
732      }
733      else{
734        jQuery('#scrollTop').fadeOut();
735      }
736    });
737  });
738
739  jQuery('.wglAddFontResizer').each(function(index){
740
741    var currentElement = jQuery(this);
742    currentElement.prepend('<div id="fontResizer"><span class="fontResizerLabel"></span><span class="fontResizerShrink">A</span><span class="fontResizerEnlarge">A</span></div');
743
744    jQuery('.fontResizerShrink').bind('click', function (event){
745      document.cookie = 'websitezoom=;path=/';
746      location.reload();
747		});
748    jQuery('.fontResizerEnlarge').bind('click', function (event){
749      document.cookie = 'websitezoom=l;path=/';
750      location.reload();
751		});
752  });
753
754  jQuery('.wglShrinkToMinWidthWithoutBreak').each(function(index){
755
756    var currentElement = jQuery(this);
757    var widthOuter = currentElement.width();
758    var widthInner = currentElement.children('*').outerWidth();
759    var textAlignBefore = currentElement.css('text-align');
760    currentElement.css({'text-align' : 'left'});
761    var lastElementInner = currentElement.children('*:last');
762    var offsetRightLastElementInner = Math.ceil(lastElementInner.get(0).offsetLeft + lastElementInner.outerWidth() + parseInt(lastElementInner.css('margin-right')));
763    currentElement.css({'text-align' : textAlignBefore});
764    currentElement.css({'width' : String(offsetRightLastElementInner) + 'px'});
765  });
766
767  jQuery('.wglAdjustWidthEqual').each(function(index){
768
769    var currentElement = jQuery(this);
770    var numberEntries  = 0;
771    currentElement.children('*').each(function(index){
772      if(jQuery(this).css('display') != 'none'){
773        numberEntries++;
774      }
775    });
776    var widthPerEntry  = String(100 / numberEntries) + '%';
777    currentElement.children('*').each(function(index){
778      if(jQuery(this).css('display') != 'none'){
779        jQuery(this).css({'width' : widthPerEntry});
780      }
781    });
782  });
783
784  jQuery('.wglRemoveOnClick').each(function(index){
785    jQuery(this).attr('onclick', '').unbind('click');
786  });
787
788  if(typeof(wEditor) == 'undefined'){
789    jQuery('.wglFancybox').each(function(index){
790      var currentElement = jQuery(this);
791      if(currentElement.get(0).nodeName == 'IMG'){
792        var wrapElement = currentElement.parent().attr('class') == 'listEntryThumbnailOuter' ? currentElement.parent() : currentElement;
793        var srcFancy    = currentElement.attr('src');
794        if(currentElement.attr('data-src') && currentElement.attr('data-src') != ''){
795          srcFancy = currentElement.attr('data-src');
796        }
797        else{
798          if(/\-/.test(srcFancy.replace(/[\s\S]+\//, ''))){
799            srcFancy = srcFancy.replace(/\/weblication\/wThumbnails/, '').replace(/-[^-]+(\.\w+)$/, '$1');
800          }
801          else if(currentElement.attr('data-src2x') && currentElement.attr('data-src2x') != ''){
802            srcFancy = currentElement.attr('data-src2x');
803          }
804        }
805
806        var closestList = currentElement.closest('.elementList');
807        var relId       = '';
808        if(closestList.length == 1){
809          relId = closestList.attr('id');
810        }
811        wrapElement.wrap('<a rel="' + relId + '" onclick="event && event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;" title="' + currentElement.get(0).alt + '" class="boxPictureOnly" href="' + srcFancy + '"/>');
812      }
813    });
814    if(('ontouchstart' in window) || navigator.msMaxTouchPoints || window.DocumentTouch && document instanceof DocumentTouch){
815      jQuery('.wglNavigationOptimizeTouch li li:not(:has(ul))').each(function(index){
816        //jQuery(this).css({'border' : 'solid 4px blue'});
817        jQuery(this).bind('click touchstart', function(event){
818          event.stopPropagation();
819        });
820      });
821      jQuery('.wglNavigationOptimizeTouch li.navLevel1Open > a, .wglNavigationOptimizeTouch li.navLevel1OpenSelected > a, .wglNavigationOptimizeTouch li.navLevel1OpenDescendantSelected > a, .wglNavigationOptimizeTouch li.navLevel1:has(a[data-previewlink]) > a').each(function(index){
822        //jQuery(this).css({'border' : 'solid 4px green'});
823        jQuery(this).bind(navigator.userAgent.indexOf('Trident') != -1 && navigator.userAgent.indexOf('Touch') != -1 ? 'pointerdown' : 'click', function(event){
824          var timeClicked = new Date().getTime();
825          if(event.pointerType && event.pointerType == 'mouse'){
826          }
827          else if(event.target.getAttribute('data-has-already-touched') && event.target.getAttribute('data-has-already-touched') > timeClicked - 600){
828          }
829          else{
830            event.preventDefault();
831            event.target.setAttribute('data-has-already-touched', timeClicked);
832          }
833        });
834      });
835    }
836
837    wglValidateElementInline = function(currentInputElement, options){
838
839      var currentInput = jQuery(currentInputElement);
840
841      var formPos      = currentInput.closest('form').attr('data-formpos');
842      var formAction   = currentInput.closest('form').attr('action');
843
844      var elementName = currentInput.attr('name');
845      elementName = elementName.replace('[]', '');
846
847      var elementValue = currentInput.val();
848      if(currentInput.attr('type') == 'checkbox'){
849        elementValue = '';
850        currentInput.parent().parent().find('input').each(function(){
851          elementValue += (jQuery(this).get(0).checked ? jQuery(this).val() : '');
852        });
853      }
854      else if(currentInput.attr('type') == 'radio'){
855        elementValue = '';
856        currentInput.parent().parent().find('input').each(function(){
857          elementValue += (jQuery(this).get(0).checked ? jQuery(this).val() : '');
858        });
859      }      
860      else if(currentInput.prop("tagName") == 'SELECT' && currentInput.attr('multiple') == 'multiple'){
861        elementValue = '';
862        currentInput.children().each(function(){
863          elementValue += (jQuery(this).get(0).selected ? jQuery(this).val() : '');
864        });
865      }
866
867      if(elementValue == null){
868        elementValue = '';
869      }
870
871      var validationID  = formPos + currentInput.attr('id');
872      var urlValidation = formAction + '?action=ve&en=' + elementName + '&ev=' + elementValue;
873
874      jQuery.ajax({
875        type: "GET",
876        async: true,
877        dataType: "json",
878        url: urlValidation,
879        success: function(result){
880
881          elementsWithValidationClass = currentInput;
882
883          if(currentInput.attr('type') == 'checkbox' || currentInput.attr('type') == 'radio'){
884            elementsWithValidationClass = elementsWithValidationClass.parent().parent().children();
885          }
886
887          var validationID = formPos + elementsWithValidationClass.attr('id');
888
889          var elementToAddError = elementsWithValidationClass.parent();
890
891          if(elementsWithValidationClass.parent().prev('dt')){
892            elementToAddError = elementsWithValidationClass.parent().prev('dt');
893          }
894
895          var elementToAddOK = elementsWithValidationClass.parent();
896
897          if(elementsWithValidationClass.attr('name') && elementsWithValidationClass.closest('form').find('label[for="' + elementsWithValidationClass.attr('name').replace('[]', '') + '"]')){
898            elementToAddOK = elementsWithValidationClass.closest('form').find('label[for="' + elementsWithValidationClass.attr('name').replace('[]', '') + '"]');
899          }
900          else if(elementsWithValidationClass.parent().prev('dt').find('label')){
901            elementToAddOK = elementsWithValidationClass.parent().prev('dt').find('label');
902          }
903
904          if(!result['isValid']){
905            elementsWithValidationClass.addClass('wglIsInvalid');
906
907            jQuery('#validationStatus_' + validationID).remove();
908
909            if(result['errorMessage'] != ''){
910              if(jQuery('#errorMessage_' + validationID).length == 0){
911                elementToAddError.addClass('wglContainsErrorMessageInline').append('<div class="wglErrorMessageInline" id="errorMessage_' + validationID + '"><div>' + result['errorMessage'] + '</div></div>');
912                (function(elementsWithValidationClass){
913                  window.setTimeout(function(){
914                    jQuery('#errorMessage_' + validationID).addClass("loaded");
915                  }, 32);
916                })(elementsWithValidationClass);
917              }
918            }
919          }
920          else{
921            elementsWithValidationClass.removeClass('wglIsInvalid');
922
923            jQuery('#errorMessage_' + validationID).remove();
924
925            if(elementToAddError.find('.wglErrorMessageInline').length == 0){
926              elementToAddError.removeClass('wglContainsErrorMessageInline');
927            }
928
929            if(jQuery('#validationStatus_' + validationID).length == 0){
930              elementToAddOK.addClass('wglContainsValidationStatusInline').append('<div class="wglValidationStatusOK" id="validationStatus_' + validationID + '"><div></div></div>');
931              (function(elementsWithValidationClass){
932                window.setTimeout(function(){
933                  jQuery('#validationStatus_' + validationID).addClass("loaded");
934                }, 32);
935              })(elementsWithValidationClass);
936            }
937          }
938        }
939      });
940    };
941
942    jQuery('form[data-inlinevalidation="onblur"]').each(function(){
943      wUiTmp['formPos'] = wUiTmp['formPos'] ? wUiTmp['formPos'] + 1 : 1;
944      jQuery(this).attr('data-formpos', wUiTmp['formPos']);
945      if(jQuery(this).attr('action').indexOf('/weblication/grid5/tmpHTTP/wForm-') != -1){
946        jQuery(this).find('input, textarea, select').each(function(){
947          if(location.search.indexOf('wFormStatus=failed') != -1){
948            wglValidateElementInline(jQuery(this).get(0), {'onInit' : true});
949          }
950          var eventsToValidate = 'blur';
951          if(jQuery(this).attr('type') == 'radio'){
952            eventsToValidate = 'click';
953          }
954          else if(jQuery(this).attr('type') == 'checkbox' || jQuery(this).prop("tagName") == 'SELECT'){
955            eventsToValidate = 'change';
956          }
957          else if(jQuery(this).hasClass('hasDatepicker')){
958            eventsToValidate = 'change';
959          }
960
961          jQuery(this).on(eventsToValidate, function(){
962            wglValidateElementInline(jQuery(this).get(0), {});
963          });
964        });
965      }
966    });
967  }
968
969  jQuery('.wglClickable').css({'cursor': 'pointer'});
970
971  jQuery(window).bind('load', function(){
972
973    if(document.documentElement && !/MSIE (6|7|8)/.test(navigator.appVersion)){
974      window.setTimeout(function(){
975        document.documentElement.className = document.documentElement.className + ' pagestatus-loaded';
976      }, 1000);
977    }
978
979    jQuery('.wglMagnifier').wMagnifier();
980
981    jQuery('.wglOverflowXTouch').each(function(index){
982
983      var currentElement = jQuery(this);
984      var widthOuter = currentElement.width();
985      var widthInner = currentElement.children('*').outerWidth();
986      if(!currentElement.is(":visible")){
987        return false;
988      }
989      else if(widthInner <= widthOuter){
990        return false;
991      }
992      else{
993        var lastElementInner = currentElement.children('*').children('*:last');
994        var offsetRightLastElementInner = lastElementInner.get(0).offsetLeft + lastElementInner.outerWidth() + parseInt(lastElementInner.css('margin-right'));
995        currentElement.children('*').children('*').each(function(index){
996          jQuery(this).css('width', jQuery(this).width());
997        });
998        lastElementInner.parent().css({'width' : String(offsetRightLastElementInner) + 'px'})
999      }
1000
1001      jQuery(this).find('img').attr('unselectable', 'on');
1002
1003      jQuery('body').bind('touchstart mousedown', function(event){
1004        if(jQuery(event.target).closest(currentElement).length != 0){
1005          event.preventDefault();
1006        }
1007      });
1008
1009      jQuery('body').bind("touchmove mousemove", function(event){
1010        if(jQuery('body').data('wtouchelement')){
1011
1012          var mouseXDiff   = (event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX) - jQuery('body').data('wtouchmousex');
1013          var mouseYDiff   = (event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY) - jQuery('body').data('wtouchmousey');
1014
1015          jQuery('body').data('wtouchmousex', event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX);
1016          jQuery('body').data('wtouchmousey', event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY);
1017          jQuery('body').data('wtouchlastdiffx', mouseXDiff);
1018          jQuery('body').data('wtouchlastdiffy', mouseYDiff);
1019
1020          var milliseconds = (new Date()).getTime();
1021          var timeDiff     = milliseconds - jQuery('body').data('timestamplast');
1022          jQuery('body').data('timestampbefore', jQuery('body').data('timestamplast'));
1023          jQuery('body').data('timestamplast', milliseconds);
1024
1025          var speedX = Math.round(100 * (mouseXDiff > 0 ? mouseXDiff : -mouseXDiff) / timeDiff) + 1;
1026
1027          jQuery('body').data('wtouchspeedX', speedX);
1028
1029          var touchDiffX = jQuery('body').data('wtouchmousex') - jQuery('body').data('wtouchstartmousex');
1030          jQuery('body').data('wtouchdiffx', touchDiffX);
1031
1032          var widthOuter = parseInt(jQuery('body').data('wtouchelement').width());
1033          var left       = parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left'));
1034          left           = isNaN(left) ? 0 : left;
1035          var right      = parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')) - jQuery('body').data('wtouchelement').children('*').width();
1036          right = isNaN(right) ? 0 : right;
1037
1038          if(left > 32){
1039            jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : 0});
1040            jQuery('body').removeData('wtouchelement');
1041            return false;
1042          }
1043          else if(right > 32){
1044            jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : String(parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').width())) + 'px'});
1045            jQuery('body').removeData('wtouchelement');
1046            return false;
1047          }
1048          if(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX < 0){
1049            jQuery('body').data('wtouchelement').children('*').css({'margin-left' : String(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX) + 'px'});
1050          }
1051          else{
1052            jQuery('body').data('wtouchelement').children('*').css({'margin-left' : String(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX) + 'px'});
1053          }
1054        }
1055      });
1056
1057      jQuery(this).bind('touchstart mousedown', function(event){
1058        jQuery(this).children('*').stop();
1059        jQuery('body').data('wtouchelement', jQuery(this));
1060        jQuery(this).data('wtouchstartmarginleft', parseInt(jQuery(this).children('*').css('margin-left')));
1061        jQuery(this).data('wtouchstartmargintop', parseInt(jQuery(this).children('*').css('margin-top')));
1062        jQuery('body').data('wtouchstartmousex', event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX);
1063        jQuery('body').data('wtouchstartmousey', event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY);
1064      });
1065
1066      jQuery('body').bind("touchend mouseup", function(event){
1067
1068        if(jQuery('body').data('wtouchelement')){
1069
1070          var milliseconds = (new Date()).getTime();
1071          var timeDiff     = milliseconds - jQuery('body').data('timestamplast');
1072          var touchDiffX   = jQuery('body').data('wtouchdiffx');
1073          var lastDiffX    = jQuery('body').data('wtouchlastdiffx');
1074          var lastDiffXn   = lastDiffX >= 0 ? lastDiffX : -lastDiffX;
1075
1076          if(lastDiffXn > 1){
1077            var speedX = (Math.round((lastDiffXn > 0 ? lastDiffXn : -lastDiffXn) / timeDiff) + 1) * 5;
1078            if(speedX > 200){
1079              speedX = 200;
1080            }
1081            var movingWidth = Math.round(touchDiffX * 2 * (1 + speedX / 100));
1082            if(jQuery('body').data('wtouchdiffx') < 0){
1083              var right      = parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')) - jQuery('body').data('wtouchelement').children('*').width();
1084              if(movingWidth < right){
1085                movingWidth = right;
1086              }
1087              var duration    = (movingWidth > 0 ? movingWidth : -movingWidth) * 1.5 + Math.round(100 / speedX);
1088              jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : '+=' + String(movingWidth)}, {'duration' : duration, 'easing' : 'wEaseOutScroll'});
1089            }
1090            else{
1091              var left       = parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left'));
1092              if(-movingWidth < left){
1093                movingWidth = -left;
1094              }
1095              var duration    = (movingWidth > 0 ? movingWidth : -movingWidth) * 1.5 + Math.round(100 / speedX);
1096              jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : '+=' + String(movingWidth)}, {'duration' : duration, 'easing' : 'wEaseOutScroll'});
1097            }
1098          }
1099          jQuery('body').removeData('wtouchelement');
1100        }
1101      });
1102    });
1103  });
1104});
1105
1106
1107wPrepareHTML = function(root){
1108
1109  if(!root){
1110    root = jQuery('body');
1111  }
1112
1113  jQuery("a[data-ajaxurl]").each(function(){
1114    var thisElement = jQuery(this);
1115    var ajaxURL     = thisElement.data('ajaxurl');
1116    thisElement.bind('click', function (event){
1117      jQuery.ajax({type: "GET", url: ajaxURL, success: function(result){
1118        var elementTarget = thisElement.parent().parent();
1119        elementTarget.fadeTo(0, 0);
1120        elementTarget.html(result);
1121        history.pushState({page: thisElement.attr('href')}, '', thisElement.attr('href'));
1122        wPrepareHTML(elementTarget.get(0));
1123        elementTarget.fadeTo(600, 1);
1124        wScrollSmoothToElement(elementTarget.get(0), {'targetPos' : 'top'});
1125
1126        for(var addClassSelector in wCssClassesToAddGlobal){
1127          jQuery(addClassSelector).each(function(index){
1128            var classesToAdd = wCssClassesToAddGlobal[addClassSelector];
1129            for(var i = 0, arrayLength = classesToAdd.length; i < arrayLength; i++){
1130              var classData = classesToAdd[i].split('=');
1131              if(classData.length == 2){
1132                var selector = jQuery.trim(classData[0]);
1133                if(selector == '.'){
1134                  jQuery(this).addClass(jQuery.trim(classData[1]));
1135                }
1136                else if(selector == 'parent'){
1137                  jQuery(this).parent().addClass(jQuery.trim(classData[1]));
1138                }
1139                else{
1140                  jQuery(this).find(selector).addClass(jQuery.trim(classData[1]));
1141                }
1142              }
1143              else{
1144                jQuery(this).addClass(jQuery.trim(classData[0]));
1145              }
1146            }
1147          });
1148        }
1149
1150        if(typeof(wOnAfterReloadElementByAjaxUrl) == 'function'){     
1151          wOnAfterReloadElementByAjaxUrl(elementTarget);
1152        }            
1153
1154        window.setTimeout(function(){
1155          jQuery(window).trigger('resize');
1156        }, 100);
1157      }});
1158      return false;
1159    });
1160  });
1161};
1162
1163wScrollSmoothToElement = function(elementTarget, options){
1164
1165  var id, offsetTopFixed, scrollTop;
1166
1167  options = options || {};
1168
1169  elementTarget = jQuery(elementTarget);
1170
1171  var currentTimestamp = new Date().getTime();
1172  if(elementTarget.length > 0 && !elementTarget.attr('data-lct') || elementTarget.attr('data-lct') < currentTimestamp - 320){
1173    elementTarget.attr('data-lct', currentTimestamp);
1174
1175    try{
1176      jQuery('body, html').stop(true, true);
1177      scrollDuration = parseInt(elementTarget.attr('data-scrollsmoothtotargetduration') ? elementTarget.attr('data-scrollsmoothtotargetduration') : 400);
1178
1179      offsetTopFixed    = jQuery('#blockTop').height() + jQuery('#blockHeader').height();
1180
1181      var visibleMin    = document.body.scrollTop + offsetTopFixed;
1182      var visibleMax    = visibleMin + jQuery(window).height();
1183      var posTopElement = elementTarget.offset().top;
1184
1185      //console.log(visibleMin + ' < ' + posTopElement + ' < ' + visibleMax);
1186
1187      if(posTopElement > visibleMin && posTopElement < visibleMax){
1188        return true;
1189      }
1190
1191      //console.log(posTopVisible);
1192      //console.log(winHeight);
1193
1194      wUiTmp['scrollingAuto'] = true;
1195
1196      jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, {duration: scrollDuration, complete: function(){
1197        offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height() + jQuery('#blockHeader').height();
1198        if(offsetTopFixed > 0){
1199          jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, {duration: scrollDuration, complete: function(){
1200            wUiTmp['scrollingAuto'] = false;
1201            jQuery(window).trigger('resize');
1202          }});
1203        }
1204        else{
1205          wUiTmp['scrollingAuto'] = false;
1206          jQuery(window).trigger('resize');
1207        }
1208      }});
1209      return false;
1210    }
1211    catch(e){console.log(e)}
1212  }
1213};
1214
1215jQuery.extend(jQuery.easing, {
1216  wEaseOutScroll: function(x, t, b, c, d){
1217    return (t == d) ? b + c : b + c * (-Math.pow(1.5, -20 * t / d) + 1);
1218  }
1219});
1220
1221////////////////////////////////////////////////////////////////
1222//
1223// @method void addAnalytics()
1224//
1225// @desc Überwacht Links mit Google Analytics
1226//
1227// @return void
1228//
1229////////////////////////////////////////////////////////////////
1230
1231jQuery.fn.wAddAnalytics = function(viewmode){
1232
1233  jQuery.each($(this), function(){
1234    jQuery(this).click(function(){ga('send', {'hitType': 'pageview', 'page': jQuery(this).attr('href'), 'title': jQuery(this).attr('title')})});
1235  });
1236};
1237
1238////////////////////////////////////////////////////////////////
1239//
1240// @method void setViewmode(viewmode)
1241//
1242// @desc Setzt den Ansichtsmodus eines Links
1243//
1244// @param viewmode Ansichtmodus
1245//
1246// @return void
1247//
1248////////////////////////////////////////////////////////////////
1249
1250jQuery.fn.wSetViewmode = function(viewmode){
1251
1252  jQuery.each(jQuery(this), function(){
1253
1254    var hrefNew = this.getAttribute('href') || '';
1255    var anchor  = '';
1256    if(/#[^#]+$/.test(hrefNew)){
1257      anchor  = hrefNew.replace(/.*#/, '');
1258      hrefNew = hrefNew.replace(/#.*/, '');
1259    }
1260
1261    hrefNew = hrefNew.indexOf('?') != -1 ? hrefNew + '&viewmode=' + viewmode: hrefNew + '?viewmode=' + viewmode;
1262
1263    if(anchor != ''){
1264      hrefNew += '#' + anchor;
1265    }
1266    if(this.className.indexOf('boxOnly') == -1 && this.innerHTML.indexOf('<img ') != -1){
1267      this.style.background  = 'none';
1268      this.style.paddingLeft = 'none';
1269    }
1270    this.setAttribute('href', hrefNew);
1271  });
1272};
1273
1274////////////////////////////////////////////////////////////////
1275//
1276// @method void wOpenPrintPreview(url)
1277//
1278// @desc Öffnet die aktuelle Seite in der Druckvorschau
1279//
1280// @return void
1281//
1282////////////////////////////////////////////////////////////////
1283
1284wOpenPrintPreview = function(width, height, name){
1285
1286  var name = name || 'printpreview';
1287
1288  var url = location.href.indexOf('?') == -1 ? location.href.replace(/#.*/, '') + '?viewmode=print' : location.href.replace(/#.*/, '') + '&viewmode=print';
1289
1290  options = ',location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no';
1291
1292  wOpenPopupURL(url, width, height, name, options);
1293};
1294
1295////////////////////////////////////////////////////////////////
1296//
1297// @method void wOpenURL(url)
1298//
1299// @desc Öffnet eine Seite
1300//
1301// @return void
1302//
1303////////////////////////////////////////////////////////////////
1304
1305wOpenURL = function(url, target, event){
1306
1307  if(location.pathname.indexOf('/weblication/grid5/') != 0){
1308    if(target == '_blank'){
1309      window.open(url);
1310    }
1311    else if(target == '_top'){
1312      top.location.href = url;
1313    }
1314    else if(target == 'box'){
1315      var widthFancybox = '80%';
1316      var heightFancybox = '80%';
1317
1318      if(jQuery(window).width() <= 480){
1319        widthFancybox = '100%';
1320      }
1321
1322      if(typeof(lightboxType) != 'undefined' && lightboxType == 'wLightbox' && !/MSIE\s*(7|8)/.test(navigator.appVersion)){
1323        wLightbox({"type": "iframe", "href" : url, "class": "default", "width": widthFancybox, "height": heightFancybox});
1324      }
1325      else if(jQuery.fancybox && jQuery.fancybox.version && parseInt(String(j
1325Query.fancybox.version).replace(/(\d+\.\d+)\.\d+/, '$1')) >= 2){
1326        if(/box\w*\-(\d+)\-(\d+)/.test(target)){
1327          widthFancybox  = RegExp.$1 + 'px';
1328          heightFancybox = RegExp.$2 + 'px';
1329          jQuery.fancybox({"type": "iframe", "href" : url, "width": widthFancybox, "maxHeight": heightFancybox, "titlePosition": "inside", helpers : {title : {type : 'inside'}, overlay : {css : {'background' : 'rgba(0, 0, 0, 0.2)'}}}});
1330        }
1331        else{
1332          jQuery.fancybox({"type": "iframe", "href" : url, "width": widthFancybox, "minHeight": '80%', "titlePosition": "inside", helpers : {title : {type : 'inside'}, overlay : {css : {'background' : 'rgba(0, 0, 0, 0.2)'}}}});
1333        }
1334      }
1335      else{
1336        jQuery.fancybox({"type": "iframe", "href" : url, "width": widthFancybox, "height": '80%', "titlePosition": "inside", "transitionIn" : "none", "transitionOut" : "none", "hideOnContentClick": true, "zoomOpacity": true, "zoomSpeedChange": 200, "zoomSpeedIn": 400, "zoomSpeedOut": 400, "overlayShow": false, "overlayOpacity": 1});
1337      }
1338    }
1339    else{
1340      if(url.indexOf('#') == 0){
1341        wScrollSmoothToElement(url);
1342      }
1343      else {
1344        location.href = url;
1345      }
1346    }
1347  }
1348};
1349
1350////////////////////////////////////////////////////////////////
1351//
1352// @method void wOpenPopupURL(url, width, height, name, options)
1353//
1354// @desc Öffnet eine Seite in einem Popup
1355//
1356// @return void
1357//
1358////////////////////////////////////////////////////////////////
1359
1360wOpenPopupURL = function(url, width, height, name, options){
1361
1362  var name = name || '';
1363
1364  if(width == '' || width == ' ' || typeof(width) == 'undefined'){
1365    width = 786;
1366  }
1367  if(height == '' || height == ' ' || typeof(height) == 'undefined'){
1368    height = 677;
1369  }
1370
1371  url = url.replace(/&amp;/g, '&');
1372  options = options || ',location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no';
1373
1374  width   = parseInt(width);
1375  height  = parseInt(height);
1376
1377  var posLeft = (screen.width / 2)  - (width  / 2);
1378  var posTop  = (screen.height / 2) - (height / 2);
1379
1380  window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
1381};
1382
1383////////////////////////////////////////////////////////////////
1384//
1385// @method void wDisableAnalytics()
1386//
1387// @desc Deaktiviert Google Analytics per Cookie
1388//
1389// @return void
1390//
1391////////////////////////////////////////////////////////////////
1392
1393wDisableAnalytics = function(){
1394
1395  document.cookie = 'disableGoogleAnalytics=1; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
1396  if(window['gaId']){
1397    window['ga-disable-' + window['gaId']] = true;
1398  }
1399};
1400
1401////////////////////////////////////////////////////////////////
1402//
1403// @method void wSendMailNospam(data)
1404//
1405// @desc Öffnet eine E-Mail zum Versenden
1406//
1407// @return void
1408//
1409////////////////////////////////////////////////////////////////
1410
1411wSendMailNospam = function(data){
1412
1413  location.href = 'mailto:' + data.replace('|', '@');
1414};
1415
1416wAdaptParallax = function(event){
1417
1418  var winScrollTop = jQuery(window).scrollTop();
1419  var winHeight    = jQuery(window).height();
1420
1421  wUiTmp['lastEventType'] = event ? event.type : '';
1422
1423  if(winScrollTop == window['lastScrollTop']){
1424    return;
1425  }
1426  else if(!window['lastScrollTop']){
1427    wUiTmp['scrollDirection'] = winScrollTop > window['lastScrollTop'] ? 'down' : 'up';
1428    wUiTmp['lastScrollTop']   = winScrollTop;
1429  }
1430
1431  wUiTmp['lastScrollTop'] = winScrollTop;
1432
1433  if(typeof(wEditor) == 'undefined'){
1434    jQuery('.wglParallaxBackground').each(function(index){
1435
1436      var currentElement  = jQuery(this);
1437
1438      if(wUiTmp['lastEventType'] != 'resize' && currentElement.data('disableParallax') == '1'){
1439        return false;
1440      }
1441
1442      var offsetTop       = parseInt(currentElement.offset().top);
1443      var offsetTopInit   = 0;
1444      var offsetHeight    = parseInt(currentElement.outerHeight());
1445      var offsetWidth     = parseInt(currentElement.outerWidth());
1446      var posInsideTop    = winScrollTop + winHeight - offsetTop;
1447      var posInsideBottom = offsetTop + offsetHeight - winScrollTop;
1448      var useEdgeOnInit   = currentElement.data('useedgeoninit') == '1' ? true : false;
1449      var moveMax         = offsetHeight + winHeight;
1450
1451      if(posInsideTop > 0 && posInsideBottom > 0){
1452        var posTopPercentage = posInsideTop / moveMax;
1453        var backgroundPositionTop       = 0;
1454        var backgroundPositionLeft      = 0;
1455        var backgroundPositionTopOrigin = 0;
1456
1457        var direction         = (currentElement.data('parallaxbackgrounddirection') ? currentElement.data('parallaxbackgrounddirection').toLowerCase() : 'bottom');
1458        var parallaxElement   = (currentElement.data('parallaxbackgroundelement') ? document.getElementById(currentElement.data('parallaxbackgroundelement')) : null);
1459
1460        var speed     = 1;
1461
1462        try{
1463          speed       = (currentElement.data('parallaxbackgroundspeed') ? currentElement.data('parallaxbackgroundspeed') : 1);
1464        }
1465        catch(e){
1466          speed = 1;
1467        }
1468
1469        if(speed == 'no' || speed == 'image'){
1470          return false;
1471        }
1472        else if(speed == 'screen'){
1473          speed = 1;
1474          currentElement.data('parallaxbackgroundspeed', speed);
1475        }
1476
1477        if(!currentElement.data('backgroundHeight') && direction.indexOf('top') != -1 && direction.indexOf('bottom') != -1){          
1478          image = new Image();
1479          image.src = currentElement.get(0).style.backgroundImage.replace(/url\((['"])?(.*?)\1\)/i, '$2');
1480          image.onload = (function(currentElement){
1481            if(image.height == 0){
1482              return false;
1483            }
1484            if(currentElement.data('disableParallax') != '1'){
1485              if(speed == 'image'){
1486                currentElement.data('backgroundHeight', image.height);
1487                speed = (image.height - offsetHeight) / offsetHeight;
1488                if(speed < 0){
1489                  speed = 'no';
1490                  currentElement.data('parallaxbackgroundspeed', speed);
1491                  return;
1492                }
1493                currentElement.data('parallaxbackgroundspeed', speed);
1494              }
1495              else{
1496                backgroundSize = currentElement.css('background-size');
1497
1498                var heightScaled    = parseInt(offsetWidth / image.width * image.height);
1499                var disableParallax = false;
1500
1501                if(/auto$/i.test(backgroundSize) || backgroundSize == ''){
1502                  heightScaled = image.height;
1503                }
1504
1505                currentElement.data('backgroundHeight', heightScaled);
1506                //console.log(image.height + ' < ' + offsetHeight);
1507                //console.log(backgroundSize + ' :: ' + heightScaled + ' + ' + parseInt(currentElement.css('background-position').split(' ')[1]) + '  <' + offsetHeight);
1508
1509                if(heightScaled + parseInt(currentElement.css('background-position').split(' ')[1]) < offsetHeight){
1510                  currentElement.css({'background-size' : 'cover', 'background-position' : '0 0'});
1511                  currentElement.data('disableParallax', '1');
1512                }
1513                else{
1514                  currentElement.css({'outline' : 'none'});
1515                  currentElement.data('disableParallax', '0');
1516                }
1517              }
1518            }
1519          })(currentElement);
1520        }
1521
1522        speed = parseFloat(speed);
1523
1524        //console.log(direction);
1525
1526        if(currentElement.data('disableParallax') == '1'){
1527          return false;
1528        }
1529
1530        if(direction.indexOf('right') != -1){
1531          backgroundPositionLeft = '-' + String(Math.round(offsetHeight - posTopPercentage * offsetHeight) * speed);
1532        }
1533        else if(direction.indexOf('left') != -1){
1534          backgroundPositionLeft = '-' + String(Math.round(posTopPercentage * offsetHeight) * speed);
1535        }
1536        if(direction.indexOf('top') != -1){
1537          backgroundPositionTop = '-' + String(Math.round(posTopPercentage * offsetHeight) * speed);
1538          backgroundPositionTopOrigin = backgroundPositionTop;
1539          if(useEdgeOnInit == true){
1540            offsetTopInit = currentElement.data('offsettopinit');
1541            if(!wUiTmp['hasInitParallax'] && !offsetTopInit){
1542              offsetTopInit = backgroundPositionTop;
1543              currentElement.data('offsettopinit', offsetTopInit);
1544            }
1545            else if(!offsetTopInit){
1546              offsetTopInit = 0;
1547            }
1548            backgroundPositionTop -= offsetTopInit;
1549            if(backgroundPositionTop > 0 ){
1550              backgroundPositionTop = 0;
1551            }
1552          }
1553          //console.log(offsetHeight + ' - ' + backgroundPositionTop + ' > ' + currentElement.data('backgroundHeight'));
1554          if(currentElement.data('backgroundHeight') && (offsetHeight - backgroundPositionTop) > currentElement.data('backgroundHeight')){
1555            backgroundPositionTop = offsetHeight - currentElement.data('backgroundHeight')
1556          }
1557        }
1558        else if(direction.indexOf('bottom') != -1 || direction == ''){
1559          backgroundPositionTop = '-' + String(Math.round(offsetHeight - posTopPercentage * offsetHeight) * speed);
1560          backgroundPositionTopOrigin = backgroundPositionTop;
1561          if(useEdgeOnInit == true){
1562            offsetTopInit = currentElement.data('offsettopinit');
1563            if(!wUiTmp['hasInitParallax'] && !offsetTopInit){
1564              offsetTopInit = backgroundPositionTop - offsetHeight;
1565              currentElement.data('offsettopinit', offsetTopInit);
1566            }
1567            else if(!offsetTopInit){
1568              offsetTopInit = 0;
1569            }
1570            backgroundPositionTop -= offsetTopInit;
1571            if(backgroundPositionTop < offsetHeight && backgroundPositionTop > 0){
1572              backgroundPositionTop = offsetHeight;
1573            }
1574          }
1575          if(currentElement.data('backgroundHeight') && (offsetHeight - backgroundPositionTop) > currentElement.data('backgroundHeight')){
1576            backgroundPositionTop = offsetHeight - currentElement.data('backgroundHeight')
1577          }
1578        }
1579
1580        backgroundPositionLeft = String(backgroundPositionLeft) + 'px';
1581        backgroundPositionTop  = String(backgroundPositionTop) + 'px';
1582
1583        wUiTmp['lastEventTypeBefore'] = wUiTmp['lastEventType'];
1584        if(parallaxElement){
1585          parallaxElement.style.marginTop = backgroundPositionTop;
1586        }
1587        else{
1588          if(wUiTmp['isIOS']){
1589            if(wUiTmp['lastEventType'] == 'touchmove'){
1590              currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'transition' : '', 'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop});
1591            }
1592            else if(wUiTmp['lastEventType'] == 'touchend'){
1593            }
1594            else if(wUiTmp['lastEventType'] == 'scroll'){
1595              currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'transition' : 'background-position ease 0.6s', 'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop});
1596            }
1597          }
1598          else{
1599            currentElement.css({'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop});
1600          }
1601        }
1602      }
1603    });
1604
1605    jQuery('.wglParallaxContent').each(function(index){
1606      var currentElement    = jQuery(this).children().first();
1607      var offsetTop         = parseInt(currentElement.offset().top);
1608      var offsetHeight      = parseInt(currentElement.height());
1609      var posInsideTop    = winScrollTop + winHeight - offsetTop;
1610      var posInsideBottom = offsetTop + offsetHeight - winScrollTop;
1611      if(posInsideTop > 0 && posInsideBottom > 0){
1612        var posTopPercentage = posInsideTop / (offsetHeight + winHeight);
1613        var positionTop  = 0;
1614        var positionLeft = 0;
1615        var direction = (currentElement.parent().data('parallaxcontentdirection') ? currentElement.parent().data('parallaxcontentdirection').toLowerCase() : 'left');
1616
1617        if(direction.indexOf('right') != -1){
1618          var offsetWidth = parseInt(currentElement.width());
1619          var left = - (1 - posTopPercentage * 2) * offsetWidth;
1620          if(left > 0) left = 0;
1621          positionLeft = String(parseInt(left)) + 'px';
1622        }
1623        else if(direction.indexOf('left') != -1){
1624          var parentOffsetWidth = parseInt(currentElement.parent().width());
1625          var left = (1 - posTopPercentage * 2) * parentOffsetWidth;
1626          if(left < 0) left = 0;
1627          positionLeft = String(parseInt(left)) + 'px';
1628        }
1629        if(direction.indexOf('top') != -1){
1630          positionTop = String(1 - posTopPercentage * offsetHeight + offsetHeight) + 'px';
1631        }
1632        else if(direction.indexOf('bottom') != -1 || direction == ''){
1633          positionTop = String(posTopPercentage * offsetHeight) + 'px';
1634        }
1635        currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'margin-left' : positionLeft, 'margin-top' : positionTop});
1636      }
1637    });
1638  }
1639  wUiTmp['hasInitParallax'] = true;
1640};
1641
1642wScrollSmoothToTarget = function(element, event){
1643
1644  var id, href = element.getAttribute('href'), offsetTopFixed, targetName, elementTarget, scrollTop;
1645
1646   //stopt einen Klick auf einen externen Link
1647  if(element.getAttribute('target') != null && element.getAttribute('target') != '') return true;
1648  if(element.href.replace(/#[\S\s]*$/, '') != location.href.replace(/#[\S\s]*$/, '')){
1649    return true;
1650  }
1651  else if(/(#.*)/.test(href)){
1652    targetName = RegExp.$1;
1653    targetSelector = targetName.replace(/\./, '\\.');
1654    elementTarget = jQuery(targetSelector);
1655    var currentTimestamp = new Date().getTime();
1656    if(elementTarget.length > 0 && !element.getAttribute('data-lct') || element.getAttribute('data-lct') < currentTimestamp - 320){
1657      element.setAttribute('data-lct', currentTimestamp);
1658     if(!(/_Tab-|#tab_|_Accordion-/.test(href))) {
1659        event.preventDefault();  
1660      }
1661      jQuery(element).parent().parent().find('li').removeClass('selected');
1662      jQuery(element).parent().addClass('selected');
1663
1664      try{
1665        jQuery('body, html').stop(true, true);
1666        scrollDuration = parseInt(element.getAttribute('data-scrollsmoothtotargetduration') ? element.getAttribute('data-scrollsmoothtotargetduration') : 400);
1667
1668        offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height();
1669        jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, {duration: scrollDuration, complete: function(){
1670          offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height();
1671          if(offsetTopFixed > 0){
1672            jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, scrollDuration);
1673          }
1674          if(history.pushState){
1675            history.pushState(null, null, targetName);
1676          }
1677        }});
1678        return false;
1679      }
1680      catch(e){}
1681    }
1682  }
1683};
1684
1685wOptimizePictureSizes = function(){
1686
1687  jQuery("img[data-src2x]:not(.wglLazyLoadInit), img.wglLazyLoad:not(.wglLazyLoadInit)").each(function(){
1688    var currentImg   = jQuery(this);
1689    var offsetTop    = parseInt(currentImg.offset().top);
1690    var srcMin       = currentImg.data('srcmin') ? currentImg.data('srcmin') : '';
1691    var widthCurrent = parseInt(currentImg.width());
1692    var attrWidthCur = parseInt(typeof(currentImg.attr('width')) != 'undefined' ? currentImg.attr('width') : 0);
1693    var widthMin     = parseInt(srcMin.replace(/.*@min/, '').replace(/\..*/, ''));
1694
1695    if(currentImg.attr('data-maxwidthifinvisible') && currentImg.attr('data-maxwidthifinvisible') > widthCurrent){
1696      widthCurrent = currentImg.attr('data-maxwidthifinvisible');
1697    }
1698
1699    //console.log(widthCurrent + ' < ' + widthMin);
1700
1701    if(devicePixelRatio >= hdLimitDpr && typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && attrWidthCur < widthCurrent * 2 && currentImg.attr('data-ishd') != '1'){
1702      currentImg.attr('src', currentImg.data('src2x'));
1703      currentImg.attr('data-ishd', '1');
1704    }
1705    else if(typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && attrWidthCur < widthCurrent && currentImg.attr('data-ishd') != '1'){
1706      currentImg.attr('src', currentImg.data('src2x'));
1707      currentImg.attr('data-ishd', '1');
1708    }
1709    else if(typeof(currentImg.attr('data-srcmin')) != 'undefined' && currentImg.attr('data-srcmin') != '' && widthCurrent < widthMin && widthMin < attrWidthCur && currentImg.attr('data-ishd') != '1' && currentImg.attr('data-isld') != '1'){
1710      if(currentImg.attr('src').indexOf('data:image') == 0 && currentImg.attr('data-ismin') != '1'){
1711        currentImg.attr('src', currentImg.data('srcmin'));
1712        currentImg.attr('data-ismin', '1');
1713      }
1714    }
1715    else if(typeof(currentImg.attr('data-src')) != 'undefined' && currentImg.attr('data-src') != '' && currentImg.attr('data-ishd') != '1' && currentImg.attr('data-isld') != '1'){
1716      currentImg.attr('src', currentImg.data('src'));
1717      currentImg.attr('data-isld', '1');
1718    }
1719  });
1720};
1721
1722wProcessWglAdjustHeightMax = function(){
1723
1724  jQuery('.wglAdjustHeightMax').each(function(index){
1725
1726    var currentElement = jQuery(this);
1727    var offsetLeft     = 0;
1728    var offsetLeftLast = 0;
1729    var maxHeight      = 0;
1730    var adjust         = true;
1731    var positionCol    = 0;
1732    var childsToAdapt  = new Array();
1733    var numberChilds   = 0;
1734    var subElement     = null;
1735    var elementHeight  = 0;
1736
1737    currentElement.children('*:visible').each(function(index){
1738      var className = jQuery(this).attr('class') || '';
1739      if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1){
1740        numberChilds++;
1741      }
1742    });
1743    currentElement.children('*:visible').each(function(index){
1744      subElement    = jQuery(this);
1745      var className = jQuery(this).attr('class') || '';
1746      if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1){
1747        if(jQuery(this).data('wHasSetHeightToAjustHeightMax') == '1'){
1748          jQuery(this).css({'height' : ''});
1749        }
1750        offsetLeft = jQuery(this).get(0).offsetLeft - (jQuery(this).parent().css('position') == 'relative' ? 0 : jQuery(this).get(0).parentNode.offsetLeft);
1751
1752        if(index > 0 && (offsetLeft == 0 || offsetLeft <= offsetLeftLast) && jQuery(this).css('position') != 'absolute'){
1753          if(positionCol == 1){
1754            childsToAdapt = new Array();
1755            maxHeight = 0;
1756          }
1757          positionCol = 0;
1758          if(offsetLeft <= offsetLeftLast){
1759            offsetLeft = 0;
1760          }
1761        }
1762
1763        positionCol++;
1764
1765        elementHeight          = subElement.css('box-sizing') == 'border-box' ? subElement.outerHeight() : subElement.height();
1766
1767        if(index + 1 == numberChilds){
1768          maxHeight = elementHeight > maxHeight ? elementHeight : maxHeight;
1769          childsToAdapt.push(jQuery(this));
1770        }
1771
1772        if(childsToAdapt.length > 1 && (index > 0 && positionCol == 1 || index + 1 == numberChilds)){
1773          for(i = 0; i < childsToAdapt.length; i++){
1774            childToAdapt = childsToAdapt[i];
1775            var className = childToAdapt.attr('class') || '';
1776            if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1){
1777              childToAdapt.css({'height' : maxHeight});
1778              childToAdapt.data('wHasSetHeightToAjustHeightMax', '1');
1779            }
1780          }
1781          childsToAdapt = new Array();
1782          maxHeight = 0;
1783        }
1784
1785        offsetLeftLast = offsetLeft;
1786        maxHeight = elementHeight > maxHeight ? elementHeight : maxHeight;
1787        childsToAdapt.push(jQuery(this));
1788      }
1789    });
1790  });
1791};
1792
1793jQuery.fn.wBannerSlider = function(){
1794
1795  jQuery.each(jQuery(this), function(){
1796
1797    var bannerSliderCurrent   = jQuery(this);
1798    var bannerSliderCurrentId = bannerSliderCurrent.attr('id').replace(/bannerSlider_/, '');
1799
1800    var options = {};
1801
1802    options['initOn']         = options['initon']  || jQuery(this).data('initon');
1803    options['initOpen']       = options['initopen']  || jQuery(this).data('initopen');
1804    options['initDelay']      = options['initDelay'] || jQuery(this).data('initdelay');
1805    if(options['initDelay'] == ''){
1806      options['initDelay'] = 0;
1807    }
1808    else{
1809      options['initDelay'] *= 1000;
1810    }
1811
1812    eval('selectEntry_' + bannerSliderCurrentId + ' = function (position){selectListEntryBannerSlider(bannerSliderCurrentId, position);}');
1813
1814    var bannerSliderInit = function(){
1815
1816      if(options['initOpen'] != ''){
1817        window.bannerSliderObjects[bannerSliderCurrentId] = {};
1818        selectListEntryBannerSlider(bannerSliderCurrentId, parseInt(options['initOpen']), {'animation' : 'none'});
1819      }
1820
1821      window.setTimeout(function(){
1822        initBannerSlider(bannerSliderCurrentId);
1823      }, options['initDelay']);
1824    };
1825
1826    if(options['initOn'] == 'load'){
1827      jQuery(window).bind('load', bannerSliderInit);
1828    }
1829    else{
1830      bannerSliderInit();
1831    }
1832  });
1833};
1834
1835jQuery.fn.wPictureGallery = function(){
1836
1837  jQuery.each(jQuery(this), function(){
1838
1839    var options = {};
1840    var pictureGalleryCurrent   = jQuery(this);
1841    var pictureGalleryCurrentId = pictureGalleryCurrent.attr('id').replace(/pictureGallery_/, '');
1842
1843    eval('selectEntry_' + pictureGalleryCurrentId + ' = function (position){selectListEntryGallery(pictureGalleryCurrentId, position);}');
1844
1845    initGallery(pictureGalleryCurrentId);
1846  });
1847};
1848
1849jQuery.fn.wTabcontainer = function(){
1850
1851  var maxHeightContent = 0;
1852
1853  jQuery.each(jQuery(this), function(){
1854
1855    var tabcontainerCurrent     = jQuery(this);
1856    var tabcontainerID          = tabcontainerCurrent.get(0).id.replace(/tabContainer_/, '');
1857    
1858    var options = {};
1859
1860    options['initOpen']         = options['initOpen']         || jQuery(this).data('initopen');
1861    options['rememberSelected'] = options['rememberSelected'] || jQuery(this).data('rememberselected');
1862
1863    var activeContent = options['initOpen'] || 0;
1864
1865    if(/^\d+$/.test(activeContent)){
1866      activeContent = parseInt(activeContent) - 1;
1867    }
1868
1869    if(options['rememberSelected'] == '1' || typeof(wEditor) != 'undefined'){
1870      var checkCookieRegExp = new RegExp('registerTab_' + tabcontainerID + '=(\\d+)');
1871      if(checkCookieRegExp.test(document.cookie)){
1872        activeContent = RegExp.$1 - 1;
1873      }
1874    }
1875
1876    var jQueryHashId = location.hash.replace(/\:/g, '\\:').replace(/\./g, '\\.').replace('open_', 'anchor_');
1877    
1878    if(jQueryHashId != '' && jQuery(this).find(jQueryHashId).length > 0){
1879      if(/_(\d+)$/.test(jQuery(jQueryHashId).attr('id'))){
1880        activeContent = RegExp.$1 - 1;
1881      }
1882      else if(/_Tab-(\d+)-/.test(jQuery(jQueryHashId).attr('id'))){
1883        activeContent = RegExp.$1 - 1;
1884      }
1885      else{
1886        var containerIndex = jQuery(jQueryHashId).parents('.container, .containerInvisible').index();
1887        if(containerIndex >= 0){
1888          activeContent = containerIndex;
1889        }
1890      }
1891    }
1892
1893    if(!activeContent || activeContent == '' || activeContent < 0){
1894      activeContent = 0;
1895    }
1896    
1897    tabcontainerCurrent.find('> .tabs > .tabSelected').removeClass('tabSelected').addClass('tab');
1898    tabcontainerCurrent.find('> .tabs > .tab:nth-child(' + (activeContent + 1) + ')').removeClass('tab').addClass('tabSelected');
1899    tabcontainerCurrent.find('> .containers > .container,> div > div > .containers > .container').addClass('containerInvisible');
1900    tabcontainerCurrent.find('> .containers > .container:nth-child(' + (activeContent + 1) + '),> div > div > .containers > .container:nth-child(' + (activeContent + 1) + ')').removeClass('containerInvisible').addClass('containerSelected').addClass('containerSelectedAfterInit');
1901
1902    jQuery(this).find('> .tabsSmall, > .tabsSelectbox, > .tabs, > div > div > .tabs').children('.tab, .tabSelected').bind('click', function(event){
1903      event.preventDefault();
1904      var headerSelected  = jQuery(this);
1905
1906      var tabcontainerSelected = headerSelected.get(0).id.replace(/.*_/, '');
1907      
1908      if(history.pushState && headerSelected.attr('id')){
1909        history.pushState({page: '#' + headerSelected.attr('id')}, '', '#' + headerSelected.attr('id'));
1910      }
1911
1912      jQuery(this).parent().parent().find('> .containers, > div > div > .containers').children('.container, .containerSelected, .containerInvisible').each(function(){
1913        currentContainer = this;
1914        (function(currentContainer){
1915          if(currentContainer.id == 'container_' + tabcontainerID + '_' + tabcontainerSelected){
1916            currentContainer.className = 'container containerSelected';
1917            window.setTimeout(function(){jQuery(currentContainer).addClass('containerSelectedAfterInit')}, 32);
1918          }
1919          else{
1920            currentContainer.className = 'container containerInvisible';
1921            window.setTimeout(function(){jQuery(currentContainer).addClass('containerInvisibleAfterInit')}, 32);
1922          }
1923        })(currentContainer);
1924      });
1925
1926      jQuery(this).parent().parent().find('> .tabsSmall, > .tabsSelectbox, > .tabs, > div > div > .tabs').children('.tab, .tabSelected').each(function(){
1927        if(this.id == 'tab_' + tabcontainerID + '_' + tabcontainerSelected){
1928          this.className = 'tabSelected';
1929        }
1930        else{
1931          this.className = 'tab';
1932        }
1933      });
1934
1935      if(typeof(wEditor) != 'undefined' || options['rememberSelected'] != '0'){
1936        document.cookie = 'registerTab_' + tabcontainerID + '=' + tabcontainerSelected;
1937      }
1938      jQuery(window).trigger('resize');
1939    });
1940
1941    if(typeof(wEditor) == 'undefined'){
1942      jQuery(this).find('.container, .containerSelected, .containerInvisible').each(function(index){
1943        if(jQuery(this).html() == ''){
1944          tabcontainerCurrent.find('> .tabs > div:nth-child(' + (index + 1) + ')').remove();
1945        }
1946      });
1947    }
1948  });
1949};
1950
1951jQuery.fn.wAccordion = function(){
1952
1953  var maxHeightContent = 0;
1954
1955  jQuery.each(jQuery(this), function(){
1956
1957    var options = {};
1958
1959    options['initOpen']         = options['initOpen']         || jQuery(this).data('initopen');
1960    options['multiple']         = options['multiple']         || jQuery(this).data('multiple');
1961    options['expandAll']        = options['expandAll']        || jQuery(this).data('expandall');
1962    options['collapsible']      = options['collapsible']      || jQuery(this).data('collapsible');
1963    options['rememberSelected'] = options['rememberSelected'] || jQuery(this).data('rememberselected');
1964
1965    var accordionID   = jQuery(this).get(0).id.replace(/accordion_/, '');
1966
1967    var activeContent = options['initOpen'];
1968
1969    if(/^\d+$/.test(activeContent)){
1970      activeContent = parseInt(activeContent) - 1;
1971    }
1972
1973    if(options['rememberSelected'] == '1'){
1974      var checkCookieRegExp = new RegExp('accordionTab_' + accordionID + '=Accordion-(\\d+)');
1975      if(checkCookieRegExp.test(document.cookie)){
1976        activeContent = RegExp.$1 - 1;
1977      }
1978    }
1979
1980    var jQueryHashTmp = location.hash.replace('open_', 'anchor_'); 
1981    var jQueryHashId = jQueryHashTmp.replace(/\./g, '\\.').replace(/\:/g, '\\:');
1982
1983    options['active'] = options['active'] || activeContent;
1984
1985    jQuery(this).children('.accordionContent').each(function(index){
1986      var heightContent = jQuery(this).height();
1987      if(heightContent > maxHeightContent){
1988        maxHeightContent = heightContent;
1989      }
1990    });
1991
1992    var lastOpenedEntry = null;
1993
1994    jQuery(this).children('h1, h2, h3, h4').each(function(index){
1995
1996      var openCurrent = false;
1997
1998      if(jQueryHashId != '' &&  '#' + jQuery(this).attr('id') == jQueryHashTmp || jQuery(this).next('.accordionContent').find(jQueryHashId).length > 0){
1999        if(/_Accordion-/.test(jQuery(jQueryHashId).attr('id'))){
2000          options['active'] = index;
2001          if(!options['multiple'] && lastOpenedEntry){
2002            lastOpenedEntry.addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible');
2003            lastOpenedEntry.next('.accordionContent').addClass('accordionContentHidden').removeClass('accordionContentVisible').hide();
2004            lastOpenedEntry = null;
2005          }
2006          openCurrent = true;
2007        }
2008        else if(jQuery(jQueryHashId).parents('.accordionContent').length > 0){
2009          options['active'] = index;
2010        }
2011      }
2012      else{
2013        jQueryHashIdAlt = jQueryHashId.replace(/_Accordion-\d+/, '_Accordion');
2014
2015        if(jQueryHashIdAlt != '' &&  '#' + jQuery(this).attr('id') == jQueryHashIdAlt || jQuery(this).next('.accordionContent').find(jQueryHashIdAlt).length > 0){
2016          if(/_Accordion-/.test(jQuery(jQueryHashIdAlt).attr('id'))){
2017            options['active'] = index;
2018            if(!options['multiple'] && lastOpenedEntry){
2019              lastOpenedEntry.addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible');
2020              lastOpenedEntry.next('.accordionContent').addClass('accordionContentHidden').removeClass('accordionContentVisible').hide();
2021              lastOpenedEntry = null;
2022            }
2023            openCurrent = true;
2024          }
2025          else if(jQuery(jQueryHashIdAlt).parents('.accordionContent').length > 0){
2026            options['active'] = index;
2027          }
2028        }
2029      }
2030
2031      if(options['collapsible']){
2032        jQuery(this).addClass('accordionHeaderCollapsible').removeClass('accordionHeaderNoneCollapsible');
2033      }
2034      else{
2035        jQuery(this).addClass('accordionHeaderNoneCollapsible').removeClass('accordionHeaderCollapsible');
2036      }
2037
2038      if(options['expandAll'] || typeof(options['active']) == 'number' && options['active'] == index){
2039        lastOpenedEntry = jQuery(this);
2040        jQuery(this).addClass('accordionHeaderVisible').removeClass('accordionHeaderHidden');
2041        jQuery(this).next('.accordionContent').addClass('accordionContentVisible').removeClass('accordionContentHidden').show();
2042      }
2043      else{
2044        jQuery(this).addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible');
2045        jQuery(this).next('.accordionContent').addClass('accordionContentHidden').removeClass('accordionContentVisible').hide();
2046      }
2047
2048      if(options['heightStyle'] == 'auto'){
2049        jQuery(this).next('.accordionContent').css({'height' : maxHeightContent});
2050      }
2051
2052      jQuery(this).on('click', function(event, forceOpen){
2053        event.preventDefault();
2054        var headerSelected  = jQuery(this);
2055
2056        forceOpen = typeof(forceOpen) != 'undefined' ? forceOpen : false;
2057
2058        if(history.pushState && headerSelected.attr('id')){
2059          history.pushState({page: '#' + headerSelected.attr('id')}, '', '#' + headerSelected.attr('id'));
2060        }
2061
2062        var contentSelected = jQuery(this).next('.accordionContent');
2063        jQuery(this).parent().children('.accordionContent').each(function(index){
2064          if(jQuery(this).get(0) == contentSelected.get(0)){
2065            if(jQuery(this).hasClass('accordionContentVisible') && ! forceOpen){
2066              if(options['collapsible']){
2067                jQuery(this).parent().trigger('accordionbeforeactivate', {'newHeader' : contentSelected});
2068                jQuery(this).prev('.accordionHeader').addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible');
2069                jQuery(this).addClass('accordionContentHidden').removeClass('accordionContentVisible').slideUp('normal', function(){
2070                  jQuery(this).parent().trigger('accordionchange', {'newHeader' : headerSelected});
2071                });
2072              }
2073            }
2074            else{
2075              jQuery(this).prev('.accordionHeader').addClass('accordionHeaderVisible').removeClass('accordionHeaderHidden');
2076              if(options['collapsible']){
2077                jQuery(this).prev('.accordionHeader').addClass('accordionHeaderCollapsible').removeClass('accordionHeaderNoneCollapsible');
2078              }
2079              else{
2080                jQuery(this).prev('.accordionHeader').addClass('accordionHeaderNoneCollapsible').removeClass('accordionHeaderCollapsible');
2081              }
2082              jQuery(this).addClass('accordionContentVisible').removeClass('accordionContentHidden').slideDown('normal', function(){
2083                jQuery(this).parent().trigger('accordionchange', {'newHeader' : headerSelected});
2084                jQuery(this).parent().trigger('accordionactivate', {'newHeader' : headerSelected});
2085              });
2086            }
2087          }
2088          else if(options['multiple'] == true){
2089          }
2090          else{
2091            jQuery(this).prev('.accordionHeader').addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible');
2092            jQuery(this).addClass('accordionContentHidden').removeClass('accordionContentVisible').slideUp('normal');
2093          }
2094        });
2095        jQuery(window).trigger('resize');
2096      });
2097    });
2098
2099    jQuery(this).on('accordionactivate', function(event, ui){
2100      try{
2101        var currentHeader          = ui.newHeader;
2102        var offsetTopCurrentHeader = (currentHeader.offset())['top'];
2103        var windowScrollTop        = jQuery(window).scrollTop();
2104        if(offsetTopCurrentHeader < windowScrollTop){
2105          if(jQuery('.wglContainerInsideTopOnScroll').length > 0){
2106            offsetTopCurrentHeader = offsetTopCurrentHeader - jQuery('.wglContainerInsideTopOnScroll').height();
2107          }
2108          jQuery('body, html').animate({scrollTop: offsetTopCurrentHeader});
2109        }
2110        else{
2111          var offsetBottomCurrentContent = (jQuery(currentHeader).next('.accordionContent').offset())['top'] + jQuery(currentHeader).next('.accordionContent').outerHeight();
2112          var windowBottom               = windowScrollTop + jQuery(window).height();
2113          if(offsetBottomCurrentContent > windowBottom){
2114            var scrollDiff =  offsetBottomCurrentContent - windowBottom;
2115            if(scrollDiff > offsetTopCurrentHeader - windowScrollTop){
2116              scrollDiff = offsetTopCurrentHeader - windowScrollTop;
2117            }
2118            if(jQuery('.wglContainerInsideTopOnScroll').length > 0){
2119              scrollDiff = scrollDiff - jQuery('.wglContainerInsideTopOnScroll').height();
2120            }
2121            jQuery('body, html').animate({scrollTop: windowScrollTop + scrollDiff});
2122          }
2123        }
2124      }
2125      catch(e){
2126      }
2127    });
2128
2129    jQuery(this).on('accordionchange', function(event, ui){
2130      var eventTarget = event.target || event.srcElement;
2131      var id          = eventTarget.id.replace(/accordion_/, '');
2132      if(options['rememberSelected']){
2133        if(ui.newHeader[0]){
2134          if(ui.newHeader[0].className.indexOf('accordionHeaderHidden') != -1){
2135            document.cookie = 'accordionTab_' + id + '=';
2136          }
2137          else{
2138            document.cookie = 'accordionTab_' + id + '=' + ui.newHeader[0].id.replace(/.*_/, '');
2139          }
2140        }
2141      }
2142      jQuery(window).trigger('resize');
2143    });
2144  });
2145};
2146
2147jQuery(window).bind('hashchange', function(e){
2148
2149  var jQueryHashId = location.hash.replace(/\./g, '\\.').replace(/\:/g, '\\:').replace('open_', 'anchor_');
2150
2151  if(jQueryHashId != '' && jQuery(jQueryHashId).length > 0){
2152
2153    if(/#anchor/.test(jQueryHashId) && jQuery(jQueryHashId).length != 0 && jQuery(jQueryHashId).parent().attr('id') && jQuery(jQueryHashId).parent().attr('id').indexOf('tab_') == 0){
2154      document.location.hash = jQuery(jQueryHashId).parent().attr('id');
2155      jQueryHashId = '#' + jQuery(jQueryHashId).parent().attr('id');
2156    }
2157
2158    if(/_Tab-|#tab_/.test(jQueryHashId)){
2159      if(/_Tab-|tab_/.test(jQuery(jQueryHashId).attr('id'))){
2160        jQuery(jQueryHashId).trigger('click', [true]);
2161        try{
2162          offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height();
2163          if(offsetTopFixed > 0){
2164            jQuery('body, html').animate({scrollTop: jQuery(jQueryHashId).parent().offset().top - offsetTopFixed}, 0);
2165          }
2166        }
2167        catch(e){}
2168      }
2169      else{
2170        var containerIndex = jQuery(jQueryHashId).parents('.containerInvisible').index();
2171        if(containerIndex >= 0){
2172          jQuery(jQueryHashId).parents('.containerInvisible').parent().parent().find('> .tabs > .tab:nth-child(' + (containerIndex + 1) + ')').trigger('click', [true]);
2173        }
2174      }
2175    }
2176    else if(/_Accordion-/.test(jQuery(jQueryHashId).attr('id'))){
2177      jQuery(jQueryHashId).trigger('click', [true]);
2178
2179      var containerIndex = jQuery(jQueryHashId).parents('.containerInvisible').index();
2180      if(containerIndex >= 0){
2181        jQuery(jQueryHashId).parents('.containerInvisible').parent().parent().find('> .tabs > .tab:nth-child(' + (containerIndex + 1) + ')').trigger('click', [true]);
2182      }
2183    }
2184    else{
2185      var containerIndex = jQuery(jQueryHashId).parents('.containerInvisible').index();
2186      if(containerIndex >= 0){
2187        jQuery(jQueryHashId).parents('.containerInvisible').parent().parent().find('> .tabs > .tab:nth-child(' + (containerIndex + 1) + ')').trigger('click', [true]);
2188      }
2189      jQuery(jQueryHashId).parents('.accordionContent').prev('.accordionHeader').trigger('click', [true]);
2190    }
2191  }
2192});
2193
2194wOpenAllAccordions = function(id){
2195  jQuery('#accordion_' + id + ' .accordionContent').addClass('accordionContentVisible').removeClass('accordionContentHidden').slideDown('normal', function(){
2196    jQuery(window).trigger('resize');
2197  });
2198  jQuery('#accordion_' + id + ' .accordionHeader').addClass('ui-state-active').addClass('ui-accordion-header-active').addClass('accordionHeaderVisible').removeClass('accordionHeaderHidden');
2199  jQuery('#accordion_' + id + ' .accordionHeader span').addClass('ui-icon-triangle-1-s').removeClass('ui-icon-triangle-1-e');
2200  jQuery('#accordionOpener' + id).hide();
2201  jQuery('#accordionCloser' + id).show();
2202  jQuery(window).trigger('resize');
2203};
2204
2205wCloseAllAccordions = function(id){
2206  jQuery('#accordion_' + id + ' .accordionContent').addClass('accordionContentHidden').removeClass('accordionContentVisible').slideUp('normal', function(){
2207    jQuery(window).trigger('resize');
2208  });
2209  jQuery('#accordion_' + id + ' .accordionHeader').removeClass('ui-state-active').removeClass('ui-accordion-header-active').removeClass('accordionHeaderVisible').addClass('accordionHeaderHidden');
2210  jQuery('#accordion_' + id + ' .accordionHeader span').addClass('ui-icon-triangle-1-e').removeClass('ui-icon-triangle-1-s');
2211  jQuery('#accordionCloser' + id).hide();
2212  jQuery('#accordionOpener' + id).show();
2213};
2214
2215wsmn = function(ml){
2216  var mln = '';for(var i=0;i<ml.length/3;i++){mln = ml.substr(i*3+1,1)+mln;}
2217  var pms = '';
2218  if(/(\?.*)/.test(mln)){
2219    pms = RegExp.$1;
2220    mln = mln.replace(/(\?.*)/, '');
2221  }
2222  mln = 'm'+'a'+'ilt'+'o'+':'+mln.replace(/a/g, '@').replace(/e/g, '.').replace(/\*/g, 'a').replace(/;/g, 'e').replace(/:/g, 'o').replace(/,/g, 'u').replace(/\!/g, 'i');
2223  mln += pms;
2224  location.href = mln;
2225};
2226
2227var wMagnifierElement      = null;
2228var wMagnifierImageElement = null;
2229
2230jQuery.fn.wMagnifier = function(options){
2231
2232  jQuery.each(jQuery(this), function(){
2233    if(jQuery(this).attr('data-src2x')){
2234      jQuery(this).bind('mouseover', function(event){
2235        jQuery('.wMagnifier').remove();
2236        jQuery('.wMagnifierMovingArea').remove();
2237
2238        var objectCurrent     = jQuery(this);
2239        objectCurrent.parent().css({'position' : 'relative', 'display' : jQuery(this).css('display') == 'inline-block' ? 'inline-block' : 'block'});
2240        objectCurrent.parent().append('<div id="wMagnifierMovingArea" class="wMagnifierMovingArea" style="z-index:1000;cursor:none;position:absolute;top:0;left:0;width:100%;height:100%"></div>');
2241        objectCurrent.parent().append('<div id="wMagnifier" class="wMagnifier"></div>');
2242        wMagnifierElement = jQuery('#wMagnifier');
2243        wMagnifierMovingAreaElement = jQuery('#wMagnifierMovingArea');
2244        wMagnifierImageElement = objectCurrent;
2245
2246        var offset = objectCurrent.offset();
2247        objectCurrent.data('offsetLeft', parseInt(offset.left));
2248        objectCurrent.data('offsetTop', parseInt(offset.top));
2249        objectCurrent.data('zoomerWidth', wMagnifierElement.width());
2250        objectCurrent.data('zoomerHeight', wMagnifierElement.height());
2251        objectCurrent.data('imageWidth',  objectCurrent.width());
2252        objectCurrent.data('imageHeight', objectCurrent.height());
2253        objectCurrent.data('borderLeftWidth', parseInt(wMagnifierElement.css('border-left-width')));
2254        objectCurrent.data('borderTopWidth', parseInt(wMagnifierElement.css('border-top-width')));
2255
2256        var scale = objectCurrent.width() / (typeof(objectCurrent.attr('width')) != 'undefined' ? objectCurrent.attr('width') : objectCurrent.attr('data-widthorig'));
2257        var ratio = 2 / scale;
2258
2259        var posX = parseInt(typeof(event.pageX !== 'undefined') ? event.pageX : (event.clientX + document.documentElement.scrollLeft)) - wMagnifierImageElement.data('offsetLeft');
2260        var posY = parseInt(typeof(event.pageY !== 'undefined') ? event.pageY : (event.clientY + document.documentElement.scrollTop)) - wMagnifierImageElement.data('offsetTop');
2261        wMagnifierElement.css({'left' : posX - wMagnifierImageElement.data('borderLeftWidth') - wMagnifierImageElement.data('zoomerWidth') / 2, 'top' : posY - wMagnifierImageElement.data('borderTopWidth') - wMagnifierImageElement.data('zoomerHeight') / 2, 'background-position' : String(-posX * ratio + wMagnifierImageElement.data('zoomerWidth') / 2) + 'px ' +  String(-posY * ratio + wMagnifierImageElement.data('zoomerHeight') / 2) + 'px'});
2262        wMagnifierElement.css({'background-image' : 'url(' + wMagnifierImageElement.attr('data-src2x') + ')', 'background-repeat' : 'no-repeat'});
2263
2264        wMagnifierMovingAreaElement.bind('mousemove', function(event){
2265          var posX = parseInt(typeof(event.pageX !== 'undefined') ? event.pageX : (event.clientX + document.documentElement.scrollLeft)) - wMagnifierImageElement.data('offsetLeft');
2266          var posY = parseInt(typeof(event.pageY !== 'undefined') ? event.pageY : (event.clientY + document.documentElement.scrollTop)) - wMagnifierImageElement.data('offsetTop');
2267          wMagnifierElement.css({'left' : posX - wMagnifierImageElement.data('borderLeftWidth') - wMagnifierImageElement.data('zoomerWidth') / 2, 'top' : posY - wMagnifierImageElement.data('borderTopWidth') - wMagnifierImageElement.data('zoomerHeight') / 2, 'background-position' : String(-posX * ratio + wMagnifierImageElement.data('zoomerWidth') / 2) + 'px ' +  String(-posY * ratio + wMagnifierImageElement.data('zoomerHeight') / 2) + 'px'});
2268        });
2269        wMagnifierMovingAreaElement.bind('mouseout click', function(event){
2270          jQuery('.wMagnifier').remove();
2271          jQuery('.wMagnifierMovingArea').remove();
2272        });
2273      });
2274     }
2275  });
2276};
2277
2278jQuery.fn.wLightbox = function(options){
2279  jQuery.each(jQuery(this), function(){
2280    jQuery(this).click(function(){
2281      var objectCurrent     = jQuery(this);
2282      return wLightbox(objectCurrent, options);
2283    });
2284  });
2285};
2286
2287wLightbox = function(objectCurrent, options){
2288  //console.log(options);
2289
2290  var elementCurrent, src, rel;
2291
2292  if(typeof(objectCurrent.jquery) == 'undefined'){
2293    options = objectCurrent;
2294    src = options['href'];
2295    rel = '';
2296    objectCurrent  = null;
2297  }
2298  else{
2299    elementCurrent    = objectCurrent.get(0);    
2300    src = objectCurrent.attr('href');
2301    if(!src){
2302      src = objectCurrent.find('img').attr('src');
2303    }
2304    rel = objectCurrent.attr('rel');
2305  }
2306
2307  var lightboxClassName = 'wLightbox-' + (options['class'] ? options['class'] : 'default');
2308
2309  var contentWidth       = 0;
2310  var contentHeight      = 0;
2311
2312  var elementsRel = jQuery("*[rel = '" + rel + "']");
2313  var numberRel   = elementsRel.length;
2314  var positionRel = 1;
2315  for(i = 0; i < numberRel; i++){
2316    if(elementCurrent && elementsRel[i] == elementCurrent){
2317      positionRel = i + 1;
2318      break;
2319    }
2320  }
2321
2322  var classPrev = 'wLightboxPrev' + (numberRel > 1 && positionRel > 1 ? ' wLightboxPrevAvailable' : '');
2323  var classNext = 'wLightboxNext' + (numberRel > 1 && positionRel < numberRel ? ' wLightboxNextAvailable' : '');
2324
2325  if(options['type'] == 'inline' || options['type'] == 'ajax'){
2326
2327    options['content'] = options['content'] || '';
2328
2329    if(options['type'] == 'ajax'){
2330      if(!options['width']){
2331        options['width'] = 'content';
2332      }
2333      if(!options['height']){
2334        options['height'] = 'content';
2335      }
2336    }
2337
2338    var boxWasOpened = true;
2339
2340    if(jQuery('.wLightbox').length == 0){
2341      jQuery('<div id="wLightbox" class="wLightbox wLightbox-' + options['type'] + ' ' + lightboxClassName + '" data-src="' + src + '">
2341<div class="wLightboxBackground"></div><div class="wLightboxOuter"><div class="wLightboxInner" touchstart="event.preventDefault();" mousedown="event.preventDefault();"><div class="wLightboxCloser"></div>' + options['content'] + '<div class="wLightboxTitle"></div></div></div></div>').appendTo('body');
2342      //jQuery('.wLightboxCloser, .wLightboxBackground').bind('mousedown touchstart', function(){wLightboxClose()});
2343
2344      jQuery(document).bind('keydown', function(e){
2345        if(e.keyCode == 27){
2346          wLightboxClose();
2347        }
2348        else if(e.keyCode == 37){
2349          jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click');
2350        }
2351        else if(e.keyCode == 39){
2352          jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click');
2353        }
2354      });
2355      boxWasOpened = false;
2356    }
2357
2358    var heightTitle = 0;
2359
2360    if(elementCurrent && elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != ''){
2361      jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title'));
2362    }
2363    else{
2364      jQuery('.wLightboxTitle').hide();
2365    }
2366
2367    heightTitle = jQuery('.wLightboxTitle').outerHeight();
2368
2369    var maxWidthBox  = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth))    - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2;
2370    var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightTitle;
2371
2372    if(/^(\d+)px$/.test(options['width'])){
2373      maxWidthBox = parseInt(RegExp.$1);
2374    }
2375    else if(/^(\d+)%$/.test(options['width'])){
2376      maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100;
2377    }
2378
2379    if(/^(\d+)px$/.test(options['height'])){
2380      maxHeightBox = parseInt(RegExp.$1);
2381    }
2382    else if(/^(\d+)%$/.test(options['height'])){
2383      maxHeightBox = parseInt(jQuery(window).height()) * RegExp.$1 / 100;
2384    }
2385
2386    if(options && options['width'] && /^\d+(.\d+)?$/.test(options['width'])){
2387      contentWidth = options['width'];
2388    }
2389    else{
2390      contentWidth = maxWidthBox;
2391    }
2392
2393    if(options && options['height'] && /^\d+(.\d+)?$/.test(options['height'])){
2394      contentHeight = options['height'];
2395    }
2396    else{
2397      contentHeight = maxHeightBox;
2398    }
2399
2400    var pageRatio    = maxWidthBox / maxHeightBox;
2401    var contentRatio = contentWidth / contentHeight;
2402
2403    var lightboxWidth  = contentWidth;
2404    var lightboxHeight = contentHeight + heightTitle;
2405
2406    if(contentWidth > maxWidthBox || contentHeight > maxHeightBox){
2407      if(contentRatio > pageRatio){
2408        lightboxWidth  = maxWidthBox;
2409        lightboxHeight = Math.round(maxWidthBox / contentRatio) + heightTitle;
2410      }
2411      else{
2412        lightboxWidth  = Math.round(maxHeightBox * contentRatio);
2413        lightboxHeight = maxHeightBox + heightTitle;
2414      }
2415    }
2416
2417    widthAttrib  = String(lightboxWidth) + 'px';
2418    heightAttrib = String(lightboxHeight) + 'px';
2419
2420    if(options['height'] == 'content'){
2421      jQuery('.wLightboxOuter').css({'max-height' : '100%'});
2422    }
2423    else{
2424      jQuery('.wLightboxOuter').css({'height' : heightAttrib});
2425    }
2426
2427    if(options['width'] == 'content'){
2428      jQuery('.wLightboxInner').css({'max-width' : '100%'});
2429    }
2430    else{
2431      jQuery('.wLightboxInner').css({'width' : widthAttrib});
2432    }
2433
2434    jQuery('.wLightboxPrev').data('entry', positionRel - 2);
2435    jQuery('.wLightboxNext').data('entry', positionRel);
2436
2437    if(boxWasOpened){
2438      jQuery('.wLightboxPrev').attr('class', classPrev);
2439      jQuery('.wLightboxNext').attr('class', classNext);
2440      jQuery('.wLightboxImage').attr('src', src);
2441      jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2442    }
2443    else{
2444      jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2445      jQuery('.wLightboxOuter, .wLightboxBackground').bind('click', function(){
2446        wLightboxClose()
2447      });
2448      jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(){
2449        jQuery('.wLightbox').removeClass('wLightboxStatusLoaded');
2450        jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click');
2451        event.stopPropagation();
2452      });
2453    }
2454    if(options['type'] == 'ajax'){
2455      jQuery.ajax({type: "GET", url: src, success: function(result){
2456        jQuery('.wLightboxCloser').after('<div class="wLightboxContent">' + result + '</div>');
2457        if(options['height'] == 'content'){
2458          jQuery('.wLightboxContent').css({'max-height' : String(lightboxHeight) + 'px'});
2459        }
2460      }});
2461    }
2462    if(typeof(wOnAfterInitLightbox) == 'function'){
2463      wOnAfterInitLightbox();
2464    }
2465  }
2466  else if(/\.(jpg|jpeg|gif|png)$/i.test(src) || options['type'] == 'image' || objectCurrent && objectCurrent.attr('data-lightboxtype') == 'image'){
2467    var image = new Image();
2468    jQuery('.wLightbox').removeClass('wLightboxStatusLoaded').addClass('wLightboxStatusLoading');
2469    image.onload = function(){
2470
2471      var imageRatio     = image.width / image.height;
2472      var lightboxWidth  = image.width;
2473      var lightboxHeight = image.height;
2474
2475      var boxWasOpened   = true;
2476      var titleInnerHTML = '';
2477
2478      if(jQuery('.wLightbox').length == 0){
2479        jQuery('<div id="wLightbox" class="wLightbox wLightbox-image ' + lightboxClassName + '" data-src="' + src + '"><div class="wLightboxBackground"></div><div class="wLightboxOuter"><div class="wLightboxInner"><div class="wLightboxCloser"></div><div class="' + classPrev + '"></div><div class="' + classNext + '"></div><div class="wLightboxImageOuter"><img class="wLightboxImage" src="' + src + '"/></div><div class="wLightboxFooter"><div class="wLightboxTitle">' + titleInnerHTML + '</div><div class="wLightboxDescription">' + titleInnerHTML + '</div></div></div></div></div>').appendTo('body');
2480
2481        jQuery(document).bind('keydown', function(e){
2482          if(e.keyCode == 27){
2483            wLightboxClose();
2484          }
2485          else if(e.keyCode == 37){
2486            jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click');
2487          }
2488          else if(e.keyCode == 39){
2489            jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click');
2490          }
2491        });
2492
2493        boxWasOpened = false;
2494      }
2495
2496      var maxWidthBox  = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth)) - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2;
2497
2498      if(elementCurrent && elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != ''){
2499        jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title'));
2500      }
2501      else{
2502        jQuery('.wLightboxTitle').hide();
2503      }
2504
2505      if(elementCurrent && elementCurrent.getAttribute('data-description') != ''){
2506        jQuery('.wLightboxDescription').show();
2507        var diffWidthDescription = parseInt(jQuery('.wLightboxInner').width() - jQuery('.wLightboxDescription').width());
2508        jQuery('.wLightboxDescription').css({'width' : maxWidthBox - diffWidthDescription, 'visibility' : 'hidden'}).show().html(elementCurrent.getAttribute('data-description'));
2509      }
2510      else{
2511        jQuery('.wLightboxDescription').hide();
2512      }
2513
2514      if(objectCurrent && objectCurrent.attr('data-lightboxdownloadable') == '1'){
2515        jQuery('.wLightboxDownload').remove();
2516        var srcDownload = src;
2517        if(objectCurrent.attr('data-srcdownload')){
2518          srcDownload = objectCurrent.attr('data-srcdownload');
2519        }
2520        jQuery('.wLightboxFooter').addClass('wLightboxFooterHasDownload').append('<div class="wLightboxDownload" data-src="' + srcDownload + '" title="Download"></div>');
2521        jQuery('.wLightboxDownload').bind('click', function (event){
2522          window.open(jQuery(this).data('src'));
2523        });
2524      }
2525      else{
2526        jQuery('.wLightboxFooter').removeClass('wLightboxFooterHasDownload');
2527      }
2528
2529      heightFooter = jQuery('.wLightboxFooter').outerHeight();
2530      jQuery('.wLightboxDescription').css({'width' : '', 'visibility' : ''})
2531
2532      var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(j
2532Query('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightFooter;
2533
2534      if(/^(\d+)px$/.test(options['width'])){
2535        maxWidthBox = parseInt(RegExp.$1);
2536      }
2537      else if(/^(\d+)%$/.test(options['width'])){
2538        maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100;
2539      }
2540
2541      var pageRatio    = maxWidthBox / maxHeightBox;
2542
2543      if(image.width > maxWidthBox || image.height > maxHeightBox){
2544        if(options['scrollIfToHeight']){
2545          if(imageRatio > pageRatio){
2546            lightboxWidth  = maxWidthBox;
2547            lightboxHeight = Math.round(maxWidthBox / imageRatio) + heightFooter;
2548          }
2549          else{
2550            lightboxWidth  = Math.round(image.width > maxWidthBox ? maxWidthBox : image.width);
2551            lightboxHeight = maxHeightBox;
2552            jQuery('.wLightboxImageOuter').css({'max-height' : String(lightboxHeight - heightFooter) + 'px', 'overflow' : 'auto'});
2553            jQuery('.wLightboxImage').css({'max-height' : ''});
2554          }
2555        }
2556        else{
2557          if(imageRatio > pageRatio){
2558            lightboxWidth  = maxWidthBox;
2559            lightboxHeight = Math.round(maxWidthBox / imageRatio) + heightFooter;
2560          }
2561          else{
2562            lightboxWidth  = Math.round(maxHeightBox * imageRatio);
2563            lightboxHeight = maxHeightBox + heightFooter;
2564          }
2565        }
2566      }
2567      else{
2568        lightboxHeight = image.height + heightFooter;
2569      }
2570
2571      widthAttrib  = String(Math.round(lightboxWidth))  + 'px';
2572      heightAttrib = String(lightboxHeight) + 'px';
2573
2574      jQuery('.wLightboxOuter').css({'height' : heightAttrib});
2575      jQuery('.wLightboxInner').css({'width' : widthAttrib});
2576
2577      jQuery('.wLightboxPrev').data('entry', positionRel - 2);
2578      jQuery('.wLightboxNext').data('entry', positionRel);
2579
2580      jQuery('.wLightboxOuter').on('transitionend', function(event){
2581        if(jQuery('.wLightboxOuter').data('transisionended') != '1'){
2582          jQuery('.wLightboxOuter').data('transisionended', '1');
2583
2584
2585          heightFooter = jQuery('.wLightboxFooter').outerHeight();
2586
2587          var maxWidthBox  = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth))    - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2;
2588          var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightFooter;
2589
2590          if(/^(\d+)px$/.test(options['width'])){
2591            maxWidthBox = parseInt(RegExp.$1);
2592          }
2593          else if(/^(\d+)%$/.test(options['width'])){
2594            maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100;
2595          }
2596
2597          var pageRatio    = maxWidthBox / maxHeightBox;
2598
2599          if(image.width > maxWidthBox || image.height > maxHeightBox){
2600            if(options['scrollIfToHeight']){
2601               if(imageRatio > pageRatio){
2602                 lightboxWidth  = maxWidthBox;
2603                 lightboxHeight = Math.round(maxWidthBox / imageRatio) + heightFooter;
2604               }
2605               else{
2606                 lightboxWidth  = Math.round(image.width > maxWidthBox ? maxWidthBox : image.width);
2607                 lightboxHeight = maxHeightBox;
2608                 jQuery('.wLightboxImageOuter').css({'max-height' : String(lightboxHeight - heightFooter) + 'px', 'overflow' : 'auto'});
2609                 jQuery('.wLightboxImage').css({'max-height' : ''});
2610               }
2611             }
2612             else{
2613              if(imageRatio > pageRatio){
2614                lightboxWidth  = maxWidthBox;
2615                lightboxHeight = Math.round(maxWidthBox / imageRatio) + heightFooter;
2616              }
2617              else{
2618                lightboxWidth  = Math.round(maxHeightBox * imageRatio);
2619                lightboxHeight = maxHeightBox + heightFooter;
2620              }
2621            }
2622          }
2623          else{
2624            lightboxHeight = image.height + heightFooter;
2625          }
2626          heightAttrib = String(lightboxHeight) + 'px';
2627          jQuery('.wLightboxOuter').css({'height' : heightAttrib});
2628        }
2629      });
2630
2631      if(boxWasOpened){
2632        jQuery('.wLightboxPrev').attr('class', classPrev);
2633        jQuery('.wLightboxNext').attr('class', classNext);
2634        jQuery('.wLightboxImage').attr('src', src);
2635        jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2636      }
2637      else{
2638        jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2639        jQuery('.wLightboxOuter, .wLightboxBackground').bind('click', function(event){
2640          wLightboxClose()
2641        });
2642        jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(event){
2643          jQuery('.wLightbox').removeClass('wLightboxStatusLoaded');
2644          jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click');
2645          event.stopPropagation();
2646        });
2647      }
2648      if(typeof(wOnAfterInitLightbox) == 'function'){
2649        wOnAfterInitLightbox();
2650      }
2651    };
2652    image.src = src;
2653  }
2654  else if(/\.(mpeg|mp4|m4v)(\?[^\/]*)*$/i.test(src) || options['type'] == 'video' ||objectCurrent && objectCurrent.attr('data-lightboxtype') == 'video'){
2655
2656    var boxWasOpened = true;
2657
2658    var videoWidth = 0, videoHeight = 0, videoRatio = 0;
2659
2660    if(jQuery('.wLightbox').length == 0){
2661      var titleInnerHTML = '';
2662      var mimeTypeVideo  = 'video/mp4';
2663      jQuery('<div id="wLightbox" class="wLightbox wLightbox-image ' + lightboxClassName + '" data-src="' + src + '"><div class="wLightboxBackground"></div><div class="wLightboxOuter"><div class="wLightboxInner" ontouchstart="event.preventDefault();" onmousedown="event.preventDefault();"><div class="wLightboxCloser"></div><video controls="" autoplay="autoplay" style="max-width:100%;width:auto;height:auto;"><source src="' + src + '" type="' + mimeTypeVideo + '" /></video><div class="wLightboxFooter"><div class="wLightboxTitle">' + titleInnerHTML + '</div></div></div></div></div>').appendTo('body');
2664      jQuery(document).bind('keydown', function(e){
2665        if(e.keyCode == 27){
2666          wLightboxClose();
2667        }
2668        else if(e.keyCode == 37){
2669          jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click');
2670        }
2671        else if(e.keyCode == 39){
2672          jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click');
2673        }
2674      });
2675
2676      boxWasOpened = false;
2677    }
2678    else{
2679      jQuery('.wLightbox').removeClass('wLightboxStatusLoaded').addClass('wLightboxStatusLoading');
2680    }
2681
2682    if(elementCurrent && elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != ''){
2683      jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title'));
2684    }
2685    else{
2686      jQuery('.wLightboxTitle').hide();
2687    }
2688
2689    if(objectCurrent && objectCurrent.attr('data-lightboxdownloadable') == '1'){
2690      jQuery('.wLightboxDownload').remove();
2691      jQuery('.wLightboxFooter').addClass('wLightboxFooterHasDownload').append('<div class="wLightboxDownload" data-src="' + src + '" title="Download"></div>');
2692      jQuery('.wLightboxDownload').bind('click', function (event){
2693        window.open(jQuery(this).data('src'));
2694      });
2695    }
2696    else{
2697      jQuery('.wLightboxFooter').removeClass('wLightboxFooterHasDownload');
2698    }
2699
2700    var heightFooter = jQuery('.wLightboxFooter').outerHeight();
2701
2702    var maxWidthBox  = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth))    - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2;
2703    var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightFooter;
2704
2705    if(/^(\d+)px$/.test(options['width'])){
2706      maxWidthBox = parseInt(RegExp.$1);
2707    }
2708    else if(/^(\d+)%$/.test(options['width'])){
2709      maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100;
2710    }
2711
2712
2713    var pageRatio    = maxWidthBox / maxHeightBox;
2714
2715    jQuery('.wLightbox video').bind('loadedmetadata', function(event){
2716      videoWidth     = jQuery(this).get(0).videoWidth;
2717      videoHeight    = jQuery(this).get(0).videoHeight;
2718
2719      videoRatio     = videoWidth / videoHeight;
2720      lightboxWidth  = videoWidth;
2721      lightboxHeight = videoHeight;
2722
2723      if(videoWidth > maxWidthBox || videoHeight > maxHeightBox){
2724        if(videoRatio > pageRatio){
2725          lightboxWidth  = maxWidthBox;
2726          lightboxHeight = Math.round(maxWidthBox / videoRatio) + heightFooter;
2727        }
2728        else{
2729          lightboxWidth  = Math.round(maxHeightBox * videoRatio);
2730          lightboxHeight = maxHeightBox + heightFooter;
2731        }
2732      }
2733      else{
2734        lightboxHeight = lightboxHeight + heightFooter;
2735      }
2736
2737      widthAttrib  = String(lightboxWidth)  + 'px';
2738      heightAttrib = String(lightboxHeight) + 'px';
2739
2740      jQuery('.wLightboxOuter').css({'height' : heightAttrib});
2741      jQuery('.wLightboxInner').css({'width' : widthAttrib});
2742
2743      jQuery('.wLightboxPrev').data('entry', positionRel - 2);
2744      jQuery('.wLightboxNext').data('entry', positionRel);
2745
2746      if(boxWasOpened){
2747        jQuery('.wLightboxPrev').attr('class', classPrev);
2748        jQuery('.wLightboxNext').attr('class', classNext);
2749        jQuery('.wLightboxImage').attr('src', src);
2750        jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2751      }
2752      else{
2753        jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2754        jQuery('.wLightboxCloser, .wLightboxBackground').bind('click', function(event){
2755          wLightboxClose()
2756        });
2757        jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(event){
2758          jQuery('.wLightbox').removeClass('wLightboxStatusLoaded');
2759          jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click');
2760          event.stopPropagation();
2761        });
2762      }
2763    });
2764    if(typeof(wOnAfterInitLightbox) == 'function'){
2765      wOnAfterInitLightbox();
2766    }
2767  }
2768  else{
2769
2770    var boxWasOpened = true;
2771
2772    if(jQuery('.wLightbox').length == 0){
2773      jQuery('<div id="wLightbox" class="wLightbox wLightbox-iframe ' + lightboxClassName + '" data-src="' + src + '"><div class="wLightboxBackground"></div><div class="wLightboxOuter"><div class="wLightboxInner"><div class="wLightboxCloser"></div><iframe id="wLightboxIframe" class="wLightboxIframe" allowfullscreen="true" src="' + src + '"></iframe><div class="wLightboxTitle"></div></div></div></div>').appendTo('body');
2774      jQuery('.wLightboxCloser, .wLightboxBackground').bind('mousedown touchstart', function(){wLightboxClose()});
2775
2776      jQuery(document).bind('keydown', function(e){
2777        if(e.keyCode == 27){
2778          wLightboxClose();
2779        }
2780        else if(e.keyCode == 37){
2781          jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click');
2782        }
2783        else if(e.keyCode == 39){
2784          jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click');
2785        }
2786      });
2787
2788      boxWasOpened = false;
2789    }
2790
2791    var heightTitle = 0;
2792
2793    if(elementCurrent && elementCurrent.getAttribute('title') != ''){
2794      jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title'));
2795    }
2796    else{
2797      jQuery('.wLightboxTitle').hide();
2798    }
2799
2800    heightTitle = jQuery('.wLightboxTitle').outerHeight();
2801
2802    var maxWidthBox  = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth))    - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2;
2803    var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightTitle;
2804
2805    if(/^(\d+)px$/.test(options['width'])){
2806      maxWidthBox = parseInt(RegExp.$1);
2807    }
2808    else if(/^(\d+)%$/.test(options['width'])){
2809      maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100;
2810    }
2811
2812    if(/^(\d+)px$/.test(options['height'])){
2813      maxHeightBox = parseInt(RegExp.$1);
2814    }
2815    else if(/^(\d+)%$/.test(options['height'])){
2816      maxHeightBox = parseInt(jQuery(window).height()) * RegExp.$1 / 100;
2817    }
2818
2819    if(options && options['width'] && /^\d+(.\d+)?$/.test(options['width'])){
2820      contentWidth = options['width'];
2821    }
2822    else{
2823      contentWidth = maxWidthBox;
2824    }
2825
2826    if(options && options['height'] && /^\d+(.\d+)?$/.test(options['height'])){
2827      contentHeight = options['height'];
2828    }
2829    else{
2830      contentHeight = maxHeightBox;
2831    }
2832
2833    var pageRatio    = maxWidthBox / maxHeightBox;
2834    var contentRatio = contentWidth / contentHeight;
2835
2836    var lightboxWidth  = contentWidth;
2837    var lightboxHeight = contentHeight + heightTitle;
2838
2839    if(contentWidth > maxWidthBox || contentHeight > maxHeightBox){
2840      if(contentRatio > pageRatio){
2841        lightboxWidth  = maxWidthBox;
2842        lightboxHeight = Math.round(maxWidthBox / contentRatio) + heightTitle;
2843      }
2844      else{
2845        lightboxWidth  = Math.round(maxHeightBox * contentRatio);
2846        lightboxHeight = maxHeightBox + heightTitle;
2847      }
2848    }
2849
2850    widthAttrib  = String(lightboxWidth) + 'px';
2851    heightAttrib = String(lightboxHeight) + 'px';
2852
2853    jQuery('.wLightboxOuter').css({'height' : heightAttrib});
2854    jQuery('.wLightboxInner').css({'width' : widthAttrib});
2855
2856    jQuery('.wLightboxPrev').data('entry', positionRel - 2);
2857    jQuery('.wLightboxNext').data('entry', positionRel);
2858
2859    if(boxWasOpened){
2860      jQuery('.wLightboxPrev').attr('class', classPrev);
2861      jQuery('.wLightboxNext').attr('class', classNext);
2862      jQuery('.wLightboxImage').attr('src', src);
2863      jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2864    }
2865    else{
2866      jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading');
2867      jQuery('.wLightboxOuter, .wLightboxBackground').bind('click', function(){
2868        wLightboxClose()
2869      });
2870      jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(){
2871        jQuery('.wLightbox').removeClass('wLightboxStatusLoaded');
2872        jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click');
2873        event.stopPropagation();
2874      });
2875    }
2876    if(typeof(wOnAfterInitLightbox) == 'function'){
2877      wOnAfterInitLightbox();
2878    }
2879  }
2880  jQuery('body').addClass('wglBox');
2881  return false;
2882};
2883
2884wLightboxClose = function(){
2885  jQuery('.wLightbox').remove();
2886  jQuery('body').removeClass('wglBox');
2887  jQuery(document).unbind('keydown');
2888};

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.