
Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';
    
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

function newWin() {
    LoginWindow = Ext.extend(Ext.Window, {
        title :'美达网盘',
        width :265,
        height :180,
        modal :true,
        waitMsgTarget :true,
        resizable :false,
        closable : false,
        defaults : {
            border :false
        },
        buttonAlign :'center',

        createFormPanel : function() {
            return new Ext.form.FormPanel( {
                bodyStyle :'padding-top:6px',
                defaultType :'textfield',
                labelAlign :'right',
                labelWidth :55,
                labelPad :0,
                frame :true,
                /*
                 * defaults : { allowBlank :false, width :158 allowHeight :true },
                 */

                items : [ new Ext.form.FieldSet( {
                        title :'用户登录',
                        allowBlank :false,
                        autoHeight :true,
                        autoWidth :true,
                        defaultType :'textfield',
                        items : [ {
                                name :'userName',
                                id :'userName',
                                fieldLabel :'帐号',
                                blankText :'帐号不能为空',
                                allowBlank :false
                            }, {
                                name :'password',
                                id :'password',
                                fieldLabel :'密码',
                                blankText :'密码不能为空',
                                inputType :'password',
                                allowBlank :false
                            } ]
                    }) ]
            });
        },
        login : function() {
            this.fp.form.submit( {
                waitMsg : '正在验证合法性，请稍候...',
                method :"POST",
                url :'login/login.htm',
                success : function(form, action) {
                    //Ext.MessageBox.alert('提示', '验证成功');
                    //Ext.Load('登录','验证成功，正在登录...');
                    window.location.href = 'index.html';
                }
                /*
                    ,failure : function(form, action) {
                        form.reset();
                        alert(action.failureType);
                        alert(Ext.form.Action.SERVER_INVALID);
                        if (action.failureType == Ext.form.Action.SERVER_INVALID)
                            Ext.MessageBox.alert('警告', action.result.errors.msg);
                    }
                 */
            });
        },
        initComponent : function() {
            this.keys = {
                key :Ext.EventObject.ENTER,
                fn :this.login,
                scope :this
            };
            LoginWindow.superclass.initComponent.call(this);
            this.fp = this.createFormPanel();
            this.add(this.fp);
            this.addButton('登录', this.login, this);
            this.addButton('重置', function() {
                this.fp.form.reset();
            }, this);
        }
    });
    var win = new LoginWindow();
    win.show();
}
/*
Ext.onReady( function() {
    newWin();
})
*/