
bogusTest = function() {

var treePanelSuperAdmin = new Ext.tree.TreePanel({
	id: 'tree-panel_1',
	minSize: 150,
	autoScroll: true,
	border : false,
	// tree-specific configs:
	rootVisible: false,
	lines: false,
	singleExpand: false,
	useArrows: true,
	
	
	loader: new Ext.tree.TreeLoader({
		dataUrl:'tree-data-superAdmin.json'
	}),
	
	root: new Ext.tree.AsyncTreeNode(),
	changeLoader : function(){
		this.fileTree.loader = new Ext.tree.TreeLoader({dataUrl: "test.htm"});
		this.fileTree.root.reload();
	}
});
treePanelSuperAdmin.on('click', function(n){
	var sn = this.selModel.selNode || {}; 
	//Ext.MessageBox.alert(n.iconCls);
	if(n.leaf && n.id != sn.id){
		var tbs = Ext.getCmp('card-tabs-panel');
		var tab = tbs.getItem(n.id);
		if(!tab)
		{
			tbs.add({
			title: n.text,
			id: n.id,
			closable: true,
			//layout:'fit',

			autoLoad: {
				"url": n.attributes.url, "scripts":true, callback:function(el, success) {
					if (!success) {
						Ext.MessageBox.alert('Message', 'Page load failed!  This error has been reported to Site Administrators!');
						Ext.get(n.id).load({
						url: 'test.htm',
						discardUrl: false,
						nocache: true,
						text: 'Loading Error Page...',
						timeout: 30,
						scripts:true
						});
					}
				}}
			}).show();
			tbs.doLayout(); 
			v.doLayout(); 
		}
		tbs.setActiveTab(n.id);
		//tbs.doLayout(); 
		
	}
});

var treePanelAdmin = new Ext.tree.TreePanel({
	id: 'tree-panel_2',
	minSize: 150,
	autoScroll: true,
	border : false,
	// tree-specific configs:
	rootVisible: false,
	lines: false,
	singleExpand: false,
	useArrows: true,
	
	
	loader: new Ext.tree.TreeLoader({
		dataUrl:'tree-data-admin.json'
	}),
	
	root: new Ext.tree.AsyncTreeNode()
});

var treePanelUser = new Ext.tree.TreePanel({
	id: 'tree-panel_3',
	minSize: 150,
	autoScroll: true,
	border : false,
	// tree-specific configs:
	rootVisible: false,
	lines: false,
	singleExpand: false,
	useArrows: true,
	containerScroll: true,

	
	loader: new Ext.tree.TreeLoader({
		dataUrl:'tree-data-user.json'
	}),
	
	root: new Ext.tree.AsyncTreeNode()
});

var treePanelClient = new Ext.tree.TreePanel({
	id: 'tree-panel_3',
	minSize: 150,
	autoScroll: true,
	border : false,
	// tree-specific configs:
	rootVisible: false,
	lines: false,
	singleExpand: false,
	useArrows: true,
	
	
	loader: new Ext.tree.TreeLoader({
		dataUrl:'tree-data-client.json'
	}),
	
	root: new Ext.tree.AsyncTreeNode()
});


var item11 = new Ext.Panel({
    title: 'SuperAdmin',
	items: [treePanelSuperAdmin],
	iconCls: 'silk-acc-sa',
	border: false

});

var item1 = new Ext.Panel({
    title: 'ABC Spa Admin',
	items: [treePanelAdmin],
	iconCls: 'silk-acc-a',
	border: false

});
var item2 = new Ext.Panel({
    title: 'ABC Spa User',
	items: [treePanelUser],
	iconCls: 'silk-acc-u',
	border: false

});
var item3 = new Ext.Panel({
    title: 'Client\'s View',
	items: [treePanelClient],
	iconCls: 'silk-user',
	border: false

});


var accordion = new Ext.Panel({
	region:'west',
	title:"Main Menu",
	margins:'5 0 0 5',
	cmargins: '5 0 0 5',
	id:"treePanel",
	//collapseMode:'mini',
	split:true,
	width: 200,
	minSize: 180,
	collapsible:true,
	layout:'accordion',
	autoScroll: true,
	layoutConfig:{animate:true},
	items: [item11, item1, item2, item3]
});







    //var bd = Ext.getBody();

//   Define the Grid data and create the Grid
    var myData = [
        ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
        ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
        ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'],
        ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
        ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
        ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
        ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
        ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
        ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
        ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am'],
        ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
        ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
        ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
        ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
        ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
        ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
        ['International Business Machines',81.41,0.44,0.54,'9/1 12:00am'],
        ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
        ['JP Morgan & Chase & Co',45.73,0.07,0.15,'9/1 12:00am'],
        ['McDonald\'s Corporation',36.76,0.86,2.40,'9/1 12:00am'],
        ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
        ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
        ['Pfizer Inc',27.96,0.4,1.45,'9/1 12:00am'],
        ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
        ['The Home Depot, Inc.',34.64,0.35,1.02,'9/1 12:00am'],
        ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
        ['United Technologies Corporation',63.26,0.55,0.88,'9/1 12:00am'],
        ['Verizon Communications',35.57,0.39,1.11,'9/1 12:00am'],
        ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'company'},
               {name: 'price', type: 'float'},
               {name: 'change', type: 'float'},
               {name: 'pctChange', type: 'float'},
               {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
          ])
    });
    ds.loadData(myData);

    // example of custom renderer function
    function italic(value){
        return '' + value + '';
    }

    // example of custom renderer function
    function change(val){
        if(val > 0){
            return '' + val + '';
        }else if(val < 0){
            return '' + val + '';
        }
        return val;
    }
    // example of custom renderer function
    function pctChange(val){
        if(val > 0){
            return '' + val + '%';
        }else if(val < 0){
            return '' + val + '%';
        }
        return val;
    }

    // the DefaultColumnModel expects this blob to define columns. It can be extended to provide
    // custom or reusable ColumnModels
    var colModel = new Ext.grid.ColumnModel([
        {id:'company',header: "Company", width: 160, sortable: true, locked:false, dataIndex: 'company'},
        {header: "Price", width: 75, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price',hidden: true},
        {header: "Change", width: 75, sortable: true, renderer: change, dataIndex: 'change',hidden: true},
        {header: "% Change", width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange',hidden: true},
        {header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange',hidden: true}
    ]);

	
	
    //bd.createChild({tag: 'h2', html: 'Using a Grid with a Form'});

/*
 *	Here is where we create the Form
 */
    var gridForm = new Ext.FormPanel({
        id: 'company-form',
        //frame: false,
		//title: 'Company Data',
		// style: 'margin: 5px;',
		layout: 'border',
		border : false,
		items: [{
			//title: 'Center Region',
			region: 'center',     // center region is required, no width/height specified
			//xtype: 'container',
			margins: '5 0 5 6',
			
			
			 iconCls: 'silk-grid',

			layout: 'fit',
			border : false,
            items: {
	            
				xtype: 'grid',
	            ds: ds,
	            cm: colModel,
	            sm: new Ext.grid.RowSelectionModel({
	                singleSelect: true,
	                listeners: {
	                    rowselect: function(sm, row, rec) {
	                        Ext.getCmp("company-form").getForm().loadRecord(rec);
	                    }
	                }
	            }),
	            autoExpandColumn: 'company',
	            //height: 500,
	            //title:'Company Data',
	            border: true,
		        listeners: {
		        	render: function(g) {
		        		g.getSelectionModel().selectRow(0);
		        	},
		        	delay: 10 // Allow rows to be rendered.
		        },
				tbar: [
					'Search: ', ' ',
					new Ext.ux.form.SearchField({
						store: ds,
						width:200
					}), '->',' ',  {	   	
						text:'Edit',
						iconCls:'silk-page-edit'
					},'->',' ',  {
						text:'Add New',
						iconCls:'silk-add'
					}, '->',' ',  {
						text:'Delete',
						iconCls:'silk-delete'
					} 
					
				],
		
				bbar: new Ext.PagingToolbar({
					store: ds,
					pageSize: 20,
					displayInfo: true,
					displayMsg: 'Displaying 1 - 30 of 44',
					emptyMsg: "No topics to display"
				})
        	}
		},{
			// xtype: 'panel' implied by default
			region:'east',
			margins: '5 5 5 0',
			width: 390,
			minSize: 390,
			split: true, 
			cmargins: '5 5 5 0', // adjust top margin when collapsed
			layout: 'fit',
			//style: { "overflow":"hidden"},
			autoScroll:true,
			frame: true,
			title:'Tenant details',
			
			items:[{
				
				xtype: 'fieldset',
				labelWidth: 140,
				//title:'Company details',
				defaults: {width: 180},	// Default config options for child items
				defaultType: 'textfield',
				autoHeight: true,
				bodyStyle: Ext.isIE ? 'padding:5px 0 5px 5px;' : 'padding:10px 5px;',
				border: false,
				/*style: {
					"margin-left": "10px", // when you add custom margin in IE 6...
					"margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0"  // you have to adjust for it somewhere else
				},*/
				items: [{
					fieldLabel: 'Tenant  Name',
					name: 'company'
				}, new Ext.form.ComboBox({
					fieldLabel: 'Type of the Tenant',
					store: [
						['CO', 'company', 'ToolTip'],
						['OR', 'organization', 'ToolTip'],
						['PE', 'person', 'ToolTip']
					], //direct array data
					typeAhead: true,
					triggerAction: 'all',
					emptyText:'Select a Type...',
					selectOnFocus:true
				}),{
					fieldLabel: 'Company Name/Organization Name/Person\'s Name',
					name: 'pctChange'
				}, new Ext.form.TextArea({
					fieldLabel: 'Description',
					wrap:'off'
				}),new Ext.form.ComboBox({
					fieldLabel: 'Country',
					store: Ext.exampledata.states, //direct array data
					typeAhead: true,
					triggerAction: 'all',
					emptyText:'Select a country...',
					selectOnFocus:true
				}),new Ext.form.ComboBox({
					fieldLabel: 'Province/State',
					store: Ext.exampledata.states, //direct array data
					typeAhead: true,
					triggerAction: 'all',
					emptyText:'Select a state...',
					selectOnFocus:true
				}),{
					fieldLabel: 'City',
					name: 'price'
				},{
					fieldLabel: 'Address ',
					name: 'price'
				},{
					fieldLabel: 'Postal Code/ZIP Code',
					name: 'price'
				},{
					fieldLabel: 'Phone #1',
					name: 'price'
				},{
					fieldLabel: 'Web-site',
					name: 'price'
				},{
					fieldLabel: 'Time zone',
					name: 'price'
				},new Ext.form.ComboBox({
					fieldLabel: 'Type of the Tenant',
					store: [
						['AC', 'Active', 'ToolTip'],
						['IA', 'Inactive', 'ToolTip']
					], //direct array data
					typeAhead: true,
					triggerAction: 'all',
					emptyText:'Select a status...',
					selectOnFocus:true
				}),{
					fieldLabel: 'Contact First Name',
					name: 'price'
				},{
					fieldLabel: 'Contact Last  Name',
					name: 'price'
				},{
					fieldLabel: 'Contact e-mail address ',
					name: 'price'
				},{
					fieldLabel: 'Contacts Phone Number',
					name: 'price'
				}],
				buttons: [{
					text: 'Save'
				},{
					text: 'Cancel'
				}]

				   
			}]
			
		}]

        
    });					 
				 
	//gridForm.render('examplegridId');				 



var win = new Ext.Window({
		width:400
		,id:'autoload-win'
		,height:300
		,autoScroll:true
		,autoLoad:{
			url:'autoload-content.php'
		 }
		//,title:Ext.getDom('page-title').innerHTML
		,tbar:[{
			text:'Reload'
			,handler:function() {
				win.load(win.autoLoad.url + '?' + (new Date).getTime());
			}
		}]
		,listeners:{show:function() {
			this.loadMask = new Ext.LoadMask(this.body, {
				msg:'Loading. Please wait...'
			});
		}}
	});


/*var p = new Ext.Panel({
        layout: 'column',
		renderTo: document.body,
		height:42,
        id: 'logoBar',
		tbar: [
            '->',
			{                   // <-- Add the action directly to a toolbar
                text: 'Logout',
				iconCls: 'silk-door-out'
            },'-',
			{                   // <-- Add the action directly to a toolbar
                text: 'Help',
				iconCls: 'silk-help',
				handler:function() {
					win.show();
				}
            }
        ]


    });*/

var cardTabs = {
    xtype: 'tabpanel',
    id: 'card-tabs-panel',
    plain: true,  //remove the header border
    activeItem: 0,
    //autoWidth: true,
	border : false,
    enableTabScroll: true,
    
	
    defaults: {autoScroll: true,resizeTabs: true,layout:'fit'},
    items:[{
            xtype:"panel",
			layout:"fit",
			border : false,
			id:"tenants",
			iconCls: 'silk-grid',
			//bodyStyle: 'padding:5 5 5 5',
            title:"Tenants"
			,items: [gridForm]
    }]
};


var v = new Ext.Viewport(
						 
{
layout:"border",

items:[
    {
    region:"center",
	title:"Tenant Manager",
    layout:"fit",
	margins:'5 5 0 0',
    items:[{
		id: 'content-panel',
		region: 'center',
		layout: 'card',
		activeItem: 0,
		margins: '2 5 5 0',
		items: [cardTabs]
	}]
  },{
    region:"south",
    title:"Status",
    height:20,
    split:true
  },{
		region:"north",
		height:42,
		id: 'logoBar',
		tbar: [
			'->',
			{                   // <-- Add the action directly to a toolbar
				text: 'Logout',
				iconCls: 'silk-door-out'
			},'-',
			{                   // <-- Add the action directly to a toolbar
				text: 'Help',
				iconCls: 'silk-help',
				handler:function() {
					win.show();
				}
			}
		]
	},
  accordion
 
  ]
}
);




};




Ext.onReady(function() {
	Ext.QuickTips.init();
	bogusTest();	
});
