function staffLogin() {
	function goIntranet(resp) {
		var json = Ext.util.JSON.decode(resp.responseText);
		if(json.success) {
			user.number = json.usernumber;
			panel.close();
			Ext.Ajax.request({
				url: json.url,
				success: function(resp) {
					var json = Ext.util.JSON.decode(resp.responseText);
					switch(json.whatnow){
						case "managerspanel":
							var nextfunc = "managerPanel";
							if(Ext.isIE){
								window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'width=1084,height=798,scrollbars=1,menubar=1,location=0');
							} else {
								window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'width=1071,height=770,scrollbars=1,menubar=1,location=0');
							}
						break;
						case "intranetpanel":
							var nextfunc = "intranetPanel";
							if(Ext.isIE){
								window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'resizable=1, menubar=1,location=0');
							} else {
								window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'resizable=1, menubar=1,location=0');
							}
						break;
						case "adminpanel":
							var nextfunc = "adminPanel";
							window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'resizable=1, scrollbars=1, menubar=1,location=0');
						break;
						case "dataentry":
							var nextfunc = "dataEntryPanel";
							window.open("intranet.php?panel="+nextfunc+"&usernum="+user.number, '', 'width=836,height=670,menubar=1,location=0');
						break;
					}
				},
				failure: function(resp) {
					Ext.MessageBox.show({
						title: "Error Encountered",
						msg: "We have encountered an unexpected error and cannot proceed.  Contact Concepte and report this event.",
						buttons: Ext.MessageBox.OK
					});
				}
			});
		} else {
			Ext.MessageBox.show({
				title: "Login Incorrect",
				msg: 'The login information you have provided is incorrect.  Please try again.',
				buttons: Ext.MessageBox.OK
			});
		}
		// submit.enable();
	}

	function submitLogin() {
		submit.disable();
		var f = Ext.getCmp('loginform').getForm();
		Ext.Ajax.request({
			url: 'validateLogin.php',
			form: 'logform',
			success: goIntranet,
			failure: function(response) {
				submit.enable();
				Ext.MessageBox.show({
					title: "Communcation Error",
					msg: 'Unable to communicate with remote server.  Check your internet connection and/or server status.',
					buttons: Ext.MessageBox.OK
				});
			}
		});
	}

	function winclose() {
		panel.close();
	}

	function formreset() {
		loginform.getForm().setValues({loginid: '', passwd: ''});
		loginform.getForm().findField('loginid').focus(true, 250);
	}

	var submit = new Ext.Button({
        text: "Login",
        scope: this,
		handler: submitLogin
	});
	
	var placeFocus = function(item){
		switch(item){
			case "loginid":
				loginform.getForm().findField('passwd').focus(true, 250);
			break;
			default:
				submitLogin();
			break;
		}
	}
        	
	var loginform = new Ext.form.FormPanel({
        id: 'loginform',
		formId: 'logform',
        border: false,
        frame: true,
        height: 125,
		defaults: {
			validationEvent: false
		},
        buttons: [submit],
        items: [{
			xtype: 'textfield',
            id: 'loginid',
            fieldLabel: 'Login ID',
            maxLength: 20,
			width: 140,
            itemCls: 'loginform',
            allowBlank: false,
            labelWidth: 200
        },{
            id: 'passwd',
			xtype: 'textfield',
            fieldLabel: 'Password',
            maxLength: 10,
			width: 140,
            itemCls: 'loginform',
            labelWidth: 200,
            allowBlank: false,
            inputType: 'password'
        }],
        keys: [{
        	key: [10,13],
        	scope: this,
        	handler: function(t, e){
        		var target = Ext.EventObject.getTarget();
        		Ext.EventObject.stopEvent();
        		placeFocus(target.name)
        	}
        }]
    });
    var panel = new Ext.Window({
        height: 150,
        width: 275,
        shadow: 'drop',
        shadowOffset: 20,
        resizable: false,
        title: 'ICCI Staff Login',
        closeAction: 'close',
        items: [loginform]
    });
    panel.on({
    	'close': {
    		fn: function() {
    			login.enable();
    		}
    	},
    	'show' : {
    		fn: function() {
    			login.disable();
    		}
    	}
    })
    panel.show();
    loginform.getForm().findField('loginid').focus(true, 250);
}
