/**
 * @author mcmichae
 */

 var hasSubmitted = false;
	var ourStates = [
        ['AL', 'Alabama', 'The Heart of Dixie'],
        ['AK', 'Alaska', 'The Land of the Midnight Sun'],
        ['AZ', 'Arizona', 'The Grand Canyon State'],
        ['AR', 'Arkansas', 'The Natural State'],
        ['CA', 'California', 'The Golden State'],
        ['CO', 'Colorado', 'The Mountain State'],
        ['CT', 'Connecticut', 'The Constitution State'],
        ['DE', 'Delaware', 'The First State'],
        ['DC', 'District of Columbia', "The Nation's Capital"],
        ['FL', 'Florida', 'The Sunshine State'],
        ['GA', 'Georgia', 'The Peach State'],
        ['HI', 'Hawaii', 'The Aloha State'],
        ['ID', 'Idaho', 'Famous Potatoes'],
        ['IL', 'Illinois', 'The Prairie State'],
        ['IN', 'Indiana', 'The Hospitality State'],
        ['IA', 'Iowa', 'The Corn State'],
        ['KS', 'Kansas', 'The Sunflower State'],
        ['KY', 'Kentucky', 'The Bluegrass State'],
        ['LA', 'Louisiana', 'The Bayou State'],
        ['ME', 'Maine', 'The Pine Tree State'],
        ['MD', 'Maryland', 'Chesapeake State'],
        ['MA', 'Massachusetts', 'The Spirit of America'],
        ['MI', 'Michigan', 'Great Lakes State'],
        ['MN', 'Minnesota', 'North Star State'],
        ['MS', 'Mississippi', 'Magnolia State'],
        ['MO', 'Missouri', 'Show Me State'],
        ['MT', 'Montana', 'Big Sky Country'],
        ['NE', 'Nebraska', 'Beef State'],
        ['NV', 'Nevada', 'Silver State'],
        ['NH', 'New Hampshire', 'Granite State'],
        ['NJ', 'New Jersey', 'Garden State'],
        ['NM', 'New Mexico', 'Land of Enchantment'],
        ['NY', 'New York', 'Empire State'],
        ['NC', 'North Carolina', 'First in Freedom'],
        ['ND', 'North Dakota', 'Peace Garden State'],
        ['OH', 'Ohio', 'The Heart of it All'],
        ['OK', 'Oklahoma', 'Oklahoma is OK'],
        ['OR', 'Oregon', 'Pacific Wonderland'],
        ['PA', 'Pennsylvania', 'Keystone State'],
        ['RI', 'Rhode Island', 'Ocean State'],
        ['SC', 'South Carolina', 'Nothing Could be Finer'],
        ['SD', 'South Dakota', 'Great Faces, Great Places'],
        ['TN', 'Tennessee', 'Volunteer State'],
        ['TX', 'Texas', 'Lone Star State'],
        ['UT', 'Utah', 'Salt Lake State'],
        ['VT', 'Vermont', 'Green Mountain State'],
        ['VA', 'Virginia', 'Mother of States'],
        ['WA', 'Washington', 'Green Tree State'],
        ['WV', 'West Virginia', 'Mountain State'],
        ['WI', 'Wisconsin', "America's Dairyland"],
        ['WY', 'Wyoming', 'Like No Place on Earth']
    ];
	
	var contactForm = null;
	function displayForm()
	{
		Ext.BLANK_IMAGE_URL = '../ext-3.0.3/resources/images/default/s.gif';
		Ext.QuickTips.init();
    	Ext.form.Field.prototype.msgTarget = 'side';
    	var bd = Ext.get('formDiv');

		if (contactForm == null) 
		{
			contactForm = new Ext.FormPanel(
			{
				labelWidth: 100, // label settings here cascade unless overridden
				//draggable:false,
				id: 'ourContactForm',
				//url:'foo.php',
				//method: 'POST',
				monitorValid: true,
				frame: true,
				buttonAlign: 'center',
				//title: 'Request for Additional Information:',
				bodyStyle: 'padding:5px 5px 0',
				width:500,
				defaults: {
					width: 350
				},
				defaultType: 'textfield',
				
				items: [{
					fieldLabel: 'First Name',
					name: 'firstName',
					allowBlank: false
				
				}, {
					fieldLabel: 'Last Name',
					name: 'lastName',
					allowBlank: false
				}, {
					fieldLabel: 'Address(1)',
					name: 'addressOne',
					allowBlank: true
				}, {
					fieldLabel: 'Address(2)',
					name: 'addressTwo',
					allowBlank: true
				}, {
					fieldLabel: 'City',
					name: 'cityName',
					allowBlank: true
				}, new Ext.form.ComboBox({
					fieldLabel: 'State',
					hiddenName: 'stateCode',
					mode: 'local',
					listWidth: 180,
					//allowBlank:true,
					store: new Ext.data.ArrayStore({
						fields: ['abbr', 'stateName', 'stateDescription'],
						data: ourStates
					}),
					valueField: 'abbr',
					displayField: 'stateName',
					typeAhead: true,
					triggerAction: 'all',
					emptyText: 'Select a state ...',
					selectOnFocus: true
				}), {
					fieldLabel: 'Zipcode',
					name: 'zipCode',
					allowBlank: true
				}, {
					fieldLabel: 'Company',
					name: 'companyName',
					allowBlank: true
				}, {
					fieldLabel: 'Contact PH#',
					name: 'contactPhone',
					allowBlank: true
				}, {
					fieldLabel: 'Email',
					name: 'emailAddress',
					id: 'emailAddress',
					allowBlank: false,
					vtype: 'email'
				}, {
					xtype:'displayfield',
					value:'PLEASE LEAVE A COMMENT:'
				}, {
					
					name: 'requestComment',
					allowBlank: true,
					height:125,
					xtype:'htmleditor',
					defaultValue:' '
				}
				//,{
				//	fieldLabel: 'Receive Mailings',
				//	name: 'onMailingList',
				//	xtype: 'checkbox',
				//	inputValue: 'true'
				//}
				],
				
				buttons: [{
					text: 'Send',
					formBind: true,
					handler: function()
							{
								//Ext.Msg.alert('Values : ' + Ext.getCmp('ourContactForm').getForm().getValues().first);
								//alert('---' + Ext.getCmp('ourContactForm').getForm().getValues().requestComment);
								xajax_formContactSave.submitInfo(Ext.getCmp('ourContactForm').getForm().getValues());
							}

				}
				//, {
				//	text: 'Cancel',
				//	handler: function(){
											//document.getElementById('formDiv').style.display = 'none';
											//document.getElementById('logoDiv').style.display = 'block';
				//						}
				//}
				]
			});
			

			contactForm.on('render', 	function(form)
										{
											Ext.getCmp('ourContactForm').getForm().submit();
										});
			
			contactForm.render(document.getElementById('formDiv'));
		}
	}
	function completeForm()
	{
		Ext.destroy(Ext.getCmp('ourContactForm'));
		//Ext.MessageBox.alert('Request for Information Sent', 'Thank you for submitting your request.');
		//document.getElementById('logoDiv').style.display = 'block';
		document.getElementById('formDiv').innerHTML = ' Your request for information has been sent.';
		hasSubmitted = true;
	}
