function GetHashObj(d){var c={},a=typeof d==T_STR?d.split("#"):window.location.href.split("#");a=a instanceof Array&&a.length==2?"#"+a[1]:"";if(!a.length)return null;a=a.replace(/^#/,"");d=a.split("/");for(var b=0;b<d.length;b++){var e=d[b].split(":");if(e&&e.length>=2)c[e.shift()]=e.join("")}if(typeof c.p==T_STR){c.raw="#"+a;return c}return null}
function SetHashObj(d){var c=GetHashObj(),a="";for(var b in d)if(b!="raw"&&b!="p"&&b!="n")a+="/"+b+":"+d[b];if(d.n)a+="/n:"+encodeURIComponent(dfString.CharEntityRefDecode(decodeURIComponent(d.n)));if(a.length)window.location="#p:"+c.p+a}
function Initialize(){var d=decodeURIComponent(window.location.href),c="$protocol//$host$pathname$hash";for(var a in window.location)if(typeof window.location[a]==T_STR)c=c.replace("$"+a,window.location[a]);c=decodeURIComponent(c);if(d!=c)window.location=c;else{dfObject.AddCSS("MSIE","/css/msie.css");Element.Body().style.overflow="hidden";$("Header").style.display="none";new Application}}
function Application(){var d=this;this.state={usrdir:"",processing:false,col:"",conf:{}};this.context=new Context(["Blog"],this);this.progress=new Progress;this.progress.Modal(true);this.progress.Visible(true);this.progress.Message("\u3057\u3070\u3089\u304f\u304a\u5f85\u3061\u304f\u3060\u3055\u3044\u3002<br />please wait while initializing...<br />");this.progress.Percentages(100);this.window=new Window(this);this.conn=new Connection(this);this.tooltip=new Tooltip;this.sprite=new Sprite({path:"/KIF/js/ApplicationKit/Sprite",
delegate:this});this.lightroom=new LightRoom("/KIF/js/ApplicationKit/LightRoom",{acceptKeyEvent:true,onDblClick:true,fixedScroll:true,delegate:this});this.isHitoryBack=false;NotificationCenter.AddObserver(this,"rcvWindowMouseUp","WindowMouseUp");NotificationCenter.AddObserver(this,"rcvWindowDidLoad","WindowDidLoad");NotificationCenter.AddObserver(this,"rcvWindowDidSwitch","WindowDidSwitch");NotificationCenter.AddObserver(this,"rcvContextDidChange","ContextDidChange");EventCenter.AddEvent(window,"hashchange",
null,function(){d.ReloadUtils();d.window.Switch()});this.window.Refresh();this.window.Load()}Application.prototype.ConnectionWillStart=function(d){this.progress.Visible(true);this.progress.Message(d.msg);this.progress.Percentages(typeof d.percent==T_NUM?d.percent:100);return true};Application.prototype.ReloadUtils=function(){dfObject.IEPNG("/KIF/imgs/trans.gif");this.tooltip.Load();this.lightroom.Init();this.sprite.Load(["a"])};
Application.prototype.Startup=function(){var d=this,c=$("Header"),a=function(b,e){c.style.top=b+"px";if(e){c.style.top="";d.ReloadUtils();d.window.Switch()}};this.progress.Message("\u521d\u671f\u5316\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002<br />***** THANK YOU FOR WAITING *****");Element.SetOpacity(c,0);c.style.display="block";this.window.Refresh();setTimeout(function(){var b=c.offsetTop,e=c.offsetTop+c.clientHeight;c.style.top=e+"px";Element.SetOpacity(c,100);d.progress.Refuge();dfObject.TrackValue(e,
b,20,5,a,c)},10)};
Application.prototype.LoadIndex=function(){var d=this;this.conn.Open({method:M_GET,url:"/static/blog/archives/json/idx.json",query:null,msg:"\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u5f97\u4e2d",paththrow:true,callback:function(c){c=d.conn.ConvertJson(c.responseText);var a=[];d.progress.Message("\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u53d6\u5f97\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f");for(var b in c.entries){c.entries[b].id=b;c.entries[b].date=new Date;c.entries[b].date.setTime(b+"000");
a[a.length]=b;d.context.Add("Blog",c.entries[b])}d.Startup()}})};
Application.prototype.LoadPage=function(d,c){if(d){var a=this,b="\u30da\u30fc\u30b8\u300c/"+c+"\u300d";this.conn.Open({method:M_GET,url:"/static/"+c,query:null,msg:b+"\u3092\u53d6\u5f97\u4e2d",paththrow:true,callback:function(e){a.progress.Message(b+"\u306e\u53d6\u5f97\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f");d.innerHTML="";setTimeout(function(){d.innerHTML=e.responseText;a.progress.Visible(false,0);a.progress.Refuge();a.window.Refresh(true);a.ReloadUtils()},1E3)}})}};
Application.prototype.IxSwitchPage=function(d){var c="#";for(var a in d)c+=a+":"+d[a]+"/";c=c.replace(/\/$/,"");window.location=c};Application.prototype.IxSwitchHome=function(){this.IxSwitchPage({p:"Home",n:"\u30db\u30fc\u30e0"})};Application.prototype.IxSwitchAbout=function(){this.IxSwitchPage({p:"About",n:"enc.\u306b\u3064\u3044\u3066"})};Application.prototype.IxSwitchBlog=function(){this.IxSwitchPage({p:"Blog",b:"recent",n:"\u6700\u8fd1\u306e\u8a18\u4e8b"})};
Application.prototype.IxContextRecent=function(){this.IxSwitchBlog()};Application.prototype.IxContextIndex=function(){this.IxSwitchPage({p:"Blog",b:"index",n:"\u8a18\u4e8b\u4e00\u89a7"})};Application.prototype.rcvContextDidChange=function(d,c,a){this.window.Refresh(a);this.ReloadUtils()};
Application.prototype.ContextLoadEntry=function(d,c){var a=this;this.conn.Open({method:M_GET,url:"/static/blog/archives/json/"+c.id+".json",query:null,msg:"\u8a18\u4e8b\u300c"+c.title+"\u300d\u3092\u53d6\u5f97\u4e2d",callback:function(b,e){if(e==null){var f=b.attr.modify;a.progress.Message("\u8a18\u4e8b\u300c"+c.title+"\u300d\u306e\u53d6\u5f97\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f");b.attr.created=new Date;b.attr.created.setTime(c.id+"000");b.attr.modify=new Date;b.attr.modify.setTime(f+"000");
setTimeout(function(){d.AddEntry(c.id,b);a.progress.Visible(false,0)},500)}}})};Application.prototype.rcvWindowDidLoad=function(){this.LoadIndex()};Application.prototype.rcvWindowDidSwitch=function(d,c,a){if(a.n)a.n=decodeURIComponent(a.n);if(a.p=="Blog")this.context.Open($("Blog"));else if(a.p!="Home"&&a.p!="About"){d=["p","b","id"];c="";for(var b=0;b<d.length;b++)if(a[d[b]])c+=a[d[b]]+"/";c+="index.txt";this.LoadPage(this.window.GetElementAtCurrentView("div","Contents"),c.toLowerCase())}this.ReloadUtils()};
window.onload=Initialize;function Connection(d){var c={ConnectionWillStart:""};this.delegate=d;this.setup=this.ack=false;if(typeof this.delegate!=T_OBJ)alert("Connection.js[new]: aDelegate is not object");else{for(var a in c)if(typeof this.delegate[a]!=T_FUNC){alert("Connection.js[new]: aDelegate has not implemented require method: "+a);return}this.setup=true}}
Connection.prototype.Open=function(d){var c=this;if(this.ack)return false;if(this.ack=this.delegate.ConnectionWillStart(d)){XMLRequestCenter.Request("Connection",d.method,d.url,d.query,function(a){if(d.paththrow&&d.paththrow==true){c.ack=false;d.callback(a)}else{var b="",e=c.ConvertJson(a.responseText,function(f,h){b=h});if(b)ThrowError(b+"<br /><br />"+decodeURIComponent(a.responseText));else{d.callback(e);c.ack=false}}},null);return true}return false};
Connection.prototype.ConvertJson=function(d,c){var a=null,b;try{var e=function(h){for(b in h)if(typeof h[b]==T_OBJ&&h[b]instanceof Object)e(h[b]);else if(typeof h[b]==T_STR)h[b]=decodeURIComponent(h[b].replace(/\+/g," "));return h};a=eval("("+d+")");a=e(a)}catch(f){if(typeof c==T_FUNC)c(d,f);else throw f;}return a};function Context(d,c){var a=this,b=d&&d instanceof Array?d:[],e="",f=null,h=null,s=null,q=null,k=null,r=null,B={},C=0,u={},F=function(g){if(u[e][g]){k&&Element.Remove(k);r=g;q=u[e].container;k=u[e][r];k.innerHTML="<h5>\u69cb\u7bc9\u4e2d...</h5>";h[e].sort(dfObject.SortDesc);q.appendChild(k);NotificationCenter.PostNotification(this,"ContextDidChange",r=="recent");B[e+r]||typeof D[r]==T_FUNC&&setTimeout(function(){if(!D[r]())window.location="#p:Blog/b:recent"},500);return true}return false},D={entry:function(){var g=
GetHashObj().id;B[e+r]=false;if(f[e][g]){if(f[e][g].entry&&f[e][g].entry instanceof Object)E(g);else{k.innerHTML="<h3>\u201c<b>"+f[e][g].title+"</b>\u201d \u3092\u8aad\u307f\u8fbc\u307f\u4e2d...</h3>";c.ContextLoadEntry(a,{fileset:e,id:g,title:f[e][g].title});NotificationCenter.PostNotification(this,"ContextDidChange",true)}return true}return false},recent:function(){var g=GetHashObj(),j=document.createElement("h3"),m=document.createElement("dl"),i,n,p=0,l="";k.innerHTML="";j.innerHTML="\u6700\u8fd1\u306e\u8a18\u4e8b";
k.appendChild(j);k.appendChild(m);i=setInterval(function(){if(p>6)clearInterval(i);else{var t=h[e][p],v=f[e][t].date,x=document.createElement("li"),w=document.createElement("a"),o=v.getFullYear()+"/"+(v.getMonth()+1);if(l!=o){var y=document.createElement("dt"),z=document.createElement("dd"),A=v.getMonth()+1;l=o;if(String(A).length==1){o=o.split("/");o[1]="0"+A;o=o.join("/")}n=document.createElement("ul");y.innerHTML=o;z.appendChild(n);m.appendChild(y);m.appendChild(z)}w.title=f[e][t].title;w.innerHTML=
f[e][t].title+"<br /><span>"+v.toString()+"</span>";w.href="#p:"+g.p+"/b:entry/id:"+t+"/n:"+encodeURIComponent(f[e][t].title);x.appendChild(w);n.appendChild(x);NotificationCenter.PostNotification(a,"ContextDidChange",false)}p++},10);return true},index:function(){var g=GetHashObj(),j=document.createElement("h3"),m=document.createElement("dl"),i,n,p=0,l="";k.innerHTML="";j.innerHTML="\u8a18\u4e8b\u4e00\u89a7";k.appendChild(j);k.appendChild(m);i=setInterval(function(){if(p>=h[e].length)clearInterval(i);
else{var t=h[e][p],v=f[e][t].date,x=document.createElement("li"),w=document.createElement("a"),o=v.getFullYear()+"/"+(v.getMonth()+1);if(l!=o){var y=document.createElement("dt"),z=document.createElement("dd"),A=v.getMonth()+1;l=o;if(String(A).length==1){o=o.split("/");o[1]="0"+A;o=o.join("/")}n=document.createElement("ul");y.innerHTML=o;z.appendChild(n);m.appendChild(y);m.appendChild(z)}w.title=f[e][t].title;w.innerHTML=f[e][t].title+"<br /><span>"+v.toString()+"</span>";w.href="#p:"+g.p+"/b:entry/id:"+
t+"/n:"+encodeURIComponent(f[e][t].title);x.appendChild(w);n.appendChild(x);NotificationCenter.PostNotification(a,"ContextDidChange",false)}p++},10);return true}},E=function(g){var j=f[e][g]?f[e][g].entry:null;if(j){var m=GetHashObj(),i={bin:"div",title:"h3",status:"p",body:"div"},n={modify:"<b>Modifid:</b> ",created:"<b>Created:</b> ",tags:"<b>Tags:</b> "};C=g;k.innerHTML="";for(var p in i)i[p]=document.createElement(i[p]);i.bin.className="Entries";i.title.innerHTML=j.attr.title;for(var l in n)i.status.innerHTML+=
n[l]+j.attr[l]+"<br />";for(n=0;n<h[e].length;n++)if(h[e][n]==g){if(g=h[e][n-1]){p=document.createElement("b");l=document.createElement("a");l.title=f[e][g].title;l.innerHTML=l.title;l.href="#p:"+m.p+"/b:entry/id:"+g+"/n:"+encodeURIComponent(l.title);p.innerHTML+="Next: ";i.status.appendChild(p);i.status.appendChild(l);i.status.appendChild(document.createElement("br"))}if(g=h[e][n+1]){p=document.createElement("b");l=document.createElement("a");l.title=f[e][g].title;l.innerHTML=l.title;l.href="#p:"+
m.p+"/b:entry/id:"+g+"/n:"+encodeURIComponent(l.title);p.innerHTML+="Prev: ";i.status.appendChild(p);i.status.appendChild(l);i.status.appendChild(document.createElement("br"))}break}i.status.className="Status";i.body.innerHTML=j.body;i.bin.appendChild(i.title);i.bin.appendChild(i.status);i.bin.appendChild(i.body);k.appendChild(i.bin);NotificationCenter.PostNotification(a,"ContextDidChange",true);dfObject.TrackValue(0,100,20,5,function(t,v,x){Element.SetOpacity(x,t)},k)}};this.Clear=function(){delete f;
f={};h=[];NotificationCenter.PostNotification(this,"ContextDidChange",null)};this.Add=function(g,j){if(g&&typeof g==T_STR){f[g]||(f[g]={});h[g]||(h[g]=[])}if(j&&j instanceof Object&&!f[g][j.id]&&!(f[g][j.id]instanceof Object)){f[g][j.id]=j;h[g][h[g].length]=j.id}};this.AddEntry=function(g,j){if(j&&j instanceof Object&&f[e][g]&&f[e][g]instanceof Object){f[e][g].entry=j;E(g)}};this.Open=function(g){if(Element.IsElement(g)){var j=GetHashObj();e=g.id;s=g;s.appendChild(u[e].container);if(!F(j.b))window.location=
"#p:Blog/b:recent"}};this.Close=function(){q&&Element.Remove(q)};(function(){for(var g={recent:null,index:null,entry:null},j=0;j<b.length;j++){var m=$(b[j]);if(Element.IsElement(m)){m=m.getElementsByTagName("div");u[b[j]]={};for(var i=0;i<m.length;i++)if(m[i].className=="Contents")u[b[j]].container=m[i];else if(m[i].className=="Entries"){u[b[j]].recent=m[i];Element.Remove(m[i]);break}Element.Remove(u[b[j]].container);for(var n in g){u[b[j]][n]=document.createElement("div");u[b[j]][n].className=n+
"Context"}}}})();this.Clear()};function DEBUG_LOG(){var d=document.createElement("pre"),c=window.open("","DEBUG_WIN","left=0,top=0,width=300,height=300,scrollbars=yes"),a;c.document.write("<html><head><title></title></head><body></body></html>");c.document.title="DEBUG_LOG";a=c.getElementsByTagName("body")[0];a.style.margin=0;a.style.padding=0;a.style.padding="1em";a.style.color="#fff";a.style.fontSize="90%";a.style.textAlign="left";a.style.backgroundColor="#000";a.appendChild(d);window.DEBUG=function(b){d.innerHTML+=b+"\n";c.scrollTo(0,
a.scrollHeight)}}function ShowProperty(d,c){var a="";c=c?c:"\n";a+="<b>PROPERTIES</b>"+c;for(var b in d)try{a+="\u25a0 "+b+" = "+d[b]+c}catch(e){a+="\u25a0 "+b+" = ERROR{"+e+"}"+c}return a}function Dump(d){var c="",a=function(b,e){for(var f in b){c+=e+f;if(b[f]!=null&&typeof b[f]==T_OBJ)if(b[f]instanceof Object){c+="[Object]:\n";a(b[f],e+"\t")}else{b[f]=decodeURIComponent(b[f].replace(/\+/g," "));c+="="+b[f]+"\n"}else c+="="+b[f]+"\n"}return b};a(d,"");return c}
function ThrowError(d){var c=Element.Body(),a=document.createElement("div"),b=document.createElement("div"),e=document.createElement("div"),f=function(){a.style.height=b.style.height=dfObject.WindowHeight()+"px"};Element.SetOpacity(a,70);a.style.backgroundColor="#000";a.style.position=b.style.position="absolute";a.style.top=b.style.top=0;a.style.width=b.style.width="100%";a.style.zIndex=gMaxNum-1;a.style.height=b.style.height=dfObject.WindowHeight()+"px";a.style.overflow=b.style.overflow="hidden";
b.style.overflowY="auto";b.style.color="#fff";b.style.textAlign="left";b.style.zIndex=gMaxNum;e.style.padding="2em";e.innerHTML=d.replace("\n","<br />");alert(d);b.appendChild(e);c.appendChild(a);c.appendChild(b);f();EventCenter.AddEvent(window,"resize",null,f,true)};function Window(){var d=this,c=$("Header"),a=$("Container"),b=null,e={Home:null,About:null,Blog:null,Products:null},f=function(){Element.SetOpacity(b,0);dfObject.TrackValue(0,100,5,10,function(h){Element.SetOpacity(b,h)},null)};this.Load=function(){if(e.Home==null){for(var h in e){e[h]=$(h);e[h]&&Element.Remove(e[h])}NotificationCenter.PostNotification(this,"WindowDidLoad")}};this.Refresh=function(h){var s=dfObject.WindowHeight()-c.clientHeight;if(a){var q=$("Label");s=s-a.offsetTop;var k=0,r=function(B,
C){b.style.top=B+"px";if(C){a.style.overflowY="auto";if(q)q.style.right=a.offsetWidth-a.clientWidth+"px"}};a.style.height=s+"px";if(a.clientHeight!=s){s-=a.clientHeight-s;a.style.height=s+"px"}if(b){k=Math.round((s-b.clientHeight)/2);k=k>=0?k:0;if(h==true){a.style.overflow="hidden";dfObject.TrackValue(b.offsetTop,k,5,10,r,null)}else b.style.top=k+"px"}if(q){q.style.position="fixed";Element.SetOpacity(q,80);q.style.right=a.offsetWidth-a.clientWidth+"px"}}};this.Switch=function(h){h=GetHashObj(h);if(h==
null)h={p:"UNDEFINED",raw:"UNDEFINED"};if(Element.IsElement(e[h.p])==false)setTimeout(function(){window.location="#p:Home"},500);else{Element.Remove(b);b=e[h.p];b.style.position="relative";b.style.display="block";Element.SetOpacity(b,0);a.appendChild(b);window.location=h.raw;NotificationCenter.PostNotification(this,"WindowDidSwitch",h);d.Refresh();f()}};this.GetElementAtCurrentView=function(h,s){var q=null;if(a)for(var k=a.getElementsByTagName(h),r=0;r<k.length;r++)if(k[r].className==s){q=k[r];break}return q};
c.style.position="absolute";a.style.overflow="hidden";a.style.overflowY="auto";EventCenter.AddEvent(window,"resize",this,"Refresh",true);EventCenter.AddEvent(window,"scroll",this,"Refresh",true)};
