/**
 * @author Stan
 */
Ext.onReady(function(){
    Ext.QuickTips.init();
 
	var txtsenha = new Ext.form.TextField({
		fieldLabel:'Senha', 
        name:'pws', 
        inputType:'password', 
        allowBlank:false,
		enableKeyEvents: true,
		value: '123456'
	});
	
	txtsenha.on('keyup',function(t,e){
		if(e.getKey()==13){
			submitForm();
		}
	});
		 
    var login = new Ext.FormPanel({ 
        labelWidth:80,
        url:'login.php',
		iconCls: 'logout',
        frame:true, 
        title:'Login', 
        width:230, 
        padding:200, 
        defaultType:'textfield',
		monitorValid:true,

        items:[{ 
                fieldLabel:'Usuário', 
                name:'usr',
				value:'demo',
                allowBlank:false 
            },txtsenha
        ],
 
        buttons:[{ 
                text:'Login',
                formBind: true,	 
                
                handler:submitForm 
            }] 
    });
	
	function submitForm(){
		login.getForm().submit({ 
        method:'POST', 
        waitTitle:'Conectando', 
        waitMsg:'Enviando informações...',
		success: function(){
			var redirect = 'home.php';
			window.location = redirect;
		} 
        });
	};
     
    var win = new Ext.Window({
        layout:'fit',
        width:300,
        height:150,
        closable: false,
        resizable: false,
        plain: true,
        items: [login]
	});
	win.show();
});