Ext.onReady(function(){

    Ext.QuickTips.init();
 	 
    var loginForm = new Ext.FormPanel({
        title: 'Amstel Contest CMS'
        ,labelWidth: 80
        ,url: base_url+admin_folder+'login/submit'
        ,frame: true
        ,items: [
            {
                xtype: 'textfield'
                ,fieldLabel: 'Username'
                ,name: 'loginUsername'
				,anchor: '100%'
            }
            ,{
                xtype: 'textfield'
                ,fieldLabel: 'Password' 
                ,name: 'loginPassword'
                ,inputType:'password'
				,anchor: '100%'
            }
            // ,{
            //     xtype: 'box'
            //     ,id: 'myCaptcha'
            //     ,autoEl: {
            //         tag: 'div'
            //     }
            // }
        ]   
        ,buttons: [
            { 
                text:'LOGIN'
                ,formBind: true 
                ,handler:function(){ 
                    loginForm.getForm().submit({ 
                        method:'POST'
                        ,success:function(form, action){
                            window.location.href = base_url+admin_url; 
						}  
                        ,failure:function(form, action){ 
                            loginForm.getForm().reset();
                            // grecaptcha.reset(); 
                        } 
                    }); 
                } 
            }
        ] 
    });
        
    var win = new Ext.Window({
        width:326
        ,closable: false
        ,resizable: false
        ,plain: true
        ,border: false
        ,items: [
            loginForm
        ]
	});

    if (top === self){
        var viewport = new Ext.Viewport({
            layout: 'anchor'
            ,style: {
                backgroundColor: '#e8eaec'
            }
            ,items: [win]
        });
        win.show();
    }
});