Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'title';

// enable tooltips and define set_tt to handle them

Ext.QuickTips.init();
Ext.QuickTips.enable();

function set_tt() {
	this.el.dom.qtip = this.tooltip.text;
	this.el.dom.qtitle = this.tooltip.title;
}

// fix to get and set radiogroup and checkboxgroup values
Ext.override(Ext.form.CheckboxGroup, {
  getNames: function() {
    var n = [];
    this.items.each(function(item) { if (item.getValue()) { n.push(item.getName()); } });
    return n;
  },
  getValues: function() {
    var v = [];
    this.items.each(function(item) { if (item.getValue()) { v.push(item.getRawValue()); } });
    return v;
  },
  setValue: function(v) {
	if( v.length==0 ) return;
    if(typeof(v)=="string") {
     var temp = '(' + v.replace(/,/g,"|") + ')';
     var r = new RegExp(temp);
    }
    else { var r = new RegExp('(' + v.join('|') + ')'); }
    this.items.each(function(item) { item.setValue(r.test(item.getRawValue())); });
  }
});

/*
Ext.override(Ext.form.RadioGroup, {
  getName: function() {
    return this.items.first().getName();
  },
  getValue: function() {
    var v;
    this.items.each(function(item) { v = item.getRawValue(); return !item.getValue(); });
    return v;
  },
  setValue: function(v) {
    this.items.each(function(item) { item.setValue(item.getRawValue() == v); });
  }
});
*/

// fix so radiogroups throw a change event
/*
Ext.override(Ext.form.RadioGroup, {
    afterRender: function() {
        var group = this;
        this.items.each(function(field) {
            // Listen for 'check' event on each child item
            field.on("check", function(self, checked) {
              // if checkbox is checked, then fire 'change' event on RadioGroup container
              if(checked)
                // Note, oldValue (third parameter in 'change' event listener) is not passed, 
                // because is not easy to get it
                group.fireEvent('change', group, self.getRawValue());
            });
        });
        Ext.form.RadioGroup.superclass.afterRender.call(this)
    }
});
*/

// create namespace
Ext.namespace('wmiscreening');

