﻿// JScript File

var loginForm = function(){
	var formData;
	var netData = {
			txtFname: '',
			txtLname: ''
		};	
	
	return {
	    getCategoryId: function(){
	        return formData.ddl
	    },
	    formFields: function(){ return formData; },
        isValid: function(){ return formData.isValid(); },
	    getValues: function(){
	        var tmp = this.getValues2().split('&');
	        
	        var vF = new Array();
	        var 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 vF.join('&');
	        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();

			// turn on validation errors beside the field globally
			Ext.form.Field.prototype.msgTarget = 'side';
			formData = new Ext.form.Form({
				labelAlign: 'left',
				labelWidth: 91,
				buttonAlign: 'right'
			});

						
			formData.fieldset(
				{id:'cf', legend:'Login'},			
				
				new Ext.form.TextField({
					fieldLabel:'User Name',
					name:'txtUserName1',
					allowBlank:false
				}),
				
				new Ext.form.TextField({
					fieldLabel:'Password',
					name:'txtPassword1',
					inputType:'password',
					allowBlank:false 
				})
			);		
			
		    
			formData.applyIfToFields({
				width: 200
			});
			
			//formData.addButton({text:'Forgot password', handler:function(){ location.href = "restorepassword.aspx"; }});
			formData.addButton({text:'Register', handler:function(){ location.href = "registration.aspx"; }});
			formData.addButton({text:'Login', handler:saveForm});

			formData.render('form-ct4');			
			
			Ext.get('fsHeader').insertAfter(Ext.get('cf').child('legend'));
		}
	};
}();
