function ShowLoginWindow() 
{	
  var login = new Ext.FormPanel(
  {
    labelWidth: 80,
    url: 'login.aspx',
    frame: true,
    border: false,
    height: 119,      
    bodyStyle:'padding: 10px 0 5px 5px; background: transparent;',      
    defaults: {width: 180},
    defaultType: 'textfield',
    monitorValid: true,

    items: [
    {
      fieldLabel: 'Email Address',
      name: 'emailAddress',
      vtype:'email',
      allowBlank: false
    },
    {
      fieldLabel: 'Password',
      name: 'loginPassword',
      inputType: 'password',
      allowBlank: false
    }],
     
    buttons: [
    {
      text: 'Login',
      //formBind: true,
      // Function that fires when user clicks the button 
      handler: function()
      {
        login.getForm().submit(
        {
          method: 'POST',
          waitTitle: 'Connecting',
          waitMsg: 'Sending data...',

          // Functions that fire (success or failure) when the server responds. 
          // The one that executes is determined by the 
          // response that comes from login.asp as seen below. The server would 
          // actually respond with valid JSON, 
          // something like: response.write "{ success: true}" or 
          // response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}" 
          // depending on the logic contained within your server script.
          // If a success occurs, the user is notified with an alert messagebox, 
          // and when they click "OK", they are redirected to whatever page
          // you define as redirect. 

          success: function(form, action)
          {
            Ext.Msg.alert('Login Successful', action.result.msg, function(btn, text)
            {
              if (btn == 'ok')
              {
                loginWindow.hide();
                var redirect = 'default2.aspx';
                window.location = redirect;
              }
            });
          },

          // Failure function, see comment above re: success and failure. 
          // You can see here, if login fails, it throws a messagebox
          // at the user telling him / her as much.  

          failure: function(form, action)
          {
//            if (a.failureType == "server" && a.result != null)
//            {
//              // an error was found when parsing the rating on the server
//              Ext.Msg.alert('Warning', a.result.message);
//            }
//            else
//            {
//              // an error has occurred sending or receiving the response
//              Ext.Msg.alert('Warning', a.response.statusText);
//            }          
          
            if (action.failureType == 'server')
            {
              obj = Ext.util.JSON.decode(action.response.responseText);
              Ext.Msg.alert('Login Failed!', obj.errors.reason);
            } 
            else
            {
              Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
            }
            login.getForm().reset();
          }
        });
      }
//    },
//    {
//        text: 'Cancel',
//        handler: function() { loginWindow.hide(); }          
    }]
  });	


	var loginWindow = new Ext.Window({
	  title: 'Login',
		layout: 'form',
		width: 300,
		height: 150,
		modal: true,
		constrain: true,
		//closable: false,			
		resizable: false,	
		bodyBorder: false,
		border: false,
		bodyStyle:'padding: 3px 0;',	
		items: login
	});
	
	loginWindow.show();
}
