function IsUTF16Browser(){if(navigator){if(navigator.userAgent){var B=(navigator.userAgent.indexOf("Safari")!=-1);var A=(navigator.userAgent.indexOf("Konqueror")!=-1);return(window.opera||B||A)}}return false}var Search=Class.create();Search.prototype={initialize:function(){this.resetSearchBoxHandler=this.resetSearchBox.bind(this);$("search-box").autocomplete="off";Event.observe($("search-box"),"keyup",this.entrySearch.bindAsEventListener(this),false);Event.observe($("search-box"),"input",this.entrySearch.bindAsEventListener(this),false);Event.observe($("search-box"),"paste",this.entrySearch.bindAsEventListener(this),false);Event.observe($("search-box"),"focus",this.resetSearchBoxHandler,false);this.counter=0;if(window.opera){return }this.checkURI()},resetSearchBox:function(){$("search-box").value="";$("search-box").style.color="black";$("search-box").style.fontSize="medium";Event.stopObserving($("search-box"),"focus",this.resetSearchBoxHandler,false)},checkURI:function(F){var E=this.parseURI(document.location.href);if(E.fragment){}else{$("search-box").value="Search...";$("search-box").style.color="gray";return }var B=E.fragment;var D=B.indexOf("query=");if(D<0){return }this.resetSearchBox();var C=D+6;var A=B.length;if(C<A){$("search-box").value=B.substring(C,A);this.update()}else{this.clear()}},entrySearch:function(A){setTimeout(this.update.bind(this),300);this.counter++},showProgress:function(){setTimeout(this.updateProgress.bind(this),200);this.progress=$("search-progress");this.progress.innerHTML="検索中.";Element.show(this.progress)},hideProgress:function(){Element.hide(this.progress);this.progress=null},updateProgress:function(){if(this.progress){var A=this.progress.innerHTML;if(A.length>=12){A="検索中."}else{A+="."}this.progress.innerHTML=A;setTimeout(this.updateProgress.bind(this),200)}},update:function(){this.counter--;if(this.counter>0){return }this.counter=0;if($F("search-box")===""){this.clear();return }this.showProgress();var A="query="+encodeURIComponent($F("search-box"));if(IsUTF16Browser()){A+=";utf16=1"}new Ajax.Request("search/search.rb",{method:"get",parameters:A,onComplete:this.response.bind(this),onFailure:this.failure.bind(this)});document.body.style.cursor="wait"},failure:function(A){document.body.style.cursor="auto";this.hideProgress()},response:function(req){var result=eval("("+req.responseText+")");this.result=result;this.makeList("date",-1);document.body.style.cursor="auto";this.hideProgress();this.rewriteURI()},makeFragment:function(A){return"#query="+encodeURIComponent(A)},rewriteURI:function(){var B=this.parseURI(document.location.href);var A=(B.query)?B.path+"?"+B.query:B.path;A+=this.makeFragment($F("search-box"));if(A!=document.location.href){document.location.href=A}},sortByScoreAscending:function(){this.makeList("score",1)},sortByScoreDescending:function(){this.makeList("score",-1)},sortByTitleAscending:function(){this.makeList("title",1)},sortByTitleDescending:function(){this.makeList("title",-1)},sortByDateAscending:function(){this.makeList("date",1)},sortByDateDescending:function(){this.makeList("date",-1)},sortByWordAscending:function(){this.makeList("word",1)},sortByWordDescending:function(){this.makeList("word",-1)},compare:function(A,B){var C=(B==1)?B:-1;return function(D,E){if(D[A]==E[A]){return 0}return(D[A]>E[A])?C:-C}},makeList:function(M,D){var P=this.result.results;M=M.toLowerCase();P.sort(this.compare(M,D));var B=$F("search-box");var G="<h4>"+B+" の検索結果 ("+this.result.time+" secs) （注：各推測ワードの上位のみを表示している可能性があります）</h4>";G+='<p class="sort-order">';G+='<button class="sort-order ascend"  id="sort-by-score-ascend">スコア ↓</button>';G+='<button class="sort-order descend" id="sort-by-score-descend">スコア ↑</button>';G+='<button class="sort-order ascend"  id="sort-by-title-ascend">タイトル ↓</button>';G+='<button class="sort-order descend" id="sort-by-title-descend">タイトル ↑</button>';G+='<button class="sort-order ascend"  id="sort-by-date-ascend">日付 ↓</button>';G+='<button class="sort-order descend" id="sort-by-date-descend">日付 ↑</button>';G+='<button class="sort-order ascend"  id="sort-by-word-ascend">単語 ↓</button>';G+='<button class="sort-order descend" id="sort-by-word-descend">単語 ↑</button>';G+='<button id="close-search-result">× 閉じる</button>';G+="</p>";G+="<dl>";for(var F=0;F<P.length;++F){var C=P[F];var J=C.date.substr(0,4);var H=C.date.substr(4,2);var K=C.date.substr(6,2);var I=((F%2)===0)?"even":"odd";var O;if(C.tags.length>0){O="[";for(var E=0;E<C.tags.length;++E){O+=C.tags[E]+", "}if(O.length>2){O=O.slice(0,-2)}O+="]"}else{O=""}var A=C.date+".html?em="+encodeURIComponent(C.word)+"#"+C.paragraph;var L=C.title+"</a> "+O+" ("+C.word+")";G+='<dt class="'+I+'"><a href="'+A+'">'+L+"</a></dt>";G+='<dd class="'+I+'">'+C.summary+"</dd>"}G+="</dl>";$("search-result").innerHTML=G;$("search-result").style.display="block";Event.observe($("sort-by-score-ascend"),"click",this.sortByScoreAscending.bind(this),false);Event.observe($("sort-by-score-descend"),"click",this.sortByScoreDescending.bind(this),false);Event.observe($("sort-by-title-ascend"),"click",this.sortByTitleAscending.bind(this),false);Event.observe($("sort-by-title-descend"),"click",this.sortByTitleDescending.bind(this),false);Event.observe($("sort-by-date-ascend"),"click",this.sortByDateAscending.bind(this),false);Event.observe($("sort-by-date-descend"),"click",this.sortByDateDescending.bind(this),false);Event.observe($("sort-by-word-ascend"),"click",this.sortByWordAscending.bind(this),false);Event.observe($("sort-by-word-descend"),"click",this.sortByWordDescending.bind(this),false);Event.observe($("close-search-result"),"click",this.clear.bind(this),false);var N="sort-by-"+M+"-"+((D==1?"ascend":"descend"));Element.addClassName($(N),"selected");$(N).style.enabled=false},parseURI:function(D){var F=D;var E,B;var A=F.indexOf("#");if(A>0){B=decodeURIComponent(F.substring(A+1,F.length));F=F.substring(0,A)}var C=F.indexOf("?");if(C>0){E=decodeURIComponent(F.substring(C+1,F.length));F=F.substring(0,C)}return{"path":decodeURIComponent(F),"query":E,"fragment":B}},clear:function(){if($("search-result")){$("search-result").style.display="none";$("search-box").value=""}this.rewriteURI()}};var search=new Search();new function(){$A(document.getElementsByClassName("speed_comment_body")).each(function(A){var B=document.createElement("textarea");B.id=A.id+"_textarea";B.rows="5";B.cols="60";Element.hide(B);B.name=A.name;A.name+="_dummy";A.parentNode.insertBefore(B,A.nextSibling);Event.observe(A,"focus",function(C){Element.show(B);Element.hide(A);B.focus()})})};function parseQueries(){var C=location.href;var I=C.indexOf("?");if(I>=0){var B=C.indexOf("#");var A=(B>=0)?B:C.length;var F=C.substring(I+1,A);var E=F.split(";");var G={};for(var D=0;D<E.length;D++){var H=E[D].split("=");G[decodeURIComponent(H[0])]=decodeURIComponent(H[1])}return G}return{}}function highlightNode(C,B,D){var A=document.createElement("em");A.className="highlight"+(D+1);A.innerHTML=B;C.parentNode.replaceChild(A,C)}function searchWords(I,H){var G=H.length;var B=I.childNodes;for(var D=0;D<B.length;D++){var C=B[D];searchWords(C,H);if(C.nodeType!=3){continue}var K=C.data;var F=K.toLowerCase();for(var J=0;J<G;J++){var A=H[J];if(F==A){highlightNode(C,K,J);break}var E=F.indexOf(A);if(E<0){continue}if(E!=0){C.splitText(E);C=C.nextSibling}C.splitText(A.length);highlightNode(C,C.data,J);C=C.nextSibling;if(!C){break}}}}var queries=parseQueries();if(queries["em"]){words=queries["em"].split(" ");for(var i=0;i<words.length;i++){words[i]=words[i].toLowerCase()}searchWords(document.body,words)}function addEvent(A,C,B){if(A.addEventListener){A.addEventListener(C,B,false)}else{if(A.attachEvent){A.attachEvent(["on",C].join(""),B)}else{A[["on",C].join("")]=B}}}function WindowSize(){this.w=0;this.h=0;return this.update()}WindowSize.prototype.update=function(){var A=document;this.w=(window.innerWidth)?window.innerWidth:(A.documentElement&&A.documentElement.clientWidth)?A.documentElement.clientWidth:A.body.clientWidth;this.h=(window.innerHeight)?window.innerHeight:(A.documentElement&&A.documentElement.clientHeight)?A.documentElement.clientHeight:A.body.clientHeight;return this};function PageSize(){this.win=new WindowSize();this.w=0;this.h=0;return this.update()}PageSize.prototype.update=function(){var A=document;this.w=(window.innerWidth&&window.scrollMaxX)?window.innerWidth+window.scrollMaxX:(A.body.scrollWidth>A.body.offsetWidth)?A.body.scrollWidth:A.body.offsetWidt;this.h=(window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:(A.body.scrollHeight>A.body.offsetHeight)?A.body.scrollHeight:A.body.offsetHeight;this.win.update();if(this.w<this.win.w){this.w=this.win.w}if(this.h<this.win.h){this.h=this.win.h}return this};function PagePos(){this.x=0;this.y=0;return this.update()}PagePos.prototype.update=function(){var A=document;this.x=(window.pageXOffset)?window.pageXOffset:(A.documentElement&&A.documentElement.scrollLeft)?A.documentElement.scrollLeft:(A.body)?A.body.scrollLeft:0;this.y=(window.pageYOffset)?window.pageYOffset:(A.documentElement&&A.documentElement.scrollTop)?A.documentElement.scrollTop:(A.body)?A.body.scrollTop:0;return this};function UserAgent(){var A=navigator.userAgent;this.isWinIE=this.isMacIE=false;this.isGecko=A.match(/Gecko\//);this.isSafari=A.match(/AppleWebKit/);this.isOpera=window.opera;if(document.all&&!this.isGecko&&!this.isSafari&&!this.isOpera){this.isWinIE=A.match(/Win/);this.isMacIE=A.match(/Mac/);this.isNewIE=(A.match(/MSIE 5\.5/)||A.match(/MSIE 6\.0/))}return this}function LightBox(B){var A=this;A._imgs=new Array();A._wrap=null;A._box=null;A._open=-1;A._page=new PageSize();A._pos=new PagePos();A._ua=new UserAgent();A._expandable=false;A._expanded=false;A._expand=B.expandimg;A._shrink=B.shrinkimg;return A._init(B)}LightBox.prototype={_init:function(G){var C=this;var H=document;if(!H.getElementsByTagName){return }var B=H.getElementsByTagName("a");for(var F=0;F<B.length;F++){var E=B[F];var D=C._imgs.length;if(!E.getAttribute("href")||E.getAttribute("rel")!="lightbox"){continue}C._imgs[D]={src:E.getAttribute("href"),w:-1,h:-1,title:""};if(E.getAttribute("title")){C._imgs[D].title=E.getAttribute("title")}else{if(E.firstChild&&E.firstChild.getAttribute&&E.firstChild.getAttribute("title")){C._imgs[D].title=E.firstChild.getAttribute("title")}}E.onclick=C._genOpener(D)}var A=H.getElementsByTagName("body")[0];C._wrap=C._createWrapOn(A,G.loadingimg);C._box=C._createBoxOn(A,G);return C},_genOpener:function(B){var A=this;return function(){A._show(B);return false}},_createWrapOn:function(obj,imagePath){var self=this;if(!obj){return null}var wrap=document.createElement("div");wrap.id="overlay";with(wrap.style){display="none";position="fixed";top="0px";left="0px";zIndex="50";width="100%";height="100%"}if(self._ua.isWinIE){wrap.style.position="absolute";wrap.style.backgroundColor="black";wrap.style.backgroundImage="url(blank.gif)";wrap.style.filter="Alpha(opacity=50)"}addEvent(wrap,"click",function(){self._close()});obj.appendChild(wrap);var imag=new Image;imag.onload=function(){var spin=document.createElement("img");spin.id="loadingImage";spin.src=imag.src;spin.style.position="relative";self._set_cursor(spin);addEvent(spin,"click",function(){self._close()});wrap.appendChild(spin);imag.onload=function(){}};if(imagePath!=""){imag.src=imagePath}return wrap},_createBoxOn:function(obj,option){var self=this;if(!obj){return null}var box=document.createElement("div");box.id="lightbox";with(box.style){display="none";position="absolute";zIndex="60"}obj.appendChild(box);var img=document.createElement("img");img.id="lightboxImage";self._set_cursor(img);addEvent(img,"click",function(){self._close()});addEvent(img,"mouseover",function(){self._show_action()});addEvent(img,"mouseout",function(){self._hide_action()});box.appendChild(img);var zoom=document.createElement("img");zoom.id="actionImage";with(zoom.style){display="none";position="absolute";top="15px";left="15px";zIndex="70"}self._set_cursor(zoom);zoom.src=self._expand;addEvent(zoom,"mouseover",function(){self._show_action()});addEvent(zoom,"click",function(){self._zoom()});box.appendChild(zoom);addEvent(window,"resize",function(){self._set_size(true)});if(option.closeimg){var btn=document.createElement("img");btn.id="closeButton";with(btn.style){display="inline";position="absolute";right="10px";top="10px";zIndex="80"}btn.src=option.closeimg;self._set_cursor(btn);addEvent(btn,"click",function(){self._close()});box.appendChild(btn)}var caption=document.createElement("span");caption.id="lightboxCaption";with(caption.style){display="none";position="absolute";zIndex="80"}box.appendChild(caption);return box},_set_photo_size:function(){var A=this;if(A._open==-1){return }var E=A._box.firstChild;var B={w:A._page.win.w-30,h:A._page.win.h-30};var D={w:A._imgs[A._open].w,h:A._imgs[A._open].h};var C=1;if((D.w>=B.w||D.h>=B.h)&&D.h&&D.w){C=((B.w/D.w)<(B.h/D.h))?B.w/D.w:B.h/D.h}E.width=Math.floor(D.w*C);E.height=Math.floor(D.h*C);A._expandable=(C<1)?true:false;if(A._ua.isWinIE){A._box.style.display="block"}A._box.style.top=[A._pos.y+(A._page.win.h-E.height-30)/2,"px"].join("");A._box.style.left=[((A._page.win.w-E.width-30)/2),"px"].join("");A._show_caption(true)},_set_size:function(B){var A=this;if(A._open==-1){return }A._page.update();A._pos.update();var D=A._wrap.firstChild;if(D){var C=(A._page.win.h-D.height)/2;if(A._wrap.style.position=="absolute"){C+=A._pos.y}D.style.top=[C,"px"].join("");D.style.left=[(A._page.win.w-D.width-30)/2,"px"].join("")}if(A._ua.isWinIE){A._wrap.style.width=[A._page.win.w,"px"].join("");A._wrap.style.height=[A._page.h,"px"].join("")}if(B){A._set_photo_size()}},_show_action:function(){var A=this;if(A._open==-1||!A._expandable){return }var B=document.getElementById("actionImage");if(!B){return }B.src=(A._expanded)?A._shrink:A._expand;B.style.display="inline"},_hide_action:function(){var A=this;var B=document.getElementById("actionImage");if(B){B.style.display="none"}},_zoom:function(){var A=this;if(A._expanded){A._set_photo_size();A._expanded=false}else{if(A._open>-1){var B=A._box.firstChild;A._box.style.top=[A._pos.y,"px"].join("");A._box.style.left="0px";B.width=A._imgs[A._open].w;B.height=A._imgs[A._open].h;A._show_caption(false);A._expanded=true}}A._show_action()},_show_caption:function(enable){var self=this;var caption=document.getElementById("lightboxCaption");if(!caption){return }if(caption.innerHTML.length==0||!enable){caption.style.display="none"}else{var imag=self._box.firstChild;with(caption.style){top=[imag.height+10,"px"].join("");left="0px";width=[imag.width+20,"px"].join("");height="1.2em";display="block"}}},_show:function(C){var B=this;var E=new Image;if(C<0||C>=B._imgs.length){return }var D=document.getElementById("loadingImage");var A=document.getElementById("lightboxCaption");B._open=C;B._set_size(false);B._wrap.style.display="block";if(D){D.style.display="inline"}E.onload=function(){if(B._imgs[B._open].w==-1){B._imgs[B._open].w=E.width;B._imgs[B._open].h=E.height}if(A){A.innerHTML=B._imgs[B._open].title}B._set_photo_size();B._hide_action();B._box.style.display="block";B._box.firstChild.src=E.src;B._box.firstChild.setAttribute("title",B._imgs[B._open].title);if(D){D.style.display="none"}};B._expandable=false;B._expanded=false;E.src=B._imgs[B._open].src},_set_cursor:function(B){var A=this;if(A._ua.isWinIE&&!A._ua.isNewIE){return }B.style.cursor="pointer"},_close:function(){var A=this;A._open=-1;A._hide_action();A._wrap.style.display="none";A._box.style.display="none"}};addEvent(window,"load",function(){var A=new LightBox({loadingimg:"loading.gif",expandimg:"expand.gif",shrinkimg:"shrink.gif",closeimg:"close.gif"})});var highlightElem=null;var saveClass=null;function highlightElement(B){if(highlightElem){highlightElem.className=saveClass;highlightElem=null}highlightElem=getHighlightElement(B);if(!highlightElem){return }saveClass=highlightElem.className;highlightElem.className="highlight";if(highlightElem.tagName=="H3"){var D="ema log (2008-02-03)";var C="".length;var A=highlightElem.innerHTML.replace(/<[^>]+?>/g,"").substr(C+1);document.title=(A+" - "+D).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")}}function getHighlightElement(B){for(var C=0;C<document.anchors.length;++C){var A=document.anchors[C];if(A.name==B){var D;if(A.parentElement){D=A.parentElement}else{if(A.parentNode){D=A.parentNode}}return D}}return null}if(document.location.hash){highlightElement(document.location.hash.substr(1))}hereURL=document.location.href.split(/#/)[0];for(var i=0;i<document.links.length;++i){if(hereURL==document.links[i].href.split(/#/)[0]){document.links[i].onclick=handleLinkClick}}function handleLinkClick(){highlightElement(this.hash.substr(1))}
