/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function($){var Plugin=function(){};Plugin.prototype=$.extend(Plugin.prototype,{name:"accordion",options:{index:0,duration:500,easing:"easeOutQuart",animated:"slide",event:"click",collapseall:true,matchheight:true,toggler:".toggler",content:".content"},initialize:function(element,options){var options=$.extend({},this.options,options),togglers=element.find(options.toggler),display=function(index){var show=togglers.eq(index).hasClass("active")?$([]):togglers.eq(index),hide=togglers.eq(index).hasClass("active")?togglers.eq(index):$([]);if(show.hasClass("active")){hide=show;show=$([])}if(options.collapseall){hide=togglers.filter(".active")}switch(options.animated){case"slide":show.next().stop().show().animate({height:show.next().data("height")},{easing:options.easing,duration:options.duration});hide.next().stop().animate({height:0},{easing:options.easing,duration:options.duration,complete:function(){hide.next().hide()}});break;default:show.next().show().css("height",show.next().data("height"));hide.next().hide().css("height",0)}show.addClass("active");hide.removeClass("active")},calcHeights=function(){var matchheight=0;if(options.matchheight){element.find(options.content).css("min-height","").css("height","").each(function(){matchheight=Math.max(matchheight,$(this).height())}).css("min-height",matchheight)}togglers.each(function(i){var toggler=$(this),content=toggler.next();content.data("height",content.css("height","").show().height());if(toggler.hasClass("active")){content.show()}else{content.hide().css("height",0)}})};togglers.each(function(i){var toggler=$(this).bind(options.event,function(){display(i)}),content=toggler.next().css("overflow","hidden").addClass("content-wrapper");if(i==options.index||options.index=="all"){toggler.addClass("active");content.show()}else{content.hide().css("height",0)}});calcHeights();$(window).bind("debouncedresize",function(){calcHeights()})}});$.fn[Plugin.prototype.name]=function(){var args=arguments;var method=args[0]?args[0]:null;return this.each(function(){var element=$(this);if(Plugin.prototype[method]&&element.data(Plugin.prototype.name)&&method!="initialize"){element.data(Plugin.prototype.name)[method].apply(element.data(Plugin.prototype.name),Array.prototype.slice.call(args,1))}else if(!method||$.isPlainObject(method)){var plugin=new Plugin;if(Plugin.prototype["initialize"]){plugin.initialize.apply(plugin,$.merge([element],args))}element.data(Plugin.prototype.name,plugin)}else{$.error("Method "+method+" does not exist on jQuery."+Plugin.name)}})};if(!window["$widgetkit"])return;$widgetkit.lazyloaders["accordion"]=function(element,options){$(element).accordion(options)}})(jQuery);