Ext.ns('com.quizzpot.tutorial');

//Ext.BLANK_IMAGE_URL = '../ext-3.0.0/resources/images/default/s.gif';

com.quizzpot.tutorial.SubmitFormTutorial = {
	init: function(){
		Ext.QuickTips.init();

formvalidacio = new Ext.form.FormPanel({
	//url: 'simplevalidations.php',
	border:false,
	labelWidth: 80,
        
	defaults: {
		xtype:'textfield',
		width: 150
	},

	items:[
		{fieldLabel:'Nombre',name:'txt-name',width: 200,allowBlank:false,maxLength:20,vtype:'alpha'},
		{fieldLabel:'Contraseña',name:'txt-password',width: 200,allowBlank:false,maxLength:64,inputType:'password'}
	]
});

		winvalidacio = new Ext.Window({
			id:'mywin',
			title: 'Validación',
			bodyStyle: 'padding:10px;background-color:#fff;',
			width:400,
			height:150,
                        modal:true,
			items:[formvalidacio],
			buttonAlign: 'right', //botones alineados a la derecha
                                buttons:[{
                                    text:'Enter',
                                    handler:function(){
                                        formvalidacio.getForm().submit({
                                            method:'POST',
                                            waitTitle:'Conectando',
                                            waitMsg:'Enviando datos...',
                                            url:rutabase+'main/validacion',
                                            success:function(){                                             
                                                winvalidacio.hide();
                                                window.location=rutabase+'home'
                                            },
                                            failure:function(form, action){
                                                /*if(action.failureType == 'server'){
                                                    obj = Ext.util.JSON.decode(action.response.responseText);
                                                    Ext.Msg.alert('Oops!', obj.errors.reason);
                                                }else{
                                                    Ext.Msg.alert('Oops!', 'Authentication server is unreachable');
                                                }*/
                                                winvalidacio.hide();
                                                window.location=rutabase +'main'
                                            }
                                        })
                                    }
                                }
                                ] //botones del formulario
                            });

                            winvalidacio.show();

	}

	
}

Ext.onReady(com.quizzpot.tutorial.SubmitFormTutorial.init,com.quizzpot.tutorial.SubmitFormTutorial);

