/**
 * @version $Id$
 * @package DJ-MegaMenu
 * @copyright Copyright (C) 2017 DJ-Extensions.com, All rights reserved.
 * @license DJ-Extensions.com Proprietary Use License
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 * @developer Szymon Woronowski - szymon.woronowski@design-joomla.eu
 */
(function($){var k=function(c,d){var f=new Element('select',{id:c.get('id')+'select','class':'inputbox dj-select',events:{change:function(){if(this.get('value'))window.location=this.get('value')}}});var g=c.getChildren('li.dj-up');l(g,f,0);f.inject(d);d.getElement('.dj-mobile-open-btn').addEvent('click',function(e){e.stopPropagation();e.preventDefault();var a=f[0];if(document.createEvent){var b=document.createEvent("MouseEvents");b.initMouseEvent("mousedown",true,true,window,0,0,0,0,0,false,false,false,false,0,null);a.dispatchEvent(b)}else if(a.fireEvent){a.fireEvent("onmousedown")}})};var l=function(f,g,h){var j='',active=false;for(var i=0;i<h;i++){j+='- '}f.each(function(a){var b=a.getElement('> a');var c=a.getChildren('> .dj-subwrap > .dj-subwrap-in > .dj-subcol > .dj-submenu > li, > .dj-subtree > li');if(b&&b.getParent()==a){var d='';if(img=b.getElement('img')){d=img.get('alt')}else{d=b.get('html').replace(/(<small[^<]+<\/small>)/ig,"");d=d.replace(/(<([^>]+)>)/ig,"")}var e=new Element('option',{value:b.get('href'),text:j+d}).inject(g);if(!b.get('href')){e.set('disabled',true)}if(a.hasClass('active')){g.set('value',e.get('value'));active=true}}if(c)l(c,g,h+1)});if(!h&&!active){new Element('option',{value:'',text:'- MENU -'}).inject(g,'top');g.set('value','')}};var m=function(d){d.getElements('ul.dj-mobile-nav > li, ul.dj-mobile-nav-child > li').each(function(a){var b=a.getElement('> a');if(b){if(a.hasClass('parent')){var c=new Element('span.toggler');c.inject(b);b.addEvent('click',function(e){if(!a.hasClass('active'))e.preventDefault();else if(e.target.hasClass('toggler')){e.preventDefault();e.stopPropagation();a.removeClass('active')}})}b.addEvent('focus',function(){setTimeout(function(){b.getParents('.dj-mobileitem').fireEvent('click')},50)})}a.addEvent('click',function(){a.getSiblings().removeClass('active');a.addClass('active')})})};var n=function(b){var c=$(document.body).getChildren();var d=new Element('div.dj-offcanvas-wrapper');var f=new Element('div.dj-offcanvas-pusher');var g=new Element('div.dj-offcanvas-pusher-in');var h=b.getElement('.dj-offcanvas');$(document.body).addClass('dj-offcanvas-effect-'+h.getProperty('data-effect'));var i=null;b.getElement('.dj-mobile-open-btn').addEvent('click',function(e){e.stopPropagation();e.preventDefault();clearTimeout(i);f.addClass('overlay');h.store('scroll',window.getScroll().y);$(document.body).addClass('dj-offcanvas-open');g.setStyle('margin-top',-h.retrieve('scroll'));h.getElement('.dj-offcanvas-close-btn').focus()});d.inject($(document.body),'top');h.inject(d);f.inject(d);g.inject(f);c.each(function(a){a.inject(g)});$$('.dj-offcanvas-pusher, .dj-offcanvas-close-btn').addEvent('click',function(){if($(document.body).hasClass('dj-offcanvas-open')){g.setStyle('margin-top',0);$(document.body).removeClass('dj-offcanvas-open');window.scrollTo(0,h.retrieve('scroll'));b.getElement('.dj-mobile-open-btn').focus();i=setTimeout(function(){f.removeClass('overlay')},1000)}});h.getElement('.dj-offcanvas-close-btn').addEvent('blur',function(){setTimeout(function(){if(!h.getElement(':focus')){h.getElement('.dj-offcanvas-close-btn').click()}},50)});h.getElement('.dj-offcanvas-end').addEvent('focus',function(){h.getElement('.dj-offcanvas-close-btn').click()});m(h)};var o=function(a){a.getElement('.dj-mobile-open-btn').addEvent('click',function(e){a.getElement('.dj-accordion-in').slide('toggle')});a.getElement('.dj-accordion-in').set('slide',{resetHeight:true,duration:'short'});a.getElement('.dj-accordion-in').slide('hide');a.getElement('.dj-accordion-in').setStyle('display','block');m(a)};window.addEvent('domready',function(){$$('.dj-megamenu').each(function(a){var b=$(a.get('id')+'mobile');var c=$(a.get('id')+'mobileWrap');if(c){b.inject(c)}if(b){b.getElements('.dj-hideitem').destroy();if(b.hasClass('dj-megamenu-offcanvas')){n(b)}else if(b.hasClass('dj-megamenu-accordion')){o(b)}}})});window.addEvent('load',function(){$$('.dj-megamenu').each(function(a){var b=$(a.get('id')+'mobile');if(b){if(b.hasClass('dj-megamenu-select')){k(a,b)}}})})})(document.id);