// create application
wmiscreening.app = function() {
    // do NOT access DOM from here; elements don't exist yet
    // private variables	
	
	var statesds = new Ext.data.JsonStore({
		url: '/components/wmi_screening_json.cfc',
		baseParams: { method: 'getStates' },
		root: 'data', totalProperty: 'recordcount', autoLoad: true,
		fields: [{ name: 'state', mapping: 'STATE' },{ name: 'stateabv', mapping: 'STATEABV' }]
	});
	
	supervisorsds = new Ext.data.JsonStore({		
		url: '/components/wmi_screening_json.cfc',
		baseParams: { method: 'getSupervisors' },
		root: 'data', totalProperty: 'recordcount', autoLoad: true,
		fields: [{ name: 'fullname', mapping: 'FULLNAME' }]
	});

	countriesds = new Ext.data.SimpleStore({
		fields: ['country','countryabv'],
		data: [['United States','US'], ['Canada','CN']]
	});
				
	classesds = new Ext.data.SimpleStore({
		fields: ['value','title'],
		data: [
			   ['SKDB','Wilton Decorating Basics'],
			   ['SKFCD','Wilton Flowers & Cake Design'],
			   ['SKGPF','Wilton Gum Paste &  Fondant'],
			   ['PJTC','Wilton Tall Cakes Project'],
			   ['SKI','Wilton Course 1 (Prior to 6/1/2010)'], 
			   ['SKII','Wilton Course 2 (Prior to 6/1/2010)'],
			   ['SKIII','Wilton Course 3 (Prior to 6/1/2010)'],
			   ['SKFGP','Wilton Fondant & Gum Paste Class (Prior to 6/1/2010)'],
			   ['WSM','Wilton Master\'s Class (Darien, IL)'],
			   ['WS','Other Class at Wilton School'],
			   ['NW','Non-Wilton Class']]
	});

	whends = new Ext.data.SimpleStore({
		fields: ['value','title'],
		data: [['within past 12 months','within past 12 months'], 
			   ['1-3 years ago','1-3 years ago'],
			   ['3-6 years ago','3-6 years ago'],
			   ['6-10 years ago','6-10 years ago'],
			   ['10 years ago or longer','10 years ago or longer']
			   ]
	});
	
	loadapplicant = function() {
		Ext.getBody().mask('Loading your information...', 'x-mask-loading');

		Ext.Ajax.request({
			url: '/components/wmi_screening_json.cfc?method=getWMIapplicant&id='+this.applicantid,
			success: function(response, options) {
				var tp = Ext.getCmp('tabpanel');
				tp.activate('tab-2');
				tp.activate('tab-3');
				tp.activate('tab-4');
				tp.activate('tab-5');
				tp.activate('tab-6');
				tp.activate('tab-7');
				tp.activate('tab-1');
				
				var f1 = Ext.getCmp('form1').getForm();
				var f2 = Ext.getCmp('form2').getForm();
				var f3 = Ext.getCmp('form3').getForm();
				var f4 = Ext.getCmp('form4').getForm();
				var f5 = Ext.getCmp('form5').getForm();
				var f6 = Ext.getCmp('form6').getForm();
				var f7 = Ext.getCmp('form7').getForm();

				var rec1 = f1.reader.read(response).records[0];
				var rec2 = f2.reader.read(response).records[0];
				var rec3 = f3.reader.read(response).records[0];
				var rec4 = f4.reader.read(response).records[0];
				var rec5 = f5.reader.read(response).records[0];
				var rec6 = f6.reader.read(response).records[0];
				var rec7 = f7.reader.read(response).records[0];
				
				f1.loadRecord(rec1);
				f2.loadRecord(rec2);
				f3.loadRecord(rec3);
				f4.loadRecord(rec4);
				f5.loadRecord(rec5);
				f6.loadRecord(rec6);
				f7.loadRecord(rec7);
				Ext.getBody().unmask();
			},
			failure: function(response, options) { Ext.getBody().unmask(); alert('error connecting to server'); },
			scope: this
		});		
	}
	
	showTab = function(tabid) { Ext.getCmp('tabpanel').activate(tabid); }
	
	setTabStates = function(tabindex,state) {
		var tp = Ext.getCmp('tabpanel');
		for( var i=tabindex; i<=7; i++) {
			if( state == 'enable') tp.getItem('tab-'+i).enable();
			else tp.getItem('tab-'+i).disable();
		}
	}
	
	submitform = function() {
		Ext.getCmp('tabpanel').getEl().mask('Saving your information...', 'x-mask-loading');
		var vals1 = Ext.getCmp('form1').getForm().getValues();
		var vals2 = Ext.getCmp('form2').getForm().getValues();
		var vals3 = Ext.getCmp('form3').getForm().getValues();
		var vals4 = Ext.getCmp('form4').getForm().getValues();
		var vals5 = Ext.getCmp('form5').getForm().getValues();
		var vals6 = Ext.getCmp('form6').getForm().getValues();
		var vals7 = Ext.getCmp('form7').getForm().getValues();
		
		var params = {};
		if( this.applicantid == '') { params = { method: 'createWMIApplicant'};	}
		else { params = { method: 'updateWMIApplicant', id: this.applicantid };	}
		
		params = Ext.apply(params, vals1);
		params = Ext.apply(params, vals2);
		params = Ext.apply(params, vals3);
		params = Ext.apply(params, vals4);
		params = Ext.apply(params, vals5);
		params = Ext.apply(params, vals6);
		params = Ext.apply(params, vals7);
	
		Ext.Ajax.request({
			url: '/components/wmi_screening_json.cfc',
			params: params,
			success: function(response, options) {
				try {
					var responseObj = Ext.util.JSON.decode(response.responseText);
					var refnumber = responseObj.data.refnumber;
					if (refnumber == '') {
						Ext.getCmp('tabpanel').getEl().unmask();
						alert('An error occurred saving your information. The event has been logged and the administrator has been notifed. We apologize for the inconvenience.'); 					
					}
					else {
						var method = this.applicantid == '' ? 'new' : 'update';
						Ext.getCmp('tabpanel').getEl().unmask();
						this.showSuccess({ refnumber: refnumber, method: method });
						_hbLink('Instructor Screening Form Complete','/classes/instructors/screening/');
						//WSS_JavaScriptView('Instructor Screening Form Complete','/classes/instructors/screening/');
					}
				}
				catch(err) {
					Ext.getCmp('tabpanel').getEl().unmask();
					alert('Error parsing response.'); 
				}
			},
			failure: function(response, options){
				Ext.getCmp('tabpanel').getEl().unmask();
				alert('Error connecting to server');
			},
			scope: this
		});
	}
	
	showSuccess = function(opts){
		var tpl = null;
		
		if( opts.method == 'new') {
			tpl = new Ext.XTemplate(
				'<div class="summary">',
				'<h1>Thank You</h1>',
				'<p>Thank you for your interest in becoming a Wilton Method Instructor.</p>',
				'<p>Your Screening Form has been submitted. Your Screening Form Reference Number is {refnumber}.</p>',
				'<p>Please make note of this number and/or <a href="javascript:print();">print this page</a> for future reference.</p>',
				'<p>You will receive a confirmation notice from us within 7-10 business days.  This response will come from a member of ', 
				'our recruiting team either by email or by letter.  If you do not receive this notice, or if you have any questions or ',
				'comments, you may contact us at <a href="mailto:recruiting@wilton.com">recruiting@wilton.com</a> or call ',
				'1-800-772-7111 ext 2812. Be sure to include your Screening Form Number when contacting us.</p>',
				'</div>'
				);			
		}
		else {
			tpl = new Ext.XTemplate(
				'<div class="summary">',
				'<h1>Thank You</h1>',
				'<p>Thank you for updating your information.</p>',
				'<p>Your Screening Form updates have been submitted. Your Screening Form Reference Number is {refnumber}.</p>',
				'<p>Please make note of this number and/or <a href="javascript:print();">print this page</a> for future reference.</p>',
				'<p>If you have any questions or ',
				'comments, you may contact us at <a href="mailto:recruiting@wilton.com">recruiting@wilton.com</a> or call ',
				'1-800-772-7111 ext 2812. Be sure to include your Screening Form Number when contacting us.</p>',
				'</div>'
				);						
		}
		tpl.compile();
		var tp = Ext.get('tabpanel');
		tp.setVisibilityMode(Ext.Element.DISPLAY);
		tp.hide(true);
		Ext.get('requiredfields').remove();
		tpl.append(Ext.get('contentpanel'), opts);
	}
	
	var sc1 = new Ext.FormPanel({
		id: 'form1', labelAlign: 'top', buttonAlign: 'center', monitorValid: true, autoHeight: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'titlename', mapping: 'TITLENAME' },
				{ name: 'firstname', mapping: 'FIRSTNAME' },
				{ name: 'middlename', mapping: 'MIDDLENAME' },
				{ name: 'lastname', mapping: 'LASTNAME' },
				{ name: 'suffixname', mapping: 'SUFFIXNAME' },
				{ name: 'homephone', mapping: 'HOMEPHONE' },
				{ name: 'timetocall', mapping: 'TIMETOCALL' },
				{ name: 'cellphone', mapping: 'CELLPHONE' },
				{ name: 'workphone', mapping: 'WORKPHONE' },
				{ name: 'email', mapping: 'EMAIL' },
				{ name: 'emailread', mapping: 'EMAILREAD' },
				{ name: 'address', mapping: 'ADDRESS' },
				{ name: 'address2', mapping: 'ADDRESS2' },
				{ name: 'city', mapping: 'CITY' },
				{ name: 'state', mapping: 'STATE' },
				{ name: 'zipcode', mapping: 'ZIPCODE' },
				{ name: 'country', mapping: 'COUNTRY' },
				{ name: 'shipaddress', mapping: 'SHIPADDRESS' },
				{ name: 'shipaddress2', mapping: 'SHIPADDRESS2' },
				{ name: 'shipcity', mapping: 'SHIPCITY' },
				{ name: 'shipstate', mapping: 'SHIPSTATE' },
				{ name: 'shipzipcode', mapping: 'SHIPZIPCODE' },
				{ name: 'shipcountry', mapping: 'SHIPCOUNTRY' }
			]
		),
		items: [
			{
                xtype: 'fieldset', title: 'Contact Information', layout: 'form', autoHeight: true,     
				items: [	
					{
						layout: 'table', autoHeight: true, defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'Title', name: 'titlename', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 4, maxlength: '10' }
								}
						  },
						  { items: {
									fieldLabel: 'First Name', name: 'firstname', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', maxlength: '25' }
								}
						  },
						  { items: {
									fieldLabel: 'Middle Name/Initial', name: 'middlename', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', maxlength: '25' }
								}
						  },
						  { items: {
									fieldLabel: 'Last Name', name: 'lastname', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', maxlength: '25' }
								}
						  },
						  { items: {
									fieldLabel: 'Suffix', name: 'suffixname', allowBlank: true, 
									autoCreate: { tag: 'input', type: 'text', size: 4, maxlength: '10' }
								}
						  }
						]
					},
					{
						layout: 'table', 
						defaults: { xtype: 'panel', style: 'padding-right: 40px;' },
						layoutConfig: { columns: 2 },
						items: [
						  { xtype: 'label', text: 'Home phone:', cls: 'x-form-item required table-label' },
						  { xtype: 'label', text: 'Best time to call:', cls: 'x-form-item required table-label'},
						  { fieldLabel: 'Home phone', name: 'homephone', itemCls: 'required', allowBlank: false, 
						    xtype: 'uxphonefield' },
						  {
								fieldLabel: 'Best time to call',
								name: 'timetocall', xtype: 'combo',
								store: store = new Ext.data.SimpleStore({
									fields: ['title'],
									data: [['Morning (8-12pm)'], ['Afternoon (1-5pm)'], ['Evening (6-8pm)']]
								}),
								valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
								typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all',
								itemCls: 'required', allowBlank: false
						  }
						]
					},
					{
						layout: 'table', 
						style: 'margin-top: 8px;',
						defaults: { xtype: 'panel', style: 'padding-right: 40px; margin-bottom: 8px;' },
						layoutConfig: { columns: 2 },
						items: [
						  { xtype: 'label', text: 'Cell phone:', cls: 'x-form-item table-label' },
						  { xtype: 'label', text: 'Work phone (if ok to call):', cls: 'x-form-item table-label'},
						  { fieldLabel: 'Cell phone', name: 'cellphone', allowBlank: true, xtype: 'uxphonefield' },
						  { fieldLabel: 'Work phone (if ok to call)', name: 'workphone', showExtension: true, allowBlank: true,
									xtype: 'uxphonefield', width: 220
						  }
						]
					},
					{
						layout: 'table', defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'Email Address', name: 'email', vtype: 'email', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 45, maxlength: '60' }
								}
						  },
						  { items: {
									fieldLabel: 'How often do you read your email?',
									name: 'emailread', xtype: 'combo', labelSeparator: '', itemCls: 'required',
									store: store = new Ext.data.SimpleStore({
										fields: ['title'],
										data: [['Daily'], ['Twice a week'], ['Weekly'], ['Monthly']]
									}),
									valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
									typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all',
									allowBlank: false
								}
						  }
						]
					}
				] // end contact info fieldset items
			},
			{
                xtype: 'fieldset', title: 'Mailing Address', layout: 'form', autoHeight: true,
				items: [				
					{
						layout: 'table', defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'Street address', name: 'address', xtype: 'textfield', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '50' }
								}
						  },
						  { items: {
									fieldLabel: 'Street address (cont.)', name: 'address2', xtype: 'textfield', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '50' }
								}
						  }
						]
					},
					{
						layout: 'table', defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'City', name: 'city', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
								}
						  },
						  { items: { 
									fieldLabel: 'State/Province', hiddenName: 'state', xtype: 'combo', itemCls: 'required', allowBlank: false,
									store: statesds, displayField: 'state', valueField: 'stateabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: true,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									fieldLabel: 'Zip/Postal Code', name: 'zipcode', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 14, maxlength: '7' }
								}
						  },
						  { items: { 
									fieldLabel: 'Country', hiddenName: 'country', xtype: 'combo', itemCls: 'required', allowBlank: false,
									store: countriesds, displayField: 'country', valueField: 'countryabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  }
						]
					}			
				] // end mailing address fieldset items
			},
			{
                xtype: 'fieldset', title: 'Shipping Address',  layout: 'form', autoHeight: true,
				items: [	
					{ name: 'sameasmailing', hideLabel: true, xtype: 'checkbox', ctCls: 'checkboxgroup',
					  boxLabel: 'Same as Mailing Address (a physical address is required for shipping materials should you be placed)',
					  handler: function(checkbox, checked) {
					  		var f = Ext.getCmp('form1').getForm();
							f.findField('shipaddress').setValue(f.findField('address').getValue());
							f.findField('shipaddress2').setValue(f.findField('address2').getValue());
							f.findField('shipcity').setValue(f.findField('city').getValue());
							f.findField('shipstate').setValue(f.findField('state').getValue());
							f.findField('shipzipcode').setValue(f.findField('zipcode').getValue());
							f.findField('shipcountry').setValue(f.findField('country').getValue());
					  }
					},
					{
						layout: 'table', defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'Street address', name: 'shipaddress', xtype: 'textfield', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '50' }
								}
						  },
						  { items: {
									fieldLabel: 'Street address (cont.)', name: 'shipaddress2', xtype: 'textfield', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '50' }
								}
						  }
						]
					},
					{
						layout: 'table', defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'City', name: 'shipcity', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
								}
						  },
						  { items: { 
									fieldLabel: 'State/Province', hiddenName: 'shipstate', xtype: 'combo', itemCls: 'required', allowBlank: false,
									store: statesds, displayField: 'state', valueField: 'stateabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: true,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									fieldLabel: 'Zip/Postal Code', name: 'shipzipcode', itemCls: 'required', allowBlank: false,
									autoCreate: { tag: 'input', type: 'text', size: 14, maxlength: 7 }
								}
						  },
						  { items: { 
									fieldLabel: 'Country', hiddenName: 'shipcountry', xtype: 'combo', itemCls: 'required', allowBlank: false,
									store: countriesds, displayField: 'country', valueField: 'countryabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  }
						]
					}			
				] // end shipping address fieldset items
			}	
		],
		buttons: [
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-2'); }, scope: this }
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-1');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-1').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-2').enable(); 
						else this.setTabStates(2,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 1

	var sc2 = new Ext.FormPanel({
		id: 'form2', labelAlign: 'left', labelWidth: 450, buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'havecontactedwmi', mapping: 'HAVECONTACTEDWMI' },
				{ name: 'supervisorrequested', mapping: 'SUPERVISORREQUESTED' },
				{ name: 'supervisorname', mapping: 'SUPERVISORNAME' },
				{ name: 'isstoreowner', mapping: 'ISSTOREOWNER' },
				{ name: 'wantofferclasses', mapping: 'WANTOFFERCLASSES' },
				{ name: 'storename', mapping: 'STORENAME' },
				{ name: 'buyingdirect', mapping: 'BUYINGDIRECT' },
				{ name: 'beenwmi', mapping: 'BEENWMI' },
				{ name: 'whenwmi', mapping: 'WHENWMI' },
				{ name: 'wiltonid', mapping: 'WILTONID' },
				{ name: 'familiarwm', mapping: 'FAMILIARWM' },
				{ name: 'howlearnedwm', mapping: 'HOWLEARNEDWM' },
				{ name: 'yearsdecorating', mapping: 'YEARSDECORATING' },
				{ name: 'forwhomdecorating', mapping: 'FORWHOMDECORATING' },
				{ name: 'profdecoratingname1', mapping: 'PROFDECORATINGNAME1' },
				{ name: 'profdecoratinglocation1', mapping: 'PROFDECORATINGLOCATION1' },
				{ name: 'profdecoratingstate1', mapping: 'PROFDECORATINGSTATE1' },
				{ name: 'profdecoratingname2', mapping: 'PROFDECORATINGNAME2' },
				{ name: 'profdecoratinglocation2', mapping: 'PROFDECORATINGLOCATION2' },
				{ name: 'profdecoratingstate2', mapping: 'PROFDECORATINGSTATE2' }
			]
		),
		items: [
			{
                xtype: 'fieldset', title: 'Background Information', layout: 'form', autoHeight: true,
				items: [	
					{
			             fieldLabel: 'Have you ever contacted Wilton about becoming a WMI?',
						 xtype: 'radiogroup', name: 'havecontactedwmi', id: 'havecontactedwmi', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'havecontactedwmi', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'havecontactedwmi', inputValue: 'n' }
			             ]
			        },
					{
			             fieldLabel: 'Did a Wilton Supervisor ask you to fill out this form?',
						 xtype: 'radiogroup', name: 'supervisorrequested', id: 'supervisorrequested', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'supervisorrequested', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'supervisorrequested', inputValue: 'n' }
			             ],
						 listeners: {
						 	change: {
								fn: function(radiogrp, radio) {
									var f = radiogrp.findParentByType(Ext.form.FormPanel).getForm();
									var cmp = Ext.getCmp('supervisorpanel');
									if( radio.inputValue == 'y') {
										cmp.show();
										f.findField('supervisorname').allowBlank = false;
										cmp.getEl().repaint();
									}
									else {
										cmp.hide();
										f.findField('supervisorname').allowBlank = true;
									}
								}
							}
						 }
			        },
					{
						layout: 'table',
						id: 'supervisorpanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield' },
						items: [
						  { items: { 
								fieldLabel: 'What was the Supervisor\'s Name?', name: 'supervisorname',
								xtype: 'combo', itemCls: 'required', 
								labelStyle: 'width:auto;padding-left:20px;',
								labelSeparator: '', allowBlank: true, 
								store: supervisorsds, displayField: 'fullname', width: 200,
								mode: 'local', typeAhead: true, editable: false, forceSelection: true, triggerAction: 'all'
							}
						  }
						]
					},			
					{
			             fieldLabel: 'Are you a store owner?',
						 xtype: 'radiogroup', name: 'isstoreowner', id: 'isstoreowner', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'isstoreowner', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'isstoreowner', inputValue: 'n' }
			             ],
						 listeners: {
						 	change: {
								fn: function(radiogrp, radio) {
									var f = radiogrp.findParentByType(Ext.form.FormPanel).getForm();
									var cmp = Ext.getCmp('storeownerpanel');
									if( radio.inputValue == 'y') {
										cmp.show();
										cmp.getEl().repaint();
										f.findField('wantofferclasses').allowBlank = false;
										f.findField('storename').allowBlank = false;
										f.findField('buyingdirect').allowBlank = false;
									}
									else {
										cmp.hide();
										f.findField('wantofferclasses').allowBlank = true;
										f.findField('storename').allowBlank = true;
										f.findField('buyingdirect').allowBlank = true;
									}
								}
							}
						 }
			        },
					{
						layout: 'table', id: 'storeownerpanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield' },
						items: [
						  { items: [
								{
						             fieldLabel: 'Do you want to offer classes in your store?',
									 xtype: 'radiogroup', name: 'wantofferclasses', id: 'wantofferclasses', 
									 itemCls: 'required radiogroup',
									 labelStyle: 'margin-left: 20px;width: auto;',
									 allowBlank: true, labelSeparator: '', columns: [ 60, 60],
						             items: [
						                 {boxLabel: 'Yes', name: 'wantofferclasses', inputValue: 'y' },
						                 {boxLabel: 'No', name:  'wantofferclasses', inputValue: 'n' }
						             ]
						        },
								{ 
									fieldLabel: 'What is the name of your store?', name: 'storename', 
									xtype: 'textfield', itemCls: 'required', 
									labelStyle: 'margin-left: 20px;width: auto;',
									labelSeparator: '', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '50' }
								},		
								{
						             fieldLabel: 'Are you currently buying products directly from Wilton?',
									 xtype: 'radiogroup', name: 'buyingdirect', id: 'buyingdirect', itemCls: 'required radiogroup',
									 labelStyle: 'margin-left: 20px;width: auto;',
									 allowBlank: true, labelSeparator: '', columns: [ 60, 60],
						             items: [
						                 {boxLabel: 'Yes', name: 'buyingdirect', inputValue: 'y' },
						                 {boxLabel: 'No', name:  'buyingdirect', inputValue: 'n' }
						             ]
						        }
						    ]
						  }
						]
					},					
					{
			             fieldLabel: 'Have you ever been a WMI?',
						 xtype: 'radiogroup', name: 'beenwmi', id: 'beenwmi', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'beenwmi', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'beenwmi', inputValue: 'n' }
			             ],
						 listeners: {
						 	change: {
								fn: function(radiogrp, radio) {
									var f = radiogrp.findParentByType(Ext.form.FormPanel).getForm();
									var cmp = Ext.getCmp('waswmipanel');
									if( radio.inputValue == 'y') {
										cmp.show();
										cmp.getEl().repaint();
										f.findField('whenwmi').allowBlank = false;
										f.findField('wiltonid').allowBlank = false;
									}
									else {
										cmp.hide();
										f.findField('whenwmi').allowBlank = true;
										f.findField('wiltonid').allowBlank = true;
									}
								}
							}
						 }
			        },
					{
						layout: 'table',
						id: 'waswmipanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield' },
						items: [
						  { items: [
							{
								fieldLabel: 'If yes, when were you a WMI?',
								name: 'whenwmi', xtype: 'combo', labelSeparator: '', itemCls: 'required', 
								labelStyle: 'padding-left: 20px;width: auto;',
								allowBlank: true, width: 150,
								store: store = new Ext.data.SimpleStore({
									fields: ['title'],
									data: [['Currently a WMI'],['1-3 years ago'],['4-6 years ago'],['7-10 years ago'],['More than 10 years ago']]
								}),
								valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
								typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
							},
							{ 
								fieldLabel: 'What was your instructor number? (8 digit numeric portion only)', name: 'wiltonid', 
								xtype: 'textfield', itemCls: 'required', labelStyle: 'padding-left: 20px;width: auto;',
								labelSeparator: '', allowBlank: true,
								autoCreate: { tag: 'input', type: 'text', size: 10, maxlength: '8' }
							}	
						    ]
						  }
						]
					},
					{
			             fieldLabel: 'Are you familiar with the Wilton Method of cake decorating?',
						 xtype: 'radiogroup', name: 'familiarwm', id: 'familiarwm', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'familiarwm', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'familiarwm', inputValue: 'n' }
			             ]
			        },
					{
						fieldLabel: 'If Yes, how did you learn it?',
						name: 'howlearnedwm', xtype: 'combo', labelSeparator: '',
						labelStyle: 'margin-left: 20px;width: auto;',
						store: store = new Ext.data.SimpleStore({
							fields: ['title'],
							data: [['Wilton Class'],['Friends or Family'],['From Wilton Books'],['On My Own'],['Other Class']]
						}),
						valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local', allowBlank: true,
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
					},
					{
						fieldLabel: 'How long have you been decorating cakes?',
						name: 'yearsdecorating', xtype: 'combo', labelSeparator: '', itemCls: 'required',
						store: store = new Ext.data.SimpleStore({
							fields: ['title'],
							data: [['Less than 1 year'],['1-3 Years'],['4-6 Years'],['7-10 Years'],['Over 10 Years']]
						}),
						valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
					},
					{
			             fieldLabel: 'For whom?',
						 xtype: 'checkboxgroup', name: 'forwhomdecorating', id: 'forwhomdecorating', itemCls: 'required checkboxgroup',
						 allowBlank: false, labelSeparator: '', columns: [ 120, 120],
			             items: [
			                 {boxLabel: 'Friends/Family', name: 'forwhomdecorating', inputValue: 'friends family' },
			                 {boxLabel: 'Professionally', name: 'forwhomdecorating', inputValue: 'professionally' }
			             ]
			        },
					{
						layout: 'table',
						defaults: { layout: 'form' }, cls: 'padbottom indent', layoutConfig: { columns: 3 },
						items: [
						  { colspan: 3, items: {
									text: 'If professionally, please list the two most recent companies (bakery, cake shop, etc.) ', 
									colspan: 3, xtype: 'label', itemCls: 'required', ctCls: 'x-form-item', cls: 'x-form-item-label', width: 600
								}
						  },
						  { width: 230, ctCls: 'tableheader', items: { text: 'Company Name', xtype: 'label' } },
						  { width: 180, ctCls: 'tableheader', items: { text: 'City', xtype: 'label' } },
						  { width: 180, ctCls: 'tableheader', items: { text: 'State/Province', xtype: 'label' } },
						  { items: {
									hideLabel: true, name: 'profdecoratingname1', xtype: 'textfield', itemCls: 'required', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
								}
						  },
						  { items: {
									hideLabel: true, name: 'profdecoratinglocation1', xtype: 'textfield', itemCls: 'required', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '40' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'profdecoratingstate1', xtype: 'combo', itemCls: 'required', allowBlank: true,
									store: statesds, displayField: 'state', valueField: 'stateabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: true,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									hideLabel: true, name: 'profdecoratingname2', xtype: 'textfield', itemCls: 'required', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
								}
						  },
						  { items: {
									hideLabel: true, name: 'profdecoratinglocation2', xtype: 'textfield', itemCls: 'required', allowBlank: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '40' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'profdecoratingstate2', xtype: 'combo', itemCls: 'required', allowBlank: true,
									store: statesds, displayField: 'state', valueField: 'stateabv',
									autoWidth: true, mode: 'local', typeAhead: true, editable: true,
									forceSelection: true, triggerAction: 'all'
								}
						  }
						]
					} // end fieldset
				]
			}		
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-1'); }, scope: this },	
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-3'); }, scope: this }
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-2');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-2').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-3').enable(); 
						else this.setTabStates(3,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 2

	var sc3 = new Ext.FormPanel({
		id: 'form3', labelAlign: 'left', labelWidth: 290, buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'takenclasses', mapping: 'TAKENCLASSES' },
				{ name: 'takenclassesname1', mapping: 'CLASSESTAKENCLASSNAME1' },
				{ name: 'takenclasseswhen1', mapping: 'CLASSESTAKENWHENTAKEN1' },
				{ name: 'takenclassesfacility1', mapping: 'CLASSESTAKENFACILITY1' },
				{ name: 'takenclassesfname1', mapping: 'CLASSESTAKENINSTRUCTORFIRSTNAME1' },
				{ name: 'takenclasseslname1', mapping: 'CLASSESTAKENINSTRUCTORLASTNAME1' },
				{ name: 'takenclassesname2', mapping: 'CLASSESTAKENCLASSNAME2' },
				{ name: 'takenclasseswhen2', mapping: 'CLASSESTAKENWHENTAKEN2' },
				{ name: 'takenclassesfacility2', mapping: 'CLASSESTAKENFACILITY2' },
				{ name: 'takenclassesfname2', mapping: 'CLASSESTAKENINSTRUCTORFIRSTNAME2' },
				{ name: 'takenclasseslname2', mapping: 'CLASSESTAKENINSTRUCTORLASTNAME2' },
				{ name: 'takenclassesname3', mapping: 'CLASSESTAKENCLASSNAME3' },
				{ name: 'takenclasseswhen3', mapping: 'CLASSESTAKENWHENTAKEN3' },
				{ name: 'takenclassesfacility3', mapping: 'CLASSESTAKENFACILITY3' },
				{ name: 'takenclassesfname3', mapping: 'CLASSESTAKENINSTRUCTORFIRSTNAME3' },
				{ name: 'takenclasseslname3', mapping: 'CLASSESTAKENINSTRUCTORLASTNAME3' },
				{ name: 'takenclassesname4', mapping: 'CLASSESTAKENCLASSNAME4' },
				{ name: 'takenclasseswhen4', mapping: 'CLASSESTAKENWHENTAKEN4' },
				{ name: 'takenclassesfacility4', mapping: 'CLASSESTAKENFACILITY4' },
				{ name: 'takenclassesfname4', mapping: 'CLASSESTAKENINSTRUCTORFIRSTNAME4' },
				{ name: 'takenclasseslname4', mapping: 'CLASSESTAKENINSTRUCTORLASTNAME4' },
				{ name: 'taughtclasses', mapping: 'TAUGHTCLASSES' },
				{ name: 'taughtclassesname1', mapping: 'CLASSESTAUGHTCLASSNAME1' },
				{ name: 'taughtclasseswhen1', mapping: 'CLASSESTAUGHTWHENTAUGHT1' },
				{ name: 'taughtclassesfacility1', mapping: 'CLASSESTAUGHTFACILITY1' },
				{ name: 'taughtclassesname2', mapping: 'CLASSESTAUGHTCLASSNAME2' },
				{ name: 'taughtclasseswhen2', mapping: 'CLASSESTAUGHTWHENTAUGHT2' },
				{ name: 'taughtclassesfacility2', mapping: 'CLASSESTAUGHTFACILITY2' },
				{ name: 'taughtclassesname3', mapping: 'CLASSESTAUGHTCLASSNAME3' },
				{ name: 'taughtclasseswhen3', mapping: 'CLASSESTAUGHTWHENTAUGHT3' },
				{ name: 'taughtclassesfacility3', mapping: 'CLASSESTAUGHTFACILITY3' },
				{ name: 'taughtclassesname4', mapping: 'CLASSESTAUGHTCLASSNAME4' },
				{ name: 'taughtclasseswhen4', mapping: 'CLASSESTAUGHTWHENTAUGHT4' },
				{ name: 'taughtclassesfacility4', mapping: 'CLASSESTAUGHTFACILITY4' }
			]
		),
		items: [
			{
				xtype: 'fieldset', title: 'Classes Taken', layout: 'form', autoHeight: true,
				items: [
					{
			             fieldLabel: 'Have you ever taken any cake-decorating classes?',
						 xtype: 'radiogroup', name: 'takenclasses', id: 'takenclasses', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'takenclasses', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'takenclasses', inputValue: 'n' }
			             ]
			        },
					{
						layout: 'table', cls: 'padbottom', defaults: { layout: 'form' }, layoutConfig: { columns: 5 },
						items: [
						  { colspan: 5, items: {
									text: 'If Yes, please describe below:', xtype: 'label', itemCls: 'required', width: 500,
									ctCls: 'x-form-item', cls: 'x-form-item-label', style: { display: 'block'}
								}
						  },
						  { width: 240, ctCls: 'tableheader', items: { text: 'Name of Class', xtype: 'label' } },
						  { width: 170, ctCls: 'tableheader', items: { text: 'When Taken', xtype: 'label' } },
						  { width: 180, ctCls: 'tableheader', items: { text: 'Store/Facility', xtype: 'label' } },
						  { width: 150, ctCls: 'tableheader', items: { text: 'Instructor First Name', xtype: 'label' } },
						  { width: 150, ctCls: 'tableheader', items: { text: 'Instructor Last Name', xtype: 'label' } },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclassesname1', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, listWidth: 320, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclasseswhen1', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'takenclassesfacility1', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 26, maxlength: '60' }
								}
						  },
						  { items: {
									name: 'takenclassesfname1', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: {
									name: 'takenclasseslname1', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclassesname2', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclasseswhen2', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'takenclassesfacility2', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 26, maxlength: '60' }
								}
						  },
						  { items: {
									name: 'takenclassesfname2', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: {
									name: 'takenclasseslname2', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },  
						  { items: { 
									hideLabel: true, hiddenName: 'takenclassesname3', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclasseswhen3', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'takenclassesfacility3', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 26, maxlength: '60' }
								}
						  },
						  { items: {
									name: 'takenclassesfname3', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: {
									name: 'takenclasseslname3', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclassesname4', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'takenclasseswhen4', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'takenclassesfacility4', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 26, maxlength: '60' }
								}
						  },
						  { items: {
									name: 'takenclassesfname4', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  },
						  { items: {
									name: 'takenclasses-lname4', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 20, maxlength: '30' }
								}
						  }
						]
					}
				]
			},	// end fieldset classes taken	
			{
				xtype: 'fieldset', title: 'Classes Taught', layout: 'form', autoHeight: true,
				items: [
					{
			             fieldLabel: 'Have you ever taught cake decorating classes?',
						 xtype: 'radiogroup', name: 'taughtclasses', id: 'taughtclasses', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'taughtclasses', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'taughtclasses', inputValue: 'n' }
			             ]
			        },
					{
						layout: 'table', cls: 'padbottom', defaults: { layout: 'form' }, layoutConfig: { columns: 3 },
						items: [
						  { colspan: 3, items: {
									text: 'If Yes, please describe below:', xtype: 'label', itemCls: 'required',
									ctCls: 'x-form-item', cls: 'x-form-item-label', width: 500, style: { display: 'block'}
								}
						  },				  
						  { width: 240, ctCls: 'tableheader', items: { text: 'Name or Specific Topic of Class', xtype: 'label' } },
						  { width: 170, ctCls: 'tableheader', items: { text: 'When Taught?', xtype: 'label' } },
						  { width: 180, ctCls: 'tableheader', items: { text: 'Store/Facility', xtype: 'label' } },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclassesname1', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, listWidth: 320, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclasseswhen1', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'taughtclassesfacility1', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '60' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclassesname2', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclasseswhen2', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'taughtclassesfacility2', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '60' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclassesname3', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclasseswhen3', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'taughtclassesfacility3', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '60' }
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclassesname4', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: classesds, displayField: 'title', valueField: 'value',
									width: 220, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: { 
									hideLabel: true, hiddenName: 'taughtclasseswhen4', xtype: 'combo', itemCls: 'required', 
									allowBlank: true, store: whends, displayField: 'title', valueField: 'value',
									width: 150, mode: 'local', typeAhead: true, editable: false,
									forceSelection: true, triggerAction: 'all'
								}
						  },
						  { items: {
									name: 'taughtclassesfacility4', xtype: 'textfield',  hideLabel: true,
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '60' }
								}
						  }
						]
					}
				]
			} // end fieldset classes taught	
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-2'); }, scope: this },	
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-4'); }, scope: this }
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-3');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-3').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-4').enable(); 
						else this.setTabStates(4,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 3

	var sc4 = new Ext.FormPanel({
		id: 'form4', labelAlign: 'top', buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'buttercream', mapping: 'BUTTERCREAM' },
				{ name: 'royalicing', mapping: 'ROYALICING' },
				{ name: 'fondant', mapping: 'FONDANT' },
				{ name: 'gumpaste', mapping: 'GUMPASTE' },
				{ name: 'shellborder', mapping: 'SHELLBORDER' },
				{ name: 'basketweave', mapping: 'BASKETWEAVE' },
				{ name: 'pipedflowers', mapping: 'PIPEDFLOWERS' },
				{ name: 'tieredcakes', mapping: 'TIEREDCAKES' },
				{ name: 'candymolding', mapping: 'CANDYMOLDING' },
				{ name: 'gingerbread', mapping: 'GINGERBREAD' },
				{ name: 'roses', mapping: 'ROSES' },
				{ name: 'additionalskills', mapping: 'ADDITIONALSKILLS' }
			]
		),
		items: [
			{
                xtype: 'fieldset', title: 'Decorating Skills', layout: 'form', autoHeight: true,
				items: [	
					{
						layout: 'table', cls: 'padbottom', defaults: { layout: 'form' }, layoutConfig: { columns: 7 },
						items: [
						  { colspan: 7, items: {
								text: 'Please Indicate Your Level of Proficiency in Each of the Following Skills:', xtype: 'label', 
								ctCls: 'x-form-item', cls: 'x-form-item-label required', style: { display: 'block'}
								}
						  },
						  { width: '150', ctCls: 'tableheader', items: { text: 'Skill', xtype: 'label' } },
						  { width: '80', ctCls: 'tableheader', items: { text: '0 (N/A)', xtype: 'label' } },
						  { width: '80', ctCls: 'tableheader', items: { text: '1 (Tried It)', xtype: 'label' } },
						  { width: '80', ctCls: 'tableheader', items: { text: '2', xtype: 'label' } },
						  { width: '80', ctCls: 'tableheader', items: { text: '3', xtype: 'label' } },
						  { width: '80', ctCls: 'tableheader', items: { text: '4', xtype: 'label' } },
						  { width: '100', ctCls: 'tableheader', items: { text: '5 (Highly Skilled)', xtype: 'label' } },	
						  { items: { text: 'Buttercream', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'buttercream', id: 'buttercream', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'buttercream', inputValue: '0' },
					                 { name: 'buttercream', inputValue: '1' },
					                 { name: 'buttercream', inputValue: '2' },
					                 { name: 'buttercream', inputValue: '3' },
					                 { name: 'buttercream', inputValue: '4' },
					                 { name: 'buttercream', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Royal Icing', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'royalicing', id: 'royalicing', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'royalicing', inputValue: '0' },
					                 { name: 'royalicing', inputValue: '1' },
					                 { name: 'royalicing', inputValue: '2' },
					                 { name: 'royalicing', inputValue: '3' },
					                 { name: 'royalicing', inputValue: '4' },
					                 { name: 'royalicing', inputValue: '5' }
					             ]
						        }
						  },
						  
						  { items: { text: 'Rolled Fondant', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'fondant', id: 'fondant', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'fondant', inputValue: '0' },
					                 { name: 'fondant', inputValue: '1' },
					                 { name: 'fondant', inputValue: '2' },
					                 { name: 'fondant', inputValue: '3' },
					                 { name: 'fondant', inputValue: '4' },
					                 { name: 'fondant', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Gum Paste', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'gumpaste', id: 'gumpaste', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'gumpaste', inputValue: '0' },
					                 { name: 'gumpaste', inputValue: '1' },
					                 { name: 'gumpaste', inputValue: '2' },
					                 { name: 'gumpaste', inputValue: '3' },
					                 { name: 'gumpaste', inputValue: '4' },
					                 { name: 'gumpaste', inputValue: '5' }
					             ]
						        }
						  },	  
						  { items: { text: 'Shell Border', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'shellborder', id: 'shellborder', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'shellborder', inputValue: '0' },
					                 { name: 'shellborder', inputValue: '1' },
					                 { name: 'shellborder', inputValue: '2' },
					                 { name: 'shellborder', inputValue: '3' },
					                 { name: 'shellborder', inputValue: '4' },
					                 { name: 'shellborder', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Basketweave', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'basketweave', id: 'basketweave', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'basketweave', inputValue: '0' },
					                 { name: 'basketweave', inputValue: '1' },
					                 { name: 'basketweave', inputValue: '2' },
					                 { name: 'basketweave', inputValue: '3' },
					                 { name: 'basketweave', inputValue: '4' },
					                 { name: 'basketweave', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Piped Flowers', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'pipedflowers', id: 'pipedflowers', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'pipedflowers', inputValue: '0' },
					                 { name: 'pipedflowers', inputValue: '1' },
					                 { name: 'pipedflowers', inputValue: '2' },
					                 { name: 'pipedflowers', inputValue: '3' },
					                 { name: 'pipedflowers', inputValue: '4' },
					                 { name: 'pipedflowers', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Tiered Cakes', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'tieredcakes', id: 'tieredcakes', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'tieredcakes', inputValue: '0' },
					                 { name: 'tieredcakes', inputValue: '1' },
					                 { name: 'tieredcakes', inputValue: '2' },
					                 { name: 'tieredcakes', inputValue: '3' },
					                 { name: 'tieredcakes', inputValue: '4' },
					                 { name: 'tieredcakes', inputValue: '5' }
					             ]
						        }
						  },						  
						  { items: { text: 'Candy Molding', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'candymolding', id: 'candymolding', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'candymolding', inputValue: '0' },
					                 { name: 'candymolding', inputValue: '1' },
					                 { name: 'candymolding', inputValue: '2' },
					                 { name: 'candymolding', inputValue: '3' },
					                 { name: 'candymolding', inputValue: '4' },
					                 { name: 'candymolding', inputValue: '5' }
					             ]
						        }
						  },
						  { items: { text: 'Gingerbread', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'gingerbread', id: 'gingerbread', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'gingerbread', inputValue: '0' },
					                 { name: 'gingerbread', inputValue: '1' },
					                 { name: 'gingerbread', inputValue: '2' },
					                 { name: 'gingerbread', inputValue: '3' },
					                 { name: 'gingerbread', inputValue: '4' },
					                 { name: 'gingerbread', inputValue: '5' }
					             ]
						        }
						  },						  
						  { items: { text: 'Roses', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'radiogroup', name: 'roses', id: 'roses', hideLabel: true, itemCls: 'required checkboxgroup',
								 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 80, 80, 80],
					             items: [
					                 { name: 'roses', inputValue: '0' },
					                 { name: 'roses', inputValue: '1' },
					                 { name: 'roses', inputValue: '2' },
					                 { name: 'roses', inputValue: '3' },
					                 { name: 'roses', inputValue: '4' },
					                 { name: 'roses', inputValue: '5' }
					             ]
						        }
						  }
						]
					},
					{
						fieldLabel: 'What additional cake decorating/confectionary arts skills do you possess?', 
						name: 'additionalskills', xtype: 'textarea', labelSeparator: '', allowBlank: true,
						height: 100, width: 600, grow: false
					}
				]
			} // end fieldset
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-3'); }, scope: this },	
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-5'); }, scope: this }		
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-4');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-4').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-5').enable(); 
						else this.setTabStates(5,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 4

	var sc5 = new Ext.FormPanel({
		id: 'form5', labelAlign: 'top', buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'whywmi', mapping: 'WHYWMI' },
				{ name: 'lastcake', mapping: 'LASTCAKE' },
				{ name: 'personalsuccess', mapping: 'PERSONALSUCCESS' },
				{ name: 'lastevent', mapping: 'LASTEVENT' },
				{ name: 'presentation', mapping: 'PRESENTATION' },
				{ name: 'procedures', mapping: 'PROCEDURES' }
			]
		),
		items: [
			{
				xtype: 'fieldset', title: 'Please Tell Us About Yourself', layout: 'form', autoHeight: true,
				items: [
					{
						fieldLabel: 'Why do you want to be a Wilton Method Instructor?', 
						name: 'whywmi', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 600, grow: false, height: 100
					},
					{
						fieldLabel: 'When was the last time you made a cake?  Were you pleased with your results?', 
						name: 'lastcake', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 600, grow: false, height: 100
					},
					{
						fieldLabel: 'Describe something you have done on your own that you consider your greatest success?', 
						name: 'personalsuccess', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 600, grow: false, height: 100
					},

					{
						fieldLabel: 'What was the last event you attended?  Did you arrive early, on-time or late?', 
						name: 'lastevent', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 600, grow: false, height: 100
					},
					{
						fieldLabel: 'Have you ever given a presentation to a small group?  If so, please tell us about it.', 
						name: 'presentation', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 600, grow: false, height: 100
					},
					{
						fieldLabel: 'Briefly describe a current or past job (paid or unpaid) that required following policies and submitting paperwork on a regular basis.  How did you feel about these requirements?', 
						name: 'procedures', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						labelStyle: 'width:600px;display:block;margin-bottom:0;', width: 600, grow: false, height: 100
					}
				]
			}		
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-4'); }, scope: this },	
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-6'); }, scope: this }		
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-5');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-5').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-6').enable(); 
						else this.setTabStates(6,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 5

	var sc6 = new Ext.FormPanel({
		id: 'form6', labelAlign: 'left', labelWidth: 400, buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'availmon', mapping: 'AVAILMON' },
				{ name: 'availtues', mapping: 'AVAILTUES' },
				{ name: 'availwed', mapping: 'AVAILWED' },
				{ name: 'availthurs', mapping: 'AVAILTHURS' },
				{ name: 'availfri', mapping: 'AVAILFRI' },
				{ name: 'availsat', mapping: 'AVAILSAT' },
				{ name: 'availsun', mapping: 'AVAILSUN' },
				{ name: 'hoursperweek', mapping: 'HOURSPERWEEK' },
				{ name: 'multipleaccounts', mapping: 'MULTIPLEACCOUNTS' },
				{ name: 'inschool', mapping: 'INSCHOOL' },
				{ name: 'schoolhours', mapping: 'SCHOOLHOURS' },
				{ name: 'employed', mapping: 'EMPLOYED' },
				{ name: 'transportation', mapping: 'TRANSPORTATION' },
				{ name: 'traveldistance', mapping: 'TRAVELDISTANCE' },
				{ name: 'travellocations', mapping: 'TRAVELLOCATIONS' }
			]
		),
		items: [
			{
				xtype: 'fieldset', title: 'Your Availability', layout: 'form', autoHeight: true,
				items: [
					{
						layout: 'table', cls: 'padbottom', defaults: { layout: 'form' },
						layoutConfig: { columns: 4 },
						items: [ 
						{ width: '150', ctCls: 'tableheader', items: { text: 'Day of Week', xtype: 'label' } }, 
						{ width: '150', ctCls: 'tableheader', items: { text: 'Mornings (10-12)', xtype: 'label' } }, 
						{ width: '150', ctCls: 'tableheader', items: { text: 'Afternoons (1-4)', xtype: 'label' } }, 
						{ width: '150', ctCls: 'tableheader', items: { text: 'Evenings (6-9)', xtype: 'label' } }, 
						  { items: { text: 'Monday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availmon', id: 'availmon', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availmon', inputValue: 'morning' },
					                 { name: 'availmon', inputValue: 'afternoon' },
					                 { name: 'availmon', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Tuesday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availtues', id: 'availtues', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availtues', inputValue: 'morning' },
					                 { name: 'availtues', inputValue: 'afternoon' },
					                 { name: 'availtues', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Wednesday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availwed', id: 'availwed', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availwed', inputValue: 'morning' },
					                 { name: 'availwed', inputValue: 'afternoon' },
					                 { name: 'availwed', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Thursday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availthurs', id: 'availthurs', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availthurs', inputValue: 'morning' },
					                 { name: 'availthurs', inputValue: 'afternoon' },
					                 { name: 'availthurs', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Friday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availfri', id: 'availfri', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availfri', inputValue: 'morning' },
					                 { name: 'availfri', inputValue: 'afternoon' },
					                 { name: 'availfri', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Saturday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availsat', id: 'availsat', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availsat', inputValue: 'morning' },
					                 { name: 'availsat', inputValue: 'afternoon' },
					                 { name: 'availsat', inputValue: 'evening' }
					             ]
						        }
						  },						  
						  { items: { text: 'Sunday', xtype: 'label' } },
						  { colspan: 6, items: {
								 xtype: 'checkboxgroup', name: 'availsun', id: 'availsun', hideLabel: true, itemCls: 'checkboxgroup',
								 allowBlank: true, labelSeparator: '', columns: [ 150, 150, 150],
					             items: [
					                 { name: 'availsun', inputValue: 'morning' },
					                 { name: 'availsun', inputValue: 'afternoon' },
					                 { name: 'availsun', inputValue: 'evening' }
					             ]
						        }
						  }
						]
					},
					{
						fieldLabel: 'Maximum hours per week you\'re available for demonstrations or classes?',
						name: 'hoursperweek', xtype: 'combo', labelSeparator: '', itemCls: 'required',
						store: store = new Ext.data.SimpleStore({
							fields: ['title'], data: [['3-6 Hrs'],['7-10 Hrs'],['11-14 Hrs'],['14 Hrs or More']]
						}),
						valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
					},
					{
			             fieldLabel: 'Would you be interested in handling more than one account?',
						 xtype: 'radiogroup', name: 'multipleaccounts', id: 'multipleaccounts', itemCls: 'required',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'multipleaccounts', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'multipleaccounts', inputValue: 'n' }
			             ]
			        },
					{
			             fieldLabel: 'Are you currently attending school?',
						 xtype: 'radiogroup', name: 'inschool', id: 'inschool', itemCls: 'required',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'inschool', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'inschool', inputValue: 'n' }
			             ]
			        },
					{
						fieldLabel: 'If yes, how many credit hours?',
						name: 'schoolhours', xtype: 'combo', labelSeparator: '',
						store: store = new Ext.data.SimpleStore({
							fields: ['title'],
							data: [['1-7 Credit Hours'],['8 or more Credit Hours'],['Non-credit (or Continuing Ed)']]
						}),
						valueField: 'title', displayField: 'title', width: 190, mode: 'local',
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
					},
					{
			             fieldLabel: 'Are you currently employed outside the home?',
						 xtype: 'radiogroup', name: 'employed', id: 'employed', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'employed', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'employed', inputValue: 'n' }
			             ]
			        },
					{
			             fieldLabel: 'Do you have your own transportation?',
						 xtype: 'radiogroup', name: 'transportation', id: 'transportation', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'transportation', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'transportation', inputValue: 'n' }
			             ]
			        },
					{
						fieldLabel: 'How far are you willing to travel on a regular basis to teach classes?',
						name: 'traveldistance', xtype: 'combo', labelSeparator: '', itemCls: 'required',
						store: store = new Ext.data.SimpleStore({
							fields: ['title'],
							data: [['1-5 miles'],['6-10 miles'],['11-15 miles'],['16-20 miles'],['21-25 miles'],['26 miles or more']]
						}),
						valueField: 'title', displayField: 'title', autoWidth: true, mode: 'local',
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all'
					},
					{
						fieldLabel: 'Please list suburbs or towns that fall within this range where you would be willing to teach.', 
						name: 'travellocations', xtype: 'textarea', labelSeparator: '', itemCls: 'required', allowBlank: false,
						width: 300, grow: false, height: 100
					}
				]
			}
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-5'); }, scope: this },	
			{ text: 'Continue', formBind: true, handler: function() { this.showTab('tab-7'); }, scope: this }		
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-6');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
					if( !Ext.getCmp('tabpanel').getItem('tab-6').disabled ) {
						if( isvalid ) Ext.getCmp('tabpanel').getItem('tab-7').enable(); 
						else this.setTabStates(7,'disable');						
					}
				}, scope: this
			}
		}
	}); // end screen 6

	var sc7 = new Ext.FormPanel({
		id: 'form7', labelAlign: 'left', labelWidth: 450, buttonAlign: 'center', monitorValid: true,
		reader: new Ext.data.JsonReader({ 
				root: 'data', totalProperty: 'recordcount', successProperty: 'success'
			},  
			[
				{ name: 'languages', mapping: 'LANGUAGES' },
				{ name: 'otherlanguages', mapping: 'OTHERLANGUAGES' },
				{ name: 'productreservations', mapping: 'PRODUCTRESERVATIONS' },
				{ name: 'productreservationreason', mapping: 'PRODUCTRESERVATIONREASON' },
				{ name: 'hobbies', mapping: 'HOBBIES' },
				{ name: 'conflicts', mapping: 'CONFLICTS' },
				{ name: 'comments', mapping: 'COMMENTS' },
				{ name: 'referralsource', mapping: 'REFERRALSOURCE' },
				{ name: 'referralnewspaper', mapping: 'REFERRALNEWSPAPER' },
				{ name: 'newspapercity', mapping: 'NEWSPAPERCITY' },
				{ name: 'newspaperstate', mapping: 'NEWSPAPERSTATE' },
				{ name: 'referralposter', mapping: 'REFERRALPOSTER' },
				{ name: 'postercity', mapping: 'POSTERCITY' },
				{ name: 'posterstate', mapping: 'POSTERSTATE' },
				{ name: 'referralfirstname', mapping: 'REFERRALFIRSTNAME' },
				{ name: 'referrallastname', mapping: 'REFERRALLASTNAME' },
				{ name: 'referralwmi', mapping: 'REFERRALWMI' },
				{ name: 'referralother', mapping: 'REFERRALOTHER' }
			]
		),
		items: [
			{
				xtype: 'fieldset', title: 'Other Information', layout: 'form', autoHeight: true,
				items: [
					{
			             fieldLabel: 'Are you fluent in any of the following languages? (check all that apply)',
						 xtype: 'checkboxgroup', name: 'languages', id: 'languages', itemCls: 'required checkboxgroup',
						 allowBlank: false, labelSeparator: '', columns: [ 80, 80, 80, 130],
			             items: [
			                 {boxLabel: 'English', name: 'languages', inputValue: 'English' },
			                 {boxLabel: 'Spanish', name: 'languages', inputValue: 'Spanish' },
			                 {boxLabel: 'French', name: 'languages', inputValue: 'French' },
			                 {boxLabel: 'Sign Language', name: 'languages', inputValue: 'Sign Language' }
			             ]
			        },
					{ 
						fieldLabel: 'Other languages', name: 'otherlanguages', xtype: 'textfield', allowBlank: true,
						autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '60' }
					},
					{
			             fieldLabel: 'Do you have any reservations about recommending Wilton products and methods exclusively?',
						 xtype: 'radiogroup', name: 'productreservations', id: 'productreservations', itemCls: 'required radiogroup',
						 allowBlank: false, labelSeparator: '', columns: [ 60, 60],
			             items: [
			                 {boxLabel: 'Yes', name: 'productreservations', inputValue: 'y' },
			                 {boxLabel: 'No', name:  'productreservations', inputValue: 'n' }
			             ],
						 listeners: {
						 	change: {
								fn: function(radiogrp, radio) {
									var f = radiogrp.findParentByType(Ext.form.FormPanel).getForm();
									var cmp = Ext.getCmp('reservationspanel');
									if( radio.inputValue == 'y') {
										cmp.show();
										cmp.getEl().repaint();
										f.findField('productreservationreason').allowBlank = false;
									}
									else {
										cmp.hide();
										f.findField('productreservationreason').allowBlank = true;
									}
								}
							}
						 }
			        },				
					{
						layout: 'table', id: 'reservationspanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield' },
						items: [
						  { items: {
								fieldLabel: 'If yes, why?', name: 'productreservationreason', xtype: 'textarea', labelSeparator: '', 
								labelStyle: 'padding-left: 20px;width: auto;', itemCls: 'required', allowBlank: true, width: 400, grow: false, height: 100
							}
						  }
						]
					},			
					{
						fieldLabel: 'Hobbies or crafts in which you engage:',
						name: 'hobbies', xtype: 'textarea', labelSeparator: '', allowBlank: true, width: 400, grow: false, height: 100
					},
					{
						fieldLabel: 'Is there anything that may cause you to reconsider this position between now and the time you are recommended for placement?', 
						name: 'conflicts', xtype: 'textarea', labelSeparator: '', allowBlank: false, itemCls: 'required', width: 400, grow: true, growmax: 200
					},
					{
						fieldLabel: 'What questions, observations, or comments do you have?', 
						name: 'comments', xtype: 'textarea', labelSeparator: '', allowBlank: true, width: 400, grow: false, height: 100
					},
					
					{
						fieldLabel: 'How did you find out about becoming a Wilton Method Instructor?',
						hiddenName: 'referralsource', xtype: 'combo', labelSeparator: '', itemCls: 'required',
						store: store = new Ext.data.SimpleStore({
							fields: ['title','value'],
							data: [['Newspaper','Newspaper'], 
								   ['Referred by WMI','RefWMI'], 
								   ['Poster','Poster'],
								   ['Wilton Book or Video','W Pub'],
								   ['E-mail from Wilton','eLtr'],
								   ['Account Newsletter for WMIs','NL Acct'],
								   ['Internet (Monster, CareerBuilders, etc.)','Web Other'],
								   ['DOII Newsletter','NL DOII'],
								   ['Wilton Website','Web Wilton'],
								   ['Postcard from Wilton','State Ltr'],
								   ['ICES Newsletter','NL ICES'],
								   ['Wilton Course or Workshop','W Crs III'],
								   ['Other','Other']
								  ]
						}),
						valueField: 'value', displayField: 'title', width: 250, mode: 'local',
						typeAhead: false, editable: false, forceSelection: true, triggerAction: 'all',
						listeners: {
						  	select: {
						  		fn: function(combo, record, index){
									var f = combo.findParentByType(Ext.form.FormPanel).getForm();
									Ext.getCmp('referralnewspaperpanel').hide();
									Ext.getCmp('referralposterpanel').hide();
									Ext.getCmp('referralinstructorpanel').hide();
									Ext.getCmp('referralotherpanel').hide();
									f.findField('referralnewspaper').allowBlank = true;
									f.findField('newspapercity').allowBlank = true;
									f.findField('newspaperstate').allowBlank = true;
									f.findField('referralposter').allowBlank = true;
									f.findField('postercity').allowBlank = true;
									f.findField('posterstate').allowBlank = true;
									f.findField('referralwmi').allowBlank = true;
									f.findField('referralfirstname').allowBlank = true;
									f.findField('referrallastname').allowBlank = true;
									f.findField('referralother').allowBlank = true;
									
									switch(combo.value) {
									case 'Newspaper':
										Ext.getCmp('referralnewspaperpanel').show();
										Ext.getCmp('referralnewspaperpanel').getEl().repaint();
										f.findField('referralnewspaper').allowBlank = false;
										f.findField('newspapercity').allowBlank = false;
										f.findField('newspaperstate').allowBlank = false;
										break;
									case 'Poster':
										Ext.getCmp('referralposterpanel').show();
										Ext.getCmp('referralposterpanel').getEl().repaint();
										f.findField('referralposter').allowBlank = false;
										f.findField('postercity').allowBlank = false;
										f.findField('posterstate').allowBlank = false;
										break;
									case 'RefWMI':
										Ext.getCmp('referralinstructorpanel').show();
										Ext.getCmp('referralinstructorpanel').getEl().repaint();
										f.findField('referralfirstname').allowBlank = false;
										f.findField('referrallastname').allowBlank = false;
										break;
									case 'Other':
										Ext.getCmp('referralotherpanel').show();
										Ext.getCmp('referralotherpanel').getEl().repaint();
										f.findField('referralother').allowBlank = false;
										break;
									}
						  		}, scope: this
						  	}
						}
					},
					{
						layout: 'table', id: 'referralnewspaperpanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: [
						  		{
									fieldLabel: 'Name of Newspaper', name: 'referralnewspaper', itemCls: 'required', allowBlank: true,
									labelStyle: 'padding-left: 20px;width: auto;', autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
								},
								{
									fieldLabel: 'City', name: 'newspapercity', itemCls: 'required', allowBlank: true,
									labelStyle: 'padding-left: 20px;width: auto;', autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '30' }
								},
								{ 
									fieldLabel: 'State/Province', hiddenName: 'newspaperstate', xtype: 'combo', itemCls: 'required', allowBlank: true,
									store: statesds, displayField: 'state', valueField: 'stateabv', labelStyle: 'padding-left: 20px;width: auto;',
									autoWidth: true, mode: 'local', typeAhead: true, editable: true, forceSelection: true, triggerAction: 'all'
								}
							]
						  }
						]
					},			
					{
						layout: 'table', hidden: true, id: 'referralposterpanel', hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: [
						  			{
										fieldLabel: 'Name of store with poster', name: 'referralposter', itemCls: 'required', allowBlank: true,
										labelStyle: 'padding-left: 20px;width: auto;',
										autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '40' }
									},
									{
										fieldLabel: 'City', name: 'postercity', itemCls: 'required', allowBlank: true,
										labelStyle: 'padding-left: 20px;width: auto;',
										autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '30' }
									},
									{ 
										fieldLabel: 'State/Province', hiddenName: 'posterstate', xtype: 'combo', itemCls: 'required', allowBlank: true,
										store: statesds, displayField: 'state', valueField: 'stateabv', labelStyle: 'padding-left: 20px;width: auto;',
										autoWidth: true, mode: 'local', typeAhead: true, editable: true, forceSelection: true, triggerAction: 'all'
									}
							]
						  }
						]
					},
					{
						layout: 'table', hidden: true, id: 'referralinstructorpanel', hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: [{
									fieldLabel: 'Instructor First Name', name: 'referralfirstname', itemCls: 'required', allowBlank: true,
									labelStyle: 'padding-left: 20px;width: auto;',
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '30' }
								},
								{
									fieldLabel: 'Last Name', name: 'referrallastname', itemCls: 'required', allowBlank: true,
									labelStyle: 'padding-left: 20px;width: auto;',
									autoCreate: { tag: 'input', type: 'text', size: 30, maxlength: '30' }
								},
								{
									fieldLabel: 'Instructor # (8 digit numeric portion)', name: 'referralwmi', itemCls: 'required', allowBlank: true,
									labelStyle: 'padding-left: 20px;width: auto;',
									autoCreate: { tag: 'input', type: 'text', size: 8, maxlength: '8' }
								}
							]
						  }
						]
					},
					{
						layout: 'table', id: 'referralotherpanel', hidden: true, hideMode: 'offsets',
						defaults: { layout: 'form', defaultType: 'textfield', style: 'padding-right: 10px' },
						items: [
						  { items: {
									fieldLabel: 'Other Referral', name: 'referralother', xtype: 'textfield', 
									itemCls: 'required', allowBlank: true, labelStyle: 'padding-left: 20px;width: auto;',
									autoCreate: { tag: 'input', type: 'text', size: 40, maxlength: '60' }
								}
						  }
						]
					}
				]
			} // end fieldset
		],
		buttons: [
			{ text: 'Back', formBind: false, handler: function() { this.showTab('tab-6'); }, scope: this },	
			{ text: 'Submit', formBind: true, handler: this.submitform, scope: this }
		],
		listeners: {
			clientvalidation: {
				fn: function(fp, isvalid) {
					var tp = Ext.getCmp('tabpanel');
					var p = tp.getItem('tab-7');
					if (isvalid) {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabincompleteicon', 'tabcompleteicon');
					}
					else {
						Ext.fly(tp.getTabEl(p)).child('.x-tab-strip-text').replaceClass('tabcompleteicon', 'tabincompleteicon');						
					}
				}, scope: this
			}
		}
	}); // end screen 7

	var tabpanel = new Ext.TabPanel({
		  id: 'tabpanel', activeTab: 0, plain: true, autoHeight: true, width: 900,
		  deferredRender: true,  layoutOnTabChange: true,
		  defaults:{ autoScroll: true, layout: 'form', border: false, frame: true, autoHeight: true},
          items: [{ id: 'tab-1', title:'General Information', iconCls: 'tabincompleteicon', iconAlign: 'right', items: sc1 },
		  		  { id: 'tab-2', title:'Background', iconCls: 'tabincompleteicon', disabled: true, items: sc2 },
				  { id: 'tab-3', title:'Classes', iconCls: 'tabincompleteicon', disabled: true, items: sc3 },
				  { id: 'tab-4', title:'Decorating Skills', iconCls: 'tabincompleteicon', disabled: true, items: sc4 },
				  { id: 'tab-5', title:'About Yourself', iconCls: 'tabincompleteicon', disabled: true, items: sc5 },
				  { id: 'tab-6', title:'Availability', iconCls: 'tabincompleteicon', disabled: true, items: sc6 },
				  { id: 'tab-7', title:'Other Information', iconCls: 'tabincompleteicon', disabled: true, items: sc7 }
          		 ]
			});
	
    // public space
    return {
        // public properties, e.g. strings to translate
		applicantid: '',
		
        // public methods
        init: function(opts) {
			applicantid = opts.applicantid;
			var contentdiv = Ext.get('contentpanel');
			contentdiv.insertHtml('afterBegin','<div id="requiredfields">* You must fill out all fields in bold to continue on to the next screen.</div>');
			tabpanel.render('contentpanel');
			if( applicantid != '') loadapplicant();
        }
    };
}(); // end of app
