/*!
 * Ext JS Library 3.1.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
 
// some data used in the examples
 
 
Ext.onReady(function(){
    var winlogin;
    var buttonaddreview = Ext.get('login-btn');
    var buttonaddreview2 = Ext.get('login-btn2');
    var buttonaddreview3 = Ext.get('login-btn3');
    var buttonaddreview4 = Ext.get('login-btn4');



if( buttonaddreview == null) {}else{
    buttonaddreview.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!winlogin){
            winlogin = new Ext.Window({
                applyTo:'login-win',
                layout:'fit',
                width:400,
				height:280,
                closeAction:'hide',
                plain: true,
				x:100,
				y:50,
                items: simplelogin
            });
        }
        winlogin.show(this);

    });
} // end if
	
	
if( buttonaddreview2 == null) {}else{		
    buttonaddreview2.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!winlogin){
            winlogin = new Ext.Window({
                applyTo:'login-win',
                layout:'fit',
                width:400,
				height:280,
                closeAction:'hide',
                plain: true,
				x:100,
				y:50,
                items: simplelogin
            });
        }
        winlogin.show(this);

    });		
} // end if
	
	if( buttonaddreview3 == null) {}else{
		
    buttonaddreview3.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!winlogin){
            winlogin = new Ext.Window({
                applyTo:'login-win',
                layout:'fit',
                width:400,
				height:280,
                closeAction:'hide',
                plain: true,
				x:100,
				y:50,
                items: simplelogin
            });
        }
        winlogin.show(this);

    });		
	}
		if( buttonaddreview4 == null) {}else{
		
    buttonaddreview4.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!winlogin){
            winlogin = new Ext.Window({
                applyTo:'login-win',
                layout:'fit',
                width:400,
				height:280,
                closeAction:'hide',
                plain: true,
				x:100,
				y:50,
                items: simplelogin
            });
        }
        winlogin.show(this);

    });		
		}
		
		


	    var simplelogin = new Ext.FormPanel({
        labelAlign: 'left',
        frame:true,
        title: '<table><td><img src="/images/mascot/oscar_pointing_right.png" width="120" height="136" align=left/></td><td align=center><font size=+2>Please login below:</font></td></table>',				
        bodyStyle:'padding:5px 5px 0',
        width: 400,
		defaultType: 'textfield',
        labelWidth: 120,

        items: [
                {
					xtype: 'textfield',
					name: 'email',
            		fieldLabel: 'Your email address',					
				    emptyText:'email address',
					anchor:'95%'
        },{
            		xtype:'textfield',
					name: 'pass',					
            		fieldLabel: 'Your password',					
    		        emptyText:'password',
		            anchor:'95%'

        }
		],


        buttons: [{
            text: 'Login',
			 handler: function(){
            simplelogin.form.submit({
                //url:'json-form-submit.cfm', // Coldfusion 
                url:'http://www.europe.org/members/login-js.html', // PHP
                waitMsg:'Checking, logging-in...',
                success: function (form, action) {
					winlogin.hide();

                    Ext.MessageBox.alert('', '<b><font size=+2>You are now logged-in');
					
					setTimeout('window.location.reload()',1250);				
                },
                failure:function(form, action) {
                    Ext.MessageBox.alert('Message', 'Invalid email address and/or password, please try again!');
                }
            });
        }

        }]
		
    });
		
});
