Ext.BLANK_IMAGE_URL = 'images/spacer.gif';//Spacer
Docs = {};

ApiPanel = function() {
    ApiPanel.superclass.constructor.call(this, {
        id:'api-tree',
        region:'west',//場所指定
        split:true,//大きさ変更ができるかどうか
        width: 250,
        minSize: 150,
        maxSize: 500,
        collapsible: true,
        margins:'0 0 5 5',
        cmargins:'0 0 0 0',
        rootVisible:false,//rootを表示するか
        lines:true,//∟
        autoScroll:true,
        animCollapse:false,
        collapseMode:'mini',//ボックスを閉じるボタンがつく
       // animate: true,//開くときのアニメーション
        
       loader: new Ext.tree.TreeLoader({
         preloadChildren: true,
         clearOnLoad: false
       }),
        root: new Ext.tree.AsyncTreeNode({
            text:'Ext JS',
            id:'root',
            expanded:true,
            children:[Docs.classData]
         })
    });
};

Ext.extend(ApiPanel, Ext.tree.TreePanel, {});
Ext.onReady(function(){
    var api = new ApiPanel();

    api.on('click', function(node, e){
       e.stopEvent();
       document.getElementById("main").src=node.attributes.href;
       
    });


    var header = new Ext.BoxComponent({
        region:'north',
	      el:'header'
    });
    
    var mainPanel= new Ext.BoxComponent({
        region:'center',
        el:'main',
        margins:'0 5 5 0',
        	
        autoScroll: true
    });
    		

    var viewport = new Ext.Viewport({
        layout:'border',
        items:[ header, api, mainPanel ]
    });

    viewport.doLayout();
	
	setTimeout(function(){
        Ext.get('loading').remove();
        Ext.get('loading-mask').fadeOut({remove:true});
    }, 250);
	
	var filter = new Ext.tree.TreeFilter(api, {
		clearBlank: true,
		autoClear: true
	});
	target = window.location.search.substring(1);
	if (target) {
		setTimeout("document.getElementById('main').src = './' + target;", 500);
		node = '/root/' + findPath(target, Docs.classData);
		api.expandPath(node);
		api.selectPath(node);
		
	} else {
    	api.expandPath('/root/default');
		api.expandAll();
	}
});


