(function(a){a.fn.expander=function(d){var f=a.extend({},a.fn.expander.defaults,d);var c;return this.each(function(){var r=a(this);var k=a.meta?a.extend({},f,r.data()):f;var u,y,m;var q=r.html();var v=q.slice(0,k.slicePoint).replace(/\w+$/,"");y=v.match(/<\w[^>]*>/g);if(y){v=q.slice(0,k.slicePoint+y.join("").length).replace(/\w+$/,"")}if(v.lastIndexOf("<")>v.lastIndexOf(">")){v=v.slice(0,v.lastIndexOf("<"))}var l=q.slice(v.length);if(!a("span.details",this).length){if(l.replace(/\s+$/,"").split(" ").length<k.widow){return}if(l.indexOf("</")>-1){m=l.match(/<(\/)?[^>]*>/g);for(var p=0;p<m.length;p++){if(m[p].indexOf("</")>-1){var x,t=false;for(var n=0;n<p;n++){x=m[n].slice(0,m[n].indexOf(" ")).replace(/(\w)$/,"$1>");if(x==g(m[p])){t=true}}if(!t){v=v+m[p];var h=false;for(var A=y.length-1;A>=0;A--){if(y[A].slice(0,y[A].indexOf(" ")).replace(/(\w)$/,"$1>")==g(m[p])&&h==false){u=u?y[A]+u:y[A];h=true}}}}}l=u&&u+l||l}r.html([v,'<span class="read-more">',k.expandPrefix,'<a href="#">',k.expandText,"</a>","</span>",'<span class="details">',l,"</span>"].join(""))}var w=a("span.details",this),z=a("span.read-more",this);w.hide();z.find("a").click(function(){z.hide();if(k.expandEffect==="show"&&!k.expandSpeed){k.beforeExpand(r);w.show();k.afterExpand(r);e(k,w)}else{k.beforeExpand(r);w[k.expandEffect](k.expandSpeed,function(){w.css({zoom:""});k.afterExpand(r);e(k,w)})}return false});if(k.userCollapse){r.find("span.details").append('<span class="re-collapse">'+k.userCollapsePrefix+'<a href="#">'+k.userCollapseText+"</a></span>");r.find("span.re-collapse a").click(function(){clearTimeout(c);var i=a(this).parents("span.details");b(i);k.onCollapse(r,true);return false})}});function b(h){h.hide().prev("span.read-more").show()}function e(i,h){if(i.collapseTimer){c=setTimeout(function(){b(h);i.onCollapse(h.parent(),false)},i.collapseTimer)}}function g(h){return h.replace(/\//,"")}};a.fn.expander.defaults={slicePoint:100,widow:4,expandText:"read more",expandPrefix:"&hellip; ",collapseTimer:0,expandEffect:"fadeIn",expandSpeed:"",userCollapse:true,userCollapseText:"[collapse expanded text]",userCollapsePrefix:" ",beforeExpand:function(b){},afterExpand:function(b){},onCollapse:function(c,b){}}})(jQuery);
