(function(NS){var $0='application.js';var g_DB=null;if(!window.google||!google.gears)
{}
else
{try{g_DB=google.gears.factory.create('beta.database','1.0');}catch(e){}}
document.open();document.write('<script type="text/javascript" src="'+u.build+'/scripts/db-'+(g_DB?'gears':'transient')+'.js"></script>\n');document.close();NS.Application={_Init:function()
{u.initClassInstance(this,{layout:null,toolbar:null,importExportDialog:null});var d=this.d;try
{NS.Msg.setCatalog(NS.MSG_ja_JP);if(!g_DB)
{u.gel('base_msg').style.display='block';}
if(NS.DB.Initialize(g_DB))
{var $1=new Date();var pg=NS.WelcomePage;for(var j=0;j<pg.length;++j)
{var src=pg[j].content;var wf=[];for(var i=0;i<src.length;++i)
{wf.push(NS.DB.CreateFragment({type:src[i].type,title:src[i].title,content:src[i].content.join('\n'),option:src[i].option,view:src[i].view,ctime:$1,mtime:$1}));}
NS.DB.StoreResource({id:pg[j].id,title:pg[j].title,fragments:wf,option:{},view:{},ctime:$1,mtime:$1});}}
var $2={west:{split:true,initialSize:200,minSize:100,titlebar:true,collapsible:true,animate:true},center:{titlebar:true,tabPosition:'top',alwaysShowTabs:true,resizeTabs:true,closeOnTab:true}};if(u.debug)
{$2.south={split:true,initialSize:200,minSize:50,titlebar:true,collapsible:true,collapsed:true,animate:true};var $3=new NS.DebugConsole();}
d.layout=new Ext.BorderLayout(Ext.get('base_app'),$2);d.layout.beginUpdate();d.layout.add('west',new Ext.ContentPanel('app_left',{title:'Left'}));if(u.debug)d.layout.add('south',$3);d.toolbar=new NS.Toolbar(d.layout.getRegion('center'));d.layout.endUpdate();if(u.debug)$3.PostAppend(d.layout.getRegion('south'));var page='home';if(/#(.+)$/.test(location.hash))
page=u.toWikiName(u.unescWikiName(RegExp.$1));this.OpenPage(page,page);}
catch(ex)
{u.cleanupClassInstance(this,NS.Application);throw ex;}},GetRegion:function($4)
{return this.d.layout.getRegion($4);},GetActivePanel:function()
{return this.GetRegion('center').getActivePanel();},CloseAllPanels:function()
{var d=this.d;var $5=NS.Application.GetRegion('center');var $3=null;while($3=$5.getPanel(0))
{$3.Close();}
NS.ResourceModel.RemoveAll();NS.FragmentModel.RemoveAll();},OpenPage:function($6,$7)
{var $6=u.toWikiName($6);if($6)
{var d=this.d,$8=null,$3=null;$8=NS.ResourceController.Find($6,$7);$8.m.RefCount.holdWhile(function(){$3=new NS.ResourceView($6,d.toolbar);try
{d.layout.beginUpdate();d.layout.add('center',$3);d.layout.endUpdate();$3.PostAppend(d.layout.getRegion('center'),true);$8.AttachView($3);}
catch(ex)
{u.cleanupClassInstance($3);throw ex;}});}},OnOpenPage:function()
{var $7=u.gel('tmp_pagename').value;this.OpenPage($7,$7);},ImportSiteDB:function($9,$a,$b)
{if(NS.Environment.ie)
$9=$9.replace(/\<\!DOCTYPE\s[^\]]*\]\s*\>/,'');try
{var $c=false;var $d=new XPathDocument((new DOMParser()).parseFromString($9,'text/xml'));var $e=$d.getRawDocument();var $f=null;if($e&&$e.documentElement.nodeName!='InfosketchDocument')
throw new Error(NS.Msg.get('ERR_ImportIllegalXML'));var $g=$d.evaluate('/InfosketchDocument/Fragments/Fragment',$d,$f,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);var $h=$d.evaluate('/InfosketchDocument/Resources/Resource',$d,$f,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);if(!$g||!$g.snapshotLength||!$h||!$h.snapshotLength)
throw new Error(NS.Msg.get('ERR_ImportEmpty'));var $i={f:{},r:{}},$j=$g.snapshotLength,$k=$h.snapshotLength;var $l=$d.createExpression('Content',$f);for(var i=0;i<$j;++i)
{var $m=$g.snapshotItem(i);var $n={id:$m.getAttribute('id'),type:$m.getAttribute('type'),title:$m.getAttribute('title')||'',option:u.parseJSON($m.getAttribute('option'))||{},view:u.parseJSON($m.getAttribute('view'))||{},ctime:new Date(Number($m.getAttribute('ctime')||'0')),mtime:new Date(Number($m.getAttribute('mtime')||'0'))};if(!NS.FragmentModel.ValidateType($n.type)||!$n.id)
{$c=true;continue;}
var $o='';var $p=$l.evaluate($m,XPathResult.ANY_UNORDERED_NODE_TYPE,null);if($p&&$p.singleNodeValue)
{$m=$p.singleNodeValue.firstChild;while($m)
{if($m.nodeType==3||$m.nodeType==4)
$o+=$m.nodeValue;$m=$m.nextSibling;}}
$n.content=$o;$i.f[$n.id]=$n;}
var $l=$d.createExpression('References/Reference',$f);for(var i=0;i<$k;++i)
{var $m=$h.snapshotItem(i);var $q={id:$m.getAttribute('id'),title:$m.getAttribute('title')||'',option:u.parseJSON($m.getAttribute('option'))||{},view:u.parseJSON($m.getAttribute('view'))||{},ctime:new Date(Number($m.getAttribute('ctime')||'0')),mtime:new Date(Number($m.getAttribute('mtime')||'0')),fids:[]};if(!$q.id||!/^rsc_/.test($q.id))
{$c=true;continue;}
$q.id=$q.id.replace(/^rsc_/,'');$i.r[$q.id]=$q;var $r=$l.evaluate($m,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);while($m=$r.iterateNext())
{var $6=$m.getAttribute('frg');if(!$6||$6.length<=0||!$i.f[$6])
{$c=true;continue;}
$q.fids[$q.fids.length]=$6;}}
NS.Application.CloseAllPanels();NS.DB.TransactionForSiteDB(function(){NS.DB.ClearSiteDB();var $s={};u.forEach($i.r,function($q){var $t=$q.fids,$g=[];for(var i=0;i<$t.length;++i)
{var $u=$s[$t[i]];if(!$u)
$u=$s[$t[i]]=NS.DB.CreateFragment($i.f[$t[i]]);$g[$g.length]=$u;}
$q.fragments=$g;NS.DB.StoreResource($q);},this);},this);if($c&&u.isFunction($a))
$a.call($b||window,new Error(NS.Msg.get('ERR_ImportIncomplete')));}
catch($v)
{if(u.isFunction($a))
$a.call($b||window,$v);return false;}
return true;},UIImportExport:function()
{var d=this.d;if(!d.importExportDialog)
{d.importExportDialog=new NS.ImportExportDialog();}
d.importExportDialog.show();}};Ext.EventManager.onDocumentReady(function(){NS.Application._Init();window.g_app=NS.Application;});NS.Msg={$w:{},setCatalog:function($w)
{this.$w=$w;},get:function($6)
{return this.$w[$6]||$6;}};NS.Toolbar=function($5)
{var $x=u.nel('DIV'),$y=$5.bodyEl.dom;$x.id='app_toolbar';$y.insertBefore($x,$y.firstChild);NS.Toolbar.superclass.constructor.call(this,$x);u.initClassInstance(this);try
{this.addButton({text:NS.Msg.get('UI_Back'),icon:u.build+'/template/action_back.gif',cls:'x-btn-text-icon',handler:this.$z.createDelegate(this)});this.addButton({text:NS.Msg.get('UI_Forward'),icon:u.build+'/template/action_forward.gif',cls:'x-btn-text-icon',handler:this.$A.createDelegate(this)});this.addButton({text:NS.Msg.get('UI_Home'),icon:u.build+'/template/house.png',cls:'x-btn-text-icon',handler:this.$B.createDelegate(this)});this.addButton({text:NS.Msg.get('UI_EditTitle'),icon:u.build+'/template/pencil.png',cls:'x-btn-text-icon',handler:this.$C.createDelegate(this)});this.addButton({text:NS.Msg.get('UI_DeletePage'),icon:u.build+'/template/action_stop.gif',cls:'x-btn-text-icon',handler:this.$D.createDelegate(this)});this.addButton({text:NS.Msg.get('UI_ImportExport'),icon:u.build+'/template/disk.png',cls:'x-btn-text-icon',handler:this.$E.createDelegate(this)});}
catch(ex)
{u.cleanupClassInstance(this,NS.Toolbar);throw ex;}};u.extend(NS.Toolbar,Ext.Toolbar,{_Cleanup:function()
{},$F:function($G)
{$H=NS.Application.GetActivePanel();if($H&&u.isFunction($H[$G]))
{$H[$G].call($H);return true;}
return false;},$z:function($I)
{this.$F('UIBack');},$A:function($I)
{this.$F('UIForward');},$B:function($I)
{if(!this.$F('UIGoHome'))
NS.Application.OpenPage('home','home');},$C:function($I)
{this.$F('UIEditTitle');},$D:function($I)
{this.$F('UIDelete');},$E:function($I)
{NS.Application.UIImportExport();}});NS.DragDrop=function($J,$K,$L)
{$K=parseInt($K,10);$L=parseInt($L,10);u.initClassInstance(this,{$J:null,$M:null,$N:null,$K:$K,$L:$L,$O:$K,$P:$L,$Q:0,$R:0});try
{if(NS.DragDrop.$S)
NS.DragDrop.$S.Cancel();NS.DragDrop.$S=this;var d=this.d;var $T=u.computeBounds($J,true);d.$J=$J;d.$N=this.$U($J,$T);d.$Q=$T.left-$K;d.$R=$T.top-$L;Ext.EventManager.on(document,'mousemove',this.$V,this);Ext.EventManager.on(document,'mouseup',this.$W,this);}
catch(ex)
{u.cleanupClassInstance(this,NS.DragDrop);throw ex;}};NS.DragDrop.$S=null;NS.DragDrop.$N=null;NS.DragDrop.prototype={_Cleanup:function()
{var d=this.d;d.$J=d.$M=d.$N=null;NS.DragDrop.$S=null;Ext.EventManager.removeListener(document,'mousemove',this.$V);Ext.EventManager.removeListener(document,'mouseup',this.$W);},$U:function($J,$T)
{var $N=NS.DragDrop.$N||u.nel('DIV');Ext.DomHelper.applyStyles($N,{position:'absolute',left:$T.left+'px',top:$T.top+'px',width:($T.width-8)+'px',height:($T.height-8)+'px',backgroundColor:'transparent',border:'dashed 4px #888',margin:'0px',padding:'0px',display:'block',zIndex:256});if(!$N.parentNode)
document.body.appendChild($N);return NS.DragDrop.$N=$N;},$X:function()
{if(this.d.$N)this.d.$N.style.display='none';},$Y:function($Z)
{var d=this.d;var $10=$Z.getXY();d.$N.style.left=((d.$O=$10[0])+d.$Q)+'px';d.$N.style.top=((d.$P=$10[1])+d.$R)+'px';var $M=u.unthrow(function(){return this.OnDrag($Z);},this);if(d.$M!=$M)
{if(d.$M)
u.unthrow(function(){this.OnDragOut($Z,d.$M);},this);if($M)
u.unthrow(function(){this.OnDragEnter($Z,$M);},this);}
d.$M=$M;},$11:function($Z)
{var d=this.d;if(d.$M)
{this.$X();u.unthrow(function(){this.OnDrop($Z,d.$M);},this);u.cleanupClassInstance(this);}
else
{this.Cancel();}},$V:function($Z)
{$Z.stopEvent();this.$Y($Z);if(NS.Environment.ie&&($Z.button!==0&&$Z.button!==1&&$Z.button!==2))
this.$11();},$W:function($Z)
{$Z.stopEvent();this.$Y($Z);this.$11($Z);},Cancel:function()
{this.$X();u.unthrow(function(){this.OnCancel();},this);u.cleanupClassInstance(this);},GetCurrentTarget:function(){return this.d.$M;},GetSource:function(){return this.d.$J;},GetProxy:function(){return this.d.$N;},OnDrag:function($Z){return null;},OnDragEnter:function($Z,$M){},OnDragOut:function($Z,$M){},OnDrop:function($Z,$M){},OnCancel:function(){}};NS.FragmentDD=function($J,$10)
{NS.FragmentDD.superclass.constructor.call(this,$J,$10[0],$10[1]);u.initClassInstance(this,{$12:{},$13:null,$14:null,$15:null,$16:100,$17:null,$18:null,$19:0});try
{var d=this.d;d.$17=new Date();d.$15=setInterval(this.$1a.createDelegate(this),100);if(NS.Environment.opera)
$J.style.setProperty('visibility','hidden','');else
Ext.get($J).setOpacity(0.5);Ext.get(this.GetProxy()).show();u.info('[CREATE] FragmentDD '+$J.id,$0);}
catch(ex)
{u.cleanupClassInstance(this,NS.FragmentDD);throw ex;}};u.extend(NS.FragmentDD,NS.DragDrop,{_Cleanup:function()
{var $J=this.GetSource();if($J)
{if(NS.Environment.opera)
$J.style.removeProperty('visibility');else
Ext.get($J).clearOpacity();}
var d=this.d;if(d)
{if(d.$15)
clearInterval(d.$15);u.info('[DELETE] FragmentDD '+this.GetSource().id,$0);}},GetUserData:function($1b)
{return this.d.$12[$1b];},SetUserData:function($1b,$i)
{this.d.$12[$1b]=$i;},SetScrollTarget:function($1c,$T)
{this.d.$13=$1c;this.d.$14=$T;},OnDrag:function($Z)
{this.d.$18=$Z.getPageY();var $1d=null;$H=NS.Application.GetActivePanel();if($H&&u.isFunction($H.OnDragFragment))
{$1d=$H.OnDragFragment(this,$Z);}
return $1d;},OnDragEnter:function($Z,$M)
{if(u.isFunction($M.OnDragEnter))
u.unthrow(function(){$M.OnDragEnter();});},OnDragOut:function($Z,$M)
{this.$1e($M);},OnDrop:function($Z,$M)
{this.$1e($M);if(u.isFunction($M.OnDragDrop))
$M.OnDragDrop($Z,this,this.GetSource());},OnCancel:function()
{var $J=this.GetSource();var $N=this.GetProxy();if($J&&$N)
{var $1f=Ext.get($N);var $T=u.computeBounds($J,true);if(typeof $J.clientLeft==='undefined'||typeof $J.clientTop==='undefined')
{$T.left+=4;$T.top+=4;}
$1f.show();$1f.setXY([$T.left,$T.top],{duration:0.3,easing:'easeNone'}).hide({duration:0.3,easing:'easeIn',callback:function(){this.clearOpacity();this.dom.style.display='none';},scope:$1f});}},$1a:function()
{var d=this.d,$1=new Date();if(d.$14&&d.$13&&!u.isNull(d.$18)&&$1-d.$17>=d.$16)
{if(d.$18<d.$14.top)
{if(d.$19>0)d.$19=0;d.$19=u.clamp(d.$19-2,-32,0);}
else if(d.$18>d.$14.bottom)
{if(d.$19<0)d.$19=0;d.$19=u.clamp(d.$19+2,0,32);}
else
{d.$19=0;}
if(d.$19!=0)
{var $1c=d.$13;var $1g=$1c.scrollTop;var $1h=Math.max($1c.scrollHeight-$1c.clientHeight,0);$1c.scrollTop=u.clamp($1g+d.$19,0,$1h);}}
d.$17=$1;},$1e:function($M)
{if(u.isFunction($M.OnDragOut))
u.unthrow(function(){$M.OnDragOut();});}});})(Infosketch);