function findPath(target, src) {
	if (src.id == target.replace(/\//g, '_')) {
		return src.id;
	} else {
		for (i in src.children) {
			ret = findPath(target, src.children[i]);
			if (ret != '') {
				return src.id + '/' + ret;
			}
		}
	}
	return '';
}
function retNode(title, href, state, children) {
	cls = 'none';
	if (state == 'draft') {
		cls = 'draft';
	} else if (state == 'done') {
		cls = 'done';
	} else if (state == 'external') {
		cls = 'external';
	}
	icon_cls = 'icon-' + cls;
	if (children) {
		return {"id":href.replace(/\//g, '_'),"href":href,"iconCls":icon_cls, "text":title,"isClass":true,"cls":cls,"leaf":false, "children":children};
	} else {
		return {"id":href.replace(/\//g, '_'),"href":href,"text":title,"isClass":true,"iconCls":icon_cls, "cls":cls,"leaf":true};
	}
}
		
//retNode("", "", "draft"),
Docs.classData =
{"id":"default","text":"Androidドキュメント","href":"fast.html","singleClickExpand":true,
"children":[
/* menu starts */
retNode("Android の基本", "#1", "none", [
	retNode("Android とは", "basics/what-is-android.html", "none")
]),
retNode("フレームワーク トピック", "#2", "none", [
	retNode("開発の基礎", "topics/fundamentals.html", "external"),
	retNode("User Interface", "topics/ui/index.html", "none", [
		retNode("Declaring Layout", "topics/ui/declaring-layout.html", "none"),
		retNode("Creating Menus", "topics/ui/menus.html", "none"),
		retNode("Creating Dialogs", "topics/ui/dialogs.html", "none"),
		retNode("Handling UI Events", "topics/ui/ui-events.html", "none"),
		retNode("Notifying the User", "topics/ui/notifiers/index.html", "none"),
		retNode("Applying Styles and Themes", "topics/ui/themes.html", "none"),
		retNode("Building Custom Components", "topics/ui/custom-components.html", "none"),
		retNode("Binding to Data with AdapterView", "topics/ui/binding.html", "none"),
		retNode("Common Layout Objects", "topics/ui/layout-objects.html", "none"),
		retNode("How Android Draws Views", "topics/ui/how-android-draws.html", "none")
	]),
	retNode("Resources and Assests", "topics/resources/index.html", "draft", [
		retNode("Resources and I18n", "topics/resources/resources-i18n.html", "none"),
		retNode("Available Resource Types", "topics/resources/available-resources.html", "none")
	]),
	retNode("Intents and Intent Filters", "topics/intents/intents-filters.html", "none"),
	retNode("Data Storage", "topics/data/data-storage.html", "none"),
	retNode("Content Providers", "topics/providers/content-providers.html", "none"),
	retNode("Security and Permissions", "topics/security/security.html", "none"),
	retNode("The AndroidManifest.xml File", "topics/manifest/manifest-intro.html", "none", [
		retNode("&lt;action&gt;", "topics/manifest/action-element.html", "draft"),
		retNode("&lt;activity&gt;", "topics/manifest/activity-element.html", "none"),
		retNode("&lt;activity-alias&gt;", "topics/manifest/activity-alias-element.html", "none"),
		retNode("&lt;application&gt;", "topics/manifest/application-element.html", "none"),
		retNode("&lt;category&gt;", "topics/manifest/category-element.html", "draft"),
		retNode("&lt;data&gt;", "topics/manifest/data-element.html", "none"),
		retNode("&lt;grant-uri-permission&gt;", "topics/manifest/grant-uri-permission-element.html", "none"),
		retNode("&lt;instrumentation&gt;", "topics/manifest/instrumentation-element.html", "none"),
		retNode("&lt;intent-filter&gt;", "topics/manifest/intent-filter-element.html", "none"),
		retNode("&lt;manifest&gt;", "topics/manifest/manifest-element.html", "none"),
		retNode("&lt;meta-data&gt;", "topics/manifest/meta-data-element.html", "none"),
		retNode("&lt;path-permission&gt;", "topics/manifest/path-permission-element.html", "draft"),
		retNode("&lt;permission&gt;", "topics/manifest/permission-element.html", "none"),
		retNode("&lt;permission-group&gt;", "topics/manifest/permission-group-element.html", "none"),
		retNode("&lt;permission-tree&gt;", "topics/manifest/permission-tree-element.html", "none"),
		retNode("&lt;provider&gt;", "topics/manifest/provider-element.html", "none"),
		retNode("&lt;receiver&gt;", "topics/manifest/receiver-element.html", "none"),
		retNode("&lt;service&gt;", "topics/manifest/service-element.html", "none"),
		retNode("&lt;supports-screens&gt;", "topics/manifest/supports-screens-element.html", "draft"),
		retNode("&lt;uses-configuration&gt;", "topics/manifest/uses-configuration-element.html", "none"),
		retNode("&lt;uses-feature&gt;", "topics/manifest/uses-feature-element.html", "draft"),
		retNode("&lt;uses-library&gt;", "topics/manifest/uses-library-element.html", "draft"),
		retNode("&lt;uses-permission&gt;", "topics/manifest/uses-permission-element.html", "draft"),
		retNode("&lt;uses-sdk&gt;", "topics/manifest/uses-sdk-element.html", "draft")
	]),
	retNode("Graphics", "topics/graphics/index.html", "none", [
		retNode("2D Graphics", "topics/graphics/2d-graphics.html", "none"),
		retNode("3D with OpenGL", "topics/graphics/opengl.html", "draft")
	]),
	retNode("Audio and Video", "topics/media/index.html", "none"),
	retNode("Location and Maps", "topics/location/index.html", "none"),
	retNode("App Widgets", "topics/appwidgets/index.html", "none")
]),
retNode("開発", "#3", "none", [
	retNode("Eclipse 内で ADT を使用", "developing/eclipse-adt.html", "none"),
	retNode("その他の統合開発環境", "developing/other-ide.html", "none"),
	retNode("On a Device", "developing/device.html", "none"),
	retNode("Debugging Tasks", "developing/debug-tasks.html", "none"),
	retNode("Tools", "developing/tools/index.html", "draft", [
		retNode("aapt", "developing/tools/aapt.html", "draft"),
		retNode("adb", "developing/tools/adb.html", "draft"),
		retNode("android", "developing/tools/othertools.html#android", "draft"),
		retNode("aidl", "developing/tools/aidl.html", "none"),
		retNode("AVDs", "developing/tools/avd.html", "none"),
		retNode("ddms", "developing/tools/ddms.html", "none"),
		retNode("dx", "developing/tools/othertools.html#dx", "draft"),
		retNode("Draw 9-Patch", "developing/tools/draw9patch.html", "none"),
		retNode("Emulator", "developing/tools/emulator.html", "none"),
		retNode("Hierarchy Viewer", "developing/tools/hierarchy-viewer.html", "none"),
		retNode("mksdcard", "developing/tools/othertools.html#mksdcard", "draft"),
		retNode("Monkey", "developing/tools/monkey.html", "none"),
		retNode("sqlite3", "developing/tools/adb.html#sqlite", "none"),
		retNode("Traceview", "developing/tools/traceview.html", "none"),
		retNode("zipalign", "developing/tools/zipalign.html", "draft")
	])
]),
retNode("公開", "#4", "none", [
	retNode("アプリケーションへの署名", "publishing/app-signing.html", "none"),
	retNode("アプリケーションのバージョニング", "publishing/versioning.html", "none"),
	retNode("公開の準備", "publishing/preparing.html", "none"),
	retNode("Publishing Your Applications", "publishing/publishing.html", "none")
]),
retNode("ベスト プラクティス", "#5", "none", [
	retNode("UI Guidelines", "practices/ui_guidelines/index.html", "draft", [
		retNode("Icon Design", "practices/ui_guidelines/icon_design.html", "none"),
		retNode("App Widget Design", "practices/ui_guidelines/widget_design.html", "none"),
		retNode("Activity and Task Design", "practices/ui_guidelines/activity_task_design.html", "none"),
		retNode("Menu Design", "practices/ui_guidelines/menu_design.html", "none")
	]),
	retNode("Designing for Performance", "practices/design/performance.html", "done"),
	retNode("Designing for Responsiveness", "practices/design/responsiveness.html", "done"),
	retNode("Designing for Seamlessness", "practices/design/seamlessness.html", "none")
]),
retNode("チュートリアルとサンプル コード", "#6", "none", [
	retNode("Hello World", "tutorials/hello-world.html", "none"),
	retNode("Hello Views", "tutorials/views/index.html", "none"),
	retNode("Notepad Tutorial", "tutorials/notepad/index.html", "none"),
	retNode("Sample Code", "samples/index.html", "done", [
		retNode("API Demos", "samples/ApiDemos/index.html", "none"),
		retNode("Home", "samples/Home/index.html", "draft"),
		retNode("JetBoy", "samples/JetBoy/index.html", "draft"),
		retNode("NotePad", "samples/NotePad/index.html", "none"),
		retNode("Searchable Dictionary", "samples/SearchableDictionary/index.html", "draft"),
		retNode("Snake", "samples/Snake/index.html", "draft"),
		retNode("Soft Keyboard", "samples/SoftKeyboard/index.html", "draft")
	])
]),
retNode("付録", "#7", "none", [
	retNode("Android API Levels", "appendix/api-levels.html", "draft"),
	retNode("Supported Media Formats", "appendix/media-formats.html", "none"),
	retNode("Intents List: Google Apps", "appendix/g-app-intents.html", "none"),
	retNode("Glossary", "appendix/glossary.html", "none"),
	retNode("FAQ", "appendix/faq/index.html", "done")
])
/* menu ends */
]};