﻿var fullName;
var street;
var city;
var state;
var zip;
var emailAddress;
var telephone;
var requestType;
var comments;

function controlsInit()
{
	fullName = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: fullNameID,
		tabIndex: 1,
		vtype: 'name',
		width: 150
	});
	Ext.form.FormPanel.controls.add('fullName', fullName);

	street = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: streetID,
		tabIndex: 2,
		width: 150
	});
	Ext.form.FormPanel.controls.add('street', street);

	city = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: cityID,
		tabIndex: 3,
		vtype: 'name',
		width: 150
	});
	Ext.form.FormPanel.controls.add('city', city);

	state = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: stateID,
		tabIndex: 4,
		vtype: 'name',
		width: 150
	});
	Ext.form.FormPanel.controls.add('state', state);

	zip = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: zipID,
		tabIndex: 5,
		vtype: 'zipcode',
		width: 150
	});
	Ext.form.FormPanel.controls.add('zip', zip);

	emailAddress = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: emailAddressID,
		blankText: 'Either Email Address or Telephone are required.',
		tabIndex: 6,
		vtype: 'email',
		width: 150
	});
	
	emailAddress.on('change', function(){
		telephone.allowBlank = emailAddress.getValue() != '';
	});
	
	Ext.form.FormPanel.controls.add('emailAddress', emailAddress);

	telephone = new Ext.form.TextField(
	{
		allowBlank: false,
		applyTo: telephoneID,
		blankText: 'Either Email Address or Telephone are required.',
		tabIndex: 7,
		vtype: 'phonenumber',
		width: 150
	});
	
	telephone.on('change', function(){
		emailAddress.allowBlank = telephone.getValue() != '';
	});
	
	Ext.form.FormPanel.controls.add('telephone', telephone);
	
	requestType = new Ext.form.ComboBox(
	{
		editable: false,
		forceSelection: true,
		tabIndex: 8,
		transform: requestTypeID,
		triggerAction: 'all',
		width: 150
	});
	Ext.form.FormPanel.controls.add('requestType', requestType);
	
	comments = new Ext.form.TextArea(
	{
		allowBlank: true,
		applyTo: commentsID,
		width: 500,
		height: 200,
		tabIndex: 9
	});
	Ext.form.FormPanel.controls.add('comments', comments);
}