(function(n){"use strict";function s(n,t,i){var r;return function(){var u=this,f=arguments,e=function(){r=null;i||n.apply(u,f)},o=i&&!r;clearTimeout(r);r=setTimeout(e,t);o&&n.apply(u,f)}}function h(n){var t=++o;return String(n==null?"rmjs-":n)+t}function e(n){var t=n.clone().css({height:"auto",width:n.width(),maxHeight:"none",overflow:"hidden"}).insertAfter(n),u=t.outerHeight(),i=parseInt(t.css({maxHeight:""}).css("max-height").replace(/[^-\d\.]/g,""),10),f=n.data("defaultHeight"),r;t.remove();r=i||n.data("collapsedHeight")||f;n.data({expandedHeight:u,maxHeight:i,collapsedHeight:r}).css({maxHeight:"none"})}function c(n){if(!f[n.selector]){var t=" ";n.embedCSS&&n.blockCSS!==""&&(t+=n.selector+" + [data-readmore-toggle], "+n.selector+"[data-readmore]{"+n.blockCSS+"}");t+=n.selector+"[data-readmore]{transition: height "+n.speed+"ms;overflow: hidden;}",function(n,t){var i=n.createElement("style");i.type="text/css";i.styleSheet?i.styleSheet.cssText=t:i.appendChild(n.createTextNode(t));n.getElementsByTagName("head")[0].appendChild(i)}(document,t);f[n.selector]=!0}}function r(r,f){var e=this;this.element=r;this.options=n.extend({},u,f);c(this.options);this._defaults=u;this._name=t;this.init();window.addEventListener?(window.addEventListener("load",i),window.addEventListener("resize",i)):(window.attachEvent("load",i),window.attachEvent("resize",i))}var t="readmore",u={speed:10,collapsedHeight:260,heightMargin:16,moreLink:'<a href="#" class="longer">Read More...<\/a>',lessLink:'<a href="#" class="longer">Read Less<\/a>',embedCSS:!0,blockCSS:"display: block; width: 100%;",startOpen:!1,beforeToggle:function(){},afterToggle:function(){}},f={},o=0,i=s(function(){n("[data-readmore]").each(function(){var t=n(this),i=t.attr("aria-expanded")==="true";e(t);t.css({height:t.data(i?"expandedHeight":"collapsedHeight")})})},100);r.prototype={init:function(){var i=this,t=n(this.element),r,f,u,o;if(t.data({defaultHeight:this.options.collapsedHeight,heightMargin:this.options.heightMargin}),e(t),r=t.data("collapsedHeight"),f=t.data("heightMargin"),t.outerHeight(!0)<=r+f)return!0;u=t.attr("id")||h();o=i.options.startOpen?i.options.lessLink:i.options.moreLink;t.attr({"data-readmore":"","aria-expanded":!1,id:u});t.after(n(o).on("click",function(n){i.toggle(this,t[0],n)}).attr({"data-readmore-toggle":"","aria-controls":u}));i.options.startOpen||t.css({height:r})},toggle:function(t,i,r){r&&r.preventDefault();t||(t=n('[aria-controls="'+this.element.id+'"]')[0]);i||(i=this.element);var f=this,u=n(i),o="",s="",e=!1,h=u.data("collapsedHeight");u.height()<=h?(o=u.data("expandedHeight")+"px",s="lessLink",e=!0):(o=h,s="moreLink");f.options.beforeToggle(t,i,!e);u.css({height:o});u.on("transitionend",function(){f.options.afterToggle(t,i,e);n(this).attr({"aria-expanded":e}).off("transitionend")});n(t).replaceWith(n(f.options[s]).on("click",function(n){f.toggle(this,i,n)}).attr({"data-readmore-toggle":"","aria-controls":u.attr("id")}))},destroy:function(){n(this.element).each(function(){var t=n(this);t.attr({"data-readmore":null,"aria-expanded":null}).css({maxHeight:"",height:""}).next("[data-readmore-toggle]").remove();t.removeData()})}};n.fn.readmore=function(i){var u=arguments,f=this.selector;return(i=i||{},typeof i=="object")?this.each(function(){if(n.data(this,"plugin_"+t)){var u=n.data(this,"plugin_"+t);u.destroy.apply(u)}i.selector=f;n.data(this,"plugin_"+t,new r(this,i))}):typeof i=="string"&&i[0]!=="_"&&i!=="init"?this.each(function(){var f=n.data(this,"plugin_"+t);f instanceof r&&typeof f[i]=="function"&&f[i].apply(f,Array.prototype.slice.call(u,1))}):void 0}})(jQuery)