	function getLoginWindow(sHttp,redirectUrl)
	{		
		if (typeof(window.loginWindow) == 'object')
		{
			window.loginWindow.mask.show();
			return window.loginWindow.show();
		}


		var simple = new Ext.form.FormPanel({

        	 submit: function() {
        		if (simple.getForm().isValid())
	            {
	            	Ext.Ajax.request({
	            		url: sHttp,
		            	form: simple.getForm().getEl().dom,
		            	extform: simple.getForm(),
		            	success: function(r,o)
		            	{
							try{
								var response = Ext.decode(r.responseText);
								if (response.valid)
								{
									if (!redirectUrl)
									{
										document.location.reload();
									}
									else
									{
										document.location.href = redirectUrl;
									}
								}
								else
								{
									o.extform.setValues([{id:'login_form_password', value:''}]);
									o.extform.clearInvalid();
									o.extform.markInvalid([{id:'login_form_name',msg: response.msg}]);
									Ext.Msg.show({
									   title:'Error',
									   msg: response.msg,
									   buttons: Ext.Msg.OK,
									   icon: Ext.MessageBox.ERROR
									});
								}
							}
							catch (e)
							{
								if (!redirectUrl)
								{
									document.location.reload();
								}
								else
								{
									document.location.href = redirectUrl;
								}
							}
		            	}
	            	});
            	//this.getForm().getEl().dom.submit();
            	}
            },
            method:'post',
	        labelWidth: 100, // label settings here cascade unless overridden
	        url: document.location.href,
	        frame:true,
	        title: false,
	        bodyStyle:'padding:5px 5px 0',
	        width: 360,
	        defaults: {width: 230},
	        defaultType: 'textfield',

	        items: [{
	                id: 'login_form_name',
	                fieldLabel: 'Username',
	                name: 'login_form_name',
	                allowBlank:false,
	                 growMax: 32
	            },{
	                id: 'login_form_password',
	                fieldLabel: 'Password',
	                inputType :'password',
	                name: 'login_form_password',
	                allowBlank:false,
	                growMax: 64
	            },new Ext.form.Checkbox({
	                fieldLabel: 'Remember me',
	                inputType :'checkbox',
	                name: 'remember_username',
	                id: 'remember_username',
	                width:20,
	                checked : Ext.Options.remember_username,
            		defaults: {width: 10},
            		itemCls   : 'x-checkbox'
	            }),{
		            xtype:'fieldset',
		            width: 300,
		            style:'border:none;padding:0',
		            labelWidth: 200,
		            autoHeight:true,
		            defaults: {width: 210},
		            defaultType: 'textfield',
		            collapsed: false,
		            items :[{
			                fieldLabel: '<a href=\'' +sHttp + 'reminder/\'> Forgot your password?</a>',
			                  labelSeparator :'',
			                 inputType :'label',
			                 labelWidth: 200,
			                 width: 1,
			                 hidden:true
			            }
		            ]
		        }
	        ],

	        buttons: [{
	            text: 'Log In',
	            type: 'submit',
	             handler : function(el,event){
	             	simple.getForm().submit();
	             }
	        },{
	            text: 'Cancel',
	             handler : function(){
	             	window.loginWindow.hide();
	             	//window.loginWindow.mask.hide();
	             }

	        },{
	            text: 'Register Now',
	             handler : function(){
					document.location.href = getBaseUrl('appRootUrl') + 'signup/';
	             }

	        }]
	    });

		    simple.render(Ext.get('login_form_container'));
		    if (Ext.Options.username)
		    {
		    	simple.getForm().items.items[0].setValue(Ext.Options.username);
		    }

			var map = new Ext.KeyMap(simple.el, {
			    key: Ext.EventObject.ENTER,
			    fn: function(){
			    		this.submit();
			    },
			    scope: simple
			});
			window.loginWindow =  new Ext.Window({
						width: 380,
						autoHeight: true,
						closable:false
						,title: 'Login Form'
						,style: 'z-index:99999'
						,layout: 'fit'
						,items: [simple],
						modal:true
						//mask: new Ext.LoadMask(Ext.Options.bodyElement,{msg:false})
					});
		//window.loginWindow.mask.show();
		return window.loginWindow.show();
	}
