PageSourceSearch

https://www.youth.gov.hk/pages/js/main.js?v=1.2

js youth.gov.hk collected 2026-10-02 05:33:55 UTC 192,154 bytes, 6,426 lines download raw bytes

1const COLLECTIONS = {
2  POPULAR_SEARCH_KEYWORD: 'popular_search_keyword',
3  MAIN_MENU_ITEMS: 'main_menu_items',
4  PAGE_FOOTER_LINKS: 'page_footer_links',
5  SOCIAL_MEDIA: 'social_media',
6  EVENTS: 'events',
7  ARTICLES: 'articles'
8}
9
10/**
11 * Patch Bootstrap 5.3.3 Dropdown to prevent "Cannot read properties of undefined (reading 'parentNode')" error.
12 * This error occurs when Bootstrap's dataApiKeydownHandler tries to get/create a Dropdown instance
13 * on an element that has been detached from the DOM (no parentNode).
14 */
15;(function() {
16  if (typeof bootstrap !== 'undefined' && bootstrap.Dropdown) {
17    var _origGetOrCreateInstance = bootstrap.Dropdown.getOrCreateInstance;
18    bootstrap.Dropdown.getOrCreateInstance = function(element, config) {
19      // Guard against undefined/null elements or elements detached from DOM
20      if (!element || !element.parentNode) {
21        // Return a dummy object with no-op methods to prevent cascading errors
22        return {
23          toggle: function() {},
24          show: function() {},
25          hide: function() {},
26          update: function() {},
27          dispose: function() {},
28          _selectMenuItem: function() {},
29          _element: null,
30          _menu: null,
31          _config: {}
32        };
33      }
34      return _origGetOrCreateInstance.call(this, element, config);
35    };
36  }
37})();
38
39var cssTransEnd = 'webkitTransitionEnd transitionend ';
40var cssAniEnd = 'animationend webkitAnimationEnd';
41/*User Agent*/
42var ua = navigator.userAgent.toLowerCase();
43var isSafartiIos = device.ios();
44var isChrome = ua.indexOf('chrome') > -1;
45var isWindow = (ua.indexOf("windows") !== -1);
46var isFirefox = typeof InstallTrigger !== 'undefined';
47var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
48var isDesktop = jQuery('html').hasClass('desktop');
49var isIOS = device.ios();
50var isAndroid = device.android();
51var isIE = detectIE();
52
53var isIE8 = isIE && isIE == 8;
54var isIE9 = isIE && isIE == 9;;
55
56
57function getShortLang() {
58  var lang = document.documentElement.lang;
59  var langCode='en';
60
61  if (lang.toLowerCase() == 'zh-hk') {
62    langCode = 'tc';
63  } else if (lang.toLowerCase() == 'zh-cn') {
64    langCode = 'tc';
65  } else if (lang.toLowerCase() == 'tc') {
66    langCode = 'tc';
67  } else {
68    langCode = 'en';
69  }
70
71  return langCode;
72
73}
74
75/**
76 * detect IE
77 * returns version of IE or false, if browser is not Internet Explorer
78 */
79function detectIE() {
80    var ua = window.navigator.userAgent;
81
82    var msie = ua.indexOf('MSIE ');
83    if (msie > 0) {
84        // IE 10 or older => return version number
85        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
86    }
87
88    var trident = ua.indexOf('Trident/');
89    if (trident > 0) {
90        // IE 11 => return version number
91        var rv = ua.indexOf('rv:');
92        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
93    }
94
95    var edge = ua.indexOf('Edge/');
96    if (edge > 0) {
97       // Edge (IE 12+) => return version number
98       return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
99    }
100
101    // other browser
102    return false;
103}
104
105var prefix = (function () {
106  if(isIE8){return {
107    dom: '',
108    lowercase: '',
109    css: '',
110    js: ''
111  };}
112  var styles = window.getComputedStyle(document.documentElement, ''),
113    pre = (Array.prototype.slice
114      .call(styles)
115      .join('')
116      .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
117    )[1],
118    dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
119  return {
120    dom: dom,
121    lowercase: pre,
122    css: '-' + pre + '-',
123    js: pre[0].toUpperCase() + pre.substr(1)
124  };
125})();
126
127
128(function ($, root, undefined) {
129
130  $(function () {
131
132    'use strict';
133
134    if(isIE) {
135        $('html').addClass('isIE isIE-' + isIE);
136    }
137
138    if(isIE && isIE < 10) {
139      $('html').addClass('isIE-noscroll');
140    }
141
142    if(isIE && isIE < 12) {
143      $('html').addClass('isIE-old');
144    }
145
146    if(isFirefox) {
147      $('html').addClass('isFF');
148    }
149  });
150
151})(jQuery, this);
152
153/*check press key is tab or shift-tab*/
154function ckSTab(e) {
155  return (e.which ==9 && e.shiftKey);
156}
157
158function ckTab(e) {
159  return (e.which ==9 && !e.shiftKey);
160}
161
162function ckEsc(e) {
163  return (e.which ==27 && !e.shiftKey);
164}
165
166function inIframe () {
167    try {
168        return window.self !== window.top;
169    } catch (e) {
170        return true;
171    }
172}
173
174
175function CheckObjEmpty(__boj) {
176   for(var key in __boj) {
177     if (__boj.hasOwnProperty(key)) {
178        return false;
179     }
180   }
181   return true;
182}
183
184var uniqueArray = function(arrArg) {
185  return arrArg.filter(function(elem, pos,arr) {
186    return arr.indexOf(elem) == pos;
187  });
188};
189
190
191/**
192 * Returns a bare object of the URL's query parameters.
193 * You can pass just a query string rather than a complete URL.
194 * The default URL is the current page.
195 */
196function getUrlParams (url) {
197    // http://stackoverflow.com/a/23946023/2407309
198    if (typeof url == 'undefined') {
199        url = window.location.search
200    }
201    var url = url.split('#')[0] // Discard fragment identifier.
202    var urlParams = {}
203    var queryString = url.split('?')[1]
204    if (!queryString) {
205        if (url.search('=') !== false) {
206            queryString = url
207        }
208    }
209    if (queryString) {
210        var keyValuePairs = queryString.split('&')
211        for (var i = 0; i < keyValuePairs.length; i++) {
212            var keyValuePair = keyValuePairs[i].split('=')
213            var paramName = keyValuePair[0]
214            var paramValue = keyValuePair[1] || ''
215            urlParams[paramName] = decodeURIComponent(paramValue.replace(/\+/g, ' '))
216        }
217    }
218    return urlParams
219} // getUrlParams
220
221
222function youtube_parser(url){
223    var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
224    var match = url.match(regExp);
225    return (match&&match[7].length==11)? match[7] : false;
226}
227
228
229function getHash(target) {
230    var hash = window.location.hash.substring(1);
231    if (!target || target.test(hash)) {
232        window.location.hash = '';
233        if (typeof history.replaceState != 'undefined')
234            history.replaceState('', document.title, window.location.pathname);
235        return hash;
236    }
237    return false;
238}
239
240
241
242function imgLoaded($_itms, callback) {
243    var $itms = $_itms,
244        $imgs = $(''),
245        $t;
246
247    $itms.each(function(){
248      var $it = $(this);
249      if($it[0].tagName.toLowerCase() == 'img'){
250        $t = $it;
251      }else  {
252        $t = $it.find('img');
253      }
254    })
255
256    $imgs = $imgs.add( $t);
257
258    var imgLength = $imgs.length,
259        deferredArray = [];
260
261    if(imgLength){
262
263      $.each($imgs, function(i){
264        var $itmImg = $(this),
265            img = new Image(),
266            imgDeferred = $.Deferred();
267
268        deferredArray.push(imgDeferred.promise());
269
270        img.onload = function(){
271          imgDeferred.resolve($itmImg);
272        }
273
274        setTimeout(function(){
275          if(imgDeferred.state() !== 'resolved') {
276            imgDeferred.resolve($itmImg);
277          }
278        }, 20000)
279
280        // this part may be enhanced the if to switch ....etc
281        if(Modernizr.srcset) {
282          if($itmImg.data('srcset') !== undefined){
283            $itmImg.prop('srcset', $itmImg.data('srcset'));
284            img.srcset = $itmImg.prop('srcset');
285          } else {
286             if($itmImg.data('src') !== undefined){
287                $itmImg.prop('src', $itmImg.data('src'));
288             }
289             img.src = $itmImg.prop('src');
290          }
291        } else {
292          if($itmImg.data('src') !== undefined){
293            $itmImg.prop('src', $itmImg.data('src'));
294          }
295          img.src = $itmImg.prop('src');
296        }
297        // END - this part may be enhanced the if to switch ....etc
298
299      })
300    } else {
301      var deferred = $.Deferred();
302
303      deferredArray.push(deferred.promise());
304
305      deferred.resolve();
306    }
307
308    $.when.apply($, deferredArray).done(function(){
309
310      callback($imgs);
311
312    }).fail(function(){
313
314    }).then(function(){
315
316    })
317}
318
319
320(function(jQuery)
321{
322   jQuery.fn.nextOrFirst = function(selector){
323                var next = this.next(selector);
324                return (next.length) ? next : this.prevAll(selector).last();
325              }
326})(jQuery);
327
328(function(jQuery)
329{
330   jQuery.fn.prevOrLast = function(selector){
331      var prev = this.prev(selector);
332      return (prev.length) ? prev : this.nextAll(selector).last();
333    }
334})(jQuery);
335
336
337/* Current Lang */
338function getLang(){
339  var curLang;
340  var b = $('body');
341  if(b.hasClass('lang-en')){
342    curLang = 'en';
343  } else if(b.hasClass('lang-tc')){
344    curLang = 'tc';
345  } else if(b.hasClass('lang-sc')){
346    curLang = 'sc';
347  } else {
348    curLang = 'en';
349  }
350  return curLang;
351};
352
353function langArg(_arg){
354  var cur_lang = getLang();
355  return _arg[cur_lang];
356};
357
358var jsQueryTest = (function($){
359  var $xsBlk = $('.query-crt-xs'),
360      $smBlk = $('.query-crt-sm'),
361      $mdBlk = $('.query-crt-md'),
362      $lgBlk = $('.query-crt-lg'),
363      $xlBlk = $('.query-crt-xl'),
364      $xxlBlk = $('.query-crt-xxl'),
365      $2xBlk = $('.query-crt-2x'),
366      current_query,
367      new_query;
368
369  function setup(){
370      if(!$xsBlk.length) {
371        $('body').append(
372          '<div class="query-crt-xs query-crt"/>',
373          '<div class="query-crt-sm query-crt"/>',
374          '<div class="query-crt-md query-crt"/>',
375          '<div class="query-crt-lg query-crt"/>',
376          '<div class="query-crt-xl query-crt"/>',
377          '<div class="query-crt-xxl query-crt"/>',
378          '<div class="query-crt-2x query-crt"/>'
379          );
380        $xsBlk = $('.query-crt-xs'),
381        $smBlk = $('.query-crt-sm'),
382        $mdBlk = $('.query-crt-md'),
383        $lgBlk = $('.query-crt-lg'),
384        $xlBlk = $('.query-crt-xl'),
385        $xxlBlk = $('.query-crt-xxl'),
386        $2xBlk = $('.query-crt-2x');
387      }
388
389      current_query = checkState();
390      updateClass(current_query);
391      stateChange(current_query, true);
392
393      $(window).on('resize load', function(){
394          new_query = checkState();
395
396          if(new_query !== current_query) {
397            updateClass(new_query);
398            stateChange(new_query);
399          }
400          current_query = new_query;
401      });
402  }
403
404  function checkState(){
405    var state;
406
407    if($xsBlk.css('display') == 'block'){
408        state = 'xs';
409    } else if($smBlk.css('display') == 'block'){
410        state = 'sm';
411    } else if($mdBlk.css('display') == 'block'){
412        state = 'md';
413    } else if($lgBlk.css('display') == 'block'){
414        state = 'lg';
415    } else if($xlBlk.css('display') == 'block'){
416        state = 'xl';
417    } else if($xxlBlk.css('display') == 'block'){
418        state = 'xxl';
419    }
420
421    if(isIE8){
422      state = 'xxl';
423    }
424
425    return state;
426  }
427
428  function updateClass(_state) {
429    $('body').removeClass('js-xs js-sm js-md js-lg js-xl js-xxl').addClass('js-' + _state);
430  }
431
432  function stateChange(_newQuery, entresite){
433    // jsIScroll.rein();
434     if(!entresite && (_newQuery !== 'xs'  || _newQuery !== 'sm')){
435     }
436
437     if(!entresite){
438     }
439  }
440
441  setup();
442
443  return {
444    init: function(){
445      setup();
446    },
447    getCurrentState: function(){
448      return checkState();
449    }
450    ,
451    isXS: function(){
452      return checkState() == 'xs';
453    }
454    ,
455    isSM: function(){
456      return checkState() == 'sm';
457    }
458    ,
459    isMD: function(){
460      return checkState() == 'md';
461    },
462    isLG: function(){
463      return checkState() == 'lg';
464    },
465    isXL: function(){
466      return checkState() == 'xl';
467    },
468    isXXL: function(){
469      return checkState() == 'xxl';
470    },
471    argF: function(opts){
472      var state = checkState();
473
474      if(state == 'xs'){
475        return opts['xs']
476      } else if(state == 'sm'){
477        return opts['sm']
478      } else if(state == 'md'){
479        return opts['md']
480      } else if(state == 'lg'){
481        return opts['lg']
482      } else if(state == 'xl'){
483        return opts['xl']
484      } else if(state == 'xxl'){
485        return opts['xxl']
486      }
487    },
488    is2x: function(){
489      return $2xBlk.css('display') == 'block'
490    }
491  };
492
493
494}(jQuery));
495var cancelMouseFocusOutline = (function(){
496
497  var $body = $('body');
498
499  function setup(){
500
501    $body.addClass('mouse-down-remove-outline');
502
503    $(document)
504      .on('mousedown.cancel-outline', function(e){
505        $body.addClass('mouse-down-remove-outline');
506      })
507      .on('keydown.cancel-outline', function(e){
508        if(e.which ==9){
509          $body.removeClass('mouse-down-remove-outline');
510        }
511      })
512  }
513
514  return {
515    init: setup
516  };
517}());
518
519
520
521var skip2content = (function() {
522  var $skip, $start;
523
524  function setup() {
525    $skip = $('#skip-to-content'),
526      $start = $('#skip-to-main-content');
527
528    $skip.on('click', function(e) {
529      e.preventDefault();
530      $start.focus();
531      $('html, body').scrollTop($start.offset().top)
532    });
533    $skip.on("keydown", function (e) {
534        var keycode = e.keyCode || e.which;
535        if (keycode==13 || keycode==32){
536          $start.focus();
537          $('html, body').scrollTop($start.offset().top);
538        }
539    });
540  }
541
542  return {
543    init: function() {
544      setup();
545    }
546  }
547}());
548
549var jsIframeWrap = (function(){
550
551  var $cke_iframe,
552      clear;
553
554  function setup(){
555    $cke_iframe = $('.ckec iframe');
556
557    $cke_iframe.each(function(){
558      var $f = $(this);
559      $f.attr('data-ori-width', $f.attr('width'));
560      $f.attr('data-ori-height', $f.attr('height'));
561    })
562
563    $(window).on('resize', function(){
564      if(clear){
565        clearTimeout(clear);
566        clear = null;
567      }
568      setTimeout(function(){
569        frameResize();
570      }, 100)
571    }).resize();
572  }
573
574
575  function frameResize(){
576    $cke_iframe.each(function(){
577      var $i = $(this),
578          o_h = $i.attr('data-ori-height'),
579          o_w = $i.attr('data-ori-width'),
580          ratio = o_h / o_w;
581      var cw = $cke_iframe.parent().width();
582
583      var isGoogleDocs = $i.attr('src').match(/docs.google.com\/a\//);
584
585      var w = Math.min(cw, o_w);
586
587      $i.css({
588        width: w,
589        height: (isGoogleDocs) ? o_h : w * ratio
590      })
591    })
592  }
593
594  return {
595    init: setup,
596    triggerResize: frameResize
597  }
598}());
599
600
601var jsCkecEnhance = (function(){
602
603  function setup(){
604    jsIframeWrap.init();
605  }
606
607  return {
608    init: setup
609  };
610}());
611var jsBsDropdownEv = (function () {
612
613  function setup(){
614
615     $('.dropdown-down--max-height').on('show.bs.dropdown', function(){
616        var $drop = $(this),
617            $meun = $drop.find('.dropdown-menu');
618
619        $meun.css('max-height', $(window).height() + $(window).scrollTop() - $meun.offset().top - 5);
620     });
621  }
622
623  return {
624    init: setup
625  };
626}());
627
628
629var jsBsDropdownPreventCloseByClick = (function () {
630
631  var selector = '.js-bs-dropdown-prevent-close';
632
633  function setup() {
634
635    var $i = $(selector),
636      $inside = $i.find('.dropdown-menu'),
637      $inside_close = $inside.find('.js-bs-dropdown-close');
638    $form_close = $inside.find('.form-control-dropdown__close');
639
640    $inside.on('mousedown touchstart', function (e) {
641      e.stopImmediatePropagation();
642
643      $(this).closest('.dropdown').addClass('dontClose');
644    })
645
646    $inside.find('.form-control-dropdown__close').on('mousedown touchstart', function (e) {
647      var $t_closebtn = $(this),
648        $container = $t_closebtn.closest('.dropdown');
649
650      $container.removeClass('dontClose');
651      e.stopPropagation();
652    })
653
654    $i.on('hide.bs.dropdown', function (e) {
655      var $drop = $(this);
656      if ($drop.hasClass('dontClose')) {
657        e.preventDefault();
658      }
659    });
660
661    $inside.find('select').each(function (i) {
662      var $s = $(this);
663      if ($s.parent().is('.js-selectBox')) {
664        $s.bind('selectmenuopen', function (event, ui) {
665          var $openSelect = $(this);
666          $openSelect.closest('.dropdown').addClass('dontClose');
667        })
668      }
669    })
670
671    $(document).on('mousedown touchstart', function (e) {
672      $('.dropdown').removeClass('dontClose');
673    })
674
675    $inside_close.on('click', function (e) {
676      var $drop = $(this),
677      $container = $drop.closest('.dropdown');
678
679      $container.removeClass('dontClose');
680      //for screen reader
681      var $focus = $container.find("a, button").first()
682      if ($focus.css("visibility") !== 'visible' || $focus.parent().css("visibility") !== 'visible') {
683        $('#mobile-menu-trigger').focus()
684      } else {
685        $focus.focus()
686      }
687    })
688
689    //for screen reader
690    $form_close.click(function () {
691      var $t_close = $(this);
692      var $t_btn = $t_close.closest(".dropdown-menu").siblings('button')
693
694      $t_btn.focus()
695
696    })
697  }
698
699  // function addDontClose($_insideElms){
700  //   if($openSelect.closest('.js-bs-dropdown-prevent-close').length){
701  //     $openSelect.closest('.js-bs-dropdown-prevent-close').addClass('dontClose')
702  //   }
703  // }
704
705  // function removeDontClose($_insideElms){
706  //   if($openSelect.closest('.js-bs-dropdown-prevent-close').length){
707  //     $openSelect.closest('.js-bs-dropdown-prevent-close').removeClass('dontClose')
708  //   }
709  // }
710
711
712
713
714  return {
715    init: setup
716    // addDontClose: addDontClose,
717    // removeDontClose: removeDontClose
718  }
719}());
720
721
722var jsBsDropdownShowSelected = (function () {
723
724  var selector = '.js-bs-dropdown-show-selected';
725
726  function setup() {
727
728    var $i = $(selector);
729    var $input = $i.find('input');
730    var $show = $i.find('.form-control');
731
732    var $selectall = $(".js-dropdown-selectall");
733
734    // $selectall.change(function () {
735    //   var $this = $(this);
736
737
738    // })
739
740    $input.change(function () {
741      var $this = $(this);
742      var $option = $this.closest('.form-control-dropdown__option')
743      var $dropdown = $this.closest('.dropdown')
744      var $t_selectall = $dropdown.find($selectall)
745
746      if (!$dropdown.data('oritext')) {
747        $dropdown.data('oritext', $this.closest($i).find($show).text())
748      }
749
750      if ($this.hasClass("js-dropdown-selectall")) {
751        var $other_input = $this.closest(".dropdown").find("input")
752        if (this.checked) {
753          $other_input.prop('checked', true);
754          $this.closest($i).find($show).text($this.siblings('span').text())
755        } else {
756          $other_input.prop('checked', false);
757          $this.closest($i).find($show).text(setShowText($option, $dropdown.data('oritext')))
758        }
759      } else {
760        if ($t_selectall.length) {
761          checkSelectall($option, $t_selectall)
762        }
763        $this.closest($i).find($show).text(setShowText($option, $dropdown.data('oritext')))
764      }
765
766    })
767
768  }
769  function setShowText($_option, _oriText) {
770    var checkedLength = $_option.find('input:checked').length;
771    var showText = "";
772    if (!checkedLength) {
773      showText = _oriText
774    } else {
775      showText = ''
776
777      $_option.find('input:checked').each(function (i) {
778        var $this = $(this);
779        var text = $this.siblings('span').text();
780
781        showText = showText + text
782        if (checkedLength - 1 != i) {
783          showText = showText + ", "
784        }
785      })
786
787    }
788    return showText
789  }
790
791  function checkSelectall($_option, $_t_selectall) {
792    if ($_option.find('input:checked').length == $_option.find('input').length) {
793      $_t_selectall.prop('checked', true);
794    } else {
795      $_t_selectall.prop('checked', false);
796    }
797  }
798
799  return {
800    init: setup
801  }
802}());
803
804
805var jsBsCollapseRte = (function(){
806
807  var $all__collapse__rte;
808
809  function setup(){
810    $all__collapse__rte = $('.rte-template-collapse');
811
812    $all__collapse__rte.each(function(i){
813      var $c = $(this),
814          $trigger = $c.find('.rte-template-collapse__trigger'),
815          $content = $c.find('.rte-template-collapse__content').eq(0),
816          $heading = $c.find('.rte-template-collapse__heading').eq(0);
817
818      var collapseId = 'collapse-' + i ;
819
820      $trigger
821        .attr('href', '#' + collapseId)
822        .attr('aria-controls', collapseId);
823
824      $heading.attr('id', collapseId + '-heading');
825
826      $content
827        .attr('id', collapseId)
828        .attr('aria-labelledby', collapseId + '-heading');
829
830
831      // $content.collapse( ($trigger.attr('aria-expanded') == 'true') ? '' : 'hide' );
832    })
833  }
834
835  return {
836    init: setup
837  };
838}());
839var responsiveImg = (function() {
840  var $resImg,
841      state,
842      t = null,
843      regex = /\/\d+p\d+\//,
844      rwdimg_size = '750';
845
846  function setup() {
847    $resImg = $('.js-responsive-img img');
848
849    $resImg.each(function(){
850      setImgData($(this));
851    })
852
853    state = jsQueryTest.getCurrentState();
854    stateChangeAction(state);
855
856    $(window).on('resize load', function() {
857      {
858        if (t !== null) {
859          clearTimeout(t);
860          t = null;
861        }
862
863        t = setTimeout(function() {
864          var old_state = state,
865              new_state = jsQueryTest.getCurrentState();
866
867          if (old_state !== new_state) {
868            stateChangeAction(new_state);
869          }
870
871          state = new_state;
872        }, 30);
873      }
874    });
875  }
876
877  function setImgData($_img) {
878    $_img.attr('data-img-ori', $_img.attr('src'));
879    $_img.attr('data-img-rwd', $_img.attr('src').replace(regex, '/' + rwdimg_size + 'p0/'));
880  }
881
882  function updateSrc(_state) {  // incorrect
883    $resImg.each(function() {
884      var $img = $(this);
885      // imgLoaded($img, function(){
886        if(_state == 'js-mobile') {
887          $img.attr('src', $img.attr('data-img-rwd'));
888        } else {
889          $img.attr('src', $img.attr('data-img-ori'));
890        }
891      // })
892    })
893  }
894
895  function stateChangeAction(_state) {
896    updateSrc(_state);
897  }
898
899  return {
900    init: setup
901  };
902}());
903
904var jsWrapTable = (function(){
905
906  var time = null,
907      buff = 3;
908
909  function setup() {
910    var $allTable = $('table:not(.blankstyle)', '.ckec');
911
912    $allTable.each(function(){
913      wrap($(this));
914    })
915
916    $(window).on('resize load', function(){
917      if(time !== null){
918        clearTimeout(time);
919        time = null
920      }
921      time = setTimeout(function(){
922        $allTable.each(function(){
923          wrap($(this));
924        })
925
926        $allTable.each(function(){
927          var $t = $(this),
928              $twrapper = $t.closest('.tableWrapper'),
929              $touter = $t.closest('.tableWrapperOuter');
930
931              if(Math.abs($touter.width() - $t.outerWidth()) < buff){
932                $touter.addClass('rightEnd');
933              } else {
934                $touter.removeClass('rightEnd');
935              }
936        })
937      }, 100)
938    })
939  }
940
941  function wrap(_table){
942    var $this = _table,
943      parentWidth = $this.parent().width(),
944      tableWidth = $this.width();
945
946    if($this.data('tablewrapper') !== undefined) {return}
947
948    if (parentWidth < tableWidth) {
949      var $tableWrapper = $('<div class="tableWrapper"></div>');
950      var $tableWrapperOuter = $('<div class="tableWrapperOuter leftEnd" />');
951
952      $tableWrapper.scroll(function(e){
953        var $thisWrapper = $(this),
954            $table = $this,
955            $outer = $thisWrapper.parent();
956
957        if($table.position().left !== 0) {
958          $outer.removeClass('leftEnd');
959        } else {
960          $outer.addClass('leftEnd');
961        }
962
963        if($table.position().left > (-($table.outerWidth() - $thisWrapper.width())) + buff ) {
964          $outer.removeClass('rightEnd');
965        } else {
966          $outer.addClass('rightEnd');
967        }
968      })
969
970
971       $this.wrap($tableWrapper);
972       $this.parent().wrap($tableWrapperOuter);
973
974       $this.data('tablewrapper', 1);
975    }
976  }
977
978  return {
979    init: function(){
980      setup();
981    }
982  };
983
984}());
985
986var jsSlick = (function(){
987  var $slick,
988      opts = {
989        'default': {
990          'prevArrow' : '<button type="button" class="slick-prev"><span class="ico ico-fw ico-arrow-left"></span><span class="sr-only">' + langArg({'en': 'Previous', 'tc': '前一頁', 'sc': '前一页'}) + '</span></button>',
991          'nextArrow' : '<button type="button" class="slick-next"><span class="ico ico-fw ico-arrow-right"></span><span class="sr-only">' + langArg({'en': 'Next', 'tc': '後一頁', 'sc': '后一页'}) + '</span></button>'
992        },
993        'key-visual__list': {
994          // normal options...
995          infinite: true,
996          arrows: true,
997          slidesToShow: 1,
998          slidesToScroll: 1,
999          autoplay: false,
1000          speed: 600,
1001          autoplaySpeed: 3000,
1002          dots: false,
1003          pauseOnHover: false,
1004          fade: true,
1005          waitForAnimate: false,
1006          touchThreshold: 10,
1007          btnPlayPause: true  // Self declare option, not in slick default
1008        },
1009        'side-img-slider__list': {
1010          // normal options...
1011          infinite: true,
1012          arrows: true,
1013          slidesToShow: 1,
1014          slidesToScroll: 1,
1015          autoplay: true,
1016          adaptiveHeight: true,
1017          autoplaySpeed: 18000,
1018          dots: true,
1019          pauseOnHover: false,
1020          fade: true,
1021          waitForAnimate: false,
1022          touchThreshold: 10,
1023          btnPlayPause: true  // Self declare option, not in slick default
1024        },
1025        'hot-slider__list': {
1026          // normal options...
1027          infinite: true,
1028          arrows: true,
1029          speed: 600,
1030          slidesToShow: 3,
1031          slidesToScroll: 3,
1032          autoplay: false,
1033          autoplaySpeed: 8000,
1034          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1035          dots: true,
1036          pauseOnHover: false,
1037          fade: false,
1038          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1039          touchThreshold: 10,
1040          btnPlayPause: false,  // Self declare option, not in slick default
1041          responsive: [{
1042            breakpoint: 1200,
1043            settings: {
1044              slidesToShow: 2,
1045              slidesToScroll: 2,
1046              speed: 450
1047            }
1048          },{
1049            breakpoint: 768,
1050            settings: {
1051              slidesToShow: 1,
1052              slidesToScroll: 1,
1053              speed: 250
1054            }
1055          }]
1056        },
1057        'interest-slider__list': {
1058          // normal options...
1059          infinite: true,
1060          arrows: true,
1061          speed: 700,
1062          slidesToShow: 4,
1063          slidesToScroll: 4,
1064          autoplay: false,
1065          autoplaySpeed: 8000,
1066          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1067          dots: true,
1068          pauseOnHover: false,
1069          fade: false,
1070          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1071          touchThreshold: 10,
1072          btnPlayPause: false,  // Self declare option, not in slick default
1073          responsive: [{
1074            breakpoint: 1200,
1075            settings: {
1076              slidesToShow: 3,
1077              slidesToScroll: 3,
1078              speed: 500,
1079            }
1080          },{
1081            breakpoint: 991,
1082            settings: {
1083              slidesToShow: 2,
1084              slidesToScroll: 2,
1085              speed: 300,
1086            }
1087          },{
1088            breakpoint: 768,
1089            settings: {
1090              slidesToShow: 2,
1091              slidesToScroll: 2,
1092              speed: 300
1093            }
1094          },{
1095            breakpoint: 576,
1096            settings: {
1097              slidesToShow: 1,
1098              slidesToScroll: 1,
1099              speed: 150,
1100            }
1101          }]
1102        },
1103        'ads-slider__list': {
1104          // normal options...
1105          infinite: true,
1106          arrows: true,
1107          speed: 280,
1108          slidesToShow: 6,
1109          slidesToScroll: 6,
1110          autoplay: false,
1111          autoplaySpeed: 8000,
1112          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1113          dots: true,
1114          pauseOnHover: false,
1115          fade: false,
1116          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1117          touchThreshold: 10,
1118          btnPlayPause: false,  // Self declare option, not in slick default
1119          responsive: [{
1120            breakpoint: 768,
1121            settings: {
1122              slidesToShow: 3,
1123              slidesToScroll: 3,
1124              speed: 180,
1125            }
1126          },{
1127            breakpoint: 480,
1128            settings: {
1129              slidesToShow: 2,
1130              slidesToScroll: 2,
1131              speed: 120,
1132            }
1133          }
1134          ]
1135        },
1136        'compare-slider__list': {
1137          // normal options...
1138          infinite: true,
1139          arrows: true,
1140          speed: 500,
1141          slidesToShow: 3,
1142
1143          slidesToScroll: 3,
1144          autoplay: false,
1145          autoplaySpeed: 8000,
1146          dots: true,
1147          fade: false,
1148          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1149          touchThreshold: 10,
1150          btnPlayPause: false,  // Self declare option, not in slick default
1151          responsive: [{
1152            breakpoint: 991,
1153            settings: {
1154              slidesToShow: 2,
1155              slidesToScroll: 2,
1156              speed: 340
1157            }
1158          },{
1159            breakpoint: 525,
1160            settings: {
1161              slidesToShow: 1,
1162              slidesToScroll: 1,
1163              speed: 200
1164            }
1165          }]
1166        },
1167        'article-slider__list': {
1168          // normal options...
1169          infinite: true,
1170          arrows: true,
1171          speed: 600,
1172          slidesToShow: 1,
1173          slidesToScroll: 1,
1174          touchThreshold: 10,
1175          autoplay: false,
1176          autoplaySpeed: 8000,
1177          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1178          dots: false,
1179          pauseOnHover: false,
1180          fade: false,
1181          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1182          btnPlayPause: false,  // Self declare option, not in slick default
1183        },
1184        'normal-item-slider__list--desktop-4': {
1185          // normal options...
1186          infinite: true,
1187          arrows: true,
1188          // speed: 1250,
1189          slidesToShow: 4,
1190          slidesToScroll: 4,
1191          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1192          speed:600, // for smooth scrolling
1193          autoplay: false,
1194          autoplaySpeed: 8000,
1195          dots: true,
1196          pauseOnHover: false,
1197          touchThreshold: 20,
1198          fade: false,
1199          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1200          btnPlayPause: false,  // Self declare option, not in slick default
1201          responsive: [{
1202            breakpoint: 1199,
1203            settings: {
1204              slidesToShow: 3,
1205              slidesToScroll: 3,
1206              speed:500,
1207            }
1208          },{
1209            breakpoint: 768,
1210            settings: {
1211              slidesToShow: 2,
1212              slidesToScroll: 2
1213            }
1214          },{
1215            breakpoint: 525,
1216            settings: {
1217              slidesToShow: 1,
1218              slidesToScroll: 1
1219            }
1220          }]
1221        },
1222        'video-slider__list': {
1223          // normal options...
1224          infinite: true,
1225          arrows: true,
1226          speed: 450,
1227          slidesToShow: 2,
1228          slidesToScroll: 2,
1229          autoplay: false,
1230          autoplaySpeed: 8000,
1231          touchThreshold: 10,
1232          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1233          dots: true,
1234          pauseOnHover: false,
1235          fade: false,
1236          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1237          btnPlayPause: false,  // Self declare option, not in slick default
1238          responsive: [{
1239            breakpoint: 525,
1240            settings: {
1241              slidesToShow: 1,
1242              slidesToScroll: 1,
1243              speed: 300
1244            }
1245          }]
1246        },
1247        'normal-item-slider__list--desktop-3': {
1248          // normal options...
1249          infinite: true,
1250          arrows: true,
1251          speed: 750,
1252          slidesToShow: 3,
1253          slidesToScroll: 3,
1254          autoplay: false,
1255          autoplaySpeed: 8000,
1256          waitForAnimate: Modernizr.touchevents ? false : true,// for smooth scrolling
1257          dots: true,
1258          pauseOnHover: false,
1259          touchThreshold: 15,
1260          fade: false,
1261          cssEase: 'cubic-bezier(0.23, 1, 0.32, 1)',
1262          btnPlayPause: false,  // Self declare option, not in slick default
1263          responsive: [{
1264            breakpoint: 768,
1265            settings: {
1266              slidesToShow: 2,
1267              slidesToScroll: 2,
1268              speed: 380
1269            }
1270          },{
1271            breakpoint: 525,
1272            settings: {
1273              slidesToShow: 1,
1274              slidesToScroll: 1,
1275              speed: 200
1276            }
1277          }]
1278        }
1279      }
1280
1281  function setup($_container){
1282    var $c = ($_container) ? $_container : $('body');
1283    $slick = $('.js-slick', $c);
1284    if(!$slick.length){return}
1285    $slick.each(function(){
1286      var $sl = $(this),
1287          $container = $sl.closest('.js-slick-container'),
1288          $items = $sl.find('.js-slick-itm'),
1289          item_no = $items.length;
1290      if($sl.hasClass('side-img-slider__list')){
1291        var optInput = $.extend({}, opts['default'] ,opts['side-img-slider__list'] )
1292      } else if ($sl.hasClass('multi-item__list') ){
1293        var optInput = $.extend({}, opts['default'] ,opts['multi-item__list'] )
1294      } else if ($sl.hasClass('hot-slider__list') ){
1295        var optInput = $.extend({}, opts['default'] ,opts['hot-slider__list'] )
1296      } else if ($sl.hasClass('article-slider__list') ){
1297        var optInput = $.extend({}, opts['default'] ,opts['article-slider__list'] )
1298      }else if ($sl.hasClass('interest-slider__list') ){
1299        var optInput = $.extend({}, opts['default'] ,opts['interest-slider__list'] )
1300      }else if ($sl.hasClass('ads-slider__list') ){
1301        var optInput = $.extend({}, opts['default'] ,opts['ads-slider__list'] )
1302      }else if ($sl.hasClass('video-slider__list') ){
1303        var optInput = $.extend({}, opts['default'] ,opts['video-slider__list'] )
1304      } else if ($sl.hasClass('normal-item-slider__list--desktop-4') ){
1305        var optInput = $.extend({}, opts['default'] ,opts['normal-item-slider__list--desktop-4'] )
1306      } else if ($sl.hasClass('normal-item-slider__list--desktop-3') ){
1307        var optInput = $.extend({}, opts['default'] ,opts['normal-item-slider__list--desktop-3'] )
1308      } else if ($sl.hasClass('compare-slider__list') ){
1309        var optInput = $.extend({}, opts['default'] ,opts['compare-slider__list'] )
1310      }
1311
1312      $sl.on('init', function(){
1313        $container.addClass('js-slick-loaded');
1314        removeAria($sl);
1315        removeLBRel($sl);
1316        setForReader($sl, $container);
1317        addPlayPauseBtn($sl, optInput);
1318        addPageNo($sl, optInput);
1319
1320
1321
1322		if($sl.hasClass("gov_index_slider")) {
1323		  // Do something if the element has the class
1324		 // alert("The element has the class 'example'");
1325		  $items.each(function() {
1326			  // Do something with each element
1327			//  alert($(this).attr("data-slick-index"));
1328			  $(this).find(".side-img-blk").attr("tabindex","-1");
1329			  $(this).find("iframe").attr("tabindex","-1");
1330			});
1331
1332		$items.eq(0).find(".side-img-blk").attr("tabindex","-1");
1333		$items.eq(0).find("iframe").attr("tabindex","0");
1334		}
1335
1336
1337        $items.eq( (optInput.initialSlide) ? optInput.initialSlide : 0 ).addClass('js-slick-changed');
1338
1339        //jsTyping Effect vtc-od
1340        // jsTypingEffect.init(arguments[1].$slides);
1341        // jsTypingEffect.type(arguments[1].$slides.eq(arguments[1].currentSlide).find('.js-typing'));
1342
1343        //video bg Effect vtc-od
1344        if(typeof jsVbg !== 'undefined'){
1345          jsVbg.play($items.eq(0));
1346        }
1347        // if($items.eq(0).find('.youtube-player').length){
1348        //   jsUtube.play($items.eq(0).find('.youtube-player')[0]);
1349        // }
1350        // imgMaxWidthHeight100.init($sl);
1351
1352        if(typeof jsDotDot !== 'undefined'){
1353          jsDotDot.init($sl, true);
1354          jsDotDot.update($sl);
1355        }
1356
1357      })
1358
1359      $sl.on('setPosition', function(){
1360        removeAria($sl);
1361        removeLBRel($sl);
1362        setForReader($sl, $container);
1363        // imgMaxWidthHeight100.init($sl);
1364        if(typeof jsDotDot !== 'undefined'){
1365         jsDotDot.update($sl);
1366        }
1367      })
1368
1369      $sl.on('swipe', function(){
1370        removeAria($sl);
1371        removeLBRel($sl);
1372        setForReader($sl, $container);
1373      })
1374
1375      $sl.on('afterChange', function(event, slick, currentSlide){
1376        removeAria($sl);
1377        removeLBRel($sl);
1378        setForReader($sl, $container);
1379
1380        if(typeof jsDotDot !== 'undefined'){
1381          jsDotDot.init($sl, true);
1382
1383          jsDotDot.init($sl);
1384          jsDotDot.update($sl);
1385        }
1386        slick.$slides.removeClass('js-slick-fading-out');
1387        slick.$slides.eq(currentSlide).addClass('js-slick-changed');
1388		slick.$slides.attr('aria-hidden','false');
1389        //slick.$slides.eq(currentSlide).attr('aria-hidden','true');
1390        // jsTypingEffect.type(slick.$slides.eq(currentSlide).find('.js-typing'));
1391
1392        if(typeof jsRipple !== 'undefined'){
1393          slick.$slides.filter('.js-ripple-slick-fade').find('.js-ripple-cover').remove();
1394        }
1395        if($sl.hasClass("js-sliding-point-event-none")){
1396          $(this).css({"pointer-events":"auto"})
1397        }
1398      });
1399
1400      $sl.on('beforeChange', function(event, slick, currentSlide, nextSlide){
1401
1402        slick.$slides.eq(currentSlide).addClass('js-slick-fading-out');
1403        slick.$slides.removeClass('js-slick-changed');
1404        // jsTypingEffect.destory(slick.$slides.eq(nextSlide).find('.js-typing'));
1405        // jsTypingEffect.init(slick.$slides.eq(nextSlide));
1406
1407        if(typeof jsVbg !== 'undefined'){
1408          jsVbg.play(slick.$slides.eq(nextSlide));
1409          jsVbg.pause(slick.$slides.eq(currentSlide));
1410        }
1411
1412        if(typeof jsRipple !== 'undefined' && slick.$slides.eq(currentSlide).hasClass('js-ripple-slick-fade')){
1413          var imgsrc = slick.$slides.eq(currentSlide).find('img').eq(0)[0].currentSrc;
1414
1415          var $ripple_elm = jsRipple.genRippleFrame(imgsrc, slick.$slides.eq(currentSlide));
1416
1417          $ripple_elm[0].jsRipple.centerRipple();
1418        }
1419
1420
1421		if($sl.hasClass("gov_index_slider")) {
1422			$items.eq(currentSlide).find(".side-img-blk").attr("tabindex","-1");
1423			$items.eq(currentSlide).find("iframe").attr("tabindex","-1");
1424			$items.eq(nextSlide).find(".side-img-blk").attr("tabindex","-1");
1425			$items.eq(nextSlide).find("iframe").attr("tabindex","0");
1426		}
1427
1428
1429        // if(slick.$slides.eq(currentSlide).find('.youtube-player').length){
1430        //   jsUtube.pause(slick.$slides.eq(currentSlide).find('.youtube-player')[0]);
1431        // }
1432
1433        // if(slick.$slides.eq(nextSlide).find('.youtube-player').length){
1434        //   jsUtube.play(slick.$slides.eq(nextSlide).find('.youtube-player')[0]);
1435        // }
1436        if($sl.hasClass("js-sliding-point-event-none")){
1437          $(this).css({"pointer-events":"none"})
1438        }
1439      });
1440
1441      $sl.on('reInit', function(){
1442        removeAria($sl);
1443        removeLBRel($sl);
1444        setForReader($sl, $container);
1445      });
1446
1447       $sl.on('edge', function(){
1448        removeAria($sl);
1449        removeLBRel($sl);
1450      });
1451
1452      if ($sl.hasClass('js-slick-slide-shown-update')) {
1453
1454        if(item_no <= 1 ){
1455          $sl.removeClass('js-slick-slide-shown-update');
1456        }
1457
1458        $sl.on('init', function() {
1459          imgLoaded($sl, function($imgs) {
1460            slideShowNoUpdate($sl);
1461
1462            var t = null;
1463            $(window)
1464              .off('resize.slide-shown-update')
1465              .on('resize.slide-shown-update', function() {
1466                if (t) {
1467                  clearTimeout(t);
1468                }
1469                t = setTimeout(function() {
1470                  slideShowNoUpdate($sl);
1471                }, 100)
1472              })
1473          })
1474        })
1475
1476        $sl.on('afterChange', function(){
1477          imgLoaded($sl, function($imgs) {
1478            slideShowNoUpdate($sl);
1479          })
1480        })
1481      }
1482
1483      // imgMaxWidthHeight100.init($sl);
1484
1485      if(jQuery.isEmptyObject(optInput)){return}
1486
1487      // Extra option part 2 , prevent opts not empty
1488      if( $sl.hasClass('idx-slides__list')) {
1489        optInput = $.extend({}, optInput, {
1490          appendArrows: $('.idx-slides__arrow'),
1491          dots: true,
1492          appendDots: $('.idx-slides__wrap')
1493        });
1494      }
1495
1496      if( $sl.hasClass('idx-slides__list')) {
1497        $(window).on('resize', function(){
1498          $sl.closest('.idx-slides__wrap').find('.idx-slides__arrow').css({
1499            'width': $(window).width() - $sl.closest('.idx-slides__container').offset().left + 3
1500          })
1501        }).resize();
1502      }
1503
1504
1505      if(isIE) {
1506        // optInput = $.extend({}
1506, optInput, {useCSS: false} )
1507      }
1508
1509      // --- End Extra option part 2 , prevent opts not empty
1510
1511      $container.removeClass('js-slick-before');
1512
1513      if(optInput['btnPlayPause']) {
1514        $container.addClass('js-add-pause-before');
1515      }
1516
1517      $container.addClass('slick-default-item-total-' + item_no);
1518
1519      $sl.slick(optInput)
1520      $sl.data('slickUp', true);
1521
1522    })
1523
1524    $(document).on('click', '.slick-pause', function() {
1525      $(this).removeClass('slick-pause icon-pause').addClass('slick-play icon-play');
1526	  var text;
1527	  if (getLang() == 'tc') {
1528        text = "播放"
1529      } else if (getLang() == 'sc') {
1530        text = "播放"
1531      } else {
1532        text = 'Play the slider'
1533      }
1534
1535	  $(this).find("span").text(text);
1536
1537      var $slick = $(this).closest('.js-slick-container ').find('.js-slick');
1538
1539      $slick.slick('slickPause');
1540
1541      var $slick_nav = $($slick[0].slick.options.asNavFor);
1542      if ($slick_nav.length) {
1543        $slick_nav.slick('slickPause');
1544      }
1545    });
1546
1547    $(document).on('click', '.slick-play', function() {
1548      $(this).removeClass('slick-play icon-play').addClass('slick-pause icon-pause');
1549	  var text;
1550      if (getLang() == 'tc') {
1551        text = "暫停"
1552      } else if (getLang() == 'sc') {
1553        text = "暂停"
1554      } else {
1555        text = 'Stop the slider'
1556      }
1557
1558	   $(this).find("span").text(text);
1559
1560      var $slick = $(this).closest('.js-slick-container ').find('.js-slick');
1561
1562      $slick.slick('slickPlay');
1563
1564      var $slick_nav = $($slick[0].slick.options.asNavFor);
1565      if ($slick_nav.length) {
1566        $slick_nav.slick('slickPlay');
1567      }
1568    });
1569
1570    $(document).on('click', '.slick-dots button', function() {
1571      var $c = $(this).closest('.js-slick-container '),
1572        $pause = $c.find('.slick-pause');
1573      if (!$pause.length) {
1574        return
1575      }
1576      $pause.trigger('click');
1577    });
1578
1579    $(document).on('mouseenter', '.js-slick-itm, .slick-arrow', function() {
1580      $(this).closest('.js-slick-container').addClass('js-slick-itm-hovered');
1581    });
1582
1583    $(document).on('mouseleave', '.js-slick-itm, .slick-arrow', function() {
1584      $(this).closest('.js-slick-container').removeClass('js-slick-itm-hovered');
1585    });
1586
1587
1588    triggerButtonSetup();
1589
1590    additionalSetting();
1591
1592    setLBTrigger();
1593  }
1594
1595  function removeAria($_slick_el){
1596    var $slick = $_slick_el;
1597    $slick.find('[aria-describedby]').removeAttr('aria-describedby')
1598    setTimeout(function(){$slick.find('[aria-describedby]').removeAttr('aria-describedby')}, 100)
1599  }
1600
1601  function removeLBRel($_slick){
1602    var $slick = $_slick;
1603    $slick.find('.slick-cloned').find('.js-lb').removeAttr('data-rel').removeClass('cboxElement');
1604  }
1605
1606  function setForReader($_slick, $_slick_container){
1607    var $slick = $_slick,
1608        $itms = $slick.find('.slick-slide'),
1609        $itms__ori = $itms.not('.slick-cloned'),
1610        $arrow = $_slick_container.find('.slick-arrow'),
1611        $all = $slick.find('*');
1612
1613    setTimeout(function(){
1614      // $itms__ori.removeAttr('aria-hidden');
1615      // $arrow.attr('aria-hidden', 'true');
1616    }, 50)
1617  }
1618
1619
1620  function addPlayPauseBtn($_sl, optInput) {
1621    var text;
1622	/*
1623    if (getLang() == 'tc') {
1624      text = "播放 / 暫停"
1625    } else if (getLang() == 'sc') {
1626      text = "播放 / 暂停"
1627    } else {
1628      text = 'Play / Stop the slider'
1629    }
1630	*/
1631
1632
1633    // currently do not support custom dot
1634    var $sl = $_sl,
1635      $container = $sl.closest('.js-slick-container');
1636
1637    $container.find('.slick-dots-container').remove();
1638    if (optInput['btnPlayPause'] === true) {
1639	  if (getLang() == 'tc') {
1640        text = "暫停"
1641      } else if (getLang() == 'sc') {
1642        text = "暂停"
1643      } else {
1644        text = 'Stop the slider'
1645      }
1646
1647      setTimeout(function() {
1648        var $dotC = $container.find('.slick-dots'),
1649        //  $doc_w = $('<div aria-hidden="true" class="slick-dots-container" role="toolbar"/>'),
1650		$doc_w = $('<div class="slick-dots-container" role="toolbar"/>'),
1651          btn__type = ($_sl[0].slick.paused === false) ? 'slick-pause icon-pause' : 'slick-play icon-play';
1652        $playpause = $('<div class="slick-pause-play"><button class="slick-pause-play-btn ' + btn__type + '"><span class="sr-only">' + text + '</span></button></div>');
1653
1654
1655        //$doc_w.attr('aria-hidden', true);
1656
1657        $dotC.css('display', '');
1658
1659        $doc_w.append($dotC, $playpause);
1660        $sl.after($doc_w);
1661
1662        $container.removeClass('js-add-pause-before');
1663      }, 0)
1664    }
1665  }
1666
1667
1668  function addPageNo($_sl, optInput){
1669
1670    var seperateor = '/';
1671
1672    setTimeout(function(){
1673       if(optInput['pageNo'] === true){
1674          var $sl = $_sl,
1675          $container = $sl.closest('.js-slick-container'),
1676          slick = $sl[0].slick,
1677          currentIdx = slick.currentSlide + 1,
1678          total = slick.slideCount;
1679
1680          var $pageWrap = $('<div class="js-slick-pageNo" aria-hidden="true">' + currentIdx + seperateor + total  + '</div>');
1681          $container.append($pageWrap);
1682
1683          $sl
1684            .off('beforeChange.currentSlide')
1685            .on('beforeChange.currentSlide', function(event, slick, currentSlide, nextSlide){
1686                $pageWrap.html((nextSlide + 1) + seperateor + total)
1687          })
1688       }
1689     }, 50)
1690    // currently do not support custom dot
1691  }
1692
1693  $(document).ready(function(){
1694    $('.slick-dots-container').slick({
1695      dots: true,
1696      infinite: true,
1697      speed: 300,
1698      slidesToShow: 1,
1699      adaptiveHeight: true
1700    });
1701
1702    $('.slick-dots-container').on('init', function(event, slick){
1703      adjustDots();
1704    });
1705
1706    $(window).on('resize', function(){
1707      adjustDots();
1708    });
1709
1710    $(window).on('load', function(){
1711      adjustDots();
1712    });
1713
1714    function adjustDots() {
1715      let maxWidth = 350;
1716      let dots = $('.slick-dots li');
1717      let containerWidth = $('.slick-dots').width();
1718      let dotWidth = dots.outerWidth(true);
1719      let dotsPerRow = Math.floor(containerWidth / dotWidth);
1720
1721      if ($(window).width() <= maxWidth) {
1722        $('.slick-dots').css('display', 'flex');
1723        $('.slick-dots').css('flex-wrap', 'wrap');
1724        dots.each(function(index, dot) {
1725          if ((index + 1) % dotsPerRow == 0) {
1726            $(dot).css('margin-right', '0');
1727          } else {
1728            $(dot).css('margin-right', '0.5rem');
1729          }
1730        });
1731      } else {
1732        $('.slick-dots').css('display', 'block');
1733        dots.css('margin-right', '0.5rem');
1734      }
1735    }
1736
1737    $(window).resize(function(){
1738      $('.ev-blk__title-section').each(function(i) {
1739        const titleHeight = $(this).height();
1740        $('.ev-blk__main').each(function(j) {
1741          if (i == j) {
1742            $(this).css("padding-top", (titleHeight+8))
1743          }
1744        })
1745      });
1746
1747      $('.video-sec__title-block').each(function(i) {
1748        const _this = this;
1749        const titleHeight = $(this).height();
1750        $(_this).css("width", $('.video-sec__item').first().width() - $('.video-sec__img').first().width() - $('.video-sec__number').width() - 35);
1751        $('.video-sec__text').each(function(j) {
1752          if (i == j) {
1753            $(this).css("padding-top", (titleHeight))
1754          }
1755        })
1756        $('.video-sec__img').each(function(k) {
1757          const imgWidth = $(this).width();
1758          if (i == k) {
1759            if ($(window).width() <= 750) {
1760              $(_this).css("left", -($('.video-sec__item').first().width() - imgWidth - $('.video-sec__number').width() - 5));
1761              if (window.location.pathname.includes('/gov-job')) {
1762                const parentElement = $(this).closest('.video-sec__content');
1763                const timeElement = parentElement.find('.label-title-blk__time');
1764
1765                if (timeElement.length > 0) {
1766                    $(_this).css("right", (timeElement.width() + 10));
1767                }
1768              } else {
1769                $(_this).css("right", "");
1770              }
1771            } else {
1772              const pathname = window.location.pathname;
1773              if(pathname.includes('/gov-job')) {
1774                if($( window ).width() > 1100 && $(window ).width() < 1366) {
1775                  $(_this).css("right", (imgWidth + 30));
1776                }else if($(window ).width() >= 1366 ) {
1777                  $(_this).css("right", (imgWidth + 50));
1778                }else {
1779                  $(_this).css("right", (imgWidth));
1780                }
1781              }else {
1782                $(_this).css("right", (imgWidth + 10));
1783              }
1784
1785              $(_this).css("left", "");
1786            }
1787          }
1788        })
1789      });
1790
1791      $('.side-img-blk__title').each(function(i) {
1792        const titleHeight = $(this).height();
1793        $('.side-img-blk__content-side').each(function(j) {
1794          if (i == j) {
1795            if ($(window).width() <= 750) {
1796              $(this).css("padding-top", (titleHeight+35));
1797            } else {
1798              $(this).css("padding-top", (titleHeight+5));
1799            }
1800          }
1801        })
1802      });
1803    })
1804  });
1805
1806  function triggerButtonSetup(){
1807    var $triggerList = $('.js-slick-other-trigger a');
1808    $triggerList.on('click', function(e){
1809      e.preventDefault();
1810      e.stopPropagation();
1811      var $btn = $(this),
1812          $list = $btn.closest('.js-slick-other-trigger');
1813
1814      var $target = $($list.attr('data-js-slick-target')),
1815          index = $btn.closest('li').index();
1816
1817      if($target.length && $target.data('slickUp')){
1818        $target.slick('slickGoTo', index);
1819      }
1820    })
1821  }
1822
1823
1824  // subscription page
1825	function validateEmailAddress(email) {
1826    const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1827    return emailRegex.test(String(email).toLowerCase());
1828	}
1829
1830	$('#subscribe-button').click(function(){
1831	   var pathname = window.location.pathname;
1832	   var lang=getShortLang();
1833	   var email=$('#email-address').val();
1834	   $('#subscription-form').attr('action', pathname);
1835	   var response = grecaptcha.getResponse();
1836	   //if ($('#robot-verification').prop("checked") == true) {
1837
1838			if (email=="" && !validateEmailAddress(email)) {
1839				if (lang=="en") {
1840					alert("Please input a valid email address");
1841				} else {
1842					alert("請輸入有效的電子郵件地址");
1843				}
1844				return false;
1845			}else {
1846				if (response.length != 0){
1847					 $('#subscription-form').attr('action', pathname);
1848					$("#subscription-form" ).submit();
1849				}else{
1850					//e.preventDefault();
1851				   $(".g-recaptcha > div").css("border","1px solid red");
1852				   if (lang=="en") {
1853						alert("Please complete robot-verification ");
1854					} else {
1855						alert("請完成機械人驗證");
1856					}
1857				   return false;
1858				}
1859			}
1860
1861	   //} else {
1862		//    if (lang=="en") {
1863		//		alert("Please check 'I am not a robot'");
1864		//	} else {
1865		//		alert("請按 'I am not a robot'");
1866		//	}
1867		//	return false;
1868	   //}
1869	});
1870
1871	$('#submit-button').click(function(){
1872	   var pathname = window.location.pathname;
1873	   var lang=getShortLang();
1874	   var email=$('#email-address').val();
1875	   $('#subscription-form').attr('action', pathname);
1876	   //if ($('#robot-verification').prop("checked") == true) {
1877
1878			if (email=="" && !validateEmailAddress(email)) {
1879				if (lang=="en") {
1880					alert("Please input a valid email address");
1881				} else {
1882					alert("請輸入有效的電子郵件地址");
1883				}
1884				return false;
1885			}else {
1886				$('#subscription-form').attr('action', pathname);
1887				$("#subscription-form" ).submit();
1888			}
1889	});
1890
1891
1892  function slideShowNoUpdate($_slick){
1893    // bug if change to center mode
1894    // if(jsQueryTest.isMobile()){return}
1895
1896    var $slick = $_slick,
1897        $container = $slick.closest('.js-slick-container'),
1898        container_w = $container.width(),
1899        $itms = $slick.find('.slick-current').add($slick.find('.slick-current').nextAll()),
1900
1901        slick = $slick[0].slick,
1902        number = 0,
1903        total_width = 0;
1904
1905       do {
1906          total_width += $itms.eq(number).outerWidth();
1907           number += 1;
1908        } while (total_width < container_w && number < $itms.length);
1909
1910        if(total_width > container_w){
1911            number = number - 1;
1912            $container.removeClass('hideFade');
1913        } else {
1914            $container.addClass('hideFade');
1915        }
1916
1917        if(number == 0) {
1918          number++;
1919        }
1920
1921        $slick
1922        .slick('slickSetOption', "slidesToShow", number, true)
1923
1924        $slick.removeClass('js-slick-slide-shown-update')
1925  }
1926
1927
1928  function additionalSetting(){
1929    var t = null;
1930
1931    // $(window).on('resize load', function(){
1932    //   if(t){
1933    //     clearTimeout(t);
1934    //   }
1935
1936    //   t = setTimeout(function(){
1937    //     jsUtube.position($('.js-slick-itm .youtube-player'));
1938    //   }, 100)
1939    // }).resize();
1940
1941    // $(document).on('click', '.idxbanner__text-wrap', function(e){
1942    //   var $textwrap = $(this),
1943    //       $slickItm = $textwrap.closest('.js-slick-itm'),
1944    //       $youtube = $slickItm.find('.youtube-player');
1945
1946    //   if($youtube.length) {
1947    //     jsUtube.play($youtube[0])
1948    //   }
1949    // })
1950  }
1951
1952
1953  function setLBTrigger(){
1954    $(document).on('click', '.js-slick-lb-trigger', function(e){
1955      e.preventDefault();
1956      var $trigger = $(this);
1957      var targetID = $trigger.attr("href");
1958
1959
1960      $(targetID).trigger('click');
1961    })
1962  }
1963
1964  return {
1965    init: setup,
1966    reInit: setup
1967  }
1968}());
1969
1970
1971var jsHeader = (function () {
1972
1973  var $header,
1974    $body,
1975    $moremenu,
1976    $pageMenu,
1977    isIndex,
1978    $placeholder,
1979    $selected,
1980    $pageMenuList,
1981    $mobScrollBtn,
1982    $scroller,
1983    timer,
1984    selectedLeft,
1985    mobOpenSearch,
1986    listScrollReady;
1987
1988  function setup() {
1989
1990    $header = $('.page-head');
1991    $body = $('body');
1992    $moremenu = $('.menu-dropdown, .header-search-dropdown');
1993    $pageMenu = $('.page-menu');
1994
1995    $selected = $(".selected")
1996    $pageMenuList = $(".page-menu__list, .index-menu__list")
1997    $mobScrollBtn = $(".js-mob-header-scroll-btn")
1998    $scroller = $(".page-menu__scroller")
1999    mobOpenSearch = false;
2000    listScrollReady = false;
2001
2002    isIndex = $body.hasClass('page-index');
2003
2004    $header.on('mouseenter', function (e) {
2005      $body.addClass('js-header-active');
2006    }).on('mouseleave', function (e) {
2007      $body.removeClass('js-header-active');
2008    });
2009
2010    $moremenu.on('show.bs.dropdown', function (e) {
2011      $body.addClass('js-header-menu-opened');
2012    });
2013
2014    $moremenu.on('hide.bs.dropdown', function (e) {
2015      var $drop = $(this);
2016      if (!$drop.hasClass('dontClose')) {
2017        $body.removeClass('js-header-menu-opened');
2018      }
2019    });
2020
2021    //detect has scrollbar
2022    (function ($) {
2023      $.fn.hasScrollBar = function () {
2024        return this.get(0).scrollWidth > this.width() + 2;
2025      }
2026    })(jQuery);
2027
2028    $(window).on('load resize', function (e) {
2029      $body.addClass('header-placeholder-setup');
2030
2031      if ($(window).outerWidth() >= 768) {
2032        setMenuTop()
2033      }
2034    });
2035
2036    scrollAction();
2037
2038    $(window).on('scroll', function (e) {
2039      if (timer) {
2040        window.clearTimeout(timer);
2041      }
2042
2043      scrollAction();
2044    });
2045
2046    checkMenuScroolLeft();
2047
2048    if ($selected.length) {
2049      $(window).on('load', function () {
2050        selectedLeft = $selected.position().left ;
2051
2052        if(selectedLeft + $selected.outerWidth() > $pageMenuList.width()){
2053          $pageMenuList.animate({
2054            scrollLeft: selectedLeft - $mobScrollBtn.eq(0).width()
2055          }, afterScroll);
2056        }
2057
2058      })
2059      if (!Modernizr.touchevents) {
2060        $(window).on('resize', function (e) {
2061          selectedLeft = $selected.position().left
2062          if(selectedLeft + $selected.outerWidth() > $pageMenuList.width()){
2063            $pageMenuList.animate({
2064              scrollLeft: selectedLeft - $mobScrollBtn.eq(0).width()
2065            }, afterScroll);
2066          }
2067        });
2068      }
2069    } else {
2070      $pageMenuList.on('scroll', function () {
2071        if(!$('body').hasClass('page-index')){
2072          $mobScrollBtn.addClass('hide')
2073        }
2074        $scroller.removeClass("at-last")
2075      });
2076      listScrollReady = true;
2077    }
2078
2079    $pageMenuList.on('scroll', function () {
2080      checkMenuScroolLeft()
2081    })
2082  }
2083
2084  function checkMenuScroolLeft(e) {
2085    if (!$pageMenuList.length || !$pageMenuList.hasScrollBar()) { return; }
2086    var nowLeft;
2087    nowLeft = $pageMenuList.scrollLeft()
2088
2089    var ele = document.querySelectorAll(".page-menu__list,.index-menu__list")[0]
2090    var atLast = Math.floor(ele.scrollWidth - $(ele).width())
2091    if (nowLeft >= atLast) {
2092      $scroller.removeClass("before-show")
2093    } else {
2094      $scroller.addClass("before-show")
2095    }
2096    if (!listScrollReady) {
2097      $mobScrollBtn.removeClass('hide')
2098      if (nowLeft >= atLast) {
2099        $scroller.addClass("at-last")
2100      } else {
2101        $scroller.removeClass("at-last")
2102      }
2103    }
2104  }
2105
2106  function afterScroll() {
2107    checkMenuScroolLeft()
2108    setTimeout(function () {
2109      $pageMenuList.stop().on('scroll', function () {
2110        $mobScrollBtn.addClass('hide')
2111        $scroller.removeClass("at-last")
2112      });
2113      listScrollReady = true;
2114    }, 200);
2115  }
2116  function setMenuTop() {
2117    var $clone = $header.clone().addClass('js-temp-clone').css({
2118      'top': -300,
2119      'visibility': 'hidden'
2120    }).insertBefore($header);
2121
2122    var h_height = $clone.outerHeight();
2123    // $pageMenu.css('top', h_height);
2124
2125    $clone.remove();
2126  }
2127
2128  function scrollAction() {
2129    if ($(window).scrollTop() > 0 && !$body.hasClass('page-scrolled')) {
2130      $body.removeClass('page-no-scrolled');
2131      $body.addClass('page-scrolled');
2132      if ($pageMenu.length) {
2133        setMenuTop();
2134      }
2135    } else if ($(window).scrollTop() == 0 && $body.hasClass('page-scrolled')) {
2136      $body.addClass('page-no-scrolled');
2137      $body.removeClass('page-scrolled');
2138      if ($pageMenu.length) {
2139        setMenuTop();
2140      }
2141
2142      setMenuTop();
2143    }
2144  }
2145
2146  function getMenuTop() {
2147    var $clone = $header.clone().addClass('js-temp-clone').css({
2148      'top': -300,
2149      'visibility': 'hidden'
2150    }).insertBefore($header);
2151
2152    var h_height = $clone.outerHeight();
2153
2154    $clone.remove();
2155
2156    return h_height;
2157  }
2158
2159  function getMenuHeight() {
2160    var $menu = $(".page-menu")
2161    var $clone = $menu.clone().addClass('js-temp-clone').css({
2162      'top': -300,
2163      'visibility': 'hidden'
2164    }).insertBefore($menu);
2165
2166    var m_height = $clone.outerHeight() ?? 0;
2167
2168    $clone.remove();
2169
2170    return m_height;
2171
2172  }
2173  function getLongerHeight() {
2174    $body.addClass("page-no-scrolled").removeClass('page-scrolled')
2175
2176    var longerMenuTop = (getMenuTop()) ? getMenuTop() : 0;
2177    var longerMenuHeight = (getMenuHeight()) ? getMenuHeight() : 0;
2178    var longerHeight = longerMenuTop + longerMenuHeight;
2179
2180    // var longerHeight = getMenuTop() + getMenuHeight()
2181    // var longerMenuTop = getMenuTop()
2182    // var longerMenuHeight = getMenuHeight()
2183
2184
2185    if ($(window).scrollTop() > 0 && !$body.hasClass('page-scrolled')) {
2186      $body.removeClass('page-no-scrolled');
2187      $body.addClass('page-scrolled');
2188    } else if ($(window).scrollTop() == 0 && $body.hasClass('page-scrolled')) {
2189      $body.addClass('page-no-scrolled');
2190      $body.removeClass('page-scrolled');
2191    }
2192
2193    return {
2194      longerHeight: longerHeight,
2195      longerMenuTop: longerMenuTop,
2196      longerMenuHeight: longerMenuHeight
2197    }
2198
2199
2200  }
2201
2202
2203  return {
2204    init: setup,
2205    getMenuTop: getMenuTop,
2206    getMenuHeight: getMenuHeight
2207  }
2208}())
2209var jsHeaderSearch = (function(){
2210
2211  var isTouch = Modernizr.touchevents,
2212      clickEvent = (isTouch) ? 'touchstart' : 'click',
2213      $search_block,
2214      $input,
2215      $btn,
2216      $body,
2217      $close;
2218
2219  function setup(){
2220    $search_block = $('.sitesearch'),
2221    $input = $('.sitesearch__input'),
2222    $btn = $('.sitesearch__trigger'),
2223    $body = $('body'),
2224    $close = $('.sitesearch__close');
2225
2226    $btn.on(clickEvent, function(e){
2227      e.preventDefault();
2228      e.stopImmediatePropagation();
2229      $search_block.toggleClass('js-active');
2230      $body.toggleClass('js-header-search-opened');
2231      if($search_block.hasClass('js-active')){
2232          setTimeout(function(){
2233            $input.focus();
2234          }, 80)
2235      }
2236    })
2237
2238    $search_block.on(clickEvent, function(e){
2239      e.stopImmediatePropagation();
2240    })
2241
2242    $close.on(clickEvent, function(e){
2243      e.preventDefault();
2244      $search_block.removeClass('js-active');
2245      $body.removeClass('js-header-search-opened');
2246      $btn.focus();
2247    })
2248
2249    $(document).on('click', function(e){
2250      $search_block.removeClass('js-active');
2251      $body.removeClass('js-header-search-opened');
2252    })
2253
2254     $(document).on('keydown.menuQuit' ,function(e){
2255        if(ckEsc(e) && $search_block.hasClass('js-active')){
2256          $search_block.removeClass('js-active');
2257          $body.removeClass('js-header-search-opened');
2258          if($input.is(':focus')){
2259            $btn.focus();
2260          }
2261        }
2262      });
2263
2264  }
2265
2266
2267  return {
2268    init: setup
2269  }
2270}());
2271
2272function trim_text(target) {
2273  var tdotext = target.text().substring(0, 600).split(" ");
2274  if (tdotext.length > 20) {
2275	  try {
2276		target.text(tdotext.slice(0, tdotext.length - 2).join(" ") + "...");
2277	  } catch {};
2278  } else {
2279	  try {
2280		target.text(tdotext.join(" "));
2281	  } catch {};
2282  }
2283}
2284
2285var jsDotDot2 = (function(){
2286  var $dot;
2287  function setup($_container, _loadtheLater){
2288
2289    var $c = ($_container) ? $_container : $('body');
2290
2291    $dot = $('.js-dot', $c);
2292
2293    $dot.each(function(){
2294
2295      var $tdot = $(this);
2296
2297      // Function to detect Chinese characters
2298      function containsChinese(text) {
2299        return /[\u4e00-\u9fff\u3400-\u4dbf\uf900-\ufaff]/.test(text);
2300      }
2301
2302      // Get text content and check for Chinese characters
2303      var textContent = $tdot.text();
2304      var hasChinese = containsChinese(textContent);
2305
2306      // Use letter-based truncation if Chinese characters are detected
2307      var truncateMode = hasChinese ? 'letter' : langArg({'en': 'word', 'tc': 'letter', 'sc': 'letter'});
2308
2309      var opt = {
2310        watch: "window",
2311        truncate: truncateMode,
2312        tolerance: 3
2313      }
2314
2315      if($tdot.is('.js-dot-maycht')){
2316        opt = $.extend({}, opt, {
2317          truncate: 'letter'
2318        })
2319      }
2320
2321      if($tdot.is('.js-dot-later') && !_loadtheLater){
2322        return;
2323      }
2324
2325      if($tdot.is('.js-dot-node')){
2326        opt = $.extend({}, opt, {
2327          truncate: 'node'
2328        })
2329      }
2330
2331      try{
2332        new Dotdotdot($tdot[0], opt );
2333      } catch(err) {
2334      }
2335    })
2336  }
2337
2338
2339  return {
2340    init: setup
2341
2342  }
2343}());
2344// only one search input per page
2345
2346
2347var typingTimer;
2348var doneTypingInterval = 500;
2349var $input = $('#search-input-text');
2350var $input2 = $('#search-input-text-inpage');
2351var $input3 = $('#mob-search-input-text') ;
2352//on keyup, start the countdown
2353$input.on('keyup', function (e) {
2354  var keycode = (e.keyCode ? e.keyCode : e.which);
2355  if(keycode == '13'){ $(this).parent().find(".search-input__submit").click();} // For press enter search
2356  clearTimeout(typingTimer);
2357  typingTimer = setTimeout(doneTyping, doneTypingInterval);
2358});
2359$input2.on('keyup', function (e) {
2360  var keycode = (e.keyCode ? e.keyCode : e.which);
2361  if(keycode == '13'){ $(this).parent().find(".search-input__submit").click();} // For press enter search
2362  clearTimeout(typingTimer);
2363  typingTimer = setTimeout(doneTyping2, doneTypingInterval);
2364});
2365$input3.on('keyup', function (e) {
2366  var keycode = (e.keyCode ? e.keyCode : e.which);
2367  if(keycode == '13'){ $(this).parent().find(".search-input__submit").click();} // For press enter search
2368  clearTimeout(typingTimer);
2369  typingTimer = setTimeout(doneTyping3, doneTypingInterval);
2370});
2371//on keydown, clear the countdown
2372$input.on('keydown', function () {
2373  $( "div" ).remove( ".tt-menu" );
2374  clearTimeout(typingTimer);
2375});
2376$input2.on('keydown', function () {
2377  $( "div" ).remove( ".tt-menu" );
2378  clearTimeout(typingTimer);
2379});
2380$input3.on('keydown', function () {
2381  $( "div" ).remove( ".tt-menu" );
2382  clearTimeout(typingTimer);
2383});
2384
2385//user is "finished typing," do something
2386function doneTyping () {
2387	let $typeahead = $('.search-dropdown__inner .js-typeahead') ,
2388		$btn = $('.search-dropdown__inner .js-clear-btn'),
2389		$searchBlk = $(".search-dropdown__inner .js-search-input"),
2390		searchUrl = '' ;
2391	checkinput($typeahead.val(),$btn);
2392	lang=getShortLang();
2393	searchUrl = $typeahead.data('suggestpath');
2394	searchUrl = searchUrl.replace('{lang}', lang);
2395//	searchUrl = searchUrl.replace('{keyword}', $("#search-input-text").val().replace(/ /g,"+"));
2396	searchUrl = searchUrl.replace('{keyword}', $typeahead.val());
2397	$.ajax({
2398
2399	  url: searchUrl //jsp path
2400	}).fail(function(data){
2401		console.log("failed!");
2402	}).done(function (data) {
2403	  $( "div" ).remove( ".search-dropdown__inner .tt-menu" ) ;
2404	  $( "div" ).remove( ".mob-menu-search .search-dropdown__inner .tt-menu" ) ;
2405	   $searchBlk.append(data);
2406	   $('.search-dropdown__inner .tt-menu:last-child').show() ;
2407	})
2408	function checkinput(i,$_b){
2409		if ($.trim(i) != "") {
2410		  $_b.removeClass("hide");
2411		} else {
2412		  $_b.addClass("hide");
2413		}
2414	}
2415}
2416function doneTyping2 () {
2417	let $typeahead = $('.search-result-inpage .js-typeahead') ,
2418		$btn = $('.search-result-inpage .js-clear-btn'),
2419		$searchBlk = $(".search-result-inpage .js-search-input"),
2420		searchUrl = '' ;
2421	checkinput($typeahead.val(),$btn);
2422	lang=getShortLang();
2423	searchUrl = $typeahead.data('suggestpath');
2424	searchUrl = searchUrl.replace('{lang}', lang);
2425//	searchUrl = searchUrl.replace('{keyword}', $("#search-input-text").val().replace(/ /g,"+"));
2426	searchUrl = searchUrl.replace('{keyword}', $typeahead.val());
2427	$.ajax({
2428
2429	  url: searchUrl //jsp path
2430	}).fail(function(data){
2431		console.log("failed!");
2432	}).done(function (data) {
2433	  $( "div" ).remove( ".search-result-inpage .tt-menu" ) ;
2434	   $searchBlk.append(data);
2435	   $('.search-result-inpage .tt-menu:last-child').show() ;
2436	})
2437	function checkinput(i,$_b){
2438		if ($.trim(i) != "") {
2439		  $_b.removeClass("hide");
2440		} else {
2441		  $_b.addClass("hide");
2442		}
2443	}
2444}
2445function doneTyping3 () {
2446	let $typeahead = $('.mob-menu-search .search-dropdown__inner .js-typeahead') ,
2447		$btn = $('.mob-menu-search .search-dropdown__inner .js-clear-btn'),
2448		$searchBlk = $(".mob-menu-search .search-dropdown__inner .js-search-input"),
2449		searchUrl = '' ;
2450	checkinput($typeahead.val(),$btn);
2451	lang=getShortLang();
2452	searchUrl = $typeahead.data('suggestpath');
2453	searchUrl = searchUrl.replace('{lang}', lang);
2454//	searchUrl = searchUrl.replace('{keyword}', $("#search-input-text").val().replace(/ /g,"+"));
2455	searchUrl = searchUrl.replace('{keyword}', $typeahead.val());
2456	$.ajax({
2457
2458	  url: searchUrl //jsp path
2459	}).fail(function(data){
2460		console.log("failed!");
2461	}).done(function (data) {
2462	  $( "div" ).remove( ".mob-menu-search .search-dropdown__inner .tt-menu" ) ;
2463	   $searchBlk.append(data);
2464	   $('.mob-menu-search .search-dropdown__inner .tt-menu:last-child').show() ;
2465	})
2466	function checkinput(i,$_b){
2467		if ($.trim(i) != "") {
2468		  $_b.removeClass("hide");
2469		} else {
2470		  $_b.addClass("hide");
2471		}
2472	}
2473}
2474
2475 $( document ).ready(function() {
2476    if($('.search-result-inpage #search-input-text-inpage').val() != "" ){
2477		$('.search-result-inpage .js-clear-btn').removeClass("hide");
2478	}
2479});
2480$('.ico-search').click(function () {
2481	$( "div" ).remove( ".tt-menu" ) ;
2482	if($(".header-wrap__right>.search-blk").hasClass("show")){
2483		$('.search-result-inpage .js-typeahead').val("") ;
2484	} else {
2485		$('.search-dropdown__inner .js-typeahead').val("") ;
2486	}
2487}) ;
2488$('.js-clear-btn').click(function () {
2489	var $this_btn = $(this);
2490	if( $this_btn.is( ".search-dropdown__inner .js-clear-btn" ) ){
2491		$( "div" ).remove( ".search-dropdown__inner .tt-menu" );
2492		$('.search-dropdown__inner .js-typeahead').val("") ;
2493		$this_btn.removeClass("show").addClass("hide");
2494	} else {
2495		$( "div" ).remove( ".search-result-inpage .tt-menu" );
2496		$('.search-result-inpage .js-typeahead').val("") ;
2497		$this_btn.removeClass("show").addClass("hide");
2498	}
2499}) ;
2500
2501
2502function searchSuggestion(keyword){
2503	console.log( keyword.textContent);
2504	$('.js-typeahead').val(keyword.textContent) ;
2505}
2506
2507// var jsTypeahead = (function() {
2508  // var $typeahead,
2509      // $btn,
2510      // $searchBlk,
2511      // searchUrl,
2512      // clearUrl
2513
2514      // text = {
2515        // tc: {
2516     //     header: '最新搜尋',
2517     //     footer: '清除紀錄'
2518        // },
2519        // sc: {
2520     //     header: '最新搜寻',
2521      //    footer: '清除纪录'
2522        // }
2523
2524      // }
2525
2526  // function setup() {
2527    // $typeahead = $('.js-typeahead');
2528    // $btn = $('.js-clear-btn');
2529    // $searchBlk = $(".js-search-input");
2530    // searchUrl = '';
2531  //  clearUrl = '/search/suggest-clear';
2532
2533	// lang=getShortLang();
2534    // if($typeahead.data('suggestpath')){
2535      // searchUrl = $typeahead.data('suggestpath');
2536	  // searchUrl = searchUrl.replace('{lang}', lang);
2537	  // searchUrl = searchUrl.replace('{keyword}', $("#search-input-text").val());
2538    // }
2539
2540    // var searchKeywords = new Bloodhound({
2541        // identify: function(obj) { return obj.name; },
2542        // datumTokenizer: Bloodhound.tokenizers.whitespace,
2543        // queryTokenizer: Bloodhound.tokenizers.whitespace,
2544         // remote: {
2545          // url: searchUrl
2546        // }
2547    // });
2548
2549    // $typeahead.typeahead({
2550      // highlight: true,
2551      // hint: false,
2552      // minLength: 1,
2553      // limit: 'Infinity'
2554    // }, {
2555      // name: 'keywords',
2556   //   displayKey: 'name', //setting the value of the input control after a suggestion is selected
2557   //   source: searchHistory,
2558      // source: searchKeywords,
2559      // limit: 'Infinity'
2560
2561
2562    // $typeahead.on('typeahead:open', function(e){
2563      // showhideItm();
2564    // })
2565
2566    // $typeahead.on('typeahead:render', function(e){
2567      // showhideItm();
2568    // })
2569
2570    // $typeahead.on('typeahead:close', function(e){
2571     // $typeahead.closest('.search-dropdown').closest('.search-dropdown').removeClass('js-typeahead-suggestion-open');
2572    // })
2573
2574
2575    // $typeahead.on('keyup', function(e){
2576      // showhideItm();
2577    // })
2578
2579    // $typeahead.each(function () {
2580      // var $this_input = $(this)
2581      // var inputVal = $this_input.val()
2582      // var $this_btn = $this_input.closest($searchBlk).find($btn)
2583
2584      // checkinput(inputVal,$this_btn);
2585    // })
2586
2587    // $typeahead.on('load change keyup paste', function () {
2588      // var $this_input = $(this)
2589      // var inputVal = $this_input.val()
2590      // var $this_btn = $this_input.closest($searchBlk).find($btn)
2591
2592      // checkinput(inputVal,$this_btn);
2593    // })
2594
2595    // $btn.click(function () {
2596        // var $this_btn = $(this);
2597        // var $this_typeahead = $(this).closest($searchBlk).find($typeahead);
2598
2599        // $this_typeahead.typeahead('val', null);
2600
2601        // $this_btn.removeClass("show").addClass("hide");
2602    // })
2603  // }
2604
2605
2606  // function showhideItm(){
2607    // var $wrapper = $typeahead.closest('.search-dropdown');
2608      // if($wrapper.find('.tt-dataset').children().length){
2609        // $wrapper.closest('.search-dropdown').addClass('js-typeahead-suggestion-open');
2610      // }else {
2611        // $wrapper.closest('.search-dropdown').removeClass('js-typeahead-suggestion-open');
2612      // }
2613  // }
2614  // function checkinput(i,$_b){
2615    // if ($.trim(i) != "") {
2616      // $_b.removeClass("hide");
2617    // } else {
2618      // $_b.addClass("hide");
2619    // }
2620  // }
2621
2622
2623  // return {
2624    // init: setup
2625  // };
2626// }());
2627
2628
2629if(typeof $.fn.equalizeHeights !== 'function') {
2630  $.fn.equalizeHeights = function() {
2631    var maxHeight = this.map(function( i, e ) {
2632      return $( e ).height();
2633    }).get();
2634    return this.height( Math.max.apply( this, maxHeight ) );
2635  };
2636}
2637
2638var jsSyncHeight = function(){
2639
2640  var t;
2641
2642  function setup(){
2643    if(!$('.js-sync-height').length){return;}
2644    $(window).on('resize.jsSyncHeight', function(){
2645        if(t){
2646          clearTimeout(t);
2647        }
2648
2649        t = setTimeout(function(){
2650          syncHeight();
2651        }, 120);
2652
2653    });
2654
2655    syncHeight();
2656  }
2657
2658  function syncHeight(){
2659    var $boxes = $('.js-sync-height');
2660    removeInlineHeight()
2661    // $boxes.css('height', '');
2662    $boxes.each(function(){
2663      var $b = $(this);
2664      var offset = $b.offset().top;
2665      var $sameHeightBox = $boxes.filter(function(){
2666        return $(this).offset().top == offset;
2667      });
2668     $sameHeightBox.equalizeHeights();
2669    });
2670    if (screen.width >= 768 && $('.js-sync-height-focus').length) {
2671      $('.js-sync-height-focus').height($('.shadow-card-blk').height());
2672    }
2673  }
2674
2675  function removeInlineHeight(){
2676     $('.js-sync-height').css('height', 'auto');
2677  }
2678
2679  return {
2680    init: setup,
2681    removeInline: removeInlineHeight
2682  };
2683}();
2684var jsBsModal = (function(){
2685
2686  function setup(){
2687        $('.modal').appendTo($('body'));
2688
2689        $('.modal').on('show.bs.modal', function(){
2690          var $modal = $(this);
2691          if($modal.hasClass('js-bs-hash') && $modal.data('bs-hash')){
2692            window.location.hash = $modal.data('bs-hash');
2693          }
2694
2695          if($modal.hasClass('js-bs-modal-full')) {
2696            $('body').addClass('js-bs-modal-full-open');
2697          }
2698        });
2699
2700
2701        $('.modal').on('hide.bs.modal', function(){
2702          var $modal = $(this);
2703          if($modal.hasClass('js-bs-modal-full')) {
2704            $('body').removeClass('js-bs-modal-full-open');
2705          }
2706        });
2707
2708
2709        var hash = window.location.hash;
2710        if(hash) {
2711          var hashData = hash.replace('#', '');
2712
2713          if(hashData !== "!"){
2714            var $target = $('.modal').filter('[data-bs-hash='+ hashData +']');
2715            $target.modal('show');
2716          }
2717        }
2718  }
2719
2720  return {
2721    init: setup
2722  }
2723}());
2724var jsScrollReveal = (function(){
2725
2726  var options = {
2727    'default': {
2728      distance: '50px',
2729      duration: 1500,
2730      scale: 1,
2731      opacity: 0,
2732      easing: 'cubic-bezier(0.23, 1, 0.32, 1)',
2733      viewFactor: .4,
2734      beforeReveal: sr__BeforeReveal,
2735      afterReveal: sr__AfterReveal,
2736      viewOffset: {
2737        left: -300,
2738        right: -300
2739      }
2740    },
2741    'type-outIn': {
2742      scale: 0.6,
2743      distance: '0px'
2744    },
2745    'type-inOut': {
2746      scale: 1.3,
2747      distance: '0px'
2748    },
2749    'type-down': {
2750      origin: 'top',
2751    },
2752    'type-left': {
2753      origin: jsQueryTest.argF({'mobile': 'bottom', 'tablet': 'left', 'desktop': 'left', 'wide': 'left'})
2754    },
2755    'type-scale-down': {
2756      scale: 1.6,
2757      distance: '0px'
2758    },
2759    'type-right': {
2760      origin: jsQueryTest.argF({'mobile': 'bottom', 'tablet': 'right', 'desktop': 'right', 'wide': 'right'})
2761    },
2762    'type-rotate': {
2763      rotate: { x: 0, y: 90, z: 0 },
2764    },
2765    'type-opacity': {
2766      distance: '0px'
2767    },
2768    'type-viewed-all': {
2769      viewFactor: 1,
2770      delay: 200,
2771    }
2772  },
2773  delay = 200,
2774  viewFactorPixel = 100;
2775
2776  function setup($_c, activeUnloaded){
2777
2778    if(isIE && isIE < 11) {
2779      return;
2780    }
2781
2782    var $c = ($_c) ? $_c : $('body'),
2783        w_height = $(window).height();
2784
2785    var $allReveal = $('.js-reveal', $c),
2786        $revel__single =  $allReveal.not('.js-reveal--groups-itm'),
2787        $revel__grouped = $allReveal.filter('.js-reveal--groups-itm');
2788
2789    if(typeof window.sr == 'undefined') {
2790      window.sr = ScrollReveal();
2791    }
2792
2793    if(!activeUnloaded) {
2794      $allReveal = $allReveal.filter(':not(.js-reveal--unloaded)');
2795    }
2796
2797    $allReveal.each(function(){
2798      var $sr = $(this),
2799          opt = $.extend({}, options['default']);
2800
2801         // view factor
2802      opt = $.extend({}, opt ,
2803        {
2804          viewFactor: ($sr.height() < $(window).height()) ? .4 : viewFactorPixel/$sr.height()
2805        }
2806      );
2807
2808      if($sr.data('reveal-type')){
2809        var type = $sr.data('reveal-type');
2810        type = type.split(',');
2811        $.each(type, function(i, v){
2812          opt = $.extend({}, opt,
2813           options['type-' + v.trim()]
2814          );
2815        });
2816      }
2817
2818      if($sr.hasClass('js-reveal--mobile-height') &&  jsQueryTest.isMobile()){
2819        opt = $.extend({}, opt ,
2820          {
2821            viewFactor:  .2
2822          }
2823        );
2824      }
2825
2826      // enchance for delay with item has same offset
2827      if($sr.hasClass('js-reveal--groups-itm')){
2828        opt = $.extend({}, opt, {'delay':  delay* $sr.index()});
2829      }
2830      if($sr.hasClass('all-gov-pos') || $sr.hasClass('govjob-table') || $sr.hasClass('ajax-reveal-item')){ // updated for long ajax reveal item
2831		opt = $.extend({}, opt ,{ viewFactor: 0.03});
2832      }
2833
2834        sr.reveal( $sr[0], opt);
2835        $sr.addClass('js-reveal--setuped')
2836    });
2837
2838
2839    $(document).on('click touchstart', '.js-reveal--uninit, .js-reveal--uninit * ', function(e){
2840        e.stopPropagation();
2841        e.preventDefault();
2842        return false;
2843    });
2844  }
2845
2846  function sr__BeforeReveal(domEl) {
2847    var $d = $(domEl);
2848
2849    $d.removeClass('js-reveal--uninit');
2850
2851    if($d.find('.js-counting').length){
2852      $d.find('.js-counting').each(function(){
2853        if($(this).is(':visible')){
2854          jsCounter.play($(this));
2855        }
2856      });
2857    }
2858
2859  }
2860
2861  function sr__AfterReveal(domEl) {
2862    var $d = $(domEl);
2863    $d.removeClass('js-reveal--setuped');
2864    $d.attr('style', '');
2865  }
2866
2867  return {
2868    init: setup
2869  };
2870}());
2871var jsMobileMenu = (function () {
2872
2873  function setup() {
2874
2875    var $body = $('body'),
2876      $wrapper = $('.wrapper'),
2877      $menu__modal = $('#mobile-menu');
2878    $trigger = $('#mobile-menu-trigger')
2879
2880    $menu__modal.on('show.bs.modal', function (event) {
2881      $body.addClass('mobile-slideIn');
2882    });
2883
2884    //for srceen reader
2885    $menu__modal.on('shown.bs.modal', function (event) {
2886      $(this).find('.mobile-menu__close').focus()
2887    });
2888
2889    $menu__modal.on('hidden.bs.modal', function (event) {
2890      $body.removeClass("mobile-slideIn")
2891    });
2892
2893    // #mobile-menu is hidden on load with the `d-none` class
2894    // (display: none !important) so it doesn't flash before JS runs. Bootstrap's
2895    // modal show() writes a plain inline `display: block` (WITHOUT !important)
2896    // asynchronously in _showElement, which strips the !important that the show
2897    // helpers apply and lets `.d-none` win — so the menu never appears. Re-assert
2898    // an !important inline display the moment the `show` class lands (and restore
2899    // the hidden state when it's removed) so the inline style can override d-none.
2900    if ($menu__modal.length) {
2901      var menuDisplayEl = $menu__modal[0],
2902        syncMobileMenuDisplay = function () {
2903          if (menuDisplayEl.classList.contains('show')) {
2904            menuDisplayEl.style.setProperty('display', 'block', 'important');
2905          } else {
2906            menuDisplayEl.style.setProperty('display', 'none', 'important');
2907          }
2908        },
2909        menuDisplayObserver = new MutationObserver(syncMobileMenuDisplay);
2910
2911      menuDisplayObserver.observe(menuDisplayEl, {
2912        attributes: true,
2913        attributeFilter: ['class']
2914      });
2915    }
2916
2917    $(window).on('resize', function () {
2918      if (!jsQueryTest.isSM() && !jsQueryTest.isXS() && $menu__modal.hasClass('show')) {
2919        $(".mobile-menu__close").click()
2920      }
2921    });
2922
2923	$menu__modal.find('.i-arrow-down').attr("aria-expanded","false");
2924
2925    $trigger.click(function () {
2926      $this = $(this)
2927      t_target = $this.data('target')
2928    })
2929
2930
2931    $menu__modal.find('.i-arrow-down').on('click', function (e) {
2932      e.preventDefault();
2933      e.stopPropagation();
2934
2935      var $this = $(this),
2936        $itm = $this.closest('li');
2937
2938	  if($this.attr("aria-expanded") == "false") {
2939		$this.attr("aria-expanded","true");
2940	  } else {
2941		$this.attr("aria-expanded","false");
2942	  }
2943
2944      if ($itm.hasClass('mb-active')) {
2945        $itm.removeClass('mb-active');
2946        $itm.find('> ul').stop(true).animate({ height: 0, opacity: 0 }, 300, function () {
2947          $(this).css({ 'height': 'auto', 'opacity': '' });
2948          this.style.setProperty('display', 'none', 'important');
2949        });
2950      } else {
2951        $itm.addClass('mb-active');
2952        var $subList = $itm.find('> ul');
2953        $subList.each(function () {
2954          this.style.setProperty('display', 'block', 'important');
2955        });
2956        var subListHeight = $subList.prop('scrollHeight');
2957        $subList.stop(true).css({ height: 0, opacity: 0 }).animate({ height: subListHeight, opacity: 1 }, 300, function () {
2958          $(this).css({ 'height': 'auto', 'opacity': '' });
2959        });
2960      }
2961    })
2962  }
2963
2964  return {
2965    init: setup
2966  }
2967}())
2968var jsLoadMore = (function ($__outer, __fn) {
2969  var $loadO,
2970    $loadC,
2971    $loadB,
2972    $loadBtn,
2973    flag = 0,
2974    loadNum,
2975    loadMoreStartReady = true,
2976    isSrcset = Modernizr.srcset,
2977    isMasonry,
2978	customSortType = "sortEndDate",
2979    ajaxPage = 0,
2980    ajaxDefaultPage = null,
2981    isAjax = false,
2982    ajaxPath = null;
2983
2984  var loadremoOptions = {
2985    imgLoadingTimeout: 20000,
2986    itemsDelay: 100
2987  }
2988
2989
2990  var textString = {
2991    'en': 'New added items',
2992    'tc': '新加事項',
2993    'sc': 'New added items'
2994  }
2995
2996  function setup(_opts, callback) {
2997    $loadO = $__outer;
2998    $loadC = $('.js-loadmore-container', $loadO);
2999    $loadB = $('.js-loadmore-backup', $loadO);
3000    $loadBtn = $('.js-loadmore-btn', $loadO);
3001    loadNum = parseInt($loadC.data('loadmore'));
3002    ajaxPath = $loadC.data('loadmore-ajax');
3003    isAjax = (ajaxPath) ? true : false;
3004    ajaxDefaultPage = $loadC.data('loadmore-ajax-page');
3005	var ajaxType = $loadC.data('loadmore-ajax-type');
3006
3007	lang=getShortLang();
3008
3009    if (ajaxDefaultPage) {
3010      ajaxPage = ajaxDefaultPage;
3011    }
3012
3013	console.log("ajaxDefaultPage=["+ajaxDefaultPage+"]");
3014	console.log("ajaxType=["+ajaxType+"]");
3015
3016    if (_opts) {
3017      loadremoOptions = $.extend({}, loadremoOptions, _opts)
3018    }
3019
3020    if (!$loadC.length) { return }
3021
3022    if ($loadC.hasClass('js-mas') || $loadC.hasClass('js-jg-container')) {
3023      loadMoreStartReady = false;
3024    }
3025
3026	/*YP Revamp start*/
3027	if (ajaxDefaultPage==0) {
3028		ajaxPage=0;
3029		if(ajaxType == "typeGovJob") {
3030			loadGovJobRecuitContent();
3031		  } else if (ajaxType == "typeCalculator") {
3032			loadCalculatorContent();
3033		  } else if (ajaxType == "typeActivityList") {
3034			 loadActivitiesContent();
3035		  } else if (ajaxType == "typeFeatureArticleList") {
3036			 loadFeatureArticleContent();
3037		  } else if (ajaxType == "typeCareer") {
3038			 loadCareerContent();
3039		  } else if (ajaxType == "typeSearch") {
3040			 loadSearchContent();
3041		  } else if (ajaxType == "typeGovJobCareer") {
3042			 loadGovJobCareerContent();
3043		  } else if (ajaxType == "typeCourse") {
3044
3045			params = getUrlParams (window.location.href);
3046
3047			// handle industry
3048			if (params["industry"] != null && params["industry"] !="") {
3049				var paramIndustryString = params["industry"];
3050				var paramIndustryArray = paramIndustryString.split(",");
3051				console.log("param industry = ["+paramIndustry+"]");
3052				var inputIndex=-1;
3053				var inputLabel="";
3054
3055				for (var i = 0; i < paramIndustryArray.length; i++) {
3056					var paramIndustry = paramIndustryArray[i].trim();
3057
3058					$( ".filter-bar__blk .checkbox-label" ).each(function( index ) {
3059						var tmpLabel = $( this ).text();
3060
3061						if (tmpLabel.toLowerCase() == paramIndustry.toLowerCase() ) {
3062							console.log( index + ": " + $( this ).text() );
3063							inputIndex=index;
3064							if(i == 0){
3065								inputLabel+=tmpLabel;
3066							}else{
3067								inputLabel+= ", " + tmpLabel;
3068							}
3069						}
3070
3071					});
3072
3073					$( ".filter-bar__blk .checkbox-input" ).each(function( index ) {
3074						if (inputIndex==index) {
3075							$( this ).prop("checked", true);
3076						}
3077					});
3078				}
3079				if (inputIndex!=-1) {
3080						$("#sys_industry").html(inputLabel);
3081					}
3082			}
3083
3084			// handle institution
3085			if (params["institution"] != null && params["institution"] !="") {
3086				var paramInstitutionString = params["institution"];
3087				var paramInstitutionArray = paramInstitutionString.split(",");
3088				console.log("param institution = ["+paramInstitution+"]");
3089				var inputIndex=-1;
3090				var inputLabel="";
3091
3092				for (var i = 0; i < paramInstitutionArray.length; i++) {
3093					var paramInstitution = paramInstitutionArray[i].trim();
3094
3095					$( ".filter-bar__blk .checkbox-label" ).each(function( index ) {
3096						var tmpLabel = $( this ).text();
3097
3098						if (tmpLabel.toLowerCase() == paramInstitution.toLowerCase() ) {
3099							console.log( index + ": " + $( this ).text() );
3100							inputIndex=index;
3101							if(i == 0){
3102								inputLabel+=tmpLabel;
3103							}else{
3104								inputLabel+= ", " + tmpLabel;
3105							}
3106						}
3107
3108					});
3109
3110					$( ".filter-bar__blk .checkbox-input" ).each(function( index ) {
3111						if (inputIndex==index) {
3112							$( this ).prop("checked", true);
3113						}
3114					});
3115				}
3116				if (inputIndex!=-1) {
3117						$("#sys_institution").html(inputLabel);
3118					}
3119			}
3120
3121			// handle studymode
3122			if (params["studymode"] != null && params["studymode"] !="") {
3123				var paramStudymodeString = params["studymode"];
3124				var paramStudymodeArray = paramStudymodeString.split(",");
3125				console.log("param studymode = ["+paramStudymode+"]");
3126				var inputIndex=-1;
3127				var inputLabel=""
3128
3129				for (var i = 0; i < paramStudymodeArray.length; i++) {
3130					var paramStudymode = paramStudymodeArray[i].trim();
3131
3132					$( ".filter-bar__blk .checkbox-label" ).each(function( index ) {
3133						var tmpLabel = $( this ).text();
3134
3135						if (tmpLabel.toLowerCase() == paramStudymode.toLowerCase() ) {
3136							console.log( index + ": " + $( this ).text() );
3137							inputIndex=index;
3138							if(i == 0){
3139								inputLabel+=tmpLabel;
3140							}else{
3141								inputLabel+= ", " + tmpLabel;
3142							}
3143						}
3144
3145					});
3146
3147					$( ".filter-bar__blk .checkbox-input" ).each(function( index ) {
3148						if (inputIndex==index) {
3149							$( this ).prop("checked", true);
3150						}
3151					});
3152				}
3153				if (inputIndex!=-1) {
3154						$("#sys_studymode").html(inputLabel);
3155					}
3156			}
3157
3158			loadCourseContent();
3159
3160		  } else if (ajaxType == "typeCommonNoFilter") {
3161			 loadCommonNoFilterContent();
3162		  }
3163	}
3164	/*YP Revamp end*/
3165
3166    $('#sys_gov_job_search').on("click",function(e){
3167		e.preventDefault();
3168		ajaxDefaultPage=0;
3169		ajaxPage=0;
3170		console.log("[$loadBtn.show()]");
3171		$loadBtn.show();
3172		$('.js-loadmore-container').html("");
3173		$('.js-loadmore-backup').html("");
3174		if(ajaxType == "typeGovJob") {
3175			loadGovJobRecuitContent();
3176		} else if (ajaxType == "typeCalculator") {
3177			loadCalculatorContent();
3178		} else if (ajaxType == "typeCareer") {
3179		    loadCareerContent();
3180	  } else if (ajaxType == "typeSearch") {
3181		 loadSearchContent();
3182		} else if (ajaxType == "typeGovJobCareer") {
3183		    loadGovJobCareerContent();
3184		} else if (ajaxType == "typeCourse") {
3185		    loadCourseContent();
3186		}
3187
3188	})
3189
3190	$('.sys_fund_sort').on("click",function(e){
3191		e.preventDefault();
3192		//$(this).prop("checked", true);
3193		$('#sys_fund_sort_btn').text($(this).next().text()) ;
3194		// $('.sys_fund_sort').removeAttr('abc');
3195		// $('.sys_fund_sort:checked').attr('abc','true');
3196
3197		customSortType = this.data("sort-type");
3198		ajaxDefaultPage=0;
3199		ajaxPage=0;
3200		console.log("[$loadBtn.show()]");
3201		$loadBtn.show();
3202		$('.js-loadmore-container').html("");
3203		$('.js-loadmore-backup').html("");
3204		if (ajaxType == "typeCalculator") {
3205			loadCalculatorContent();
3206		}
3207	})
3208
3209    $('#sys_gov_job_reset').on('click', function (e) {
3210		e.preventDefault();
3211		if(ajaxType == "typeGovJob") {
3212			if (lang=="tc") {
3213				$("#sys_dept").html("全部政府部門");
3214				$("#sys_req").html("聘用條款");
3215				$("#sys_education").html("學歷要求");
3216				$("#sys_salary").html("薪酬");
3217			} else {
3218				$("#sys_dept").html("All government department");
3219				$("#sys_req").html("Terms of appointment");
3220				$("#sys_education").html("Academic qualification requirement");
3221				$("#sys_salary").html("Salary");
3222
3223				/*$("#sys_dept").html("All Department");
3224				$("#sys_req").html("Terms of Appointment");
3225				$("#sys_education").html("Academic Qualification Requirement");
3226				$("#sys_salary").html("Salary"); */
3227			}
3228		} else if (ajaxType == "typeCourse") {
3229			if (lang=="tc") {
3230				$("#sys_industry").html("所有行業");
3231				$("#sys_job").html("所有職位");
3232				$("#sys_institution").html("所有院校");
3233				$("#sys_studymode").html("所有學制");
3234			} else {
3235				$("#sys_industry").html("All Industries");
3236				$("#sys_job").html("All Jobs");
3237				$("#sys_institution").html("All Institutions");
3238				$("#sys_studymode").html("All Study Modes");
3239			}
3240			$("#sys_fundKey").val("");
3241		} else if (ajaxType == "typeCalculator") {
3242			if (lang=="tc") {
3243				$("#sys_fundType").html("全部資助類型");
3244				$("#sys_fundRange").html("全部資助金額");
3245				$("#sys_fundStatus").html("全部申請狀況");
3246			} else {
3247				$("#sys_fundType").html("Types of Support scheme");
3248				$("#sys_fundRange").html("Funding amount");
3249				$("#sys_fundStatus").html("Status of the Funds");
3250			}
3251			$("#sys_fundKey").val("");
3252		}
3253		$(".filter-bar__blk .checkbox-input").prop("checked", false);
3254		$(".promo-row-blk__filter-blk  .checkbox-input").prop("checked", false);
3255
3256	})
3257
3258
3259    $loadBtn.on('click', function (e) {
3260      e.preventDefault();
3261	  if(ajaxType == "typeGovJob") {
3262		loadGovJobRecuitContent();
3263	  } else if (ajaxType == "typeCalculator") {
3264		loadCalculatorContent();
3265	  } else if (ajaxType == "typeActivityList") {
3266		loadActivitiesContent();
3267	  } else if (ajaxType == "typeFeatureArticleList") {
3268		 loadFeatureArticleContent();
3269	  } else if (ajaxType == "typeCareer") {
3270		 loadCareerContent();
3271	  } else if (ajaxType == "typeGovJobCareer") {
3272		 loadGovJobCareerContent();
3273	  } else if (ajaxType == "typeSearch") {
3274		 loadSearchContent();
3275	  } else if (ajaxType == "typeCommonNoFilter") {
3276		 loadCommonNoFilterContent();
3277	  } else if (ajaxType == "typeCourse") {
3278		 loadCourseContent();
3279	  } else if (ajaxType == "typeHashtag") {
3280		 loadHashtagContent();
3281	  }
3282    })
3283
3284
3285    if ($loadC.hasClass('js-loadmore-scorll')) {
3286      $(window).on('scroll.jsloadmore', function (e) {
3287        var $btn = $('.js-loadmore-btn');
3288        if (!$btn.length) { return }
3289        var scrolled = $(window).scrollTop();
3290        if ($btn.offset().top <= scrolled + $(window).height()) {
3291          $btn.click();
3292        }
3293      })
3294    }
3295
3296    $loadC.data('loadmore-options', loadremoOptions);
3297  }
3298 function loadCareerContent() {
3299		console.log("[loadCareerContent] start");
3300		var sel_careerType=$("#sys_careerType").html().trim();
3301		if (sel_careerType=="選擇行業類別" || sel_careerType=="选择行业类别" || sel_careerType=="全部行業類別" || sel_careerType=="全部行业类别" || sel_careerType.toLowerCase()=="Types of the Career".toLowerCase() || sel_careerType.toLowerCase()=="All of Career Types".toLowerCase()) {
3302			sel_careerType="";
3303		} else {
3304			var selTmpArray = sel_careerType.split(",");
3305			var selTmp="";
3306			for (var i=0;i<selTmpArray.length;i++) {
3307				var tmpKey = selTmpArray[i].trim();
3308				if (selTmp!="") {
3309					selTmp+=",";
3310				}
3311				selTmp += industryKeyMap[tmpKey];
3312			}
3313			sel_careerType=selTmp;
3314		}
3315
3316		console.log("sys_careerType="+sel_careerType);
3317
3318		if (flag == 1 || !loadMoreStartReady) { return }
3319		flag = 1;
3320		$loadBtn.addClass('js-loadmore-loading');
3321		ajaxPage++;
3322
3323		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3324		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3325		  l_ajaxPath=l_ajaxPath.replace('{careerType}', sel_careerType);
3326
3327		  console.log("l_ajaxPath="+l_ajaxPath);
3328
3329		  if (isAjax) {
3330			$.ajax({
3331			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3332			}).fail(function(data){
3333				console.log("failed!");
3334			}).done(function (data) {
3335			  //console.log(data);
3336			  $loadB.append(data);
3337			  moveBk();
3338			  appendParamLink();
3339			  jsDotDot2.init(".js-loadmore-new-item");
3340			  jsSelectTwo.init(addNew = true);
3341			  jsLazyLoad.init()
3342			})
3343		  } else {
3344			moveBk();
3345			jsDotDot2.init(".js-loadmore-new-item");
3346			jsSelectTwo.init(addNew = true);
3347			jsLazyLoad.init()
3348		  }
3349
3350		console.log("[loadCareerContent] end");
3351
3352  }
3353
3354  function loadGovJobCareerContent() {
3355		console.log("[loadCareerContent] start");
3356		var sel_careerType=$("#sys_careerType").html().trim();
3357		if (sel_careerType=="選擇政府部門" || sel_careerType=="选择政府部门" || sel_careerType=="全部政府部門" || sel_careerType=="全部政府部门" || sel_careerType.toLowerCase()=="Select Gov Job Department".toLowerCase() || sel_careerType.toLowerCase()=="All Gov Job Department".toLowerCase()) {
3358			sel_careerType="";
3359		} else {
3360			var selTmpArray = sel_careerType.split(",");
3361			var selTmp="";
3362			for (var i=0;i<selTmpArray.length;i++) {
3363				var tmpKey = selTmpArray[i].trim();
3364				if (selTmp!="") {
3365					selTmp+=",";
3366				}
3367				selTmp += departmentKeyMap[tmpKey];
3368			}
3369			sel_careerType=selTmp;
3370		}
3371
3372		//console.log("sys_careerType="+sel_careerType);
3373
3374		if (flag == 1 || !loadMoreStartReady) { return }
3375		flag = 1;
3376		$loadBtn.addClass('js-loadmore-loading');
3377		ajaxPage++;
3378
3379		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3380		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3381		  l_ajaxPath=l_ajaxPath.replace('{careerType}', sel_careerType);
3382
3383		 // console.log("l_ajaxPath="+l_ajaxPath);
3384
3385		  if (isAjax) {
3386			$.ajax({
3387			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3388			}).fail(function(data){
3389				console.log("failed!");
3390			}).done(function (data) {
3391			  $loadB.append(data);
3392			  moveBk();
3393			  appendParamLink();
3394			  jsDotDot2.init(".js-loadmore-new-item");
3395			  jsSelectTwo.init(addNew = true);
3396			  jsLazyLoad.init()
3397			   if ($(data).hasClass("js-loadmore-dummy")) {
3398				$loadBtn.show();
3399			  } else {
3400				$loadBtn.hide();
3401			  }
3402			})
3403		  } else {
3404			moveBk();
3405			jsDotDot2.init(".js-loadmore-new-item");
3406			jsSelectTwo.init(addNew = true);
3407			jsLazyLoad.init()
3408		  }
3409
3410		console.log("[loadCareerContent] end");
3411
3412  }
3413
3414
3415   function loadCommonNoFilterContent() {
3416		console.log("[loadCommonNoFilterContent] start");
3417
3418		var ajaxSection = $loadC.data('loadmore-section');
3419
3420		if (flag == 1 || !loadMoreStartReady) { return }
3421		flag = 1;
3422		$loadBtn.addClass('js-loadmore-loading');
3423		ajaxPage++;
3424
3425		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3426		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3427
3428		  console.log("l_ajaxPath="+l_ajaxPath);
3429
3430		  if (isAjax) {
3431			$.ajax({
3432			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3433			}).fail(function(data){
3434				console.log("failed!");
3435			}).done(function (data) {
3436			  //alert(data);
3437			  $loadB.append(data);
3438			  moveBk();
3439
3440			  //show load more if exists
3441			   if ($(data).hasClass("js-loadmore-dummy")) {
3442				$loadBtn.show();
3443			  } else {
3444				$loadBtn.hide();
3445			  }
3446			  appendParamLink();
3447
3448			  jsDotDot2.init(".js-loadmore-new-item");
3449			  jsSelectTwo.init(addNew = true);
3450			  jsLazyLoad.init()
3451
3452			})
3453		  } else {
3454			moveBk();
3455			jsDotDot2.init(".js-loadmore-new-item");
3456			jsSelectTwo.init(addNew = true);
3457			jsLazyLoad.init()
3458		  }
3459
3460		console.log("[loadCommonNoFilterContent] end");
3461
3462  }
3463
3464
3465
3466 function loadFeatureArticleContent() {
3467		console.log("[loadFeatureArticleContent] start");
3468
3469		var ajaxSection = $loadC.data('loadmore-section');
3470
3471		if (flag == 1 || !loadMoreStartReady) { return }
3472		flag = 1;
3473		$loadBtn.addClass('js-loadmore-loading');
3474		ajaxPage++;
3475
3476		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3477		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3478		  l_ajaxPath=l_ajaxPath.replace('{section}
3478', ajaxSection);
3479
3480		  console.log("l_ajaxPath="+l_ajaxPath);
3481
3482		  if (isAjax) {
3483			$.ajax({
3484			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3485			}).fail(function(data){
3486				console.log("failed!");
3487			}).done(function (data) {
3488			  //alert(data);
3489			  $loadB.append(data);
3490			  moveBk();
3491
3492			  //show load more if exists
3493			  if ($(data).hasClass("js-loadmore-dummy")) {
3494				$loadBtn.show();
3495			  } else {
3496				$loadBtn.hide();
3497			  }
3498			  appendParamLink();
3499
3500			  jsDotDot2.init(".js-loadmore-new-item");
3501			  jsSelectTwo.init(addNew = true);
3502			  jsLazyLoad.init()
3503
3504			})
3505		  } else {
3506			moveBk();
3507			jsDotDot2.init(".js-loadmore-new-item");
3508			jsSelectTwo.init(addNew = true);
3509			jsLazyLoad.init()
3510		  }
3511
3512		console.log("[loadFeatureArticleContent] end");
3513
3514  }
3515
3516  function loadHashtagContent() {
3517		console.log("[loadHashtagContent] start");
3518
3519		var ajaxHashtag = $loadC.data('loadmore-hashtag');
3520
3521		if (flag == 1 || !loadMoreStartReady) { return }
3522		flag = 1;
3523		$loadBtn.addClass('js-loadmore-loading');
3524		ajaxPage++;
3525
3526		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3527		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3528		  l_ajaxPath=l_ajaxPath.replace('{hashtag}', ajaxHashtag);
3529
3530		  console.log("l_ajaxPath="+l_ajaxPath);
3531
3532		  if (isAjax) {
3533			$.ajax({
3534			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3535			}).fail(function(data){
3536				console.log("failed!");
3537			}).done(function (data) {
3538			  //alert(data);
3539			  $loadB.append(data);
3540			  moveBk();
3541
3542			  //show load more if exists
3543			  if ($(data).hasClass("js-loadmore-dummy")) {
3544				$loadBtn.show();
3545			  } else {
3546				$loadBtn.hide();
3547			  }
3548			  appendParamLink();
3549
3550			  jsDotDot2.init(".js-loadmore-new-item");
3551			  jsSelectTwo.init(addNew = true);
3552			  jsLazyLoad.init()
3553
3554			})
3555		  } else {
3556			moveBk();
3557			jsDotDot2.init(".js-loadmore-new-item");
3558			jsSelectTwo.init(addNew = true);
3559			jsLazyLoad.init()
3560		  }
3561
3562		console.log("[loadHashtagContent] end");
3563
3564  }
3565 function loadActivitiesContent() {
3566		console.log("[loadActivitiesContent] start");
3567
3568		var ajaxSection = $loadC.data('loadmore-section');
3569
3570		if (flag == 1 || !loadMoreStartReady) { return }
3571		flag = 1;
3572		$loadBtn.addClass('js-loadmore-loading');
3573		ajaxPage++;
3574
3575		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3576		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3577		  l_ajaxPath=l_ajaxPath.replace('{section}', ajaxSection);
3578
3579		  console.log("l_ajaxPath="+l_ajaxPath);
3580
3581		  if (isAjax) {
3582			$.ajax({
3583			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3584			}).fail(function(data){
3585				console.log("failed!");
3586			}).done(function (data) {
3587			  //alert(data);
3588			  $loadB.append(data);
3589			  moveBk();
3590
3591			  //show load more if exists
3592			  if ($(data).hasClass("js-loadmore-dummy")) {
3593				$loadBtn.show();
3594			  } else {
3595				$loadBtn.hide();
3596			  }
3597			  appendParamLink();
3598
3599			  jsDotDot2.init(".js-loadmore-new-item");
3600			  jsSelectTwo.init(addNew = true);
3601			  jsLazyLoad.init()
3602
3603			})
3604		  } else {
3605			moveBk();
3606			jsDotDot2.init(".js-loadmore-new-item");
3607			jsSelectTwo.init(addNew = true);
3608			jsLazyLoad.init()
3609		  }
3610
3611		console.log("[loadActivitiesContent] end");
3612
3613  }
3614
3615  function loadSearchContent() {
3616		console.log("[loadSearchContent] start");
3617		var sel_keyword=$loadC.data('loadmore-keyword');
3618		console.log("sel_keyword="+sel_keyword);
3619
3620		if (flag == 1 || !loadMoreStartReady) { return }
3621		flag = 1;
3622		$loadBtn.addClass('js-loadmore-loading');
3623		ajaxPage++;
3624
3625		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3626		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3627		  l_ajaxPath=l_ajaxPath.replace('{keyword}', sel_keyword);
3628
3629		  console.log("l_ajaxPath="+l_ajaxPath);
3630
3631		  if (isAjax) {
3632			$.ajax({
3633			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3634			}).fail(function(data){
3635				console.log("failed!");
3636			}).done(function (data) {
3637			  //alert(data);
3638			  $loadB.append(data);
3639			  moveBk();
3640			  appendParamLink();
3641			  jsDotDot2.init(".js-loadmore-new-item");
3642			  jsSelectTwo.init(addNew = true);
3643			  jsLazyLoad.init()
3644
3645			})
3646		  } else {
3647			moveBk();
3648			jsDotDot2.init(".js-loadmore-new-item");
3649			jsSelectTwo.init(addNew = true);
3650			jsLazyLoad.init()
3651		  }
3652
3653		console.log("[loadSearchContent] end");
3654
3655  }
3656
3657
3658  function loadGovJobRecuitContent() {
3659		console.log("[loadGovJobContent] start");
3660		var sel_dept=$("#sys_dept").html().trim();
3661		if (sel_dept=="全部政府部門" || sel_dept=="全部政府部门" || sel_dept.toLowerCase()=="All government department".toLowerCase()) {
3662			sel_dept="";
3663		} else {
3664      var selTmpArray = [];
3665      $("#sys_dept").parent().find("input:checked").each(function(){
3666        selTmpArray.push($(this).parent().find("span").html())
3667      });
3668			// var selTmpArray = sel_dept.split(",");
3669			var selTmp="";
3670			for (var i=0;i<selTmpArray.length;i++) {
3671				var tmpKey = selTmpArray[i].trim();
3672				if (selTmp!="") {
3673					selTmp+=",";
3674				}
3675				selTmp += departmentKeyMap[tmpKey];
3676			}
3677			sel_dept=selTmp;
3678		}
3679
3680		var sel_req=$( "#sys_req" ).html().trim();
3681		if (sel_req=="聘用條款" || sel_req=="聘用条款" || sel_req.toLowerCase()=="Terms of appointment".toLowerCase()) {
3682			sel_req="";
3683		} else {
3684			var selTmpArray = sel_req.split(",");
3685			var selTmp="";
3686			for (var i=0;i<selTmpArray.length;i++) {
3687				var tmpKey = selTmpArray[i].trim();
3688				if (selTmp!="") {
3689					selTmp+=",";
3690				}
3691				selTmp += employmentKeyMap[tmpKey];
3692			}
3693			sel_req=selTmp;
3694		}
3695
3696		var sel_education=$( "#sys_education" ).html().trim();
3697		if (sel_education=="學歷要求" || sel_education=="学历要求" || sel_education.toLowerCase()=="Academic qualification requirement".toLowerCase()) {
3698			sel_education="";
3699		} else {
3700			var selTmpArray = sel_education.split(",");
3701			var selTmp="";
3702			for (var i=0;i<selTmpArray.length;i++) {
3703				var tmpKey = selTmpArray[i].trim();
3704				if (selTmp!="") {
3705					selTmp+=",";
3706				}
3707				selTmp += educationKeyMap[tmpKey];
3708			}
3709			sel_education=selTmp;
3710		}
3711
3712		var sel_salary=$( "#sys_salary" ).html().trim();
3713		if (sel_salary=="薪酬" || sel_salary.toLowerCase()=="Salary".toLowerCase()) {
3714			sel_salary="";
3715		}
3716
3717		console.log("sys_dept="+sel_dept);
3718		console.log("sel_req="+sel_req);
3719		console.log("sel_education="+sel_education);
3720		console.log("sel_salary="+sel_salary);
3721
3722		if (flag == 1 || !loadMoreStartReady) { return }
3723		flag = 1;
3724		$loadBtn.addClass('js-loadmore-loading');
3725		ajaxPage++;
3726
3727		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3728		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3729		  l_ajaxPath=l_ajaxPath.replace('{req}', sel_req);
3730		  l_ajaxPath=l_ajaxPath.replace('{education}', sel_education);
3731		  l_ajaxPath=l_ajaxPath.replace('{salary}', sel_salary);
3732		  l_ajaxPath=l_ajaxPath.replace('{dept}', sel_dept);
3733
3734		  console.log("l_ajaxPath="+l_ajaxPath);
3735
3736		  if (isAjax) {
3737			$.ajax({
3738			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3739			}).fail(function(data){
3740				console.log("failed!");
3741			}).done(function (data) {
3742			  //alert(data);
3743			  $loadB.append(data);
3744			  moveBk();
3745			  appendParamLink();
3746			  jsDotDot2.init(".js-loadmore-new-item");
3747			  jsSelectTwo.init(addNew = true);
3748			  jsLazyLoad.init()
3749
3750			})
3751		  } else {
3752			moveBk();
3753			jsDotDot2.init(".js-loadmore-new-item");
3754			jsSelectTwo.init(addNew = true);
3755			jsLazyLoad.init()
3756		  }
3757
3758		console.log("[loadGovJobContent] end");
3759
3760  }
3761
3762  function loadCourseContent() {
3763		console.log("[loadCourseContent] start");
3764
3765		var sel_industry=$("#sys_industry").html().trim();
3766		if (sel_industry=="所有行業" || sel_industry=="所有行业" || sel_industry.toLowerCase()=="All Industries".toLowerCase()) {
3767			sel_industry="";
3768		} else {
3769			console.log("[loadCourseContent] sel_industry=["+sel_industry+"]");
3770			var selTmpArray = sel_industry.split(",");
3771			var selTmp="";
3772			console.log("[loadCourseContent] selTmpArray.length=["+selTmpArray.length+"]");
3773			for (var i=0;i<selTmpArray.length;i++) {
3774				console.log("[loadCourseContent] selTmpArray[i].trim()="+selTmpArray[i].trim());
3775				var tmpKey = selTmpArray[i].trim();
3776				if (selTmp!="") {
3777					selTmp+=",";
3778				}
3779				selTmp += industryKeyMap[tmpKey];
3780				console.log("[loadCourseContent] selTmp="+selTmp);
3781			}
3782			sel_industry=selTmp;
3783		}
3784
3785		var sel_job=$( "#sys_job" ).html().trim();
3786		if (sel_job=="所有職位" || sel_job=="所有职位" || sel_job.toLowerCase()=="All Jobs".toLowerCase()) {
3787			sel_job="";
3788		} else {
3789			var selTmpArray = sel_job.split(",");
3790			var selTmp="";
3791			for (var i=0;i<selTmpArray.length;i++) {
3792				var tmpKey = selTmpArray[i].trim();
3793				if (selTmp!="") {
3794					selTmp+=",";
3795				}
3796				selTmp += jobKeyMap[tmpKey];
3797			}
3798			sel_job=selTmp;
3799		}
3800
3801		var sel_institution=$( "#sys_institution" ).html().trim();
3802		if (sel_institution=="所有院校" || sel_institution.toLowerCase()=="All Institutions".toLowerCase()) {
3803			sel_institution="";
3804		} else {
3805			var selTmpArray = sel_institution.split(",");
3806			var selTmp="";
3807			for (var i=0;i<selTmpArray.length;i++) {
3808				var tmpKey = selTmpArray[i].trim();
3809				if (selTmp!="") {
3810					selTmp+=",";
3811				}
3812				selTmp += institutionKeyMap[tmpKey];
3813			}
3814			sel_institution=selTmp;
3815		}
3816
3817		var sel_studymode=$( "#sys_studymode" ).html().trim();
3818		if (sel_studymode=="所有學制" || sel_studymode=="所有学制" || sel_studymode.toLowerCase()=="All Study Modes".toLowerCase()) {
3819			sel_studymode="";
3820		} else {
3821			var selTmpArray = sel_studymode.split(",");
3822			var selTmp="";
3823			for (var i=0;i<selTmpArray.length;i++) {
3824				var tmpKey = selTmpArray[i].trim();
3825				if (selTmp!="") {
3826					selTmp+=",";
3827				}
3828				selTmp += studymodeKeyMap[tmpKey];
3829			}
3830			sel_studymode=selTmp;
3831		}
3832
3833		console.log("sel_industry="+sel_industry);
3834		console.log("sel_job="+sel_job);
3835		console.log("sel_institution="+sel_institution);
3836		console.log("sel_studymode="+sel_studymode);
3837
3838		if (flag == 1 || !loadMoreStartReady) { return }
3839		flag = 1;
3840		$loadBtn.addClass('js-loadmore-loading');
3841		ajaxPage++;
3842
3843		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3844		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3845		  l_ajaxPath=l_ajaxPath.replace('{industry}', sel_industry);
3846		  l_ajaxPath=l_ajaxPath.replace('{job}', sel_job);
3847		  l_ajaxPath=l_ajaxPath.replace('{institution}', sel_institution);
3848		  l_ajaxPath=l_ajaxPath.replace('{studymode}', sel_studymode);
3849
3850		  console.log("l_ajaxPath="+l_ajaxPath);
3851
3852		  if (isAjax) {
3853			$.ajax({
3854			  url: getIsKanhanForceBaseUrl()+l_ajaxPath//jsp path
3855			}).fail(function(data){
3856				console.log("failed!");
3857			}).done(function (data) {
3858			  //alert(data);
3859			  $loadB.append(data);
3860			  moveBk();
3861			  appendParamLink();
3862			  jsDotDot2.init(".js-loadmore-new-item");
3863			  jsSelectTwo.init(addNew = true);
3864			  jsLazyLoad.init()
3865
3866			})
3867		  } else {
3868			moveBk();
3869			jsDotDot2.init(".js-loadmore-new-item");
3870			jsSelectTwo.init(addNew = true);
3871			jsLazyLoad.init()
3872		  }
3873
3874		console.log("[loadCourseContent] end");
3875
3876  }
3877
3878  function loadCalculatorContent() {
3879		console.log("[loadCalculatorContent] start");
3880		var sel_fundType=$("#sys_fundType").html().trim();
3881		if (sel_fundType=="全部資助類型" || sel_fundType=="全部资助类型" || sel_fundType.toLowerCase()=="Types of Support scheme".toLowerCase()) {
3882			sel_fundType="";
3883		} else {
3884			var selTmpArray = sel_fundType.split(",");
3885			var selTmp="";
3886			for (var i=0;i<selTmpArray.length;i++) {
3887				var tmpKey = selTmpArray[i].trim();
3888				if (selTmp!="") {
3889					selTmp+=",";
3890				}
3891				selTmp += schemeTypeKeyMap[tmpKey];
3892			}
3893			sel_fundType=selTmp;
3894		}
3895
3896		var sel_fundRange=$( "#sys_fundRange" ).html().trim();
3897		if (sel_fundRange=="全部資助金額" || sel_fundRange=="全部资助金额" || sel_fundRange.toLowerCase()=="Funding amount".toLowerCase()) {
3898			sel_fundRange="";
3899		}/* else { //No need use key map
3900			var selTmpArray = sel_fundRange.split(",");
3901			var selTmp="";
3902			for (var i=0;i<selTmpArray.length;i++) {
3903				var tmpKey = selTmpArray[i].trim();
3904				if (selTmp!="") {
3905					selTmp+=",";
3906				}
3907				selTmp += fundRangeKeyMap[tmpKey];
3908			}
3909			sel_fundRange=selTmp;
3910		}*/
3911
3912		if(sel_fundRange.indexOf("少於20萬") != -1 || sel_fundRange.indexOf("少于20万") != -1 || sel_fundRange.indexOf("Less than 200,000") != -1) {
3913			sel_fundRange = sel_fundRange.replace("少於20萬", "0-199999");
3914			sel_fundRange = sel_fundRange.replace("少于20万", "0-199999");
3915			sel_fundRange = sel_fundRange.replace("Less than 200,000", "0-199999");
3916		}
3917		if(sel_fundRange.indexOf("20-30萬") != -1 || sel_fundRange.indexOf("20-30万") != -1 || sel_fundRange.indexOf("200,000 - 300,000") != -1) {
3918			sel_fundRange = sel_fundRange.replace("20-30萬", "200000-300000");
3919			sel_fundRange = sel_fundRange.replace("20-30万", "200000-300000");
3920			sel_fundRange = sel_fundRange.replace("200,000 - 300,000", "200000-300000");
3921		}
3922		if(sel_fundRange.indexOf("多於30萬") != -1 || sel_fundRange.indexOf("多于30万") != -1 || sel_fundRange.indexOf("More than 300,000") != -1) {
3923			sel_fundRange = sel_fundRange.replace("多於30萬", "300001-999999999");
3924			sel_fundRange = sel_fundRange.replace("多于30万", "300001-999999999");
3925			sel_fundRange = sel_fundRange.replace("More than 300,000", "300001-999999999");
3926		}
3927
3928		var sel_fundStatus = "";
3929
3930		var sel_fundKey = $( "#sys_fundKey" ).val();
3931
3932		console.log("sys_fundType="+sel_fundType);
3933		console.log("sys_fundRange="+sel_fundRange);
3934		console.log("sys_fundStatus="+sel_fundStatus);
3935		console.log("sel_fundKey="+sel_fundKey);
3936
3937		if (flag == 1 || !loadMoreStartReady) { return }
3938		flag = 1;
3939		$loadBtn.addClass('js-loadmore-loading');
3940		ajaxPage++;
3941
3942		  var l_ajaxPath = ajaxPath.replace('{lang}', lang);
3943		  l_ajaxPath=l_ajaxPath.replace('{page}', ajaxPage);
3944		  l_ajaxPath=l_ajaxPath.replace('{fundRange}', sel_fundRange);
3945		  l_ajaxPath=l_ajaxPath.replace('{fundStatus}', sel_fundStatus);
3946		  l_ajaxPath=l_ajaxPath.replace('{fundKey}', sel_fundKey);
3947		  l_ajaxPath=l_ajaxPath.replace('{fundType}', sel_fundType);
3948
3949		  console.log("l_ajaxPath="+l_ajaxPath);
3950
3951		  if (isAjax) {
3952			$.ajax({
3953			  url: getIsKanhanForceBaseUrl()+l_ajaxPath+"&sortType="+customSortType//jsp path
3954			}).fail(function(data){
3955				console.log("failed!");
3956			}).done(function (data) {
3957			  //console.log(data);
3958			  $loadB.append(data);
3959			  moveBk();
3960			  appendParamLink();
3961			  jsDotDot2.init(".js-loadmore-new-item");
3962			  jsSelectTwo.init(addNew = true);
3963			  jsLazyLoad.init()
3964			})
3965		  } else {
3966			moveBk();
3967			jsDotDot2.init(".js-loadmore-new-item");
3968			jsSelectTwo.init(addNew = true);
3969			jsLazyLoad.init()
3970		  }
3971
3972		console.log("[loadCalculatorContent] end");
3973
3974  }
3975
3976  function moveBk() {
3977    var $moveItms = $loadB.find('> *').slice(0, loadNum),
3978      $imgs = $moveItms.find('img'),
3979      imgLength = $imgs.length,
3980      deferredArray = [];
3981
3982    if (imgLength) {
3983
3984      $.each($imgs, function (i) {
3985        var $itmImg = $(this),
3986          img = new Image(),
3987          imgDeferred = $.Deferred();
3988
3989        deferredArray.push(imgDeferred.promise());
3990
3991        img.onload = function () {
3992          imgDeferred.resolve($itmImg);
3993        }
3994
3995        setTimeout(function () {
3996          if (imgDeferred.state() !== 'resolved') {
3997            imgDeferred.resolve($itmImg);
3998          }
3999        }, loadremoOptions['imgLoadingTimeout'])
4000
4001        // this part may be enhanced the if to switch ....etc
4002        if(!$('.lazy').length){
4003          if (isSrcset) {
4004            if ($itmImg.data('srcset') !== undefined) {
4005              $itmImg.prop('srcset', $itmImg.data('srcset'));
4006              img.srcset = $itmImg.prop('srcset');
4007            } else {
4008              if ($itmImg.data('src') !== undefined) {
4009                $itmImg.prop('src', $itmImg.data('src'));
4010              }
4011              img.src = $itmImg.prop('src');
4012            }
4013          } else {
4014            if ($itmImg.data('src') !== undefined) {
4015              $itmImg.prop('src', $itmImg.data('src'));
4016            }
4017            img.src = $itmImg.prop('src');
4018          }
4019        }else{
4020          imgDeferred.resolve($itmImg);
4021        }
4022        // END - this part may be enhanced the if to switch ....etc
4023
4024      })
4025    } else {
4026      var deferred = $.Deferred();
4027
4028      deferredArray.push(deferred.promise());
4029
4030      deferred.resolve();
4031    }
4032
4033    $.when.apply($, deferredArray).done(function () {
4034
4035      var inJSMAS = $moveItms.eq(0).closest('.js-mas-backup').length,
4036        inJSJG = $moveItms.eq(0).closest('.js-jg-backup').length;
4037
4038      $moveItms
4039        .addClass('js-loadmore-moved')
4040        .css('visibility', 'hidden');
4041
4042      if (!inJSJG) {
4043        $moveItms.appendTo($loadC);
4044      } else {
4045        $moveItms
4046          .css('position', 'absolute')
4047          .insertAfter($loadC);
4048      }
4049
4050      if (inJSMAS) {
4051        setTimeout(function () {
4052          $loadC.masonry('appended', $moveItms);
4053          loadAfter($moveItms);
4054        }, 100)
4055      } else if (inJSJG) {
4056        setTimeout(function () {
4057          $imgs.each(function (i) {
4058            var $iloaded = $(this);
4059            $iloaded
4060              .attr('src', $iloaded[0].currentSrc)
4061              .removeAttr('srcset');
4062
4063            $iloaded.closest('.js-loadmore-moved').css('visibility', '');
4064          })
4065
4066          jsJustifiedGallery.appendImgLoaded($imgs, function () {
4067            $loadC.find('.js-lb-init-late').removeClass('js-lb-init-late')
4068
4069            if (typeof jsLB !== 'undefined') {
4070              jsLB.init($loadC);
4071            }
4072          });
4073
4074
4075          loadAfter($moveItms, true);
4076        }, 100)
4077      } else {
4078        loadAfter($moveItms);
4079      }
4080
4081
4082      if (isIE8) {
4083        $loadBtn.addClass('waitBefore');
4084        setTimeout(function () {
4085          $loadBtn.removeClass('waitBefore js-loadmore-loading');
4086          if (!$loadB.find('> *').filter(':not(.js-loadmore-dummy)').length) {
4087			console.log("[$loadBtn.hide() 1]");
4088            $loadBtn.hide();
4089          }
4090
4091          $loadB.find('.js-loadmore-dummy').remove();
4092        }, 400)
4093      } else {
4094        $loadBtn.removeClass('js-loadmore-loading');
4095        if (!$loadB.find('> *').length) {
4096		  console.log("[$loadBtn.hide() 2]");
4097          $loadBtn.hide();
4098        }
4099
4100        $loadB.find('.js-loadmore-dummy').remove();
4101      }
4102
4103    }).fail(function () {
4104
4105    }).then(function () {
4106      if(imgLength){
4107        jsDotDot2.init(".js-loadmore-new-item");
4108      }
4109
4110    })
4111  }
4112
4113  function loadAfter($_elms, isRemove) {
4114    var $elms = $_elms,
4115      $tempFirst = null;
4116    $elms.css('visibility', '');
4117    $elms.each(function (i) {
4118      var $e = $(this);
4119      if ($e.data('loadmore-animatecss')) {
4120        $e
4121          .css(
4122            prefix['css'] + 'animation-delay', i * loadremoOptions['itemsDelay'] + 'ms'
4123          )
4124          .addClass('animated ' + $e.data('loadmore-animatecss'));
4125
4126        $e.one(cssAniEnd, function () {
4127          $e.css(
4128            prefix['css'] + 'animation-delay', ''
4129          );
4130
4131
4132        })
4133      } else {
4134        $e
4135          .css(
4136            prefix['css'] + 'transition-delay', i * loadremoOptions['itemsDelay'] + 'ms'
4137          );
4138
4139        $e.one(cssTransEnd, function () {
4140          $e.css(
4141            prefix['css'] + 'transition-delay', ''
4142          );
4143
4144        })
4145      }
4146
4147      if (i == 0) {
4148        $tempFirst = $e;
4149      }
4150    });
4151
4152
4153    var $focusLink = $('<a class="js-loadmore-conlink sr-only" href="javascript:void(0)" tabindex="0">' + textString[getLang()] + '</a>');
4154
4155    if(!$tempFirst.is('tr')){
4156    $tempFirst.before($focusLink);
4157    } else {
4158      $tempFirst.find('td:eq(0)').prepend($focusLink);
4159    }
4160
4161
4162    setTimeout(function () {
4163      $elms.removeClass('js-mas-init');
4164      flag = 0;
4165
4166      var nowScrolltop = $(window).scrollTop()
4167      $focusLink.focus();
4168      $('html, body').scrollTop(nowScrolltop)
4169
4170      if (__fn && __fn.onMoved) {
4171        __fn.onMoved($elms, $loadC);
4172      }
4173
4174    }, 50);
4175
4176    if (isRemove) {
4177      $_elms.remove();
4178    }
4179
4180  }
4181
4182  function removeUnready() {
4183    loadMoreStartReady = true;
4184  }
4185
4186  function getLoadmoreOpts($_itm) {
4187    return $_itm.data('loadmore-options');
4188  }
4189
4190  return {
4191    init: setup,
4192    removeUnready: removeUnready,
4193    getLoadmoreOpts: getLoadmoreOpts
4194  }
4195});
4196
4197
4198var jsLoadMoreInit = (function () {
4199
4200  var $jsLoadmoreOuter;
4201
4202  function setup() {
4203    $jsLoadmoreOuter = $('.js-loadmore-outer');
4204    $jsLoadmoreOuter.each(function () {
4205      var $outer = $(this);
4206      if ($outer.data('js-loadmore')) { return };
4207      var loadmoreObj = new jsLoadMore($outer, {
4208        onMoved: function ($__movedElms, $__showContainer) {
4209          if (typeof jsProgressBar !== 'undefined') {
4210            jsProgressBar.init($__showContainer);
4211          }
4212        }
4213      });
4214      $outer.data('js-loadmore', loadmoreObj);
4215      loadmoreObj.init();
4216    })
4217  }
4218
4219  return {
4220    init: setup
4221  }
4222}());
4223var jsTable = (function(){
4224
4225  function setup(){
4226      var $table = $('.js-style-table');
4227      $table.find('tr').on('mouseenter', function(e){
4228         var $this__tr = $(this);
4229         if($this__tr.prev().length){
4230           $this__tr.prev().addClass('tr-hover-prev');
4231         }
4232
4233         if($this__tr.next().length){
4234           $this__tr.next().addClass('tr-hover-next');
4235         }
4236      });
4237
4238
4239      $table.find('tr').on('mouseleave', function(e){
4240         var $this__tr = $(this);
4241         if($this__tr.prev().length){
4242           $this__tr.prev().removeClass('tr-hover-prev');
4243         }
4244
4245         if($this__tr.next().length){
4246           $this__tr.next().removeClass('tr-hover-next');
4247         }
4248      });
4249  }
4250
4251  return {
4252    init: setup
4253  };
4254}());
4255var jsSelectTwo = (function(){
4256    var $blk,
4257        $checkbox
4258
4259    function setup(addNew){
4260
4261        $blk = $(".js-selecttwo-blk");
4262        $checkbox = $(".js-selecttwo-checkbox");
4263
4264		$checkbox.addClass("sr-only");
4265
4266        if($blk.length == 0){return;}
4267
4268        if(!addNew){ setTop(); }
4269    }
4270
4271    function setTop(e){
4272        var $menu =$(".page-menu");
4273        var screenWidth = $(window).width();
4274        var blkWidth,
4275            blkHeight,
4276            timer;
4277
4278
4279        $(window).on('load resize scroll', function(e){
4280            if(timer) {
4281                window.clearTimeout(timer);
4282            }
4283
4284            timer = window.setTimeout(function() {
4285                setT($menu,blkWidth,blkHeight);
4286            }, 50);
4287
4288            if(!$blk.is(":visible")){
4289                $blk.show();
4290             }
4291        });
4292    }
4293
4294    function setT(m,w,h){
4295        var screenWidth = $(window).width();
4296        var scollTop = $(window).scrollTop();
4297        var headHeight = jsHeader.getMenuTop();
4298        var menuHeight = jsHeader.getMenuHeight();
4299        var mobMenu = headHeight+menuHeight;
4300        if(screenWidth > 1140){
4301            w = screenWidth/2 - 570;
4302        }else{
4303            w = 0;
4304        }
4305
4306        if(screenWidth >767){
4307            h =  mobMenu;
4308        }else{
4309            if(scollTop != 0 ){
4310                if(scollTop < menuHeight){
4311                    h = mobMenu - scollTop  + 1
4312                }else{
4313                    h = headHeight
4314                }
4315            }else{
4316                h = mobMenu
4317            }
4318
4319        }
4320        $blk.css({
4321            // top:h,
4322            right:w,
4323            transform: 'translateY('+h+'px)'
4324        })
4325
4326    }
4327
4328    return {
4329      init: setup
4330    };
4331  }());
4332var jsNiceScroll = (function(){
4333
4334  var opts = {
4335    default: {
4336      cursorcolor: '#000',
4337      cursoropacitymin: 0,
4338      cursoropacitymax: 0,
4339      cursorwidth: "3px",
4340      cursorborder: "1px solid #000",
4341      emulatetouch: true
4342    },
4343    "top-cart": {
4344      railoffset: {
4345        "left": -10
4346      }
4347    }
4348  };
4349
4350  function setup($__container){
4351    var $c = ($__container) ? $__container : $('body');
4352
4353    var $elms = $('.js-nice', $c);
4354
4355    if(!$elms.length || Modernizr.touchevents) {return};
4356
4357    $elms.each(function(){
4358      var $e = $(this),
4359          option = $.extend({}, opts.default);
4360
4361
4362      if($e.attr('data-nice') == 'top-cart') {
4363        option = $.extend({}, option, opts["top-cart"]);
4364      }
4365
4366      $e.data('js-nice', $e.niceScroll(option));
4367    });
4368  }
4369
4370  return {
4371    init: setup
4372  };
4373}());
4374var jsShowMore = (function(){
4375
4376    var $btn,
4377        $item,
4378        $container;
4379
4380    var one_col_no  = 14;
4381
4382    function setup(){
4383        $btn = $(".js-show-more-btn");
4384        $item = $(".js-show-more-item");
4385        $container = $(".js-show-more-container");
4386        $outer = $('.js-show-more-container-outer');
4387
4388        if($btn.length == 0){return;}
4389
4390        $btn.click(function(){
4391            var $this = $(this);
4392            var $parent = $this.parents('.info-blk__list');
4393
4394            if($parent.find($container).hasClass("open")){
4395                hideItem($parent);
4396                $this.removeClass("open");
4397                $this.text('更多');
4398
4399            }else{
4400                showItem($parent);
4401                $this.addClass("open");
4402                $this.text('隱藏');
4403            }
4404        })
4405    }
4406
4407    function showItem(p){
4408        p.find($item).slice(jsQueryTest.argF({'xs': one_col_no, 'sm': one_col_no, 'md': one_col_no*2, 'lg': one_col_no*2, 'xl': one_col_no*2, 'xxl': one_col_no*2})).wrapAll("<div class='info-blk__slide-container'></div>");
4409        p.find($container).addClass("open");
4410        p.find('.info-blk__slide-container').css({"display":"none"}).slideDown(400, function(){
4411            p.find('.info-blk__slide-container ').find($item ).unwrap();
4412        });
4413    }
4414
4415    function hideItem(p){
4416         p.find($item).slice( - (p.find($item).length - jsQueryTest.argF({'xs': one_col_no, 'sm': one_col_no, 'md': one_col_no*2, 'lg': one_col_no*2, 'xl': one_col_no*2, 'xxl': one_col_no*2})) ).wrapAll("<div class='info-blk__slide-container'></div>");
4417
4418         p.find('.info-blk__slide-container').slideUp(400, function(){
4419            p.find('.info-blk__slide-container ').find($item ).unwrap();
4420             p.find($container).removeClass("open");
4421        });
4422    }
4423    return {
4424      init: setup
4425    };
4426  }());
4427var jsFilterBar = (function(){
4428
4429    var $first,
4430        $second;
4431
4432
4433    function setup() {
4434        $first = $(".js-filter-bar-first");
4435        $second = $(".js-filter-bar-second");
4436
4437        var secondtext = $second.find('.form-control').text();
4438
4439        if($first.length == 0 || $second.length == 0){return;}
4440
4441        $first.find('input').change(function(){
4442            var $this = $(this);
4443            var value = $(".js-filter-bar-first > button").text();
4444			var str_arr = value.split(', ') ;
4445            var this_class = $this.closest($first).attr('class')
4446            var word = "js-filter-bar-type-"
4447            var type = word + this_class.slice(this_class.indexOf(word) + word.length,this_class.indexOf(word) + word.length+1);//find which type of first and second
4448
4449			if( $second.hasClass(type)){
4450				$second.find('.form-control').prop('disabled', false).text(secondtext);
4451				$second.find('input').each(function(){
4452					var $this_input = $(this) ;
4453					$this_input.prop('checked', false);
4454					$this_input.closest(".checkbox").addClass("hide");
4455					for(var i = 0 ; i < str_arr.length ;i++){
4456						if($this_input.attr('name') == str_arr[i]){
4457							$this_input.closest(".checkbox").removeClass("hide");
4458						}
4459					}
4460				});
4461			}
4462
4463        })
4464    }
4465
4466    return {
4467        init: setup
4468    }
4469  }());
4470
4471
4472var jsMas = (function () {
4473  var $jsMas,
4474    masopts = {
4475      'js-mas-lb': {
4476        transitionDuration: 0,
4477        itemSelector: '.demo-loadmore-masnory-block'
4478      }
4479    },
4480    isSrcset = Modernizr.srcset;
4481
4482  var jsmas_defaultOptions = {
4483    imgLoadingTimeout: 20000,
4484    itemsDelay: 100
4485  }
4486
4487  function setup($_select, _opts) {
4488    var $container = ($_select !== undefined) ? $_select : $('body');
4489
4490    if (_opts) {
4491      jsmas_defaultOptions = $.extend({}, jsmas_defaultOptions, _opts);
4492    }
4493
4494    $jsMas = $('.js-mas', $container);
4495
4496    $jsMas.each(function () {
4497      var $mas = $(this),
4498        opt = null;
4499
4500      if ($mas.hasClass('js-mas-lb')) {
4501        opt = $.extend({}, masopts['js-mas-lb'], {
4502          columnWidth: masopts['js-mas-lb'].itemSelector,
4503          percentPosition: true
4504          // columnWidth: $(masopts['js-mas-lb'].itemSelector).parent().width() / 2
4505        })
4506      }
4507
4508      if (opt === null) { return }
4509      var $blocks = $mas.find(opt.itemSelector),
4510        $imgs = ($_select !== undefined) ? $blocks.find('img') : $blocks.filter('.js-mas-init').find('img'),
4511        imgLength = $imgs.length,
4512        deferredArray = [];
4513
4514      if (imgLength) {
4515
4516        $.each($imgs, function (i) {
4517          var $itmImg = $(this),
4518            img = new Image(),
4519            imgDeferred = $.Deferred();
4520
4521          deferredArray.push(imgDeferred.promise());
4522
4523          img.onload = function () {
4524            imgDeferred.resolve($itmImg);
4525          }
4526
4527          setTimeout(function () {
4528            if (imgDeferred.state() !== 'resolved') {
4529              imgDeferred.resolve($itmImg);
4530            }
4531          }, jsmas_defaultOptions['imgLoadingTimeout'])
4532
4533          // this part may be enhanced the if to switch ....etc
4534          if(!$('.lazy').length){
4535            if (isSrcset) {
4536              if ($itmImg.data('srcset') !== undefined) {
4537                $itmImg.prop('srcset', $itmImg.data('srcset'));
4538                img.srcset = $itmImg.prop('srcset');
4539              } else {
4540                if ($itmImg.data('src') !== undefined) {
4541                  $itmImg.prop('src', $itmImg.data('src'));
4542                }
4543                img.src = $itmImg.prop('src');
4544              }
4545            } else {
4546              if ($itmImg.data('src') !== undefined) {
4547                $itmImg.prop('src', $itmImg.data('src'));
4548              }
4549              img.src = $itmImg.prop('src');
4550            }
4551          }else{
4552            imgDeferred.resolve($itmImg);
4553          }
4554          // END - this part may be enhanced the if to switch ....etc
4555        })
4556      } else {
4557        var deferred = $.Deferred();
4558
4559        deferredArray.push(deferred.promise());
4560
4561        deferred.resolve();
4562      }
4563
4564      $.when.apply($, deferredArray).done(function () {
4565
4566        exeMAS($mas, opt);
4567      })
4568    })
4569  }
4570
4571  function exeMAS($_mas, _opt) {
4572    var $mas = $_mas,
4573      opt = _opt;
4574    $mas.masonry(opt);
4575
4576    $mas.find('.js-mas-init').each(function (i) {
4577      var $b = $(this);
4578      $b.removeClass('js-mas-init');
4579      if ($b.data('loadmore-animatecss')) {
4580        $b
4581          .css(
4582            prefix['css'] + 'animation-delay', i * jsmas_defaultOptions['itemsDelay'] + 'ms'
4583          )
4584          .addClass('animated ' + $b.data('loadmore-animatecss'));
4585
4586        $b.one(cssAniEnd, function () {
4587          $b.css(
4588            prefix['css'] + 'animation-delay', ''
4589          );
4590        })
4591      } else {
4592        $b
4593          .css(
4594            prefix['css'] + 'transition-delay', i * jsmas_defaultOptions['itemsDelay'] + 'ms'
4595          );
4596
4597        $b.one(cssTransEnd, function () {
4598          $b.css(
4599            prefix['css'] + 'transition-delay', ''
4600          );
4601        })
4602      }
4603    });
4604    $('body').removeClass('js-mas-wait').css({ height: 'auto' });
4605    $mas.addClass('js-mas-added');
4606
4607    if (typeof $mas.closest('.js-loadmore-outer').data('js-loadmore') !== 'undefined') {
4608      $mas.closest('.js-loadmore-outer').data('js-loadmore').removeUnready();
4609    }
4610  }
4611
4612  return {
4613    init: function ($_select) {
4614      setup($_select);
4615    }
4616  }
4617}())
4618var jsParallax = (function () {
4619  var $par;
4620
4621  function setup() {
4622    $par = $('.parallax-window')
4623    $par.parallax({
4624      zIndex: 1,
4625      speed:  2.5,
4626      naturalWidth: 16,
4627      naturalHeight: 9,
4628      positionY:'-360px'
4629    });
4630
4631    //add alt to parallax silder
4632    $par.each(function () {
4633      $this_p = $(this);
4634      this_src = $this_p.data('image-src')
4635      this_alt = $this_p.data('alt')
4636
4637      $slider = $('.parallax-slider')
4638
4639      $slider.each(function () {
4640        if (this_src == $(this).attr('src')) {
4641          $(this).attr('alt', this_alt)
4642        }
4643      })
4644    })
4645  }
4646
4647  return {
4648    init: setup
4649  }
4650}())
4651var jsLazyLoad = (function () {
4652    function setup() {
4653        var lazyLoadInstance = new LazyLoad({
4654            elements_selector: ".lazy",
4655			threshold:1000,
4656            // load_delay: 5000
4657        });
4658    }
4659
4660    return {
4661        init: setup
4662    }
4663}())
4664
4665/*bootstrap selectbox*/
4666var jsSelectBox = (function(){
4667  var $all_select,
4668      default_options = {
4669        buttonClass: 'form-control form-control--ellipsis form-control--gray',
4670        buttonContainer: '<div></div>',
4671        numberDisplayed: 1,
4672        templates: {
4673          ul: '<ul class="form-control-dropdown__dropdown multiselect-container dropdown-menu option-group form-control-dropdown__option form-control-dropdown__option--bold"></ul>',
4674          li: '<li class="form-control-dropdown__dropdown--wide form-control-dropdown__rc"><a href="javascript:void(0);"><label class="option-label checkbox-label"></label></a></li>',
4675        }
4676      };
4677
4678  function setup($_container){
4679      var $container = ($_container !== undefined) ? $_container : $('body');
4680
4681      $all_select = $('.js-selectBox select:not(".select-default")', $container);
4682
4683
4684      if(!$all_select.length) {return;}
4685
4686      $all_select.each(function(){
4687        var $select = $(this),
4688            $selectContainer = $select.parent(),
4689            isMulti = $select.prop('multiple'),
4690            isNextPrev = $selectContainer.hasClass('js-selectBox-left-right');
4691        var option = null;
4692        option = $.extend({}, default_options, {});
4693
4694        // class specific
4695        if($selectContainer.data('color') !== undefined){
4696          var color = $selectContainer.data('color');
4697          option = $.extend({}, option, {
4698            buttonClass: " js-selectBox-color-" + color
4699          });
4700        }
4701
4702        if (isMulti) {
4703          option = $.extend({}, option, {
4704            buttonText: function(options, select) {
4705              if (options.length === 0) {
4706                return $(select).prop('title');
4707              } else if(options.length <= default_options['numberDisplayed']){
4708                var texts = [];
4709                options.each(function(){
4710                  texts.push($(this).text());
4711                })
4712
4713                return texts.join(', ');
4714              }
4715              else {
4716                return langArg({
4717                  'en': options.length + ' selected',
4718                  'tc': '已選' + options.length + '個',
4719                  'sc': '已选' + options.length + '个'
4720                })
4721              }
4722            }
4723          });
4724        }
4725
4726
4727
4728        if(isNextPrev) {
4729         setNextPrev($select, $selectContainer);
4730        }
4731
4732        // -- end class specific
4733        option = $.extend({}, option , {
4734          onInitialized: function(select, container){
4735            if($(select).prop('multiple') == false){
4736              $selectContainer.addClass('js-selectBox-single');
4737            }
4738           if($selectContainer.hasClass('js-selectBox--sm')){
4739              $selectContainer.find('button').addClass('multiselect--sm')
4740            }
4741            var $btn = $selectContainer.find('button.multiselect');
4742            var $menu = $selectContainer.find('ul.multiselect-container');
4743            var $btnContainer = $btn.parent();
4744            // Remove Bootstrap data-toggle attributes so Bootstrap 5 does not intercept clicks.
4745            // Use a manual toggle instead because style.css overrides .dropdown-menu display:none
4746            // with display:block, making Bootstrap 5's .show class mechanism ineffective.
4747            $btn.removeAttr('data-toggle').removeAttr('data-bs-toggle');
4748            $menu.hide();
4749
4750            // ------------------------------------------------------------------
4751            // ARIA combobox pattern (WAI-ARIA APG "Select-Only Combobox"):
4752            // https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
4753            // The plugin replaces the native <select> with a <button> + <ul> list.
4754            // Map the button to a combobox, the ul to a listbox, and each option li
4755            // to an option, and keep aria-activedescendant on the button in sync.
4756            // ------------------------------------------------------------------
4757            var listboxId = $menu.attr('id');
4758            if (!listboxId) {
4759              var baseId = ($select.attr('id') || $select.attr('name') || 'select');
4760              listboxId = 'js-selectbox-' + baseId + '-listbox';
4761              if (baseId === 'select' || document.getElementById(listboxId)) {
4762                listboxId += '-' + Math.random().toString(36).slice(2, 8);
4763              }
4764              $menu.attr('id', listboxId);
4765            }
4766            $menu.attr('role', 'listbox');
4767            $btn.attr({
4768              'role': 'combobox',
4769              'aria-haspopup': 'listbox',
4770              'aria-expanded': 'false',
4771              'aria-controls': listboxId
4772            });
4773
4774            // Option <li> elements only — skip plugin utility items (divider/group/filter)
4775            // and the injected close button.
4776            var $getOptionLis = function() {
4777              return $menu.children('li').filter(function() {
4778                var $li = $(this);
4779                return !$li.hasClass('multiselect-item')
4780                  && !$li.hasClass('js-selectBox-close-wrap')
4781                  && $li.find('> a > label > input').length;
4782              });
4783            };
4784
4785            // Give every option a stable id + role="option" and keep aria-selected in sync.
4786            var applyOptionRoles = function() {
4787              $getOptionLis().each(function(index) {
4788                var $li = $(this);
4789                $li.attr('role', 'option');
4790                if (!$li.attr('id')) {
4791                  $li.attr('id', listboxId + '-option-' + index);
4792                }
4793                var $input = $li.find('> a > label > input').first();
4794                $li.attr('aria-selected', ($input.length && $input.is(':checked')) ? 'true' : 'false');
4795              });
4796            };
4797
4798            // aria-activedescendant tells assistive tech which option is active while
4799            // keyboard focus stays on the combobox button.
4800            var updateActiveDescendant = function($li) {
4801              if ($li && $li.length) {
4802                $btn.attr('aria-activedescendant', $li.attr('id'));
4803              }
4804            };
4805
4806            // The select-only combobox always exposes aria-activedescendant on the button,
4807            // pointing at the currently selected option, and keeps it in sync as the active
4808            // option changes (WAI-ARIA APG "Select-Only Combobox").
4809            var syncActiveDescendantToSelected = function() {
4810              var $selected = $getOptionLis().filter('.active, :has(input:checked)').first();
4811              if (!$selected.length) {
4812                $selected = $getOptionLis().not('.disabled').first();
4813              }
4814              updateActiveDescendant($selected);
4815            };
4816
4817            // Keyboard navigation moves real focus to the <a>/<label> inside the option <li>;
4818            // mirror that as the active descendant of the combobox.
4819            $menu.on('focus.jsSelectBoxOptionAria', 'li[role="option"] a, li[role="option"] label', function() {
4820              updateActiveDescendant($(this).closest('li[role="option"]'));
4821            });
4822
4823            // Keep aria-selected (and aria-activedescendant) in sync when an option is chosen.
4824            $menu.on('change.jsSelectBoxOptionAria', 'li[role="option"] input', function() {
4825              applyOptionRoles();
4826              syncActiveDescendantToSelected();
4827            });
4828
4829            applyOptionRoles();
4830            // Expose aria-activedescendant immediately, even while the listbox is collapsed,
4831            // pointing at the currently selected option so the current choice is announced.
4832            syncActiveDescendantToSelected();
4833
4834            var closeMenu = function() {
4835              $menu.hide();
4836              $btn.attr('aria-expanded', 'false');
4837              // Keep aria-activedescendant present, pointing back at the selected option.
4838              syncActiveDescendantToSelected();
4839              $btnContainer.trigger('hide.bs.dropdown');
4840              $(document).off('click.jsSelectBoxClose');
4841            };
4842
4843            var openMenu = function() {
4844              $menu.show();
4845              $btn.attr('aria-expanded', 'true');
4846              // Options may have been rebuilt since init (multiselect('rebuild')), so re-apply roles.
4847              applyOptionRoles();
4848              syncActiveDescendantToSelected();
4849              $btnContainer.trigger('show.bs.dropdown');
4850              $(document).one('click.jsSelectBoxClose', closeMenu);
4851            };
4852
4853            var stepSingleSelect = function(direction) {
4854              if ($(select).prop('multiple')) {
4855                return false;
4856              }
4857
4858              var $enabledOptions = $(select).find('option').filter(function() {
4859                return !this.disabled;
4860              });
4861
4862              if (!$enabledOptions.length) {
4863                return false;
4864              }
4865
4866              var $selected = $enabledOptions.filter(':selected').first();
4867              var currentIndex = $enabledOptions.index($selected);
4868              if (currentIndex < 0) {
4869                currentIndex = 0;
4870              }
4871
4872              var nextIndex = direction === 'down'
4873                ? Math.min(currentIndex + 1, $enabledOptions.length - 1)
4874                : Math.max(currentIndex - 1, 0);
4875
4876              if (nextIndex !== currentIndex) {
4877                $enabledOptions.prop('selected', false);
4878                $enabledOptions.eq(nextIndex).prop('selected', true);
4879                $(select).multiselect('refresh');
4880                // refresh() rebuilds the option <li>s, so re-apply the ARIA roles and point
4881                // aria-activedescendant at the option that now has the selection/focus.
4882                applyOptionRoles();
4883                syncActiveDescendantToSelected();
4884                $(select).trigger('change');
4885              }
4886
4887              return true;
4888            };
4889
4890            var commitKeyboardSelection = function() {
4891              $(select).trigger('change');
4892              changeAction($(select));
4893            };
4894
4895            var activateFocusedOption = function($sourceNode) {
4896              var $option = $sourceNode.closest('li.multiselect-option');
4897              if (!$option.length || $option.hasClass('disabled')) {
4898                return false;
4899              }
4900
4901              var $input = $option.find('input:not(:disabled)').first();
4902              if (!$input.length) {
4903                return false;
4904              }
4905
4906              $input.trigger('click');
4907
4908              if (!$(select).prop('multiple')) {
4909                setTimeout(function() {
4910                  closeMenu();
4911                  $btn.focus();
4912                }, 0);
4913              }
4914
4915              return true;
4916            };
4917
4918            $btn.on('click.jsSelectBox', function(e) {
4919              e.stopPropagation();
4920              $(document).off('click.jsSelectBoxClose');
4921              if ($menu.is(':visible')) {
4922                closeMenu();
4923              } else {
4924                openMenu();
4925              }
4926            });
4927
4928            $btn.on('keydown.jsSelectBox', function(e) {
4929              var key = e.key || '';
4930              var keyCode = e.which || e.keyCode;
4931              var isArrowDown = key === 'ArrowDown' || keyCode === 40;
4932              var isArrowUp = key === 'ArrowUp' || keyCode === 38;
4933              var isEnter = key === 'Enter' || keyCode === 13;
4934
4935              if (!isArrowDown && !isArrowUp && !isEnter) {
4936                return;
4937              }
4938
4939              e.preventDefault();
4940              e.stopPropagation();
4941
4942              if (isEnter) {
4943                if (!$menu.is(':visible')) {
4944                  openMenu();
4945                  return;
4946                }
4947
4948                if (!$(select).prop('multiple')) {
4949                  var $focusedSingleOption = $(document.activeElement).closest('li.multiselect-option');
4950                  if ($focusedSingleOption.length) {
4951                    activateFocusedOption($focusedSingleOption);
4952                  } else {
4953                    commitKeyboardSelection();
4954                    closeMenu();
4955                    $btn.focus();
4956                  }
4957                  return;
4958                }
4959
4960                var $activeOption = $menu.find('li.multiselect-option.active:not(.disabled):visible').first();
4961                if (!$activeOption.length) {
4962                  $activeOption = $menu.find('li.multiselect-option:not(.disabled):visible').first();
4963                }
4964                if ($activeOption.length) {
4965                  activateFocusedOption($activeOption);
4966                } else {
4967                  closeMenu();
4968                }
4969                return;
4970              }
4971
4972              if (stepSingleSelect(isArrowDown ? 'down' : 'up')) {
4973                return;
4974              }
4975
4976              $(document).off('click.jsSelectBoxClose');
4977              if (!$menu.is(':visible')) {
4978                openMenu();
4979              }
4980
4981              var $focusableItems = $menu.find('li.multiselect-option:not(.disabled):visible a');
4982              if (!$focusableItems.length) {
4983                return;
4984              }
4985
4986              var currentIndex = $focusableItems.index(document.activeElement);
4987              if (currentIndex < 0) {
4988                currentIndex = isArrowDown ? -1 : 0;
4989              }
4990
4991              var nextIndex = isArrowDown
4992                ? Math.min(currentIndex + 1, $focusableItems.length - 1)
4993                : Math.max(currentIndex - 1, 0);
4994
4995              $focusableItems.eq(nextIndex).focus();
4996            });
4997
4998            $menu.on('keydown.jsSelectBoxOption', 'li.multiselect-option a, li.multiselect-option label', function(e) {
4999              var key = e.key || '';
5000              var keyCode = e.which || e.keyCode;
5001              var isEnter = key === 'Enter' || keyCode === 13;
5002              var isSpace = key === ' ' || keyCode === 32;
5003
5004              if (!isEnter && !isSpace) {
5005                return;
5006              }
5007
5008              e.preventDefault();
5009              e.stopPropagation();
5010              activateFocusedOption($(this));
5011            });
5012
5013            changeOptionDom($(select));
5014            changeAction($(select), false, true)
5015          },
5016          onDropdownShow: function(event){
5017            $selectContainer.addClass('js-select-active');
5018            if(!$selectContainer.find('.form-control-dropdown__close').length){
5019               var $drop = $selectContainer.find('.form-control-dropdown__dropdown');
5020               $drop.append('<li class="js-selectBox-close-wrap"><button class="form-control-dropdown__close">
5020'+ langArg({'en': 'Close', 'tc': '關閉', 'sc': '关闭'}) +'</button></li>');
5021            }
5022            if(isIE8){
5023              $selectContainer.addClass('waitBefore');
5024              setTimeout(function(){
5025                $selectContainer.removeClass('waitBefore');
5026              }, 100)
5027            }
5028          },
5029          onDropdownHide: function(event){
5030            $selectContainer.removeClass('js-select-active');
5031            if(isIE8){
5032              $selectContainer.addClass('waitBefore');
5033              setTimeout(function(){
5034                $selectContainer.removeClass('waitBefore');
5035              }, 100)
5036            }
5037          },
5038          onChange: function(option, checked, select){
5039            changeAction($select);
5040            // Return focus to the multiselect button after keyboard selection
5041            // so the user can press Enter again to re-expand the dropdown.
5042            // setTimeout lets the synchronous changeAction → tabJumpTo →
5043            // selectJumpTo → multiselect('refresh') chain complete first.
5044            setTimeout(function() {
5045              var $toggleBtn = $selectContainer.find('button.multiselect.dropdown-toggle');
5046              if ($toggleBtn.length) {
5047                $toggleBtn.focus();
5048              }
5049            }, 150);
5050          }
5051        })
5052
5053        $select.data('selectmenu', $select.multiselect(option));
5054        $select.attr('tabindex', 0);
5055
5056        setClickActive($select);
5057      })
5058
5059      $(document).on('focus blur', '.multiselect.dropdown-toggle', function(e){
5060
5061        var $button = $(this);
5062        $button.closest('.js-selectBox').toggleClass('js-selectBox-focus', e.type == 'focusin');
5063      })
5064  }
5065
5066  function setClickActive($_select){
5067        var $select = $_select,
5068            $selectWrap = $select.closest('.js-selectBox');
5069          if($selectWrap.hasClass('js-selectBox-single')){
5070            $selectWrap.find('.multiselect-option.rc__itm label').on('click', function(e){
5071              var $opt = $(this).closest('.rc__itm');
5072              if($opt.hasClass('active')){
5073                $select.multiselect('rebuild');
5074                changeOptionDom($select);
5075                setClickActive($select);
5076              }
5077          });
5078        }
5079      }
5080
5081  function setNextPrev($_select, $_container){
5082
5083
5084      if($_select.prop('multiple')){return;}
5085
5086      var $appendBtn__prev = $('<button class="js-selectBox-left-right-arrow js-selectBox-left-right-arrow--prev" data-type="prev"><span class="sr-only">'+ langArg({'en': 'Prev', 'tc': '上一個', 'sc': '上一个'}) +'</span></button>'),
5087          $appendBtn__next = $('<button class="js-selectBox-left-right-arrow js-selectBox-left-right-arrow--next" data-type="next"><span class="sr-only">'+ langArg({'en': 'Next', 'tc': '下一個', 'sc': '下一个'}) +'</span></button>');
5088          $_container.append($appendBtn__prev, $appendBtn__next);
5089
5090          $appendBtn__prev.add($appendBtn__next).on('click', function(e){
5091              e.preventDefault();
5092              e.stopPropagation();
5093              var $b = $(this),
5094                  $s = $_select,
5095                  dir = $b.data('type'),
5096                  $selected = $s.find('option:selected'),
5097                  $nextItm;
5098
5099
5100              if(dir == 'next') {
5101                $nextItm = $selected.nextOrFirst();
5102              } else {
5103                $nextItm = $selected.prevOrLast();
5104              }
5105
5106              $nextItm.prop('selected', true);
5107
5108              $_select.multiselect('refresh');
5109
5110              $_select.trigger('change');
5111          })
5112  }
5113
5114  function changeOptionDom($_select) {
5115    var $select = $_select;
5116
5117    var $dropdown = $select.next().find('.multiselect-container'),
5118        $option = $dropdown.find('.multiselect-option');
5119
5120    $option.each(function(){
5121      var $optLabel = $(this).find('label'),
5122          text = $optLabel.text();
5123      $optLabel.find('input').addClass('rc--' + $optLabel.find('input').attr('type'));
5124      $optLabel[0].removeChild($optLabel[0].childNodes[1]);
5125      $optLabel.append('<span>'+ text +'</span>')
5126    })
5127  }
5128
5129
5130  function changeAction(_select, _isMulti, _first_enter){
5131    var isMulti = (_isMulti) ? _isMulti : 0;
5132
5133
5134    if(_select.closest('.js-selectBox').hasClass('js-selectBox-jump') && !_first_enter){
5135      if(_select.val() !== ''){
5136        window.location.href = _select.val();
5137        _select.parent().find('.multiselect-selected-text').addClass('multiselect-selected-text--orange');
5138      }else{
5139        _select.parent().find('.multiselect-selected-text').removeClass('multiselect-selected-text--orange');
5140      }
5141    }
5142
5143    if(_select[0].selectedIndex == 0) {
5144      _select.closest('.js-selectBox').addClass('js-selectBox-default');
5145    } else {
5146      _select.closest('.js-selectBox').removeClass('js-selectBox-default');
5147    }
5148
5149    if(!_first_enter && _select.closest('.toolbar-sorter').length){
5150      _select.trigger('click');
5151    }
5152
5153    if(typeof jsBsTabNav !== 'undefined' && _select.closest('.js-selectBox').hasClass('js-selectBox-tabselect')) {
5154      console.log('as');
5155      jsBsTabNav.tabJumpTo(_select, _select[0].selectedIndex, _first_enter)
5156    }
5157
5158    if(_select.closest('.js-selectBox').hasClass('js-targetVisibile')){
5159      var target__select = _select.find('option').eq(_select[0].selectedIndex).data('js-target-visible-target');
5160      if(target__select){
5161        jsTargetVisible.showWithTargetString([target__select]);
5162      } else {
5163        _select.find('option').filter('[data-js-target-visible-target]').map(function(){return $(this).data('js-target-visible-target')});
5164        jsTargetVisible.hideWithTargetString(_select.find('option').filter('[data-js-target-visible-target]').map(function(){return $(this).data('js-target-visible-target')}));
5165      }
5166    }
5167
5168    if(_select.closest('.js-selectBox').hasClass('js-selectBox-form-submit') && !_first_enter){
5169      _select.closest('form').submit();
5170    }
5171
5172    setTimeout(function(){
5173
5174    }, 80)
5175  }
5176
5177  function renderEnable($_select, _isChecked){
5178    var $s = $_select,
5179        isJqSeletMenu = $s.next('.ui-selectmenu-button').length,
5180        isBsMultiSelect = $s.next().find('.multiselect').length;
5181
5182      $s.prop('disabled', !_isChecked);
5183
5184      if(isJqSeletMenu){
5185        $s.selectmenu('refresh')
5186      }
5187
5188      if(isBsMultiSelect){
5189        $s.multiselect((_isChecked) ? 'enable' : 'disable');
5190      }
5191
5192      if(_isChecked){
5193        $s.closest('.js-selectBox').removeClass('js-selectBox-disable');
5194      } else {
5195        $s.closest('.js-selectBox').addClass('js-selectBox-disable');
5196      }
5197  }
5198
5199  function rebuild($_select){
5200    var $s = $_select,
5201        isJqSeletMenu = $s.next('.ui-selectmenu-button').length,
5202        isBsMultiSelect = $s.next().find('.multiselect').length;
5203
5204    if(isBsMultiSelect){
5205        $s.multiselect('rebuild');
5206        changeOptionDom($s);
5207    }
5208  }
5209
5210  return {
5211    init: setup,
5212    renderEnable: renderEnable,
5213    reBuild: rebuild
5214  }
5215}());
5216var jsBsTabNav = (function(){
5217
5218  var $tab__nav;
5219
5220  function setup(){
5221      $tab__nav = $('.js-tab-nav');
5222
5223      $tab__nav.each(function(){
5224        var $tn = $(this),
5225            $select = $tn.find('select').eq(0),
5226            $t__list = $tn.find('[role="tablist"]').eq(0);
5227
5228        $t__list.find('[role="tab"]').on('click', function(e){
5229          // e.preventDefault();
5230          var $btn = $(this),
5231              idx = $btn.index();
5232
5233            selectJumpTo($btn, idx);
5234        })
5235
5236
5237        if((window.location.pathname.includes('/career-study/useful-links') || window.location.pathname.includes('/career-study/useful-links/')) &&
5238           ($select.hasClass('js-selectBox-tabselect') || $select.closest('.js-selectBox').hasClass('js-selectBox-tabselect'))){
5239          var $firstTab = $t__list.find('[role="tab"]').first();
5240          if($firstTab.length){
5241            // Use setTimeout to ensure DOM is ready
5242            setTimeout(function(){
5243              // Try multiple methods to activate the first tab
5244              $firstTab.trigger('click');
5245              $firstTab.tab('show');
5246
5247              // Directly manipulate tab content
5248              var targetId = $firstTab.attr('href');
5249              if(targetId){
5250                var $targetPane = $(targetId);
5251                if($targetPane.length){
5252                  // Hide all tab panes
5253                  $tn.find('.blk-tab__tab-pane').removeClass('show active');
5254                  // Show first tab pane
5255                  $targetPane.addClass('show active');
5256                  // Update tab button states
5257                  $t__list.find('[role="tab"]').removeClass('show active').attr('aria-selected', 'false');
5258                  $firstTab.addClass('show active').attr('aria-selected', 'true');
5259                }
5260              }
5261            }, 200);
5262          }
5263        }
5264
5265        // Accessibility: manage aria-hidden for responsive tab/select duplicates
5266        var $selectWrapper = $tn.find('.js-selectBox-tabselect').eq(0);
5267        var $tabList = $t__list;
5268
5269        function updateAriaHidden() {
5270          var isDesktop = window.matchMedia('(min-width: 768px)').matches;
5271
5272          if (isDesktop) {
5273            // Desktop: tabs are visible, select is hidden
5274            $selectWrapper.attr('aria-hidden', 'true');
5275            $selectWrapper.find('select').attr('tabindex', '-1');
5276            $tabList.removeAttr('aria-hidden');
5277            $tabList.find('[role="tab"]').each(function() {
5278              var $tab = $(this);
5279              var isActive = $tab.attr('aria-selected') === 'true';
5280              $tab.attr('tabindex', isActive ? '0' : '-1');
5281            });
5282          } else {
5283            // Mobile: select is visible, tabs are hidden
5284            $selectWrapper.removeAttr('aria-hidden');
5285            $selectWrapper.find('select').attr('tabindex', '-1');
5286            // The multiselect plugin hides the native select and generates its own
5287            // button — give that button tabindex=0 so it's keyboard-accessible.
5288            $selectWrapper.find('.multiselect.dropdown-toggle').attr('tabindex', '0');
5289            $tabList.attr('aria-hidden', 'true');
5290            $tabList.find('[role="tab"]').attr('tabindex', '-1');
5291          }
5292        }
5293
5294        // Initial update
5295        updateAriaHidden();
5296
5297        // Update on resize (debounced)
5298        var resizeTimeout;
5299        $(window).on('resize.ariaTabNav', function() {
5300          clearTimeout(resizeTimeout);
5301          resizeTimeout = setTimeout(updateAriaHidden, 150);
5302        });
5303
5304        // Update when Bootstrap tab is shown (desktop tab activation)
5305        $t__list.on('shown.bs.tab', '[role="tab"]', function() {
5306          if (window.matchMedia('(min-width: 768px)').matches) {
5307            var $tabs = $tabList.find('[role="tab"]');
5308            $tabs.attr('tabindex', '-1');
5309            $(this).attr('tabindex', '0');
5310          }
5311        });
5312      })
5313
5314
5315      // var checkHash = window.location.hash.substring(1);
5316
5317      // if(checkHash !== ''){
5318
5319      //   var pageTabId = $('.js-tab-nav').filter('[data-tab-id]').data('tab-id');
5320
5321      //   var target_id = checkHash.replace(pageTabId+ '-', pageTabId),
5322      //       $target_tab = $tab__nav.find('[role="tab"]').filter('[href="#'+ target_id +'"]');
5323
5324      //   if($target_tab.length){
5325      //     $target_tab.trigger('click');
5326      //   }
5327      // }
5328
5329      // detectHash();
5330  }
5331
5332  function tabJumpTo($_select, _idx, _first_enter){
5333    if(_first_enter){return;}
5334    var $btn = $_select.closest('.js-tab-nav').find('[role="tablist"] > a').eq(_idx);
5335    // selectJumpTo($btn, _idx);
5336    // $btn.tab('show');
5337    if(!$btn.is('[role="tab"]')){
5338      var url = $btn.prop('href');
5339      if($btn.attr('target') == '_blank'){
5340        window.open(url, '_blank');
5341      } else {
5342        window.location = url;
5343      }
5344    }
5345    $btn.click();
5346
5347    // Manually toggle tab content in case Bootstrap's tab plugin
5348    // doesn't handle the programmatic click (e.g. on mobile dropdown).
5349    var $tabNav = $_select.closest('.js-tab-nav');
5350    var targetId = $btn.attr('href');
5351    if (targetId) {
5352      $tabNav.find('.blk-tab__tab-pane').removeClass('show active');
5353      $tabNav.find(targetId).addClass('show active');
5354      $tabNav.find('[role="tablist"] [role="tab"]').removeClass('show active').attr('aria-selected', 'false');
5355      $btn.addClass('show active').attr('aria-selected', 'true');
5356    }
5357    // jsSyncHeight.init();
5358  }
5359
5360  function selectJumpTo($_btn, _idx){
5361      var $top = $_btn.closest('.js-tab-nav'),
5362          $select = $top.find('select').eq(0),
5363          is_bootstrap_select = $select.parent().is('.multiselect-native-select');
5364
5365      $select[0].selectedIndex = _idx;
5366
5367      // console.log($select.val());
5368
5369      if( !$select.closest('.tab__content').length) {
5370        if($select.closest('.js-tab-nav').length && $select.closest('.js-tab-nav').data('tab-id')){
5371          if(Modernizr.history){
5372            history.pushState(null, null, $select.closest('.js-tab-nav').data('tab-id') +'/' + $select.val());
5373          }
5374        }
5375      }
5376
5377      if(is_bootstrap_select) {
5378        $select.multiselect('refresh');
5379      }
5380  }
5381
5382  // function detectHash() {
5383  //   var targetHash = window.location.hash.substring(1);
5384  //   $(window).on('load', function () {
5385
5386  //     if ($('.committee').length > 0) {
5387
5388  //       $('.tab__btn[aria-controls="' + targetHash + '"]').trigger('click');
5389  //       $('.tab__btn[aria-controls="' + targetHash + '"]').trigger('touchstart');
5390  //     }
5391
5392  //   });
5393
5394  //   // $(window).on('hashchange', function () {
5395  //   //   if ($('.committee').length > 0) {
5396  //   //     location.reload();
5397  //   //   }
5398  //   // });
5399  // }
5400
5401  return {
5402    init: setup,
5403    tabJumpTo: tabJumpTo
5404  }
5405}());
5406
5407;(function ($, root, undefined) {
5408
5409  $(function () {
5410
5411    // 'use strict';
5412
5413    $('body').removeClass('css-transitions-only-after-page-load');
5414
5415    cancelMouseFocusOutline.init();
5416
5417    skip2content.init();
5418
5419    jsWrapTable.init();
5420
5421    jsCkecEnhance.init();
5422
5423    responsiveImg.init();
5424
5425    jsScrollReveal.init();
5426
5427    jsSlick.init();
5428
5429    jsBsDropdownPreventCloseByClick.init();
5430
5431    jsBsDropdownShowSelected.init();
5432
5433    jsDotDot2.init();
5434
5435    jsSyncHeight.init();
5436
5437    jsHeader.init();
5438
5439   // jsTypeahead.init();
5440
5441    jsLoadMoreInit.init();
5442
5443    jsBsModal.init();
5444
5445    jsMobileMenu.init();
5446
5447    jsBsCollapseRte.init();
5448
5449    jsSelectTwo.init();
5450
5451    jsNiceScroll.init();
5452
5453    jsShowMore.init();
5454
5455    jsFilterBar.init();
5456
5457    jsMas.init();
5458
5459    jsParallax.init();
5460
5461    jsLazyLoad.init();
5462
5463    jsBsDropdownEv.init();
5464
5465    jsSelectBox.init();
5466
5467    jsBsTabNav.init();
5468
5469    // dont include the dummy select in live
5470    if(window.location.href.indexOf('localhost') > 0){
5471            var $dummySelect = $('<select style="top: 5px; left: 5px; position: fixed; z-index: 999;">\
5472        <option value="2">2</option>\
5473        <option value="1">1</option>\
5474        <option value="3">3</option>\
5475        <option value="4">4</option>\
5476        <option value="5">5</option>\
5477        <option value="6">6</option>\
5478        <option value="7">7</option>\
5479        <option value="8">8</option>\
5480        </select>');
5481
5482    $('body').append($dummySelect);
5483
5484    $dummySelect.on('change', function(){
5485        var $s = $(this);
5486        setTimeout(function(){
5487              $('body').removeClass('theme-color--type1 theme-color--type2 theme-color--type3 theme-color--type4 theme-color--type5 theme-color--type6 theme-color--type7 theme-color--type8')
5488              $('body').addClass('theme-color--type' + $s.val());
5489        }, 15);
5490    });
5491    }
5492    // dont include the dummy select in live
5493
5494  });
5495
5496})(jQuery, this);
5497
5498$( document ).ready(function() {
5499	$(".slider-feature__focus-side  .feature-promo-blk__imgctrl").css("padding-top", $(".slider-feature__focus-side  .feature-promo-blk").height() );
5500    $(".slider-feature__focus-side  .feature-promo-blk__imgctrl img").css("height", "100%") ;
5501    $(".page-menu__scroll-btn").click(function(){
5502      if ($(this).parent().hasClass("at-last")){
5503        $('.page-menu__list').animate({scrollLeft: "0px"}, "slow");
5504      } else {
5505        $('.page-menu__list').animate({scrollLeft: "+=150px"}, "slow");
5506      }
5507    });
5508	$("body").addClass("rloaded");
5509  $(".dropdown-cloud__inner .sm-icon-blk__imgw img").click(function(){ // Added by Raven 20190916 for saving time on adding a tag on social image
5510    window.open($(this).parent().parent().find("a").attr("href"), '_blank');
5511  });
5512  // Added for WCAG ===
5513  $("body").on("keydown", ".checkbox-label", function (e) {
5514    var keycode = e.keyCode || e.which;
5515    if (keycode==13 || keycode == 32){
5516        if (jQuery(this).parent().hasClass("btn")){
5517            jQuery(this).parent().click();
5518            e.preventDefault();
5519            return;
5520        }
5521        jQuery(this).find("input[type='checkbox']").trigger('click');
5522        jQuery(this).find("input[type='radio']").trigger('click');
5523    }
5524  });
5525  $(".select-two-blk .select-two-blk__title").keydown(function(e){
5526    var keycode = e.keyCode || e.which;
5527    if (keycode==13  || keycode==32){ jQuery(this).click(); }
5528  });
5529
5530  window.onkeydown = function(e) {
5531      var elem = e.target.nodename;
5532	  if( elem !== 'TEXTAREA' && elem != 'INPUT' && elem?.type == 'text') {
5533          return !(e.keyCode == 32);
5534      }
5535  };
5536//added on 20230605 for WCAG - contrast ratio changing
5537   console.log('tO-topic-box__text:first change color - #00364d');
5538   $(".tO-topic-box__text:first").css("color","#00364d");
5539
5540  // Show detail non-ethnic
5541  $('.icon-detail').click(function(e) {
5542    const element = e.currentTarget;
5543    if (element.classList.contains('close-detail')) {
5544      element.classList.remove('close-detail');
5545      element.setAttribute('aria-expanded', 'false');
5546    } else {
5547      element.classList.add('close-detail');
5548      element.setAttribute('aria-expanded', 'true');
5549    }
5550    const id = e.currentTarget.dataset.detailId ?? '';
5551    $('tr#detail-'+ id).toggle();
5552  })
5553
5554});
5555
5556//added on 20230410 for WCAG - aria-expanded on social media <a> tag
5557/*
5558const toggleButton = document.querySelector('.social_media_btn');
5559toggleButton.addEventListener('click', () => {
5560  toggleButton.setAttribute('aria-expanded', 'true');
5561
5562  setTimeout(function() {
5563    const myDiv = $("#at15s");
5564	myDiv.attr("onmouseout", "if (this.className.indexOf('border')==-1) {addthis_close();setAriaLabel();}");
5565  }, 500);
5566
5567});
5568
5569function setAriaLabel(){
5570	const toggleButton = document.querySelector('.social_media_btn');
5571	toggleButton.setAttribute('aria-expanded', 'false');
5572}
5573*/
5574function resetDataFilter(names=[], buttons=[], filters=[], idButtonSearch, ev){
5575  for(let index in names){
5576    $(`input[name="${names[index]}"]:checked`).each(function(ev) {
5577      $(this).prop('checked', false);
5578    });
5579  }
5580  for(let index in buttons){
5581    $(`.${buttons[index]}`).text($(`#${buttons[index]}`).attr('title'))
5582  }
5583  for(let index in filters){
5584    $(`#${filters[index]}`).addClass('d-none')
5585  }
5586  $(`#${idButtonSearch}`).attr('data-urlnext', $(ev).data('url'))
5587  $(`#${idButtonSearch}`).click()
5588
5589}
5590
5591function downLoadFileICS(ev){
5592  const data = ev.getAttribute('data-value')
5593  const blob = new Blob([data], { type: 'text/calendar' });
5594  // Create a link element
5595  const link = document.createElement('a');
5596  // Set the download attribute with a filename
5597  link.setAttribute('download', 'event.ics');
5598  // Create an object URL for the blob
5599  link.href = URL.createObjectURL(blob);
5600  // Append the link to the body
5601  document.body.appendChild(link);
5602  // Programmatically click the link to trigger the download
5603  link.click();
5604  // Remove the link from the document
5605  document.body.removeChild(link);
5606}
5607
5608function formatDate(date) {
5609
5610  return $.datepicker.formatDate("dd-mm-yy", new Date(date));
5611}
5612
5613function updateCollection( ) {
5614  const page = $('#js-loadmore-backup').attr('page');
5615  const collection = $('#js-loadmore-backup').data('collection');
5616  const categories =  $('#js-loadmore-backup').data('categories');
5617  const blueprint =  $('#js-loadmore-backup').data('blueprint');
5618  const site = $('#js-loadmore-backup').attr('data-site');
5619  const status = $('#js-loadmore-backup').attr('data-status');
5620  const published = $('#js-loadmore-backup').attr('data-published');
5621
5622  let param = {
5623    'filter[site:is]': site === 'en' ? 'default' :  site,
5624    'filter[data->categories:contains]': categories,
5625    'filter[data->external_url:doesnt_exist]': true,
5626    'filter[status:in]': status,
5627    'filter[published:in]': published,
5628    limit: 6,
5629    sort: '-date,id',
5630    page: (parseInt(page) || 1) + 1
5631  }
5632  if (blueprint) {
5633    param = {
5634      'filter[site:is]': site === 'en' ? 'default' :  site,
5635      'filter[data->categories:contains]': categories,
5636      'filter[blueprint:is]': 'new_articles',
5637      'filter[data->external_url:doesnt_exist]': true,
5638      'filter[status:in]': status,
5639      'filter[published:in]': published,
5640      limit:  6,
5641      sort: '-date,id',
5642      page: (parseInt(page) || 1) + 1
5643    }
5644  }
5645
5646  $.get(`/api/collections/${collection}/entries`, {
5647      ...param
5648    }).done(data => {
5649      data.data.forEach((activity, index) => {
5650          let activityHtml = generateActivityHtml(activity, index);
5651          $('#js-loadmore-data').append(activityHtml)
5652      });
5653      $('.ev-blk__title-section').each(function(i) {
5654        const titleHeight = $(this).height();
5655        $('.ev-blk__main').each(function(j) {
5656          if (i == j) {
5657            $(this).css("padding-top", (titleHeight+8))
5658          }
5659        })
5660      });
5661      if (!data.links?.next){
5662        $('#btn-loadmore-activities').empty()
5663      }
5664      else{
5665        $('#js-loadmore-backup').attr('page', (parseInt(page) || 1) + 1);
5666      }
5667    })
5668
5669  .fail(error => {
5670        return Promise.reject(error)
5671    })
5672}
5673
5674function updateCareerCollection( ) {
5675    const page = $('#js-loadmore-backup').attr('page');
5676    const collection = $('#js-loadmore-backup').data('collection');
5677    const categories =  $('#js-loadmore-backup').data('categories');
5678    const blueprint =  $('#js-loadmore-backup').data('blueprint');
5679    const site = $('#js-loadmore-backup').attr('data-site');
5680
5681    const status = $('#js-loadmore-backup').attr('data-status');
5682    const published = $('#js-loadmore-backup').attr('data-published');
5683
5684    let param = {
5685        site: site === 'en' ? 'default' :  site,
5686        categories: categories,
5687        status: status,
5688        published: published,
5689        limit: 6,
5690        sort: '-date,id',
5691        page: (parseInt(page) || 1) + 1
5692    }
5693
5694    $.get(`/api/collections/${collection}/mapTcEntries`, {
5695        ...param
5696    }).done(data => {
5697        data.data.forEach((activity, index) => {
5698            let currentEntryCategories = categories || activity.list_categories[0]?.slug || null;
5699
5700            let activityHtml = generateActivityHtml(activity, index, currentEntryCategories);
5701            $('#js-loadmore-data').append(activityHtml)
5702        });
5703        $('.ev-blk__title-section').each(function(i) {
5704            const titleHeight = $(this).height();
5705            $('.ev-blk__main').each(function(j) {
5706                if (i == j) {
5707                    $(this).css("padding-top", (titleHeight+8))
5708                }
5709            })
5710        });
5711        if (!data.links?.next){
5712            $('#btn-loadmore-activities').empty()
5713        }
5714        else{
5715             $('#js-loadmore-backup').attr('page', (parseInt(page) || 1) + 1);
5716        }
5717    })
5718
5719    .fail(error => {
5720        return Promise.reject(error)
5721    })
5722}
5723
5724function generateActivityHtml(activity, index, categories = null) {
5725  const lang = $('#js-loadmore-backup').attr('data-site');
5726  const defaultBanner = '/images/YP-image.png';
5727
5728  let dateHtml = `<p class="label-title-blk__time">${formatDate( activity.publish_date || activity.date)}</p>`;
5729  if (activity.collection.handle == "events") {
5730    dateHtml = `<p class="label-title-blk__time">${formatDate(activity.start_date)} ~ ${formatDate(activity.end_date)}</p>`
5731  }
5732
5733  return `
5734        <div class="col-md-6 col-12 p-0 m-0">
5735          <div class="ev-blk ev-blk--hori js-reveal-com pl-3 pr-3">
5736              <div class="ev-blk__imgw test-href-a">
5737                  <a href="${showDetail(lang, activity.collection.handle, activity.id, categories)}">
5738                      <div class="rounded-less-radius ev-blk__imgctrl img--abs-wrap">
5739                          <img src="${activity.cover_image_banner ? activity.cover_image_banner?.url : defaultBanner}"
5740                              class="img--abs lazy loaded"
5741                              alt="${activity.title}"
5742                              sizes="(min-width:1200px) 267px,(min-width:768px) 23vw, 44vw"
5743                              data-was-processed="true">
5744                          <p class="ev-blk__title ev-blk__title-section js-dot theme-color__text ddd-truncated">
5745                            ${activity.title}
5746                          </p>
5747                      </div>
5748                  </a>
5749              </div>
5750              <div class="ev-blk__main">
5751                  <p class="shadow-card-blk__desc truncate-2" style="overflow-wrap: break-word;">
5752                    ${ activity.collection.handle === "articles" ? '' : activity.venue?.address }
5753                  </p>
5754                  <div class="label-title-blk ev-blk__label-time">
5755                      ${rendercategories(activity.list_categories, lang)}
5756                      ${dateHtml}
5757                  </div>
5758                  <div class="ev-blk__hash hashtag-list theme-color__text js-dot"
5759                      style="overflow-wrap: break-word;">
5760                      ${renderTags(activity.list_tags)}
5761                  </div>
5762              </div>
5763          </div>
5764      </div>
5765      ${index % 2 !== 0 ? '<hr class="color-line color-line--light js-reveal-com col-12" aria-hidden="true" data-sr-id="5">'
5766        : '<hr class="d-block d-md-none color-line color-line--light js-reveal-com col-12" data-sr-id="5">'}
5767  `;
5768}
5769
5770function showDetail(lang, collection, slug, category = null, isJobOverview = false) {
5771  category = category ?? window.location.pathname.split('/')[2] ?? ''
5772
5773  if (collection == 'articles') {
5774      collection = isJobOverview ? 'job-overview' : 'stories';
5775  }else if (collection == 'events') {
5776      collection = 'activities';
5777  }
5778  return `/${lang}/${category}/${collection}/${slug}` ;
5779}
5780
5781function rendercategories(categories, lang){
5782  let html = ''
5783  categories.forEach(activity =>{
5784    if (activity.is_published) {
5785      html += `<a href="${showCategoryPage(lang, activity.slug)}" class="label-tag theme-color__text" target="_self">
5786                  ${activity.title}
5787              </a>`
5788    }
5789  })
5790  return html
5791}
5792
5793function showCategoryPage(lang, slug) {
5794  return `/${lang}/${slug}`
5795}
5796
5797function renderTags(tags){
5798  let html = ''
5799  tags.forEach(tag =>{
5800    if (tag.is_published) {
5801      html += `<span class="hashtag-list__item">
5802              <a href="${tag.permalink}">#${ tag.title }</a>
5803            </span>`
5804    }
5805  })
5806  return html
5807}
5808
5809// Find the trigger element (the button that carries the filter-dropdown config)
5810// which controls the given dropdown panel, i.e. the element with
5811// data-toggle-dropdown-json='{"id":"<panelId>",...}'.
5812function getDropdownTriggerByPanel(panelId){
5813  var trigger = null;
5814  document.querySelectorAll('[data-toggle-dropdown-json]').forEach(function(el){
5815    if (trigger) return;
5816    try {
5817      var cfg = JSON.parse(el.getAttribute('data-toggle-dropdown-json'));
5818      if (cfg && cfg.id === panelId) { trigger = el; }
5819    } catch (err) { /* ignore malformed config */ }
5820  });
5821  return trigger;
5822}
5823
5824// Reflect the dropdown open/closed state on the trigger element via aria-expanded.
5825function syncDropdownAriaExpanded(panelId, isOpen){
5826  var trigger = getDropdownTriggerByPanel(panelId);
5827  if (trigger) {
5828    trigger.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
5829  }
5830}
5831
5832function toggleDropdown(id, closeOther=[], nameCheckBox={}, IdButtonSearch=null){
5833  const element = $(`#${id}`)
5834  if (element.hasClass('d-none')) {
5835    element.removeClass('d-none');
5836    syncDropdownAriaExpanded(id, true);
5837  } else {
5838    element.addClass('d-none');
5839    syncDropdownAriaExpanded(id, false);
5840  }
5841  for(let idElement of closeOther){
5842    $(`#${idElement}`).addClass('d-none');
5843    syncDropdownAriaExpanded(idElement, false);
5844  }
5845  const { name , param, classButton} = nameCheckBox
5846  if (name){
5847    handleInputChange(name, param, classButton, IdButtonSearch);
5848  }
5849}
5850
5851function getProtocol(url) {
5852  return new URL(url).protocol;
5853}
5854
5855async function loadMoreJobOverview(ev, replace=false, idElement='js-loadmore-data', filters=[]){
5856  $(ev).attr('disabled', 'disabled')
5857  for(let index in filters){
5858    $(`#${filters[index]}`).addClass('d-none');
5859    syncDropdownAriaExpanded(filters[index], false);
5860  }
5861  let url = $(ev).attr('data-urlnext')
5862  let protocol = window.location.protocol;
5863  if(getProtocol(url) == 'http:' && protocol == 'https:') {
5864    url = url.replace('http:', 'https:');
5865  }
5866
5867  const html = await $.get(url)
5868  if (replace)
5869    $(`#${idElement}`).replaceWith($(html).find(`#${idElement}`));
5870  else
5871    $(html).find(`#${idElement}`).children().appendTo(`#${idElement}`);
5872  $('#btn-loadmore-activities').replaceWith($(html).find('#btn-loadmore-activities'));
5873  $('#btn-filter-job-overview').replaceWith($(html).find('#btn-filter-job-overview'));
5874
5875  handleInputChange('career-dropdown', 'b_ds', 'sys_dept');
5876  handleInputChange('terms_of_appointment', 'terms_of_appointment', 'sys_req');
5877  handleInputChange('academic_qualification_requirement', 'academic_qualification_requirement', 'list_academic_qualification_requirement');
5878  $(ev).removeAttr('disabled')
5879}
5880
5881function handleInputChange(inputName, urlFilterKey=None, titleButtonKey, buttonSearch='sys_gov_job_search') {
5882  $('input[name="' + inputName + '"]').change(function() {
5883      let title = getTitleButtonFilter(inputName);
5884      if (urlFilterKey)
5885        updateUrlFilter(buttonSearch, urlFilterKey, title);
5886      updateTitleButtonFilter(titleButtonKey, title);
5887      const children = $(this).data('children')
5888      if(title){
5889        const button = $(this).attr('button-disabled')
5890        $(`.${button}`).removeAttr('disabled')
5891      }
5892      else{
5893        const button = $(this).attr('button-disabled')
5894        $(`.${button}`).attr('disabled', 'disabled')
5895      }
5896      if (children){
5897        const childrens = $(`.${children}`)
5898        for(let child of childrens){
5899          if ($(child).data('parents')){
5900            const listTitle = title.split('|')
5901            const parent = $(child).data('parents')?.split(',')
5902            if (listTitle.some(item => parent.includes(item))){
5903              $(child).removeClass('d-none')
5904            }
5905            else{
5906              $(child).addClass('d-none')
5907            }
5908          }
5909        }
5910      }
5911  });
5912}
5913
5914function showMoreUserFulLink(ev, className='useful_link_list_', number=8){
5915  const index = $(ev).attr('data-index')
5916  const nextIndex = parseInt(index) + number
5917  const count = $(ev).data('count')
5918  for(let i=0; i<=nextIndex; i++){
5919    $(`.${className}${i}`).removeClass('d-none');
5920  }
5921
5922  $(ev).attr('data-index', nextIndex)
5923  if ((count * 1) - 1 <= nextIndex * 1){
5924    $(ev).remove()
5925  }
5926}
5927
5928async function btnSearchSubmit( ev, id_input, lang){
5929
5930  const keyword = $(`#${id_input}`).val()
5931  $('.btn-more').empty()
5932  await new searchPage(ev, lang, keyword).render('data-search-result')
5933}
5934
5935function searchPage(ev, lang, keyword){
5936  this.buttonSearch = $(ev)
5937  this.buttonSearch.attr('disabled', 'disabled')
5938  this.keyword = keyword;
5939  const self = this
5940  this.lang = lang;
5941  this.decodeKeyword = function(){
5942    return self.keyword.toLocaleLowerCase()
5943        .replace(/&/g, "&amp;")
5944        .replace(/"/g, "&quot;")
5945        .replace(/'/g, "&#39;");
5946  }()
5947  this.getDataSearchDetail = function(res){
5948    for (let data of res.data){
5949        const record = data
5950        let context = record.content || record.detail_content
5951        if (Array.isArray(context)) {
5952          context = context.filter(item => item.type === 'text' || item.type === "detail_content");
5953        }
5954        context = context.replace('\"', '')
5955        const div = document.createElement("div");
5956        div.innerHTML = JSON.stringify(context);
5957        const plainText = div.innerText.trim();
5958        record.content = plainText
5959    }
5960  }
5961  this.getData = async function (){
5962    if (!keyword){
5963      this.datas = []
5964      return
5965    }
5966    const datas = await $.get(`/api/collections/search/entries?site=${this.lang == 'en' ? 'default': this.lang}&keyword=${this.keyword}&page=${this.next_page || 1}`)
5967    // this.getDataSearchDetail(datas)
5968    this.datas = datas.data.filter(item => item !== undefined);
5969    this.next_page = datas.next_page
5970    this.total = datas.total
5971    const translations = await $.getJSON('/lang/' + this.lang + '.json');
5972    this.titleMore = translations.more
5973  }
5974  this.render = async function(position){
5975    this.position = position
5976    await this.getData()
5977    this.renderElement(position)
5978    this.buttonSearch.removeAttr('disabled')
5979  }
5980  this.searchMore = async function(){
5981    await this.getData()
5982    this.renderElement(this.position, true)
5983  }
5984
5985  this.renderElement = function(position, append=false){
5986    const datas = this.datas
5987    const page = $('.search-page')
5988    page.find('.length-search-result')?.find('.count')?.text(this.total)
5989    const element_data = page.find(`.${position}`)
5990    if (!append){
5991      element_data.empty()
5992    }
5993    for(let data of datas){
5994      const element = `
5995      <div data-id=${data.id} data-collection=${data.handle}>
5996          <hr class="color-line color-line--light js-reveal-com" style="margin: .5rem !important;">
5997          <div class="ev-blk ev-blk--hori">
5998              <div class="ev-blk__imgw">
5999                  <a href="${showDetail(lang, data.handle, data.id, data?.categories[0]?.slug)}">
6000                      <div class="ev-blk__imgctrl img--abs-wrap">
6001                          <img src="${data?.cover_image_banner ?? ''}"
6002                              class="img--abs lazy loaded"
6003                              alt="${data.title}"
6004                              data-was-processed="true">
6005                          <p class="ev-blk__title ev-blk__title-section js-dot theme-color__text" style="overflow-wrap: break-word;">
6006                            ${data.title}
6007                          </p>
6008                      </div>
6009                  </a>
6010              </div>
6011              <div class="ev-blk__main">
6012                  <div class="shadow-card-blk__desc truncate-2"
6013                      style="overflow-wrap: break-word;">
6014                      ${this.showContent(data)}
6015                  </div>
6016                  <div class="label-title-blk ev-blk__label-time">
6017                    ${rendercategories(data.categories, lang)}
6018                      <p class="label-title-blk__time label-title-blk__time--wrap">${formatDate(data.date)}</p>
6019                  </div>
6020                  <div class="ev-blk__hash hashtag-list theme-color__text">
6021                    ${renderTags(data.tags)}
6022                  </span>
6023              </div>
6024          </div>
6025      </div>
6026      `
6027      element_data.append(element)
6028    }
6029    $('.ev-blk__title-section').each(function(i) {
6030      const titleHeight = $(this).height();
6031      $('.ev-blk__main').each(function(j) {
6032        if (i == j) {
6033          $(this).css("padding-top", (titleHeight+8))
6034        }
6035      })
6036    });
6037    if (this.next_page && !this.btnMore) {
6038      this.btnMore = $(`
6039          <div class="more-btn-row js-reveal-com col-12 btn-more">
6040              <button class="more-btn-row__btn js-loadmore-btn theme-color__text">${this.titleMore || 'More'}</button>
6041          </div>
6042      `);
6043      this.btnMore.find('button').on('click', () => {
6044        this.btnMore.find('button').attr('disabled', 'disabled')
6045          this.searchMore();
6046      });
6047      $(element_data).after(this.btnMore);
6048    } else if (!this.next_page && this.btnMore) {
6049      this.btnMore.remove();
6050      this.btnMore = null;
6051    }
6052    if (this.btnMore) {
6053      this.btnMore.find('button').removeAttr('disabled')
6054    }
6055  }
6056  this.showContent = function(entry){
6057      let content = entry.content
6058      content = content.replaceAll(/<a[^>]*>|<\/a>|<img[^>]*>/g, '')
6059      content = content.replaceAll(/<p>[ , ]*<\/p>/g, '');
6060      let textDisplay = this.getTextDisplay(content)
6061
6062      if (!textDisplay) {
6063          return ''
6064      }
6065      const textDisplayLowerCase = textDisplay.toLowerCase();
6066      let keywordIndex = textDisplayLowerCase.indexOf(this.decodeKeyword)
6067
6068      if (keywordIndex < 0) {
6069        return ''
6070      }
6071
6072      let word = textDisplay.substring(keywordIndex, keywordIndex + this.decodeKeyword.length)
6073      textDisplay = '...' + textDisplay.substring(keywordIndex)
6074      textDisplay = textDisplay.replace(word, '<span class="key-word-text">' + word + '</span>')
6075      textDisplay = textDisplay.replace(/\\n/g, '')
6076      .replace(/^"/, '')
6077      .replace(/"$/, '')
6078      .replaceAll('\\', '')
6079
6080      return textDisplay
6081  }
6082  this.getTextDisplay = function(content) {
6083    let textDisplay = ''
6084    if (typeof content == 'string') {
6085        textDisplay = content.toLowerCase().includes(this.decodeKeyword) ? content : '';
6086    } else {
6087        textDisplay = this.findFirstText(content)
6088    }
6089
6090    return textDisplay
6091  }
6092}
6093
6094function adjustLayout() {
6095    $('.ev-blk__title-section').each(function(i) {
6096        const titleHeight = $(this).height();
6097        $('.ev-blk__main').each(function(j) {
6098            if (i == j) {
6099                $(this).css("padding-top", (titleHeight+8))
6100            }
6101        })
6102    });
6103
6104    $('.video-sec__title-block').each(function(i) {
6105        console.log('hhhh');
6106
6107        const _this = this;
6108        const titleHeight = $(this).height();
6109        $(_this).css("width", $('.video-sec__item').first().width() - $('.video-sec__img').first().width() - $('.video-sec__number').width() - 35);
6110        $('.video-sec__text').each(function(j) {
6111            if (i == j) {
6112                $(this).css("padding-top", (titleHeight))
6113            }
6114        })
6115        $('.video-sec__img').each(function(k) {
6116            const imgWidth = $(this).width();
6117            if (i == k) {
6118                if ($(window).width() <= 750) {
6119                    $(_this).css("left", -($('.video-sec__item').first().width() - imgWidth - $('.video-sec__number').width() - 5));
6120                    if (window.location.pathname.includes('/gov-job')) {
6121                        const parentElement = $(this).closest('.video-sec__content');
6122                        const timeElement = parentElement.find('.label-title-blk__time');
6123
6124                        if (timeElement.length > 0) {
6125                            $(_this).css("right", (timeElement.width() + 10));
6126                        }
6127                    } else {
6128                        $(_this).css("right", "");
6129                    }
6130                } else {
6131                  const pathname = window.location.pathname;
6132                  if(pathname.includes('/gov-job')) {
6133                    if($( window ).width() > 1100 && $(window ).width() < 1366) {
6134                      $(_this).css("right", (imgWidth + 30));
6135                    }else if($(window ).width() >= 1366 ) {
6136                      $(_this).css("right", (imgWidth + 50));
6137                    }else {
6138                      $(_this).css("right", (imgWidth));
6139                    }
6140                  }else {
6141                    $(_this).css("right", (imgWidth + 10));
6142                  }
6143
6144                    $(_this).css("left", "");
6145                }
6146            }
6147        })
6148    });
6149
6150    $('.side-img-blk__title').each(function(i) {
6151        const titleHeight = $(this).height();
6152        $('.side-img-blk__content-side').each(function(j) {
6153            if (i == j) {
6154                if ($(window).width() <= 750) {
6155                    $(this).css("padding-top", (titleHeight+35));
6156                } else {
6157                    $(this).css("padding-top", (titleHeight+5));
6158                }
6159            }
6160        })
6161    });
6162}
6163
6164function loadMoreSearch() {
6165  const loadMoreBtn = document.getElementById('load-more-btn');
6166  const resultsContainer = document.getElementById('results-container');
6167  const nextPageUrl = loadMoreBtn.getAttribute('data-next-page');
6168  const loadingBar = document.getElementById('loading-bar');
6169
6170  // Show the loading bar when search is triggered
6171  loadingBar.style.width = '0';
6172  loadingBar.style.opacity = '1';
6173  loadingBar.style.width = '100%';
6174  // Make an AJAX request to load more results
6175  fetch(nextPageUrl)
6176      .then(response => response.text())
6177      .then(data => {
6178          // Hide loading bar when the content is loaded
6179          loadingBar.style.opacity = '0';
6180          loadingBar.style.width = '0';
6181
6182          const parser = new DOMParser();
6183          const doc = parser.parseFromString(data, 'text/html');
6184          const newResults = doc.querySelectorAll('.searching-result');
6185
6186          // Append new results to the container
6187          newResults.forEach(result => {
6188              resultsContainer.appendChild(result);
6189          });
6190
6191          // Update the "Load More" button with the new next page URL
6192          const nextPageBtn = doc.getElementById('load-more-btn');
6193          if (nextPageBtn) {
6194              loadMoreBtn.setAttribute('data-next-page', nextPageBtn.getAttribute('data-next-page'));
6195          } else {
6196              // Remove the "Load More" button if there are no more pages
6197              loadMoreBtn.remove();
6198          }
6199          adjustLayout();
6200      })
6201      .catch(error => {
6202          console.error('Error loading more results:', error);
6203          // Optionally hide loading bar on error
6204          loadingBar.style.opacity = '0';
6205          loadingBar.style.width = '0';
6206      });
6207}
6208
6209// =============================================================================
6210// CSP-compliant delegated event handlers
6211// Replaces all inline onclick/onkeydown/javascript: attributes
6212// =============================================================================
6213;(function() {
6214    'use strict';
6215
6216    // --- Keyboard companion: Enter/Space triggers click on elements with data-csp-key ---
6217    $(document).on('keydown', '[data-csp-key]', function(e) {
6218        if (e.key === 'Enter' || e.key === ' ') {
6219            e.preventDefault();
6220            $(this).trigger('click');
6221        }
6222    });
6223
6224    // --- Language switcher: data-set-lang="en|tc|sc" ---
6225    $(document).on('click', '[data-set-lang]', function(e) {
6226        e.preventDefault();
6227        var lang = $(this).data('set-lang');
6228        if (typeof setLanguage === 'function') setLanguage(lang);
6229        var href = $(this).attr('href');
6230        if (href) {
6231            window.location.href = href;
6232        }
6233    });
6234
6235    // --- Dropdown toggle (simple): data-toggle-dropdown="id" ---
6236    $(document).on('click', '[data-toggle-dropdown]', function(e) {
6237        var $el = $(this);
6238        var val = $el.data('toggle-dropdown');
6239        // If value is a plain string, call toggleDropdown(id)
6240        if (typeof val === 'string' && typeof toggleDropdown === 'function') {
6241            toggleDropdown(val);
6242        }
6243    });
6244
6245    // --- Dropdown toggle (complex, with JSON): data-toggle-dropdown-json='{"id":"...","closeOthers":[...],"nameCheckBox":{...},"idButtonSearch":"..."}' ---
6246    $(document).on('click', '[data-toggle-dropdown-json]', function(e) {
6247        var cfg = $(this).data('toggle-dropdown-json');
6248        if (cfg && typeof toggleDropdown === 'function') {
6249            toggleDropdown(cfg.id, cfg.closeOthers || [], cfg.nameCheckBox || {}, cfg.idButtonSearch || null);
6250        }
6251    });
6252
6253    // --- Close dropdown options: data-close-dropdown-options="id" ---
6254    $(document).on('click', '[data-close-dropdown-options]', function(e) {
6255        var id = $(this).data('close-dropdown-options');
6256        if (typeof closeDropdownOptions === 'function') closeDropdownOptions(id);
6257    });
6258
6259    // --- Funding list show item: data-funding-show-item="type" ---
6260    $(document).on('click', '[data-funding-show-item]', function(e) {
6261        var type = $(this).data('funding-show-item');
6262        if (typeof fundingListHandleShowItem === 'function') fundingListHandleShowItem(type);
6263    });
6264
6265    // --- Show item: data-show-item="value" ---
6266    $(document).on('click', '[data-show-item]', function(e) {
6267        var val = $(this).data('show-item');
6268        if (typeof handleShowItem === 'function') handleShowItem(val);
6269    });
6270
6271    // --- Close popup: data-close-popup="selector" ---
6272    $(document).on('click', '[data-close-popup]', function(e) {
6273        var sel = $(this).data('close-popup');
6274        if (typeof closePopup === 'function') closePopup(sel);
6275    });
6276
6277    // --- Close navigation menu: data-nav-close="selector" ---
6278    $(document).on('click', '[data-nav-close]', function(e) {
6279        var sel = $(this).data('nav-close');
6280        if (typeof closePopup === 'function') closePopup(sel);
6281    });
6282
6283    // --- Search submit: data-search-submit='{"locale":"tc","input":"#selector"}' ---
6284    $(document).on('click', '[data-search-submit]', function(e) {
6285        var cfg = $(this).data('search-submit');
6286        if (cfg && typeof searchSubmit === 'function') searchSubmit(cfg.locale, cfg.input);
6287    });
6288
6289    // --- Search close: data-search-close ---
6290    $(document).on('click', '[data-search-close]', function(e) {
6291        if (typeof searchClose === 'function') searchClose();
6292    });
6293
6294    // --- Search: data-search ---
6295    $(document).on('click', '[data-search]', function(e) {
6296        if (typeof onSearch === 'function') onSearch();
6297    });
6298
6299    // --- Reset search: data-reset-search ---
6300    $(document).on('click', '[data-reset-search]', function(e) {
6301        if (typeof onResetSearch === 'function') onResetSearch();
6302    });
6303
6304    // --- Load more fund: data-load-more-fund ---
6305    $(document).on('click', '[data-load-more-fund]', function(e) {
6306        if (typeof loadMoreFund === 'function') loadMoreFund();
6307    });
6308
6309    // --- Toggle compare: data-toggle-compare ---
6310    $(document).on('click', '[data-toggle-compare]', function(e) {
6311        if (typeof toggleShowCompare === 'function') toggleShowCompare();
6312    });
6313
6314    // --- Update collection: data-update-collection ---
6315    $(document).on('click', '[data-update-collection]', function(e) {
6316        if (typeof updateCollection === 'function') updateCollection();
6317    });
6318
6319    // --- Update career collection: data-update-career ---
6320    $(document).on('click', '[data-update-career]', function(e) {
6321        if (typeof updateCareerCollection === 'function') updateCareerCollection();
6322    });
6323
6324    // --- Load more search: data-load-more-search ---
6325    $(document).on('click', '[data-load-more-search]', function(e) {
6326        if (typeof loadMoreSearch === 'function') loadMoreSearch();
6327    });
6328
6329    // --- Load more job overview: data-load-more-job='{"id":"...","closeDropdowns":[...]}' ---
6330    $(document).on('click', '[data-load-more-job]', function(e) {
6331        var cfg = $(this).data('load-more-job');
6332        if (cfg && typeof loadMoreJobOverview === 'function') {
6333            loadMoreJobOverview(this, true, cfg.id, cfg.closeDropdowns || []);
6334        }
6335    });
6336
6337    // --- Load more (simple, no config): data-load-more ---
6338    $(document).on('click', '[data-load-more]', function(e) {
6339        if (typeof loadMoreJobOverview === 'function') loadMoreJobOverview(this, true);
6340    });
6341
6342    // --- Reset filter: data-reset-filter='{"names":[...],"buttons":[...],"filters":[...],"idButtonSearch":"..."}' ---
6343    $(document).on('click', '[data-reset-filter]', function(e) {
6344        var cfg = $(this).data('reset-filter');
6345        if (cfg && typeof resetDataFilter === 'function') {
6346            resetDataFilter(cfg.names || [], cfg.buttons || [], cfg.filters || [], cfg.idButtonSearch, this);
6347        }
6348    });
6349
6350    // --- Download ICS: data-download-ics ---
6351    $(document).on('click', '[data-download-ics]', function(e) {
6352        if (typeof downLoadFileICS === 'function') downLoadFileICS(this);
6353    });
6354
6355    // --- Show more links: data-show-more='{"prefix":"...","count":6}' ---
6356    $(document).on('click', '[data-show-more]', function(e) {
6357        var cfg = $(this).data('show-more');
6358        if (cfg && typeof showMoreUserFulLink === 'function') {
6359            showMoreUserFulLink(this, cfg.prefix, cfg.count || 6);
6360        }
6361    });
6362
6363    // --- Back button: data-action="back" ---
6364    $(document).on('click', '[data-action="back"]', function(e) {
6365        e.preventDefault();
6366        window.history.back();
6367    });
6368
6369    // --- Blur self: data-action="blur-self" ---
6370    $(document).on('click', '[data-action="blur-self"]', function(e) {
6371        this.blur();
6372    });
6373
6374    // --- Open link in new window: data-open-link="url" ---
6375    $(document).on('click', '[data-open-link]', function(e) {
6376        e.preventDefault();
6377        var url = $(this).data('open-link');
6378        if (url) window.open(url);
6379    });
6380
6381    // --- Navigation menu dropdown toggle: data-nav-menu-drop ---
6382    $(document).on('click', '[data-nav-menu-drop]', function(e) {
6383        e.preventDefault();
6384        var $menu = $('.dropdown-main-menu');
6385        if ($menu.length) {
6386            $menu.toggleClass('show');
6387        }
6388    });
6389
6390    // --- Stop propagation on checkboxes/inputs inside dropdowns: data-stop-propagation ---
6391    $(document).on('click', '[data-stop-propagation]', function(e) {
6392        e.stopPropagation();
6393    });
6394
6395})();
6396
6397// =============================================================================
6398// Responsive table ARIA role: the govjob tables render a real <thead> on
6399// desktop (>= 768px) but collapse into card/list rows on mobile (< 768px),
6400// where the header row is hidden via CSS. So the table keeps its native table
6401// semantics on desktop, and role="presentation" is applied on mobile only.
6402// =============================================================================
6403;(function() {
6404    'use strict';
6405
6406    // Bootstrap "md" breakpoint (max-width: 767.98px => mobile)
6407    var GOVJOB_TABLE_MOBILE_BREAKPOINT = 768;
6408
6409    function applyGovJobTablePresentationRole() {
6410        var isMobile = window.innerWidth < GOVJOB_TABLE_MOBILE_BREAKPOINT;
6411        document.querySelectorAll('table.govjob-table').forEach(function (table) {
6412            if (isMobile) {
6413                table.setAttribute('role', 'presentation');
6414            } else {
6415                table.removeAttribute('role');
6416            }
6417        });
6418    }
6419
6420    if (document.readyState === 'loading') {
6421        document.addEventListener('DOMContentLoaded', applyGovJobTablePresentationRole);
6422    } else {
6423        applyGovJobTablePresentationRole();
6424    }
6425    window.addEventListener('resize', applyGovJobTablePresentationRole);
6426})();

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.