﻿//
// This is the main layout definition.
//
var ua = navigator.userAgent.toLowerCase();  
var isIE = ua.indexOf("msie") > -1;

//alert(isIE);
var start = {
	id: 'start-panel',
	title: '內容',
	layout: 'fit',
	bodyStyle: 'padding:0px',
	contentEl: 'start-div',  // pull existing content from the page
    height: 600,
    autoScroll: isIE
};


Ext.onReady(function(){
	
	Ext.QuickTips.init();
	
	// This is an inner body element within the Details panel created to provide a "slide in" effect
	// on the panel body without affecting the body's box itself.  This element is created on
	// initial use and cached in this var for subsequent access.
	var detailEl;
	var contentEl;

	// This is the main content center region that will contain each example layout panel.
	// It will be implemented as a CardLayout since it will contain multiple panels with
	// only one being visible at any given time.
	var contentPanel = {
		id: 'content-panel',
		region: 'center', // this is what makes this panel into a region within the containing layout
		layout: 'card',
		margins: '2 5 5 0',
		activeItem: 0,
		border: false,
        autoScroll: true,
		items: [
			// from basic.js:
			start/*, absolute, accordion, anchor, border, cardTabs, cardWizard, column, fit, form, table,
			// from custom.js:
			rowLayout, centerLayout,
			// from combination.js:
			absoluteForm, tabsNestedLayouts*/
		]
	};
    
	// Go ahead and create the TreePanel now so that we can use it below
    var treePanel = new Ext.tree.TreePanel({
    	id: 'tree-panel',
    	title: '導覽列',
        region:'north',
        split: true,
        height: 400,
        minSize: 150,
        autoScroll: true,
        
        // tree-specific configs:
        rootVisible: false,
        lines: false,
        singleExpand: false,
        useArrows: true,
        
        loader: new Ext.tree.TreeLoader({
            dataUrl:'tree-data.json'
        }),
        
        root: new Ext.tree.AsyncTreeNode()
    });
    
    var action_list = {
        register: function(){
            Ext.getDom('start-div').innerHTML = '<iframe src="https://spreadsheets.google.com/embeddedform?key=pk9KMw9m-QEPd3RFhjFFIew" width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>';
        },
        puzzle: function(){
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/PuzzleGamev3/index.html' width='100%' height='100%'></iframe>";
        },
        level1: function(){
            Ext.getDom('start-div').innerHTML = '<EMBED allowScriptAccess="never" src="http://five.flash-gear.com/npuz/puz.php?c=f&o=1&id=3090038&k=2486643&s=150&w=600&h=450" quality=high wmode=transparent scale=noscale salign=LT bgcolor="FFFFFF" WIDTH="750" HEIGHT="600" NAME="puz481616" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        },
        level2: function(){
            Ext.getDom('start-div').innerHTML = '<EMBED allowScriptAccess="never" src="http://five.flash-gear.com/npuz/puz.php?c=f&o=1&id=3090040&k=59029854&s=90&w=630&h=450" quality=high wmode=transparent scale=noscale salign=LT bgcolor="FFFFFF" WIDTH="780" HEIGHT="600" NAME="puz424655" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        },
        level3: function(){
            Ext.getDom('start-div').innerHTML = '<EMBED allowScriptAccess="never" src="http://two.flash-gear.com/npuz/puz.php?c=f&o=1&id=2299577&k=14531995&s=60&w=600&h=420" quality=high wmode=transparent scale=noscale salign=LT bgcolor="FFFFFF" WIDTH="750" HEIGHT="570" NAME="puz213464" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        },
        level4: function(){
            Ext.getDom('start-div').innerHTML = '<EMBED allowScriptAccess="never" src="http://two.flash-gear.com/npuz/puz.php?c=f&o=1&id=2299578&k=34006022&s=30&w=570&h=420" quality=high wmode=transparent scale=noscale salign=LT bgcolor="FFFFFF" WIDTH="720" HEIGHT="570" NAME="puz41723" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        },
        level5: function(){
            Ext.getDom('start-div').innerHTML = '<EMBED allowScriptAccess="never" src="http://six.flash-gear.com/npuz/puz.php?c=f&o=1&id=2763858&k=80500949&s=15&w=555&h=405" quality=high wmode=transparent scale=noscale salign=LT bgcolor="FFFFFF" WIDTH="705" HEIGHT="555" NAME="puz34545" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        },
        img1: function(){
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5204308328756739537%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },

        img2: function(){
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5209851468162692129%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },

        img3: function(){
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5232930776921164657%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },
          
        img4: function(){            
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5232930313372250033%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },
        img51: function(){            
            // 迎娶   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5257040774553034561%3Fkind%3Dphoto%26alt%3Drss%26authkey%3DeadD3o7QYy0" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'
        },
        img52: function(){            
            // 典禮    
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5255020527708705729%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },

        img53: function(){            
            // 晚宴   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5255036883063246385%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },
        img61: function(){
            // 蜜月旅行9/30   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.ebook%2Falbumid%2F5257421695114180833%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';            
        },
        img62: function(){
            // 蜜月旅行10/1   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.ebook%2Falbumid%2F5257422262746638817%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';            
        },
        img63: function(){
            // 蜜月旅行10/2   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.ebook%2Falbumid%2F5257423159257610977%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';            
        },
        img64: function(){
            // 蜜月旅行10/3   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.ebook%2Falbumid%2F5257411685028755921%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';            
        },
        img65: function(){
            // 蜜月旅行10/4   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.ebook%2Falbumid%2F5257421167067747089%3Fkind%3Dphoto%26alt%3Drss" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';            
        },
        img8: function(){
            // 歸寧   
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5257039859789396449%3Fkind%3Dphoto%26alt%3Drss%26authkey%3DoM1l0y5F2ig" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
            
        },
        img7: function(){
            // 訂婚                
            Ext.getDom('start-div').innerHTML = '<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com.tw/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com.tw&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com.tw%2Fdata%2Ffeed%2Fapi%2Fuser%2Fsisimi.pchome%2Falbumid%2F5257040839455730881%3Fkind%3Dphoto%26alt%3Drss%26authkey%3DBU9CILx0AjA" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
        },
        img81: function(){              
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_001.htm' width='100%' height='100%'></iframe>";
        },
        img82: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_002.htm' width='100%' height='100%'></iframe>";
        },
        img83: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_003.htm' width='100%' height='100%'></iframe>";
        },

        img84: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_004.htm' width='100%' height='100%'></iframe>";
        },
        img85: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_005.htm' width='100%' height='100%'></iframe>";
        },
        img86: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_006.htm' width='100%' height='100%'></iframe>";
        },
        img87: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_007.htm' width='100%' height='100%'></iframe>";
        },
        img88: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_008.htm' width='100%' height='100%'></iframe>";
        },

        img89: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_009.htm' width='100%' height='100%'></iframe>";
        },
        img8a: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_010.htm' width='100%' height='100%'></iframe>";
        },
        img8b: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_011.htm' width='100%' height='100%'></iframe>";
        },
        img8c: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_012.htm' width='100%' height='100%'></iframe>";
        },
        img8d: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_013.htm' width='100%' height='100%'></iframe>";
        },
        img8e: function(){
            //                 
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/video_014.htm' width='100%' height='100%'></iframe>";
        },
        proc_page: function(){
            window.open('/file/proc_page.doc');
        },

        news: function(){
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/news.html' width='100%' height='100%'></iframe>";
        },
        contact_msn: function(){
            Ext.getDom('start-div').innerHTML = '<iframe src="http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=ca5d9227df9e78e8@apps.messenger.live.com&mkt=zh-cn&useTheme=true&foreColor=333333&backColor=E8F1F8&linkColor=333333&borderColor=AFD3EB&buttonForeColor=333333&buttonBackColor=EEF7FE&buttonBorderColor=AFD3EB&buttonDisabledColor=EEF7FE&headerForeColor=0066A7&headerBackColor=8EBBD8&menuForeColor=333333&menuBackColor=FFFFFF&chatForeColor=333333&chatBackColor=FFFFFF&chatDisabledColor=F6F6F6&chatErrorColor=760502&chatLabelColor=6E6C6C" width="500" height="300" style="border: solid 1px black; width: 100%; height: 100%;" frameborder="0"></iframe>';
        },
        contact_gtalk: function(){
            Ext.getDom('start-div').innerHTML = '<iframe src="http://www.google.com/talk/service/badge/Show?tk=z01q6amlq9vi14akkvkc9f8o777eh5uga1eidv24ns7sc7u7eqvflik7rc7jap5pev3u7ncecbl34biquct4l7kob9f1jqnnd3qgmul1nq97tlg11c4tnhgkebqr87etdem4jo8euajoe9erb1ucnbg08l76hne7l8epageb2&amp;w=200&amp;h=60" allowtransparency="true" width="700" frameborder="0" height="400"></iframe>';
        },
        traffic: function(){
            start.autoScroll = false;
            Ext.getDom('start-div').innerHTML = "<iframe src='/html/traffic.html' width='100%' height='100%'></iframe>";
        },
        rss: function(){
            window.open("/file/feed.rss");    
        },
        board: function(){
            
            if (isIE){
                start.autoScroll = false;
                contentPanel.autoScroll = false;
                Ext.getDom('start-div').innerHTML = "<iframe src='/guestbook' width='810px' height='100%'></iframe>";
            }else{
                start.autoScroll = true;
                Ext.getDom('start-div').innerHTML = "<iframe src='/guestbook' width='100%' height='100%'></iframe>";
            }
        }
    };
        
	// Assign the changeLayout function to be called on tree node click.
    treePanel.on('click', function(n){
        //alert(n);
    	var sn = this.selModel.selNode || {}; // selNode is null on initial selection
        //alert(n.id);
    	//if(n.leaf && n.id != sn.id){  // ignore clicks on folders and currently selected node 
    		//Ext.getCmp('content-panel').layout.setActiveItem(n.id + '-panel');
            //if (!contentEl){
    			//var bd = Ext.getCmp('content-panel').body;
    			//bd.update('').setStyle('background','#fff');
    			//contentEl = bd.createChild(); //create default empty div
            //}
            var action = action_list[n.id];
            if (typeof action == 'function'){
                action();
            }
            //Ext.getDom('start-div').innerHTML = n.id;
            
            //Ext.getDom('xyz').src = 'http://www.google.com';
            //alert(x);
            //contentEl.hide().update(Ext.getDom(n.id+'-details').innerHTML).slideIn('l', {stopFx:true,duration:.2});
            /*
    		if(!detailEl){
    			var bd = Ext.getCmp('details-panel').body;
    			bd.update('').setStyle('background','#fff');
    			detailEl = bd.createChild(); //create default empty div
    		}
    		detailEl.hide().update(Ext.getDom(n.id+'-details').innerHTML).slideIn('l', {stopFx:true,duration:.2});
            */
    	//}
    });
    
	// 左下角
    // '<!--embed align="middle" src="/flash/clock.swf" width="100%" height="100%" wmode="transparent" allowScriptAccess="always" quality="high" flashvars="v_wd=結婚倒數&v_t=2008/9/28"></embed-->'
	var detailsPanel = {
		id: 'details-panel',
        title: '',
        region: 'center', 
        height: '100%',    
        bodyStyle: 'padding-bottom:15px;background:#eee;',
		autoScroll: false,
		html: '<span style="text-align:center"><img width="100%" src="http://lh3.ggpht.com/sisimi.pchome/SO2hwcnAlII/AAAAAAAAErA/VVRKkWwuXk4/s400/P1060086.JPG" /></span>'
    };
	
	// Finally, build the main layout once all the pieces are ready.  This is also a good
	// example of putting together a full-screen BorderLayout within a Viewport.
    new Ext.Viewport({
		layout: 'border',
		title: 'Ext Layout Browser',
		items: [{
			xtype: 'box',
			region: 'north',
			applyTo: 'header',
			height: 30
		},{
			layout: 'border',
	    	id: 'layout-browser',
	        region:'west',
	        border: false,
	        split:true,
			margins: '2 0 5 5',
	        width: 180,
	        minSize: 100,
	        maxSize: 500,
			items: [treePanel, detailsPanel]
		},
			contentPanel
		],
        renderTo: Ext.getBody()
    });
});
