function login(data, config)
{
	var form = $('#form');
	
	//if we were logged in
	if(data.userid)
	{
		form
			.find('form').remove().end()
			.find('#logged-in').show()
				.find('span').html(data.user_alias);
	}
	else if(config.type == 'login')
	{
		form.find('.notice').show().find('div').html('Invalid username or password.');
	}
	
	if(config.type == 'form')
		form_update(data, config);
}

function login_submit(form)
{
	//submit the request
	$(form).ajaxSubmit(
		{
			iframe: false,
			success: function(data) { login(data, {type: 'login', form: form}); },
			error: form_error,
			dataType: 'json'
		}
	);
	
	return false;
}