!function(){"use strict";window.jnews=window.jnews||{},window.jnews.jpreviewslider=window.jnews.jpreviewslider||{};var e="object"==typeof jnews&&"object"==typeof jnews.library,i="function"==typeof jnews.tns,t=!!e&&jnews.library,n=function(){if(e){return function(e){var n=function(e,i){this.jnewsLibrary=t,this.element=e,this.options=i,this.holder=this.element.getElementsByClassName("jeg_preview_media_content_holder"),this.slider=this.element.getElementsByClassName("jeg_preview_bottom_slider"),this.nav_next=this.element.querySelectorAll(".jeg_preview_media_content_navigation > div.next"),this.nav_prev=this.element.querySelectorAll(".jeg_preview_media_content_navigation > div.prev"),this.control_index=this.element.querySelectorAll(".jeg_preview_control .counter .current"),this.thumb=this.element.querySelectorAll(".jeg_preview_bottom_slider > a"),this.subtitle=this.element.querySelectorAll(".jeg_preview_control .subtitle"),this.description=this.element.getElementsByClassName("jeg_hidden_preview_description"),this.description_wrap=this.element.getElementsByClassName("jeg_preview_description_wrapper"),this.slider_ads=this.element.getElementsByClassName("jeg_preview_slider_ads"),this.mode="normal",this.mode_switcher=this.element.getElementsByClassName("fullscreen-switch"),this.preview_holder=this.element.getElementsByClassName("jeg_preview_holder"),this.description_holder=this.element.getElementsByClassName("jeg_preview_description"),this.preview_content=this.element.getElementsByClassName("jeg_preview_media_content"),this.text_title=this.element.querySelectorAll(".jeg_preview_media_holder h3"),this.index=0,this.max=this.thumb.length-1,this.zoom_size=0,this.zoom_reduce=this.element.querySelectorAll(".jeg_preview_control .reduce"),this.zoom_increase=this.element.querySelectorAll(".jeg_preview_control .increase"),this.zoom_cache=null,this.zoom_lock=!0,this.zoom_limit=[0,0,0,0],this.init()};n.DEFAULTS={textDirection:"ltr",native_zoom:!0,slideSpeed:100,fit:"fit",zoom_max:5,zoom_step:20,fullscreen_stop:976},n.prototype.init=function(){this.bind_event(),this.create_slider_normal(),this.assign_slider_event(),this.first_load()},n.prototype.first_load=function(){this.change_content(),this.change_subtitle(),this.slider_navigation_check()},n.prototype.bind_event=function(){var e,i=this;i.jnewsLibrary.forEach(i.zoom_reduce,(function(e,t){i.jnewsLibrary.addEvents(e,{click:function(){i.change_zoom("reduce")}})})),i.jnewsLibrary.forEach(i.zoom_increase,(function(e,t){i.jnewsLibrary.addEvents(e,{click:function(){i.change_zoom("increase")}})})),i.jnewsLibrary.forEach(i.holder,(function(e,t){i.jnewsLibrary.addEvents(e,{dblclick:function(){i.jnewsLibrary.forEach(i.mode_switcher,(function(e,t){i.jnewsLibrary.triggerEvents(e,"click")}))}})})),i.jnewsLibrary.forEach(i.holder,(function(e,t){var n,r,o=e;i.jnewsLibrary.addEvents(e,{mousedown:function(e){i.jnewsLibrary.addClass(o,"draggable");var t=e.pageY,s=e.pageX;n||(n={mousemove:function(e){i.do_dragging(e.pageX-s,e.pageY-t),t=e.pageY,s=e.pageX}}),r||(r={mouseup:function(){i.jnewsLibrary.removeClass(o,"draggable"),i.jnewsLibrary.removeEvents(i.jnewsLibrary.win,n)}}),i.jnewsLibrary.addEvents(i.jnewsLibrary.win,n),i.jnewsLibrary.addEvents(i.jnewsLibrary.win,r),e.preventDefault()},mouseup:function(){i.jnewsLibrary.removeClass(o,"draggable"),i.jnewsLibrary.removeEvents(i.jnewsLibrary.win,n)}})})),i.jnewsLibrary.forEach(i.mode_switcher,(function(e,t){i.jnewsLibrary.addEvents(e,{click:function(e){jnews.zoom&&jnews.zoom.resetZoom(),i.options.native_zoom?i.switch_mode():null===jnewsoption?i.open_magnific_popup():"photoswipe"===jnewsoption.popup_script?i.open_photoswipe_popup():i.open_magnific_popup(),e.preventDefault()}.bind(i)})})),i.jnewsLibrary.addEvents(i.jnewsLibrary.win,{resize:function(){i.jnewsLibrary.cancelAnimationFrame.call(i.jnewsLibrary.win,e),e=i.jnewsLibrary.requestAnimationFrame.call(i.jnewsLibrary.win,(function(){"normal"===i.mode?i.resize_normal():"fullscreen"===i.mode&&i.resize_fullscreen()}))}})},n.prototype.open_magnific_popup=function(){var e=this,i=e.options.image_sequence,t=e.index;jQuery.magnificPopup.instance.next=function(){jQuery.magnificPopup.proto.next.call(this),e.index>=e.max?e.index=0:e.index=e.index+1,e.do_change_slider()},jQuery.magnificPopup.instance.prev=function(){jQuery.magnificPopup.proto.prev.call(this),0===e.index?e.index=e.max:e.index=e.index-1,e.do_change_slider()},jQuery.magnificPopup.open({items:i,gallery:{enabled:!0},type:"image",closeOnContentClick:!0,closeBtnInside:!1,fixedContentPos:!0,mainClass:"mfp-no-margins mfp-with-zoom",image:{verticalFit:!0}},t)},n.prototype.open_photoswipe_popup=function(){var e=this,i=e.options.image_sequence,t=e.index,n=e.jnewsLibrary.globalBody.getElementsByClassName("pswp");if(n.length){n=n[0];var r=new PhotoSwipe(n,PhotoSwipeUI_Default,i,{index:t,history:!1,focus:!1,showAnimationDuration:0,hideAnimationDuration:0});r.listen("afterChange",(function(){e.index=r.getCurrentIndex(),e.do_change_slider()})),r.init()}},n.prototype.switch_mode=function(){"normal"===this.mode?this.fullscreen_mode():"fullscreen"===this.mode&&this.normal_mode()},n.prototype.fullscreen_mode=function(){this.mode="fullscreen",this.jnewsLibrary.addClass(this.jnewsLibrary.globalBody,"jeg_preview_body_hidden"),this.go_fullscreen(!0),this.keyboard_event("bind")},n.prototype.normal_mode=function(){this.mode="normal",this.jnewsLibrary.removeClass(this.jnewsLibrary.globalBody,"jeg_preview_body_hidden"),this.go_normal(),this.keyboard_event("unbind")},n.prototype.keyboard_event=function(e){var i=this;i.keyDown||(i.keyDown=function(e){37==e.keyCode?i.change_slider("prev"):39==e.keyCode?i.change_slider("next"):27==e.keyCode&&(i.mode="normal",i.normal_mode()),e.preventDefault()}),i.eventKeyDown||(i.eventKeydown={keydown:i.keyDown}),"bind"===e?i.jnewsLibrary.addEvents(i.jnewsLibrary.globalBody,i.eventKeydown):"unbind"===e&&i.jnewsLibrary.removeEvents(i.jnewsLibrary.globalBody,i.eventKeydown)},n.prototype.resize_normal=function(){this.change_content()},n.prototype.resize_fullscreen=function(){this.jnewsLibrary.windowWidth()>this.options.fullscreen_stop?this.go_fullscreen(!1):(this.mode="normal",this.normal_mode())},n.prototype.go_fullscreen=function(e){var i,t=this,n=t.jnewsLibrary.windowWidth(),r=t.jnewsLibrary.windowHeight();i=n-400,t.jnewsLibrary.addClass(t.element,"fullscreen"),t.jnewsLibrary.forEach(t.preview_holder,(function(e,t){e.style.width=i+"px"})),t.jnewsLibrary.forEach(t.description_holder,(function(e,i){e.style.width="400px"})),t.jnewsLibrary.forEach(t.description_wrap,(function(e,i){var n=e,o=0;t.jnewsLibrary.forEach(t.slider_ads,(function(e,i){o=t.jnewsLibrary.getWidth(e)})),n.style.height=r-o+"px"})),e&&t.recreate_slider("fullscreen"),t.jnewsLibrary.forEach(t.preview_content,(function(e,i){var n=e,o=0,s=0;t.jnewsLibrary.forEach(t.slider,(function(e,i){o=e.getBoundingClientRect().height})),t.jnewsLibrary.forEach(t.text_title,(function(e,i){s=e.getBoundingClientRect().height})),n.style.height=r-o-s+"px"})),t.change_content()},n.prototype.go_normal=function(){this.jnewsLibrary.removeClass(this.element,"fullscreen"),this.jnewsLibrary.forEach(this.preview_holder,(function(e,i){e.style.width="auto"})),this.jnewsLibrary.forEach(this.description_holder,(function(e,i){e.style.width="auto"})),this.jnewsLibrary.forEach(this.preview_content,(function(e,i){e.style.height="auto"})),this.recreate_slider("normal"),this.change_content()},n.prototype.recreate_slider=function(e){var i=this;i.jnewsLibrary.forEach(i.slider,(function(t,n){i.sliderActive=i.jnewsLibrary.dataStorage.has(t,"tiny-slider")?i.jnewsLibrary.dataStorage.get(t,"tiny-slider"):i.sliderActive,i.jnewsLibrary.removeClass(t,"jeg_tns_active"),"fullscreen"===e&&(i.create_slider_fullscreen(),i.assign_slider_event(!0)),"normal"===e&&(i.create_slider_normal(),i.assign_slider_event(!0)),i.do_change_slider()}))},n.prototype.create_slider_normal=function(){var e=this;if(i){var t={loop:!1,mouseDrag:!0,textDirection:e.options.textDirection,controls:!1,gutter:15,controlsText:["",""],nav:!1,edgePadding:15,responsive:{0:{items:3},480:{items:4},768:{items:5},1e3:{items:7}}};if(e.sliderActive){var n=e.sliderActive.getInfo();e.sliderActive;e.sliderActive.destroy(),e.thumb=e.element.querySelectorAll(".jeg_preview_bottom_slider > a"),e.jnewsLibrary.hasClass(n.container,"jeg_tns_active")||(t.container=n.container,e.sliderActive=e.sliderActive.rebuild(t),e.sliderActive.events.on("dragStart",(function(e){e.event.preventDefault(),e.event.stopPropagation()})),e.jnewsLibrary.addClass(n.container,"jeg_tns_active"),e.jnewsLibrary.dataStorage.put(n.container,"tiny-slider",e.sliderActive))}else e.jnewsLibrary.forEach(e.slider,(function(i,n){e.jnewsLibrary.hasClass(i,"jeg_tns_active")||(t.container=i,e.sliderActive=jnews.tns(t),void 0!==e.sliderActive&&(e.sliderActive.events.on("dragStart",(function(e){e.event.preventDefault(),e.event.stopPropagation()})),e.jnewsLibrary.addClass(i,"jeg_tns_active"),e.jnewsLibrary.dataStorage.put(i,"tiny-slider",e.sliderActive)))}))}else console.warn("Tiny Slider could not be found")},n.prototype.create_slider_fullscreen=function(){var e=this;if(i){var t={loop:!1,mouseDrag:!0,textDirection:e.options.textDirection,controls:!1,gutter:15,controlsText:["",""],nav:!1,edgePadding:15,responsive:{0:{items:2},480:{items:3},768:{items:5},1e3:{items:6},1200:{items:8},1600:{items:10}}};if(e.sliderActive){var n=e.sliderActive.getInfo();e.sliderActive;e.sliderActive.destroy(),e.thumb=e.element.querySelectorAll(".jeg_preview_bottom_slider > a"),e.jnewsLibrary.hasClass(n.container,"jeg_tns_active")||(t.container=n.container,e.sliderActive=e.sliderActive.rebuild(t),e.sliderActive.events.on("dragStart",(function(e){e.event.preventDefault(),e.event.stopPropagation()})),e.jnewsLibrary.addClass(n.container,"jeg_tns_active"),e.jnewsLibrary.dataStorage.put(n.container,"tiny-slider",e.sliderActive))}else e.jnewsLibrary.forEach(e.slider,(function(i,n){e.jnewsLibrary.hasClass(i,"jeg_tns_active")||(t.container=i,e.sliderActive=jnews.tns(t),void 0!==e.sliderActive&&(e.sliderActive.events.on("dragStart",(function(e){e.event.preventDefault(),e.event.stopPropagation()})),e.jnewsLibrary.addClass(i,"jeg_tns_active"),e.jnewsLibrary.dataStorage.put(i,"tiny-slider",e.sliderActive)))}))}else console.warn("Tiny Slider could not be found")},n.prototype.assign_slider_event=function(e){var i=this;i.jnewsLibrary.forEach(i.thumb,(function(e,t){i.jnewsLibrary.addEvents(e,{click:function(e){e.preventDefault(),i.index=parseInt(this.dataset.id),i.do_change_slider()}})})),e||(i.jnewsLibrary.forEach(i.nav_next,(function(e,t){var n={click:function(e){e.preventDefault(),i.change_slider("next")}};i.jnewsLibrary.addEvents(e,n)})),i.jnewsLibrary.forEach(i.nav_prev,(function(e,t){var n={click:function(e){e.preventDefault(),i.change_slider("prev")}};i.jnewsLibrary.addEvents(e,n)})))},n.prototype.change_slider=function(e){if(this.index="next"===e?this.index+1:this.index-1,this.index<0||this.index>this.max)return this.index<0&&(this.index=0),void(this.index>this.max&&(this.index=this.max));this.do_change_slider()},n.prototype.slider_navigation_check=function(){0===this.max?(this.jnewsLibrary.forEach(this.nav_next,(function(e,i){e.style.display="none"})),this.jnewsLibrary.forEach(this.nav_prev,(function(e,i){e.style.display="none"}))):0===this.index?(this.jnewsLibrary.forEach(this.nav_prev,(function(e,i){e.style.display="none"})),this.jnewsLibrary.forEach(this.nav_next,(function(e,i){e.style.display="block"}))):this.index===this.max?(this.jnewsLibrary.forEach(this.nav_next,(function(e,i){e.style.display="none"})),this.jnewsLibrary.forEach(this.nav_prev,(function(e,i){e.style.display="block"}))):(this.jnewsLibrary.forEach(this.nav_next,(function(e,i){e.style.display="block"})),this.jnewsLibrary.forEach(this.nav_prev,(function(e,i){e.style.display="block"})))},n.prototype.do_change_slider=function(){var e=this,i=e.thumb[e.index];e.jnewsLibrary.hasClass(i,"active")||e.jnewsLibrary.forEach(e.slider,(function(i,t){e.sliderActive=e.jnewsLibrary.dataStorage.has(i,"tiny-slider")?e.jnewsLibrary.dataStorage.get(i,"tiny-slider"):e.sliderActive,e.sliderActive.goTo(e.index)})),e.jnewsLibrary.forEach(e.thumb,(function(t,n){e.jnewsLibrary.removeClass(t,"active"),e.jnewsLibrary.addClass(i,"active")})),e.jnewsLibrary.forEach(e.control_index,(function(i,t){i.innerText&&(i.innerText=e.index+1),i.textContent&&(i.textContent=e.index+1)})),e.change_content(),e.slider_navigation_check()},n.prototype.reset_zoom=function(){var e=this;e.zoom_size=0,e.zoom_lock=!0,e.jnewsLibrary.forEach(e.zoom_reduce,(function(i,t){e.jnewsLibrary.addClass(i,"off")})),e.jnewsLibrary.forEach(e.zoom_increase,(function(i,t){e.jnewsLibrary.removeClass(i,"off")})),e.jnewsLibrary.forEach(e.holder,(function(i,t){e.jnewsLibrary.removeClass(i,"jeg_preview_grabbing")}))},n.prototype.change_subtitle=function(){var e=this.thumb[this.index].dataset.title;return this.jnewsLibrary.forEach(this.subtitle,(function(i,t){""===e?i.style.display="none":(i.style.display="block",i.textContent=e)})),e},n.prototype.change_description=function(){var e=this;e.description.length&&(e.jnewsLibrary.forEach(e.description,(function(i,t){e.jnewsLibrary.removeClass(i,"active")})),e.jnewsLibrary.addClass(e.description[e.index],"active"))},n.prototype.change_content=function(){var e=this,i=new Image,t=e.index,n=e.thumb[t].dataset.image;e.reset_zoom(),e.jnewsLibrary.forEach(e.holder,(function(i,t){e.jnewsLibrary.forEach(i.getElementsByTagName("img"),(function(e,i){e&&e.parentNode.removeChild(e)}))})),e.change_subtitle(),e.change_description(),e.jnewsLibrary.addEvents(i,{load:function(){if(t===e.index){var n=e.image_resize_calc(i,e.holder,"fit");e.zoom_cache=n,e.jnewsLibrary.addClass(i,"jeg_preview_hide"),e.jnewsLibrary.forEach(e.holder,(function(t,n){e.jnewsLibrary.forEach(t.getElementsByTagName("img"),(function(e,i){e&&e.parentNode.removeChild(e)})),t.append(i)})),i.style.height=Math.floor(n[0])+"px",i.style.width=Math.floor(n[1])+"px",i.style.left=Math.floor(n[2])+"px",i.style.top=Math.floor(n[3])+"px",i.style.maxWidth="inherit",i.style.display="inline",e.zoom_lock=!1}}}),i.setAttribute("src",n)},n.prototype.change_zoom=function(e){var i=this;if(!i.zoom_lock){if(i.zoom_size="increase"===e?i.zoom_size+1:i.zoom_size-1,i.zoom_size<0||i.zoom_size>i.options.zoom_max)return i.zoom_size<0&&(i.zoom_size=0),void(i.zoom_size>i.options.zoom_max&&(i.zoom_size=i.options.zoom_max));i.zoom_size<=0?(i.jnewsLibrary.forEach(i.zoom_reduce,(function(e,t){i.jnewsLibrary.addClass(e,"off")})),i.jnewsLibrary.forEach(i.zoom_increase,(function(e,t){i.jnewsLibrary.removeClass(e,"off")})),i.jnewsLibrary.forEach(i.holder,(function(e,t){i.jnewsLibrary.removeClass(e,"jeg_preview_grabbing")})),i.zoom_size=0):i.zoom_size>=i.options.zoom_max?(i.jnewsLibrary.forEach(i.zoom_reduce,(function(e,t){i.jnewsLibrary.removeClass(e,"off")})),i.jnewsLibrary.forEach(i.zoom_increase,(function(e,t){i.jnewsLibrary.addClass(e,"off")})),i.jnewsLibrary.forEach(i.holder,(function(e,t){i.jnewsLibrary.addClass(e,"jeg_preview_grabbing")})),i.zoom_size=i.options.zoom_max):(i.jnewsLibrary.forEach(i.zoom_reduce,(function(e,t){i.jnewsLibrary.removeClass(e,"off")})),i.jnewsLibrary.forEach(i.zoom_increase,(function(e,t){i.jnewsLibrary.removeClass(e,"off")})),i.jnewsLibrary.forEach(i.holder,(function(e,t){i.jnewsLibrary.addClass(e,"jeg_preview_grabbing")}))),i.change_image_zoom(e)}},n.prototype.do_dragging=function(e,i){var t=this;t.zoom_size>0&&t.jnewsLibrary.forEach(t.holder,(function(n,r){var o=n.getElementsByTagName("img");t.jnewsLibrary.forEach(o,(function(n,r){var o=n,s=o.offsetTop+i,a=o.offsetLeft+e;st.zoom_limit[0]&&(s=t.zoom_limit[0]),at.zoom_limit[2]&&(a=t.zoom_limit[2]),n.style.top=s+"px",n.style.left=a+"px"}))}))},n.prototype.change_image_zoom=function(e){var i=this;i.jnewsLibrary.forEach(i.holder,(function(t,n){var r=t;i.jnewsLibrary.forEach(r.getElementsByTagName("img"),(function(t,n){var o,s,a,c,l,d,h=t,_=i.zoom_size,y=i.options.zoom_step,f=Math.floor(i.zoom_cache[0]+i.zoom_cache[0]*y*_/100),m=Math.floor(i.zoom_cache[1]+i.zoom_cache[1]*y*_/100);"increase"===e?(o=h.offsetTop-i.zoom_cache[0]*y/2/100,s=h.offsetLeft-i.zoom_cache[1]*y/2/100):(o=h.offsetTop+i.zoom_cache[0]*y/2/100,s=h.offsetLeft+i.zoom_cache[1]*y/2/100);var p=i.jnewsLibrary.getHeight(r),w=i.jnewsLibrary.getWidth(r);p>f?c=(a=(p-f)/2)+f:(a=0,c=p-f),w>m?d=(l=(w-m)/2)+m:(l=0,d=w-m),i.zoom_limit=[a,c,l,d],i.zoom_size>0?(oa&&(o=a),sl&&(s=l)):(o=(p-f)/2,s=(w-m)/2),h.style.height=f+"px",h.style.width=m+"px",h.style.left=s+"px",h.style.top=o+"px"}))}))},n.prototype.image_resize_calc=function(e,i){var t,n,r=this,o=e.naturalHeight,s=e.naturalWidth;0===o&&r.jnewsLibrary.forEach(e,(function(e,i){o=e.dataset.height,s=e.dataset.width}));var a=0,c=0;r.jnewsLibrary.forEach(i,(function(e,i){a=r.jnewsLibrary.getHeight(e),c=r.jnewsLibrary.getWidth(e)}));var l=o/s;return a>o&&c>s?[t=o,n=s,(c-n)/2,(a-t)/2]:a/c>l?[t=c*l,n=c,(c-n)/2,(a-t)/2]:[t=a,n=a/l,(c-n)/2,(a-t)/2]},jnews.library.winLoad((function(){var i=e,r=t.extend({},n.DEFAULTS,i.dataset),o=!!t.dataStorage.has(i,"jeg.previewslider")&&t.dataStorage.get(i,"jeg.previewslider");o||t.dataStorage.put(i,"jeg.previewslider",o=new n(e,r))}))}}e||console.warn("JNews Library could not be found")}();window.jnews.jpreviewslider=n}();