$(document).ready(init);

function init()
{
	$("#forgot_email").val($("#login_email").val());
	$("#login_email").keyup(function()
	{
		$("#forgot_email").val($("#login_email").val());
	});
	
	$("#forgot_submit").click(validate);
}


function validate()
{
	var email=$("#forgot_email").val();
	
	if (email=='')
	{
		$("#forgot_email").addClass('input_err');
		$("#forgot_error").html('Please type in an email address first.');
		return false;
	}
	
	else if (! is_email(email))
	{
		$("#forgot_email").addClass('input_err');
		$("#forgot_error").html('<b>' + email + '</b> is not a valid email address.');
		return false;
	}
	
	else
	{
		$("#forgot_email").removeClass();
		$("#forgot_error").html('');
		document.forgot_form.submit();
	}
}

function is_email(str)
{
	var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

	if (str.search(validRegExp) == -1)
		return false;
	else
		return true;
		
}
