// When you change tabPanels, do something in the east/west panes
	rpmPan.showEmailFormWindow = function(){
		// Create the email form that is populated with the Window popup
		    var emailFormItemsWindow = new Ext.form.FormPanel({
		        baseCls: 'x-plain',
		        labelWidth: 75,
		        name: 'emailFormItemsWindowID',
		        id: 'emailFormItemsWindowID',
		        defaultType: 'textfield',
		        monitorValid:true,

		        items: [{
		            fieldLabel: 'Your Name',
		            name: 'emailFromWindow',
		            id: 'emailFromWindow',
		            anchor:'96%',  // anchor width by percentage
		            allowBlank:false,
		            blankText:'Please enter your full name',
					tooltipText:'Please enter your full name',
					listeners: {
						render: rpmCom.setFormFieldTooltip
					}
		        },
		        {
		            fieldLabel: 'Subject',
		            name: 'emailSubjectWindow',
		            id: 'emailSubjectWindow',
		            anchor: '96%',  // anchor width by percentage
		            allowBlank:false,
		            blankText:'Please enter a brief one-line description of your issue',
		            tooltipText:'Please enter a brief one-line description of your issue',
					listeners: {
						render: rpmCom.setFormFieldTooltip
					}
		        },
		        {
		            xtype: 'textarea',
		            hideLabel: true,
		            name: 'emailMsgWindow',
		            id: 'emailMsgWindow',
		            anchor: '100% -53'  // anchor width by percentage and height by raw adjustment
		        },
		        {
		        	xtype: 'hidden',
		        	name: 'emailNameWindow',
		        	id: 'emailNameWindow',
		        	value: 'Noah Kronemeyer'
		        }],

		        buttons: [{ // automatically put in the footer
		            text: 'Send',
		            type: 'submit',
		            formBind:true, // combined with monitorValid above, the submit button will remain disabled until everything is properly validated. -nk
		            handler: function(){
		            	Ext.getCmp('emailStatus').show();
		            	Ext.getCmp('emailStatus').updateText('Sending...');
		            	Ext.getCmp('emailStatus').wait({
   							interval: 100, // bar will move fast!
   							duration: 2000,
   							increment: 20,
   							scope: this,
   							fn: function(){
      							Ext.getCmp('emailStatus').updateText('Done');
      							Ext.getCmp('thisEmailFormWindow').close();
   							}
						});
		            }
		        },
		        {
		            text: 'Reset',
		            type: 'reset',
		            handler: function(){
						// Clear all the values in the form
							Ext.getCmp('emailFormItemsWindowID').getForm().reset();
						// Set the focus to the FROM field
	    					Ext.getCmp('emailFromWindow').focus();
		            }
		        }]
		    });

    	// Create the email window using the form created above
		    var emailFormWindow = new Ext.Window({
		        title: 'Support: Submit a Help Ticket...',
		        id: 'thisEmailFormWindow',
		        width: 500,
		        height:300,
		        minWidth: 300,
		        minHeight: 200,
		        plain: true,
		        layout: 'fit',
		        shadow:false,
		        collapsible: true,
		        maximizable: true,
		        bodyStyle: 'padding:5px;',
		        buttonAlign: 'center',
		        items: [ emailFormItemsWindow ],

	            // Status bar
				bbar: new Ext.ProgressBar({
			        id: 'emailStatus',
			        cls:'x-plain'
			    })
		    });

		    return emailFormWindow;
	   };

	    rpmPan.userAdminTab = function(mainPanel, api){

	    	// Simple stores
    			var storeState = new Ext.data.SimpleStore({
        			fields: ['abbr', 'state', 'nick'],
        			data: Ext.data.states
    			});
    			var storeTimeZone = new Ext.data.SimpleStore({
        			fields: ['timezone-long', 'timezone-short', 'offset'],
        			data: Ext.data.timezone
    			});
    			var storeLang = new Ext.data.SimpleStore({
        			fields: ['abbr', 'lang'],
        			data: Ext.data.language
    			});
    			var storeCurr = new Ext.data.SimpleStore({
        			fields: ['curr'],
        			data: Ext.data.currency
    			});
    			var storeReport = new Ext.data.SimpleStore({
        			fields: ['report'],
        			data: Ext.data.report
    			});

				// Workspaces dataStore
				var adminUserStore = new Ext.data.Store({
					proxy: new Ext.data.HttpProxy({url: '/repository/libs/php/get-users.php'}),
					reader: new Ext.data.JsonReader({
						root: 'data',
						totalProperty: 'totalCount',
						id: 'user_id'
					},
					[
			           	{name: 'id', mapping: 'user_id'},
			           	{name: 'fname', mapping: 'fname'},
			           	{name: 'lname', mapping: 'lname'},
			           	{name: 'username', mapping: 'username'},
			           	{name: 'email', mapping: 'email'},
			           	{name: 'phone', mapping: 'phone'},
			           	{name: 'address', mapping: 'address'},
			           	{name: 'city', mapping: 'city'},
			           	{name: 'state', mapping: 'state'},
			           	{name: 'zip', mapping: 'zip'},
			           	{name: 'timezone', mapping: 'timezone'}
					])
				});
				// Preload the workspace combobox list
				adminUserStore.load({params:{query:'', start:0, limit:999, sort:'user_id', dir:'ASC'}});

			    // Custom rendering Template
			    var adminUserTpl = new Ext.XTemplate(
			        '<tpl for="."><div class="search-item">',
			            '<h3>{fname} {lname}</h3>',
			            'Email: {email}<br />',
			            'Phone: {phone}<br />',
			            'Location: {city}, {state}',
			        '</div></tpl>'
			    );

	    		// Create the various combo box
				var states = new Ext.form.ComboBox({
        			tpl: '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>',
        			store: storeState,
        			name:'state',
        			displayField:'abbr',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			emptyText:'Select a state...',
        			selectOnFocus:true,
        			fieldLabel: 'State'
    			});
				var timezone = new Ext.form.ComboBox({
        			tpl: '<tpl for="."><div class="x-combo-list-item">{timezone-long} ({timezone-short}, {offset} GMT)</div></tpl>',
        			store: storeTimeZone,
        			name:'timezone',
        			displayField:'timezone-long',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			emptyText:'Select a time zone...',
        			selectOnFocus:true,
        			fieldLabel: 'Time Zone'
    			});
				var language = new Ext.form.ComboBox({
        			tpl: '<tpl for="."><div class="x-combo-list-item">{lang}</div></tpl>',
        			store: storeLang,
        			name:'language',
        			displayField:'abbr',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			emptyText:'Select a language...',
        			selectOnFocus:true,
        			fieldLabel: 'Language'
    			});
				var currency = new Ext.form.ComboBox({
        			tpl: '<tpl for="."><div class="x-combo-list-item">{curr}</div></tpl>',
        			store: storeCurr,
        			name:'currency',
        			displayField:'curr',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			emptyText:'Select a currency...',
        			selectOnFocus:true,
        			fieldLabel: 'Default Currency'
    			});
				var report = new Ext.form.ComboBox({
        			tpl: '<tpl for="."><div class="x-combo-list-item">{report}</div></tpl>',
        			store: storeReport,
        			name:'report',
        			displayField:'report',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			emptyText:'Select a report method...',
        			selectOnFocus:true,
        			fieldLabel: 'Report Preference'
    			});

    			var emailReports = new Ext.form.Checkbox({
    				fieldLabel:'Email Reports',
    				name:'email_reports'
    			});
    			var includeGraphs = new Ext.form.Checkbox({
    				fieldLabel:'Include Graphs',
    				name:'include_graphs'
    			});

			// Create the email form that is populated with the Panel display
				var userAdminForm = new Ext.form.FormPanel({
			        baseCls: 'x-plain',
			        labelWidth: 130,
			        url:'/repository/libs/php/get-users.php',
			        id: 'userAdminItems',
			        defaultType: 'textfield',
			        monitorValid:true,

			        reader: new Ext.data.JsonReader({
			            root: 'data', // the root of the json array
			            totalProperty: 'totalCount',
			            id: 'id',
			           fields: [
			           	{name: 'id', mapping: 'user_id'},
			           	{name: 'fname', mapping: 'fname'},
			           	{name: 'lname', mapping: 'lname'},
			           	{name: 'username', mapping: 'username'},
			           	{name: 'email', mapping: 'email'},
			           	{name: 'phone', mapping: 'phone'},
			           	{name: 'address', mapping: 'address'},
			           	{name: 'city', mapping: 'city'},
			           	{name: 'state', mapping: 'state'},
			           	{name: 'zip', mapping: 'zip'},
			           	{name: 'timezone', mapping: 'timezone'},
			           	{name: 'language', mapping: 'language'},
			           	{name: 'currency', mapping: 'currency'},
			           	{name: 'report', mapping: 'report'},
			           	{name: 'email_reports', mapping: 'email_reports'},
			           	{name: 'include_graphs', mapping: 'include_graphs'}
			           ]
			        }),

			        items: [
					new Ext.form.UsersComboBox({
	           			store: adminUserStore,
	           			tpl: adminUserTpl,
	           			itemSelector: 'div.search-item',
	           			fieldLabel: 'Users',
	           			anchor: '96%'
	        		}),
			        {
			            fieldLabel: 'Last Name',
			            id: 'userAdminLastName',
			            name: 'lname',
		            	blankText:'Please enter a last name',
			            anchor:'96%',
			            allowBlank:false
			        },
			        {
			            fieldLabel: 'First Name',
			            name:'fname',
		            	blankText:'Please enter a first name',
			            anchor:'96%',
			            allowBlank:false
			        },
			        {
			            fieldLabel: 'Email',
			            name:'email',
			            vtype:'email',
		            	blankText:'Please enter an email address',
			            anchor:'96%'
			        },
			        {
			            fieldLabel: 'Phone Number',
			            name:'phone',
		            	blankText:'Please enter a phone number',
			            anchor:'96%'
			        },
			        {
			            fieldLabel: 'Address',
			            name:'address',
		            	blankText:'Please enter an address',
			            anchor:'96%'
			        },
			        states,
			        {
			            fieldLabel: 'Zip',
			            name:'zip',
		            	blankText:'Please enter a zip code',
			            anchor:'50%'
			        },
			        timezone,
			        language,
			        currency,
			        report,
			        emailReports,
			        includeGraphs,
			        {
			        	xtype: 'hidden',
			        	name: 'emailNamePanel',
			        	id: 'emailNamePanel',
			        	value: 'Noah Kronemeyer'
			        }],
			        buttons: [
			        {
			            text: 'Save',
			            type: 'submit',
			            formBind:true, // combined with monitorValid above, the submit button will remain disabled until everything is properly validated. -nk
        				handler: function(){
            				Ext.getCmp('userAdminItems').getForm().submit({
            					url:'/repository/libs/php/save-users.php',
            					waitMsg:'Saving User Data...',
	    						failure: Ext.user.saveUserFail,
	    						success: Ext.user.saveUserSuccess
            				});
        				}
			        },{
			            text: 'Reset',
			            type: 'reset',
			            handler: function(){
							// Clear all the values in the form
							Ext.getCmp('userAdminItems').getForm().reset();
							// Set the focus to the FROM field
		    				Ext.getCmp('userAdminLastName').focus();
			            }
			        }]
			    });

			// Create the panel which will contain the grid (so we can resize, etc)
				var userAdminPanel = new Ext.ux.AdminPanel({
			        title: 'Admin > User Admin',
			        id:'userAdminPanel',

			        // Add the form elements
			        items: [ userAdminForm ],
			        // Top bar
					tbar: [
          				{
          					// ADD USER
          					icon: appOptions.urlDocDir + '/resources/icons/user_add.png',
          					cls: 'x-btn-icon',
          					tooltip: '<b>Add New User</b><br />Add a new user to the system.',
          					handler: function(){
          						Ext.user.newUser('userAdminItems', 'userAdminLastName'); // second variable is the name of the formField we set focus to when creating a new user
          					}
          				},
          				{
          					// DELETE USER
          					icon: appOptions.urlDocDir + '/resources/icons/user_delete.png',
          					cls: 'x-btn-icon',
          					tooltip: '<b>Delete User</b><br />Delete current user\'s information from the system.',
          					handler: function(){
          						Ext.user.deleteUser('userAdminItems', 'userAdminLastName');
          					}
          				},
          				'-',
          				{
          					// SAVE
          					icon: appOptions.urlDocDir + '/resources/icons/save.gif',
          					cls: 'x-btn-icon',
          					tooltip: '<b>Save User</b><br />Save current user\'s information.'
          					//handler: Ext.user.saveUser
          				},
          				{
          					// SAVE AS
          					icon: appOptions.urlDocDir + '/resources/icons/save_as.gif',
          					cls: 'x-btn-icon',
          					tooltip: '<b>Save As...</b><br />Copy current user\'s information<br />to a new user.'
          					//handler: Ext.user.saveAsUser
          				},
          				'-',
          				{
          					// MANAGE ALL WORKSPACES
          					icon: appOptions.urlDocDir + '/resources/icons/application_form.png',
          					cls: 'x-btn-icon',
          					tooltip: '<b>Manage All Users</b><br />Search, Edit, Copy, & Delete all users.',
          					handler: function(){
          						Ext.user.manageAllUsers('userAdminItems', mainPanel); // creates a grid in a window that lists all users
          					}
          				}
		           	]
				});

		    // Now that we've created the Panel properly, load the component
		    	rpmCom.loadComp(userAdminPanel, 'User Administration', mainPanel);
		    // Set focus to the last name field
    			Ext.getCmp('userAdminLastName').focus('', 100);
    		    if(Ext.isIE){
    			    // Resize north panels in various calendars
    			    if(Ext.getCmp('fullShowPanel')){
    			    	Ext.getCmp('fullShowPanel').setHeight(120);
    			    }
    			    
    			    if(Ext.getCmp('gridViewPanel')){
    			    	Ext.getCmp('gridViewPanel').setHeight(120);
    			    }
    			    
    			    if(Ext.getCmp('meetingCalendarViewPanel')){
    			    	Ext.getCmp('meetingCalendarViewPanel').setHeight(90);
    			    }
    			    
    			    if(Ext.getCmp('gridViewPanelDemo')){
    			    	Ext.getCmp('gridViewPanelDemo').setHeight(40);
    			    }
    			    
    			    if(Ext.getCmp('resourceAvailViewPanel')){
    			    	Ext.getCmp('resourceAvailViewPanel').setHeight(70);
    			    }
    			    
    			    if(Ext.getCmp('myViewFormPanel')){
    			    	Ext.getCmp('myViewFormPanel').setHeight(50);
    			    }
    		    }
	    };

    // Create the localization window, where we will choose our language
    	rpmPan.createLocaleWindow = function()
    	{
    		// As defined on index.html
	    		var localeWindow = new Locale.LocalizationWin();
    			localeWindow.show();
    	};

	// Create a custom admin panel class by extending Panel
		Ext.ux.AdminPanel = Ext.extend(Ext.Panel, {
			width:'50%',
	        //autoHeight:true,
	        x: 10,
	        y: 10,
	        cls:'admin-toolbar', // fixes the tbar alignment
	        floating:false, // if floating is true, other comp rendered will be BEHIND this object, and thus hiddens
	        frame:true,
	        shadow:false,
			buttonAlign: 'center',
			bodyStyle: 'padding:5px',

			initEvents : function(){
    			// Call the parent
        		Ext.ux.AdminPanel.superclass.initEvents.call(this);
        		var formId = this.el.id;
        	}
		}); // end Ext.ux.adminPanel