(function($){$.fn.orphans=function(){var txt=[];this.each(function(){$.each(this.childNodes,function(){if(this.nodeType==3&&$.trim(this.nodeValue))txt.push(this)})});return $(txt);};$.fn.accordion=function(options){var defaults={obj:'ul',objClass:'.accordion',objID:'',wrapper:'li',el:'li',head:'',next:'ul',initShow:'',showMethod:'slideDown',hideMethod:'slideUp',showSpeed:400,hideSpeed:800,activeLink:true,event:'click',collapsible:true,standardExpansible:false,shift:false,elToWrap:null};var o=$.extend({},defaults,options);return this.each(function(){var containerID='#'+this.id,Obj=containerID+' '+o.obj+o.objID+o.objClass,El=Obj+' '+o.el,loc=window.location.href;$(Obj).find(o.head).addClass('h');$(El).each(function(){var $node=$(this);if($node.find(o.next).length||$node.next(o.next).length){if($node.find('> a').length){$node.find('> a').addClass("trigger").css('display',"block").attr('title',"zwiń/rozwiń");}else{var anchor='' if(o.elToWrap){var $t=$node.orphans(),$s=$node.find(o.elToWrap);$t.add($s).wrapAll(anchor);}else{$node.orphans().wrap(anchor);}}}else{$node.addClass('last-child');}});$(El+'+ div:not(.outer)').wrap('
');$(Obj+' .h').each(function(){var $this=$(this);if(o.wrapper=='div'){$this.add($this.next('div.outer')).wrapAll('
');}});$(El+' a.trigger').closest(o.wrapper).find('> '+o.next).hide();if(o.activeLink){$(Obj+' a:not([href $= "#"])[href="'+loc+'"]').addClass('active').closest(o.next).addClass('current');} $(Obj).find(o.initShow).show().addClass('shown').parents(o.next).show().addClass('shown').end().parents(o.wrapper).find('> a.trigger, > '+o.el+' a.trigger').addClass('open');if(o.event=='click'){var ev='click';}else{var ev=[o.event]+' focus';} $(El).find('a.trigger').bind(ev,function(){var $thislink=$(this),$thisWrapper=$thislink.closest(o.wrapper),$nextEl=$thisWrapper.find('> '+o.next),$siblings=$thisWrapper.siblings(o.wrapper);if(($nextEl).length&&($nextEl.is(':visible'))&&(o.collapsible)){$(this).removeClass('open');$nextEl.filter(':visible')[o.hideMethod](o.hideSpeed);} if(($nextEl).length&&($nextEl.is(':hidden'))){if(!o.standardExpansible){$siblings.find('> a.open, >'+o.el+' a.open').removeClass('open').end().find('> '+o.next+':visible')[o.hideMethod](o.hideSpeed);} if(o.shift&&$thisWrapper.prev(o.wrapper).length){var $thisStack=$thisWrapper.nextAll().andSelf(),$first=$siblings.filter(":first");if(o.shift=='clicked'||(o.shift=='all'&&$siblings.length)){$thisWrapper.insertBefore($first);} if(o.shift=='all'&&$siblings.length>1){$thisStack.insertBefore($first);}} $(this).addClass('open');$nextEl[o.showMethod](o.showSpeed);} if(o.event!='click'){$thislink.click(function(){$thislink.blur();if($thislink.attr('href')=='#'){$thislink.blur();return false;}});} if(o.event=='click')return false;});});};})(jQuery);