/*
 * Copyright © 2021 Regular Labs - All Rights Reserved
 * License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */
var RegularLabsSliders=null;(function($){"use strict";RegularLabsSliders={options:{},timers:[],scroll_to:null,scrolling:false,init:function(options){var self=this;options=options?options:this.getOptions();this.options=options;try{this.hash_id=decodeURIComponent(window.location.hash.replace('#',''));if(this.hash_id.indexOf('/')>-1||this.hash_id.indexOf('/')>-1){this.hash_id='';}}catch(err){this.hash_id='';}
this.current_url=window.location.href;if(this.current_url.indexOf('#')>-1){this.current_url=this.current_url.substr(0,this.current_url.indexOf('#'));}
this.current_path=this.current_url.replace(/^.*\/\/.*?\//,'');$('.rl_sliders-body:not(.in)').height(0);$('.rl_sliders').removeClass('has_effects');var timeout=$('.rl_tabs').length?250:0;setTimeout((function(){self.initActiveClasses();if(options.use_cookies){self.showByCookies();}self.initScrollTracking();self.showByURL();self.showByHash();setTimeout((function(){self.initClickMode();self.initHoverMode();if(options.use_cookies||options.set_cookies){self.initCookieHandling();}if(options.use_hash){self.initHashHandling();}
self.initHashLinkList();if(options.reload_iframes){self.initIframeReloading();}
if(typeof $().emulateTransitionEnd!='function'){$('.rl_sliders').addClass('has_effects');}}),1000);}),timeout);},show:function(id,scroll,openparents){if(openparents){this.openParents(id);return;}
var self=this;var $el=this.getElement(id);if(!$el.length){return;}
$el.one('hidden.bs.collapse',function(){$('a#slider-'+id).attr('aria-expanded',false);$('div#'+id).attr('aria-hidden',true);});if(scroll&&!$el.hasClass('in')){$el.one('shown.bs.collapse',function(){$('html,body').animate({scrollTop:self.getScrollToElement($el).offset().top});});}if(this.scroll_to){this.setScrollOnLoad($el);}
var show=(!$el.hasClass('in')&&!$el.hasClass('active'));if(show){$el.collapse({toggle:true,parent:$el.parent().parent()});$el.collapse('show');$el.closest('div.rl_sliders').find('.rl_sliders-toggle').attr('aria-expanded',false);$('a#slider-'+id).attr('aria-expanded',true);$el.closest('div.rl_sliders').find('.rl_sliders-body').attr('aria-hidden',true);$('div#'+id).attr('aria-hidden',false);window.dispatchEvent(new Event('resize'));}
this.updateActiveClassesOnSliderLinks($el);setTimeout(function(){$el[0].focus();},10);},setScrollOnLoad:function($el){var self=this;if($el.hasClass('in')){self.scrollOnLoad();return;}
$el.one('shown.bs.collapse',function(){self.scrollOnLoad();});},scrollOnLoad:function(){var self=this;if(this.scrolling){setTimeout(function(){self.scrollOnLoad();},100);return;}
clearTimeout(self.timers['scroll']);self.timers['scroll']=setTimeout(function(){if(!self.scroll_to){return;}
$('html,body').animate({scrollTop:self.scroll_to.offset().top});self.scroll_to=null;},100);},getElement:function(id){return this.getSliderElement(id);},getTabElement:function(id){return $('a.rl_tabs-toggle[data-id="'+id+'"]');},getSliderElement:function(id){return $('#'+id+'.rl_sliders-body');},showByCookies:function(){var cookies=$.cookie(this.options.cookie_name);if(!cookies){return;}
cookies=cookies.split('___');for(var i=0;i<cookies.length;i++){var keyval=cookies[i].split('=');if(keyval.length<2){continue;}
var key=keyval.shift();if(key.substr(0,14)!='set-rl_sliders'){continue;}
this.openParents(decodeURIComponent(keyval.join('=')));}},initScrollTracking:function(){var self=this;self.scrolling=true;self.timers['scrolling']=setTimeout((function(){self.scrolling=false;}),250);var scroll_function_orig=window.onscroll;window.onscroll=(function(){self.scrolling=true;clearTimeout(self.timers['scrolling']);self.timers['scrolling']=setTimeout((function(){self.scrolling=false;}),1250);if(scroll_function_orig){scroll_function_orig();}});},showByURL:function(){var id=this.getUrlVar();if(id==''){return;}
this.showByID(id,this.options.urlscroll);},showByHash:function(){if(this.hash_id==''){return;}
var id=this.hash_id;if(id==''||id.indexOf("&")!=-1||id.indexOf("=")!=-1){return;}
if($('a.rl_tabs-toggle[data-id="'+id+'"]').length){return;}
if(!$('a#rl_sliders-scrollto_'+id).length){this.showByHashAnchor(id);return;}
if(!this.options.use_hash){return;}
if(!this.options.urlscroll){$('html,body').animate({scrollTop:0});}
this.showByID(id,this.options.urlscroll);},showByHashAnchor:function(id){if(id==''){return;}
var $anchor=$('[id="'+id+'"],a[name="'+id+'"],a#anchor-'+id);if(!$anchor.length){return;}
$anchor=$anchor.first();if(!$anchor.closest('.rl_sliders').length){return;}
var $slider=$anchor.closest('.rl_sliders-body').first();this.setScrollToElement($anchor);this.openParents($slider.attr('id'));},showByID:function(id,scroll){var $el=$('a#rl_sliders-scrollto_'+id);if(!$el.length){return;}if(scroll){this.setScrollToElement(this.getScrollToElement($el));}this.openParents(id);},getScrollToElement:function($el){var scrolling_type=$el.closest('.rl_sliders-group').find('.rl_sliders-toggle').hasClass('rl_sliders-item-scroll')?2:this.options.scroll;switch(scrolling_type){case 2:var $scroll_to=$el.closest('.rl_sliders-group').find('.rl_sliders-scroll').first();break;case 1:default:var $scroll_to=$el.closest('.rl_sliders').find('.rl_sliders-scroll').first();break;}
if(!$scroll_to.length){return null;}
return $scroll_to;},setScrollToElement:function($el){if(!$el.length){return;}
this.scroll_to=$el;},openParents:function(id){var $el=this.getElement(id);if(!$el.length){return;}
var parents=[];var parent=this.getElementArray($el);while(parent){parents[parents.length]=parent;parent=this.getParent(parent.el);}
if(!parents.length){return false;}
this.stepThroughParents(parents,null);},stepThroughParents:function(parents,parent){var self=this;if(!parents.length&&parent){self.show(parent.id);return;}
parent=parents.pop();if(parent.el.hasClass('in')||parent.el.parent().hasClass('active')){self.stepThroughParents(parents,parent);return;}
switch(parent.type){case'tab':if(typeof RegularLabsTabs==='undefined'){self.stepThroughParents(parents,parent);break;}
parent.el.one('shown.bs.tab',function(){self.stepThroughParents(parents,parent);});RegularLabsTabs.show(parent.id);break;case'slider':parent.el.one('shown.bs.collapse',function(){self.stepThroughParents(parents,parent);});self.show(parent.id);break;}},getParent:function($el){if(!$el){return false;}
var $parent=$el.parent().closest('.rl_tabs-pane, .rl_sliders-body');if(!$parent.length){return false;}
return this.getElementArray($parent);},getElementArray:function($el){var id=$el.attr('data-toggle')?$el.attr('data-id'):$el.attr('id');var type=($el.hasClass('rl_tabs-pane')||$el.hasClass('rl_tabs-toggle'))?'tab':'slider';return{'type':type,'id':id,'el':type=='tab'?this.getTabElement(id):this.getSliderElement(id)};},initActiveClasses:function(){$('.rl_sliders-body').on('show.bs.collapse',function(e){if(!$(e.target).hasClass('rl_sliders-body')){return;}
$(this).parent().addClass('active');$('a[data-toggle="collapse"][data-id="'+this.id+'"]').removeClass('collapsed');e.stopPropagation();});$('.rl_sliders-body').on('hidden hidden.bs.collapse',function(e){if(!$(e.target).hasClass('rl_sliders-body')){return;}
$(this).parent().removeClass('active');$('a[data-toggle="collapse"][data-id="'+this.id+'"]').addClass('collapsed');e.stopPropagation();});},updateActiveClassesOnSliderLinks:function(active_el){active_el.parent().parent().find('.rl_sliders-toggle').each(function($i,el){$('a.rl_sliders-link[data-id="'+$(el).attr('data-id')+'"]').each(function($i,el){var $link=$(el);if($link.attr('data-toggle')||$link.hasClass('rl_tabs-toggle-sm')||$link.hasClass('rl_sliders-toggle-sm')){return;}
if($link.attr('data-id')!==active_el.attr('id')){$link.removeClass('active');return;}
$link.addClass('active');});});},initHashLinkList:function(){var self=this;$('a[href^="#"],'+'a[href^="'+this.current_url+'#"],'+'a[href^="'+this.current_path+'#"],'+'a[href^="/'+this.current_path+'#"],'+'area[href^="#"],'+'area[href^="'+this.current_url+'#"]'+'area[href^="'+this.current_path+'#"]'+'area[href^="/'+this.current_path+'#"]').each(function($i,el){self.initHashLink(el);});},initHashLink:function(el){var self=this;var $link=$(el);if($link.attr('data-toggle')||$link.hasClass('rl_sliders-toggle')||$link.hasClass('rl_tabs-toggle')||$link.hasClass('rl_tabs-toggle-sm')||$link.hasClass('rl_tabs-link')){return;}
var id=$link.attr('href').substr($link.attr('href').indexOf('#')+1);id=id.replace(/^\//,'');id=id.replace(/^(.*?) .*$/,'$1');if(id==''){return;}var scroll=this.options.linkscroll;var is_slider=true;var $anchor=$('a[data-toggle="collapse"][data-id="'+id+'"]');if(!$anchor.length){$anchor=$('[id="'+id+'"],a[name="'+id+'"]');if(!$anchor.length){return;}
scroll=true;is_slider=false;}
$anchor=$anchor.first();if(!$anchor.closest('.rl_sliders').length){return;}
var $slider=$anchor.closest('.rl_sliders-group').find('.rl_sliders-body').first();var slider_id=$slider.attr('id');if($link.closest('.rl_sliders').length){if($link.closest('.rl_sliders-body').first().attr('id')==slider_id){return;}}
$link.click(function(e){e.preventDefault();var slider_open=$slider.hasClass('in');var scroll_to=is_slider?self.getScrollToElement($slider):$anchor;self.showByID(slider_id);if(scroll){if(slider_open){$('html,body').animate({scrollTop:scroll_to.offset().top});history.replaceState({},'',self.current_url+'#'+id);return;}
$slider.one('shown.bs.collapse',function(e){$('html,body').animate({scrollTop:scroll_to.offset().top});history.replaceState({},'',self.current_url+'#'+id);e.stopPropagation();});}e.stopPropagation();});},initHashHandling:function(){if(!window.history.replaceState){return;}
var self=this;$('.rl_sliders-body').on('shown.bs.collapse',function(e){history.replaceState({},'',self.current_url+'#'+this.id);e.stopPropagation();});},initClickMode:function(){var self=this;$('body').on('click.collapse.data-api','a.rl_sliders-toggle',function(e){e.preventDefault();var id=$(this).attr('data-id');var $el=self.getElement(id);if(!$el.hasClass('in')){self.show(id,$(this).hasClass('rl_sliders-item-scroll'));}else{$el.collapse('hide');}
e.stopPropagation();});},initHoverMode:function(){var mode=this.options.mode;$('body').on('mouseenter.collapse.data-api','a.rl_sliders-toggle',function(e){var group=$(this).closest('.rl_sliders-group');if((mode=='hover'&&group.hasClass('click'))||(mode=='click'&&!group.hasClass('hover'))){return;}
e.preventDefault();RegularLabsSliders.show($(this).attr('data-id'));});$('body').on('click.collapse.data-api','a.rl_sliders-toggle',function(e){var group=$(this).closest('.rl_sliders-group');if(!group.hasClass('hover')){return;}
group.removeClass('hover');$('body').one('mouseenter.collapsed.data-api','a.rl_sliders-toggle',function(e){group.addClass('hover');});});},initCookieHandling:function(){var self=this;$('.rl_sliders-body').on('show.bs.collapse',function(e){self.addCookie($(this).attr('id'));});$('.rl_sliders-body').on('hidden.bs.collapse',function(e){self.removeCookie($(this).attr('id'));});},addCookie:function(id){var set=this.getSetId(id);var cookies=this.getCookiesBySet(set);cookies['set-rl_sliders-'+set]=id;this.setCookiesBySet(set,cookies);},removeCookie:function(id){var set=this.getSetId(id);var cookies=this.getCookiesBySet(set);delete cookies['set-rl_sliders-'+set];this.setCookiesBySet(set,cookies);},getCookiesBySet:function(set){var obj={};var cookies=$.cookie(this.options.cookie_name);if(!cookies){return obj;}
cookies=cookies.split('___');for(var count=0;count<cookies.length;count++){var keyval=cookies[count].split('=');if(keyval.length<=1||keyval[0]==set){continue;}
var key=keyval.shift();if(key.substr(0,14)=='set-rl_sliders'){obj[key]=keyval.join('=');}}
return obj;},setCookiesBySet:function(set,cookies){var arr=[];for(var set in cookies){if(set&&cookies[set]){arr[arr.length]=set+'='+cookies[set];}}
$.cookie(this.options.cookie_name,arr.join('___'));},getSetId:function(id){var set=0;$('#'+id).closest('.rl_sliders').each(function($i,el){set=el.id;return;});return set;},initIframeReloading:function(){$('.rl_sliders-body.in iframe').each(function(){$(this).attr('reloaded',true);});$('.rl_sliders-body').on('show.bs.collapse',function(e){if(typeof initialize=='function'){initialize();}
var $el=$(this);$el.find('iframe').each(function(){if(this.src&&!$(this).attr('reloaded')){this.src+='';$(this).attr('reloaded',true);}});});$(window).resize(function(){if(typeof initialize=='function'){initialize();}
$('.rl_sliders-body iframe').each(function(){$(this).attr('reloaded',false);});$('.rl_sliders-body.in iframe').each(function(){if(this.src){this.src+='';$(this).attr('reloaded',true);}});});},getUrlVar:function(){var search='slider';var query=window.location.search.substring(1);if(query.indexOf(search+'=')<0){return'';}
var vars=query.split('&');for(var i=0;i<vars.length;i++){var keyval=vars[i].split('=');if(keyval[0]!=search){continue;}
return keyval[1];}
return'';},getOptions:function(){if(typeof rl_sliders_options!=='undefined'){return rl_sliders_options;}
if(typeof Joomla==='undefined'||typeof Joomla.getOptions==='undefined'){console.error('Joomla.getOptions not found!\nThe Joomla core.js file is not being loaded.');return false;}
return Joomla.getOptions('rl_sliders');}};$(document).ready(function(){var options=RegularLabsSliders.getOptions();if(!options){return;}
if(typeof options.init_timeout==='undefined'){return;}
setTimeout(function(){RegularLabsSliders.init(options);},options.init_timeout);});})(jQuery);function openSliders(id){var parent=findSliderSetBy(id);var elements=parent.find('.rl_sliders-body:not(.in)');if(!elements.length){return;}
elements.collapse('show');}
function openAllSliders(id){openSliders(id);}
function openSlider(id){openSliders(id);}
function closeSliders(id){var parent=findSliderSetBy(id);var elements=parent.find('.rl_sliders-body.in');if(!elements.length){return;}
elements.collapse('hide');}
function closeAllSliders(id){closeSliders(id);}
function closeSlider(id){closeSliders(id);}
function findSliderSetBy(id){var el=jQuery('#'+id+'.rl_sliders-body');if(el.length){return el.closest('.rl_sliders');}
el=jQuery('#'+id);if(el.length){return el;}
return jQuery('body');}