(function(e){"use strict";e.fn.accordionjs=function(t){if(this.length>1)return this.each(function(){e(this).accordionjs(t)}),this;var i,s=this,o={isInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},isArray:function(e){return Object.prototype.toString.call(e)==="[object Array]"},isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},sectionIsOpen:function(e){return e.hasClass("acc_active")},getHash:function(){return!!window.location.hash&&window.location.hash.substring(1)}},n=e.extend({closeAble:!1,closeOther:!0,slideSpeed:150,activeIndex:1,openSection:!1,beforeOpenSection:!1},t);return e.each(n,function(e){var o=e.replace(/([A-Z])/g,"-$1").toLowerCase().toString(),t=s.data(o);(t||!1===t)&&(n[e]=t)}),(n.activeIndex===!1||n.closeOther===!1)&&(n.closeAble=!0),i=function(){s.create(),s.openOnClick(),e(window).on("load",function(){s.openOnHash()}),e(window).on("hashchange",function(){s.openOnHash()})},this.openSection=function(t,s){e(document).trigger("accjs_before_open_section",[t]),typeof n.beforeOpenSection=="function"&&n.beforeOpenSection.call(this,t),s=s>=0?s:n.slideSpeed;var o=t.children().eq(1);o.slideDown(s,function(){e(document).trigger("accjs_open_section",[t]),typeof n.openSection=="function"&&n.openSection.call(this,t)}),t.addClass("acc_active"),t.children().eq(0).attr("aria-expanded",!0)},this.closeSection=function(t,s){e(document).trigger("accjs_before_close_section",[t]),typeof n.beforeCloseSection=="function"&&n.beforeCloseSection.call(this,t),s=s>=0?s:n.slideSpeed;var o=t.children().eq(1);o.slideUp(s,function(){e(document).trigger("accjs_close_section",[t]),typeof n.closeSection=="function"&&n.closeSection.call(this,t)}),t.removeClass("acc_active"),t.children().eq(0).attr("aria-expanded",!1)},this.closeOtherSections=function(t,n){var o=t.closest(".accordionjs").children();e(o).each(function(){s.closeSection(e(this).not(t),n)})},this.create=function(){s.addClass("accordionjs");var i,a,t=s.children();if(e.each(t,function(t,n){s.createSingleSection(e(n))}),o.isArray(n.activeIndex)){a=n.activeIndex;for(i=0;i1?s.openSection(t.eq(n.activeIndex-1),0):!1!==n.activeIndex&&s.openSection(t.eq(0),0)},this.createSingleSection=function(t){var n=t.children();t.addClass("acc_section"),e(n[0]).addClass("acc_head"),e(n[0]).attr("role","button"),e(n[1]).addClass("acc_content"),e(n[1]).attr("role","region"),t.hasClass("acc_active")||t.children(".acc_content").hide()},this.openOnClick=function(){s.on("click",".acc_head",function(t){t.stopImmediatePropagation();var i=e(this).closest(".acc_section");o.sectionIsOpen(i)?n.closeAble?s.closeSection(i):s.children().length===1&&s.closeSection(i):n.closeOther?(s.closeOtherSections(i),s.openSection(i)):s.openSection(i)})},this.openOnHash=function(){if(o.getHash()){var t=e("#"+o.getHash());t.hasClass("acc_section")&&(s.openSection(t),n.closeOther&&s.closeOtherSections(t),e("html, body").animate({scrollTop:parseInt(t.offset().top)-50},150))}},i(),this}})(jQuery)