(function(n){function t(t){function e(n){i=n||[],i.isLocal=i.url?i.url.search(/^\w+$/ig)>-1?!0:!1:!1,i.chapters&&(i.count=i.chapters.length||i.count||0),r=[];for(var t in i)r.push(t);u=$e.bookdir(i.id),f=$e.isdir(u)}function o(n){var t=i.chapters[n];return t&&t.file==null&&(t.file=s(n),t.exists=f?$e.isfile(t.file):!1,i.chapters[n]=t),t}function c(n){var t=o(n),r;return t?(r=$e.isfile(t.file),r!=t.exists&&(t.exists=r,i.chapters[n]=t),r):!1}function a(n,t){return parseInt(n,10)+1+"-"+external.relacefilenamechar(t)+".txt"}function s(n){var t=i.chapters[n];if(t)return u+a(n,t.title)}function v(n){var t=[],u,f;for(t=n=="*"?r:n.split(/,/g),u=t.length,f=[];u--;)f[t[u]]=i[t[u]];return t.length==1?f[t[0]]:f}function y(n,i){var u=t.chapters,r=i||0,f;for(l=u.length;r<l;r++)if(f=n(u[r]),f)break}function p(n,t){var r=[];r["bak_"+n]=t,$e.setBookInfo(i.id,r)}function w(n){var t=[];t["read_"+n]=$e.timestamp(),t.lastreadindex=n,$e.setBookInfo(i.id,t)}function h(){return $e.getBookInfo(i.id,"rankstar")}function b(n){var t=[],r;t.rankstar=n,r=parseInt($e.getBookInfo(i.id,"ranknum"),10),t.ranknum=isNaN(r)?0:r,t.ranknum++,$e.setBookInfo(i.id,t)}function k(){return $e.getBookInfo(i.id,"_wordnum")}function d(){for(var u=r.length,n="",o=parseInt(h(),10),f,t,e;u--;){f=r[u].toLowerCase(),t=i[r[u]];switch(f){case"id":break;case"chapters":n+="&chapternum="+t.length;break;case"desc":n+="&desc="+$e.urlencode(t.sub(150,"..."),!0);break;default:n+="&"+f+"="+$e.urlencode(t,!0)}}return mzVersion>5250&&!isNaN(o)&&(n+="&star="+o),mzVersion>5240&&(e=$e.timestamp(),n+="&sign="+$e.sign((i.url||"")+"|"+(i.chapters.length||0)+"|"+e)+"&t="+e),n.substr(1)}function g(n){if(n.indexOf("[img")>-1){var t="mz://book/"+i.id+"/";n=n.replace(/\</ig,"&lt;").replace(/\>/ig,"&gt;").replace(/\s/,"&nbsp;&nbsp;"),n=n.replace(/\[img(?:=([^\]]*))?\](.*?)\[\/img\]/ig,'<br><font><img _src="mz://system/image/grey.gif" _style="background:gray" _original src="'+t+'$2" onload="picLoad(this, 0)" onerror="picError(this)" _menu="_popmenu_content" data-url="$1" /><\/font><br>'),n=n.replace(/<img src="(\w+\.\w+)"/ig,"<img src='"+t+"$1'")}return n=n.replace(/[\r\n]/ig,"<\/p><p>").replace(/<([^>]*?)\&nbsp\;([^>]*?)>/ig,"<$1 $2>"),n=n.replace(/　+/g,"\t"),"<p>"+n+"<\/p>"}var i=[],r=[],f=!1,u="";return n._popmenu_content=function(){return!1},t&&e(t),this.setData=e,this.getChapter=o,this.getChapterFile=s,this.getData=v,this.getPostData=d,this.getChapters=y,this.formatContent=g,this.chapterFileExists=c,this.setReadIndex=w,this.setReadStar=b,this.saveChapter=p,this.getWordNum=k,this.getReadStar=h,this}n.bookModule=t})(window)