﻿// JScript File

var editForm = function(){
	var formData;
	var netData = { txtFname: '', txtLname: '' };	
	
	return {
        isValid: function(){ return formData.isValid(); },
	    getValues: function(){
	        var tmp = this.getValues2().split('&');
	        var vF = new Array(), vFi = 0;
	        
	        for (var i = 0; i < tmp.length; i++) {
	            var fn = tmp[i].split('=');
	            if (fn[0].substring(0,3) == 'ext') vF[vFi++] = tmp[i];
	        } return Ext.urlDecode(vF.join('&'));
	    },
	    
		getValues2: function(asString){
            var fs = Ext.lib.Ajax.serializeForm(document.forms[0]);
            if(asString == true) return fs;
            return fs; //Ext.urlDecode(fs);
		},
		setValues: function(arr){ formData.setValues(arr); },
		init: function() {
			Ext.QuickTips.init();

			Ext.form.Field.prototype.msgTarget = 'side';
			formData = new Ext.form.Form({ labelAlign: 'left', labelWidth: 100, buttonAlign: 'left' });

			formData.container( {id:'cf'},
				new Ext.form.TextField({ fieldLabel:'First Name', name:'txtFname', allowBlank:false }),
				new Ext.form.TextField({ fieldLabel:'Last Name', name:'txtLname' }),
				new Ext.form.TextField({ fieldLabel:'Company', name:'txtCompany' }),
				new Ext.form.TextField({ fieldLabel:'Phone', name:'txtPhone' }),
				new Ext.form.TextField({ fieldLabel:'EMail', name:'txtEmail', vtype: 'email', allowBlank:false }),
				new Ext.form.ComboBox({ fieldLabel:'Subject', value: 'General',
					store: new Ext.data.SimpleStore({ fields: ['text'], data : [ ['General'] ] }),
                    editable:false, valueField:'text', displayField:'text', mode: 'local', name:'subject',
					triggerAction: 'all', hiddenName: 'txtSubject', allowBlank:false
				}),

				new Ext.form.TextArea({ fieldLabel:'Details', height:'100', width: '244', name:'txtMsg' })
			);
		    
			formData.applyIfToFields({ width: 250 });
			formData.addButton({text:'Submit', handler:saveForm});
			formData.render('form-ct4');
			//Ext.get('fsHeader').insertAfter(Ext.get('cf').child('legend'));
		}
	};
}();
