(function(){var special={a:/[àáâãäåăą]/g,A:/[ÀÁÂÃÄÅĂĄ]/g,c:/[ćčç]/g,C:/[ĆČÇ]/g,d:/[ďđ]/g,D:/[ĎÐ]/g,e:/[èéêëěę]/g,E:/[ÈÉÊËĚĘ]/g,g:/[ğ]/g,G:/[Ğ]/g,i:/[ìíîï]/g,I:/[ÌÍÎÏ]/g,l:/[ĺľł]/g,L:/[ĹĽŁ]/g,n:/[ñňń]/g,N:/[ÑŇŃ]/g,o:/[òóôõöøő]/g,O:/[ÒÓÔÕÖØ]/g,r:/[řŕ]/g,R:/[ŘŔ]/g,s:/[ššş]/g,S:/[ŠŞŚ]/g,t:/[ťţ]/g,T:/[ŤŢ]/g,ue:/[ü]/g,UE:/[Ü]/g,u:/[ùúûůµ]/g,U:/[ÙÚÛŮ]/g,y:/[ÿý]/g,Y:/[ŸÝ]/g,z:/[žźż]/g,Z:/[ŽŹŻ]/g,th:/[þ]/g,TH:/[Þ]/g,dh:/[ð]/g,DH:/[Ð]/g,ss:/[ß]/g,oe:/[œ]/g,OE:/[Œ]/g,ae:/[æ]/g,AE:/[Æ]/g},tidy={" ":/[\xa0\u2002\u2003\u2009]/g,"*":/[\xb7]/g,"'":/[\u2018\u2019]/g,'"':/[\u201c\u201d]/g,"...":/[\u2026]/g,"-":/[\u2013]/g,"&raquo;":/[\uFFFD]/g};var walk=function(string,replacements){var result=string,key;for(key in replacements){result=result.replace(replacements[key],key)}return result};var getRegexForTag=function(tag,contents){tag=tag||"";var regstr=contents?"<"+tag+"(?!\\w)[^>]*>([\\s\\S]*?)</"+tag+"(?!\\w)>":"</?"+tag+"([^>]+)?>",reg=new RegExp(regstr,"gi");return reg};String.implement({standardize:function(){return walk(this,special)},repeat:function(times){return new Array(times+1).join(this)},pad:function(length,str,direction){if(this.length>=length){return this}var pad=(str==null?" ":""+str).repeat(length-this.length).substr(0,length-this.length);if(!direction||direction=="right"){return this+pad}if(direction=="left"){return pad+this}return pad.substr(0,(pad.length/2).floor())+this+pad.substr(0,(pad.length/2).ceil())},getTags:function(tag,contents){return this.match(getRegexForTag(tag,contents))||[]},stripTags:function(tag,contents){return this.replace(getRegexForTag(tag,contents),"")},tidy:function(){return walk(this,tidy)},truncate:function(max,trail,atChar){var string=this;if(trail==null&&arguments.length==1){trail="…"}if(string.length>max){string=string.substring(0,max);if(atChar){var index=string.lastIndexOf(atChar);if(index!=-1){string=string.substr(0,index)}}if(trail){string+=trail}}return string}})})();