/*
 source : nehan.js
 version : 1.1.8
 site : http://tategakibunko.mydns.jp/
 blog : http://tategakibunko.blog83.fc2.com/

 Copyright (c) 2010, Watanabe Masaki <lambda.watanabe[at]gmail.com>
 licenced under MIT licence.

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
*/
var Nehan;Nehan||(Nehan={});if(!Nehan.Layout)Nehan.Layout={};if(!Nehan.TextStream)Nehan.TextStream={};if(!Nehan.StreamParser)Nehan.StreamParser={};if(!Nehan.LayoutMapper)Nehan.LayoutMapper={};if(!Nehan.Env)Nehan.Env={};if(!Nehan.ParserHook)Nehan.ParserHook={};
(function(){function m(a){y.read(this,{width:700,height:480,fontSize:16,lineHeightRate:1.8,letterSpacingRate:0.1,direction:"vertical",textLayerClassName:"text-layer",charImgRoot:"/img/char",charImgMap:[],charImgColor:"black",kinsokuCharCount:2,headNgChars:["\uff1f","\u3011","\uff0c",",","\u300b","\u3002","\u3001","\u30fb","\uff63","\u300d","\u300f","\uff09","\uff1e","\u3009","\u226b","]","\u3015","]","\uff3d","\uff01","!",") ","\u3005","\u309d","\u30fc","\uff0d"],tailNgChars:["\u3010","\u300a","\u300c",
"\u300e","\uff08","\uff3b","[","\u3014","\uff1c","\u226a","(","\u3008"],plusCss:{}},a);if(typeof a.fontFamily!="undefined")this.fontFamily=a.fontFamily;this.initialize()}function o(a,b,d){this.buffer=a;this.length=b;this.isEOF=d;this.seekPos=0}function q(a){this.yomi=this.kanji="";this.seekPos=0;this.rubyStartPos=a;this.ready=false}function e(a,b){this.layout=a;this.seekCharCount=0;this.seekTable=[{spos:0,cpos:0}];this.seekLineCharCount=this.seekHeight=this.seekWidth=0;this.lineSave=this.lineBuff=
"";this.resumePos=-1;this.blockBuff="";this.tagStack=[];this.rubyStack=[];this.pageCache=[];this.boutenStack=[];this.boutenCount=0;this.bouten=false;this.indentCount=0;this.rubyStream=null;this.packStr="";this.textStream=b;this.isResuming=false;this.cacheAble=true;this.lineScale=this.fontScale=1;this.fontStyle=this.bgColor="";this.isHankaku=this.isImgChar=false;this.imgBuff=[];this.blockIndentCount=this.imgIndentCount=this.curImgWidth=0;this.halfWordBreak=false;this.anchors={};this.anchorCount=0;
this.anchorName=""}function t(a,b,d){this.grids=b.sort(function(f,g){return f.order-g.order});this.head=this.grids[0];b=this.head.node.innerHTML;if(r.isIE||!d.noBR)b=b.replace(/<br \/>/gi,"\n").replace(/<br>/gi,"\n");this.head.node.innerHTML="";this.fontFamily=d.fontFamily;this.onSeek=d.onSeek;this.onComplete=d.onComplete;this.charImgRoot=d.charImgRoot;this.groupName=a;this.gridIndex=0;this.parser=new e(new m({direction:this.head.direction,width:this.head.width,height:this.head.height,fontSize:this.head.fontSize,
fontFamily:this.fontFamily,kinsokuCharCount:1,letterSpacingRate:0.1,charImgRoot:this.charImgRoot,charImgColor:this.head.charImgColor}),new o(b,b.length,true));if(this.head.isSinglePaging){var c=this;this.pager=document.createElement("div");a=document.createElement("a");d=document.createElement("a");this.pager.className="nehan-pager";a.href="/next";a.className="nehan-pager-link";d.innerHTML="PREV &gt;";d.href="/prev";d.className="nehan-pager-link";a.onclick=function(){if(c.parser.hasNextPage()){c.gridIndex++;
c.render(c.gridIndex)}return false};d.onclick=function(){if(c.gridIndex>0){c.gridIndex--;c.render(c.gridIndex)}return false};if(this.head.direction.match("vertical")){a.innerHTML="&lt; NEXT";d.innerHTML="PREV &gt;";this.pager.appendChild(a);this.pager.appendChild(d)}else{a.innerHTML="NEXT &gt;";d.innerHTML="&lt; PREV";this.pager.appendChild(d);this.pager.appendChild(a)}this.seekBar=document.createElement("div");this.seekBar.className="nehan-seek-bar-wrapper";a=this.seekBar.style;a.width=this.head.width+
"px";a.height="12px";a.lineHeight="12px";a=document.createElement("div");d=a.style;a.className="nehan-seek-bar";d.width="0%";d["float"]="right";d["text-align"]="right";d["font-size"]="10px";a.innerHTML="0%";this.seekBar.appendChild(a)}}var z={concat:function(a,b){a=a==""?"":a.slice(-1)=="/"?a:a+"/";b=b==""?"":b[0]=="/"?b.substring(1,b.length):b;return a+b}},y={read:function(a,b,d){for(prop in b)a[prop]=typeof d[prop]=="undefined"?b[prop]:d[prop]}},u={init:function(){this.browser=this.searchString(this.dataBrowser)||
"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;b<a.length;b++){var d=a[b].string,c=a[b].prop;this.versionSearchString=a[b].versionSearch||a[b].identity;if(d){if(d.indexOf(a[b].subString)!=-1)return a[b].identity}else if(c)return a[b].identity}},searchVersion:function(a){var b=a.indexOf(this.versionSearchString);if(b!=
-1)return parseFloat(a.substring(b+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,
subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},
{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};u.init();var r={init:function(){var a=u.browser.toLowerCase(),b=u.version,d=u.OS;this.isIE=a=="explorer";this.isWin=d=="Windows";this.isMac=d=="Mac";this.isVistaOrWin7=navigator.userAgent.toLowerCase().indexOf("windows nt 6")>=0;this.canTransform=a=="chrome"?true:a=="safari"?true:a=="firefox"&&b>=3.5?true:
this.isIE&&b>=6?true:false}};r.init();var w=function(a){var b="";for(prop in a)if(a[prop]!="")b+=prop+"='"+a[prop]+"' ";return b},n=function(a){var b="";for(prop in a)b+=prop+":"+a[prop]+";";return b},l=function(a,b,d){return"<"+a+" "+w(b)+(d?" />":" >")};m.prototype.initialize=function(){this.direction=this.direction.toLowerCase();this.directionH=this.direction=="horizontal"||this.direction=="vertical-lr"?"lr":"rl";this.isV=this.direction=="vertical"||this.direction=="vertical-lr"||this.direction==
"vertical-rl";this.baseLineHeight=Math.floor(this.lineHeightRate*this.fontSize);this.baseLetterSpacing=Math.floor(this.letterSpacingRate*this.fontSize);var a=this.fontSize+this.baseLetterSpacing;this.width=Math.max(this.baseLineHeight,this.width);this.height=Math.max(a,this.height);this.yohakuHeight=this.baseLineHeight-this.fontSize;this.letterHeight=this.isV?this.fontSize+this.baseLetterSpacing:1;this.wrapTag=this.isV?"table":"div";this.rubyFontSize=Math.floor(this.fontSize/2);this.lineCount=this.isV?
Math.floor(this.height/this.letterHeight)-this.kinsokuCharCount:Math.floor(this.width/this.fontSize)-this.kinsokuCharCount;this.wrapCss="";this.wrapCss+="text-align:left;";this.wrapCss+="padding:0;";this.wrapCss+="font-size:"+this.fontSize+"px;";this.wrapCss+="width:"+this.width+"px;";this.wrapCss+="height:"+this.height+"px;";this.wrapCss+="overflow:hidden;";this.wrapCss+="white-space:nowrap;";if(this.isV)this.wrapCss+="border-collapse:collapse;";else{this.wrapCss+="line-height:1.8em;";this.wrapCss+=
"letter-spacing:0;"}this.wrapCss+=typeof this.fontFamily=="undefined"?"font-family:monospace;":this.fontFamily==""?"font-family:monospace;":"font-family:"+this.fontFamily+", monospace;";this.wrapCss+=n(this.plusCss)};m.prototype.setHeight=function(a){this.height=a};m.prototype.setWidth=function(a){this.width=a};m.prototype.setCharImgRoot=function(a){this.charImgRoot=a};m.prototype.setCharImgColor=function(a){a=a.toLowerCase().replace(/#/g,"");this.charImgColor=a=="white"||a=="fff"||a=="ffffff"?"white":
"black"};m.prototype.setDirection=function(a){this.direction=a};m.prototype.getDirection=function(){return this.direction};m.prototype.setFontFamily=function(a){this.fontFamily=a};m.prototype.setFontSize=function(a){this.fontSize=a};m.prototype.setLineHeightRate=function(a){this.lineHeightRate=a};m.prototype.setLetterSpacingRate=function(a){this.letterSpacingRate=a};m.prototype.setKinsokuCharCount=function(a){this.kinsokuCharCount=a};o.prototype.getchar=function(){if(this.seekPos<this.buffer.length){var a=
this.buffer.substring(this.seekPos,this.seekPos+1);this.seekPos++;return a}else throw"BufferEnd";};o.prototype.lookNextChar=function(){if(this.seekPos<this.buffer.length)return this.buffer.substring(this.seekPos,this.seekPos+1);return""};o.prototype.stepSeekPos=function(){this.seekPos<this.buffer.length&&this.seekPos++};o.prototype.getTag=function(){for(var a="<";;){var b=this.getchar();a+=b;if(b==">")return a}};o.prototype.skipCRLF=function(){var a=this.seekPos,b=this.lookNextChar();if(b=="\n"){this.seekPos++;
return this.seekPos}else if(b=="\r"){this.seekPos++;if(this.lookNextChar()=="\n"){this.seekPos++;return this.seekPos}}return a};o.prototype.getBuffer=function(){return this.buffer};o.prototype.setBuffer=function(a,b){this.buffer=a;this.length=typeof b!="undefined"?b:a.length;this.isEOF=true};o.prototype.addBuffer=function(a){if(!this.isEOF){this.buffer+=a;if(this.buffer.length>=this.length)this.isEOF=true}};o.prototype.setEOF=function(a){this.isEOF=a};o.prototype.getEOF=function(){return this.isEOF};
q.prototype.addKanji=function(a){this.kanji+=a};q.prototype.addYomi=function(a){this.yomi+=a};q.prototype.setReady=function(){this.ready=true};q.prototype.isReady=function(){return this.ready};q.prototype.getchar=function(){if(this.seekPos<this.kanji.length){var a=this.kanji.substring(this.seekPos,this.seekPos+1);this.seekPos++;return a}else throw"RubyBufferEnd";};var x={tagHook:{},enableTagHook:function(a){return typeof this.tagHook[a]!="undefined"},addTagHook:function(a,b){this.tagHook[a]=b},getTagHook:function(a){return this.tagHook[a]}};
e.prototype.activateTag=function(a,b){for(var d=["ruby","rp","rb","rt","pack","script","object"],c=0;c<d.length;c++)if(a==d[c]){this[a]=b;break}};e.prototype.isActiveTag=function(a){if(typeof this[a]=="undefined")return false;return this[a]};e.prototype.getTextStream=function(){return this.textStream};e.prototype.charToImg=function(a){switch(a){case "\u300c":case "\uff62":a="kakko1.gif";break;case "\u300d":case "\uff63":a="kakko2.gif";break;case "\u300e":a="kakko3.gif";break;case "\u300f":a="kakko4.gif";
break;case "\uff08":case "(":case "{":a="kakko5.gif";break;case "\uff09":case "}":case ")":a="kakko6.gif";break;case "\uff1c":case "<":case "\u3008":a="kakko7.gif";break;case "\uff1e":case ">":case "\u3009":a="kakko8.gif";break;case "\u300a":case "\u226a":a="kakko9.gif";break;case "\u300b":case "\u226b":a="kakko10.gif";break;case "\uff3b":case "[":case "\u3014":a="kakko13.gif";break;case "\uff3d":case "]":case "\u3015":a="kakko14.gif";break;case "\u3010":a="kakko17.gif";break;case "\u3011":a="kakko18.gif";
break;case "\uff61":case "\u3002":a="kuten.gif";break;case "\uff0e":case ".":a="kuten2.gif";break;case "\uff64":case "\u3001":case ",":case "\uff0c":a="touten.gif";break;case "\uff5e":case "\u301c":a="kara.gif";break;case "\u2026":a="mmm.gif";break;case "\uff1a":case ":":a="tenten.gif";break;case "\u2025":a="mm.gif";break;case "\uff1d":case "=":a="equal.gif";break;case "\u2015":a="dash.gif";break;case "\u301d":a="dmn1.gif";break;case "\u301f":a="dmn2.gif";break;case "\u30fc":case "\uff0d":case "\u2501":a=
"\uff5c";break;case "\u2014":case "-":case "\u2010":case "\u2500":case "\u2212":case "_":case "\uff70":a="\uff5c";break;case "\u2192":case "\u21d2":a="\u2193";break;case "\u2190":a="\u2191";break;case "!":a="\uff01";break;case "?":a="\uff1f";break;case "\uff65":a="\u30fb";break;case "+":a="\uff0b";break;case "@":a="\uff20";break;case "#":a="\uff03";break;case "\\":a="\uffe5"}return a};e.prototype.makeCharInner=function(a){var b=this.charToImg(a);if(b.match(/\.gif/)){this.isImgChar=true;var d=this.layout.charImgColor==
"white"?"w@"+b:b;if(typeof this.layout.charImgMap[d]!="undefined")return this.makeCharImgTag(this.layout.charImgMap[d])}if(b==a||b.length==1){this.isImgChar=false;return b}this.isImgChar=true;if(this.layout.charImgColor=="white")b="w_"+b;return this.makeCharImgTag(z.concat(this.layout.charImgRoot,b))};e.prototype.makeCharImgTag=function(a){var b=Math.floor(this.layout.fontSize*this.fontScale);a={src:a,style:n({"vertical-align":"top",width:b+"px",height:b+"px","line-height":b+"px",margin:"0",padding:"0",
"border-width":"0"})};return l("img",a,true)};e.prototype.getBoutenStr=function(a){switch(a){case "bt-accent":return"\u30fd";case "bt-circle":return"\u3002"}return"\u30fb"};e.prototype.parseAttr=function(a){a=a.split(/[\s\t\u3000]+/);for(var b={},d=this,c=0;c<a.length;c++)(function(f){if(f.match(/([^=]+)=(.+)/)){f=RegExp.$1;var g=d.cutQuote(RegExp.$2);b[f]=g}})(a[c],c);return b};e.prototype.cutQuote=function(a){return a.replace(/\"/g,"").replace(/\'/g,"")};e.prototype.startBgColor=function(){if(this.layout.isV){var a=
{"text-align":"center",padding:Math.floor(Math.floor(this.layout.yohakuHeight*this.lineScale)/3)+"px 0",width:Math.floor(this.layout.baseLineHeight*this.lineScale)+"px","background-color":this.bgColor};return l("div",{style:n(a)},false)}else{a={"padding-top":"0.3em","padding-left":"0.3em","vertical-align":"middle","background-color":this.bgColor};return l("span",{style:n(a)},false)}};e.prototype.endBgColor=function(){if(this.layout.isV)return"</div>";return"</span>"};e.prototype.makeLineTd=function(){if(this.boutenCount>
0){this.boutenStack.push({startPos:this.boutenStartPos,count:this.boutenCount,str:this.boutenStr});this.boutenStartPos=this.boutenCount=0}var a={margin:"0",padding:"0","text-align":"left",width:Math.floor(this.layout.yohakuHeight*this.lineScale)+"px","vertical-align":"top"};return l("td",{style:n({"font-size":this.layout.fontSize+"px",margin:"0",padding:"0","text-align":this.lineScale>1?"center":"left","line-height":this.layout.letterHeight+"px","vertical-align":"top",width:Math.floor(this.layout.fontSize*
this.lineScale)+"px"})},false)+this.lineBuff+"</td>"+l("td",{style:n(a)},false)+this.makeRubyLine()+this.makeBoutenLine()+"</td>"};e.prototype.makeRubyLine=function(){for(var a="",b=Math.floor(this.layout.rubyFontSize*this.lineScale),d=n({position:"absolute","font-size":b+"px","line-height":"1.14em"}),c=this.indentCount*this.layout.letterHeight,f=[],g=this.layout.height-Math.floor(this.fontScale*this.layout.letterHeight*2),h=0;h<this.rubyStack.length;h++){var k=this.rubyStack[h],j=Math.floor(c+k.startPos),
p=j;a+=l("div",{style:d+"margin-top:"+j+"px;"},false);for(j=0;j<k.yomi.length;j++){var s=k.yomi.substring(j,j+1);a+=this.makeCharInner(s)+"<br />";p+=b;if(p>=g){f.push({yomi:k.yomi.slice(j+1),startPos:0});break}}a+="</div>"}this.rubyStack=f;return a};e.prototype.makeLineH=function(){var a="";if(this.rubyStack.length>0)a+=this.makeRubyLineH();a+="<div>";a+=this.lineBuff+"<br />";if(this.fontStyle!="")a+="</span>";if(this.bgColor!="")a+=this.endBgColor();a+="</div>";return a};e.prototype.makeRubyLineH=
function(){var a="",b=this.indentCount*this.layout.letterHeight,d=Math.floor(this.layout.rubyFontSize*this.lineScale);a+=l("div",{style:n({"font-size":d+"px",margin:"0",padding:"0","line-height":d+"px"})},false);for(d=0;d<this.rubyStack.length;d++)(function(c,f){a+=l("span",{style:"position:absolute; margin-top:-0.3em; margin-left:"+Math.floor(b+f.startPos)+"px;"},false);for(var g=0;g<f.yomi.length;g++)(function(h,k){a+=k})(g,f.yomi.substring(g,g+1));a+="</span>"})(d,this.rubyStack[d]);this.rubyStack=
[];a+="</div>";return a};e.prototype.makeBoutenLine=function(){for(var a="",b=this,d=n({position:"absolute","margin-left":"-0.35em"}),c=0;c<this.boutenStack.length;c++)(function(f){for(;f.count>0;){if(f.str=="\u30fb")var g=b.layout.fontSize;else if(f.str=="\u30fd")g=Math.floor(b.layout.fontSize*70/100);a+=l("div",{style:d+"; font-size:"+g+"px; margin-top:"+f.startPos+"px;"},false);a+=f.str;a+="</div>";f.startPos+=b.layout.letterHeight;f.count--}})(this.boutenStack[c]);this.boutenStack=[];return a};
e.prototype.normalIndent=function(a){this.isSmall=this.isHankaku=false;if(this.lineScale<=1)if(a.match(/[a-z0-9]+/i)){this.isHankaku=true;var b=a.length>1?"line-height:1em":"line-height:1em; margin-left:0.25em";return l("span",{style:b},false)+a+"</span><br />"}if(a.match(/[\u3041\u30a1\u3043\u30a3\u3045\u30a5\u3047\u30a7\u3049\u30a9\u30f5\u30f6\u3063\u30c3\u3083\u30e3\u3085\u30e5\u3087\u30e7\u308e\u30ee]/)){this.isSmall=true;b="overflow:visible;position:relative;top:-0.15em;right:-0.08em;line-height:1em;";
return l("span",{style:b},false)+a+"</span><br />"}return this.makeCharInner(a)+"<br />"};e.prototype.toBold=function(a){return"<b>"+a+"</b>"};e.prototype.toStyle=function(a){return function(b){return"<span style='"+a+"'>"+b+"</span>"}};e.prototype.toLink=function(a){return function(b){return"<a "+w(a)+">"+b+"</a>"}};e.prototype.isHeadNg=function(a){for(i=0;i<this.layout.headNgChars.length;i++)if(a==this.layout.headNgChars[i])return true;return false};e.prototype.isTailNg=function(a){for(i=0;i<this.layout.tailNgChars.length;i++)if(a==
this.layout.tailNgChars[i])return true;return false};e.prototype.applyTagStack=function(a,b){var d=b?this.normalIndent(a):a;for(i=this.tagStack.length-1;i>=0;i--)d=(0,this.tagStack[i])(d);return d};e.prototype.isValidPageRange=function(a){return 0<=a&&a<this.seekTable.length};e.prototype.setSeekPage=function(a){if(this.isValidPageRange(a)){this.textStream.seekPos=this.seekTable[a].spos;this.seekLineCharCount=this.seekHeight=this.seekWidth=0;if(a==0)this.tagStack=[]}};e.prototype.getPageSeekPos=function(a){if(this.isValidPageRange(a))return this.seekTable[a];
return 0};e.prototype.getSeekPercent=function(a){if(a<this.seekTable.length-1)return Math.floor(100*this.seekTable[a+1].spos/this.textStream.length);return 100};e.prototype.getPageSourceText=function(a){if(a<this.seekTable.length){var b=this.seekTable[a].spos;if(a+1<this.seekTable.length)return this.textStream.buffer.substring(b,this.seekTable[a+1].spos)}return""};e.prototype.getPageNoFromSeekPos=function(a){for(var b=0;b<this.seekTable.length-1;b++)if(this.seekTable[b].spos<=a&&a<this.seekTable[b+
1].spos)return b;if(this.seekTable[b].spos<=a&&a<=this.textStream.buffer.length)return b;return-1};e.prototype.makeRestSpaceTd=function(){var a=this.layout.width-this.seekWidth,b="";if(a>0)b="<td style='display:block; width:"+a+"px; height:"+this.layout.height+"'></td>\n";return b};e.prototype.getPageSeekPos=function(a){if(this.isValidPageRange(a))return this.seekTable[a];return{spos:0,cpos:0}};e.prototype.saveSeekState=function(a,b){if(this.isValidPageRange(a))this.seekTable[a]=b;else this.seekTable.push(b)};
e.prototype.fixH=function(a){if(a=="\u2015")return"<span style='margin-top:-0.2em; float:right'>"+a+"</span>";return a};e.prototype.fixW=function(a){if(a=="\u2015"||a=="\u2026")return"<span style='margin-left:-0.24em'>"+a+"</span>";return a};e.prototype.hasNextPage=function(){return this.textStream.seekPos<this.textStream.length};e.prototype.addCache=function(a,b){this.pageCache[a]=b};e.prototype.getCache=function(a){return this.pageCache[a]};e.prototype.clearCache=function(){this.pageCache=[];this.tagStack=
[]};e.prototype.reset=function(){this.clearCache();this.textStream.seekPos=0};e.prototype.getLetterCount=function(a){return escape(a).charAt(1)=="u"?1:this.layout.isV?a==" "?1:r.canTransform?0.5:1:0.5};e.prototype.addIndent=function(a){for(var b=this.layout.isV?"\u3000<br />":"\u3000",d=0;d<a;d++)this.lineBuff+=b};e.prototype.getLayout=function(){return this.layout};e.prototype.setLayout=function(a){this.layout=a;this.layout.initialize()};e.prototype.getAnchors=function(){return this.anchors};e.prototype.getAnchorCount=
function(){return this.anchorCount};e.prototype.getPageLayout=function(a,b){var d="<"+this.layout.wrapTag+" class='"+this.layout.textLayerClassName+"' style='"+this.layout.wrapCss+"'>",c="</"+this.layout.wrapTag+">";d=b!=""?d+b+c:"";this.addCache(a,d);return d};e.prototype.outputPage=function(a){if(this.isResuming){this.isResuming=false;return this.parsePage(a)}else if(typeof this.pageCache[a]!="undefined"){this.setSeekPage(a+1);return this.pageCache[a]}else{this.setSeekPage(a);return this.parsePage(a)}};
e.prototype.onOverFlowPage=function(a,b){if(b)if(this.layout.directionH=="rl")this.blockBuff=this.makeRestSpaceTd()+this.blockBuff;else this.blockBuff+=this.makeRestSpaceTd();var d=b?"<tr>"+this.blockBuff+"</tr>":this.blockBuff;this.saveSeekState(a+1,{spos:this.textStream.seekPos,cpos:this.seekCharCount});this.lineBuff=this.blockBuff="";if(this.bgColor!="")this.lineBuff+=this.startBgColor();this.lineScale=this.fontScale;if(b)this.seekWidth=0;else this.seekHeight=0;this.seekLineCharCount=0;return this.getPageLayout(a,
d)};e.prototype.onBufferEnd=function(a,b){if(this.textStream.isEOF){this.lineBuff!=""&&this.pushLine(a,b);return this.onOverFlowPage(a,b)}else{this.isResuming=true;if(this.resumePos>=0){this.textStream.seekPos=this.resumePos;this.lineBuff=this.lineSave}throw"BufferEnd";}};e.prototype.onRubyBufferEnd=function(){delete this.rubyStream;this.rubyStream=null};e.prototype.pushLineToBlockV=function(a){if(this.layout.directionH=="rl")this.blockBuff=a+this.blockBuff;else this.blockBuff+=a};e.prototype.pushLine=
function(a,b){if(this.blockBuff!=""||this.lineBuff!=""){if(b){if(this.halfBuff){this.lineBuff+=this.outputHalfWord();if(this.getLetterCount(this.textStream.lookNextChar())<1)this.halfWordBreak=true}this.pushLineToBlockV(this.makeLineTd())}else this.blockBuff+=this.makeLineH();this.lineBuff="";if(this.fontStyle!="")this.lineBuff+=fontStyle;if(this.bgColor!="")this.lineBuff=this.startBgColor();if(b){this.seekWidth+=Math.floor(this.layout.baseLineHeight*this.lineScale);this.seekHeight=0}else{this.seekHeight+=
Math.floor(this.layout.baseLineHeight*this.lineScale);this.seekWidth=0}this.seekLineCharCount=0;this.lineScale=this.fontScale}};e.prototype.checkOverflow=function(a){if(a)return this.seekWidth+Math.floor(this.layout.fontSize*this.lineScale)>this.layout.width;return this.seekHeight+Math.floor((this.layout.fontSize+this.layout.rubyFontSize)*this.lineScale)>this.layout.height};e.prototype.parseEndPage=function(a,b){this.lineBuff!=""&&this.pushLine(a,b);if(this.recursiveParser)this.textStream.seekPos=
this.resumePos;throw"OverflowPage";};e.prototype.adjustSize=function(a,b,d,c){var f=a,g=b;if(a>d){f=d;g-=Math.floor(b/a*(a-d))}if(b>c){g=c;f-=Math.floor(a/b*(b-c))}return{width:f,height:g}};e.prototype.parseObjectStart=function(a,b,d,c){a=parseInt(c.width);b=parseInt(c.height);this.objFigure={src:d,align:typeof c.align!="undefined"?c.align:"none",width:a,height:b,drawWidth:a,drawHeight:b}};e.prototype.parseObjectBody=function(a,b,d){if(this.objFigure)this.objFigure.src+=d};e.prototype.parseObjectEnd=
function(a,b,d){this.objFigure.src+=d;this.pushFigure(a,b,"object",this.objFigure)};e.prototype.parseImg=function(a,b,d,c){d=c.src;var f=typeof c.width!="undefined"?parseInt(c.width):200,g=typeof c.height!="undefined"?parseInt(c.height):300;c=typeof c.align!="undefined"?c.align:"none";var h=this.layout.width-this.seekWidth,k=this.layout.height-this.seekHeight,j=this.layout.letterHeight*2;if(b)k=Math.max(10,k-j);else h=Math.max(10,h-j);h=this.adjustSize(f,g,h,k);this.pushFigure(a,b,"img",{src:d,align:c,
width:f,height:g,drawWidth:h.width,drawHeight:h.height})};e.prototype.pushFigure=function(a,b,d,c){if(this.lineBuff!=""){this.pushLine(a,b);if(this.checkOverflow(b)){this.textStream.seekPos=this.resumePos;throw"OverflowPage";}}if(this.recursiveParser){this.lineBuff!=""&&this.pushLine(a,b);this.textStream.seekPos=this.resumePos;throw"OverflowPage";}if(!(b&&c.width>this.layout.width||!b&&c.height>this.layout.height)){if(b&&this.seekWidth+c.drawWidth+this.layout.yohakuHeight>this.layout.width||!b&&this.seekHeight+
c.drawHeight+this.layout.yohakuHeight>this.layout.height){this.textStream.seekPos=this.resumePos;throw"OverflowPage";}if((c.drawWidth!=c.width||c.drawHeight!=c.height)&&(c.drawWidth*2<c.width||c.drawHeight*2<c.height)){this.textStream.seekPos=this.resumePos;throw"OverflowPage";}a=b?this.layout.height-c.drawHeight-this.layout.fontSize:this.layout.width-c.drawWidth-this.layout.fontSize;var f="";if(b){if(!this.textStream.isEOF||c.align=="none"||a<=0||a*2<this.layout.height){b=d=="img"?l("img",{src:c.src,
width:c.drawWidth,height:c.drawHeight},true):c.src;b=this.applyTagStack(b,false)}else{if(c.align=="top"||c.align=="left")var g="padding:0; margin-bottom:"+this.layout.fontSize+"px;";else if(c.align=="bottom"||c.align=="right")g="padding:0; margin-top:0;";b=d=="img"?l("img",{src:c.src,width:c.drawWidth,height:c.drawHeight,style:g},true):l("div",{style:g},false)+c.src+"</div>";b=this.applyTagStack(b,false);d=new e(new m({width:c.drawWidth,height:a,fontSize:this.layout.fontSize,direction:this.layout.direction,
charImgRoot:this.layout.charImgRoot,charImgMap:this.layout.charImgMap,charImgColor:this.layout.charImgColor,kinsokuCharCount:this.layout.kinsokuCharCount}),this.textStream);d.recursiveParser=true;if(this.layout.fontFamily){d.layout.fontFamily=this.layout.fontFamily;d.layout.initialize()}f=d.parsePage(0);this.tagStack=d.tagStack;delete d}var h=c.align=="top"||c.align=="left"?b+f:f+b;this.blockBuff=l("td",{style:n({"vertical-align":"top","padding-right":this.layout.yohakuHeight+"px"})},false)+h+"</td>"+
this.blockBuff;this.seekWidth+=c.drawWidth+this.layout.yohakuHeight}else{if(!this.textStream.isEOF||c.align=="none"||a<=0||a*2<this.layout.width){b=d=="img"?l("img",{src:c.src,width:c.drawWidth,height:c.drawHeight},true):c.src;this.blockBuff+=b+"<br />"}else{b=d=="img"?l("img",{src:c.src,width:c.drawWidth,height:c.drawHeight},true):c.src;d=new e(new m({width:a,height:c.drawHeight,fontSize:this.layout.fontSize,direction:"horizontal",charImgRoot:this.layout.charImgRoot,charImgMap:this.layout.charImgMap,
charImgColor:this.layout.charImgColor,kinsokuCharCount:1}),this.textStream);d.recursiveParser=true;if(this.layout.fontFamily){d.layout.fontFamily=this.layout.fontFamily;d.layout.initialize()}f=d.parsePage(0);delete d;if(c.align=="top"||c.align=="left"){h="<div style='float:left; width:"+(c.drawWidth+this.layout.fontSize)+"px;'>"+b+"</div>";var k="<div style='float:left; width:"+a+"px;'>"+f+"</div>"}else if(c.align=="bottom"||c.align=="right"){h="<div style='float:left; width:"+a+"px;'>"+f+"</div>";
k="<div style='float:left; width:"+(c.drawWidth+this.layout.fontSize)+"px;'>"+b+"</div>"}this.blockBuff+="<div style='width:"+this.layout.width+"px;'>"+h+k+"<div style='clear:left;line-height:0px;font-size:0px;'></div></div>"}this.seekHeight+=c.drawHeight+this.layout.yohakuHeight}}};e.prototype.parseLinkStart=function(a,b,d,c,f){if(f=="a2")c.target="_blank";if(c.name){this.anchorName=c.name;this.anchors[this.anchorName]={title:"",pageNo:a};this.anchorCount++}else if(b)this.tagStack.push(this.toLink(c));
else this.lineBuff+="<a "+w(c)+">"};e.prototype.parseLinkEnd=function(a,b,d,c,f){if(this.anchorName!="")this.anchorName="";else if(b)this.tagStack.pop();else this.lineBuff+=f=="/a2"?"</a>":d};e.prototype.parseBoldStart=function(a,b,d){if(b)this.tagStack.push(this.toBold);else this.lineBuff+=d};e.prototype.parseBoldEnd=function(a,b,d){if(b)this.tagStack.pop();else this.lineBuff+=d};e.prototype.parseFontStart=function(a,b,d,c){a={};this.fontScale=typeof c.scale!="undefined"?parseFloat(c.scale):1;if(this.fontScale<
1||this.fontScale>1){a["font-size"]=this.fontScale+"em";if(b)a["line-height"]="1.1em"}if(this.fontScale>this.lineScale)this.lineScale=this.fontScale;if(typeof c.color!="undefined")a.color=c.color;if(typeof c.family!="undefined")a["font-family"]=c.family;if(typeof c.weight!="undefined")a["font-weight"]=c.weight;this.bgColor=typeof c.bgcolor!="undefined"?c.bgcolor:"";if(this.bgColor!="")this.lineBuff+=this.startBgColor();c=n(a);if(c!=""){c+="vertical-align:baseline;";if(b)this.tagStack.push(this.toStyle(c));
else{this.fontStyle=l("span",{style:c},false);this.lineBuff+=this.fontStyle}}};e.prototype.parseFontEnd=function(a,b){this.fontScale=1;if(this.seekLineCharCount==0)this.lineScale=1;if(b){if(this.bgColor!=""){this.lineBuff+=this.endBgColor();this.bgColor=""}this.tagStack.pop()}else{this.fontStyle="";this.lineBuff+="</span>";if(this.bgColor!=""){this.lineBuff+=this.endBgColor();this.bgColor=""}}};e.prototype.parseBoutenStart=function(a,b,d,c,f){this.bouten=true;this.boutenStartPos=this.seekHeight;if(r.isIE)this.boutenStartPos+=
Math.floor(this.layout.baseLetterSpacing*this.fontScale);this.boutenStr=this.getBoutenStr(f)};e.prototype.parseBoutenEnd=function(){this.bouten=false;this.boutenStack.push({startPos:this.boutenStartPos,count:this.boutenCount,str:this.boutenStr});this.boutenCount=0};e.prototype.parsePackStart=function(a,b){if(b)this.packStr=""};e.prototype.parseRubyStart=function(a,b){this.rubyStream=b?new q(this.seekHeight):new q(this.seekWidth)};e.prototype.parseRubyEnd=function(){this.rubyStack.push({yomi:this.rubyStream.yomi,
startPos:this.rubyStream.rubyStartPos});this.rubyStream.setReady()};e.prototype.parseBlockquoteStart=function(a,b,d,c){this.blockIndentCount=typeof c.indent!="undefined"?parseInt(c.indent):2;this.indentCount+=this.blockIndentCount;this.lineCount<=this.indentCount*2&&this.activateTag("blockquote",false);this.layout.lineCount-=this.blockIndentCount*2};e.prototype.parseBlockquoteEnd=function(){this.indentCount-=this.blockIndentCount;this.layout.lineCount+=this.blockIndentCount*2;this.blockIndentCount=
0};e.prototype.parseTagHook=function(a,b,d,c,f){x.enableTagHook(f)&&x.getTagHook(f).apply(this,[a,b,d,c,f])};e.prototype.parseTag=function(a,b){var d=this.textStream.getTag(),c=d.replace("<","").replace(">","").replace("/>",""),f=this.parseAttr(c);c=c.split(/[\s\t]+/)[0].toLowerCase();var g=c.substring(0,1)=="/";this.activateTag(c.replace("/",""),!g);switch(c){case "end-page":this.parseEndPage(a,b,d,f,c);break;case "img":this.parseImg(a,b,d,f,c);break;case "a":case "a2":this.parseLinkStart(a,b,d,
f,c);break;case "/a":case "/a2":this.parseLinkEnd(a,b,d,f,c);break;case "b":case "strong":this.parseBoldStart(a,b,d,f,c);break;case "/b":case "/strong":this.parseBoldEnd(a,b,d,f,c);break;case "font":this.parseFontStart(a,b,d,f,c);break;case "/font":this.parseFontEnd(a,b,d,f,c);break;case "bt-disc":case "bt-accent":case "bt-circle":case "bt-dot":this.parseBoutenStart(a,b,d,f,c);break;case "/bt-disc":case "/bt-accent":case "/bt-circle":case "/bt-dot":this.parseBoutenEnd(a,b,d,f,c);break;case "pack":this.parsePackStart(a,
b,d,f,c);break;case "ruby":this.parseRubyStart(a,b,d,f,c);break;case "/ruby":this.parseRubyEnd(a,b,d,f,c);break;case "blockquote":this.parseBlockquoteStart(a,b,d,f,c);break;case "/blockquote":this.parseBlockquoteEnd(a,b,d,f,c);break;case "object":this.parseObjectStart(a,b,d,f,c);break;case "/object":this.parseObjectEnd(a,b,d,f,c);break;case "embed":case "/embed":case "param":case "/param":this.parseObjectBody(a,b,d,f,c);break;default:this.parseTagHook(a,b,d,f,c)}};e.prototype.checkTailNg=function(a,
b){if(this.isTailNg(this.textStream.lookNextChar())){this.pushLine(a,b);this.textStream.skipCRLF()}};e.prototype.checkHeadNg=function(a,b){var d=this.textStream.lookNextChar();if(this.isHeadNg(d)){this.textStream.stepSeekPos();this.seekCharCount++;this.bouten&&this.boutenCount++;this.lineBuff+=b?this.applyTagStack(d,true):this.fixW(d);d=this.textStream.lookNextChar();if(this.isHeadNg(d)){this.textStream.stepSeekPos();this.seekCharCount++;this.bouten&&this.boutenCount++;this.lineBuff+=this.applyTagStack(d,
true)}}this.pushLine(a,b);this.textStream.skipCRLF()};e.prototype.outputHalfWord=function(){if(this.halfBuff.length==1)var a=this.applyTagStack(this.halfBuff,true);else if(this.halfBuff.length==2&&!this.halfWordBreak&&(this.halfBuff.match(/\d+/)||this.halfBuff.match(/[!\?]+/)))a=this.applyTagStack(this.halfBuff,true);else if(r.isIE){a=n({"writing-mode":"tb-rl",width:this.layout.fontSize+"px"});a="<div class='hw-tbrl' style='"+a+"'>"+this.applyTagStack(this.halfBuff,false)+"</div>"}else{a=n({"-webkit-transform":"rotate(90deg)",
"-webkit-transform-origin":"50% 50%","-moz-transform":"rotate(90deg)","-moz-transform-origin":"50% 50%","margin-bottom":Math.max(0,Math.floor((this.halfBuff.length-2)*(this.fontScale*this.layout.fontSize/2)))+"px",width:this.layout.fontSize+"px"});a="<div class='hw-trans' style='"+a+"'>"+this.applyTagStack(this.halfBuff,false)+"</div>"}delete this.halfBuff;this.halfBuff=null;this.halfWordBreak=false;return a};e.prototype.pushHalfChar=function(a){if(this.halfBuff)this.halfBuff+=a;else this.halfBuff=
a;a=this.textStream.lookNextChar();if(this.getLetterCount(a)>=1||a=="<"||a==" "||a=="\u3000"||a=="\t"||a=="\r"||a=="\n")this.lineBuff+=this.outputHalfWord()};e.prototype.pushChar=function(a,b,d){if(this.anchorName!="")this.anchors[this.anchorName].title+=d;var c=this.getLetterCount(d),f=c*this.fontScale;this.seekLineCharCount==0&&this.indentCount>0&&this.addIndent(this.indentCount);if(b){if(c<1&&r.canTransform)this.pushHalfChar(d);else this.lineBuff+=this.applyTagStack(d,true);this.seekHeight+=this.isImgChar?
Math.floor(f*this.layout.fontSize):this.isHankaku||this.isSmall?Math.floor(f*this.layout.fontSize):Math.floor(f*this.layout.letterHeight)}else{this.lineBuff+=this.fixW(d);this.seekWidth+=Math.floor(f*this.layout.fontSize)}this.seekLineCharCount+=f;this.seekCharCount++;this.bouten&&this.boutenCount++;d=this.layout.lineCount-this.seekLineCharCount;if(1<=d&&d<=1.5)this.checkTailNg(a,b);else d<1&&this.checkHeadNg(a,b)};e.prototype.parsePage=function(a){var b=this.layout.isV;for(this.lineSave="";;)try{this.resumePos=
-1;var d=this.textStream.seekPos;if(!this.pack&&this.packStr!=""){var c=this.packStr;this.packStr=""}else c=this.rubyStream&&this.rubyStream.isReady()?this.rubyStream.getchar():this.textStream.getchar();if(c!="\r")if(c=="\n")this.pushLine(a,b);else if(c=="<"){this.lineSave=this.lineBuff;this.resumePos=d;this.parseTag(a,b)}else if(this.isActiveTag("pack"))this.packStr+=c;else if(this.isActiveTag("ruby"))if(this.isActiveTag("rt"))this.rubyStream.addYomi(c);else this.isActiveTag("rb")&&this.rubyStream.addKanji(c);
else this.isActiveTag("script")||this.pushChar(a,b,c);if(this.checkOverflow(b))throw"OverflowPage";}catch(f){if(f=="RubyBufferEnd")this.onRubyBufferEnd(a,b);else if(f=="OverflowPage")return this.onOverFlowPage(a,b);else if(f=="BufferEnd")return this.onBufferEnd(a,b)}};var A={parse:function(a){a=a.split(/[\s\t]/);for(var b={direction:"vertical",fontSize:16,width:400,height:300,order:0,charImgColor:"black",kinsokuCharCount:1,isSinglePaging:false,isBreak:false},d=0;d<a.length;d++){var c=a[d];if(c=="lp-vertical"||
c=="lp-vertical-rl")b.direction="vertical";else if(c=="lp-vertical-lr")b.direction="vertical-lr";else if(c=="lp-horizontal")b.direction="horizontal";else if(c.match(/span-([0-9]+)/))b.width=parseInt(RegExp.$1)*40-10;else if(c.match(/lp-width-([0-9]+)/))b.width=parseInt(RegExp.$1);else if(c.match(/lp-height-([0-9]+)/))b.height=parseInt(RegExp.$1);else if(c.match(/lp-font-size-([0-9]+)/))b.fontSize=parseInt(RegExp.$1);else if(c.match(/lp-order-([0-9]+)/))b.order=parseInt(RegExp.$1);else if(c.match(/lp-char-img-white/))b.charImgColor=
"white";else if(c.match(/lp-single-paging/))b.isSinglePaging=true;else if(c.match(/lp-kinsoku-([0-9]+)/))b.kinsokuCharCount=parseInt(RegExp.$1);else if(c.match(/lp-break/))b.isBreak=true}return b}};t.prototype.setGridLayout=function(a){var b=this.parser.layout;b.setDirection(a.direction);b.setWidth(a.width);b.setHeight(a.height);b.setFontSize(a.fontSize);b.setCharImgColor(a.charImgColor);b.setKinsokuCharCount(a.kinsokuCharCount);b.setFontFamily(this.fontFamily);b.setCharImgRoot(this.charImgRoot);
b.initialize()};t.prototype.getGrid=function(a){return a<this.grids.length?this.grids[a]:this.grids[this.grids.length-1]};t.prototype.render=function(a){this.gridIndex=a;var b=this.head.isSinglePaging?this.head:this.getGrid(a);this.setGridLayout(b);var d=this.parser.outputPage(a),c=!this.parser.hasNextPage(),f=this.parser.getSeekPercent(a);this.onSeek(this.groupName,f);var g=function(j){var p=document.createElement("div");p.className=j;p.innerHTML=d;return p};if(d!=""){var h="text-layer-wrapper";
if(a==0)h+=" text-layer-header";if(c)h+=" text-layer-footer";if(this.head.isSinglePaging){if(typeof this.pagerInit=="undefined"){c=this.pagerInit=true;this.textLayer=g(h);this.textLayer.style.height=this.head.height+"px";b.node.appendChild(this.pager);b.node.appendChild(this.textLayer);b.node.appendChild(this.seekBar)}else this.textLayer.innerHTML=d;g=this.seekBar.firstChild;g.style.width=Math.max(20,Math.floor(f))+"%";g.innerHTML=f+"%"}else if(a<this.grids.length)b.node.innerHTML="<div class='"+
h+"'>"+d+"</div>";else b.node.appendChild(g(h))}if(c||b.isBreak){v.setFinish(this.groupName);this.onComplete(this.groupName,v.getSeekPercent());v.checkFinish()}else if(!this.head.isSinglePaging){var k=this;setTimeout(function(){k.render(a+1)},0)}};var v={setFinish:function(){this.gridMappedCount++},getSeekPercent:function(){return Math.floor(100*this.gridMappedCount/this.gridCount)},checkFinish:function(){this.gridMappedCount>=this.gridCount&&this.onCompleteAll()},start:function(a,b){var d={filter:"direction",
noBR:false,charImgRoot:"/img/char",fontFamily:"IPA\u660e\u671d, \uff2d\uff33 \u660e\u671d, Osaka-Mono, Hiragino Mincho Pro",onSeek:function(){},onComplete:function(){},onCompleteAll:function(){}};if(typeof b=="undefined")b={};for(var c in d)if(c=="onCompleteAll")this[c]=typeof b[c]!="undefined"?b[c]:d[c];else b[c]=typeof b[c]!="undefined"?b[c]:d[c];d=document.getElementsByTagName(a);c=function(p,s,B){s=A.parse(B);s.node=p;s.tagGroup=a;return s};var f={};for(var g=this.gridMappedCount=this.gridCount=
0;g<d.length;g++){var h=d[g],k=false;if(b.filter=="group"){if(h.className.match(/lp-group-([a-zA-Z0-9\-_]+)/)){var j=RegExp.$1;k=true}}else if(b.filter=="direction")if(h.className.match(/lp-vertical/)){j="group-v"+g;k=true}else if(h.className.match(/lp-horizontal/)){j="group-h"+g;k=true}if(k){this.gridCount++;h=c(h,j,h.className);if(typeof f[j]=="undefined")f[j]=[h];else f[j].push(h)}}for(j in f)(new t(j,f[j],b)).render(0)}};Nehan.Env=r;Nehan.Layout=m;Nehan.TextStream=o;Nehan.StreamParser=e;Nehan.LayoutMapper=
v;Nehan.ParserHook=x})();

