﻿function LoginUser(email,password)
{
    if(email == '')
    {
        alert('You did not enter in your email address!');
        return false;
    }
    else
    {
        if(password == '')
        {
            alert('You did not enter in your password!');
            return false;
        }
        else
        {
            StartProcess(document.getElementById('spanLogin'),document.getElementById('spanLoginProgress'));
            Security.Login(email,password,LoginUserComplete);
        }
    }
}
function LoginUserComplete(result)
{
    EndProcess(document.getElementById('spanLogin'),document.getElementById('spanLoginProgress'));
    if(result=='success')
	{
		document.location = 'MoneyStores.aspx';
	}
	else
	{
		alert('Sorry, login failed. Please try again or click the request password link.');
	}
}

function Subscribe(email,password,fullname)
{	if(fullname == '')
    {
        alert('You did not enter in your full name!');
    }
    else
    {
        if(email == '')
        {
            alert('You did not enter in your email address!');
            return false;
        }
        else
        {
            if(password == '')
            {
                alert('You did not enter in your password!');
                return false;
            }
            else
            {
                StartProcess(document.getElementById('spanSubscribe'),document.getElementById('spanSubscribeProgress'));
                Security.Subscribe(email,password,fullname,SubscribeComplete);
            }
        }
    }
}
function SubscribeComplete(result)
{
    EndProcess(document.getElementById('spanSubscribe'),document.getElementById('spanSubscribeProgress'));
	if(result=='success')
	{
		document.location = 'MoneyStores.aspx';
	}
	else
	{
		alert('A subscriber with that email address already exists.');
	}
}