function dologinbouncewithlogin(formname, emailfield, passwordfield) {

	Ext.Ajax.request({
		url: '/?event=cmp.loginbounce.checkuserloggedin',
		success: function(a, b) {
			resp = Ext.decode(a.responseText);
			
			if(resp.USERLOGGEDIN == 1) {

				Ext.Msg.show({
					title: getLanguageText('defaults.hint'),
					msg: getLanguageText('loginbounce.userloggedin.' + resp.DOLOGOUT),
					buttons: Ext.Msg.OKCANCEL,
					fn: function (c) {
						if(c == 'cancel') 
							location.href = '/';
						else 
							document.getElementsByName(formname)[0].submit();
					}
				});
				
			} else {
				document.getElementsByName(formname)[0].submit();
			}
		}, 
		params: { 
			email: document.getElementById(emailfield).value,
			password: document.getElementById(passwordfield).value
		}
	});
	
	return false;
	
}

function dologinbounceformsubmitwithlogin (formname, emailfield, passwordfield) {
	
	dologinbouncewithlogin(formname, emailfield, passwordfield);
	
}


function showLoginBounceMessage(logouttype) {
	
	Ext.Msg.show({
		title: getLanguageText('defaults.hint'),
		msg: getLanguageText('loginbounce.logouthint.' + logouttype),
		buttons: Ext.Msg.OK,
		fn: function (c) {
			if(logouttype) {
				location.href = '/';				
			}
		}
	});
	
}
